@univerjs/sheets-drawing-ui 0.12.3 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +2 -2
- package/lib/cjs/locale/ca-ES.js +1 -1
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/es-ES.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ja-JP.js +1 -1
- package/lib/cjs/locale/ko-KR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/facade.js +439 -395
- package/lib/es/index.js +1786 -1234
- package/lib/es/locale/ca-ES.js +15 -2
- package/lib/es/locale/en-US.js +13 -0
- package/lib/es/locale/es-ES.js +13 -0
- package/lib/es/locale/fa-IR.js +13 -0
- package/lib/es/locale/fr-FR.js +13 -0
- package/lib/es/locale/ja-JP.js +13 -0
- package/lib/es/locale/ko-KR.js +13 -0
- package/lib/es/locale/ru-RU.js +13 -0
- package/lib/es/locale/vi-VN.js +13 -0
- package/lib/es/locale/zh-CN.js +13 -0
- package/lib/es/locale/zh-TW.js +17 -4
- package/lib/facade.js +439 -395
- package/lib/index.css +1 -1
- package/lib/index.js +1786 -1234
- package/lib/locale/ca-ES.js +15 -2
- package/lib/locale/en-US.js +13 -0
- package/lib/locale/es-ES.js +13 -0
- package/lib/locale/fa-IR.js +13 -0
- package/lib/locale/fr-FR.js +13 -0
- package/lib/locale/ja-JP.js +13 -0
- package/lib/locale/ko-KR.js +13 -0
- package/lib/locale/ru-RU.js +13 -0
- package/lib/locale/vi-VN.js +13 -0
- package/lib/locale/zh-CN.js +13 -0
- package/lib/locale/zh-TW.js +17 -4
- package/lib/types/commands/commands/save-cell-images.command.d.ts +2 -0
- package/lib/types/facade/f-range.d.ts +40 -0
- package/lib/types/facade/f-worksheet.d.ts +29 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/types/locale/en-US.d.ts +13 -0
- package/lib/types/services/batch-save-images.service.d.ts +148 -0
- package/lib/types/services/canvas-float-dom-manager.service.d.ts +2 -0
- package/lib/types/views/batch-save-images/BatchSaveImagesDialog.d.ts +16 -0
- package/lib/types/views/batch-save-images/component-name.d.ts +16 -0
- package/lib/types/views/batch-save-images/index.d.ts +17 -0
- package/lib/types/views/menu/save-images.menu.d.ts +4 -0
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +16 -15
package/lib/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var kt=Object.defineProperty;var Wt=(s,r,t)=>r in s?kt(s,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[r]=t;var te=(s,r,t)=>Wt(s,typeof r!="symbol"?r+"":r,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@univerjs/engine-render"),b=require("@univerjs/sheets-ui"),l=require("@univerjs/core"),m=require("@univerjs/sheets-drawing"),y=require("@univerjs/sheets"),q=require("@univerjs/design"),ze=require("@univerjs/docs-ui"),j=require("@univerjs/drawing"),W=require("@univerjs/ui"),Rt=require("@univerjs/docs-drawing"),le=require("@univerjs/drawing-ui"),A=require("rxjs"),Z=require("react/jsx-runtime"),Ie=require("react");function K(s,r,t){const{from:e,to:n,flipY:i=!1,flipX:o=!1,angle:a=0,skewX:d=0,skewY:g=0}=s,u=t.getCurrent();if(u==null)return;const c=b.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:e,to:n},t);let{left:p,top:h,width:f,height:w}=c;const S=t.getCurrentSkeleton(),_=S.rowHeaderWidth+S.columnTotalWidth,I=S.columnHeaderHeight+S.rowTotalHeight;return p+f>_&&(p=_-f),h+w>I&&(h=I-w),{flipY:i,flipX:o,angle:a,skewX:d,skewY:g,left:p,top:h,width:f,height:w}}function G(s,r){const{left:t=0,top:e=0,width:n=0,height:i=0,flipY:o=!1,flipX:a=!1,angle:d=0,skewX:g=0,skewY:u=0}=s,c=r.getCellWithCoordByOffset(t,e);if(c==null)return;const p={column:c.actualColumn,columnOffset:k.precisionTo(t-c.startX,1),row:c.actualRow,rowOffset:k.precisionTo(e-c.startY,1)},h=r.getCellWithCoordByOffset(t+n,e+i);if(h==null)return;const f={column:h.actualColumn,columnOffset:k.precisionTo(t+n-h.startX,1),row:h.actualRow,rowOffset:k.precisionTo(e+i-h.startY,1)};return{flipY:o,flipX:a,angle:d,skewX:g,skewY:u,from:p,to:f}}const L={id:"sheet.operation.clear-drawing-transformer",type:l.CommandType.MUTATION,handler:(s,r)=>{const t=s.get(k.IRenderManagerService);return r.forEach(e=>{var n,i;(i=(n=t.getRenderById(e))==null?void 0:n.scene.getTransformer())==null||i.debounceRefreshControls()}),!0}},De={id:"sheet.command.remove-sheet-image",type:l.CommandType.COMMAND,handler:(s,r)=>{var I,C,R;const t=s.get(l.ICommandService),e=s.get(l.IUndoRedoService),n=s.get(y.SheetInterceptorService),i=s.get(m.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=[];o.forEach(D=>{const{unitId:M}=D;a.push(M)});const d=i.getBatchRemoveOp(o),{unitId:g,subUnitId:u,undo:c,redo:p,objects:h}=d,f=n.onCommandExecute({id:De.id,params:r}),w={id:m.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:p,objects:h,type:m.DrawingApplyType.REMOVE}},S={id:m.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:c,objects:h,type:m.DrawingApplyType.INSERT}};return l.sequenceExecute([...(I=f.preRedos)!=null?I:[],w,...f.redos],t)?(e.pushUndoRedo({unitID:g,undoMutations:[...(C=f.preUndos)!=null?C:[],S,...f.undos,{id:L.id,params:a}],redoMutations:[...(R=f.preRedos)!=null?R:[],w,...f.redos,{id:L.id,params:a}]}),!0):!1}},ut={id:"sheet.command.delete-drawing",type:l.CommandType.COMMAND,handler:s=>{const r=s.get(l.ICommandService),e=s.get(m.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const n=e[0].unitId,i=e.map(o=>{const{unitId:a,subUnitId:d,drawingId:g,drawingType:u}=o;return{unitId:a,subUnitId:d,drawingId:g,drawingType:u}});return r.executeCommand(De.id,{unitId:n,drawings:i})}};function Bt(s){const r=[];return s.forEach(t=>{const{parent:e,children:n}=t,{unitId:i,subUnitId:o,drawingId:a}=e,d=k.getGroupState(0,0,n.map(c=>c.transform||{})),g=n.map(c=>{const p=c.transform||{left:0,top:0},{unitId:h,subUnitId:f,drawingId:w}=c;return{unitId:h,subUnitId:f,drawingId:w,transform:{...p,left:p.left-d.left,top:p.top-d.top},groupId:a}}),u={unitId:i,subUnitId:o,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:d};r.push({parent:u,children:g})}),r}function Yt(s){const r=[];return s.forEach(t=>{const{parent:e,children:n}=t,{unitId:i,subUnitId:o,drawingId:a,transform:d={width:0,height:0}}=e;if(d==null)return;const g=n.map(c=>{const{transform:p}=c,{unitId:h,subUnitId:f,drawingId:w}=c,S=k.transformObjectOutOfGroup(p||{},d,d.width||0,d.height||0);return{unitId:h,subUnitId:f,drawingId:w,transform:S,groupId:void 0}}),u={unitId:i,subUnitId:o,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:g})}),r}const gt={id:"sheet.command.group-sheet-image",type:l.CommandType.COMMAND,handler:(s,r)=>{const t=s.get(l.ICommandService),e=s.get(l.IUndoRedoService),n=s.get(m.ISheetDrawingService);if(!r)return!1;const i=[];r.forEach(({parent:h,children:f})=>{i.push(h.unitId),f.forEach(w=>{i.push(w.unitId)})});const o=n.getGroupDrawingOp(r),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=o;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:Yt(c),type:m.DrawingApplyType.UNGROUP}},{id:L.id,params:i}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.GROUP}},{id:L.id,params:i}]}),!0):!1}},Ue={id:"sheet.command.insert-sheet-image",type:l.CommandType.COMMAND,handler:(s,r)=>{var I,C,R;const t=s.get(l.ICommandService),e=s.get(l.IUndoRedoService),n=s.get(m.ISheetDrawingService),i=s.get(y.SheetInterceptorService);if(!r)return!1;const o=r.drawings,a=o.map(D=>D.unitId),d=n.getBatchAddOp(o),{unitId:g,subUnitId:u,undo:c,redo:p,objects:h}=d,f=i.onCommandExecute({id:Ue.id,params:r}),w={id:m.SetDrawingApplyMutation.id,params:{op:p,unitId:g,subUnitId:u,objects:h,type:m.DrawingApplyType.INSERT}},S={id:m.SetDrawingApplyMutation.id,params:{op:c,unitId:g,subUnitId:u,objects:h,type:m.DrawingApplyType.REMOVE}};return l.sequenceExecute([...(I=f.preRedos)!=null?I:[],w,...f.redos],t)?(e.pushUndoRedo({unitID:g,undoMutations:[...(C=f.preUndos)!=null?C:[],S,...f.undos,{id:L.id,params:a}],redoMutations:[...(R=f.preRedos)!=null?R:[],w,...f.redos,{id:L.id,params:a}]}),!0):!1}},ht={id:"sheet.command.set-drawing-arrange",type:l.CommandType.COMMAND,handler:(s,r)=>{const t=s.get(l.ICommandService),e=s.get(l.IUndoRedoService);if(!r)return!1;const n=s.get(m.ISheetDrawingService),{unitId:i,subUnitId:o,drawingIds:a,arrangeType:d}=r,g={unitId:i,subUnitId:o,drawingIds:a};let u;if(d===l.ArrangeTypeEnum.forward?u=n.getForwardDrawingsOp(g):d===l.ArrangeTypeEnum.backward?u=n.getBackwardDrawingOp(g):d===l.ArrangeTypeEnum.front?u=n.getFrontDrawingsOp(g):d===l.ArrangeTypeEnum.back&&(u=n.getBackDrawingsOp(g)),u==null)return!1;const{objects:c,redo:p,undo:h}=u;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:p,unitId:i,subUnitId:o,objects:c,type:m.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:i,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:h,unitId:i,subUnitId:o,objects:c,type:m.DrawingApplyType.ARRANGE}}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:p,unitId:i,subUnitId:o,objects:c,type:m.DrawingApplyType.ARRANGE}}]}),!0):!1}},Ae={id:"sheet.command.set-sheet-image",type:l.CommandType.COMMAND,handler:(s,r)=>{const t=s.get(l.ICommandService),e=s.get(l.IUndoRedoService),n=s.get(m.ISheetDrawingService);if(!r)return!1;const{drawings:i}=r,o=n.getBatchUpdateOp(i),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=o;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:a,subUnitId:d,op:u,objects:c,type:m.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:g,objects:c,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[a]}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:u,objects:c,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[a]}]}),!0):!1}},pt={id:"sheet.command.ungroup-sheet-image",type:l.CommandType.COMMAND,handler:(s,r)=>{const t=s.get(l.ICommandService),e=s.get(l.IUndoRedoService),n=s.get(m.ISheetDrawingService);if(!r)return!1;const i=[];r.forEach(({parent:h,children:f})=>{i.push(h.unitId),f.forEach(w=>{i.push(w.unitId)})});const o=n.getUngroupDrawingOp(r),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=o;return t.syncExecuteCommand(m.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:a,undoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:Bt(c),type:m.DrawingApplyType.GROUP}},{id:L.id,params:i}],redoMutations:[{id:m.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:m.DrawingApplyType.UNGROUP}},{id:L.id,params:i}]}),!0):!1}};var Ft=Object.getOwnPropertyDescriptor,$t=(s,r,t,e)=>{for(var n=e>1?void 0:e?Ft(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},ne=(s,r)=>(t,e)=>r(t,e,s);function Gt(s,r,t){const e=t*Math.PI/180,n=Math.abs(s*Math.cos(e))+Math.abs(r*Math.sin(e)),i=Math.abs(s*Math.sin(e))+Math.abs(r*Math.cos(e));return{rotatedWidth:n,rotatedHeight:i}}function at(s,r,t,e,n){var I;const{rotatedHeight:i,rotatedWidth:o}=Gt(t,e,n),d=s.get(k.IRenderManagerService).getRenderById(r.unitId);if(!d)return!1;const u=(I=d.with(b.SheetSkeletonManagerService).getSkeletonParam(r.subUnitId))==null?void 0:I.skeleton;if(u==null)return!1;const c=u.getCellByIndex(r.row,r.col),p=c.mergeInfo.endX-c.mergeInfo.startX-2,h=c.mergeInfo.endY-c.mergeInfo.startY-2,f=o/i,S=Math.ceil(Math.min(p,h*f))/o,_=!S||Number.isNaN(S)?.001:S;return{width:t*_,height:e*_}}exports.SheetDrawingUpdateController=class extends l.Disposable{constructor(t,e,n,i,o,a,d,g,u,c,p,h,f){super();te(this,"_workbookSelections");this._context=t,this._skeletonManagerService=e,this._commandService=n,this._selectionRenderService=i,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=d,this._drawingManagerService=g,this._contextService=u,this._messageService=c,this._localeService=p,this._injector=f,this._workbookSelections=h.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const t=await this._fileOpenerService.openFile({multiple:!0,accept:j.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}),e=t.length;return e>j.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(j.DRAWING_IMAGE_COUNT_LIMIT))}),!1):e===0?!1:(t.forEach(async n=>await this.insertFloatImageByFile(n)),!0)}async insertCellImage(){const e=(await this._fileOpenerService.openFile({multiple:!1,accept:j.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}))[0];return e?(await this._insertCellImage(e),!0):!1}insertCellImageByFile(t,e){return this._insertCellImage(t,e)}async insertFloatImageByFile(t){let e;try{e=await this._imageIoService.saveImage(t)}catch(C){const R=C.message;R===j.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(j.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):R===j.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):R===j.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(e==null)return;const n=this._getUnitInfo(),{unitId:i,subUnitId:o}=n,{imageId:a,imageSourceType:d,source:g,base64Cache:u}=e,{width:c,height:p,image:h}=await j.getImageSize(u||""),{width:f,height:w}=this._context.scene;this._imageIoService.addImageSourceCache(g,d,h);let S=1;if(c>j.DRAWING_IMAGE_WIDTH_LIMIT||p>j.DRAWING_IMAGE_HEIGHT_LIMIT){const C=j.DRAWING_IMAGE_WIDTH_LIMIT/c,R=j.DRAWING_IMAGE_HEIGHT_LIMIT/p;S=Math.max(C,R)}const _=this._getImagePosition(c*S,p*S,f,w);if(_==null)return;const I={unitId:i,subUnitId:o,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:d,source:g,transform:K(_,this._selectionRenderService,this._skeletonManagerService),sheetTransform:_};return this._commandService.executeCommand(Ue.id,{unitId:i,drawings:[I]})}async _insertCellImage(t,e){var R,D;let n;try{n=await this._imageIoService.saveImage(t)}catch(M){const v=M.message;v===j.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(j.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):v===j.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):v===j.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:q.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return!1;const{imageId:i,imageSourceType:o,source:a,base64Cache:d}=n,{width:g,height:u,image:c}=await j.getImageSize(d||"");this._imageIoService.addImageSourceCache(a,o,c);const p=this._workbookSelections.getCurrentLastSelection();if(!p)return!1;let h=p.primary.actualRow,f=p.primary.actualColumn;p.primary.isMerged&&(h=p.primary.startRow,f=p.primary.startColumn);const w=l.createDocumentModelWithStyle("",{}),S=at(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:h,col:f},g,u,0);if(!S)return!1;const _={size:{width:S.width,height:S.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},I={unitId:w.getUnitId(),subUnitId:w.getUnitId(),drawingId:i,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:o,source:a,transform:ze.docDrawingPositionToTransform(_),docTransform:_,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},C=l.BuildTextUtils.drawing.add({documentDataModel:w,drawings:[I],selection:{collapsed:!0,startOffset:0,endOffset:0}});return C?(w.apply(C),this._commandService.syncExecuteCommand(y.SetRangeValuesCommand.id,{value:{[(R=e==null?void 0:e.row)!=null?R:h]:{[(D=e==null?void 0:e.col)!=null?D:f]:{p:w.getSnapshot(),t:1}}},unitId:e==null?void 0:e.unitId,subUnitId:e==null?void 0:e.subUnitId})):!1}async insertCellImageByUrl(t,e){var h,f;const{width:n,height:i,image:o}=await j.getImageSize(t||"");this._imageIoService.addImageSourceCache(t,l.ImageSourceType.URL,o);const a=this._workbookSelections.getCurrentLastSelection();if(!a)return!1;const d=l.createDocumentModelWithStyle("",{}),g=at(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:a.primary.actualRow,col:a.primary.actualColumn},n,i,0);if(!g)return!1;const u={size:{width:g.width,height:g.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},c={unitId:d.getUnitId(),subUnitId:d.getUnitId(),drawingId:l.generateRandomId(),drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:l.ImageSourceType.URL,source:t,transform:ze.docDrawingPositionToTransform(u),docTransform:u,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},p=l.BuildTextUtils.drawing.add({documentDataModel:d,drawings:[c],selection:{collapsed:!0,startOffset:0,endOffset:0}});return p?(d.apply(p),this._commandService.syncExecuteCommand(y.SetRangeValuesCommand.id,{value:{[(h=e==null?void 0:e.row)!=null?h:a.primary.actualRow]:{[(f=e==null?void 0:e.col)!=null?f:a.primary.actualColumn]:{p:d.getSnapshot(),t:1}}},unitId:e==null?void 0:e.unitId,subUnitId:e==null?void 0:e.subUnitId})):!1}_getUnitInfo(){const t=this._context.unit,e=t.getActiveSheet(),n=t.getUnitId(),i=e.getSheetId();return{unitId:n,subUnitId:i}}_getImagePosition(t,e,n,i){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const d=b.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(d==null)return;let{startColumn:g,startRow:u,startX:c,startY:p}=d,h=!1;if(c+t>n&&(c=n-t,c<0&&(c=0,t=n),h=!0),p+e>i&&(p=i-e,p<0&&(p=0,e=i),h=!0),h){const _=this._selectionRenderService.getCellWithCoordByOffset(c,p);if(_==null)return;c=_.startX,p=_.startY,g=_.actualColumn,u=_.actualRow}const f={column:g,columnOffset:0,row:u,rowOffset:0},w=this._selectionRenderService.getCellWithCoordByOffset(c+t,p+e);if(w==null)return;const S={column:w.actualColumn,columnOffset:c+t-w.startX,row:w.actualRow,rowOffset:p+e-w.startY};return{from:f,to:S}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(t=>{const{unitId:e,subUnitId:n,drawingIds:i,arrangeType:o}=t;this._commandService.executeCommand(ht.id,{unitId:e,subUnitId:n,drawingIds:i,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(t=>{const e=[];t.length!==0&&(t.forEach(n=>{const{unitId:i,subUnitId:o,drawingId:a,drawingType:d,transform:g}=n;if(g==null)return;const u=this._sheetDrawingService.getDrawingByParam({unitId:i,subUnitId:o,drawingId:a});if(u==null||u.unitId!==this._context.unitId)return;const c=G({...u.transform,...g},this._selectionRenderService);if(c==null)return;const p={...n,transform:{...u.transform,...g,...K(c,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...c}};e.push(p)}),e.length>0&&this._commandService.executeCommand(Ae.id,{unitId:t[0].unitId,drawings:e}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(t=>{this._commandService.executeCommand(gt.id,t);const{unitId:e,subUnitId:n,drawingId:i}=t[0].parent;this._commandService.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[{unitId:e,subUnitId:n,drawingId:i}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(t=>{this._commandService.executeCommand(pt.id,t)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(t=>{t==null||t.length===0?(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(t))}))}};exports.SheetDrawingUpdateController=$t([ne(1,l.Inject(b.SheetSkeletonManagerService)),ne(2,l.ICommandService),ne(3,b.ISheetSelectionRenderService),ne(4,j.IImageIoService),ne(5,W.ILocalFileService),ne(6,m.ISheetDrawingService),ne(7,j.IDrawingManagerService),ne(8,l.IContextService),ne(9,W.IMessageService),ne(10,l.Inject(l.LocaleService)),ne(11,l.Inject(y.SheetsSelectionsService)),ne(12,l.Inject(l.Injector))],exports.SheetDrawingUpdateController);const Pe={id:"sheet.command.insert-float-image",type:l.CommandType.COMMAND,handler:async(s,r)=>{var o,a;const t=s.get(l.IUniverInstanceService),e=s.get(k.IRenderManagerService),n=(o=k.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,t,e))==null?void 0:o.with(exports.SheetDrawingUpdateController);if(!n)return!1;const i=r==null?void 0:r.files;if(i){const d=i.map(g=>n.insertFloatImageByFile(g));return(await Promise.all(d)).every(g=>g)}else return(a=n.insertFloatImage())!=null?a:!1}},mt={id:"sheet.command.insert-cell-image",type:l.CommandType.COMMAND,handler:s=>{var e,n;const r=s.get(l.IUniverInstanceService),t=s.get(k.IRenderManagerService);return(n=(e=k.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,r,t))==null?void 0:e.with(exports.SheetDrawingUpdateController).insertCellImage())!=null?n:!1}},ye={id:"sheet.command.move-drawing",type:l.CommandType.COMMAND,handler:(s,r)=>{const t=s.get(l.ICommandService),e=s.get(m.ISheetDrawingService),n=s.get(b.ISheetSelectionRenderService),{direction:i}=r,o=e.getFocusDrawings();if(o.length===0)return!1;const a=o[0].unitId,d=o.map(u=>{const{transform:c}=u;if(c==null)return null;const p={...c},{left:h=0,top:f=0}=c;return i===l.Direction.UP?p.top=f-1:i===l.Direction.DOWN?p.top=f+1:i===l.Direction.LEFT?p.left=h-1:i===l.Direction.RIGHT&&(p.left=h+1),{...u,transform:p,sheetTransform:G(p,n)}}).filter(u=>u!=null);return t.syncExecuteCommand(Ae.id,{unitId:a,drawings:d})?(t.syncExecuteCommand(L.id,[a]),!0):!1}},Et="COMPONENT_SHEET_DRAWING_PANEL",wt={id:"sidebar.operation.sheet-image",type:l.CommandType.COMMAND,handler:async(s,r)=>{const t=s.get(W.ISidebarService),e=s.get(l.LocaleService),n=s.get(l.IUniverInstanceService),i=s.get(l.ICommandService);if(!y.getSheetCommandTarget(n))return!1;switch(r.value){case"open":t.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Et},onClose:()=>{i.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[])},width:360});break;case"close":default:t.close();break}return!0}},ft={id:"sheet.operation.edit-sheet-image",type:l.CommandType.OPERATION,handler:(s,r)=>{const t=s.get(l.ICommandService);return r==null?!1:(t.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[r]),t.executeCommand(wt.id,{value:"open"}),!0)}},xt="sheets-drawing-ui.config",Ct={};var Lt=Object.getOwnPropertyDescriptor,Ht=(s,r,t,e)=>{for(var n=e>1?void 0:e?Lt(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},re=(s,r)=>(t,e)=>r(t,e,s);let qe=class extends l.RxDisposable{constructor(r,t,e,n,i,o,a,d,g,u){super();te(this,"_initImagePopupMenu",new Set);this._injector=r,this._localeService=t,this._drawingManagerService=e,this._canvasPopManagerService=n,this._renderManagerService=i,this._univerInstanceService=o,this._messageService=a,this._contextService=d,this._ioService=g,this._commandService=u,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(A.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).pipe(A.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(l.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._setupLoadingStatus()}_setupLoadingStatus(){const r="image-upload-loading";let t;this.disposeWithMe(this._ioService.change$.subscribe(e=>{e>0&&!t?t=this._messageService.show({id:r,type:q.MessageType.Loading,content:`${this._localeService.t("uploadLoading.loading")}: ${e}`,duration:0}):e===0&&(t==null||t.dispose(),t=void 0)}))}_dispose(r){super.dispose();const t=r.getUnitId();this._renderManagerService.removeRender(t)}_create(r){if(!r)return;const t=r.getUnitId();this._renderManagerService.has(t)&&!this._initImagePopupMenu.has(t)&&(this._popupMenuListener(t),this._initImagePopupMenu.add(t))}_hasCropObject(r){const t=r.getAllObjectsByOrder();for(const e of t)if(e instanceof le.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var i;const t=(i=this._renderManagerService.getRenderById(r))==null?void 0:i.scene;if(!t)return;const e=t.getTransformerByCreate();if(!e)return;let n;this.disposeWithMe(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(t))return;const o=e.getSelectedObjectMap();if(o.size>1){n==null||n.dispose();return}const a=o.values().next().value;if(!a)return;const d=a.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:u,subUnitId:c,drawingId:p,drawingType:h}=g,f=g.data;if(f&&f.disablePopup)return;n==null||n.dispose();const w=this._canvasPopManagerService.getFeatureMenu(u,c,p,h);n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:le.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:w||this._getImageMenuItems(u,c,p,h)}}))})),this.disposeWithMe(e.clearControl$.subscribe(()=>{n==null||n.dispose(),this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._commandService.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[])})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(o=>{o[l.FOCUSING_COMMON_DRAWINGS]===!1&&(n==null||n.dispose())})),this.disposeWithMe(e.changing$.subscribe(()=>{n==null||n.dispose()}))}_getImageMenuItems(r,t,e,n){return[{label:"image-popup.edit",index:0,commandId:ft.id,commandParams:{unitId:r,subUnitId:t,drawingId:e},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:De.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:t,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:le.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:t,drawingId:e},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:le.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:t,drawingId:e}],disable:n===l.DrawingTypeEnum.DRAWING_DOM}]}};qe=Ht([re(0,l.Inject(l.Injector)),re(1,l.Inject(l.LocaleService)),re(2,j.IDrawingManagerService),re(3,l.Inject(b.SheetCanvasPopManagerService)),re(4,k.IRenderManagerService),re(5,l.IUniverInstanceService),re(6,W.IMessageService),re(7,l.IContextService),re(8,l.IImageIoService),re(9,l.ICommandService)],qe);var Xt=Object.getOwnPropertyDescriptor,Vt=(s,r,t,e)=>{for(var n=e>1?void 0:e?Xt(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},He=(s,r)=>(t,e)=>r(t,e,s);let ct=class extends l.Disposable{constructor(r,t,e,n,i){super();te(this,"_isSetCursor",!1);this._context=r,this._hoverManagerService=t,this._selectionsService=e,this._drawingRenderService=n,this._sheetSkeletonManagerService=i,this._initHover(),this._initImageClick()}_initHover(){this.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe(A.throttleTime(33)).subscribe(r=>{var e,n;let t=[];r!==null&&(t=this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections()),t.length>0&&(r==null?void 0:r.unitId)===this._context.unitId&&(r!=null&&r.drawing)&&t.length===1&&((e=t[0].primary)==null?void 0:e.actualRow)===r.row&&((n=t[0].primary)==null?void 0:n.actualColumn)===r.col?(this._isSetCursor=!0,this._context.scene.setCursor(k.CURSOR_TYPE.ZOOM_IN)):this._isSetCursor&&(this._isSetCursor=!1,this._context.scene.resetCursor())}))}_initImageClick(){this.disposeWithMe(this._hoverManagerService.currentClickedCell$.subscribe(r=>{var t;if(r!=null&&r.drawing&&this._isSetCursor){const e=r.drawing.drawing.drawingOrigin,n=(t=this._sheetSkeletonManagerService.getCurrentSkeleton())==null?void 0:t.imageCacheMap.getImage(e.imageSourceType,e.source);if(!n)return;this._drawingRenderService.previewImage("preview-cell-image",n.src,n.width,n.height),this._context.scene.resetCursor(),this._isSetCursor=!1}}))}};ct=Vt([He(1,l.Inject(b.HoverManagerService)),He(2,l.Inject(y.SheetsSelectionsService)),He(3,l.Inject(le.DrawingRenderService)),He(4,l.Inject(b.SheetSkeletonManagerService))],ct);var Kt=Object.getOwnPropertyDescriptor,zt=(s,r,t,e)=>{for(var n=e>1?void 0:e?Kt(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},Xe=(s,r)=>(t,e)=>r(t,e,s);let dt=class extends l.Disposable{constructor(s,r,t,e,n){super(),this._context=s,this._sheetDrawingService=r,this._drawingManagerService=t,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=n,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const s=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in s){const t=s[r];for(const e in t.data){const n=t.data[e];n.sheetTransform&&(n.transform=K(n.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService))}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};dt=zt([Xe(1,m.ISheetDrawingService),Xe(2,j.IDrawingManagerService),Xe(3,l.Inject(b.ISheetSelectionRenderService)),Xe(4,l.Inject(b.SheetSkeletonManagerService))],dt);var qt=Object.getOwnPropertyDescriptor,Zt=(s,r,t,e)=>{for(var n=e>1?void 0:e?qt(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},_e=(s,r)=>(t,e)=>r(t,e,s);function bt(s,r,t){var e,n,i,o;if(((n=(e=t==null?void 0:t.p)==null?void 0:e.body)==null?void 0:n.dataStream.length)===3&&((o=(i=t.p)==null?void 0:i.drawingsOrder)==null?void 0:o.length)===1){const a=t.p.drawings[t.p.drawingsOrder[0]],d=at(s,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},a.docTransform.size.width,a.docTransform.size.height,a.docTransform.angle);if(d)return a.transform.width=d.width,a.transform.height=d.height,a.docTransform.size.width=d.width,a.docTransform.size.height=d.height,a.transform.left=0,a.transform.top=0,a.docTransform.positionH.posOffset=0,a.docTransform.positionV.posOffset=0,t.p.documentStyle.pageSize.width=1/0,t.p.documentStyle.pageSize.height=1/0,!0}return!1}let Ze=class extends l.Disposable{constructor(s,r,t,e,n,i){super(),this._commandService=s,this._sheetInterceptorService=r,this._injector=t,this._drawingManagerService=e,this._docDrawingController=n,this._editorBridgeService=i,this._handleInitEditor(),this._initCellContentInterceptor()}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(s=>{s.visible?s.visible&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(s=>{s.id===ze.ReplaceSnapshotCommand.id&&s.params.unitId===l.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,priority:y.InterceptCellContentPriority.CELL_IMAGE,handler:(s,r,t)=>{var e;return s!=null&&s.p&&((e=s.p.drawingsOrder)!=null&&e.length)&&(s===r.rawData&&(s={...r.rawData}),s.interceptorStyle||(s.interceptorStyle={}),s.interceptorStyle.tr={a:0},bt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},s)),t(s)}}))}};Ze=Zt([_e(0,l.ICommandService),_e(1,l.Inject(y.SheetInterceptorService)),_e(2,l.Inject(l.Injector)),_e(3,j.IDrawingManagerService),_e(4,l.Inject(Rt.DocDrawingController)),_e(5,l.Inject(b.IEditorBridgeService))],Ze);var Jt=Object.getOwnPropertyDescriptor,Qt=(s,r,t,e)=>{for(var n=e>1?void 0:e?Jt(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},Tt=(s,r)=>(t,e)=>r(t,e,s);let Je=class extends l.Disposable{constructor(s,r){super(),this._autoFillService=s,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(s,r,t,e)=>{new l.ObjectMatrix(e).forValue((n,i,o)=>{bt(this._injector,{unitId:s.unitId,subUnitId:s.subUnitId,row:n,col:i},o)})}}))}};Je=Qt([Tt(0,l.Inject(b.IAutoFillService)),Tt(1,l.Inject(l.Injector))],Je);var en=Object.getOwnPropertyDescriptor,tn=(s,r,t,e)=>{for(var n=e>1?void 0:e?en(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},Re=(s,r)=>(t,e)=>r(t,e,s);const nn=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,l.DOCS_ZEN_EDITOR_UNIT_ID_KEY];let Qe=class extends l.Disposable{constructor(s,r,t,e,n){super(),this._commandService=s,this._univerInstanceService=r,this._dialogService=t,this._renderManagerService=e,this._localeService=n,this._initDocImageCopyPasteHooks()}_setCellImage(s){var n;const r=l.createDocumentModelWithStyle("",{}),t=(n=k.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.with(b.EditingRenderController),e=l.BuildTextUtils.drawing.add({documentDataModel:r,drawings:[s],selection:{collapsed:!0,startOffset:0,endOffset:0}});e&&(r.apply(e),t&&t.submitCellData(r))}_initDocImageCopyPasteHooks(){this.disposeWithMe(this._commandService.beforeCommandExecuted(s=>{var r,t;if(s.id===ze.InnerPasteCommand.id){const e=s.params,{doc:n}=e,i=this._univerInstanceService.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_DOC);if(i==null||!Object.keys((r=n.drawings)!=null?r:{}).length)return;const o=i.getUnitId();if(nn.includes(o)){if(o!==l.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const a=()=>{this._dialogService.close("sheet-cell-image-copy-paste"),this._commandService.syncExecuteCommand(b.SetCellEditVisibleOperation.id,{visible:!1})};((t=i.getBody())==null?void 0:t.dataStream)===`\r
|
|
2
|
-
`?(this._commandService.syncExecuteCommand(b.SetCellEditVisibleOperation.id,{visible:!1}),this._setCellImage(Object.values(n.drawings)[0])):this._dialogService.open({id:"sheet-cell-image-copy-paste",title:{label:this._localeService.t("cell-image.pasteTitle")},children:{label:this._localeService.t("cell-image.pasteContent")},width:320,destroyOnClose:!0,onClose:a,showOk:!0,showCancel:!0,onOk:()=>{a(),this._setCellImage(Object.values(n.drawings)[0])},onCancel:a})}throw new Error("Sheet cell image copy paste is not supported in this unit")}}}))}};Qe=tn([Re(0,l.ICommandService),Re(1,l.IUniverInstanceService),Re(2,W.IDialogService),Re(3,k.IRenderManagerService),Re(4,l.Inject(l.LocaleService))],Qe);var rn=Object.getOwnPropertyDescriptor,sn=(s,r,t,e)=>{for(var n=e>1?void 0:e?rn(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},Ee=(s,r)=>(t,e)=>r(t,e,s);const Ot="image/png";function on(s){const r=s.split(","),t=atob(r[1]),e=t.length,n=new Uint8Array(e);for(let i=0;i<e;i++)n[i]=t.charCodeAt(i);return new Blob([n],{type:Ot})}function an(s){const r=new ClipboardItem({[Ot]:on(s)});navigator.clipboard.write([r]).catch(t=>{console.error("Could not copy image using clipboard API: ",t)})}function cn(){function s(){const e=document.createElement("input");return e.style.position="absolute",e.style.height="1px",e.style.width="1px",e.style.opacity="0",e}const r=document.activeElement,t=s();return document.body.appendChild(t),t.focus(),()=>{t.blur(),document.body.removeChild(t),r instanceof HTMLElement&&r.focus()}}const Mt=[b.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,b.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,b.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,b.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA];let et=class extends l.Disposable{constructor(r,t,e,n,i){super();te(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=t,this._drawingService=e,this._clipboardInterfaceService=n,this._commandService=i,this._initCopyPaste()}get _focusedDrawings(){return this._drawingService.getFocusDrawings()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,t,e,n)=>{this._copyInfo=null;const i=this._focusedDrawings;if(i.length>0){const[o]=i;if(o.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;if(n===b.COPY_TYPE.CUT){const d={unitId:r,drawings:[o]};this._commandService.executeCommand(De.id,d)}setTimeout(()=>{const d=cn();o.drawingType===l.DrawingTypeEnum.DRAWING_IMAGE&&o.imageSourceType===j.ImageSourceType.BASE64?an(o.source):this._clipboardInterfaceService.writeText(""),d()},200);const a={unitId:o.unitId,subUnitId:o.subUnitId,drawings:[o]};this._copyInfo=a}else{const o=this._createDrawingsCopyInfoByRange(r,t,e);this._copyInfo=o}},onPasteCells:(r,t,e,n)=>{if(!this._copyInfo)return{redos:[],undos:[]};const{copyType:i=b.COPY_TYPE.COPY,pasteType:o}=n,{range:a}=r||{},{range:d,unitId:g,subUnitId:u}=t;return this._copyInfo.copyRange?this._generateRangeDrawingsPasteMutations({pasteType:o,unitId:g,subUnitId:u,pasteRange:d},{copyRange:a,copyType:i}):this._generateSingleDrawingPasteMutations({pasteTo:t,pasteType:o},b.COPY_TYPE.COPY)},onPastePlainText:(r,t)=>({undos:[],redos:[]}),onPasteUnrecognized:r=>this._copyInfo?this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:b.PREDEFINED_HOOK_NAME.DEFAULT_PASTE},b.COPY_TYPE.COPY):{undos:[],redos:[]},onPasteFiles:(r,t)=>{if(this._copyInfo)return this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:b.PREDEFINED_HOOK_NAME.DEFAULT_PASTE},b.COPY_TYPE.COPY);{const e=t.filter(n=>n.type.includes("image"));if(e.length)return{undos:[],redos:[{id:Pe.id,params:{files:e}}]}}return{undos:[],redos:[]}}})}_createDrawingsCopyInfoByRange(r,t,e){var p;const n=(p=this._renderManagerService.getRenderById(r))==null?void 0:p.with(b.SheetSkeletonManagerService);if(!n)return;const i=n.attachRangeWithCoord(e);if(!i)return;const{startX:o,endX:a,startY:d,endY:g}=i,u=this._drawingService.getDrawingData(r,t),c=this._focusedDrawings.slice();if(Object.keys(u).forEach(h=>{const f=u[h];if(f.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;const{transform:w}=f;if(f.anchorType!==m.SheetDrawingAnchorType.Both||!w)return;const{left:S=0,top:_=0,width:I=0,height:C=0}=w,{drawingStartX:R,drawingEndX:D,drawingStartY:M,drawingEndY:v}={drawingStartX:S,drawingEndX:S+I,drawingStartY:_,drawingEndY:_+C};o<=R&&D<=a&&d<=M&&v<=g&&c.push(f)}),c.length)return{copyRange:e,drawings:c,unitId:r,subUnitId:t}}_generateSingleDrawingPasteMutations(r,t){const{pasteType:e,pasteTo:n}=r;if(Mt.includes(e))return{redos:[],undos:[]};const{unitId:i,subUnitId:o,range:a}=n,d=this._renderManagerService.getRenderById(i),g=d==null?void 0:d.with(b.SheetSkeletonManagerService),u=d==null?void 0:d.with(b.ISheetSelectionRenderService),c=this._copyInfo;if(!g||!u)return{redos:[],undos:[]};const{drawings:p}=c,h=b.discreteRangeToRange(a);return this._generateMutations(p,{unitId:i,subUnitId:o,isCut:t===b.COPY_TYPE.CUT,getTransform:(f,w)=>{var I;const S=g.attachRangeWithCoord({startRow:h.startRow,endRow:h.endRow,startColumn:h.startColumn,endColumn:h.endColumn}),_={...f,left:S==null?void 0:S.startX,top:S==null?void 0:S.startY};return{transform:_,sheetTransform:(I=G(_,u))!=null?I:w}}})}_generateMutations(r,t){const{unitId:e,subUnitId:n,getTransform:i,isCut:o}=t,a=[],d=[],{_drawingService:g}=this;return r.forEach(u=>{const{transform:c,sheetTransform:p}=u;if(!c)return;const h=i(c,p),f={...u,unitId:e,subUnitId:n,drawingId:o?u.drawingId:l.generateRandomId(),transform:h.transform,sheetTransform:h.sheetTransform};if(o){const{undo:w,redo:S,objects:_}=g.getBatchUpdateOp([f]);a.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,type:m.DrawingApplyType.UPDATE,op:S,objects:_}}),d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,type:m.DrawingApplyType.UPDATE,op:w,objects:_}})}else{const{undo:w,redo:S,objects:_}=g.getBatchAddOp([f]);a.push({id:m.SetDrawingApplyMutation.id,params:{op:S,unitId:e,subUnitId:n,objects:_,type:m.DrawingApplyType.INSERT}}),d.push({id:m.SetDrawingApplyMutation.id,params:{op:w,unitId:e,subUnitId:n,objects:_,type:m.DrawingApplyType.REMOVE}})}}),{redos:a,undos:d}}_generateRangeDrawingsPasteMutations(r,t){var U;const{unitId:e,subUnitId:n,pasteType:i,pasteRange:o}=r,{copyRange:a,copyType:d}=t;if(Mt.includes(i))return{redos:[],undos:[]};const g=(U=this._renderManagerService.getRenderById(e))==null?void 0:U.with(b.SheetSkeletonManagerService);if(!g||!this._copyInfo)return{redos:[],undos:[]};const{drawings:u}=this._copyInfo;if(!a)return this._generateSingleDrawingPasteMutations({pasteTo:{unitId:e,subUnitId:n,range:b.discreteRangeToRange(o)},pasteType:i},d);const{ranges:[c,p],mapFunc:h}=b.virtualizeDiscreteRanges([a,o]),{row:f,col:w}=h(c.startRow,c.startColumn),{row:S,col:_}=h(p.startRow,p.startColumn),I=g.attachRangeWithCoord({startRow:f,endRow:f,startColumn:w,endColumn:w}),C=g.attachRangeWithCoord({startRow:S,endRow:S,startColumn:_,endColumn:_});if(!I||!C||!this._copyInfo)return{redos:[],undos:[]};const R=C.startX-I.startX,D=C.startY-I.startY,M=S-f,v=_-w;return this._generateMutations(u,{unitId:e,subUnitId:n,getTransform:(E,P)=>{var N,O;return{transform:{...E,left:((N=E==null?void 0:E.left)!=null?N:0)+R,top:((O=E==null?void 0:E.top)!=null?O:0)+D},sheetTransform:{...P,to:{...P.to,row:P.to.row+M,column:P.to.column+v},from:{...P.from,row:P.from.row+M,column:P.from.column+v}}}},isCut:d===b.COPY_TYPE.CUT})}};et=sn([Ee(0,b.ISheetClipboardService),Ee(1,k.IRenderManagerService),Ee(2,j.IDrawingManagerService),Ee(3,W.IClipboardInterfaceService),Ee(4,l.ICommandService)],et);var dn=Object.getOwnPropertyDescriptor,ln=(s,r,t,e)=>{for(var n=e>1?void 0:e?dn(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},be=(s,r)=>(t,e)=>r(t,e,s);let tt=class extends l.Disposable{constructor(s,r,t,e,n){super(),this._drawingManagerService=s,this._renderManagerService=r,this._permissionService=t,this._univerInstanceService=e,this._userManagerService=n,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const s=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,t=A.combineLatest([s,r]);this.disposeWithMe(t.pipe(A.switchMap(([e,n])=>e?e.activeSheet$.pipe(A.tap(i=>{if(!i){this._drawingManagerService.setDrawingVisible(!1);return}const o=e.getUnitId(),a=i.getSheetId();this._permissionService.composePermission([new y.WorkbookViewPermission(o).id,new y.WorksheetViewPermission(o,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingVisible(!0):this._handleDrawingVisibilityFalse(e,i)})):(this._drawingManagerService.setDrawingVisible(!1),A.EMPTY))).subscribe())}_handleDrawingVisibilityFalse(s,r){this._drawingManagerService.setDrawingVisible(!1);const t=s.getUnitId(),e=r.getSheetId(),n=this._drawingManagerService.getDrawingData(t,e),i=Object.values(n),o=this._renderManagerService.getRenderById(t),a=o==null?void 0:o.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===k.RENDER_CLASS_TYPE.IMAGE&&i.some(u=>g.oKey.includes(u.drawingId))&&a.removeObject(g)})}_initDrawingEditable(){const s=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,t=A.combineLatest([s,r]);this.disposeWithMe(t.pipe(A.switchMap(([e,n])=>e?e.activeSheet$.pipe(A.tap(i=>{if(!i){this._drawingManagerService.setDrawingEditable(!1);return}const o=e.getUnitId(),a=i.getSheetId();this._permissionService.composePermission([new y.WorkbookEditablePermission(o).id,new y.WorksheetEditPermission(o,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingEditable(!0):this._handleDrawingEditableFalse(e,i)})):(this._drawingManagerService.setDrawingEditable(!1),A.EMPTY))).subscribe())}_handleDrawingEditableFalse(s,r){this._drawingManagerService.setDrawingEditable(!1);const t=s.getUnitId(),e=r.getSheetId(),n=this._drawingManagerService.getDrawingData(t,e),i=Object.values(n),o=this._renderManagerService.getRenderById(t),a=o==null?void 0:o.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===k.RENDER_CLASS_TYPE.IMAGE&&i.some(u=>g.oKey.includes(u.drawingId))&&a.detachTransformerFrom(g)})}_initViewPermissionChange(){const s=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(A.combineLatest([s,r]).pipe(A.switchMap(([t,e])=>t?t.activeSheet$.pipe(A.switchMap(n=>{if(!n)return A.EMPTY;const i=t.getUnitId(),o=n.getSheetId(),a=this._renderManagerService.getRenderById(i),d=a==null?void 0:a.scene;if(!d)return A.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new y.WorkbookViewPermission(i).id,new y.WorksheetViewPermission(i,o).id]).pipe(A.map(c=>c.every(p=>p.value)),A.distinctUntilChanged()).pipe(A.map(c=>({permission:c,scene:d,transformer:g,unitId:i,subUnitId:o})))})):A.EMPTY)).subscribe({next:({permission:t,scene:e,transformer:n,unitId:i,subUnitId:o})=>{this._drawingManagerService.setDrawingVisible(t);const a=e.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(i,o),g=Object.values(d);t?this._drawingManagerService.addNotification(g):(a.forEach(u=>{u.classType===k.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&e.removeObject(u)}),n.clearSelectedObjects())},complete:()=>{this._drawingManagerService.setDrawingVisible(!0);const t=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),e=t==null?void 0:t.getActiveSheet(),n=t==null?void 0:t.getUnitId(),i=e==null?void 0:e.getSheetId();if(!n||!i)return;const o=this._drawingManagerService.getDrawingData(n,i),a=Object.values(o);this._drawingManagerService.addNotification(a)}}))}_initEditPermissionChange(){const s=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(A.combineLatest([s,r]).pipe(A.switchMap(([t,e])=>t?t.activeSheet$.pipe(A.switchMap(n=>{if(!n)return A.EMPTY;const i=t.getUnitId(),o=n.getSheetId(),a=this._renderManagerService.getRenderById(i),d=a==null?void 0:a.scene;if(!d)return A.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new y.WorkbookEditablePermission(i).id,new y.WorksheetEditPermission(i,o).id]).pipe(A.map(c=>c.every(p=>p.value)),A.distinctUntilChanged()).pipe(A.map(c=>({permission:c,scene:d,transformer:g,unitId:i,subUnitId:o})))})):A.EMPTY)).subscribe({next:({permission:t,scene:e,transformer:n,unitId:i,subUnitId:o})=>{this._drawingManagerService.setDrawingEditable(t);const a=e.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(i,o),g=Object.values(d);t?(a.forEach(u=>{u.classType===k.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&e.attachTransformerTo(u)}),this._drawingManagerService.addNotification(g)):(a.forEach(u=>{u.classType===k.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&e.detachTransformerFrom(u)}),n.clearSelectedObjects())},complete:()=>{const t=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!t)return;const e=t.getUnitId(),n=t.getActiveSheet();if(!n)return;const i=n.getSheetId(),o=this._renderManagerService.getRenderById(e),a=o==null?void 0:o.scene;if(!a)return;const d=this._drawingManagerService.getDrawingData(e,i),g=Object.values(d);this._drawingManagerService.setDrawingEditable(!0),a.getAllObjectsByOrder().forEach(c=>{c.classType===k.RENDER_CLASS_TYPE.IMAGE&&g.some(p=>c.oKey.includes(p.drawingId))&&a.detachTransformerFrom(c)})}}))}};tt=ln([be(0,j.IDrawingManagerService),be(1,k.IRenderManagerService),be(2,l.IPermissionService),be(3,l.IUniverInstanceService),be(4,l.Inject(l.UserManagerService))],tt);var un=Object.getOwnPropertyDescriptor,gn=(s,r,t,e)=>{for(var n=e>1?void 0:e?un(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},ue=(s,r)=>(t,e)=>r(t,e,s);function Ut(s,r,t,e,n,i=!1){const{scaleX:o,scaleY:a}=r.getAncestorScale(),d=r.getViewport(k.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=e.getFreeze(),{startColumn:u,startRow:c,xSplit:p,ySplit:h}=g,f={left:!0,top:!0};if(!d)return{...s,absolute:f};const{left:w,right:S,top:_,bottom:I}=s;let{top:C,left:R,viewportScrollX:D,viewportScrollY:M}=d;const{boundsOfViewArea:v,scrollDirectionResponse:U}=n||{},{rowHeaderWidth:E,columnHeaderHeight:P}=t,N={top:i?0:P,left:i?0:E};v&&(l.Tools.isDefine(N.top)&&(N.top=v.top),l.Tools.isDefine(N.left)&&(N.left=v.left)),U==="HORIZONTAL"&&(M=0),U==="VERTICAL"&&(D=0);let O=0,T=0;const B=t.rowStartY(c-h)+P,$=t.colStartX(u-p)+E,z=t.rowStartY(c)+P,J=t.colStartX(u)+E;if(p===0)f.left=!1,O=(w-D)*o,T=(S-D)*o;else{const X=w-($-E),Y=S-($-E);S<J?(O=X*o,T=Y*o):w<=J&&S>=J?(O=X*o,T=Math.max(R,(S-D)*o)):w>J&&(f.left=!1,O=Math.max((w-D)*o,R),T=Math.max((S-D)*o,R))}let H=0,V=0;if(h===0)f.top=!1,H=(_-M)*a,V=(I-M)*a;else{const X=_-(B-P),Y=I-(B-P);I<z?(H=X*a,V=Y*a):_<=z&&I>=z?(H=X*a,V=Math.max(C,(I-M)*a)):_>z&&(f.top=!1,H=Math.max((_-M)*a,C),V=Math.max((I-M)*a,C))}return O=Math.max(O,N.left),H=Math.max(H,N.top),T=Math.max(T,N.left),V=Math.max(V,N.top),{left:O,right:T,top:H,bottom:V,absolute:f}}const ie=(s,r,t,e,n)=>{const{left:i,top:o,width:a,height:d,angle:g}=s,u={left:i,right:i+a,top:o,bottom:o+d},c=Ut(u,r,t,e,n),{scaleX:p,scaleY:h}=r.getAncestorScale();return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:g,width:a*p,height:d*h,absolute:c.absolute}};exports.SheetCanvasFloatDomManagerService=class extends l.Disposable{constructor(t,e,n,i,o,a,d){super();te(this,"_domLayerInfoMap",new Map);te(this,"_transformChange$",new A.Subject);te(this,"transformChange$",this._transformChange$.asObservable());te(this,"_add$",new A.Subject);te(this,"add$",this._add$.asObservable());te(this,"_remove$",new A.Subject);te(this,"remove$",this._remove$.asObservable());this._renderManagerService=t,this._univerInstanceService=e,this._commandService=n,this._drawingManagerService=i,this._canvasFloatDomService=o,this._sheetDrawingService=a,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(A.filter(t=>t===l.LifecycleStages.Rendered),A.take(1)).subscribe(()=>{this._scrollUpdateListener()})}getFloatDomInfo(t){return this._domLayerInfoMap.get(t)}getFloatDomsBySubUnitId(t,e){return Array.from(this._domLayerInfoMap.values()).filter(n=>n.subUnitId===e&&n.unitId===t)}_getSceneAndTransformerByDrawingSearch(t){if(t==null)return;const e=this._renderManagerService.getRenderById(t),n=e==null?void 0:e.scene;if(e==null||n==null)return null;const i=n.getTransformerByCreate(),o=e.engine.getCanvasElement();return{scene:n,transformer:i,renderUnit:e,canvas:o}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(t=>{t.forEach(e=>{var X;const{unitId:n,subUnitId:i,drawingId:o}=e,a=y.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:i}),d=this._drawingManagerService.getDrawingByParam(e),g=this._univerInstanceService.getUnit(n,l.UniverInstanceType.UNIVER_SHEET);if(!g)return;const u=g.getActiveSheet().getSheetId();if(!d||!a)return;const c=(X=this._renderManagerService.getRenderById(n))==null?void 0:X.with(b.SheetSkeletonManagerService).getSkeletonParam(i);if(!c)return;const{transform:p,drawingType:h,data:f}=d;if(h!==l.DrawingTypeEnum.DRAWING_DOM&&h!==l.DrawingTypeEnum.DRAWING_CHART)return;const w=this._getSceneAndTransformerByDrawingSearch(n);if(w==null)return;const{scene:S,canvas:_}=w;if(p==null)return!0;if(u!==i)return;const{left:I,top:C,width:R,height:D,angle:M,flipX:v,flipY:U,skewX:E,skewY:P}=p,N=j.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:o}),O=S.getObject(N);if(O!=null){O.transformByState({left:I,top:C,width:R,height:D,angle:M,flipX:v,flipY:U,skewX:E,skewY:P});return}const T={left:I,top:C,width:R,height:D,zIndex:this._drawingManagerService.getDrawingOrder(n,i).length-1},B=h===l.DrawingTypeEnum.DRAWING_CHART;if(T.rotateEnabled=!1,B){const Y=f?f.backgroundColor:"white";T.fill=Y,f&&f.border&&(T.stroke=f.border),T.paintFirst="stroke",T.strokeWidth=1,T.borderEnabled=!1,T.radius=8}const $=new k.Rect(N,T);B&&$.setObjectType(k.ObjectType.CHART),S.addObject($,k.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&S.attachTransformerTo($);const z=new l.DisposableCollection,J=ie($,w.renderUnit.scene,c.skeleton,a.worksheet),H=new A.BehaviorSubject(J),V={dispose:z,rect:$,position$:H,unitId:n,subUnitId:i,id:o};this._canvasFloatDomService.addFloatDom({position$:H,id:o,componentKey:d.componentKey,onPointerDown:Y=>{_.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerMove:Y=>{_.dispatchEvent(new PointerEvent(Y.type,Y))},onPointerUp:Y=>{_.dispatchEvent(new PointerEvent(Y.type,Y))},onWheel:Y=>{_.dispatchEvent(new WheelEvent(Y.type,Y))},data:f,unitId:n});const Q=$.onTransformChange$.subscribeEvent(()=>{const Y=ie($,w.renderUnit.scene,c.skeleton,a.worksheet);H.next(Y)});z.add(()=>{this._canvasFloatDomService.removeFloatDom(o)}),Q&&z.add(Q),this._domLayerInfoMap.set(o,V)})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(e=>{var p;const{unitId:n,subUnitId:i,drawingId:o}=e,a=j.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:i,drawingId:o}),d=this._getSceneAndTransformerByDrawingSearch(n);if(d==null)return;const{transformer:g,scene:u}=d,c=u.getObject(a);c!=null&&c.oKey&&(g.clearControlByIds([c==null?void 0:c.oKey]),(p=u.getTransformer())==null||p.clearSelectedObjects())})}))}_scrollUpdateListener(){const t=(e,n)=>{var g;const i=this._getSceneAndTransformerByDrawingSearch(e),o=Array.from(this._domLayerInfoMap.keys()).map(u=>({id:u,...this._domLayerInfoMap.get(u)})).filter(u=>u.subUnitId===n&&u.unitId===e).map(u=>u.id),a=y.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:n}),d=(g=this._renderManagerService.getRenderById(e))==null?void 0:g.with(b.SheetSkeletonManagerService).getSkeletonParam(n);!i||!a||!d||o.forEach(u=>{const c=this._domLayerInfoMap.get(u);if(c){const p=ie(c.rect,i.renderUnit.scene,d.skeleton,a.worksheet,c);c.position$.next(p)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(A.switchMap(e=>e?e.activeSheet$:A.of(null)),A.map(e=>{if(!e)return null;const n=e.getUnitId(),i=this._renderManagerService.getRenderById(n);return i?{render:i,unitId:n,subUnitId:e.getSheetId()}:null}),A.switchMap(e=>e?l.fromEventSubject(e.render.scene.getViewport(k.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(A.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))):A.of(null))).subscribe(e=>{if(!e)return;const{unitId:n,subUnitId:i}=e;t(n,i)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(e.id===b.SetZoomRatioOperation.id){const n=e.params,{unitId:i}=n;Array.from(this._domLayerInfoMap.values()).filter(a=>a.unitId===i).map(a=>a.subUnitId).forEach(a=>{t(i,a)})}else if(e.id===y.SetFrozenMutation.id){const{unitId:n,subUnitId:i}=e.params;t(n,i)}}))}updateFloatDomProps(t,e,n,i){const o=this._domLayerInfoMap.get(n),a=this._getSceneAndTransformerByDrawingSearch(t);if(o&&a){const{scene:d}=a,g=j.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:e,drawingId:n}),u=d.getObject(g);u&&u instanceof k.Rect&&u.setProps(i)}}_getPosition(t,e){var h;const{startX:n,endX:i,startY:o,endY:a}=t,d=(h=this._renderManagerService.getRenderById(e))==null?void 0:h.with(b.ISheetSelectionRenderService);if(d==null)return;const g=d.getCellWithCoordByOffset(n,o);if(g==null)return;const u={column:g.actualColumn,columnOffset:n-g.startX,row:g.actualRow,rowOffset:o-g.startY},c=d.getCellWithCoordByOffset(i,a);if(c==null)return;const p={column:c.actualColumn,columnOffset:i-c.startX,row:c.actualRow,rowOffset:a-c.startY};return{from:u,to:p}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(t=>{t.forEach(e=>{const n=this._drawingManagerService.getDrawingByParam(e);if(!n||n.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART)return;const i={...n.transform};this._transformChange$.next({id:e.drawingId,value:i}),this._canvasFloatDomService.updateFloatDom(e.drawingId,{...n});const o=this._getSceneAndTransformerByDrawingSearch(e.unitId);if(o&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART){const{scene:a}=o,d=this._domLayerInfoMap.get(e.drawingId);d!=null&&d.rect&&(n.allowTransform===!1?a.detachTransformerFrom(d.rect):a.attachTransformerTo(d.rect))}})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(t=>{t.forEach(e=>{this._removeDom(e.drawingId)})}))}addFloatDomToPosition(t,e){const n=y.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!n)throw new Error("cannot find current target!");const{unitId:i,subUnitId:o}=n,{initPosition:a,componentKey:d,data:g,allowTransform:u=!0}=t,c=e!=null?e:l.generateRandomId(),p=this._getPosition(a,i);if(p==null)return;const h={unitId:i,subUnitId:o,drawingId:c,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:p,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY},data:g,allowTransform:u};return this._commandService.executeCommand(Ue.id,{unitId:i,drawings:[h]}),this._add$.next({unitId:i,subUnitId:o,id:c}),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(t,e=!1){const n=this._domLayerInfoMap.get(t);if(!n)return;const{unitId:i,subUnitId:o}=n;this._domLayerInfoMap.delete(t),n.dispose.dispose();const a=this._getSceneAndTransformerByDrawingSearch(i);if(a&&a.scene.removeObject(n.rect),e){const d=this._drawingManagerService.getDrawingByParam({unitId:i,subUnitId:o,drawingId:t});if(!d)return;const g=this._sheetDrawingService.getBatchRemoveOp([d]),{redo:u,objects:c}=g;this._commandService.syncExecuteCommand(m.SetDrawingApplyMutation.id,{unitId:i,subUnitId:o,op:u,objects:c,type:m.DrawingApplyType.REMOVE})}}addFloatDomToRange(t,e,n,i){var v,U,E;const o=y.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!o)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=o,g=this._getSceneAndTransformerByDrawingSearch(a);if(!g)return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(v=this._renderManagerService.getRenderById(a))==null?void 0:v.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:p,data:h,allowTransform:f=!0}=e,w=i!=null?i:l.generateRandomId(),{position:S,position$:_}=this._createRangePositionObserver(t,u,c.skeleton);if(this._getPosition(S,a)==null)return;const C=g.scene,{scaleX:R}=C.getAncestorScale(),D=Ve(S,n,R),M={unitId:a,subUnitId:d,drawingId:w,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:p,transform:{left:D.startX,top:D.startY,width:D.width,height:D.height},data:h,allowTransform:f};{const{unitId:P,subUnitId:N,drawingId:O}=M,T=y.getSheetCommandTarget(this._univerInstanceService,{unitId:P,subUnitId:N}),B=M,$=this._univerInstanceService.getUnit(P,l.UniverInstanceType.UNIVER_SHEET);if(!$)return;const z=$.getActiveSheet().getSheetId();if(!B||!T)return;const J=(U=this._renderManagerService.getRenderById(P))==null?void 0:U.with(b.SheetSkeletonManagerService);if(!J)return;const H=J.getWorksheetSkeleton(N);if(!H)return;const{transform:V,drawingType:Q,data:X}=B;if(Q!==l.DrawingTypeEnum.DRAWING_DOM&&Q!==l.DrawingTypeEnum.DRAWING_CHART)return;const Y=this._getSceneAndTransformerByDrawingSearch(P);if(Y==null)return;const{scene:he,canvas:pe}=Y;if(V==null||z!==N)return;const{left:je,top:ke,width:We,height:Be,angle:it,flipX:st,flipY:Ye,skewX:Fe,skewY:me}=V,$e=j.getDrawingShapeKeyByDrawingSearch({unitId:P,subUnitId:N,drawingId:O}),se=he.getObject($e);if(se!=null){se.transformByState({left:je,top:ke,width:We,height:Be,angle:it,flipX:st,flipY:Ye,skewX:Fe,skewY:me});return}const ee={left:je,top:ke,width:We,height:Be,zIndex:this._drawingManagerService.getDrawingOrder(P,N).length-1},we=Q===l.DrawingTypeEnum.DRAWING_CHART;if(we){const F=X?X.backgroundColor:"white";ee.fill=F,ee.rotateEnabled=!1,X&&X.border&&(ee.stroke=X.border),ee.paintFirst="stroke",ee.strokeWidth=1,ee.borderEnabled=!1,ee.radius=8}const oe=new k.Rect($e,ee);we&&oe.setObjectType(k.ObjectType.CHART),he.addObject(oe,k.DRAWING_OBJECT_LAYER_INDEX),B.allowTransform!==!1&&he.attachTransformerTo(oe);const ae=new l.DisposableCollection,Ge=he.getMainViewport(),{rowHeaderWidth:fe,columnHeaderHeight:Ce}=H.skeleton,xe={top:Ce,left:fe,bottom:Ge.bottom,right:Ge.right},ce={dispose:ae,rect:oe,boundsOfViewArea:xe,domAnchor:n,unitId:P,subUnitId:N},x=ie(oe,Y.renderUnit.scene,H.skeleton,T.worksheet,ce),Se=new A.BehaviorSubject(x);ce.position$=Se;let Te={position$:Se,id:O,componentKey:B.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:F=>{pe.dispatchEvent(new WheelEvent(F.type,F))},data:X,unitId:P};e.eventPassThrough&&(Te={...Te,onPointerDown:F=>{pe.dispatchEvent(new PointerEvent(F.type,F))},onPointerMove:F=>{pe.dispatchEvent(new PointerEvent(F.type,F))},onPointerUp:F=>{pe.dispatchEvent(new PointerEvent(F.type,F))}}),this._canvasFloatDomService.addFloatDom(Te),this.disposeWithMe(_.subscribe(F=>{var vt,It,Dt,yt;const _t=Ve({startX:F.startX,startY:F.startY,endX:F.endX,endY:F.endY,width:(vt=n.width)!=null?vt:F.width,height:(It=n.height)!=null?It:F.height,absolute:{left:S.absolute.left,top:S.absolute.top}},n),Pt=j.getDrawingShapeKeyByDrawingSearch({unitId:P,subUnitId:N,drawingId:O}),Nt=new k.Rect(Pt,{left:_t.startX,top:_t.startY,width:(Dt=n.width)!=null?Dt:F.width,height:(yt=n.height)!=null?yt:F.height,zIndex:this._drawingManagerService.getDrawingOrder(P,N).length-1}),jt=ie(Nt,Y.renderUnit.scene,H.skeleton,T.worksheet,ce);Se.next(jt)}));const Me=(E=this._renderManagerService.getRenderById(P))==null?void 0:E.with(b.SheetSkeletonManagerService);Me==null||Me.currentSkeleton$.subscribe(F=>{F&&H.sheetId!==F.sheetId&&this._removeDom(w,!0)});const Le=oe.onTransformChange$.subscribeEvent(()=>{const F=ie(oe,Y.renderUnit.scene,H.skeleton,T.worksheet,ce);Se.next(F)});ae.add(()=>{this._canvasFloatDomService.removeFloatDom(O)}),Le&&ae.add(Le),this._domLayerInfoMap.set(O,ce)}return{id:w,dispose:()=>{this._removeDom(w,!0)}}}addFloatDomToColumnHeader(t,e,n,i){var D,M,v;const o=y.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!o)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=o;if(!this._getSceneAndTransformerByDrawingSearch(a))return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(D=this._renderManagerService.getRenderById(a))==null?void 0:D.with(b.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:p,data:h,allowTransform:f=!0}=e,w=i!=null?i:l.generateRandomId(),{position:S,position$:_}=this._createRangePositionObserver({startRow:0,endRow:0,startColumn:t,endColumn:t},u,c.skeleton),I=S;if(I.startY=0,this._getPosition(S,a)==null)return;const R={unitId:a,subUnitId:d,drawingId:w,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:p,transform:{left:I.startX,top:I.startY,width:I.width,height:I.height},data:h,allowTransform:f};{const{unitId:U,subUnitId:E,drawingId:P}=R,N=y.getSheetCommandTarget(this._univerInstanceService,{unitId:U,subUnitId:E}),O=R,T=this._univerInstanceService.getUnit(U,l.UniverInstanceType.UNIVER_SHEET);if(!T)return;const B=T.getActiveSheet().getSheetId();if(!O||!N)return;const $=(M=this._renderManagerService.getRenderById(U))==null?void 0:M.with(b.SheetSkeletonManagerService);if(!$)return;const z=$.getWorksheetSkeleton(E);if(!z)return;const{transform:J,data:H}=O,V=this._getSceneAndTransformerByDrawingSearch(U);if(V==null)return;const{scene:Q,canvas:X}=V;if(J==null||B!==E)return;const{left:Y,top:he,width:pe,height:je,angle:ke,flipX:We,flipY:Be,skewX:it,skewY:st}=J,Ye=j.getDrawingShapeKeyByDrawingSearch({unitId:U,subUnitId:E,drawingId:P}),Fe=Q.getObject(Ye);if(Fe!=null){Fe.transformByState({left:Y,top:he,width:pe,height:je,angle:ke,flipX:We,flipY:Be,skewX:it,skewY:st});return}const me=Ve({startX:I.startX,startY:0,endX:S.endX,endY:S.endY,width:n.width,height:n.height,absolute:{left:S.absolute.left,top:S.absolute.top}},n),$e={left:me.startX,top:me.startY,width:me.width,height:me.height,zIndex:this._drawingManagerService.getDrawingOrder(U,E).length-1},se=new k.Rect(Ye,$e);Q.addObject(se,k.DRAWING_OBJECT_LAYER_INDEX),O.allowTransform!==!1&&Q.attachTransformerTo(se);const ee=new l.DisposableCollection,we=Q.getMainViewport(),oe={top:0,left:we.left,bottom:we.bottom,right:we.right},ae={dispose:ee,rect:se,unitId:U,subUnitId:E,boundsOfViewArea:oe,domAnchor:n,scrollDirectionResponse:"HORIZONTAL"},Ge=ie(se,V.renderUnit.scene,z.skeleton,N.worksheet,ae),fe=new A.BehaviorSubject(Ge);ae.position$=fe;let Ce={position$:fe,id:P,componentKey:O.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:x=>{X.dispatchEvent(new WheelEvent(x.type,x))},data:H,unitId:U};e.eventPassThrough&&(Ce={...Ce,onPointerDown:x=>{X.dispatchEvent(new PointerEvent(x.type,x))},onPointerMove:x=>{X.dispatchEvent(new PointerEvent(x.type,x))},onPointerUp:x=>{X.dispatchEvent(new PointerEvent(x.type,x))}}),this._canvasFloatDomService.addFloatDom(Ce);const xe=se.onTransformChange$.subscribeEvent(()=>{const x=ie(se,V.renderUnit.scene,z.skeleton,N.worksheet,ae);fe.next(x)});this.disposeWithMe(_.subscribe(x=>{const Se=Ve({startX:x.startX,startY:0,endX:x.endX,endY:x.endY,width:n.width,height:n.height,absolute:{left:S.absolute.left,top:S.absolute.top}},n),Te=j.getDrawingShapeKeyByDrawingSearch({unitId:U,subUnitId:E,drawingId:P}),Me=new k.Rect(Te,{left:Se.startX,top:0,width:n.width,height:n.height,zIndex:this._drawingManagerService.getDrawingOrder(U,E).length-1}),Le=ie(Me,V.renderUnit.scene,z.skeleton,N.worksheet,ae);fe.next(Le)}));const ce=(v=this._renderManagerService.getRenderById(U))==null?void 0:v.with(b.SheetSkeletonManagerService);ce==null||ce.currentSkeleton$.subscribe(x=>{x&&c.sheetId!==x.sheetId&&this._removeDom(w,!0)}),ee.add(()=>{this._canvasFloatDomService.removeFloatDom(P)}),xe&&ee.add(xe),this._domLayerInfoMap.set(P,ae)}return{id:w,dispose:()=>{this._removeDom(w,!0)}}}_createRangePositionObserver(t,e,n){let{startRow:i,startColumn:o}=t;const a=Oe(i,o,n),d=new A.BehaviorSubject(a),g=Oe(t.endRow,t.endColumn,n),u=new A.BehaviorSubject(g),c=()=>{const _=Oe(i,o,n),I=Oe(t.endRow,t.endColumn,n);d.next(_),u.next(I)},p=new l.DisposableCollection;p.add(e.engine.clientRect$.subscribe(()=>c())),p.add(this._commandService.onCommandExecuted(_=>{if(_.id===y.SetWorksheetRowAutoHeightMutation.id&&_.params.rowsAutoHeightInfo.findIndex(C=>C.row===i)>-1){c();return}(y.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(_.id)>-1||_.id===b.SetScrollOperation.id||_.id===b.SetZoomRatioOperation.id)&&c()}));const h=(_,I)=>{i=_,o=I,c()},f=()=>({rotate:0,width:g.right-a.left,height:g.bottom-a.top,absolute:{left:!0,top:!0},startX:a.left,startY:a.top,endX:g.right,endY:g.bottom}),w=d.pipe(A.map(_=>{const I=Oe(t.endRow,t.endColumn,n);return{rotate:0,width:I.right-_.left,height:I.bottom-_.top,absolute:{left:!0,top:!0},startX:_.left,startY:_.top,endX:I.right,endY:I.bottom}})),S=f();return{position$:w,position:S,updateRowCol:h,topLeftPos$:d,rightBottomPos$:u,disposable:p}}};exports.SheetCanvasFloatDomManagerService=gn([ue(0,l.Inject(k.IRenderManagerService)),ue(1,l.IUniverInstanceService),ue(2,l.Inject(l.ICommandService)),ue(3,j.IDrawingManagerService),ue(4,l.Inject(W.CanvasFloatDomService)),ue(5,m.ISheetDrawingService),ue(6,l.Inject(l.LifecycleService))],exports.SheetCanvasFloatDomManagerService);function Oe(s,r,t){const e=t.getCellWithCoordByIndex(s,r),n=e.isMergedMainCell?e.mergeInfo:e;return{left:n.startX,right:n.endX,top:n.startY,bottom:n.endY}}function Ve(s,r,t){var g,u;t=t!=null?t:1;const e=s.endX-s.startX,n=s.endY-s.startY,i=(g=r==null?void 0:r.width)!=null?g:e,o=(u=r==null?void 0:r.height)!=null?u:n;let a=0,d=0;if(r){if(r.horizonOffsetAlign==="right"){const c=Ke(r.marginX,e*t);a=s.endX-c-i}else a=s.startX+Ke(r.marginX,e);if(r.verticalOffsetAlign==="bottom"){const c=Ke(r.marginY,n*t);d=s.endY-c-o}else d=s.startY+Ke(r.marginY,n)}return{rotate:0,startX:a,startY:d,endX:s.endX,endY:s.endY,width:i,height:o,absolute:{left:s.absolute.left,top:s.absolute.top}}}function Ke(s,r){if(s===void 0)return 0;if(typeof s=="number")return s;const t=Number.parseFloat(s);return r*t/100}const hn=s=>{const{floatDomInfos:r,scene:t,skeleton:e,worksheet:n}=s,i=Ie.useMemo(()=>r.map(o=>{const{width:a,height:d,angle:g,left:u,top:c}=o.transform,p=Ut({left:u!=null?u:0,right:(u!=null?u:0)+(a!=null?a:0),top:c!=null?c:0,bottom:(c!=null?c:0)+(d!=null?d:0)},t,e,n,void 0,!0),{scaleX:h,scaleY:f}=t.getAncestorScale(),w={startX:p.left,endX:p.right,startY:p.top,endY:p.bottom,rotate:g,width:a*h,height:d*f,absolute:p.absolute},S={position$:new A.BehaviorSubject(w),position:w,id:o.drawingId,componentKey:o.componentKey,onPointerMove:()=>{},onPointerDown:()=>{},onPointerUp:()=>{},onWheel:()=>{},unitId:o.unitId,data:o.data};return[o.drawingId,S]}),[r,t,e,n]);return Z.jsx("div",{style:{position:"absolute",top:0,left:0},children:i.map(([o,a])=>Z.jsx(W.PrintFloatDomSingle,{layer:a,id:o,position:a.position},o))})};var pn=Object.getOwnPropertyDescriptor,mn=(s,r,t,e)=>{for(var n=e>1?void 0:e?pn(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},ge=(s,r)=>(t,e)=>r(t,e,s);let nt=class extends l.Disposable{constructor(s,r,t,e,n,i,o){super(),this._sheetPrintInterceptorService=s,this._drawingRenderService=r,this._drawingManagerService=t,this._renderManagerService=e,this._canvasFloatDomManagerService=n,this._componetManager=i,this._injector=o,this._initPrinting(),this._initPrintingDom()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(s,r,t)=>{const{unitId:e,scene:n,subUnitId:i}=r,o=this._drawingManagerService.getDrawingDataForUnit(e),a=o==null?void 0:o[i];return a&&a.order.forEach(d=>{const g=a.data[d];g.drawingType!==l.DrawingTypeEnum.DRAWING_CHART&&g.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&this._drawingRenderService.renderDrawing(g,n)}),t()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(s,r,t)=>{const{unitId:e,subUnitId:n}=r,i=this._renderManagerService.getRenderById(e);if(!i)return t(s);const o=i.with(b.SheetSkeletonManagerService).getSkeletonParam(n);if(!o)return t(s);const a=this._drawingManagerService.getDrawingDataForUnit(e),d=a==null?void 0:a[r.subUnitId];if(!d)return t(s);const{scaleX:g,scaleY:u}=i.scene,c=s?{...s}:{startColumn:0,endColumn:0,endRow:0,startRow:0},p=d.order.map(h=>d.data[h]);return p.length?(p.forEach(h=>{if(!h.groupId&&h.transform&&l.Tools.isDefine(h.transform.left)&&l.Tools.isDefine(h.transform.top)&&l.Tools.isDefine(h.transform.width)&&l.Tools.isDefine(h.transform.height)){const f=o.skeleton.getCellIndexByOffset(h.transform.left,h.transform.top,g,u,{x:0,y:0}),w=o.skeleton.getCellIndexByOffset(h.transform.left+h.transform.width,h.transform.top+h.transform.height,g,u,{x:0,y:0});f.column<c.startColumn&&(c.startColumn=f.column),f.row<c.startRow&&(c.startRow=f.row),c.endRow<w.row&&(c.endRow=w.row),c.endColumn<w.column&&(c.endColumn=w.column)}}),t(c)):t(s)}}))}_initPrintingDom(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{handler:(s,r,t)=>{const{unitId:e,subUnitId:n}=r,i=this._drawingManagerService.getDrawingDataForUnit(e),o=i==null?void 0:i[n];if(o){const a=o.order.map(g=>{const u=o.data[g];if(u.drawingType===l.DrawingTypeEnum.DRAWING_CHART)return{...u,componentKey:this._componetManager.get(l.PRINT_CHART_COMPONENT_KEY)};if(u.drawingType===l.DrawingTypeEnum.DRAWING_DOM){const c=this._sheetPrintInterceptorService.getPrintComponent(u.componentKey);return{...u,componentKey:this._componetManager.get(c||u.componentKey)}}return null}).filter(Boolean),d=W.connectInjector(hn,this._injector);return q.render(Z.jsx(d,{floatDomInfos:a,scene:r.scene,skeleton:r.skeleton,worksheet:r.worksheet}),r.root),s==null||s.add(()=>{q.unmount(r.root)}),t(s)}}}))}};nt=mn([ge(0,l.Inject(b.SheetPrintInterceptorService)),ge(1,l.Inject(le.DrawingRenderService)),ge(2,j.IDrawingManagerService),ge(3,k.IRenderManagerService),ge(4,l.Inject(exports.SheetCanvasFloatDomManagerService)),ge(5,l.Inject(W.ComponentManager)),ge(6,l.Inject(l.Injector))],nt);var wn=Object.getOwnPropertyDescriptor,fn=(s,r,t,e)=>{for(var n=e>1?void 0:e?wn(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},de=(s,r)=>(t,e)=>r(t,e,s);const Sn=[y.InsertRowCommand.id,y.InsertColCommand.id,y.RemoveRowCommand.id,y.RemoveColCommand.id,y.DeleteRangeMoveLeftCommand.id,y.DeleteRangeMoveUpCommand.id,y.InsertRangeMoveDownCommand.id,y.InsertRangeMoveRightCommand.id,y.DeltaRowHeightCommand.id,y.SetRowHeightCommand.id,y.DeltaColumnWidthCommand.id,y.SetColWidthCommand.id,y.SetRowHiddenCommand.id,y.SetSpecificRowsVisibleCommand.id,y.SetSpecificColsVisibleCommand.id,y.SetColHiddenCommand.id,y.MoveColsCommand.id,y.MoveRowsCommand.id,y.MoveRangeCommand.id],_n=[y.SetRowVisibleMutation.id,y.SetRowHiddenMutation.id,y.SetColVisibleMutation.id,y.SetColHiddenMutation.id,y.SetWorksheetRowHeightMutation.id,y.SetWorksheetColWidthMutation.id];let lt=class extends l.Disposable{constructor(s,r,t,e,n,i,o,a,d){super(),this._context=s,this._renderManagerService=r,this._commandService=t,this._selectionRenderService=e,this._skeletonManagerService=n,this._sheetInterceptorService=i,this._sheetDrawingService=o,this._drawingManagerService=a,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({getMutations:s=>{if(!Sn.includes(s.id))return{redos:[],undos:[]};if(s.params==null)return{redos:[],undos:[]};const r=s.id;if(r===y.InsertRowCommand.id)return this._moveRowInterceptor(s.params,"insert");if([y.MoveColsCommand.id,y.MoveRowsCommand.id,y.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(s.params);if(r===y.InsertColCommand.id)return this._moveColInterceptor(s.params,"insert");if(r===y.RemoveRowCommand.id)return this._moveRowInterceptor(s.params,"remove");if(r===y.RemoveColCommand.id)return this._moveColInterceptor(s.params,"remove");if(r===y.DeleteRangeMoveLeftCommand.id){const{range:t}=s.params;return this._getRangeMoveUndo(t,0)}else if(r===y.DeleteRangeMoveUpCommand.id){const{range:t}=s.params;return this._getRangeMoveUndo(t,1)}else if(r===y.InsertRangeMoveDownCommand.id){const{range:t}=s.params;return this._getRangeMoveUndo(t,2)}else if(r===y.InsertRangeMoveRightCommand.id){const{range:t}=s.params;return this._getRangeMoveUndo(t,3)}else if(r===y.SetRowHiddenCommand.id||r===y.SetSpecificRowsVisibleCommand.id){const t=s.params,{unitId:e,subUnitId:n,ranges:i}=t;return this._getDrawingUndoForRowVisible(e,n,i)}else if(r===y.SetSpecificColsVisibleCommand.id||r===y.SetColHiddenCommand.id){const t=s.params,{unitId:e,subUnitId:n,ranges:i}=t;return this._getDrawingUndoForColVisible(e,n,i)}else if(r===y.DeltaRowHeightCommand.id||r===y.SetRowHeightCommand.id||r===y.DeltaColumnWidthCommand.id||r===y.SetColWidthCommand.id){const t=s.params,{unitId:e,subUnitId:n,ranges:i}=t,o=r===y.DeltaRowHeightCommand.id||r===y.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,n,i,o)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(s,r){const t=y.getSheetCommandTarget(this._univerInstanceService);if(t==null)return{redos:[],undos:[]};const e=t.unitId,n=t.subUnitId,i=[],o=[],a=this._sheetDrawingService.getDrawingData(e,n),d=[],g=[];if(Object.keys(a).forEach(u=>{const c=a[u],{updateDrawings:p,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(s,r,c);d.push(...p),g.push(...h)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(d),{undo:c,redo:p,objects:h}=u;i.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:p,objects:h,type:m.DrawingApplyType.UPDATE}}),o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:c,objects:h,type:m.DrawingApplyType.UPDATE}})}if(g.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(g),c=u.undo,p=u.redo,h=u.objects;i.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:p,objects:h,type:m.DrawingApplyType.REMOVE}}),o.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:c,objects:h,type:m.DrawingApplyType.INSERT}})}return i.push({id:L.id,params:[e]}),o.push({id:L.id,params:[e]}),{redos:i,undos:o}}_getUpdateOrDeleteDrawings(s,r,t){const e=[],n=[],{sheetTransform:i,anchorType:o=m.SheetDrawingAnchorType.Position,transform:a,unitId:d,subUnitId:g,drawingId:u}=t,{from:c,to:p}=i,{row:h,column:f}=c,{row:w,column:S}=p;if(i==null||a==null)return{updateDrawings:e,deleteDrawings:n};const{startRow:_,endRow:I,startColumn:C,endColumn:R}=s;let D=null,M=null;if(r===0&&h>=_&&w<=I)if(f>=C&&S<=R)n.push({unitId:d,subUnitId:g,drawingId:u});else{const v=this._shrinkCol(i,a,C,R,o);D=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(r===1&&f>=C&&S<=R)if(h>=_&&w<=I)n.push({unitId:d,subUnitId:g,drawingId:u});else{const v=this._shrinkRow(i,a,_,I,o);D=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(r===2){const v=this._expandRow(i,a,_,I,o);D=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(r===3){const v=this._expandCol(i,a,C,R,o);D=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}if(D!=null&&M!=null){const v=K(D,this._selectionRenderService,this._skeletonManagerService);e.push({...t,sheetTransform:D,transform:v})}return{updateDrawings:e,deleteDrawings:n}}_remainDrawingSize(s,r,t){const e=G({...s},this._selectionRenderService);e!=null&&r.push({...t,sheetTransform:e})}_getDrawingUndoForColVisible(s,r,t){const e=this._drawingManagerService.getDrawingData(s,r),n=[],i=[];if(Object.keys(e).forEach(u=>{const c=e[u],{sheetTransform:p,transform:h,anchorType:f=m.SheetDrawingAnchorType.Position}=c;if(f===m.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:w,to:S}=p,{row:_,column:I}=w,{row:C,column:R}=S;for(let D=0;D<t.length;D++){const M=t[D],{startRow:v,endRow:U,startColumn:E,endColumn:P}=M;if(R<E)continue;if(f===m.SheetDrawingAnchorType.Position){let T=null,B=null;if(I>=E&&I<=P){const $=this._skeletonManagerService.attachRangeWithCoord({startColumn:I,endColumn:P,startRow:w.row,endRow:S.row});if($==null)return;B={...h,left:$.startX}}if(B!=null&&(T=G(B,this._selectionRenderService),T!=null&&B!=null)){n.push({...c,sheetTransform:T,transform:B});break}this._remainDrawingSize(h,n,c);continue}if(I>=E&&R<=P)continue;let N=null,O=null;if(I>=E&&I<=P){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:I,endColumn:P,startRow:w.row,endRow:S.row});if(T==null)return;O={...h,left:(T==null?void 0:T.startX)||0,width:((h==null?void 0:h.width)||0)-T.endX+T.startX}}else if(R>=E&&R<=P){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:R,startRow:w.row,endRow:S.row});if(T==null)return;O={...h,left:T.startX-((h==null?void 0:h.width)||0)}}else{const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:E,endColumn:P,startRow:w.row,endRow:S.row});if(T==null)return;if(O={...h,width:((h==null?void 0:h.width)||0)-T.endX+T.startX},N=G(O,this._selectionRenderService),N!=null&&O!=null){i.push({...c,sheetTransform:N,transform:O});break}}if(O!=null&&(N=G(O,this._selectionRenderService)),O!=null&&N!=null){n.push({...c,sheetTransform:N,transform:O});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&i.length===0)return{redos:[],undos:[]};const{redos:o,undos:a}=this._createUndoAndRedoMutation(s,r,n),d=[],g=[];if(i.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(s,r,i);d.push(...u),g.push(...c)}return{redos:o,undos:a,preRedos:d,preUndos:g}}_createUndoAndRedoMutation(s,r,t){const e=this._sheetDrawingService.getBatchUpdateOp(t),{undo:n,redo:i,objects:o}=e,a=[{id:m.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:r,op:i,objects:o,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[s]}],d=[{id:m.SetDrawingApplyMutation.id,params:{unitId:s,subUnitId:r,op:n,objects:o,type:m.DrawingApplyType.UPDATE}},{id:L.id,params:[s]}];return{redos:a,undos:d}}_getDrawingUndoForRowVisible(s,r,t){const e=this._drawingManagerService.getDrawingData(s,r),n=[],i=[];if(Object.keys(e).forEach(u=>{const c=e[u],{sheetTransform:p,transform:h,anchorType:f=m.SheetDrawingAnchorType.Position}=c;if(f===m.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:w,to:S}=p,{row:_,column:I}=w,{row:C,column:R}=S;for(let D=0;D<t.length;D++){const M=t[D],{startRow:v,endRow:U,startColumn:E,endColumn:P}=M;if(C<v)continue;if(f===m.SheetDrawingAnchorType.Position){let T=null,B=null;if(_>=v&&_<=U){const $=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:_,endRow:U});if($==null)return;B={...h,top:$.startY}}if(B!=null&&(T=G(B,this._selectionRenderService),T!=null&&B!=null)){n.push({...c,sheetTransform:T,transform:B});break}this._remainDrawingSize(h,n,c);continue}if(_>=v&&C<=U)continue;let N=null,O=null;if(_>=v&&_<=U){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:_,endRow:U});if(T==null)return;O={...h,top:(T==null?void 0:T.startY)||0,height:((h==null?void 0:h.height)||0)-T.endY+T.startY}}else if(C>=v&&C<=U){const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:C});if(T==null)return;O={...h,top:T.startY-((h==null?void 0:h.height)||0)}}else{const T=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:U});if(T==null)return;if(O={...h,height:((h==null?void 0:h.height)||0)-T.endY+T.startY},N=G(O,this._selectionRenderService),N!=null&&O!=null){i.push({...c,sheetTransform:N,transform:O});break}}if(O!=null&&(N=G(O,this._selectionRenderService)),O!=null&&N!=null){n.push({...c,sheetTransform:N,transform:O});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&i.length===0)return{redos:[],undos:[]};const{redos:o,undos:a}=this._createUndoAndRedoMutation(s,r,n),d=[],g=[];if(i.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(s,r,i);d.push(...u),g.push(...c)}return{redos:o,undos:a,preRedos:d,preUndos:g}}_getDrawingUndoForRowAndColSize(s,r,t,e){const n=this._drawingManagerService.getDrawingData(s,r),i=[];return Object.keys(n).forEach(o=>{const a=n[o],{sheetTransform:d,transform:g,anchorType:u=m.SheetDrawingAnchorType.Position}=a;if(u===m.SheetDrawingAnchorType.None)this._remainDrawingSize(g,i,a);else{const{from:c,to:p}=d,{row:h,column:f}=c,{row:w,column:S}=p;for(let _=0;_<t.length;_++){const I=t[_],{startRow:C,endRow:R,startColumn:D,endColumn:M}=I;if(w<C||S<D)continue;if(u===m.SheetDrawingAnchorType.Position&&(h<=C&&w>=R||f<=D&&S>=M)){this._remainDrawingSize(g,i,a);continue}const v=K({...d},this._selectionRenderService,this._skeletonManagerService);if(v!=null){i.push({...a,transform:v});break}}}}),i.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(s,r,i)}_getUnitIdAndSubUnitId(s,r){let t,e;if(r==="insert")t=s.unitId,e=s.subUnitId;else{const n=y.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;t=n.unitId,e=n.subUnitId}return{unitId:t,subUnitId:e}}_moveRangeInterceptor(s){var C,R;const{toRange:r,fromRange:t}=s,e=y.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:n,subUnitId:i}=e,o=(R=(C=this._renderManagerService.getRenderById(n))==null?void 0:C.with(b.SheetSkeletonManagerService))==null?void 0:R.getCurrentSkeleton();if(!o)return{redos:[],undos:[]};const a=b.attachRangeWithCoord(o,t);if(!a)return{redos:[],undos:[]};const{startX:d,endX:g,startY:u,endY:c}=a,p=this._sheetDrawingService.getDrawingData(n,i),h=[];Object.keys(p).forEach(D=>{const M=p[D];if(M.anchorType!==m.SheetDrawingAnchorType.Both)return;const{transform:v}=M;if(!v)return;const{left:U=0,top:E=0,width:P=0,height:N=0}=v,{drawingStartX:O,drawingEndX:T,drawingStartY:B,drawingEndY:$}={drawingStartX:U,drawingEndX:U+P,drawingStartY:E,drawingEndY:E+N};d<=O&&T<=g&&u<=B&&$<=c&&h.push(M)});const f=[],w=[],S=r.startRow-t.startRow,_=r.startColumn-t.startColumn,I=h.map(D=>{const M=D.sheetTransform,v={to:{...M.to,row:M.to.row+S,column:M.to.column+_},from:{...M.from,row:M.from.row+S,column:M.from.column+_}},U=K(v,this._selectionRenderService,this._skeletonManagerService);return{unitId:n,subUnitId:i,drawingId:D.drawingId,transform:U,sheetTransform:v}});if(I.length){const D=this._sheetDrawingService.getBatchUpdateOp(I),{undo:M,redo:v,objects:U}=D;f.push({id:m.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:i,op:v,objects:U,type:m.DrawingApplyType.UPDATE}}),w.push({id:m.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:i,op:M,objects:U,type:m.DrawingApplyType.UPDATE}})}return{redos:f,undos:w}}_moveRowInterceptor(s,r){const t=this._getUnitIdAndSubUnitId(s,r);if(t==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:n}=t,{range:i}=s,o=i.startRow,a=i.endRow,d=[],g=[],u=this._sheetDrawingService.getDrawingData(e,n),c=[],p=[];if(Object.keys(u).forEach(h=>{const f=u[h],{sheetTransform:w,transform:S,anchorType:_=m.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let I,C;if(r==="insert"){const D=this._expandRow(w,S,o,a,_);I=D==null?void 0:D.newSheetTransform,C=D==null?void 0:D.newTransform}else{const{from:D,to:M}=w,{row:v}=D,{row:U}=M;if(_===m.SheetDrawingAnchorType.Both&&v>=o&&U<=a)p.push({unitId:e,subUnitId:n,drawingId:h});else{const E=this._shrinkRow(w,S,o,a,_);I=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!I||!C)return;const R={unitId:e,subUnitId:n,drawingId:h,transform:C,sheetTransform:I};c.push(R)}),c.length===0&&p.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:f,redo:w,objects:S}=h;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:w,objects:S,type:m.DrawingApplyType.UPDATE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:S,type:m.DrawingApplyType.UPDATE}})}if(p.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(p),f=h.undo,w=h.redo,S=h.objects;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:w,objects:S,type:m.DrawingApplyType.REMOVE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:S,type:m.DrawingApplyType.INSERT}})}return d.push({id:L.id,params:[e]}),g.push({id:L.id,params:[e]}),{redos:d,undos:g}}_moveColInterceptor(s,r){const t=this._getUnitIdAndSubUnitId(s,r);if(t==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:n}=t,{range:i}=s,o=i.startColumn,a=i.endColumn,d=[],g=[],u=this._sheetDrawingService.getDrawingData(e,n),c=[],p=[];if(Object.keys(u).forEach(h=>{const f=u[h],{sheetTransform:w,transform:S,anchorType:_=m.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let I,C;if(r==="insert"){const D=this._expandCol(w,S,o,a,_);I=D==null?void 0:D.newSheetTransform,C=D==null?void 0:D.newTransform}else{const{from:D,to:M}=w,{column:v}=D,{column:U}=M;if(_===m.SheetDrawingAnchorType.Both&&v>=o&&U<=a)p.push({unitId:e,subUnitId:n,drawingId:h});else{const E=this._shrinkCol(w,S,o,a,_);I=E==null?void 0:E.newSheetTransform,C=E==null?void 0:E.newTransform}}if(!I||!C)return;const R={unitId:e,subUnitId:n,drawingId:h,transform:C,sheetTransform:I};c.push(R)}),c.length===0&&p.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:f,redo:w,objects:S}=h;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:w,objects:S,type:m.DrawingApplyType.UPDATE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:S,type:m.DrawingApplyType.UPDATE}})}if(p.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(p),f=h.undo,w=h.redo,S=h.objects;d.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:w,objects:S,type:m.DrawingApplyType.REMOVE}}),g.push({id:m.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:n,op:f,objects:S,type:m.DrawingApplyType.INSERT}})}return d.push({id:L.id,params:[e]}),g.push({id:L.id,params:[e]}),{redos:d,undos:g}}_expandCol(s,r,t,e,n=m.SheetDrawingAnchorType.Position){const i=e-t+1,{from:o,to:a}=s,{column:d}=o,{column:g}=a;if(n===m.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=t){const p=this._skeletonManagerService.attachRangeWithCoord({startColumn:t,endColumn:e,startRow:o.row,endRow:a.row});if(p==null)return;c={...r,left:(r.left||0)+p.endX-p.startX},u=G(c,this._selectionRenderService)}else if(g>=e)if(n===m.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,column:g+i}},c=K(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkCol(s,r,t,e,n=m.SheetDrawingAnchorType.Position){const i=e-t+1,{from:o,to:a}=s,{column:d}=o,{column:g}=a;if(n===m.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>e)u={from:{...o,column:d-i},to:{...a,column:g-i}},c=K(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=t&&g<=e)return null;if(d<t&&g>e)if(n===m.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,column:g-i}},c=K(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};else if(d>=t&&d<=e){if(d===t)c={...r,left:(r.left||0)-s.from.columnOffset};else{const p=this._skeletonManagerService.attachRangeWithCoord({startColumn:t,endColumn:d-1,startRow:o.row,endRow:a.row});if(p==null)return;c={...r,left:(r.left||0)-p.endX+p.startX-s.from.columnOffset}}u=G(c,this._selectionRenderService)}else if(g>=t&&g<=e&&n===m.SheetDrawingAnchorType.Both){const p=this._skeletonManagerService.attachRangeWithCoord({startColumn:t-1,endColumn:t-1,startRow:o.row,endRow:a.row});if(p==null)return;u={from:{...o},to:{...a,column:t-1,columnOffset:p.endX-p.startX}},c=K(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_expandRow(s,r,t,e,n=m.SheetDrawingAnchorType.Position){const i=e-t+1,{from:o,to:a}=s,{row:d}=o,{row:g}=a;if(n===m.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=t){const p=this._skeletonManagerService.attachRangeWithCoord({startRow:t,endRow:e,startColumn:o.column,endColumn:a.column});if(p==null)return;c={...r,top:(r.top||0)+p.endY-p.startY},u=G(c,this._selectionRenderService)}else if(g>=e)if(n===m.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,row:g+i}},c=K(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkRow(s,r,t,e,n=m.SheetDrawingAnchorType.Position){const i=e-t+1,{from:o,to:a}=s,{row:d}=o,{row:g}=a;if(n===m.SheetDrawingAnchorType.None)return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>e)u={from:{...o,row:d-i},to:{...a,row:g-i}},c=K(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=t&&g<=e)return null;if(d<t&&g>e)if(n===m.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,row:g-i}},c=K(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:G({...r},this._selectionRenderService),newTransform:r};else if(d>=t&&d<=e){if(d===t)c={...r,top:(r.top||0)-s.from.rowOffset};else{const p=this._skeletonManagerService.attachRangeWithCoord({startRow:t,endRow:d-1,startColumn:o.column,endColumn:a.column});if(p==null)return;c={...r,top:(r.top||0)-p.endY+p.startY-s.from.rowOffset}}u=G(c,this._selectionRenderService)}else if(g>=t&&g<=e&&n===m.SheetDrawingAnchorType.Both){const p=this._skeletonManagerService.attachRangeWithCoord({startColumn:o.column,endColumn:o.column,startRow:t-1,endRow:t-1});if(p==null)return;u={from:{...o},to:{...a,row:t-1,rowOffset:p.endY-p.startY}},c=K(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(s=>{if(s.id===y.SetWorksheetActiveOperation.id){const{unitId:r,subUnitId:t}=s.params;this._updateDrawings(r,t)}})),this.disposeWithMe(this._context.activated$.subscribe(s=>{const{unit:r,unitId:t}=this._context;if(s){const e=r.getActiveSheet().getSheetId();this._updateDrawings(t,e)}else this._clearDrawings(t)}))}_clearDrawings(s){setTimeout(()=>{const r=this._drawingManagerService.drawingManagerData,t=[];Object.keys(r).forEach(e=>{const n=r[e];n!=null&&Object.keys(n).forEach(i=>{const o=n[i].data;o!=null&&Object.keys(o).forEach(a=>{e===s&&t.push(o[a])})})}),this._drawingManagerService.removeNotification(t)})}_updateDrawings(s,r){setTimeout(()=>{const t=this._drawingManagerService.drawingManagerData,e=[],n=[];Object.keys(t).forEach(i=>{const o=t[i];o!=null&&Object.keys(o).forEach(a=>{const d=o[a].data;d!=null&&Object.keys(d).forEach(g=>{if(i===s&&a===r){const u=d[g];u.transform=K(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),e.push(d[g])}else n.push(d[g])})})}),this._drawingManagerService.removeNotification(n),this._drawingManagerService.addNotification(e)},0)}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(s=>{_n.includes(s.id)&&requestIdleCallback(()=>{const r=s.params,{unitId:t,subUnitId:e,ranges:n}=r;this._refreshDrawingTransform(t,e,n)})}))}_refreshDrawingTransform(s,r,t){const e=this._drawingManagerService.getDrawingData(s,r),n=[];Object.keys(e).forEach(i=>{const o=e[i],{sheetTransform:a,transform:d,anchorType:g=m.SheetDrawingAnchorType.Position}=o;if(g===m.SheetDrawingAnchorType.None)return!0;const{from:u,to:c}=a,{row:p,column:h}=u,{row:f,column:w}=c;for(let S=0;S<t.length;S++){const _=t[S],{startRow:I,endRow:C,startColumn:R,endColumn:D}=_;if(l.Rectangle.intersects({startRow:I,endRow:C,startColumn:R,endColumn:D},{startRow:p,endRow:f,startColumn:h,endColumn:w})||p>C||h>D){const M=g===m.SheetDrawingAnchorType.Position,v=K(a,this._selectionRenderService,this._skeletonManagerService);n.push({...o,transform:{...v,width:M?d==null?void 0:d.width:v==null?void 0:v.width,height:M?d==null?void 0:d.height:v==null?void 0:v.height}});break}}}),n.length!==0&&(this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(L.id,[s]))}};lt=fn([de(1,k.IRenderManagerService),de(2,l.ICommandService),de(3,b.ISheetSelectionRenderService),de(4,l.Inject(b.SheetSkeletonManagerService)),de(5,l.Inject(y.SheetInterceptorService)),de(6,m.ISheetDrawingService),de(7,j.IDrawingManagerService),de(8,l.IUniverInstanceService)],lt);const vn=s=>{var I;const r=W.useDependency(l.ICommandService),t=W.useDependency(l.LocaleService),e=W.useDependency(j.IDrawingManagerService),n=W.useDependency(k.IRenderManagerService),{drawings:i}=s,o=i[0];if(o==null)return;const{unitId:a}=o,d=n.getRenderById(a),g=d==null?void 0:d.scene;if(g==null)return;const u=g.getTransformerByCreate(),[c,p]=Ie.useState(!0),h=(I=o.anchorType)!=null?I:m.SheetDrawingAnchorType.Position,[f,w]=Ie.useState(h);function S(C,R){const D=[];return C.forEach(M=>{const{oKey:v}=M,U=R.getDrawingOKey(v);if(U==null)return D.push(null),!0;const{unitId:E,subUnitId:P,drawingId:N,drawingType:O,anchorType:T,sheetTransform:B}=U;D.push({unitId:E,subUnitId:P,drawingId:N,anchorType:T,sheetTransform:B,drawingType:O})}),D}Ie.useEffect(()=>{const C=u.clearControl$.subscribe(D=>{D===!0&&p(!1)}),R=u.changeStart$.subscribe(D=>{var U;const{objects:M}=D,v=S(M,e);if(v.length===0)p(!1);else if(v.length>=1){p(!0);const E=((U=v[0])==null?void 0:U.anchorType)||m.SheetDrawingAnchorType.Position;w(E)}});return()=>{R.unsubscribe(),C.unsubscribe()}},[]);function _(C){w(C);const R=e.getFocusDrawings();if(R.length===0)return;const D=R.map(M=>({unitId:M.unitId,subUnitId:M.subUnitId,drawingId:M.drawingId,anchorType:C}));r.executeCommand(Ae.id,{unitId:R[0].unitId,drawings:D})}return Z.jsxs("div",{className:q.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!c}),children:[Z.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:Z.jsx("div",{children:t.t("drawing-anchor.title")})}),Z.jsx("div",{children:Z.jsxs(q.RadioGroup,{value:f,onChange:_,direction:"vertical",children:[Z.jsx(q.Radio,{value:m.SheetDrawingAnchorType.Both,children:t.t("drawing-anchor.both")}),Z.jsx(q.Radio,{value:m.SheetDrawingAnchorType.Position,children:t.t("drawing-anchor.position")}),Z.jsx(q.Radio,{value:m.SheetDrawingAnchorType.None,children:t.t("drawing-anchor.none")})]})})]})},In=()=>{const s=W.useDependency(j.IDrawingManagerService),r=s.getFocusDrawings(),[t,e]=Ie.useState(r);return Ie.useEffect(()=>{const n=s.focus$.subscribe(i=>{e(i)});return()=>{n.unsubscribe()}},[]),!!(t!=null&&t.length)&&Z.jsxs("div",{className:"univer-text-sm",children:[Z.jsx(le.DrawingCommonPanel,{drawings:t}),Z.jsx(vn,{drawings:t})]})},St="sheet.menu.image";function Dn(s){return{id:St,type:W.MenuItemType.SUBITEMS,icon:"AddImageIcon",tooltip:"sheetImage.title",hidden$:W.getMenuHiddenObservable(s,l.UniverInstanceType.UNIVER_SHEET),disabled$:b.getCurrentRangeDisable$(s,{workbookTypes:[y.WorkbookEditablePermission],worksheetTypes:[y.WorksheetEditPermission],rangeTypes:[y.RangeProtectionPermissionEditPoint]})}}function yn(s){return{id:Pe.id,title:"sheetImage.upload.float",type:W.MenuItemType.BUTTON,hidden$:W.getMenuHiddenObservable(s,l.UniverInstanceType.UNIVER_SHEET)}}function Cn(s){return{id:mt.id,title:"sheetImage.upload.cell",type:W.MenuItemType.BUTTON,hidden$:W.getMenuHiddenObservable(s,l.UniverInstanceType.UNIVER_SHEET)}}const Tn={[W.RibbonInsertGroup.MEDIA]:{[St]:{order:0,menuItemFactory:Dn,[Pe.id]:{order:0,menuItemFactory:yn},[mt.id]:{order:1,menuItemFactory:Cn}}}};function Ne(s){return!s.getContextValue(l.FOCUSING_FX_BAR_EDITOR)&&!s.getContextValue(l.EDITOR_ACTIVATED)&&!s.getContextValue(l.FOCUSING_PANEL_EDITOR)&&s.getContextValue(l.FOCUSING_COMMON_DRAWINGS)}const Mn={id:ye.id,description:"shortcut.drawing-move-down",group:"4_drawing-view",binding:W.KeyCode.ARROW_DOWN,priority:100,preconditions:Ne,staticParameters:{direction:l.Direction.DOWN}},Rn={id:ye.id,description:"shortcut.drawing-move-up",group:"4_drawing-view",binding:W.KeyCode.ARROW_UP,priority:100,preconditions:Ne,staticParameters:{direction:l.Direction.UP}},En={id:ye.id,description:"shortcut.drawing-move-left",group:"4_drawing-view",binding:W.KeyCode.ARROW_LEFT,priority:100,preconditions:Ne,staticParameters:{direction:l.Direction.LEFT}},bn={id:ye.id,description:"shortcut.drawing-move-right",group:"4_drawing-view",binding:W.KeyCode.ARROW_RIGHT,priority:100,preconditions:Ne,staticParameters:{direction:l.Direction.RIGHT}},On={id:ut.id,description:"shortcut.drawing-delete",group:"4_drawing-view",preconditions:Ne,binding:W.KeyCode.DELETE,mac:W.KeyCode.BACKSPACE};var Un=Object.getOwnPropertyDescriptor,An=(s,r,t,e)=>{for(var n=e>1?void 0:e?Un(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},ve=(s,r)=>(t,e)=>r(t,e,s);let rt=class extends l.Disposable{constructor(s,r,t,e,n,i){super(),this._componentManager=s,this._menuManagerService=r,this._commandService=t,this._shortcutService=e,this._drawingManagerService=n,this._sheetsSelectionsService=i,this._init()}_initCustomComponents(){const s=this._componentManager;this.disposeWithMe(s.register(Et,In))}_initMenus(){this._menuManagerService.mergeMenu(Tn)}_initCommands(){[Pe,mt,Ue,De,Ae,wt,L,ft,gt,pt,ye,ut,ht].forEach(s=>this.disposeWithMe(this._commandService.registerCommand(s)))}_initShortcuts(){[Mn,Rn,En,bn,On].forEach(s=>{this.disposeWithMe(this._shortcutService.registerShortcut(s))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};rt=An([ve(0,l.Inject(W.ComponentManager)),ve(1,W.IMenuManagerService),ve(2,l.ICommandService),ve(3,W.IShortcutService),ve(4,j.IDrawingManagerService),ve(5,l.Inject(y.SheetsSelectionsService))],rt);var Pn=Object.defineProperty,Nn=Object.getOwnPropertyDescriptor,jn=(s,r,t)=>r in s?Pn(s,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[r]=t,kn=(s,r,t,e)=>{for(var n=e>1?void 0:e?Nn(r,t):r,i=s.length-1,o;i>=0;i--)(o=s[i])&&(n=o(n)||n);return n},ot=(s,r)=>(t,e)=>r(t,e,s),At=(s,r,t)=>jn(s,typeof r!="symbol"?r+"":r,t);const Wn="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends l.Plugin{constructor(r=Ct,t,e,n){super(),this._config=r,this._injector=t,this._renderManagerService=e,this._configService=n;const{menu:i,...o}=l.merge({},Ct,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(xt,o)}onStarting(){l.registerDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService],[rt],[qe],[nt],[tt],[et],[Ze],[Je],[Qe]]),l.touchDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService]])}onReady(){l.touchDependencies(this._injector,[[et],[Qe]])}onRendered(){this._registerRenderModules(),l.touchDependencies(this._injector,[[tt],[nt],[rt],[Ze],[Je]])}onSteady(){this._injector.get(qe)}_registerRenderModules(){[[exports.SheetDrawingUpdateController],[lt],[dt],[ct]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,r))})}};At(exports.UniverSheetsDrawingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);At(exports.UniverSheetsDrawingUIPlugin,"pluginName",Wn);exports.UniverSheetsDrawingUIPlugin=kn([l.DependentOn(j.UniverDrawingPlugin,Rt.UniverDocsDrawingPlugin,le.UniverDrawingUIPlugin,m.UniverSheetsDrawingPlugin),ot(1,l.Inject(l.Injector)),ot(2,k.IRenderManagerService),ot(3,l.IConfigService)],exports.UniverSheetsDrawingUIPlugin);exports.ClearSheetDrawingTransformerOperation=L;exports.DeleteDrawingsCommand=ut;exports.EditSheetDrawingOperation=ft;exports.GroupSheetDrawingCommand=gt;exports.InsertFloatImageCommand=Pe;exports.InsertSheetDrawingCommand=Ue;exports.MoveDrawingsCommand=ye;exports.RemoveSheetDrawingCommand=De;exports.SHEETS_IMAGE_MENU_ID=St;exports.SetDrawingArrangeCommand=ht;exports.SetSheetDrawingCommand=Ae;exports.SidebarSheetDrawingOperation=wt;exports.UngroupSheetDrawingCommand=pt;exports.calcSheetFloatDomPosition=ie;exports.drawingPositionToTransform=K;exports.transformToDrawingPosition=G;
|
|
1
|
+
"use strict";var Jt=Object.defineProperty;var Qt=(i,r,e)=>r in i?Jt(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e;var ne=(i,r,e)=>Qt(i,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("@univerjs/engine-render"),E=require("@univerjs/sheets-ui"),l=require("@univerjs/core"),S=require("@univerjs/sheets-drawing"),C=require("@univerjs/sheets"),F=require("@univerjs/design"),Je=require("@univerjs/docs-ui"),j=require("@univerjs/drawing"),k=require("@univerjs/ui"),$t=require("@univerjs/docs-drawing"),he=require("@univerjs/drawing-ui"),O=require("rxjs"),B=require("react/jsx-runtime"),G=require("react");function Z(i,r,e){const{from:t,to:n,flipY:s=!1,flipX:o=!1,angle:a=0,skewX:d=0,skewY:g=0}=i,u=e.getCurrent();if(u==null)return;const c=E.convertPositionSheetOverGridToAbsolute(u.unitId,u.sheetId,{from:t,to:n},e);let{left:m,top:h,width:p,height:w}=c;const f=e.getCurrentSkeleton(),v=f.rowHeaderWidth+f.columnTotalWidth,_=f.columnHeaderHeight+f.rowTotalHeight;return m+p>v&&(m=v-p),h+w>_&&(h=_-w),{flipY:s,flipX:o,angle:a,skewX:d,skewY:g,left:m,top:h,width:p,height:w}}function Y(i,r){const{left:e=0,top:t=0,width:n=0,height:s=0,flipY:o=!1,flipX:a=!1,angle:d=0,skewX:g=0,skewY:u=0}=i,c=r.getCellWithCoordByOffset(e,t);if(c==null)return;const m={column:c.actualColumn,columnOffset:x.precisionTo(e-c.startX,1),row:c.actualRow,rowOffset:x.precisionTo(t-c.startY,1)},h=r.getCellWithCoordByOffset(e+n,t+s);if(h==null)return;const p={column:h.actualColumn,columnOffset:x.precisionTo(e+n-h.startX,1),row:h.actualRow,rowOffset:x.precisionTo(t+s-h.startY,1)};return{flipY:o,flipX:a,angle:d,skewX:g,skewY:u,from:m,to:p}}const X={id:"sheet.operation.clear-drawing-transformer",type:l.CommandType.MUTATION,handler:(i,r)=>{const e=i.get(x.IRenderManagerService);return r.forEach(t=>{var n,s;(s=(n=e.getRenderById(t))==null?void 0:n.scene.getTransformer())==null||s.debounceRefreshControls()}),!0}},Me={id:"sheet.command.remove-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var _,y,T;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(C.SheetInterceptorService),s=i.get(S.ISheetDrawingService);if(!r)return!1;const{drawings:o}=r,a=[];o.forEach(D=>{const{unitId:M}=D;a.push(M)});const d=s.getBatchRemoveOp(o),{unitId:g,subUnitId:u,undo:c,redo:m,objects:h}=d,p=n.onCommandExecute({id:Me.id,params:r}),w={id:S.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:m,objects:h,type:S.DrawingApplyType.REMOVE}},f={id:S.SetDrawingApplyMutation.id,params:{unitId:g,subUnitId:u,op:c,objects:h,type:S.DrawingApplyType.INSERT}};return l.sequenceExecute([...(_=p.preRedos)!=null?_:[],w,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(y=p.preUndos)!=null?y:[],f,...p.undos,{id:X.id,params:a}],redoMutations:[...(T=p.preRedos)!=null?T:[],w,...p.redos,{id:X.id,params:a}]}),!0):!1}},_t={id:"sheet.command.delete-drawing",type:l.CommandType.COMMAND,handler:i=>{const r=i.get(l.ICommandService),t=i.get(S.ISheetDrawingService).getFocusDrawings();if(t.length===0)return!1;const n=t[0].unitId,s=t.map(o=>{const{unitId:a,subUnitId:d,drawingId:g,drawingType:u}=o;return{unitId:a,subUnitId:d,drawingId:g,drawingType:u}});return r.executeCommand(Me.id,{unitId:n,drawings:s})}};function en(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:s,subUnitId:o,drawingId:a}=t,d=x.getGroupState(0,0,n.map(c=>c.transform||{})),g=n.map(c=>{const m=c.transform||{left:0,top:0},{unitId:h,subUnitId:p,drawingId:w}=c;return{unitId:h,subUnitId:p,drawingId:w,transform:{...m,left:m.left-d.left,top:m.top-d.top},groupId:a}}),u={unitId:s,subUnitId:o,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:d};r.push({parent:u,children:g})}),r}function tn(i){const r=[];return i.forEach(e=>{const{parent:t,children:n}=e,{unitId:s,subUnitId:o,drawingId:a,transform:d={width:0,height:0}}=t;if(d==null)return;const g=n.map(c=>{const{transform:m}=c,{unitId:h,subUnitId:p,drawingId:w}=c,f=x.transformObjectOutOfGroup(m||{},d,d.width||0,d.height||0);return{unitId:h,subUnitId:p,drawingId:w,transform:f,groupId:void 0}}),u={unitId:s,subUnitId:o,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};r.push({parent:u,children:g})}),r}const It={id:"sheet.command.group-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(S.ISheetDrawingService);if(!r)return!1;const s=[];r.forEach(({parent:h,children:p})=>{s.push(h.unitId),p.forEach(w=>{s.push(w.unitId)})});const o=n.getGroupDrawingOp(r),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=o;return e.syncExecuteCommand(S.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:S.DrawingApplyType.GROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:S.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:tn(c),type:S.DrawingApplyType.UNGROUP}},{id:X.id,params:s}],redoMutations:[{id:S.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:S.DrawingApplyType.GROUP}},{id:X.id,params:s}]}),!0):!1}},Ne={id:"sheet.command.insert-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{var _,y,T;const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(S.ISheetDrawingService),s=i.get(C.SheetInterceptorService);if(!r)return!1;const o=r.drawings,a=o.map(D=>D.unitId),d=n.getBatchAddOp(o),{unitId:g,subUnitId:u,undo:c,redo:m,objects:h}=d,p=s.onCommandExecute({id:Ne.id,params:r}),w={id:S.SetDrawingApplyMutation.id,params:{op:m,unitId:g,subUnitId:u,objects:h,type:S.DrawingApplyType.INSERT}},f={id:S.SetDrawingApplyMutation.id,params:{op:c,unitId:g,subUnitId:u,objects:h,type:S.DrawingApplyType.REMOVE}};return l.sequenceExecute([...(_=p.preRedos)!=null?_:[],w,...p.redos],e)?(t.pushUndoRedo({unitID:g,undoMutations:[...(y=p.preUndos)!=null?y:[],f,...p.undos,{id:X.id,params:a}],redoMutations:[...(T=p.preRedos)!=null?T:[],w,...p.redos,{id:X.id,params:a}]}),!0):!1}},Dt={id:"sheet.command.set-drawing-arrange",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService);if(!r)return!1;const n=i.get(S.ISheetDrawingService),{unitId:s,subUnitId:o,drawingIds:a,arrangeType:d}=r,g={unitId:s,subUnitId:o,drawingIds:a};let u;if(d===l.ArrangeTypeEnum.forward?u=n.getForwardDrawingsOp(g):d===l.ArrangeTypeEnum.backward?u=n.getBackwardDrawingOp(g):d===l.ArrangeTypeEnum.front?u=n.getFrontDrawingsOp(g):d===l.ArrangeTypeEnum.back&&(u=n.getBackDrawingsOp(g)),u==null)return!1;const{objects:c,redo:m,undo:h}=u;return e.syncExecuteCommand(S.SetDrawingApplyMutation.id,{op:m,unitId:s,subUnitId:o,objects:c,type:S.DrawingApplyType.ARRANGE})?(t.pushUndoRedo({unitID:s,undoMutations:[{id:S.SetDrawingApplyMutation.id,params:{op:h,unitId:s,subUnitId:o,objects:c,type:S.DrawingApplyType.ARRANGE}}],redoMutations:[{id:S.SetDrawingApplyMutation.id,params:{op:m,unitId:s,subUnitId:o,objects:c,type:S.DrawingApplyType.ARRANGE}}]}),!0):!1}},je={id:"sheet.command.set-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(S.ISheetDrawingService);if(!r)return!1;const{drawings:s}=r,o=n.getBatchUpdateOp(s),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=o;return e.syncExecuteCommand(S.SetDrawingApplyMutation.id,{unitId:a,subUnitId:d,op:u,objects:c,type:S.DrawingApplyType.UPDATE})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:S.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:g,objects:c,type:S.DrawingApplyType.UPDATE}},{id:X.id,params:[a]}],redoMutations:[{id:S.SetDrawingApplyMutation.id,params:{unitId:a,subUnitId:d,op:u,objects:c,type:S.DrawingApplyType.UPDATE}},{id:X.id,params:[a]}]}),!0):!1}},Ct={id:"sheet.command.ungroup-sheet-image",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(l.IUndoRedoService),n=i.get(S.ISheetDrawingService);if(!r)return!1;const s=[];r.forEach(({parent:h,children:p})=>{s.push(h.unitId),p.forEach(w=>{s.push(w.unitId)})});const o=n.getUngroupDrawingOp(r),{unitId:a,subUnitId:d,undo:g,redo:u,objects:c}=o;return e.syncExecuteCommand(S.SetDrawingApplyMutation.id,{op:u,unitId:a,subUnitId:d,objects:c,type:S.DrawingApplyType.UNGROUP})?(t.pushUndoRedo({unitID:a,undoMutations:[{id:S.SetDrawingApplyMutation.id,params:{op:g,unitId:a,subUnitId:d,objects:en(c),type:S.DrawingApplyType.GROUP}},{id:X.id,params:s}],redoMutations:[{id:S.SetDrawingApplyMutation.id,params:{op:u,unitId:a,subUnitId:d,objects:c,type:S.DrawingApplyType.UNGROUP}},{id:X.id,params:s}]}),!0):!1}};var nn=Object.getOwnPropertyDescriptor,rn=(i,r,e,t)=>{for(var n=t>1?void 0:t?nn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},re=(i,r)=>(e,t)=>r(e,t,i);function sn(i,r,e){const t=e*Math.PI/180,n=Math.abs(i*Math.cos(t))+Math.abs(r*Math.sin(t)),s=Math.abs(i*Math.sin(t))+Math.abs(r*Math.cos(t));return{rotatedWidth:n,rotatedHeight:s}}function pt(i,r,e,t,n){var _;const{rotatedHeight:s,rotatedWidth:o}=sn(e,t,n),d=i.get(x.IRenderManagerService).getRenderById(r.unitId);if(!d)return!1;const u=(_=d.with(E.SheetSkeletonManagerService).getSkeletonParam(r.subUnitId))==null?void 0:_.skeleton;if(u==null)return!1;const c=u.getCellByIndex(r.row,r.col),m=c.mergeInfo.endX-c.mergeInfo.startX-2,h=c.mergeInfo.endY-c.mergeInfo.startY-2,p=o/s,f=Math.ceil(Math.min(m,h*p))/o,v=!f||Number.isNaN(f)?.001:f;return{width:e*v,height:t*v}}exports.SheetDrawingUpdateController=class extends l.Disposable{constructor(e,t,n,s,o,a,d,g,u,c,m,h,p){super();ne(this,"_workbookSelections");this._context=e,this._skeletonManagerService=t,this._commandService=n,this._selectionRenderService=s,this._imageIoService=o,this._fileOpenerService=a,this._sheetDrawingService=d,this._drawingManagerService=g,this._contextService=u,this._messageService=c,this._localeService=m,this._injector=p,this._workbookSelections=h.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const e=await this._fileOpenerService.openFile({multiple:!0,accept:j.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}),t=e.length;return t>j.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:F.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(j.DRAWING_IMAGE_COUNT_LIMIT))}),!1):t===0?!1:(e.forEach(async n=>await this.insertFloatImageByFile(n)),!0)}async insertCellImage(){const t=(await this._fileOpenerService.openFile({multiple:!1,accept:j.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(n=>`.${n.replace("image/","")}`).join(",")}))[0];return t?(await this._insertCellImage(t),!0):!1}insertCellImageByFile(e,t){return this._insertCellImage(e,t)}async insertFloatImageByFile(e){let t;try{t=await this._imageIoService.saveImage(e)}catch(y){const T=y.message;T===j.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:F.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(j.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):T===j.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:F.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):T===j.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:F.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(t==null)return;const n=this._getUnitInfo(),{unitId:s,subUnitId:o}=n,{imageId:a,imageSourceType:d,source:g,base64Cache:u}=t,{width:c,height:m,image:h}=await j.getImageSize(u||""),{width:p,height:w}=this._context.scene;this._imageIoService.addImageSourceCache(g,d,h);let f=1;if(c>j.DRAWING_IMAGE_WIDTH_LIMIT||m>j.DRAWING_IMAGE_HEIGHT_LIMIT){const y=j.DRAWING_IMAGE_WIDTH_LIMIT/c,T=j.DRAWING_IMAGE_HEIGHT_LIMIT/m;f=Math.max(y,T)}const v=this._getImagePosition(c*f,m*f,p,w);if(v==null)return;const _={unitId:s,subUnitId:o,drawingId:a,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:d,source:g,transform:Z(v,this._selectionRenderService,this._skeletonManagerService),sheetTransform:v};return this._commandService.executeCommand(Ne.id,{unitId:s,drawings:[_]})}async _insertCellImage(e,t){var T,D;let n;try{n=await this._imageIoService.saveImage(e)}catch(M){const I=M.message;I===j.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:F.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(j.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===j.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:F.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===j.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:F.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(n==null)return!1;const{imageId:s,imageSourceType:o,source:a,base64Cache:d}=n,{width:g,height:u,image:c}=await j.getImageSize(d||"");this._imageIoService.addImageSourceCache(a,o,c);const m=this._workbookSelections.getCurrentLastSelection();if(!m)return!1;let h=m.primary.actualRow,p=m.primary.actualColumn;m.primary.isMerged&&(h=m.primary.startRow,p=m.primary.startColumn);const w=l.createDocumentModelWithStyle("",{}),f=pt(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:h,col:p},g,u,0);if(!f)return!1;const v={size:{width:f.width,height:f.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},_={unitId:w.getUnitId(),subUnitId:w.getUnitId(),drawingId:s,drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:o,source:a,transform:Je.docDrawingPositionToTransform(v),docTransform:v,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},y=l.BuildTextUtils.drawing.add({documentDataModel:w,drawings:[_],selection:{collapsed:!0,startOffset:0,endOffset:0}});return y?(w.apply(y),this._commandService.syncExecuteCommand(C.SetRangeValuesCommand.id,{value:{[(T=t==null?void 0:t.row)!=null?T:h]:{[(D=t==null?void 0:t.col)!=null?D:p]:{p:w.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})):!1}async insertCellImageByUrl(e,t){var h,p;const{width:n,height:s,image:o}=await j.getImageSize(e||"");this._imageIoService.addImageSourceCache(e,l.ImageSourceType.URL,o);const a=this._workbookSelections.getCurrentLastSelection();if(!a)return!1;const d=l.createDocumentModelWithStyle("",{}),g=pt(this._injector,{unitId:this._context.unitId,subUnitId:this._context.unit.getActiveSheet().getSheetId(),row:a.primary.actualRow,col:a.primary.actualColumn},n,s,0);if(!g)return!1;const u={size:{width:g.width,height:g.height},positionH:{relativeFrom:l.ObjectRelativeFromH.PAGE,posOffset:0},positionV:{relativeFrom:l.ObjectRelativeFromV.PARAGRAPH,posOffset:0},angle:0},c={unitId:d.getUnitId(),subUnitId:d.getUnitId(),drawingId:l.generateRandomId(),drawingType:l.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:l.ImageSourceType.URL,source:e,transform:Je.docDrawingPositionToTransform(u),docTransform:u,behindDoc:l.BooleanNumber.FALSE,title:"",description:"",layoutType:l.PositionedObjectLayoutType.INLINE,wrapText:l.WrapTextType.BOTH_SIDES,distB:0,distL:0,distR:0,distT:0},m=l.BuildTextUtils.drawing.add({documentDataModel:d,drawings:[c],selection:{collapsed:!0,startOffset:0,endOffset:0}});return m?(d.apply(m),this._commandService.syncExecuteCommand(C.SetRangeValuesCommand.id,{value:{[(h=t==null?void 0:t.row)!=null?h:a.primary.actualRow]:{[(p=t==null?void 0:t.col)!=null?p:a.primary.actualColumn]:{p:d.getSnapshot(),t:1}}},unitId:t==null?void 0:t.unitId,subUnitId:t==null?void 0:t.subUnitId})):!1}_getUnitInfo(){const e=this._context.unit,t=e.getActiveSheet(),n=e.getUnitId(),s=t.getSheetId();return{unitId:n,subUnitId:s}}_getImagePosition(e,t,n,s){const o=this._workbookSelections.getCurrentSelections();let a={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(a=o[o.length-1].range);const d=E.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,a);if(d==null)return;let{startColumn:g,startRow:u,startX:c,startY:m}=d,h=!1;if(c+e>n&&(c=n-e,c<0&&(c=0,e=n),h=!0),m+t>s&&(m=s-t,m<0&&(m=0,t=s),h=!0),h){const v=this._selectionRenderService.getCellWithCoordByOffset(c,m);if(v==null)return;c=v.startX,m=v.startY,g=v.actualColumn,u=v.actualRow}const p={column:g,columnOffset:0,row:u,rowOffset:0},w=this._selectionRenderService.getCellWithCoordByOffset(c+e,m+t);if(w==null)return;const f={column:w.actualColumn,columnOffset:c+e-w.startX,row:w.actualRow,rowOffset:m+t-w.startY};return{from:p,to:f}}_updateOrderListener(){this.disposeWithMe(this._drawingManagerService.featurePluginOrderUpdate$.subscribe(e=>{const{unitId:t,subUnitId:n,drawingIds:s,arrangeType:o}=e;this._commandService.executeCommand(Dt.id,{unitId:t,subUnitId:n,drawingIds:s,arrangeType:o})}))}_updateImageListener(){this.disposeWithMe(this._drawingManagerService.featurePluginUpdate$.subscribe(e=>{const t=[];e.length!==0&&(e.forEach(n=>{const{unitId:s,subUnitId:o,drawingId:a,drawingType:d,transform:g}=n;if(g==null)return;const u=this._sheetDrawingService.getDrawingByParam({unitId:s,subUnitId:o,drawingId:a});if(u==null||u.unitId!==this._context.unitId)return;const c=Y({...u.transform,...g},this._selectionRenderService);if(c==null)return;const m={...n,transform:{...u.transform,...g,...Z(c,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...c}};t.push(m)}),t.length>0&&this._commandService.executeCommand(je.id,{unitId:e[0].unitId,drawings:t}))}))}_groupDrawingListener(){this.disposeWithMe(this._drawingManagerService.featurePluginGroupUpdate$.subscribe(e=>{this._commandService.executeCommand(It.id,e);const{unitId:t,subUnitId:n,drawingId:s}=e[0].parent;this._commandService.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[{unitId:t,subUnitId:n,drawingId:s}])})),this.disposeWithMe(this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(e=>{this._commandService.executeCommand(Ct.id,e)}))}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(e=>{e==null||e.length===0?(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(e))}))}};exports.SheetDrawingUpdateController=rn([re(1,l.Inject(E.SheetSkeletonManagerService)),re(2,l.ICommandService),re(3,E.ISheetSelectionRenderService),re(4,j.IImageIoService),re(5,k.ILocalFileService),re(6,S.ISheetDrawingService),re(7,j.IDrawingManagerService),re(8,l.IContextService),re(9,k.IMessageService),re(10,l.Inject(l.LocaleService)),re(11,l.Inject(C.SheetsSelectionsService)),re(12,l.Inject(l.Injector))],exports.SheetDrawingUpdateController);const ke={id:"sheet.command.insert-float-image",type:l.CommandType.COMMAND,handler:async(i,r)=>{var o,a;const e=i.get(l.IUniverInstanceService),t=i.get(x.IRenderManagerService),n=(o=x.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,e,t))==null?void 0:o.with(exports.SheetDrawingUpdateController);if(!n)return!1;const s=r==null?void 0:r.files;if(s){const d=s.map(g=>n.insertFloatImageByFile(g));return(await Promise.all(d)).every(g=>g)}else return(a=n.insertFloatImage())!=null?a:!1}},yt={id:"sheet.command.insert-cell-image",type:l.CommandType.COMMAND,handler:i=>{var t,n;const r=i.get(l.IUniverInstanceService),e=i.get(x.IRenderManagerService);return(n=(t=x.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,r,e))==null?void 0:t.with(exports.SheetDrawingUpdateController).insertCellImage())!=null?n:!1}},Te={id:"sheet.command.move-drawing",type:l.CommandType.COMMAND,handler:(i,r)=>{const e=i.get(l.ICommandService),t=i.get(S.ISheetDrawingService),n=i.get(E.ISheetSelectionRenderService),{direction:s}=r,o=t.getFocusDrawings();if(o.length===0)return!1;const a=o[0].unitId,d=o.map(u=>{const{transform:c}=u;if(c==null)return null;const m={...c},{left:h=0,top:p=0}=c;return s===l.Direction.UP?m.top=p-1:s===l.Direction.DOWN?m.top=p+1:s===l.Direction.LEFT?m.left=h-1:s===l.Direction.RIGHT&&(m.left=h+1),{...u,transform:m,sheetTransform:Y(m,n)}}).filter(u=>u!=null);return e.syncExecuteCommand(je.id,{unitId:a,drawings:d})?(e.syncExecuteCommand(X.id,[a]),!0):!1}};var on=Object.getOwnPropertyDescriptor,an=(i,r,e,t)=>{for(var n=t>1?void 0:t?on(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},ut=(i,r)=>(e,t)=>r(e,t,i),ge=(i=>(i.CELL_ADDRESS="cellAddress",i.COLUMN_VALUE="columnValue",i))(ge||{});const ct=l.createIdentifier("sheets-drawing-ui.batch-save-images.service");function ft(i){let r="",e=i;for(;e>=0;)r=String.fromCharCode(e%26+65)+r,e=Math.floor(e/26)-1;return r}function Qe(i,r){return`${ft(r)}${i+1}`}function cn(i){const r=Qe(i.startRow,i.startColumn),e=Qe(i.endRow,i.endColumn);return r===e?r:`${r}:${e}`}function Pt(i){var r,e,t,n;return!!((e=(r=i==null?void 0:i.p)==null?void 0:r.drawingsOrder)!=null&&e.length&&((n=(t=i==null?void 0:i.p)==null?void 0:t.drawingsOrder)==null?void 0:n.length)>0)}function Nt(i){var t,n,s;if(!((n=(t=i.p)==null?void 0:t.drawingsOrder)!=null&&n.length)||!((s=i.p)!=null&&s.drawings))return null;const r=i.p.drawingsOrder[0],e=i.p.drawings[r];return!e||!("source"in e)||!("imageSourceType"in e)?null:e}function gt(i,r){if(r===l.ImageSourceType.BASE64){const e=i.match(/^data:image\/(\w+);/);if(e)return e[1]==="jpeg"?"jpg":e[1]}if(r===l.ImageSourceType.URL){const e=i.match(/\.(\w+)(?:\?|$)/);if(e)return e[1].toLowerCase()}return"png"}async function jt(i,r){if(r===l.ImageSourceType.BASE64)return(await fetch(i)).blob();if(r===l.ImageSourceType.URL)return(await fetch(i)).blob();throw new Error("UUID image type requires additional handling")}exports.BatchSaveImagesService=class extends l.Disposable{constructor(r,e,t){super(),this._univerInstanceService=r,this._selectionService=e,this._imageIoService=t}getCellImagesInSelection(){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!r)return[];const e=r.getActiveSheet();if(!e)return[];const t=this._selectionService.getCurrentSelections();if(!t||t.length===0)return[];const n=e.getCellMatrix(),s=[];for(const o of t){const{startRow:a,endRow:d,startColumn:g,endColumn:u}=o.range;for(let c=a;c<=d;c++)for(let m=g;m<=u;m++){const h=n.getValue(c,m);if(Pt(h)){const p=Nt(h);p&&s.push({row:c,col:m,cellAddress:Qe(c,m),source:p.source,imageSourceType:p.imageSourceType,imageId:p.drawingId})}}}return s}getCellImagesFromRanges(r,e,t){const n=this._univerInstanceService.getUnit(r,l.UniverInstanceType.UNIVER_SHEET);if(!n)return[];const s=n.getSheetBySheetId(e);if(!s)return[];const o=s.getCellMatrix(),a=[];for(const d of t){const{startRow:g,endRow:u,startColumn:c,endColumn:m}=d;for(let h=g;h<=u;h++)for(let p=c;p<=m;p++){const w=o.getValue(h,p);if(Pt(w)){const f=Nt(w);f&&a.push({row:h,col:p,cellAddress:Qe(h,p),source:f.source,imageSourceType:f.imageSourceType,imageId:f.drawingId})}}}return a}getDataColumns(){var m,h,p,w;const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!r)return[];const e=r.getActiveSheet();if(!e)return[];const t=this._selectionService.getCurrentSelections();if(!t||t.length===0)return[];const n=e.getCellMatrix(),s=n.getDataRange();let o=1/0,a=-1/0;const d=new Set;for(const f of t){o=Math.min(o,f.range.startRow),a=Math.max(a,f.range.endRow);for(let v=f.range.startColumn;v<=f.range.endColumn;v++)d.add(v)}const g=new Set;for(let f=s.startColumn;f<=s.endColumn;f++)if(!d.has(f))for(let v=o;v<=a;v++){const _=n.getValue(v,f);if(_&&(((m=_.v)==null?void 0:m.toString())||((w=(p=(h=_.p)==null?void 0:h.body)==null?void 0:p.dataStream)==null?void 0:w.trim())||"")){g.add(f);break}}const u=[],c=Array.from(g).sort((f,v)=>f-v);for(const f of c)u.push({index:f,label:ft(f)});return u}getDataColumnsForRanges(r,e,t){var p,w,f,v;const n=this._univerInstanceService.getUnit(r,l.UniverInstanceType.UNIVER_SHEET);if(!n)return[];const s=n.getSheetBySheetId(e);if(!s)return[];const o=s.getCellMatrix(),a=o.getDataRange();let d=1/0,g=-1/0;const u=new Set;for(const _ of t){d=Math.min(d,_.startRow),g=Math.max(g,_.endRow);for(let y=_.startColumn;y<=_.endColumn;y++)u.add(y)}const c=new Set;for(let _=a.startColumn;_<=a.endColumn;_++)if(!u.has(_))for(let y=d;y<=g;y++){const T=o.getValue(y,_);if(T&&(((p=T.v)==null?void 0:p.toString())||((v=(f=(w=T.p)==null?void 0:w.body)==null?void 0:f.dataStream)==null?void 0:v.trim())||"")){c.add(_);break}}const m=[],h=Array.from(c).sort((_,y)=>_-y);for(const _ of h)m.push({index:_,label:ft(_)});return m}getSelectionRangeNotation(){const r=this._selectionService.getCurrentSelections();return!r||r.length===0?"":r.map(e=>cn(e.range)).join(", ")}getSelectionRowRange(){const r=this._selectionService.getCurrentSelections();if(!r||r.length===0)return null;let e=1/0,t=-1/0;for(const n of r)e=Math.min(e,n.range.startRow),t=Math.max(t,n.range.endRow);return{startRow:e,endRow:t}}getSelectionColumnIndices(){const r=this._selectionService.getCurrentSelections();if(!r||r.length===0)return new Set;const e=new Set;for(const t of r)for(let n=t.range.startColumn;n<=t.range.endColumn;n++)e.add(n);return e}generateFileName(r,e){var o,a,d,g;const t=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),n=gt(r.source,r.imageSourceType),s=[];for(const u of e.fileNameParts)if(u==="cellAddress")s.push(r.cellAddress);else if(u==="columnValue"&&e.columnIndex!==void 0){const c=t==null?void 0:t.getActiveSheet();if(c){const h=c.getCellMatrix().getValue(r.row,e.columnIndex);if(h){const p=((o=h.v)==null?void 0:o.toString())||((g=(d=(a=h.p)==null?void 0:a.body)==null?void 0:d.dataStream)==null?void 0:g.trim())||"";if(p){const w=p.replace(/[<>:"/\\|?*]/g,"_").trim();w&&s.push(w)}}}}return s.length===0?`${r.cellAddress}.${n}`:`${s.join("_")}.${n}`}generateFileNameWithContext(r,e,t,n){var d,g,u,c;const s=this._univerInstanceService.getUnit(t,l.UniverInstanceType.UNIVER_SHEET),o=gt(r.source,r.imageSourceType),a=[];for(const m of e.fileNameParts)if(m==="cellAddress")a.push(r.cellAddress);else if(m==="columnValue"&&e.columnIndex!==void 0){const h=s==null?void 0:s.getSheetBySheetId(n);if(h){const w=h.getCellMatrix().getValue(r.row,e.columnIndex);if(w){const f=((d=w.v)==null?void 0:d.toString())||((c=(u=(g=w.p)==null?void 0:g.body)==null?void 0:u.dataStream)==null?void 0:c.trim())||"";if(f){const v=f.replace(/[<>:"/\\|?*]/g,"_").trim();v&&a.push(v)}}}}return a.length===0?`${r.cellAddress}.${o}`:`${a.join("_")}.${o}`}async saveImages(r,e){var s;const t=await window.showDirectoryPicker({mode:"readwrite"}),n=new Map;for(const o of r){let a=this.generateFileName(o,e);const d=a.replace(/\.\w+$/,""),g=((s=a.match(/\.\w+$/))==null?void 0:s[0])||".png",u=n.get(d)||0;u>0&&(a=`${d}_${u}${g}`),n.set(d,u+1);try{const c=await this._getImageBlob(o),h=await(await t.getFileHandle(a,{create:!0})).createWritable();await h.write(c),await h.close()}catch(c){throw console.error(`Failed to save image ${a}:`,c),c}}}async saveImagesWithContext(r,e,t,n){var a;const s=await window.showDirectoryPicker({mode:"readwrite"}),o=new Map;for(const d of r){let g=this.generateFileNameWithContext(d,e,t,n);const u=g.replace(/\.\w+$/,""),c=((a=g.match(/\.\w+$/))==null?void 0:a[0])||".png",m=o.get(u)||0;m>0&&(g=`${u}_${m}${c}`),o.set(u,m+1);try{const h=await this._getImageBlob(d),w=await(await s.getFileHandle(g,{create:!0})).createWritable();await w.write(h),await w.close()}catch(h){throw console.error(`Failed to save image ${g}:`,h),h}}}async downloadSingleImage(r){const e=gt(r.source,r.imageSourceType),t=`${r.cellAddress}.${e}`;try{const n=await this._getImageBlob(r),s=URL.createObjectURL(n),o=document.createElement("a");o.href=s,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(s)}catch(n){throw console.error(`Failed to download image ${t}:`,n),n}}async _getImageBlob(r){if(r.imageSourceType===l.ImageSourceType.UUID){const e=await this._imageIoService.getImage(r.source);return jt(e,l.ImageSourceType.URL)}return jt(r.source,r.imageSourceType)}};exports.BatchSaveImagesService=an([ut(0,l.IUniverInstanceService),ut(1,l.Inject(C.SheetsSelectionsService)),ut(2,l.IImageIoService)],exports.BatchSaveImagesService);const Ce="sheet.dialog.batch-save-images",ye={id:"sheet.command.save-cell-images",type:l.CommandType.COMMAND,handler:async i=>{const r=i.get(k.IDialogService),e=i.get(ct),t=e.getCellImagesInSelection();if(t.length===1)try{return await e.downloadSingleImage(t[0]),!0}catch(a){return console.error("Failed to download image:",a),!1}const n=i.get(l.LocaleService),s=e.getSelectionRangeNotation(),o=`${n.t("sheetImage.save.title")} (${s})`;return r.open({id:Ce,draggable:!0,width:360,title:{title:o},children:{label:Ce},destroyOnClose:!0,preservePositionOnDestroy:!0,onClose:()=>r.close(Ce)}),!0}},Bt="COMPONENT_SHEET_DRAWING_PANEL",Mt={id:"sidebar.operation.sheet-image",type:l.CommandType.COMMAND,handler:async(i,r)=>{const e=i.get(k.ISidebarService),t=i.get(l.LocaleService),n=i.get(l.IUniverInstanceService),s=i.get(l.ICommandService);if(!C.getSheetCommandTarget(n))return!1;switch(r.value){case"open":e.open({header:{title:t.t("sheetImage.panel.title")},children:{label:Bt},onClose:()=>{s.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[])},width:360});break;case"close":default:e.close();break}return!0}},Tt={id:"sheet.operation.edit-sheet-image",type:l.CommandType.OPERATION,handler:(i,r)=>{const e=i.get(l.ICommandService);return r==null?!1:(e.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[r]),e.executeCommand(Mt.id,{value:"open"}),!0)}},dn="sheets-drawing-ui.config",kt={};var ln=Object.getOwnPropertyDescriptor,un=(i,r,e,t)=>{for(var n=t>1?void 0:t?ln(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},se=(i,r)=>(e,t)=>r(e,t,i);let et=class extends l.RxDisposable{constructor(r,e,t,n,s,o,a,d,g,u){super();ne(this,"_initImagePopupMenu",new Set);this._injector=r,this._localeService=e,this._drawingManagerService=t,this._canvasPopManagerService=n,this._renderManagerService=s,this._univerInstanceService=o,this._messageService=a,this._contextService=d,this._ioService=g,this._commandService=u,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(r=>this._create(r)),this._univerInstanceService.getTypeOfUnitDisposed$(l.UniverInstanceType.UNIVER_SHEET).pipe(O.takeUntil(this.dispose$)).subscribe(r=>this._dispose(r)),this._univerInstanceService.getAllUnitsForType(l.UniverInstanceType.UNIVER_SHEET).forEach(r=>this._create(r)),this._setupLoadingStatus()}_setupLoadingStatus(){const r="image-upload-loading";let e;this.disposeWithMe(this._ioService.change$.subscribe(t=>{t>0&&!e?e=this._messageService.show({id:r,type:F.MessageType.Loading,content:`${this._localeService.t("uploadLoading.loading")}: ${t}`,duration:0}):t===0&&(e==null||e.dispose(),e=void 0)}))}_dispose(r){super.dispose();const e=r.getUnitId();this._renderManagerService.removeRender(e)}_create(r){if(!r)return;const e=r.getUnitId();this._renderManagerService.has(e)&&!this._initImagePopupMenu.has(e)&&(this._popupMenuListener(e),this._initImagePopupMenu.add(e))}_hasCropObject(r){const e=r.getAllObjectsByOrder();for(const t of e)if(t instanceof he.ImageCropperObject)return!0;return!1}_popupMenuListener(r){var s;const e=(s=this._renderManagerService.getRenderById(r))==null?void 0:s.scene;if(!e)return;const t=e.getTransformerByCreate();if(!t)return;let n;this.disposeWithMe(t.createControl$.subscribe(()=>{if(this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(e))return;const o=t.getSelectedObjectMap();if(o.size>1){n==null||n.dispose();return}const a=o.values().next().value;if(!a)return;const d=a.oKey,g=this._drawingManagerService.getDrawingOKey(d);if(!g)return;const{unitId:u,subUnitId:c,drawingId:m,drawingType:h}=g,p=g.data;if(p&&p.disablePopup)return;n==null||n.dispose();const w=this._canvasPopManagerService.getFeatureMenu(u,c,m,h);n=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(a,{componentKey:he.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:w||this._getImageMenuItems(u,c,m,h)}}))})),this.disposeWithMe(t.clearControl$.subscribe(()=>{n==null||n.dispose(),this._contextService.setContextValue(l.FOCUSING_COMMON_DRAWINGS,!1),this._commandService.syncExecuteCommand(j.SetDrawingSelectedOperation.id,[])})),this.disposeWithMe(this._contextService.contextChanged$.subscribe(o=>{o[l.FOCUSING_COMMON_DRAWINGS]===!1&&(n==null||n.dispose())})),this.disposeWithMe(t.changing$.subscribe(()=>{n==null||n.dispose()}))}_getImageMenuItems(r,e,t,n){return[{label:"image-popup.edit",index:0,commandId:Tt.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:Me.id,commandParams:{unitId:r,drawings:[{unitId:r,subUnitId:e,drawingId:t}]},disable:!1},{label:"image-popup.crop",index:2,commandId:he.OpenImageCropOperation.id,commandParams:{unitId:r,subUnitId:e,drawingId:t},disable:n===l.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:he.ImageResetSizeOperation.id,commandParams:[{unitId:r,subUnitId:e,drawingId:t}],disable:n===l.DrawingTypeEnum.DRAWING_DOM}]}};et=un([se(0,l.Inject(l.Injector)),se(1,l.Inject(l.LocaleService)),se(2,j.IDrawingManagerService),se(3,l.Inject(E.SheetCanvasPopManagerService)),se(4,x.IRenderManagerService),se(5,l.IUniverInstanceService),se(6,k.IMessageService),se(7,l.IContextService),se(8,l.IImageIoService),se(9,l.ICommandService)],et);var gn=Object.getOwnPropertyDescriptor,hn=(i,r,e,t)=>{for(var n=t>1?void 0:t?gn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},Ke=(i,r)=>(e,t)=>r(e,t,i);let wt=class extends l.Disposable{constructor(r,e,t,n,s){super();ne(this,"_isSetCursor",!1);this._context=r,this._hoverManagerService=e,this._selectionsService=t,this._drawingRenderService=n,this._sheetSkeletonManagerService=s,this._initHover(),this._initImageClick()}_initHover(){this.disposeWithMe(this._hoverManagerService.currentRichTextNoDistinct$.pipe(O.throttleTime(33)).subscribe(r=>{var t,n;let e=[];r!==null&&(e=this._selectionsService.getWorkbookSelections(this._context.unitId).getCurrentSelections()),e.length>0&&(r==null?void 0:r.unitId)===this._context.unitId&&(r!=null&&r.drawing)&&e.length===1&&((t=e[0].primary)==null?void 0:t.actualRow)===r.row&&((n=e[0].primary)==null?void 0:n.actualColumn)===r.col?(this._isSetCursor=!0,this._context.scene.setCursor(x.CURSOR_TYPE.ZOOM_IN)):this._isSetCursor&&(this._isSetCursor=!1,this._context.scene.resetCursor())}))}_initImageClick(){this.disposeWithMe(this._hoverManagerService.currentClickedCell$.subscribe(r=>{var e;if(r!=null&&r.drawing&&this._isSetCursor){const t=r.drawing.drawing.drawingOrigin,n=(e=this._sheetSkeletonManagerService.getCurrentSkeleton())==null?void 0:e.imageCacheMap.getImage(t.imageSourceType,t.source);if(!n)return;this._drawingRenderService.previewImage("preview-cell-image",n.src,n.width,n.height),this._context.scene.resetCursor(),this._isSetCursor=!1}}))}};wt=hn([Ke(1,l.Inject(E.HoverManagerService)),Ke(2,l.Inject(C.SheetsSelectionsService)),Ke(3,l.Inject(he.DrawingRenderService)),Ke(4,l.Inject(E.SheetSkeletonManagerService))],wt);var mn=Object.getOwnPropertyDescriptor,pn=(i,r,e,t)=>{for(var n=t>1?void 0:t?mn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},ze=(i,r)=>(e,t)=>r(e,t,i);let St=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._context=i,this._sheetDrawingService=r,this._drawingManagerService=e,this._sheetSelectionRenderService=t,this._sheetSkeletonManagerService=n,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const r in i){const e=i[r];for(const t in e.data){const n=e.data[t];n.sheetTransform&&(n.transform=Z(n.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService))}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};St=pn([ze(1,S.ISheetDrawingService),ze(2,j.IDrawingManagerService),ze(3,l.Inject(E.ISheetSelectionRenderService)),ze(4,l.Inject(E.SheetSkeletonManagerService))],St);var fn=Object.getOwnPropertyDescriptor,wn=(i,r,e,t)=>{for(var n=t>1?void 0:t?fn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},Ie=(i,r)=>(e,t)=>r(e,t,i);function Lt(i,r,e){var t,n,s,o;if(((n=(t=e==null?void 0:e.p)==null?void 0:t.body)==null?void 0:n.dataStream.length)===3&&((o=(s=e.p)==null?void 0:s.drawingsOrder)==null?void 0:o.length)===1){const a=e.p.drawings[e.p.drawingsOrder[0]],d=pt(i,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},a.docTransform.size.width,a.docTransform.size.height,a.docTransform.angle);if(d)return a.transform.width=d.width,a.transform.height=d.height,a.docTransform.size.width=d.width,a.docTransform.size.height=d.height,a.transform.left=0,a.transform.top=0,a.docTransform.positionH.posOffset=0,a.docTransform.positionV.posOffset=0,e.p.documentStyle.pageSize.width=1/0,e.p.documentStyle.pageSize.height=1/0,!0}return!1}let tt=class extends l.Disposable{constructor(i,r,e,t,n,s){super(),this._commandService=i,this._sheetInterceptorService=r,this._injector=e,this._drawingManagerService=t,this._docDrawingController=n,this._editorBridgeService=s,this._handleInitEditor(),this._initCellContentInterceptor()}_handleInitEditor(){this.disposeWithMe(this._editorBridgeService.visible$.subscribe(i=>{i.visible?i.visible&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)):this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})),this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===Je.ReplaceSnapshotCommand.id&&i.params.unitId===l.DOCS_ZEN_EDITOR_UNIT_ID_KEY&&(this._drawingManagerService.removeDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._docDrawingController.loadDrawingDataForUnit(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY),this._drawingManagerService.initializeNotification(l.DOCS_ZEN_EDITOR_UNIT_ID_KEY))}))}_initCellContentInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(C.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,priority:C.InterceptCellContentPriority.CELL_IMAGE,handler:(i,r,e)=>{var t;return i!=null&&i.p&&((t=i.p.drawingsOrder)!=null&&t.length)&&(i===r.rawData&&(i={...r.rawData}),i.interceptorStyle||(i.interceptorStyle={}),i.interceptorStyle.tr={a:0},Lt(this._injector,{unitId:r.unitId,subUnitId:r.subUnitId,row:r.row,col:r.col},i)),e(i)}}))}};tt=wn([Ie(0,l.ICommandService),Ie(1,l.Inject(C.SheetInterceptorService)),Ie(2,l.Inject(l.Injector)),Ie(3,j.IDrawingManagerService),Ie(4,l.Inject($t.DocDrawingController)),Ie(5,l.Inject(E.IEditorBridgeService))],tt);var Sn=Object.getOwnPropertyDescriptor,vn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Sn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},xt=(i,r)=>(e,t)=>r(e,t,i);let nt=class extends l.Disposable{constructor(i,r){super(),this._autoFillService=i,this._injector=r,this._initAutoFillHooks()}_initAutoFillHooks(){this.disposeWithMe(this._autoFillService.addHook({id:"sheet-cell-image-autofill",onBeforeSubmit:(i,r,e,t)=>{new l.ObjectMatrix(t).forValue((n,s,o)=>{Lt(this._injector,{unitId:i.unitId,subUnitId:i.subUnitId,row:n,col:s},o)})}}))}};nt=vn([xt(0,l.Inject(E.IAutoFillService)),xt(1,l.Inject(l.Injector))],nt);var _n=Object.getOwnPropertyDescriptor,In=(i,r,e,t)=>{for(var n=t>1?void 0:t?_n(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},Oe=(i,r)=>(e,t)=>r(e,t,i);const Dn=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,l.DOCS_ZEN_EDITOR_UNIT_ID_KEY];let rt=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._commandService=i,this._univerInstanceService=r,this._dialogService=e,this._renderManagerService=t,this._localeService=n,this._initDocImageCopyPasteHooks()}_setCellImage(i){var n;const r=l.createDocumentModelWithStyle("",{}),e=(n=x.getCurrentTypeOfRenderer(l.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null?void 0:n.with(E.EditingRenderController),t=l.BuildTextUtils.drawing.add({documentDataModel:r,drawings:[i],selection:{collapsed:!0,startOffset:0,endOffset:0}});t&&(r.apply(t),e&&e.submitCellData(r))}_initDocImageCopyPasteHooks(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{var r,e;if(i.id===Je.InnerPasteCommand.id){const t=i.params,{doc:n}=t,s=this._univerInstanceService.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_DOC);if(s==null||!Object.keys((r=n.drawings)!=null?r:{}).length)return;const o=s.getUnitId();if(Dn.includes(o)){if(o!==l.DOCS_ZEN_EDITOR_UNIT_ID_KEY){const a=()=>{this._dialogService.close("sheet-cell-image-copy-paste"),this._commandService.syncExecuteCommand(E.SetCellEditVisibleOperation.id,{visible:!1})};((e=s.getBody())==null?void 0:e.dataStream)===`\r
|
|
2
|
+
`?(this._commandService.syncExecuteCommand(E.SetCellEditVisibleOperation.id,{visible:!1}),this._setCellImage(Object.values(n.drawings)[0])):this._dialogService.open({id:"sheet-cell-image-copy-paste",title:{label:this._localeService.t("cell-image.pasteTitle")},children:{label:this._localeService.t("cell-image.pasteContent")},width:320,destroyOnClose:!0,onClose:a,showOk:!0,showCancel:!0,onOk:()=>{a(),this._setCellImage(Object.values(n.drawings)[0])},onCancel:a})}throw new Error("Sheet cell image copy paste is not supported in this unit")}}}))}};rt=In([Oe(0,l.ICommandService),Oe(1,l.IUniverInstanceService),Oe(2,k.IDialogService),Oe(3,x.IRenderManagerService),Oe(4,l.Inject(l.LocaleService))],rt);var Cn=Object.getOwnPropertyDescriptor,yn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Cn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},Ue=(i,r)=>(e,t)=>r(e,t,i);const Ft="image/png";function Mn(i){const r=i.split(","),e=atob(r[1]),t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return new Blob([n],{type:Ft})}function Tn(i){const r=new ClipboardItem({[Ft]:Mn(i)});navigator.clipboard.write([r]).catch(e=>{console.error("Could not copy image using clipboard API: ",e)})}function Rn(){function i(){const t=document.createElement("input");return t.style.position="absolute",t.style.height="1px",t.style.width="1px",t.style.opacity="0",t}const r=document.activeElement,e=i();return document.body.appendChild(e),e.focus(),()=>{e.blur(),document.body.removeChild(e),r instanceof HTMLElement&&r.focus()}}const Wt=[E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,E.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA];let it=class extends l.Disposable{constructor(r,e,t,n,s){super();ne(this,"_copyInfo");this._sheetClipboardService=r,this._renderManagerService=e,this._drawingService=t,this._clipboardInterfaceService=n,this._commandService=s,this._initCopyPaste()}get _focusedDrawings(){return this._drawingService.getFocusDrawings()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(r,e,t,n)=>{this._copyInfo=null;const s=this._focusedDrawings;if(s.length>0){const[o]=s;if(o.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;if(n===E.COPY_TYPE.CUT){const d={unitId:r,drawings:[o]};this._commandService.executeCommand(Me.id,d)}setTimeout(()=>{const d=Rn();o.drawingType===l.DrawingTypeEnum.DRAWING_IMAGE&&o.imageSourceType===j.ImageSourceType.BASE64?Tn(o.source):this._clipboardInterfaceService.writeText(""),d()},200);const a={unitId:o.unitId,subUnitId:o.subUnitId,drawings:[o]};this._copyInfo=a}else{const o=this._createDrawingsCopyInfoByRange(r,e,t);this._copyInfo=o}},onPasteCells:(r,e,t,n)=>{if(!this._copyInfo)return{redos:[],undos:[]};const{copyType:s=E.COPY_TYPE.COPY,pasteType:o}=n,{range:a}=r||{},{range:d,unitId:g,subUnitId:u}=e;return this._copyInfo.copyRange?this._generateRangeDrawingsPasteMutations({pasteType:o,unitId:g,subUnitId:u,pasteRange:d},{copyRange:a,copyType:s}):this._generateSingleDrawingPasteMutations({pasteTo:e,pasteType:o},E.COPY_TYPE.COPY)},onPastePlainText:(r,e)=>({undos:[],redos:[]}),onPasteUnrecognized:r=>this._copyInfo?this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:E.PREDEFINED_HOOK_NAME.DEFAULT_PASTE},E.COPY_TYPE.COPY):{undos:[],redos:[]},onPasteFiles:(r,e)=>{if(this._copyInfo)return this._generateSingleDrawingPasteMutations({pasteTo:r,pasteType:E.PREDEFINED_HOOK_NAME.DEFAULT_PASTE},E.COPY_TYPE.COPY);{const t=e.filter(n=>n.type.includes("image"));if(t.length)return{undos:[],redos:[{id:ke.id,params:{files:t}}]}}return{undos:[],redos:[]}}})}_createDrawingsCopyInfoByRange(r,e,t){var m;const n=(m=this._renderManagerService.getRenderById(r))==null?void 0:m.with(E.SheetSkeletonManagerService);if(!n)return;const s=n.attachRangeWithCoord(t);if(!s)return;const{startX:o,endX:a,startY:d,endY:g}=s,u=this._drawingService.getDrawingData(r,e),c=this._focusedDrawings.slice();if(Object.keys(u).forEach(h=>{const p=u[h];if(p.drawingType!==l.DrawingTypeEnum.DRAWING_IMAGE)return;const{transform:w}=p;if(p.anchorType!==S.SheetDrawingAnchorType.Both||!w)return;const{left:f=0,top:v=0,width:_=0,height:y=0}=w,{drawingStartX:T,drawingEndX:D,drawingStartY:M,drawingEndY:I}={drawingStartX:f,drawingEndX:f+_,drawingStartY:v,drawingEndY:v+y};o<=T&&D<=a&&d<=M&&I<=g&&c.push(p)}),c.length)return{copyRange:t,drawings:c,unitId:r,subUnitId:e}}_generateSingleDrawingPasteMutations(r,e){const{pasteType:t,pasteTo:n}=r;if(Wt.includes(t))return{redos:[],undos:[]};const{unitId:s,subUnitId:o,range:a}=n,d=this._renderManagerService.getRenderById(s),g=d==null?void 0:d.with(E.SheetSkeletonManagerService),u=d==null?void 0:d.with(E.ISheetSelectionRenderService),c=this._copyInfo;if(!g||!u)return{redos:[],undos:[]};const{drawings:m}=c,h=E.discreteRangeToRange(a);return this._generateMutations(m,{unitId:s,subUnitId:o,isCut:e===E.COPY_TYPE.CUT,getTransform:(p,w)=>{var _;const f=g.attachRangeWithCoord({startRow:h.startRow,endRow:h.endRow,startColumn:h.startColumn,endColumn:h.endColumn}),v={...p,left:f==null?void 0:f.startX,top:f==null?void 0:f.startY};return{transform:v,sheetTransform:(_=Y(v,u))!=null?_:w}}})}_generateMutations(r,e){const{unitId:t,subUnitId:n,getTransform:s,isCut:o}=e,a=[],d=[],{_drawingService:g}=this;return r.forEach(u=>{const{transform:c,sheetTransform:m}=u;if(!c)return;const h=s(c,m),p={...u,unitId:t,subUnitId:n,drawingId:o?u.drawingId:l.generateRandomId(),transform:h.transform,sheetTransform:h.sheetTransform};if(o){const{undo:w,redo:f,objects:v}=g.getBatchUpdateOp([p]);a.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,type:S.DrawingApplyType.UPDATE,op:f,objects:v}}),d.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,type:S.DrawingApplyType.UPDATE,op:w,objects:v}})}else{const{undo:w,redo:f,objects:v}=g.getBatchAddOp([p]);a.push({id:S.SetDrawingApplyMutation.id,params:{op:f,unitId:t,subUnitId:n,objects:v,type:S.DrawingApplyType.INSERT}}),d.push({id:S.SetDrawingApplyMutation.id,params:{op:w,unitId:t,subUnitId:n,objects:v,type:S.DrawingApplyType.REMOVE}})}}),{redos:a,undos:d}}_generateRangeDrawingsPasteMutations(r,e){var A;const{unitId:t,subUnitId:n,pasteType:s,pasteRange:o}=r,{copyRange:a,copyType:d}=e;if(Wt.includes(s))return{redos:[],undos:[]};const g=(A=this._renderManagerService.getRenderById(t))==null?void 0:A.with(E.SheetSkeletonManagerService);if(!g||!this._copyInfo)return{redos:[],undos:[]};const{drawings:u}=this._copyInfo;if(!a)return this._generateSingleDrawingPasteMutations({pasteTo:{unitId:t,subUnitId:n,range:E.discreteRangeToRange(o)},pasteType:s},d);const{ranges:[c,m],mapFunc:h}=E.virtualizeDiscreteRanges([a,o]),{row:p,col:w}=h(c.startRow,c.startColumn),{row:f,col:v}=h(m.startRow,m.startColumn),_=g.attachRangeWithCoord({startRow:p,endRow:p,startColumn:w,endColumn:w}),y=g.attachRangeWithCoord({startRow:f,endRow:f,startColumn:v,endColumn:v});if(!_||!y||!this._copyInfo)return{redos:[],undos:[]};const T=y.startX-_.startX,D=y.startY-_.startY,M=f-p,I=v-w;return this._generateMutations(u,{unitId:t,subUnitId:n,getTransform:(b,P)=>{var N,U;return{transform:{...b,left:((N=b==null?void 0:b.left)!=null?N:0)+T,top:((U=b==null?void 0:b.top)!=null?U:0)+D},sheetTransform:{...P,to:{...P.to,row:P.to.row+M,column:P.to.column+I},from:{...P.from,row:P.from.row+M,column:P.from.column+I}}}},isCut:d===E.COPY_TYPE.CUT})}};it=yn([Ue(0,E.ISheetClipboardService),Ue(1,x.IRenderManagerService),Ue(2,j.IDrawingManagerService),Ue(3,k.IClipboardInterfaceService),Ue(4,l.ICommandService)],it);var bn=Object.getOwnPropertyDescriptor,En=(i,r,e,t)=>{for(var n=t>1?void 0:t?bn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},Ae=(i,r)=>(e,t)=>r(e,t,i);let st=class extends l.Disposable{constructor(i,r,e,t,n){super(),this._drawingManagerService=i,this._renderManagerService=r,this._permissionService=e,this._univerInstanceService=t,this._userManagerService=n,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,e=O.combineLatest([i,r]);this.disposeWithMe(e.pipe(O.switchMap(([t,n])=>t?t.activeSheet$.pipe(O.tap(s=>{if(!s){this._drawingManagerService.setDrawingVisible(!1);return}const o=t.getUnitId(),a=s.getSheetId();this._permissionService.composePermission([new C.WorkbookViewPermission(o).id,new C.WorksheetViewPermission(o,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingVisible(!0):this._handleDrawingVisibilityFalse(t,s)})):(this._drawingManagerService.setDrawingVisible(!1),O.EMPTY))).subscribe())}_handleDrawingVisibilityFalse(i,r){this._drawingManagerService.setDrawingVisible(!1);const e=i.getUnitId(),t=r.getSheetId(),n=this._drawingManagerService.getDrawingData(e,t),s=Object.values(n),o=this._renderManagerService.getRenderById(e),a=o==null?void 0:o.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===x.RENDER_CLASS_TYPE.IMAGE&&s.some(u=>g.oKey.includes(u.drawingId))&&a.removeObject(g)})}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$,e=O.combineLatest([i,r]);this.disposeWithMe(e.pipe(O.switchMap(([t,n])=>t?t.activeSheet$.pipe(O.tap(s=>{if(!s){this._drawingManagerService.setDrawingEditable(!1);return}const o=t.getUnitId(),a=s.getSheetId();this._permissionService.composePermission([new C.WorkbookEditablePermission(o).id,new C.WorksheetEditPermission(o,a).id]).every(g=>g.value)?this._drawingManagerService.setDrawingEditable(!0):this._handleDrawingEditableFalse(t,s)})):(this._drawingManagerService.setDrawingEditable(!1),O.EMPTY))).subscribe())}_handleDrawingEditableFalse(i,r){this._drawingManagerService.setDrawingEditable(!1);const e=i.getUnitId(),t=r.getSheetId(),n=this._drawingManagerService.getDrawingData(e,t),s=Object.values(n),o=this._renderManagerService.getRenderById(e),a=o==null?void 0:o.scene;if(!a)return;a.getAllObjectsByOrder().forEach(g=>{g.classType===x.RENDER_CLASS_TYPE.IMAGE&&s.some(u=>g.oKey.includes(u.drawingId))&&a.detachTransformerFrom(g)})}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(O.combineLatest([i,r]).pipe(O.switchMap(([e,t])=>e?e.activeSheet$.pipe(O.switchMap(n=>{if(!n)return O.EMPTY;const s=e.getUnitId(),o=n.getSheetId(),a=this._renderManagerService.getRenderById(s),d=a==null?void 0:a.scene;if(!d)return O.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new C.WorkbookViewPermission(s).id,new C.WorksheetViewPermission(s,o).id]).pipe(O.map(c=>c.every(m=>m.value)),O.distinctUntilChanged()).pipe(O.map(c=>({permission:c,scene:d,transformer:g,unitId:s,subUnitId:o})))})):O.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:s,subUnitId:o})=>{this._drawingManagerService.setDrawingVisible(e);const a=t.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(s,o),g=Object.values(d);e?this._drawingManagerService.addNotification(g):(a.forEach(u=>{u.classType===x.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&t.removeObject(u)}),n.clearSelectedObjects())},complete:()=>{this._drawingManagerService.setDrawingVisible(!0);const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),t=e==null?void 0:e.getActiveSheet(),n=e==null?void 0:e.getUnitId(),s=t==null?void 0:t.getSheetId();if(!n||!s)return;const o=this._drawingManagerService.getDrawingData(n,s),a=Object.values(o);this._drawingManagerService.addNotification(a)}}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),r=this._userManagerService.currentUser$;this.disposeWithMe(O.combineLatest([i,r]).pipe(O.switchMap(([e,t])=>e?e.activeSheet$.pipe(O.switchMap(n=>{if(!n)return O.EMPTY;const s=e.getUnitId(),o=n.getSheetId(),a=this._renderManagerService.getRenderById(s),d=a==null?void 0:a.scene;if(!d)return O.EMPTY;const g=d.getTransformerByCreate();return this._permissionService.composePermission$([new C.WorkbookEditablePermission(s).id,new C.WorksheetEditPermission(s,o).id]).pipe(O.map(c=>c.every(m=>m.value)),O.distinctUntilChanged()).pipe(O.map(c=>({permission:c,scene:d,transformer:g,unitId:s,subUnitId:o})))})):O.EMPTY)).subscribe({next:({permission:e,scene:t,transformer:n,unitId:s,subUnitId:o})=>{this._drawingManagerService.setDrawingEditable(e);const a=t.getAllObjectsByOrder(),d=this._drawingManagerService.getDrawingData(s,o),g=Object.values(d);e?(a.forEach(u=>{u.classType===x.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&t.attachTransformerTo(u)}),this._drawingManagerService.addNotification(g)):(a.forEach(u=>{u.classType===x.RENDER_CLASS_TYPE.IMAGE&&g.some(c=>u.oKey.includes(c.drawingId))&&t.detachTransformerFrom(u)}),n.clearSelectedObjects())},complete:()=>{const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!e)return;const t=e.getUnitId(),n=e.getActiveSheet();if(!n)return;const s=n.getSheetId(),o=this._renderManagerService.getRenderById(t),a=o==null?void 0:o.scene;if(!a)return;const d=this._drawingManagerService.getDrawingData(t,s),g=Object.values(d);this._drawingManagerService.setDrawingEditable(!0),a.getAllObjectsByOrder().forEach(c=>{c.classType===x.RENDER_CLASS_TYPE.IMAGE&&g.some(m=>c.oKey.includes(m.drawingId))&&a.detachTransformerFrom(c)})}}))}};st=En([Ae(0,j.IDrawingManagerService),Ae(1,x.IRenderManagerService),Ae(2,l.IPermissionService),Ae(3,l.IUniverInstanceService),Ae(4,l.Inject(l.UserManagerService))],st);var On=Object.getOwnPropertyDescriptor,Un=(i,r,e,t)=>{for(var n=t>1?void 0:t?On(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},me=(i,r)=>(e,t)=>r(e,t,i);const Yt="univer-sheet-float-dom-";function Gt(i,r,e,t,n,s=!1){const{scaleX:o,scaleY:a}=r.getAncestorScale(),d=r.getViewport(x.SHEET_VIEWPORT_KEY.VIEW_MAIN),g=t.getFreeze(),{startColumn:u,startRow:c,xSplit:m,ySplit:h}=g,p={left:!0,top:!0};if(!d)return{...i,absolute:p};const{left:w,right:f,top:v,bottom:_}=i;let{top:y,left:T,viewportScrollX:D,viewportScrollY:M}=d;const{boundsOfViewArea:I,scrollDirectionResponse:A}=n||{},{rowHeaderWidth:b,columnHeaderHeight:P}=e,N={top:s?0:P,left:s?0:b};I&&(l.Tools.isDefine(N.top)&&(N.top=I.top),l.Tools.isDefine(N.left)&&(N.left=I.left)),A==="HORIZONTAL"&&(M=0),A==="VERTICAL"&&(D=0);let U=0,R=0;const W=e.rowStartY(c-h)+P,L=e.colStartX(u-m)+b,J=e.rowStartY(c)+P,ee=e.colStartX(u)+b;if(m===0)p.left=!1,U=(w-D)*o,R=(f-D)*o;else{const z=w-(L-b),Q=f-(L-b);f<ee?(U=z*o,R=Q*o):w<=ee&&f>=ee?(U=z*o,R=Math.max(T,(f-D)*o)):w>ee&&(p.left=!1,U=Math.max((w-D)*o,T),R=Math.max((f-D)*o,T))}let K=0,q=0;if(h===0)p.top=!1,K=(v-M)*a,q=(_-M)*a;else{const z=v-(W-P),Q=_-(W-P);_<J?(K=z*a,q=Q*a):v<=J&&_>=J?(K=z*a,q=Math.max(y,(_-M)*a)):v>J&&(p.top=!1,K=Math.max((v-M)*a,y),q=Math.max((_-M)*a,y))}return U=Math.max(U,N.left),K=Math.max(K,N.top),R=Math.max(R,N.left),q=Math.max(q,N.top),{left:U,right:R,top:K,bottom:q,absolute:p}}const oe=(i,r,e,t,n)=>{const{left:s,top:o,width:a,height:d,angle:g}=i,u={left:s,right:s+a,top:o,bottom:o+d},c=Gt(u,r,e,t,n),{scaleX:m,scaleY:h}=r.getAncestorScale();return{startX:c.left,endX:c.right,startY:c.top,endY:c.bottom,rotate:g,width:a*m,height:d*h,absolute:c.absolute}};exports.SheetCanvasFloatDomManagerService=class extends l.Disposable{constructor(e,t,n,s,o,a,d){super();ne(this,"_domLayerInfoMap",new Map);ne(this,"_transformChange$",new O.Subject);ne(this,"transformChange$",this._transformChange$.asObservable());ne(this,"_add$",new O.Subject);ne(this,"add$",this._add$.asObservable());ne(this,"_remove$",new O.Subject);ne(this,"remove$",this._remove$.asObservable());this._renderManagerService=e,this._univerInstanceService=t,this._commandService=n,this._drawingManagerService=s,this._canvasFloatDomService=o,this._sheetDrawingService=a,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(O.filter(e=>e===l.LifecycleStages.Rendered),O.take(1)).subscribe(()=>{this._scrollUpdateListener()})}getFloatDomInfo(e){return this._domLayerInfoMap.get(e)}getFloatDomsBySubUnitId(e,t){return Array.from(this._domLayerInfoMap.values()).filter(n=>n.subUnitId===t&&n.unitId===e)}_getSceneAndTransformerByDrawingSearch(e){if(e==null)return;const t=this._renderManagerService.getRenderById(e),n=t==null?void 0:t.scene;if(t==null||n==null)return null;const s=n.getTransformerByCreate(),o=t.engine.getCanvasElement();return{scene:n,transformer:s,renderUnit:t,canvas:o}}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(e=>{e.forEach(t=>{var Q;const{unitId:n,subUnitId:s,drawingId:o}=t,a=C.getSheetCommandTarget(this._univerInstanceService,{unitId:n,subUnitId:s}),d=this._drawingManagerService.getDrawingByParam(t),g=this._univerInstanceService.getUnit(n,l.UniverInstanceType.UNIVER_SHEET);if(!g)return;const u=g.getActiveSheet().getSheetId();if(!d||!a)return;const c=(Q=this._renderManagerService.getRenderById(n))==null?void 0:Q.with(E.SheetSkeletonManagerService).getSkeletonParam(s);if(!c)return;const{transform:m,drawingType:h,data:p}=d;if(h!==l.DrawingTypeEnum.DRAWING_DOM&&h!==l.DrawingTypeEnum.DRAWING_CHART)return;const w=this._getSceneAndTransformerByDrawingSearch(n);if(w==null)return;const{scene:f,canvas:v}=w;if(m==null)return!0;if(u!==s)return;const{left:_,top:y,width:T,height:D,angle:M,flipX:I,flipY:A,skewX:b,skewY:P}=m,N=j.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:s,drawingId:o}),U=f.getObject(N);if(U!=null){U.transformByState({left:_,top:y,width:T,height:D,angle:M,flipX:I,flipY:A,skewX:b,skewY:P});return}const R={left:_,top:y,width:T,height:D,zIndex:this._drawingManagerService.getDrawingOrder(n,s).length-1},W=h===l.DrawingTypeEnum.DRAWING_CHART;if(R.rotateEnabled=!1,W){const H=p?p.backgroundColor:"white";R.fill=H,p&&p.border&&(R.stroke=p.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8}const L=new x.Rect(N,R);W&&L.setObjectType(x.ObjectType.CHART),f.addObject(L,x.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&f.attachTransformerTo(L);const J=new l.DisposableCollection,ee=oe(L,w.renderUnit.scene,c.skeleton,a.worksheet),K=new O.BehaviorSubject(ee),q=`${Yt}${l.generateRandomId(6)}`,ie={dispose:J,rect:L,position$:K,unitId:n,subUnitId:s,id:o,domId:q};this._canvasFloatDomService.addFloatDom({position$:K,id:o,domId:q,componentKey:d.componentKey,onPointerDown:H=>{v.dispatchEvent(new PointerEvent(H.type,H))},onPointerMove:H=>{v.dispatchEvent(new PointerEvent(H.type,H))},onPointerUp:H=>{v.dispatchEvent(new PointerEvent(H.type,H))},onWheel:H=>{v.dispatchEvent(new WheelEvent(H.type,H))},data:p,unitId:n});const z=L.onTransformChange$.subscribeEvent(()=>{const H=oe(L,w.renderUnit.scene,c.skeleton,a.worksheet);K.next(H)});J.add(()=>{this._canvasFloatDomService.removeFloatDom(o)}),z&&J.add(z),this._domLayerInfoMap.set(o,ie)})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{var m;const{unitId:n,subUnitId:s,drawingId:o}=t,a=j.getDrawingShapeKeyByDrawingSearch({unitId:n,subUnitId:s,drawingId:o}),d=this._getSceneAndTransformerByDrawingSearch(n);if(d==null)return;const{transformer:g,scene:u}=d,c=u.getObject(a);c!=null&&c.oKey&&(g.clearControlByIds([c==null?void 0:c.oKey]),(m=u.getTransformer())==null||m.clearSelectedObjects())})}))}_scrollUpdateListener(){const e=(t,n)=>{var g;const s=this._getSceneAndTransformerByDrawingSearch(t),o=Array.from(this._domLayerInfoMap.keys()).map(u=>({id:u,...this._domLayerInfoMap.get(u)})).filter(u=>u.subUnitId===n&&u.unitId===t).map(u=>u.id),a=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:n}),d=(g=this._renderManagerService.getRenderById(t))==null?void 0:g.with(E.SheetSkeletonManagerService).getSkeletonParam(n);!s||!a||!d||o.forEach(u=>{const c=this._domLayerInfoMap.get(u);if(c){const m=oe(c.rect,s.renderUnit.scene,d.skeleton,a.worksheet,c);c.position$.next(m)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(O.switchMap(t=>t?t.activeSheet$:O.of(null)),O.map(t=>{if(!t)return null;const n=t.getUnitId(),s=this._renderManagerService.getRenderById(n);return s?{render:s,unitId:n,subUnitId:t.getSheetId()}:null}),O.switchMap(t=>t?l.fromEventSubject(t.render.scene.getViewport(x.SHEET_VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(O.map(()=>({unitId:t.unitId,subUnitId:t.subUnitId}))):O.of(null))).subscribe(t=>{if(!t)return;const{unitId:n,subUnitId:s}=t;e(n,s)})),this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(t.id===E.SetZoomRatioOperation.id){const n=t.params,{unitId:s}=n;Array.from(this._domLayerInfoMap.values()).filter(a=>a.unitId===s).map(a=>a.subUnitId).forEach(a=>{e(s,a)})}else if(t.id===C.SetFrozenMutation.id){const{unitId:n,subUnitId:s}=t.params;e(n,s)}else if(t.id===C.SetSelectionsOperation.id){const{unitId:n,subUnitId:s}=t.params;e(n,s)}}))}updateFloatDomProps(e,t,n,s){const o=this._domLayerInfoMap.get(n),a=this._getSceneAndTransformerByDrawingSearch(e);if(o&&a){const{scene:d}=a,g=j.getDrawingShapeKeyByDrawingSearch({unitId:e,subUnitId:t,drawingId:n}),u=d.getObject(g);u&&u instanceof x.Rect&&u.setProps(s)}}_getPosition(e,t){var h;const{startX:n,endX:s,startY:o,endY:a}=e,d=(h=this._renderManagerService.getRenderById(t))==null?void 0:h.with(E.ISheetSelectionRenderService);if(d==null)return;const g=d.getCellWithCoordByOffset(n,o);if(g==null)return;const u={column:g.actualColumn,columnOffset:n-g.startX,row:g.actualRow,rowOffset:o-g.startY},c=d.getCellWithCoordByOffset(s,a);if(c==null)return;const m={column:c.actualColumn,columnOffset:s-c.startX,row:c.actualRow,rowOffset:a-c.startY};return{from:u,to:m}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(e=>{e.forEach(t=>{const n=this._drawingManagerService.getDrawingByParam(t);if(!n||n.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART)return;const s={...n.transform};this._transformChange$.next({id:t.drawingId,value:s}),this._canvasFloatDomService.updateFloatDom(t.drawingId,{...n});const o=this._getSceneAndTransformerByDrawingSearch(t.unitId);if(o&&n.drawingType!==l.DrawingTypeEnum.DRAWING_CHART){const{scene:a}=o,d=this._domLayerInfoMap.get(t.drawingId);d!=null&&d.rect&&(n.allowTransform===!1?a.detachTransformerFrom(d.rect):a.attachTransformerTo(d.rect))}})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(e=>{e.forEach(t=>{this._removeDom(t.drawingId)})}))}addFloatDomToPosition(e,t){const n=C.getSheetCommandTarget(this._univerInstanceService,{unitId:e.unitId,subUnitId:e.subUnitId});if(!n)throw new Error("cannot find current target!");const{unitId:s,subUnitId:o}=n,{initPosition:a,componentKey:d,data:g,allowTransform:u=!0}=e,c=t!=null?t:l.generateRandomId(),m=this._getPosition(a,s);if(m==null)return;const h={unitId:s,subUnitId:o,drawingId:c,drawingType:e.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:m,transform:{left:a.startX,top:a.startY,width:a.endX-a.startX,height:a.endY-a.startY},data:g,allowTransform:u};return this._commandService.executeCommand(Ne.id,{unitId:s,drawings:[h]}),this._add$.next({unitId:s,subUnitId:o,id:c}),{id:c,dispose:()=>{this._removeDom(c,!0)}}}_removeDom(e,t=!1){const n=this._domLayerInfoMap.get(e);if(!n)return;const{unitId:s,subUnitId:o}=n;this._domLayerInfoMap.delete(e),n.dispose.dispose();const a=this._getSceneAndTransformerByDrawingSearch(s);if(a&&a.scene.removeObject(n.rect),t){const d=this._drawingManagerService.getDrawingByParam({unitId:s,subUnitId:o,drawingId:e});if(!d)return;const g=this._sheetDrawingService.getBatchRemoveOp([d]),{redo:u,objects:c}=g;this._commandService.syncExecuteCommand(S.SetDrawingApplyMutation.id,{unitId:s,subUnitId:o,op:u,objects:c,type:S.DrawingApplyType.REMOVE})}}addFloatDomToRange(e,t,n,s){var I,A,b;const o=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!o)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=o,g=this._getSceneAndTransformerByDrawingSearch(a);if(!g)return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(I=this._renderManagerService.getRenderById(a))==null?void 0:I.with(E.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,w=s!=null?s:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver(e,u,c.skeleton);if(this._getPosition(f,a)==null)return;const y=g.scene,{scaleX:T}=y.getAncestorScale(),D=qe(f,n,T),M={unitId:a,subUnitId:d,drawingId:w,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:D.startX,top:D.startY,width:D.width,height:D.height},data:h,allowTransform:p};{const{unitId:P,subUnitId:N,drawingId:U}=M,R=C.getSheetCommandTarget(this._univerInstanceService,{unitId:P,subUnitId:N}),W=M,L=this._univerInstanceService.getUnit(P,l.UniverInstanceType.UNIVER_SHEET);if(!L)return;const J=L.getActiveSheet().getSheetId();if(!W||!R)return;const ee=(A=this._renderManagerService.getRenderById(P))==null?void 0:A.with(E.SheetSkeletonManagerService);if(!ee)return;const K=ee.getWorksheetSkeleton(N);if(!K)return;const{transform:q,drawingType:ie,data:z}=W;if(ie!==l.DrawingTypeEnum.DRAWING_DOM&&ie!==l.DrawingTypeEnum.DRAWING_CHART)return;const Q=this._getSceneAndTransformerByDrawingSearch(P);if(Q==null)return;const{scene:H,canvas:fe}=Q;if(q==null||J!==N)return;const{left:We,top:$e,width:Be,height:Le,angle:dt,flipX:lt,flipY:Fe,skewX:Ye,skewY:we}=q,Ge=j.getDrawingShapeKeyByDrawingSearch({unitId:P,subUnitId:N,drawingId:U}),ae=H.getObject(Ge);if(ae!=null){ae.transformByState({left:We,top:$e,width:Be,height:Le,angle:dt,flipX:lt,flipY:Fe,skewX:Ye,skewY:we});return}const te={left:We,top:$e,width:Be,height:Le,zIndex:this._drawingManagerService.getDrawingOrder(P,N).length-1},Se=ie===l.DrawingTypeEnum.DRAWING_CHART;if(Se){const $=z?z.backgroundColor:"white";te.fill=$,te.rotateEnabled=!1,z&&z.border&&(te.stroke=z.border),te.paintFirst="stroke",te.strokeWidth=1,te.borderEnabled=!1,te.radius=8}const ce=new x.Rect(Ge,te);Se&&ce.setObjectType(x.ObjectType.CHART),H.addObject(ce,x.DRAWING_OBJECT_LAYER_INDEX),W.allowTransform!==!1&&H.attachTransformerTo(ce);const de=new l.DisposableCollection,He=H.getMainViewport(),{rowHeaderWidth:ve,columnHeaderHeight:Re}=K.skeleton,Ve={top:Re,left:ve,bottom:He.bottom,right:He.right},le={dispose:de,rect:ce,boundsOfViewArea:Ve,domAnchor:n,unitId:P,subUnitId:N},V=oe(ce,Q.renderUnit.scene,K.skeleton,R.worksheet,le),_e=new O.BehaviorSubject(V);le.position$=_e;let be={position$:_e,id:U,componentKey:W.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:$=>{fe.dispatchEvent(new WheelEvent($.type,$))},data:z,unitId:P};t.eventPassThrough&&(be={...be,onPointerDown:$=>{fe.dispatchEvent(new PointerEvent($.type,$))},onPointerMove:$=>{fe.dispatchEvent(new PointerEvent($.type,$))},onPointerUp:$=>{fe.dispatchEvent(new PointerEvent($.type,$))}}),this._canvasFloatDomService.addFloatDom(be),this.disposeWithMe(v.subscribe($=>{var Et,Ot,Ut,At;const bt=qe({startX:$.startX,startY:$.startY,endX:$.endX,endY:$.endY,width:(Et=n.width)!=null?Et:$.width,height:(Ot=n.height)!=null?Ot:$.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),zt=j.getDrawingShapeKeyByDrawingSearch({unitId:P,subUnitId:N,drawingId:U}),qt=new x.Rect(zt,{left:bt.startX,top:bt.startY,width:(Ut=n.width)!=null?Ut:$.width,height:(At=n.height)!=null?At:$.height,zIndex:this._drawingManagerService.getDrawingOrder(P,N).length-1}),Zt=oe(qt,Q.renderUnit.scene,K.skeleton,R.worksheet,le);_e.next(Zt)}));const Ee=(b=this._renderManagerService.getRenderById(P))==null?void 0:b.with(E.SheetSkeletonManagerService);Ee==null||Ee.currentSkeleton$.subscribe($=>{$&&K.sheetId!==$.sheetId&&this._removeDom(w,!0)});const Xe=ce.onTransformChange$.subscribeEvent(()=>{const $=oe(ce,Q.renderUnit.scene,K.skeleton,R.worksheet,le);_e.next($)});de.add(()=>{this._canvasFloatDomService.removeFloatDom(U)}),Xe&&de.add(Xe),this._domLayerInfoMap.set(U,le)}return{id:w,dispose:()=>{this._removeDom(w,!0)}}}addFloatDomToColumnHeader(e,t,n,s){var D,M,I;const o=C.getSheetCommandTarget(this._univerInstanceService,{unitId:t.unitId,subUnitId:t.subUnitId});if(!o)throw new Error("cannot find current target!");const{unitId:a,subUnitId:d}=o;if(!this._getSceneAndTransformerByDrawingSearch(a))return;const u=this._renderManagerService.getRenderById(a);if(!u)return;const c=(D=this._renderManagerService.getRenderById(a))==null?void 0:D.with(E.SheetSkeletonManagerService).getWorksheetSkeleton(d);if(!c)return;const{componentKey:m,data:h,allowTransform:p=!0}=t,w=s!=null?s:l.generateRandomId(),{position:f,position$:v}=this._createRangePositionObserver({startRow:0,endRow:0,startColumn:e,endColumn:e},u,c.skeleton),_=f;if(_.startY=0,this._getPosition(f,a)==null)return;const T={unitId:a,subUnitId:d,drawingId:w,drawingType:t.type||l.DrawingTypeEnum.DRAWING_DOM,componentKey:m,transform:{left:_.startX,top:_.startY,width:_.width,height:_.height},data:h,allowTransform:p};{const{unitId:A,subUnitId:b,drawingId:P}=T,N=C.getSheetCommandTarget(this._univerInstanceService,{unitId:A,subUnitId:b}),U=T,R=this._univerInstanceService.getUnit(A,l.UniverInstanceType.UNIVER_SHEET);if(!R)return;const W=R.getActiveSheet().getSheetId();if(!U||!N)return;const L=(M=this._renderManagerService.getRenderById(A))==null?void 0:M.with(E.SheetSkeletonManagerService);if(!L)return;const J=L.getWorksheetSkeleton(b);if(!J)return;const{transform:ee,data:K}=U,q=this._getSceneAndTransformerByDrawingSearch(A);if(q==null)return;const{scene:ie,canvas:z}=q;if(ee==null||W!==b)return;const{left:Q,top:H,width:fe,height:We,angle:$e,flipX:Be,flipY:Le,skewX:dt,skewY:lt}=ee,Fe=j.getDrawingShapeKeyByDrawingSearch({unitId:A,subUnitId:b,drawingId:P}),Ye=ie.getObject(Fe);if(Ye!=null){Ye.transformByState({left:Q,top:H,width:fe,height:We,angle:$e,flipX:Be,flipY:Le,skewX:dt,skewY:lt});return}const we=qe({startX:_.startX,startY:0,endX:f.endX,endY:f.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),Ge={left:we.startX,top:we.startY,width:we.width,height:we.height,zIndex:this._drawingManagerService.getDrawingOrder(A,b).length-1},ae=new x.Rect(Fe,Ge);ie.addObject(ae,x.DRAWING_OBJECT_LAYER_INDEX),U.allowTransform!==!1&&ie.attachTransformerTo(ae);const te=new l.DisposableCollection,Se=ie.getMainViewport(),ce={top:0,left:Se.left,bottom:Se.bottom,right:Se.right},de={dispose:te,rect:ae,unitId:A,subUnitId:b,boundsOfViewArea:ce,domAnchor:n,scrollDirectionResponse:"HORIZONTAL"},He=oe(ae,q.renderUnit.scene,J.skeleton,N.worksheet,de),ve=new O.BehaviorSubject(He);de.position$=ve;let Re={position$:ve,id:P,componentKey:U.componentKey,onPointerDown:()=>{},onPointerMove:()=>{},onPointerUp:()=>{},onWheel:V=>{z.dispatchEvent(new WheelEvent(V.type,V))},data:K,unitId:A};t.eventPassThrough&&(Re={...Re,onPointerDown:V=>{z.dispatchEvent(new PointerEvent(V.type,V))},onPointerMove:V=>{z.dispatchEvent(new PointerEvent(V.type,V))},onPointerUp:V=>{z.dispatchEvent(new PointerEvent(V.type,V))}}),this._canvasFloatDomService.addFloatDom(Re);const Ve=ae.onTransformChange$.subscribeEvent(()=>{const V=oe(ae,q.renderUnit.scene,J.skeleton,N.worksheet,de);ve.next(V)});this.disposeWithMe(v.subscribe(V=>{const _e=qe({startX:V.startX,startY:0,endX:V.endX,endY:V.endY,width:n.width,height:n.height,absolute:{left:f.absolute.left,top:f.absolute.top}},n),be=j.getDrawingShapeKeyByDrawingSearch({unitId:A,subUnitId:b,drawingId:P}),Ee=new x.Rect(be,{left:_e.startX,top:0,width:n.width,height:n.height,zIndex:this._drawingManagerService.getDrawingOrder(A,b).length-1}),Xe=oe(Ee,q.renderUnit.scene,J.skeleton,N.worksheet,de);ve.next(Xe)}));const le=(I=this._renderManagerService.getRenderById(A))==null?void 0:I.with(E.SheetSkeletonManagerService);le==null||le.currentSkeleton$.subscribe(V=>{V&&c.sheetId!==V.sheetId&&this._removeDom(w,!0)}),te.add(()=>{this._canvasFloatDomService.removeFloatDom(P)}),Ve&&te.add(Ve),this._domLayerInfoMap.set(P,de)}return{id:w,dispose:()=>{this._removeDom(w,!0)}}}_createRangePositionObserver(e,t,n){let{startRow:s,startColumn:o}=e;const a=Pe(s,o,n),d=new O.BehaviorSubject(a),g=Pe(e.endRow,e.endColumn,n),u=new O.BehaviorSubject(g),c=()=>{const v=Pe(s,o,n),_=Pe(e.endRow,e.endColumn,n);d.next(v),u.next(_)},m=new l.DisposableCollection;m.add(t.engine.clientRect$.subscribe(()=>c())),m.add(this._commandService.onCommandExecuted(v=>{if(v.id===C.SetWorksheetRowAutoHeightMutation.id&&v.params.rowsAutoHeightInfo.findIndex(y=>y.row===s)>-1){c();return}(C.COMMAND_LISTENER_SKELETON_CHANGE.indexOf(v.id)>-1||v.id===E.SetScrollOperation.id||v.id===E.SetZoomRatioOperation.id)&&c()}));const h=(v,_)=>{s=v,o=_,c()},p=()=>({rotate:0,width:g.right-a.left,height:g.bottom-a.top,absolute:{left:!0,top:!0},startX:a.left,startY:a.top,endX:g.right,endY:g.bottom}),w=d.pipe(O.map(v=>{const _=Pe(e.endRow,e.endColumn,n);return{rotate:0,width:_.right-v.left,height:_.bottom-v.top,absolute:{left:!0,top:!0},startX:v.left,startY:v.top,endX:_.right,endY:_.bottom}})),f=p();return{position$:w,position:f,updateRowCol:h,topLeftPos$:d,rightBottomPos$:u,disposable:m}}};exports.SheetCanvasFloatDomManagerService=Un([me(0,l.Inject(x.IRenderManagerService)),me(1,l.IUniverInstanceService),me(2,l.Inject(l.ICommandService)),me(3,j.IDrawingManagerService),me(4,l.Inject(k.CanvasFloatDomService)),me(5,S.ISheetDrawingService),me(6,l.Inject(l.LifecycleService))],exports.SheetCanvasFloatDomManagerService);function Pe(i,r,e){const t=e.getCellWithCoordByIndex(i,r),n=t.isMergedMainCell?t.mergeInfo:t;return{left:n.startX,right:n.endX,top:n.startY,bottom:n.endY}}function qe(i,r,e){var g,u;e=e!=null?e:1;const t=i.endX-i.startX,n=i.endY-i.startY,s=(g=r==null?void 0:r.width)!=null?g:t,o=(u=r==null?void 0:r.height)!=null?u:n;let a=0,d=0;if(r){if(r.horizonOffsetAlign==="right"){const c=Ze(r.marginX,t*e);a=i.endX-c-s}else a=i.startX+Ze(r.marginX,t);if(r.verticalOffsetAlign==="bottom"){const c=Ze(r.marginY,n*e);d=i.endY-c-o}else d=i.startY+Ze(r.marginY,n)}return{rotate:0,startX:a,startY:d,endX:i.endX,endY:i.endY,width:s,height:o,absolute:{left:i.absolute.left,top:i.absolute.top}}}function Ze(i,r){if(i===void 0)return 0;if(typeof i=="number")return i;const e=Number.parseFloat(i);return r*e/100}const An=i=>{const{floatDomInfos:r,scene:e,skeleton:t,worksheet:n}=i,s=G.useMemo(()=>r.map(o=>{const{width:a,height:d,angle:g,left:u,top:c}=o.transform,m=Gt({left:u!=null?u:0,right:(u!=null?u:0)+(a!=null?a:0),top:c!=null?c:0,bottom:(c!=null?c:0)+(d!=null?d:0)},e,t,n,void 0,!0),{scaleX:h,scaleY:p}=e.getAncestorScale(),w={startX:m.left,endX:m.right,startY:m.top,endY:m.bottom,rotate:g,width:a*h,height:d*p,absolute:m.absolute},f={position$:new O.BehaviorSubject(w),position:w,id:o.drawingId,componentKey:o.componentKey,onPointerMove:()=>{},onPointerDown:()=>{},onPointerUp:()=>{},onWheel:()=>{},unitId:o.unitId,data:o.data};return[o.drawingId,f]}),[r,e,t,n]);return B.jsx("div",{style:{position:"absolute",top:0,left:0},children:s.map(([o,a])=>B.jsx(k.PrintFloatDomSingle,{layer:a,id:o,position:a.position},o))})};var Pn=Object.getOwnPropertyDescriptor,Nn=(i,r,e,t)=>{for(var n=t>1?void 0:t?Pn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},pe=(i,r)=>(e,t)=>r(e,t,i);let ot=class extends l.Disposable{constructor(i,r,e,t,n,s,o){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=r,this._drawingManagerService=e,this._renderManagerService=t,this._canvasFloatDomManagerService=n,this._componetManager=s,this._injector=o,this._initPrinting(),this._initPrintingDom()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,r,e)=>{const{unitId:t,scene:n,subUnitId:s}=r,o=this._drawingManagerService.getDrawingDataForUnit(t),a=o==null?void 0:o[s];return a&&a.order.forEach(d=>{const g=a.data[d];g.drawingType!==l.DrawingTypeEnum.DRAWING_CHART&&g.drawingType!==l.DrawingTypeEnum.DRAWING_DOM&&this._drawingRenderService.renderDrawing(g,n)}),e()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,r,e)=>{const{unitId:t,subUnitId:n}=r,s=this._renderManagerService.getRenderById(t);if(!s)return e(i);const o=s.with(E.SheetSkeletonManagerService).getSkeletonParam(n);if(!o)return e(i);const a=this._drawingManagerService.getDrawingDataForUnit(t),d=a==null?void 0:a[r.subUnitId];if(!d)return e(i);const{scaleX:g,scaleY:u}=s.scene,c=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},m=d.order.map(h=>d.data[h]);return m.length?(m.forEach(h=>{if(!h.groupId&&h.transform&&l.Tools.isDefine(h.transform.left)&&l.Tools.isDefine(h.transform.top)&&l.Tools.isDefine(h.transform.width)&&l.Tools.isDefine(h.transform.height)){const p=o.skeleton.getCellIndexByOffset(h.transform.left,h.transform.top,g,u,{x:0,y:0}),w=o.skeleton.getCellIndexByOffset(h.transform.left+h.transform.width,h.transform.top+h.transform.height,g,u,{x:0,y:0});p.column<c.startColumn&&(c.startColumn=p.column),p.row<c.startRow&&(c.startRow=p.row),c.endRow<w.row&&(c.endRow=w.row),c.endColumn<w.column&&(c.endColumn=w.column)}}),e(c)):e(i)}}))}_initPrintingDom(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_DOM_COLLECT,{handler:(i,r,e)=>{const{unitId:t,subUnitId:n}=r,s=this._drawingManagerService.getDrawingDataForUnit(t),o=s==null?void 0:s[n];if(o){const a=o.order.map(g=>{const u=o.data[g];if(u.drawingType===l.DrawingTypeEnum.DRAWING_CHART)return{...u,componentKey:this._componetManager.get(l.PRINT_CHART_COMPONENT_KEY)};if(u.drawingType===l.DrawingTypeEnum.DRAWING_DOM){const c=this._sheetPrintInterceptorService.getPrintComponent(u.componentKey);return{...u,componentKey:this._componetManager.get(c||u.componentKey)}}return null}).filter(Boolean),d=k.connectInjector(An,this._injector);return F.render(B.jsx(d,{floatDomInfos:a,scene:r.scene,skeleton:r.skeleton,worksheet:r.worksheet}),r.root),i==null||i.add(()=>{F.unmount(r.root)}),e(i)}}}))}};ot=Nn([pe(0,l.Inject(E.SheetPrintInterceptorService)),pe(1,l.Inject(he.DrawingRenderService)),pe(2,j.IDrawingManagerService),pe(3,x.IRenderManagerService),pe(4,l.Inject(exports.SheetCanvasFloatDomManagerService)),pe(5,l.Inject(k.ComponentManager)),pe(6,l.Inject(l.Injector))],ot);var jn=Object.getOwnPropertyDescriptor,kn=(i,r,e,t)=>{for(var n=t>1?void 0:t?jn(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},ue=(i,r)=>(e,t)=>r(e,t,i);const xn=[C.InsertRowCommand.id,C.InsertColCommand.id,C.RemoveRowCommand.id,C.RemoveColCommand.id,C.DeleteRangeMoveLeftCommand.id,C.DeleteRangeMoveUpCommand.id,C.InsertRangeMoveDownCommand.id,C.InsertRangeMoveRightCommand.id,C.DeltaRowHeightCommand.id,C.SetRowHeightCommand.id,C.DeltaColumnWidthCommand.id,C.SetColWidthCommand.id,C.SetRowHiddenCommand.id,C.SetSpecificRowsVisibleCommand.id,C.SetSpecificColsVisibleCommand.id,C.SetColHiddenCommand.id,C.MoveColsCommand.id,C.MoveRowsCommand.id,C.MoveRangeCommand.id],Wn=[C.SetRowVisibleMutation.id,C.SetRowHiddenMutation.id,C.SetColVisibleMutation.id,C.SetColHiddenMutation.id,C.SetWorksheetRowHeightMutation.id,C.SetWorksheetColWidthMutation.id];let vt=class extends l.Disposable{constructor(i,r,e,t,n,s,o,a,d){super(),this._context=i,this._renderManagerService=r,this._commandService=e,this._selectionRenderService=t,this._skeletonManagerService=n,this._sheetInterceptorService=s,this._sheetDrawingService=o,this._drawingManagerService=a,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptAfterCommand({getMutations:i=>{if(!xn.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const r=i.id;if(r===C.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([C.MoveColsCommand.id,C.MoveRowsCommand.id,C.MoveRangeCommand.id].includes(r))return this._moveRangeInterceptor(i.params);if(r===C.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(r===C.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(r===C.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(r===C.DeleteRangeMoveLeftCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,0)}else if(r===C.DeleteRangeMoveUpCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,1)}else if(r===C.InsertRangeMoveDownCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,2)}else if(r===C.InsertRangeMoveRightCommand.id){const{range:e}=i.params;return this._getRangeMoveUndo(e,3)}else if(r===C.SetRowHiddenCommand.id||r===C.SetSpecificRowsVisibleCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:s}=e;return this._getDrawingUndoForRowVisible(t,n,s)}else if(r===C.SetSpecificColsVisibleCommand.id||r===C.SetColHiddenCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:s}=e;return this._getDrawingUndoForColVisible(t,n,s)}else if(r===C.DeltaRowHeightCommand.id||r===C.SetRowHeightCommand.id||r===C.DeltaColumnWidthCommand.id||r===C.SetColWidthCommand.id){const e=i.params,{unitId:t,subUnitId:n,ranges:s}=e,o=r===C.DeltaRowHeightCommand.id||r===C.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(t,n,s,o)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,r){const e=C.getSheetCommandTarget(this._univerInstanceService);if(e==null)return{redos:[],undos:[]};const t=e.unitId,n=e.subUnitId,s=[],o=[],a=this._sheetDrawingService.getDrawingData(t,n),d=[],g=[];if(Object.keys(a).forEach(u=>{const c=a[u],{updateDrawings:m,deleteDrawings:h}=this._getUpdateOrDeleteDrawings(i,r,c);d.push(...m),g.push(...h)}),d.length===0&&g.length===0)return{redos:[],undos:[]};if(d.length>0){const u=this._sheetDrawingService.getBatchUpdateOp(d),{undo:c,redo:m,objects:h}=u;s.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:m,objects:h,type:S.DrawingApplyType.UPDATE}}),o.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:c,objects:h,type:S.DrawingApplyType.UPDATE}})}if(g.length>0){const u=this._sheetDrawingService.getBatchRemoveOp(g),c=u.undo,m=u.redo,h=u.objects;s.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:m,objects:h,type:S.DrawingApplyType.REMOVE}}),o.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:c,objects:h,type:S.DrawingApplyType.INSERT}})}return s.push({id:X.id,params:[t]}),o.push({id:X.id,params:[t]}),{redos:s,undos:o}}_getUpdateOrDeleteDrawings(i,r,e){const t=[],n=[],{sheetTransform:s,anchorType:o=S.SheetDrawingAnchorType.Position,transform:a,unitId:d,subUnitId:g,drawingId:u}=e,{from:c,to:m}=s,{row:h,column:p}=c,{row:w,column:f}=m;if(s==null||a==null)return{updateDrawings:t,deleteDrawings:n};const{startRow:v,endRow:_,startColumn:y,endColumn:T}=i;let D=null,M=null;if(r===0&&h>=v&&w<=_)if(p>=y&&f<=T)n.push({unitId:d,subUnitId:g,drawingId:u});else{const I=this._shrinkCol(s,a,y,T,o);D=I==null?void 0:I.newSheetTransform,M=I==null?void 0:I.newTransform}else if(r===1&&p>=y&&f<=T)if(h>=v&&w<=_)n.push({unitId:d,subUnitId:g,drawingId:u});else{const I=this._shrinkRow(s,a,v,_,o);D=I==null?void 0:I.newSheetTransform,M=I==null?void 0:I.newTransform}else if(r===2){const I=this._expandRow(s,a,v,_,o);D=I==null?void 0:I.newSheetTransform,M=I==null?void 0:I.newTransform}else if(r===3){const I=this._expandCol(s,a,y,T,o);D=I==null?void 0:I.newSheetTransform,M=I==null?void 0:I.newTransform}if(D!=null&&M!=null){const I=Z(D,this._selectionRenderService,this._skeletonManagerService);t.push({...e,sheetTransform:D,transform:I})}return{updateDrawings:t,deleteDrawings:n}}_remainDrawingSize(i,r,e){const t=Y({...i},this._selectionRenderService);t!=null&&r.push({...e,sheetTransform:t})}_getDrawingUndoForColVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],s=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:m,transform:h,anchorType:p=S.SheetDrawingAnchorType.Position}=c;if(p===S.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:w,to:f}=m,{row:v,column:_}=w,{row:y,column:T}=f;for(let D=0;D<e.length;D++){const M=e[D],{startRow:I,endRow:A,startColumn:b,endColumn:P}=M;if(T<b)continue;if(p===S.SheetDrawingAnchorType.Position){let R=null,W=null;if(_>=b&&_<=P){const L=this._skeletonManagerService.attachRangeWithCoord({startColumn:_,endColumn:P,startRow:w.row,endRow:f.row});if(L==null)return;W={...h,left:L.startX}}if(W!=null&&(R=Y(W,this._selectionRenderService),R!=null&&W!=null)){n.push({...c,sheetTransform:R,transform:W});break}this._remainDrawingSize(h,n,c);continue}if(_>=b&&T<=P)continue;let N=null,U=null;if(_>=b&&_<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:_,endColumn:P,startRow:w.row,endRow:f.row});if(R==null)return;U={...h,left:(R==null?void 0:R.startX)||0,width:((h==null?void 0:h.width)||0)-R.endX+R.startX}}else if(T>=b&&T<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:T,startRow:w.row,endRow:f.row});if(R==null)return;U={...h,left:R.startX-((h==null?void 0:h.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:P,startRow:w.row,endRow:f.row});if(R==null)return;if(U={...h,width:((h==null?void 0:h.width)||0)-R.endX+R.startX},N=Y(U,this._selectionRenderService),N!=null&&U!=null){s.push({...c,sheetTransform:N,transform:U});break}}if(U!=null&&(N=Y(U,this._selectionRenderService)),U!=null&&N!=null){n.push({...c,sheetTransform:N,transform:U});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&s.length===0)return{redos:[],undos:[]};const{redos:o,undos:a}=this._createUndoAndRedoMutation(i,r,n),d=[],g=[];if(s.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,s);d.push(...u),g.push(...c)}return{redos:o,undos:a,preRedos:d,preUndos:g}}_createUndoAndRedoMutation(i,r,e){const t=this._sheetDrawingService.getBatchUpdateOp(e),{undo:n,redo:s,objects:o}=t,a=[{id:S.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:s,objects:o,type:S.DrawingApplyType.UPDATE}},{id:X.id,params:[i]}],d=[{id:S.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:r,op:n,objects:o,type:S.DrawingApplyType.UPDATE}},{id:X.id,params:[i]}];return{redos:a,undos:d}}_getDrawingUndoForRowVisible(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[],s=[];if(Object.keys(t).forEach(u=>{const c=t[u],{sheetTransform:m,transform:h,anchorType:p=S.SheetDrawingAnchorType.Position}=c;if(p===S.SheetDrawingAnchorType.None)this._remainDrawingSize(h,n,c);else{const{from:w,to:f}=m,{row:v,column:_}=w,{row:y,column:T}=f;for(let D=0;D<e.length;D++){const M=e[D],{startRow:I,endRow:A,startColumn:b,endColumn:P}=M;if(y<I)continue;if(p===S.SheetDrawingAnchorType.Position){let R=null,W=null;if(v>=I&&v<=A){const L=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:f.column,startRow:v,endRow:A});if(L==null)return;W={...h,top:L.startY}}if(W!=null&&(R=Y(W,this._selectionRenderService),R!=null&&W!=null)){n.push({...c,sheetTransform:R,transform:W});break}this._remainDrawingSize(h,n,c);continue}if(v>=I&&y<=A)continue;let N=null,U=null;if(v>=I&&v<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:f.column,startRow:v,endRow:A});if(R==null)return;U={...h,top:(R==null?void 0:R.startY)||0,height:((h==null?void 0:h.height)||0)-R.endY+R.startY}}else if(y>=I&&y<=A){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:f.column,startRow:I,endRow:y});if(R==null)return;U={...h,top:R.startY-((h==null?void 0:h.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:f.column,startRow:I,endRow:A});if(R==null)return;if(U={...h,height:((h==null?void 0:h.height)||0)-R.endY+R.startY},N=Y(U,this._selectionRenderService),N!=null&&U!=null){s.push({...c,sheetTransform:N,transform:U});break}}if(U!=null&&(N=Y(U,this._selectionRenderService)),U!=null&&N!=null){n.push({...c,sheetTransform:N,transform:U});break}else this._remainDrawingSize(h,n,c)}}}),n.length===0&&s.length===0)return{redos:[],undos:[]};const{redos:o,undos:a}=this._createUndoAndRedoMutation(i,r,n),d=[],g=[];if(s.length>0){const{redos:u,undos:c}=this._createUndoAndRedoMutation(i,r,s);d.push(...u),g.push(...c)}return{redos:o,undos:a,preRedos:d,preUndos:g}}_getDrawingUndoForRowAndColSize(i,r,e,t){const n=this._drawingManagerService.getDrawingData(i,r),s=[];return Object.keys(n).forEach(o=>{const a=n[o],{sheetTransform:d,transform:g,anchorType:u=S.SheetDrawingAnchorType.Position}=a;if(u===S.SheetDrawingAnchorType.None)this._remainDrawingSize(g,s,a);else{const{from:c,to:m}=d,{row:h,column:p}=c,{row:w,column:f}=m;for(let v=0;v<e.length;v++){const _=e[v],{startRow:y,endRow:T,startColumn:D,endColumn:M}=_;if(w<y||f<D)continue;if(u===S.SheetDrawingAnchorType.Position&&(h<=y&&w>=T||p<=D&&f>=M)){this._remainDrawingSize(g,s,a);continue}const I=Z({...d},this._selectionRenderService,this._skeletonManagerService);if(I!=null){s.push({...a,transform:I});break}}}}),s.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,r,s)}_getUnitIdAndSubUnitId(i,r){let e,t;if(r==="insert")e=i.unitId,t=i.subUnitId;else{const n=C.getSheetCommandTarget(this._univerInstanceService);if(n==null)return;e=n.unitId,t=n.subUnitId}return{unitId:e,subUnitId:t}}_moveRangeInterceptor(i){var y,T;const{toRange:r,fromRange:e}=i,t=C.getSheetCommandTarget(this._univerInstanceService);if(!t)return{redos:[],undos:[]};const{unitId:n,subUnitId:s}=t,o=(T=(y=this._renderManagerService.getRenderById(n))==null?void 0:y.with(E.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!o)return{redos:[],undos:[]};const a=E.attachRangeWithCoord(o,e);if(!a)return{redos:[],undos:[]};const{startX:d,endX:g,startY:u,endY:c}=a,m=this._sheetDrawingService.getDrawingData(n,s),h=[];Object.keys(m).forEach(D=>{const M=m[D];if(M.anchorType!==S.SheetDrawingAnchorType.Both)return;const{transform:I}=M;if(!I)return;const{left:A=0,top:b=0,width:P=0,height:N=0}=I,{drawingStartX:U,drawingEndX:R,drawingStartY:W,drawingEndY:L}={drawingStartX:A,drawingEndX:A+P,drawingStartY:b,drawingEndY:b+N};d<=U&&R<=g&&u<=W&&L<=c&&h.push(M)});const p=[],w=[],f=r.startRow-e.startRow,v=r.startColumn-e.startColumn,_=h.map(D=>{const M=D.sheetTransform,I={to:{...M.to,row:M.to.row+f,column:M.to.column+v},from:{...M.from,row:M.from.row+f,column:M.from.column+v}},A=Z(I,this._selectionRenderService,this._skeletonManagerService);return{unitId:n,subUnitId:s,drawingId:D.drawingId,transform:A,sheetTransform:I}});if(_.length){const D=this._sheetDrawingService.getBatchUpdateOp(_),{undo:M,redo:I,objects:A}=D;p.push({id:S.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:s,op:I,objects:A,type:S.DrawingApplyType.UPDATE}}),w.push({id:S.SetDrawingApplyMutation.id,params:{unitId:n,subUnitId:s,op:M,objects:A,type:S.DrawingApplyType.UPDATE}})}return{redos:p,undos:w}}_moveRowInterceptor(i,r){const e=this._getUnitIdAndSubUnitId(i,r);if(e==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=e,{range:s}=i,o=s.startRow,a=s.endRow,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],m=[];if(Object.keys(u).forEach(h=>{const p=u[h],{sheetTransform:w,transform:f,anchorType:v=S.SheetDrawingAnchorType.Position}=p;if(w==null||f==null)return;let _,y;if(r==="insert"){const D=this._expandRow(w,f,o,a,v);_=D==null?void 0:D.newSheetTransform,y=D==null?void 0:D.newTransform}else{const{from:D,to:M}=w,{row:I}=D,{row:A}=M;if(v===S.SheetDrawingAnchorType.Both&&I>=o&&A<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const b=this._shrinkRow(w,f,o,a,v);_=b==null?void 0:b.newSheetTransform,y=b==null?void 0:b.newTransform}}if(!_||!y)return;const T={unitId:t,subUnitId:n,drawingId:h,transform:y,sheetTransform:_};c.push(T)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:w,objects:f}=h;d.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:w,objects:f,type:S.DrawingApplyType.UPDATE}}),g.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:S.DrawingApplyType.UPDATE}})}if(m.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(m),p=h.undo,w=h.redo,f=h.objects;d.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:w,objects:f,type:S.DrawingApplyType.REMOVE}}),g.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:S.DrawingApplyType.INSERT}})}return d.push({id:X.id,params:[t]}),g.push({id:X.id,params:[t]}),{redos:d,undos:g}}_moveColInterceptor(i,r){const e=this._getUnitIdAndSubUnitId(i,r);if(e==null)return{redos:[],undos:[]};const{unitId:t,subUnitId:n}=e,{range:s}=i,o=s.startColumn,a=s.endColumn,d=[],g=[],u=this._sheetDrawingService.getDrawingData(t,n),c=[],m=[];if(Object.keys(u).forEach(h=>{const p=u[h],{sheetTransform:w,transform:f,anchorType:v=S.SheetDrawingAnchorType.Position}=p;if(w==null||f==null)return;let _,y;if(r==="insert"){const D=this._expandCol(w,f,o,a,v);_=D==null?void 0:D.newSheetTransform,y=D==null?void 0:D.newTransform}else{const{from:D,to:M}=w,{column:I}=D,{column:A}=M;if(v===S.SheetDrawingAnchorType.Both&&I>=o&&A<=a)m.push({unitId:t,subUnitId:n,drawingId:h});else{const b=this._shrinkCol(w,f,o,a,v);_=b==null?void 0:b.newSheetTransform,y=b==null?void 0:b.newTransform}}if(!_||!y)return;const T={unitId:t,subUnitId:n,drawingId:h,transform:y,sheetTransform:_};c.push(T)}),c.length===0&&m.length===0)return{redos:[],undos:[]};if(c.length>0){const h=this._sheetDrawingService.getBatchUpdateOp(c),{undo:p,redo:w,objects:f}=h;d.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:w,objects:f,type:S.DrawingApplyType.UPDATE}}),g.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:S.DrawingApplyType.UPDATE}})}if(m.length>0){const h=this._sheetDrawingService.getBatchRemoveOp(m),p=h.undo,w=h.redo,f=h.objects;d.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:w,objects:f,type:S.DrawingApplyType.REMOVE}}),g.push({id:S.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:n,op:p,objects:f,type:S.DrawingApplyType.INSERT}})}return d.push({id:X.id,params:[t]}),g.push({id:X.id,params:[t]}),{redos:d,undos:g}}_expandCol(i,r,e,t,n=S.SheetDrawingAnchorType.Position){const s=t-e+1,{from:o,to:a}=i,{column:d}=o,{column:g}=a;if(n===S.SheetDrawingAnchorType.None)return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=e){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:t,startRow:o.row,endRow:a.row});if(m==null)return;c={...r,left:(r.left||0)+m.endX-m.startX},u=Y(c,this._selectionRenderService)}else if(g>=t)if(n===S.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,column:g+s}},c=Z(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkCol(i,r,e,t,n=S.SheetDrawingAnchorType.Position){const s=t-e+1,{from:o,to:a}=i,{column:d}=o,{column:g}=a;if(n===S.SheetDrawingAnchorType.None)return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>t)u={from:{...o,column:d-s},to:{...a,column:g-s}},c=Z(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&g<=t)return null;if(d<e&&g>t)if(n===S.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,column:g-s}},c=Z(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};else if(d>=e&&d<=t){if(d===e)c={...r,left:(r.left||0)-i.from.columnOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e,endColumn:d-1,startRow:o.row,endRow:a.row});if(m==null)return;c={...r,left:(r.left||0)-m.endX+m.startX-i.from.columnOffset}}u=Y(c,this._selectionRenderService)}else if(g>=e&&g<=t&&n===S.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:e-1,endColumn:e-1,startRow:o.row,endRow:a.row});if(m==null)return;u={from:{...o},to:{...a,column:e-1,columnOffset:m.endX-m.startX}},c=Z(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_expandRow(i,r,e,t,n=S.SheetDrawingAnchorType.Position){const s=t-e+1,{from:o,to:a}=i,{row:d}=o,{row:g}=a;if(n===S.SheetDrawingAnchorType.None)return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>=e){const m=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:t,startColumn:o.column,endColumn:a.column});if(m==null)return;c={...r,top:(r.top||0)+m.endY-m.startY},u=Y(c,this._selectionRenderService)}else if(g>=t)if(n===S.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,row:g+s}},c=Z(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_shrinkRow(i,r,e,t,n=S.SheetDrawingAnchorType.Position){const s=t-e+1,{from:o,to:a}=i,{row:d}=o,{row:g}=a;if(n===S.SheetDrawingAnchorType.None)return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};let u=null,c=null;if(d>t)u={from:{...o,row:d-s},to:{...a,row:g-s}},c=Z(u,this._selectionRenderService,this._skeletonManagerService);else{if(d>=e&&g<=t)return null;if(d<e&&g>t)if(n===S.SheetDrawingAnchorType.Both)u={from:{...o},to:{...a,row:g-s}},c=Z(u,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:Y({...r},this._selectionRenderService),newTransform:r};else if(d>=e&&d<=t){if(d===e)c={...r,top:(r.top||0)-i.from.rowOffset};else{const m=this._skeletonManagerService.attachRangeWithCoord({startRow:e,endRow:d-1,startColumn:o.column,endColumn:a.column});if(m==null)return;c={...r,top:(r.top||0)-m.endY+m.startY-i.from.rowOffset}}u=Y(c,this._selectionRenderService)}else if(g>=e&&g<=t&&n===S.SheetDrawingAnchorType.Both){const m=this._skeletonManagerService.attachRangeWithCoord({startColumn:o.column,endColumn:o.column,startRow:e-1,endRow:e-1});if(m==null)return;u={from:{...o},to:{...a,row:e-1,rowOffset:m.endY-m.startY}},c=Z(u,this._selectionRenderService,this._skeletonManagerService)}}return u!=null&&c!=null?{newSheetTransform:u,newTransform:c}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===C.SetWorksheetActiveOperation.id){const{unitId:r,subUnitId:e}=i.params;this._updateDrawings(r,e)}})),this.disposeWithMe(this._context.activated$.subscribe(i=>{const{unit:r,unitId:e}=this._context;if(i){const t=r.getActiveSheet().getSheetId();this._updateDrawings(e,t)}else this._clearDrawings(e)}))}_clearDrawings(i){setTimeout(()=>{const r=this._drawingManagerService.drawingManagerData,e=[];Object.keys(r).forEach(t=>{const n=r[t];n!=null&&Object.keys(n).forEach(s=>{const o=n[s].data;o!=null&&Object.keys(o).forEach(a=>{t===i&&e.push(o[a])})})}),this._drawingManagerService.removeNotification(e)})}_updateDrawings(i,r){setTimeout(()=>{const e=this._drawingManagerService.drawingManagerData,t=[],n=[];Object.keys(e).forEach(s=>{const o=e[s];o!=null&&Object.keys(o).forEach(a=>{const d=o[a].data;d!=null&&Object.keys(d).forEach(g=>{if(s===i&&a===r){const u=d[g];u.transform=Z(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),t.push(d[g])}else n.push(d[g])})})}),this._drawingManagerService.removeNotification(n),this._drawingManagerService.addNotification(t)},0)}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{Wn.includes(i.id)&&requestIdleCallback(()=>{const r=i.params,{unitId:e,subUnitId:t,ranges:n}=r;this._refreshDrawingTransform(e,t,n)})}))}_refreshDrawingTransform(i,r,e){const t=this._drawingManagerService.getDrawingData(i,r),n=[];Object.keys(t).forEach(s=>{const o=t[s],{sheetTransform:a,transform:d,anchorType:g=S.SheetDrawingAnchorType.Position}=o;if(g===S.SheetDrawingAnchorType.None)return!0;const{from:u,to:c}=a,{row:m,column:h}=u,{row:p,column:w}=c;for(let f=0;f<e.length;f++){const v=e[f],{startRow:_,endRow:y,startColumn:T,endColumn:D}=v;if(l.Rectangle.intersects({startRow:_,endRow:y,startColumn:T,endColumn:D},{startRow:m,endRow:p,startColumn:h,endColumn:w})||m>y||h>D){const M=g===S.SheetDrawingAnchorType.Position,I=Z(a,this._selectionRenderService,this._skeletonManagerService);n.push({...o,transform:{...I,width:M?d==null?void 0:d.width:I==null?void 0:I.width,height:M?d==null?void 0:d.height:I==null?void 0:I.height}});break}}}),n.length!==0&&(this._drawingManagerService.refreshTransform(n),this._commandService.syncExecuteCommand(X.id,[i]))}};vt=kn([ue(1,x.IRenderManagerService),ue(2,l.ICommandService),ue(3,E.ISheetSelectionRenderService),ue(4,l.Inject(E.SheetSkeletonManagerService)),ue(5,l.Inject(C.SheetInterceptorService)),ue(6,S.ISheetDrawingService),ue(7,j.IDrawingManagerService),ue(8,l.IUniverInstanceService)],vt);function Ht({ref:i,...r}){const{icon:e,id:t,className:n,extend:s,...o}=r,a=`univerjs-icon univerjs-icon-${t} ${n||""}`.trim(),d=G.useRef(`_${Ln()}`);return Vt(e,`${t}`,{defIds:e.defIds,idSuffix:d.current},{ref:i,className:a,...o},s)}function Vt(i,r,e,t,n){return G.createElement(i.tag,{key:r,...$n(i,e,n),...t},(Bn(i,e).children||[]).map((s,o)=>Vt(s,`${r}-${i.tag}-${o}`,e,void 0,n)))}function $n(i,r,e){const t={...i.attrs};e!=null&&e.colorChannel1&&t.fill==="colorChannel1"&&(t.fill=e.colorChannel1),i.tag==="mask"&&t.id&&(t.id=t.id+r.idSuffix),Object.entries(t).forEach(([s,o])=>{s==="mask"&&typeof o=="string"&&(t[s]=o.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))});const{defIds:n}=r;return!n||n.length===0||(i.tag==="use"&&t["xlink:href"]&&(t["xlink:href"]=t["xlink:href"]+r.idSuffix),Object.entries(t).forEach(([s,o])=>{typeof o=="string"&&(t[s]=o.replace(/url\(#(.*)\)/,`url(#$1${r.idSuffix})`))})),t}function Bn(i,r){var t;const{defIds:e}=r;return!e||e.length===0?i:i.tag==="defs"&&((t=i.children)!=null&&t.length)?{...i,children:i.children.map(n=>typeof n.attrs.id=="string"&&e&&e.includes(n.attrs.id)?{...n,attrs:{...n.attrs,id:n.attrs.id+r.idSuffix}}:n)}:i}function Ln(){return Math.random().toString(36).substring(2,8)}Ht.displayName="UniverIcon";const Fn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.35381 3.65517C2.35381 2.88198 2.98061 2.25518 3.75381 2.25518H8.10381C8.43518 2.25518 8.70381 1.98655 8.70381 1.65518C8.70381 1.3238 8.43518 1.05518 8.10381 1.05518H3.75381C2.31787 1.05518 1.15381 2.21923 1.15381 3.65517V12.3552C1.15381 13.7911 2.31787 14.9552 3.75381 14.9552H12.4538C13.8897 14.9552 15.0538 13.7911 15.0538 12.3552V8.00518C15.0538 7.6738 14.7852 7.40518 14.4538 7.40518C14.1224 7.40518 13.8538 7.6738 13.8538 8.00518V9.24469L12.3428 8.11143C11.8294 7.72642 11.1111 7.77744 10.6573 8.23119L9.11281 9.77567L6.84342 7.83047C6.34812 7.40592 5.61375 7.41815 5.13289 7.85896L2.35381 10.4064V3.65517ZM2.35381 12.0343V12.3552C2.35381 13.1284 2.98061 13.7552 3.75381 13.7552H12.4538C13.227 13.7552 13.8538 13.1284 13.8538 12.3552V10.7447L11.6228 9.07144C11.5871 9.04469 11.5373 9.04827 11.5058 9.07971L10.0266 10.5589L11.2057 11.5696C11.4573 11.7853 11.4865 12.164 11.2708 12.4156C11.0552 12.6672 10.6764 12.6964 10.4248 12.4807L6.06245 8.74157C6.02809 8.71212 5.97713 8.71296 5.94377 8.74353L2.35381 12.0343Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3911 3.84419C10.6254 3.60988 11.0053 3.60988 11.2396 3.84419L11.8818 4.48643V1.93496C11.8818 1.60359 12.1505 1.33496 12.4818 1.33496C12.8132 1.33496 13.0818 1.60359 13.0818 1.93496V4.48676L13.7244 3.84419C13.9587 3.60988 14.3386 3.60988 14.5729 3.84419C14.8072 4.07851 14.8072 4.45841 14.5729 4.69272L12.9063 6.35939C12.6719 6.5937 12.292 6.5937 12.0577 6.35939L10.3911 4.69272C10.1568 4.45841 10.1568 4.07851 10.3911 3.84419Z"}}]},Xt=G.forwardRef(function(r,e){return G.createElement(Ht,Object.assign({},r,{id:"download-image-icon",ref:e,icon:Fn}))});Xt.displayName="DownloadImageIcon";function Yn(){const i=k.useDependency(l.LocaleService),r=k.useDependency(k.IDialogService),e=k.useDependency(ct),[t,n]=G.useState([ge.CELL_ADDRESS]),[s,o]=G.useState(!1),[a,d]=G.useState(null),g=G.useMemo(()=>e.getCellImagesInSelection(),[e]),u=G.useMemo(()=>e.getDataColumns(),[e]),c=G.useMemo(()=>e.getSelectionRowRange(),[e]),m=u.length>0,h=G.useMemo(()=>u.map(M=>({label:M.label,value:String(M.index)})),[u]),[p,w]=G.useState(()=>h.length>0?h[0].value:"0"),f=G.useMemo(()=>{if(!t.includes(ge.COLUMN_VALUE)||!c)return[];const I=Number(p);return[{startRow:c.startRow,endRow:c.endRow,startColumn:I,endColumn:I}]},[t,p,c]);E.useHighlightRange(f);const v=G.useCallback(M=>{M.length!==0&&n(M)},[]),_=G.useCallback(M=>{w(String(M))},[]),y=G.useCallback(()=>{r.close(Ce)},[r]),T=G.useCallback(async()=>{if(g.length!==0){o(!0),d(null);try{await e.saveImages(g,{fileNameParts:t,columnIndex:t.includes(ge.COLUMN_VALUE)?Number(p):void 0}),r.close(Ce)}catch(M){console.error("Failed to save images:",M),d(i.t("sheetImage.save.error"))}finally{o(!1)}}},[e,g,t,p,r,i]),D=t.includes(ge.COLUMN_VALUE);return B.jsxs("div",{className:"univer-flex univer-flex-col",children:[B.jsx(F.FormLayout,{label:i.t("sheetImage.save.imageCount"),children:B.jsx("div",{className:"univer-text-sm univer-text-gray-600",children:g.length})}),B.jsx(F.FormLayout,{label:i.t("sheetImage.save.fileNameConfig"),children:B.jsxs(F.CheckboxGroup,{value:t,onChange:v,direction:"vertical",children:[B.jsx(F.Checkbox,{value:ge.CELL_ADDRESS,disabled:!m,children:i.t("sheetImage.save.useRowCol")}),m&&B.jsx(F.Checkbox,{value:ge.COLUMN_VALUE,children:i.t("sheetImage.save.useColumnValue")})]})}),D&&B.jsx(F.FormLayout,{label:i.t("sheetImage.save.selectColumn"),children:B.jsx(F.Select,{value:p,options:h,onChange:_})}),a&&B.jsx("div",{className:"univer-text-xs univer-text-red-500",children:a}),B.jsxs("div",{className:"univer-flex univer-justify-end univer-gap-2 univer-border-t univer-border-gray-200 univer-pt-3",children:[B.jsx(F.Button,{onClick:y,disabled:s,children:i.t("sheetImage.save.cancel")}),B.jsx(F.Button,{variant:"primary",onClick:T,disabled:s||g.length===0,children:s?i.t("sheetImage.save.saving"):i.t("sheetImage.save.confirm")})]})]})}const Gn=i=>{var _;const r=k.useDependency(l.ICommandService),e=k.useDependency(l.LocaleService),t=k.useDependency(j.IDrawingManagerService),n=k.useDependency(x.IRenderManagerService),{drawings:s}=i,o=s[0];if(o==null)return;const{unitId:a}=o,d=n.getRenderById(a),g=d==null?void 0:d.scene;if(g==null)return;const u=g.getTransformerByCreate(),[c,m]=G.useState(!0),h=(_=o.anchorType)!=null?_:S.SheetDrawingAnchorType.Position,[p,w]=G.useState(h);function f(y,T){const D=[];return y.forEach(M=>{const{oKey:I}=M,A=T.getDrawingOKey(I);if(A==null)return D.push(null),!0;const{unitId:b,subUnitId:P,drawingId:N,drawingType:U,anchorType:R,sheetTransform:W}=A;D.push({unitId:b,subUnitId:P,drawingId:N,anchorType:R,sheetTransform:W,drawingType:U})}),D}G.useEffect(()=>{const y=u.clearControl$.subscribe(D=>{D===!0&&m(!1)}),T=u.changeStart$.subscribe(D=>{var A;const{objects:M}=D,I=f(M,t);if(I.length===0)m(!1);else if(I.length>=1){m(!0);const b=((A=I[0])==null?void 0:A.anchorType)||S.SheetDrawingAnchorType.Position;w(b)}});return()=>{T.unsubscribe(),y.unsubscribe()}},[]);function v(y){w(y);const T=t.getFocusDrawings();if(T.length===0)return;const D=T.map(M=>({unitId:M.unitId,subUnitId:M.subUnitId,drawingId:M.drawingId,anchorType:y}));r.executeCommand(je.id,{unitId:T[0].unitId,drawings:D})}return B.jsxs("div",{className:F.clsx("univer-grid univer-gap-2 univer-py-2 univer-text-gray-400",{"univer-hidden":!c}),children:[B.jsx("header",{className:"univer-text-gray-600 dark:!univer-text-gray-200",children:B.jsx("div",{children:e.t("drawing-anchor.title")})}),B.jsx("div",{children:B.jsxs(F.RadioGroup,{value:p,onChange:v,direction:"vertical",children:[B.jsx(F.Radio,{value:S.SheetDrawingAnchorType.Both,children:e.t("drawing-anchor.both")}),B.jsx(F.Radio,{value:S.SheetDrawingAnchorType.Position,children:e.t("drawing-anchor.position")}),B.jsx(F.Radio,{value:S.SheetDrawingAnchorType.None,children:e.t("drawing-anchor.none")})]})})]})},Hn=()=>{const i=k.useDependency(j.IDrawingManagerService),r=i.getFocusDrawings(),[e,t]=G.useState(r);return G.useEffect(()=>{const n=i.focus$.subscribe(s=>{t(s)});return()=>{n.unsubscribe()}},[]),!!(e!=null&&e.length)&&B.jsxs("div",{className:"univer-text-sm",children:[B.jsx(he.DrawingCommonPanel,{drawings:e}),B.jsx(Gn,{drawings:e})]})},Rt="sheet.menu.image";function Vn(i){return{id:Rt,type:k.MenuItemType.SUBITEMS,icon:"AddImageIcon",tooltip:"sheetImage.title",hidden$:k.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:E.getCurrentRangeDisable$(i,{workbookTypes:[C.WorkbookEditablePermission],worksheetTypes:[C.WorksheetEditPermission],rangeTypes:[C.RangeProtectionPermissionEditPoint]})}}function Xn(i){return{id:ke.id,title:"sheetImage.upload.float",type:k.MenuItemType.BUTTON,hidden$:k.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function Kn(i){return{id:yt.id,title:"sheetImage.upload.cell",type:k.MenuItemType.BUTTON,hidden$:k.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET)}}function zn(i){var r,e,t,n;return!!((e=(r=i==null?void 0:i.p)==null?void 0:r.drawingsOrder)!=null&&e.length&&((n=(t=i==null?void 0:i.p)==null?void 0:t.drawingsOrder)==null?void 0:n.length)>0)}function qn(i,r){const e=i.getActiveSheet();if(!e)return!1;const t=e.getCellMatrix(),{startRow:n,endRow:s,startColumn:o,endColumn:a}=r;for(let d=n;d<=s;d++)for(let g=o;g<=a;g++){const u=t.getValue(d,g);if(zn(u))return!0}return!1}function Zn(){return"showDirectoryPicker"in window}function ht(i){const r=i.get(l.IUniverInstanceService),e=i.get(C.SheetsSelectionsService),t=O.combineLatest([k.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).pipe(O.switchMap(n=>n?e.selectionMoveEnd$.pipe(O.map(()=>{if(!Zn())return!0;const s=e.getCurrentSelections();if(!s||s.length===0)return!0;for(const o of s)if(qn(n,o.range))return!1;return!0})):O.of(!0)))]).pipe(O.map(([n,s])=>n||s));return{id:ye.id,type:k.MenuItemType.BUTTON,icon:"DownloadImageIcon",title:"sheetImage.save.menuLabel",hidden$:t}}const Jn={[k.RibbonInsertGroup.MEDIA]:{[Rt]:{order:0,menuItemFactory:Vn,[ke.id]:{order:0,menuItemFactory:Xn},[yt.id]:{order:1,menuItemFactory:Kn}}},[k.ContextMenuPosition.MAIN_AREA]:{[k.ContextMenuGroup.OTHERS]:{[ye.id]:{order:10,menuItemFactory:ht}}},[k.ContextMenuPosition.COL_HEADER]:{[k.ContextMenuGroup.OTHERS]:{[ye.id]:{order:10,menuItemFactory:ht}}},[k.ContextMenuPosition.ROW_HEADER]:{[k.ContextMenuGroup.OTHERS]:{[ye.id]:{order:10,menuItemFactory:ht}}}};function xe(i){return!i.getContextValue(l.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(l.EDITOR_ACTIVATED)&&!i.getContextValue(l.FOCUSING_PANEL_EDITOR)&&i.getContextValue(l.FOCUSING_COMMON_DRAWINGS)}const Qn={id:Te.id,description:"shortcut.drawing-move-down",group:"4_drawing-view",binding:k.KeyCode.ARROW_DOWN,priority:100,preconditions:xe,staticParameters:{direction:l.Direction.DOWN}},er={id:Te.id,description:"shortcut.drawing-move-up",group:"4_drawing-view",binding:k.KeyCode.ARROW_UP,priority:100,preconditions:xe,staticParameters:{direction:l.Direction.UP}},tr={id:Te.id,description:"shortcut.drawing-move-left",group:"4_drawing-view",binding:k.KeyCode.ARROW_LEFT,priority:100,preconditions:xe,staticParameters:{direction:l.Direction.LEFT}},nr={id:Te.id,description:"shortcut.drawing-move-right",group:"4_drawing-view",binding:k.KeyCode.ARROW_RIGHT,priority:100,preconditions:xe,staticParameters:{direction:l.Direction.RIGHT}},rr={id:_t.id,description:"shortcut.drawing-delete",group:"4_drawing-view",preconditions:xe,binding:k.KeyCode.DELETE,mac:k.KeyCode.BACKSPACE};var ir=Object.getOwnPropertyDescriptor,sr=(i,r,e,t)=>{for(var n=t>1?void 0:t?ir(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},De=(i,r)=>(e,t)=>r(e,t,i);let at=class extends l.Disposable{constructor(i,r,e,t,n,s){super(),this._componentManager=i,this._menuManagerService=r,this._commandService=e,this._shortcutService=t,this._drawingManagerService=n,this._sheetsSelectionsService=s,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Bt,Hn)),this.disposeWithMe(i.register(Ce,Yn)),this.disposeWithMe(i.register("DownloadImageIcon",Xt))}_initMenus(){this._menuManagerService.mergeMenu(Jn)}_initCommands(){[ke,yt,Ne,Me,je,Mt,X,Tt,It,Ct,Te,_t,Dt,ye].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[Qn,er,tr,nr,rr].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};at=sr([De(0,l.Inject(k.ComponentManager)),De(1,k.IMenuManagerService),De(2,l.ICommandService),De(3,k.IShortcutService),De(4,j.IDrawingManagerService),De(5,l.Inject(C.SheetsSelectionsService))],at);var or=Object.defineProperty,ar=Object.getOwnPropertyDescriptor,cr=(i,r,e)=>r in i?or(i,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[r]=e,dr=(i,r,e,t)=>{for(var n=t>1?void 0:t?ar(r,e):r,s=i.length-1,o;s>=0;s--)(o=i[s])&&(n=o(n)||n);return n},mt=(i,r)=>(e,t)=>r(e,t,i),Kt=(i,r,e)=>cr(i,typeof r!="symbol"?r+"":r,e);const lr="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends l.Plugin{constructor(r=kt,e,t,n){super(),this._config=r,this._injector=e,this._renderManagerService=t,this._configService=n;const{menu:s,...o}=l.merge({},kt,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(dn,o)}onStarting(){l.registerDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService],[at],[et],[ot],[st],[it],[tt],[nt],[rt],[ct,{useClass:exports.BatchSaveImagesService}]]),l.touchDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService]])}onReady(){l.touchDependencies(this._injector,[[it],[rt]])}onRendered(){this._registerRenderModules(),l.touchDependencies(this._injector,[[st],[ot],[at],[tt],[nt]])}onSteady(){this._injector.get(et)}_registerRenderModules(){[[exports.SheetDrawingUpdateController],[vt],[St],[wt]].forEach(r=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,r))})}};Kt(exports.UniverSheetsDrawingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);Kt(exports.UniverSheetsDrawingUIPlugin,"pluginName",lr);exports.UniverSheetsDrawingUIPlugin=dr([l.DependentOn(j.UniverDrawingPlugin,$t.UniverDocsDrawingPlugin,he.UniverDrawingUIPlugin,S.UniverSheetsDrawingPlugin),mt(1,l.Inject(l.Injector)),mt(2,x.IRenderManagerService),mt(3,l.IConfigService)],exports.UniverSheetsDrawingUIPlugin);exports.ClearSheetDrawingTransformerOperation=X;exports.DeleteDrawingsCommand=_t;exports.EditSheetDrawingOperation=Tt;exports.FileNamePart=ge;exports.GroupSheetDrawingCommand=It;exports.IBatchSaveImagesService=ct;exports.InsertFloatImageCommand=ke;exports.InsertSheetDrawingCommand=Ne;exports.MoveDrawingsCommand=Te;exports.RemoveSheetDrawingCommand=Me;exports.SHEETS_IMAGE_MENU_ID=Rt;exports.SHEET_FLOAT_DOM_PREFIX=Yt;exports.SaveCellImagesCommand=ye;exports.SetDrawingArrangeCommand=Dt;exports.SetSheetDrawingCommand=je;exports.SidebarSheetDrawingOperation=Mt;exports.UngroupSheetDrawingCommand=Ct;exports.calcSheetFloatDomPosition=oe;exports.drawingPositionToTransform=Z;exports.transformToDrawingPosition=Y;
|
package/lib/cjs/locale/ca-ES.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={sheetImage:{title:"Imatge",upload:{float:"Imatge flotant",cell:"Imatge de cel·la"},panel:{title:"Edita la imatge"}},"image-popup":{replace:"Reemplaça",delete:"Elimina",edit:"Edita",crop:"Retalla",reset:"Restableix la mida"},"drawing-anchor":{title:"Propietats d’ancoratge",both:"Mou i canvia la mida amb les cel·les",position:"Mou però no canviïs la mida amb les cel·les",none:"No moguis ni canviïs la mida amb les cel·les"},"update-status":{exceedMaxSize:"La mida de la imatge supera el límit, el límit és {0}M",invalidImageType:"Tipus d’imatge no vàlid",exceedMaxCount:"Només es poden pujar {0} imatges alhora",invalidImage:"Imatge no vàlida"},"cell-image":{pasteTitle:"Enganxa com a imatge de cel·la",pasteContent:"Enganxar una imatge de cel·la sobreescriurà el contingut existent de la cel·la, continuar enganxant",pasteError:"La còpia i enganxat d’imatges de cel·la de full no està suportada en aquesta unitat"}};module.exports=e;
|
|
1
|
+
"use strict";const e={sheetImage:{title:"Imatge",upload:{float:"Imatge flotant",cell:"Imatge de cel·la"},panel:{title:"Edita la imatge"},save:{title:"Desa les imatges de cel·la",menuLabel:"Desa les imatges de cel·la",imageCount:"Nombre d'imatges",fileNameConfig:"Nom del fitxer",useRowCol:"Utilitza l'adreça de la cel·la (A1, B2...)",useColumnValue:"Utilitza el valor de la columna",selectColumn:"Selecciona la columna",cancel:"Cancel·la",confirm:"Desa",saving:"Desant...",error:"No s'han pogut desar les imatges de cel·la"}},"image-popup":{replace:"Reemplaça",delete:"Elimina",edit:"Edita",crop:"Retalla",reset:"Restableix la mida"},"drawing-anchor":{title:"Propietats d’ancoratge",both:"Mou i canvia la mida amb les cel·les",position:"Mou però no canviïs la mida amb les cel·les",none:"No moguis ni canviïs la mida amb les cel·les"},"update-status":{exceedMaxSize:"La mida de la imatge supera el límit, el límit és {0}M",invalidImageType:"Tipus d’imatge no vàlid",exceedMaxCount:"Només es poden pujar {0} imatges alhora",invalidImage:"Imatge no vàlida"},"cell-image":{pasteTitle:"Enganxa com a imatge de cel·la",pasteContent:"Enganxar una imatge de cel·la sobreescriurà el contingut existent de la cel·la, continuar enganxant",pasteError:"La còpia i enganxat d’imatges de cel·la de full no està suportada en aquesta unitat"}};module.exports=e;
|
package/lib/cjs/locale/en-US.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={sheetImage:{title:"Image",upload:{float:"Float Image",cell:"Cell Image"},panel:{title:"Edit Image"}},"image-popup":{replace:"Replace",delete:"Delete",edit:"Edit",crop:"Crop",reset:"Reset Size"},"drawing-anchor":{title:"Anchor Properties",both:"Move and size with cells",position:"Move but don't size with cells",none:"Don't move or size with cells"},"update-status":{exceedMaxSize:"Image size exceeds limit, limit is {0}M",invalidImageType:"Invalid image type",exceedMaxCount:"Only {0} images can be uploaded at a time",invalidImage:"Invalid image"},"cell-image":{pasteTitle:"Paste as cell image",pasteContent:"Pasting a cell image will overwrite the existing content of the cell, continue pasting",pasteError:"Sheet cell image copy paste is not supported in this unit"}};module.exports=e;
|
|
1
|
+
"use strict";const e={sheetImage:{title:"Image",upload:{float:"Float Image",cell:"Cell Image"},panel:{title:"Edit Image"},save:{title:"Save Cell Images",menuLabel:"Save Cell Images",imageCount:"Image Count",fileNameConfig:"File Name",useRowCol:"Use Cell Address (A1, B2...)",useColumnValue:"Use Column Value",selectColumn:"Select Column",cancel:"Cancel",confirm:"Save",saving:"Saving...",error:"Failed to save cell images"}},"image-popup":{replace:"Replace",delete:"Delete",edit:"Edit",crop:"Crop",reset:"Reset Size"},"drawing-anchor":{title:"Anchor Properties",both:"Move and size with cells",position:"Move but don't size with cells",none:"Don't move or size with cells"},"update-status":{exceedMaxSize:"Image size exceeds limit, limit is {0}M",invalidImageType:"Invalid image type",exceedMaxCount:"Only {0} images can be uploaded at a time",invalidImage:"Invalid image"},"cell-image":{pasteTitle:"Paste as cell image",pasteContent:"Pasting a cell image will overwrite the existing content of the cell, continue pasting",pasteError:"Sheet cell image copy paste is not supported in this unit"}};module.exports=e;
|
package/lib/cjs/locale/es-ES.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={sheetImage:{title:"Imagen",upload:{float:"Imagen flotante",cell:"Imagen de celda"},panel:{title:"Editar imagen"}},"image-popup":{replace:"Reemplazar",delete:"Eliminar",edit:"Editar",crop:"Recortar",reset:"Restablecer tamaño"},"drawing-anchor":{title:"Propiedades de anclaje",both:"Mover y cambiar tamaño con las celdas",position:"Mover pero no cambiar tamaño con las celdas",none:"No mover ni cambiar tamaño con las celdas"},"update-status":{exceedMaxSize:"El tamaño de la imagen supera el límite, el límite es {0}M",invalidImageType:"Tipo de imagen no válido",exceedMaxCount:"Solo se pueden subir {0} imágenes a la vez",invalidImage:"Imagen no válida"},"cell-image":{pasteTitle:"Pegar como imagen de celda",pasteContent:"Pegar una imagen de celda sobrescribirá el contenido existente de la celda, continuar pegando",pasteError:"La copia y pegado de imágenes de celda de hoja no está soportada en esta unidad"}};module.exports=e;
|
|
1
|
+
"use strict";const e={sheetImage:{title:"Imagen",upload:{float:"Imagen flotante",cell:"Imagen de celda"},panel:{title:"Editar imagen"},save:{title:"Guardar imágenes de celda",menuLabel:"Guardar imágenes de celda",imageCount:"Cantidad de imágenes",fileNameConfig:"Nombre del archivo",useRowCol:"Usar dirección de celda (A1, B2...)",useColumnValue:"Usar valor de columna",selectColumn:"Seleccionar columna",cancel:"Cancelar",confirm:"Guardar",saving:"Guardando...",error:"Error al guardar las imágenes de celda"}},"image-popup":{replace:"Reemplazar",delete:"Eliminar",edit:"Editar",crop:"Recortar",reset:"Restablecer tamaño"},"drawing-anchor":{title:"Propiedades de anclaje",both:"Mover y cambiar tamaño con las celdas",position:"Mover pero no cambiar tamaño con las celdas",none:"No mover ni cambiar tamaño con las celdas"},"update-status":{exceedMaxSize:"El tamaño de la imagen supera el límite, el límite es {0}M",invalidImageType:"Tipo de imagen no válido",exceedMaxCount:"Solo se pueden subir {0} imágenes a la vez",invalidImage:"Imagen no válida"},"cell-image":{pasteTitle:"Pegar como imagen de celda",pasteContent:"Pegar una imagen de celda sobrescribirá el contenido existente de la celda, continuar pegando",pasteError:"La copia y pegado de imágenes de celda de hoja no está soportada en esta unidad"}};module.exports=e;
|
package/lib/cjs/locale/fa-IR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={sheetImage:{title:"تصویر",upload:{float:"شناور کردن تصویر",cell:"تصویر سلولی"},panel:{title:"ویرایش تصویر"}},"image-popup":{replace:"تعویض",delete:"حذف",edit:"ویرایش",crop:"کراپ",reset:"بازنشانی اندازه"},"drawing-anchor":{title:"خواص لنگر",both:"جابهجایی و تغییر اندازه با سلولها",position:"جابهجایی اما تغییر اندازه نکردن با سلولها",none:"جابهجایی یا تغییر اندازه نکردن با سلولها"},"update-status":{exceedMaxSize:"اندازه تصویر از حد مجاز فراتر رفته است، حد مجاز {0}M است",invalidImageType:"نوع تصویر نامعتبر است",exceedMaxCount:"فقط {0} تصویر میتوانند همزمان آپلود شوند",invalidImage:"تصویر نامعتبر است"},"cell-image":{pasteTitle:"چسباندن به عنوان تصویر سلول",pasteContent:"چسباندن تصویر سلول محتوای موجود سلول را پاک خواهد کرد، ادامه چسباندن",pasteError:"کپی و چسباندن تصویر سلول در این واحد پشتیبانی نمیشود"}};module.exports=e;
|
|
1
|
+
"use strict";const e={sheetImage:{title:"تصویر",upload:{float:"شناور کردن تصویر",cell:"تصویر سلولی"},panel:{title:"ویرایش تصویر"},save:{title:"ذخیره تصاویر سلول",menuLabel:"ذخیره تصاویر سلول",imageCount:"تعداد تصاویر",fileNameConfig:"نام فایل",useRowCol:"استفاده از آدرس سلول (A1, B2...)",useColumnValue:"استفاده از مقدار ستون",selectColumn:"انتخاب ستون",cancel:"لغو",confirm:"ذخیره",saving:"در حال ذخیره...",error:"ذخیره تصاویر سلول ناموفق بود"}},"image-popup":{replace:"تعویض",delete:"حذف",edit:"ویرایش",crop:"کراپ",reset:"بازنشانی اندازه"},"drawing-anchor":{title:"خواص لنگر",both:"جابهجایی و تغییر اندازه با سلولها",position:"جابهجایی اما تغییر اندازه نکردن با سلولها",none:"جابهجایی یا تغییر اندازه نکردن با سلولها"},"update-status":{exceedMaxSize:"اندازه تصویر از حد مجاز فراتر رفته است، حد مجاز {0}M است",invalidImageType:"نوع تصویر نامعتبر است",exceedMaxCount:"فقط {0} تصویر میتوانند همزمان آپلود شوند",invalidImage:"تصویر نامعتبر است"},"cell-image":{pasteTitle:"چسباندن به عنوان تصویر سلول",pasteContent:"چسباندن تصویر سلول محتوای موجود سلول را پاک خواهد کرد، ادامه چسباندن",pasteError:"کپی و چسباندن تصویر سلول در این واحد پشتیبانی نمیشود"}};module.exports=e;
|
package/lib/cjs/locale/fr-FR.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={sheetImage:{title:"Image",upload:{float:"Image flottante",cell:"Image de cellule"},panel:{title:"Modifier l'image"}},"image-popup":{replace:"Remplacer",delete:"Supprimer",edit:"Éditer",crop:"Rogner",reset:"Réinitialiser la taille"},"drawing-anchor":{title:"Propriétés de l'ancre",both:"Déplacer et redimensionner avec les cellules",position:"Déplacer mais ne pas redimensionner avec les cellules",none:"Ne pas déplacer ni redimensionner avec les cellules"},"update-status":{exceedMaxSize:"La taille de l'image dépasse la limite, la limite est de {0}M",invalidImageType:"Type d'image invalide",exceedMaxCount:"Seulement {0} images peuvent être téléchargées à la fois",invalidImage:"Image invalide"},"cell-image":{pasteTitle:"Coller comme image de cellule",pasteContent:"Coller une image de cellule écrasera le contenu existant de la cellule, continuer le collage",pasteError:"Le copier-coller d'image de cellule n'est pas pris en charge dans cette unité"}};module.exports=e;
|
|
1
|
+
"use strict";const e={sheetImage:{title:"Image",upload:{float:"Image flottante",cell:"Image de cellule"},panel:{title:"Modifier l'image"},save:{title:"Enregistrer les images de cellule",menuLabel:"Enregistrer les images de cellule",imageCount:"Nombre d'images",fileNameConfig:"Nom du fichier",useRowCol:"Utiliser l'adresse de cellule (A1, B2...)",useColumnValue:"Utiliser la valeur de la colonne",selectColumn:"Sélectionner la colonne",cancel:"Annuler",confirm:"Enregistrer",saving:"Enregistrement...",error:"Échec de l'enregistrement des images de cellule"}},"image-popup":{replace:"Remplacer",delete:"Supprimer",edit:"Éditer",crop:"Rogner",reset:"Réinitialiser la taille"},"drawing-anchor":{title:"Propriétés de l'ancre",both:"Déplacer et redimensionner avec les cellules",position:"Déplacer mais ne pas redimensionner avec les cellules",none:"Ne pas déplacer ni redimensionner avec les cellules"},"update-status":{exceedMaxSize:"La taille de l'image dépasse la limite, la limite est de {0}M",invalidImageType:"Type d'image invalide",exceedMaxCount:"Seulement {0} images peuvent être téléchargées à la fois",invalidImage:"Image invalide"},"cell-image":{pasteTitle:"Coller comme image de cellule",pasteContent:"Coller une image de cellule écrasera le contenu existant de la cellule, continuer le collage",pasteError:"Le copier-coller d'image de cellule n'est pas pris en charge dans cette unité"}};module.exports=e;
|
package/lib/cjs/locale/ja-JP.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e={sheetImage:{title:"画像",upload:{float:"セル上に配置",cell:"セル内に配置"},panel:{title:"画像の編集"}},"image-popup":{replace:"画像の変更",delete:"削除",edit:"編集",crop:"トリミング",reset:"元のサイズに戻す"},"drawing-anchor":{title:"プロパティ",both:"セルに合わせて移動やサイズ変更をする",position:"セルに合わせて移動するがサイズ変更はしない",none:"セルに合わせて移動やサイズ変更をしない"},"update-status":{exceedMaxSize:"画像サイズが制限({0}MB)を超えています",invalidImageType:"サポートされていない画像形式です",exceedMaxCount:"一度にアップロードできるのは {0} 個までです",invalidImage:"無効な画像です"},"cell-image":{pasteTitle:"セル内画像として貼り付け",pasteContent:"セル内画像を貼り付けると、既存のセル内容が上書きされます。続行しますか?",pasteError:"この箇所では、シートのセル内画像のコピー&ペーストはサポートされていません"}};module.exports=e;
|
|
1
|
+
"use strict";const e={sheetImage:{title:"画像",upload:{float:"セル上に配置",cell:"セル内に配置"},panel:{title:"画像の編集"},save:{title:"セル画像を保存",menuLabel:"セル画像を保存",imageCount:"画像数",fileNameConfig:"ファイル名",useRowCol:"セルアドレスを使用 (A1, B2...)",useColumnValue:"列の値を使用",selectColumn:"列を選択",cancel:"キャンセル",confirm:"保存",saving:"保存中...",error:"セル画像の保存に失敗しました"}},"image-popup":{replace:"画像の変更",delete:"削除",edit:"編集",crop:"トリミング",reset:"元のサイズに戻す"},"drawing-anchor":{title:"プロパティ",both:"セルに合わせて移動やサイズ変更をする",position:"セルに合わせて移動するがサイズ変更はしない",none:"セルに合わせて移動やサイズ変更をしない"},"update-status":{exceedMaxSize:"画像サイズが制限({0}MB)を超えています",invalidImageType:"サポートされていない画像形式です",exceedMaxCount:"一度にアップロードできるのは {0} 個までです",invalidImage:"無効な画像です"},"cell-image":{pasteTitle:"セル内画像として貼り付け",pasteContent:"セル内画像を貼り付けると、既存のセル内容が上書きされます。続行しますか?",pasteError:"この箇所では、シートのセル内画像のコピー&ペーストはサポートされていません"}};module.exports=e;
|