@univerjs/sheets-drawing-ui 0.4.2-nightly.202411071606 → 0.4.2-nightly.202411091134

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.
@@ -0,0 +1 @@
1
+ "use strict";const s=require("@univerjs/sheets/facade"),d=require("@univerjs/sheets-drawing-ui"),c=require("@univerjs/sheets-ui/facade"),h=require("@univerjs/ui");class u extends s.FWorksheet{addFloatDomToPosition(t,i){const n=this._workbook.getUnitId(),r=this._worksheet.getSheetId(),{key:a,disposableCollection:o}=c.transformComponentKey(t,this._injector.get(h.ComponentManager)),e=this._injector.get(d.SheetCanvasFloatDomManagerService).addFloatDomToPosition({...t,componentKey:a,unitId:n,subUnitId:r},i);return e?(o.add(e.dispose),{id:e.id,dispose:()=>{o.dispose(),e.dispose()}}):(o.dispose(),null)}}s.FWorksheet.extend(u);
@@ -0,0 +1,9 @@
1
+ "use strict";var Je=Object.defineProperty;var Ze=(i,n,r)=>n in i?Je(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r;var Y=(i,n,r)=>Ze(i,typeof n!="symbol"?n+"":n,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@univerjs/core"),E=require("@univerjs/drawing"),te=require("@univerjs/drawing-ui"),N=require("@univerjs/engine-render"),p=require("@univerjs/sheets-drawing"),U=require("@univerjs/sheets-ui"),G=require("@univerjs/ui"),L=require("rxjs"),D=require("@univerjs/sheets"),H=require("react"),Z=require("@univerjs/design"),Qe="sheets-drawing-ui.config",et={},x={id:"sheet.operation.clear-drawing-transformer",type:m.CommandType.MUTATION,handler:(i,n)=>{const r=i.get(N.IRenderManagerService);return n.forEach(e=>{var t,o;(o=(t=r.getRenderById(e))==null?void 0:t.scene.getTransformer())==null||o.debounceRefreshControls()}),!0}},ie={id:"sheet.command.remove-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{var y,I,T;const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(D.SheetInterceptorService),o=i.get(p.ISheetDrawingService);if(!n)return!1;const{drawings:s}=n,c=[];s.forEach(_=>{const{unitId:M}=_;c.push(M)});const d=o.getBatchRemoveOp(s),{unitId:h,subUnitId:l,undo:a,redo:u,objects:g}=d,f=t.onCommandExecute({id:ie.id,params:n}),w={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:l,op:u,objects:g,type:p.DrawingApplyType.REMOVE}},S={id:p.SetDrawingApplyMutation.id,params:{unitId:h,subUnitId:l,op:a,objects:g,type:p.DrawingApplyType.INSERT}};return m.sequenceExecute([...(y=f.preRedos)!=null?y:[],w,...f.redos],r)?(e.pushUndoRedo({unitID:h,undoMutations:[...(I=f.preUndos)!=null?I:[],S,...f.undos,{id:x.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],w,...f.redos,{id:x.id,params:c}]}),!0):!1}},Be="COMPONENT_SHEET_DRAWING_PANEL",be={id:"sidebar.operation.sheet-image",type:m.CommandType.COMMAND,handler:async(i,n)=>{const r=i.get(G.ISidebarService),e=i.get(m.LocaleService),t=i.get(m.IUniverInstanceService),o=i.get(E.IDrawingManagerService);if(!D.getSheetCommandTarget(t))return!1;switch(n.value){case"open":r.open({header:{title:e.t("sheetImage.panel.title")},children:{label:Be},onClose:()=>{o.focusDrawing(null)},width:360});break;case"close":default:r.close();break}return!0}},Ee={id:"sheet.operation.edit-sheet-image",type:m.CommandType.OPERATION,handler:(i,n)=>{const r=i.get(E.IDrawingManagerService),e=i.get(m.ICommandService);return n==null?!1:(r.focusDrawing([n]),e.executeCommand(be.id,{value:"open"}),!0)}};var $e={exports:{}},ve={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var tt=H,nt=Symbol.for("react.element"),rt=Symbol.for("react.fragment"),it=Object.prototype.hasOwnProperty,ot=tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,st={key:!0,ref:!0,__self:!0,__source:!0};function Ge(i,n,r){var e,t={},o=null,s=null;r!==void 0&&(o=""+r),n.key!==void 0&&(o=""+n.key),n.ref!==void 0&&(s=n.ref);for(e in n)it.call(n,e)&&!st.hasOwnProperty(e)&&(t[e]=n[e]);if(i&&i.defaultProps)for(e in n=i.defaultProps,n)t[e]===void 0&&(t[e]=n[e]);return{$$typeof:nt,type:i,key:o,ref:s,props:t,_owner:ot.current}}ve.Fragment=rt;ve.jsx=Ge;ve.jsxs=Ge;$e.exports=ve;var k=$e.exports;const at="univer-upload-loading",ct="univer-upload-loading-body",dt="univer-upload-loading-body-animation",lt="univer-UniverCircleAnimation",ut="univer-upload-loading-body-text",ce={uploadLoading:at,uploadLoadingBody:ct,uploadLoadingBodyAnimation:dt,univerCircleAnimation:lt,uploadLoadingBodyText:ut},gt=()=>{const i=m.useDependency(E.IImageIoService),n=m.useDependency(m.LocaleService),[r,e]=H.useState(0);return H.useEffect(()=>{const t=i.change$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[i]),k.jsx("div",{style:{display:r>0?"block":"none"},className:ce.uploadLoading,children:k.jsxs("div",{className:ce.uploadLoadingBody,children:[k.jsx("div",{className:ce.uploadLoadingBodyAnimation}),k.jsx("div",{className:ce.uploadLoadingBodyText,children:`${n.t("uploadLoading.loading")}: ${r}`})]})})};var ht=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,pt=(i,n,r,e)=>{for(var t=e>1?void 0:e?mt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ht(n,r,t),t},Q=(i,n)=>(r,e)=>n(r,e,i);let he=class extends m.RxDisposable{constructor(n,r,e,t,o,s,c){super();Y(this,"_initImagePopupMenu",new Set);this._injector=n,this._drawingManagerService=r,this._canvasPopManagerService=e,this._renderManagerService=t,this._univerInstanceService=o,this._contextService=s,this._uiPartsService=c,this._init()}_init(){this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.takeUntil(this.dispose$)).subscribe(n=>this._create(n)),this._univerInstanceService.getTypeOfUnitDisposed$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.takeUntil(this.dispose$)).subscribe(n=>this._dispose(n)),this._univerInstanceService.getAllUnitsForType(m.UniverInstanceType.UNIVER_SHEET).forEach(n=>this._create(n)),this._uiPartsService.registerComponent(G.BuiltInUIPart.CONTENT,()=>m.connectInjector(gt,this._injector))}_dispose(n){const r=n.getUnitId();this._renderManagerService.removeRender(r)}_create(n){if(!n)return;const r=n.getUnitId();this._renderManagerService.has(r)&&!this._initImagePopupMenu.has(r)&&(this._popupMenuListener(r),this._initImagePopupMenu.add(r))}_hasCropObject(n){const r=n.getAllObjectsByOrder();for(const e of r)if(e instanceof te.ImageCropperObject)return!0;return!1}_popupMenuListener(n){var o;const r=(o=this._renderManagerService.getRenderById(n))==null?void 0:o.scene;if(!r)return;const e=r.getTransformerByCreate();if(!e)return;let t;this.disposeWithMe(m.toDisposable(e.createControl$.subscribe(()=>{if(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._hasCropObject(r))return;const s=e.getSelectedObjectMap();if(s.size>1){t==null||t.dispose();return}const c=s.values().next().value;if(!c)return;const d=c.oKey,h=this._drawingManagerService.getDrawingOKey(d);if(!h)return;const{unitId:l,subUnitId:a,drawingId:u,drawingType:g}=h,f=h.data;f&&f.disablePopup||(t==null||t.dispose(),t=this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(c,{componentKey:te.COMPONENT_IMAGE_POPUP_MENU,direction:"horizontal",offset:[2,0],extraProps:{menuItems:this._getImageMenuItems(l,a,u,g)}})),this._drawingManagerService.focusDrawing([{unitId:l,subUnitId:a,drawingId:u}]))}))),this.disposeWithMe(e.clearControl$.subscribe(()=>{t==null||t.dispose(),this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!1),this._drawingManagerService.focusDrawing(null)})),this.disposeWithMe(e.changing$.subscribe(()=>{t==null||t.dispose()}))}_getImageMenuItems(n,r,e,t){return[{label:"image-popup.edit",index:0,commandId:Ee.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===E.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.delete",index:1,commandId:ie.id,commandParams:{unitId:n,drawings:[{unitId:n,subUnitId:r,drawingId:e}]},disable:!1},{label:"image-popup.crop",index:2,commandId:te.OpenImageCropOperation.id,commandParams:{unitId:n,subUnitId:r,drawingId:e},disable:t===E.DrawingTypeEnum.DRAWING_DOM},{label:"image-popup.reset",index:3,commandId:te.ImageResetSizeOperation.id,commandParams:[{unitId:n,subUnitId:r,drawingId:e}],disable:t===E.DrawingTypeEnum.DRAWING_DOM}]}};he=pt([Q(0,m.Inject(m.Injector)),Q(1,E.IDrawingManagerService),Q(2,m.Inject(U.SheetCanvasPopManagerService)),Q(3,N.IRenderManagerService),Q(4,m.IUniverInstanceService),Q(5,m.IContextService),Q(6,m.Inject(G.IUIPartsService))],he);function V(i,n,r){const{from:e,to:t,flipY:o=!1,flipX:s=!1,angle:c=0,skewX:d=0,skewY:h=0}=i,{column:l,columnOffset:a,row:u,rowOffset:g}=e,{column:f,columnOffset:w,row:S,rowOffset:C}=t,y=r.getCurrentSkeleton(),I=U.attachRangeWithCoord(y,{startColumn:l,endColumn:l,startRow:u,endRow:u});if(I==null)return;const T=U.attachRangeWithCoord(y,{startColumn:f,endColumn:f,startRow:S,endRow:S});if(T==null)return;const{startX:_,startY:M}=I,{startX:v,startY:P}=T;let b=N.precisionTo(_+a,1),j=N.precisionTo(M+g,1),A=N.precisionTo(v+w-b,1),O=N.precisionTo(P+C-j,1);I.startX===T.endX&&(A=0),I.startY===T.endY&&(O=0);const R=y.rowHeaderWidth+y.columnTotalWidth,W=y.columnHeaderHeight+y.rowTotalHeight;return b+A>R&&(b=R-A),j+O>W&&(j=W-O),{flipY:o,flipX:s,angle:c,skewX:d,skewY:h,left:b,top:j,width:A,height:O}}function $(i,n){const{left:r=0,top:e=0,width:t=0,height:o=0,flipY:s=!1,flipX:c=!1,angle:d=0,skewX:h=0,skewY:l=0}=i,a=n.getSelectionCellByPosition(r,e);if(a==null)return;const u={column:a.actualColumn,columnOffset:N.precisionTo(r-a.startX,1),row:a.actualRow,rowOffset:N.precisionTo(e-a.startY,1)},g=n.getSelectionCellByPosition(r+t,e+o);if(g==null)return;const f={column:g.actualColumn,columnOffset:N.precisionTo(r+t-g.startX,1),row:g.actualRow,rowOffset:N.precisionTo(e+o-g.startY,1)};return{flipY:s,flipX:c,angle:d,skewX:h,skewY:l,from:u,to:f}}var ft=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,St=(i,n,r,e)=>{for(var t=e>1?void 0:e?wt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ft(n,r,t),t},de=(i,n)=>(r,e)=>n(r,e,i);let Re=class extends m.Disposable{constructor(i,n,r,e,t){super(),this._context=i,this._sheetDrawingService=n,this._drawingManagerService=r,this._sheetSelectionRenderService=e,this._sheetSkeletonManagerService=t,this._init()}_init(){this._drawingInitializeListener()}_drawingInitializeListener(){this._sheetDrawingService.initializeNotification(this._context.unitId);const i=this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);for(const n in i){const r=i[n];for(const e in r.data){const t=r.data[e];t.transform=V(t.sheetTransform,this._sheetSelectionRenderService,this._sheetSkeletonManagerService)}}this._drawingManagerService.registerDrawingData(this._context.unitId,this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)),this._drawingManagerService.initializeNotification(this._context.unitId)}};Re=St([de(1,p.ISheetDrawingService),de(2,E.IDrawingManagerService),de(3,m.Inject(U.ISheetSelectionRenderService)),de(4,m.Inject(U.SheetSkeletonManagerService))],Re);var X=function(){return X=Object.assign||function(i){for(var n,r=1,e=arguments.length;r<e;r++){n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(i[t]=n[t])}return i},X.apply(this,arguments)},vt=function(i,n){var r={};for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&n.indexOf(e)<0&&(r[e]=i[e]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var t=0,e=Object.getOwnPropertySymbols(i);t<e.length;t++)n.indexOf(e[t])<0&&Object.prototype.propertyIsEnumerable.call(i,e[t])&&(r[e[t]]=i[e[t]]);return r},ke=H.forwardRef(function(i,n){var r=i.icon,e=i.id,t=i.className,o=i.extend,s=vt(i,["icon","id","className","extend"]),c="univerjs-icon univerjs-icon-".concat(e," ").concat(t||"").trim(),d=H.useRef("_".concat(It()));return Ve(r,"".concat(e),{defIds:r.defIds,idSuffix:d.current},X({ref:n,className:c},s),o)});function Ve(i,n,r,e,t){return H.createElement(i.tag,X(X({key:n},_t(i,r,t)),e),(Dt(i,r).children||[]).map(function(o,s){return Ve(o,"".concat(n,"-").concat(i.tag,"-").concat(s),r,void 0,t)}))}function _t(i,n,r){var e=X({},i.attrs);r!=null&&r.colorChannel1&&e.fill==="colorChannel1"&&(e.fill=r.colorChannel1);var t=n.defIds;return!t||t.length===0||(i.tag==="use"&&e["xlink:href"]&&(e["xlink:href"]=e["xlink:href"]+n.idSuffix),Object.entries(e).forEach(function(o){var s=o[0],c=o[1];typeof c=="string"&&(e[s]=c.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),e}function Dt(i,n){var r,e=n.defIds;return!e||e.length===0?i:i.tag==="defs"&&(!((r=i.children)===null||r===void 0)&&r.length)?X(X({},i),{children:i.children.map(function(t){return typeof t.attrs.id=="string"&&e&&e.indexOf(t.attrs.id)>-1?X(X({},t),{attrs:X(X({},t.attrs),{id:t.attrs.id+n.idSuffix})}):t})}):i}function It(){return Math.random().toString(36).substring(2,8)}ke.displayName="UniverIcon";var Ct={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.2498 3.65005C2.2498 2.87685 2.87661 2.25005 3.64981 2.25005H7.9998C8.33118 2.25005 8.5998 1.98142 8.5998 1.65005C8.5998 1.31868 8.33118 1.05005 7.9998 1.05005H3.64981C2.21387 1.05005 1.0498 2.21411 1.0498 3.65005V12.35C1.0498 13.786 2.21386 14.95 3.6498 14.95H12.3498C13.7857 14.95 14.9498 13.786 14.9498 12.3501V8.00005C14.9498 7.66868 14.6812 7.40005 14.3498 7.40005C14.0184 7.40005 13.7498 7.66868 13.7498 8.00005V9.23974L12.2385 8.1063C11.7252 7.72129 11.0068 7.7723 10.5531 8.22605L9.00869 9.77041L6.73916 7.8251C6.24387 7.40055 5.5095 7.41278 5.02864 7.85359L2.2498 10.4009V3.65005ZM2.2498 12.0287V12.35C2.2498 13.1232 2.87661 13.75 3.6498 13.75H12.3498C13.123 13.75 13.7498 13.1232 13.7498 12.3501V10.7397L11.5186 9.06631C11.4829 9.03956 11.433 9.04314 11.4016 9.07458L9.92249 10.5537L11.1015 11.5642C11.3531 11.7799 11.3822 12.1587 11.1666 12.4103C10.9509 12.6619 10.5721 12.691 10.3205 12.4753L5.9582 8.7362C5.92384 8.70674 5.87288 8.70758 5.83952 8.73816L2.2498 12.0287Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M11.8097 1.14783C12.1411 1.14783 12.4097 1.41646 12.4097 1.74783V3.297H14.1541C14.4855 3.297 14.7541 3.56563 14.7541 3.897C14.7541 4.22837 14.4855 4.497 14.1541 4.497H12.4097V6.24167C12.4097 6.57304 12.1411 6.84167 11.8097 6.84167C11.4783 6.84167 11.2097 6.57304 11.2097 6.24167V4.497H9.6603C9.32893 4.497 9.0603 4.22837 9.0603 3.897C9.0603 3.56563 9.32893 3.297 9.6603 3.297H11.2097V1.74783C11.2097 1.41646 11.4783 1.14783 11.8097 1.14783Z"}}]},Fe=H.forwardRef(function(i,n){return H.createElement(ke,Object.assign({},i,{id:"add-image-single",ref:n,icon:Ct}))});Fe.displayName="AddImageSingle";const Oe={id:"sheet.command.delete-drawing",type:m.CommandType.COMMAND,handler:i=>{const n=i.get(m.ICommandService),e=i.get(p.ISheetDrawingService).getFocusDrawings();if(e.length===0)return!1;const t=e[0].unitId,o=e.map(s=>{const{unitId:c,subUnitId:d,drawingId:h,drawingType:l}=s;return{unitId:c,subUnitId:d,drawingId:h,drawingType:l}});return n.executeCommand(ie.id,{unitId:t,drawings:o})}};function yt(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:s,drawingId:c}=e,d=N.getGroupState(0,0,t.map(a=>a.transform||{})),h=t.map(a=>{const u=a.transform||{left:0,top:0},{unitId:g,subUnitId:f,drawingId:w}=a;return{unitId:g,subUnitId:f,drawingId:w,transform:{...u,left:u.left-d.left,top:u.top-d.top},groupId:c}}),l={unitId:o,subUnitId:s,drawingId:c,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:d};n.push({parent:l,children:h})}),n}function Mt(i){const n=[];return i.forEach(r=>{const{parent:e,children:t}=r,{unitId:o,subUnitId:s,drawingId:c,transform:d={width:0,height:0}}=e;if(d==null)return;const h=t.map(a=>{const{transform:u}=a,{unitId:g,subUnitId:f,drawingId:w}=a,S=N.transformObjectOutOfGroup(u||{},d,d.width||0,d.height||0);return{unitId:g,subUnitId:f,drawingId:w,transform:S,groupId:void 0}}),l={unitId:o,subUnitId:s,drawingId:c,drawingType:E.DrawingTypeEnum.DRAWING_GROUP,transform:{left:0,top:0}};n.push({parent:l,children:h})}),n}const Pe={id:"sheet.command.group-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(w=>{o.push(w.unitId)})});const s=t.getGroupDrawingOp(n),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.GROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:d,objects:Mt(a),type:p.DrawingApplyType.UNGROUP}},{id:x.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.GROUP}},{id:x.id,params:o}]}),!0):!1}},oe={id:"sheet.command.insert-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{var y,I,T;const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService),o=i.get(D.SheetInterceptorService);if(!n)return!1;const s=n.drawings,c=s.map(_=>_.unitId),d=t.getBatchAddOp(s),{unitId:h,subUnitId:l,undo:a,redo:u,objects:g}=d,f=o.onCommandExecute({id:oe.id,params:n}),w={id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:h,subUnitId:l,objects:g,type:p.DrawingApplyType.INSERT}},S={id:p.SetDrawingApplyMutation.id,params:{op:a,unitId:h,subUnitId:l,objects:g,type:p.DrawingApplyType.REMOVE}};return m.sequenceExecute([...(y=f.preRedos)!=null?y:[],w,...f.redos],r)?(e.pushUndoRedo({unitID:h,undoMutations:[...(I=f.preUndos)!=null?I:[],S,...f.undos,{id:x.id,params:c}],redoMutations:[...(T=f.preRedos)!=null?T:[],w,...f.redos,{id:x.id,params:c}]}),!0):!1}},Ae={id:"sheet.command.set-drawing-arrange",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService);if(!n)return!1;const t=i.get(p.ISheetDrawingService),{unitId:o,subUnitId:s,drawingIds:c,arrangeType:d}=n,h={unitId:o,subUnitId:s,drawingIds:c};let l;if(d===E.ArrangeTypeEnum.forward?l=t.getForwardDrawingsOp(h):d===E.ArrangeTypeEnum.backward?l=t.getBackwardDrawingOp(h):d===E.ArrangeTypeEnum.front?l=t.getFrontDrawingsOp(h):d===E.ArrangeTypeEnum.back&&(l=t.getBackDrawingsOp(h)),l==null)return!1;const{objects:a,redo:u,undo:g}=l;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:u,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE})?(e.pushUndoRedo({unitID:o,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:g,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE}}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:u,unitId:o,subUnitId:s,objects:a,type:p.DrawingApplyType.ARRANGE}}]}),!0):!1}},se={id:"sheet.command.set-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const{drawings:o}=n,s=t.getBatchUpdateOp(o),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:c,subUnitId:d,op:l,objects:a,type:p.DrawingApplyType.UPDATE})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:h,objects:a,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[c]}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{unitId:c,subUnitId:d,op:l,objects:a,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[c]}]}),!0):!1}},Ue={id:"sheet.command.ungroup-sheet-image",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(m.IUndoRedoService),t=i.get(p.ISheetDrawingService);if(!n)return!1;const o=[];n.forEach(({parent:g,children:f})=>{o.push(g.unitId),f.forEach(w=>{o.push(w.unitId)})});const s=t.getUngroupDrawingOp(n),{unitId:c,subUnitId:d,undo:h,redo:l,objects:a}=s;return r.syncExecuteCommand(p.SetDrawingApplyMutation.id,{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.UNGROUP})?(e.pushUndoRedo({unitID:c,undoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:h,unitId:c,subUnitId:d,objects:yt(a),type:p.DrawingApplyType.GROUP}},{id:x.id,params:o}],redoMutations:[{id:p.SetDrawingApplyMutation.id,params:{op:l,unitId:c,subUnitId:d,objects:a,type:p.DrawingApplyType.UNGROUP}},{id:x.id,params:o}]}),!0):!1}};var Rt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,bt=(i,n,r,e)=>{for(var t=e>1?void 0:e?Tt(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Rt(n,r,t),t},K=(i,n)=>(r,e)=>n(r,e,i);let me=class extends m.Disposable{constructor(n,r,e,t,o,s,c,d,h,l,a,u){super();Y(this,"_workbookSelections");this._context=n,this._skeletonManagerService=r,this._commandService=e,this._selectionRenderService=t,this._imageIoService=o,this._fileOpenerService=s,this._sheetDrawingService=c,this._drawingManagerService=d,this._contextService=h,this._messageService=l,this._localeService=a,this._workbookSelections=u.getWorkbookSelections(this._context.unitId),this._updateImageListener(),this._updateOrderListener(),this._groupDrawingListener(),this._focusDrawingListener()}async insertFloatImage(){const n=await this._fileOpenerService.openFile({multiple:!0,accept:E.DRAWING_IMAGE_ALLOW_IMAGE_LIST.map(e=>`.${e.replace("image/","")}`).join(",")}),r=n.length;return r>E.DRAWING_IMAGE_COUNT_LIMIT?(this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxCount",String(E.DRAWING_IMAGE_COUNT_LIMIT))}),!1):r===0?!1:(n.forEach(async e=>await this._insertFloatImage(e)),!0)}async _insertFloatImage(n){let r;try{r=await this._imageIoService.saveImage(n)}catch(y){const I=y.message;I===E.ImageUploadStatusType.ERROR_EXCEED_SIZE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.exceedMaxSize",String(E.DRAWING_IMAGE_ALLOW_SIZE/(1024*1024)))}):I===E.ImageUploadStatusType.ERROR_IMAGE_TYPE?this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImageType")}):I===E.ImageUploadStatusType.ERROR_IMAGE&&this._messageService.show({type:Z.MessageType.Error,content:this._localeService.t("update-status.invalidImage")})}if(r==null)return;const e=this._getUnitInfo(),{unitId:t,subUnitId:o}=e,{imageId:s,imageSourceType:c,source:d,base64Cache:h}=r,{width:l,height:a,image:u}=await E.getImageSize(h||""),{width:g,height:f}=this._context.scene;this._imageIoService.addImageSourceCache(d,c,u);let w=1;if(l>E.DRAWING_IMAGE_WIDTH_LIMIT||a>E.DRAWING_IMAGE_HEIGHT_LIMIT){const y=E.DRAWING_IMAGE_WIDTH_LIMIT/l,I=E.DRAWING_IMAGE_HEIGHT_LIMIT/a;w=Math.max(y,I)}const S=this._getImagePosition(l*w,a*w,g,f);if(S==null)return;const C={unitId:t,subUnitId:o,drawingId:s,drawingType:E.DrawingTypeEnum.DRAWING_IMAGE,imageSourceType:c,source:d,transform:V(S,this._selectionRenderService,this._skeletonManagerService),sheetTransform:S};this._commandService.executeCommand(oe.id,{unitId:t,drawings:[C]})}_getUnitInfo(){const n=this._context.unit,r=n.getActiveSheet(),e=n.getUnitId(),t=r.getSheetId();return{unitId:e,subUnitId:t}}_getImagePosition(n,r,e,t){const o=this._workbookSelections.getCurrentSelections();let s={startRow:0,endRow:0,startColumn:0,endColumn:0};o&&o.length>0&&(s=o[o.length-1].range);const c=U.attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton,s);if(c==null)return;let{startColumn:d,startRow:h,startX:l,startY:a}=c,u=!1;if(l+n>e&&(l=e-n,l<0&&(l=0,n=e),u=!0),a+r>t&&(a=t-r,a<0&&(a=0,r=t),u=!0),u){const S=this._selectionRenderService.getSelectionCellByPosition(l,a);if(S==null)return;l=S.startX,a=S.startY,d=S.actualColumn,h=S.actualRow}const g={column:d,columnOffset:0,row:h,rowOffset:0},f=this._selectionRenderService.getSelectionCellByPosition(l+n,a+r);if(f==null)return;const w={column:f.actualColumn,columnOffset:l+n-f.startX,row:f.actualRow,rowOffset:a+r-f.startY};return{from:g,to:w}}_updateOrderListener(){this._drawingManagerService.featurePluginOrderUpdate$.subscribe(n=>{const{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o}=n;this._commandService.executeCommand(Ae.id,{unitId:r,subUnitId:e,drawingIds:t,arrangeType:o})})}_updateImageListener(){this._drawingManagerService.featurePluginUpdate$.subscribe(n=>{const r=[];n.length!==0&&(n.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:s,drawingType:c,transform:d}=e;if(d==null)return;const h=this._sheetDrawingService.getDrawingByParam({unitId:t,subUnitId:o,drawingId:s});if(h==null||h.unitId!==this._context.unitId)return;const l=$({...h.transform,...d},this._selectionRenderService);if(l==null)return;const a={...e,transform:{...h.transform,...d,...V(l,this._selectionRenderService,this._skeletonManagerService)},sheetTransform:{...l}};r.push(a)}),r.length>0&&this._commandService.executeCommand(se.id,{unitId:n[0].unitId,drawings:r}))})}_groupDrawingListener(){this._drawingManagerService.featurePluginGroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Pe.id,n);const{unitId:r,subUnitId:e,drawingId:t}=n[0].parent;this._drawingManagerService.focusDrawing([{unitId:r,subUnitId:e,drawingId:t}])}),this._drawingManagerService.featurePluginUngroupUpdate$.subscribe(n=>{this._commandService.executeCommand(Ue.id,n)})}_focusDrawingListener(){this.disposeWithMe(this._drawingManagerService.focus$.subscribe(n=>{n==null||n.length===0?(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!1),this._sheetDrawingService.focusDrawing([])):(this._contextService.setContextValue(m.FOCUSING_COMMON_DRAWINGS,!0),this._sheetDrawingService.focusDrawing(n))}))}};me=bt([K(1,m.Inject(U.SheetSkeletonManagerService)),K(2,m.ICommandService),K(3,U.ISheetSelectionRenderService),K(4,E.IImageIoService),K(5,G.ILocalFileService),K(6,p.ISheetDrawingService),K(7,E.IDrawingManagerService),K(8,m.IContextService),K(9,G.IMessageService),K(10,m.Inject(m.LocaleService)),K(11,m.Inject(D.SheetsSelectionsService))],me);const _e={id:"sheet.command.insert-float-image",type:m.CommandType.COMMAND,handler:i=>{var r,e;return(e=(r=i.get(N.IRenderManagerService).getCurrentTypeOfRenderer(m.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.with(me).insertFloatImage())!=null?e:!1}},ne={id:"sheet.command.move-drawing",type:m.CommandType.COMMAND,handler:(i,n)=>{const r=i.get(m.ICommandService),e=i.get(p.ISheetDrawingService),t=i.get(U.ISheetSelectionRenderService),{direction:o}=n,s=e.getFocusDrawings();if(s.length===0)return!1;const c=s[0].unitId,d=s.map(l=>{const{transform:a}=l;if(a==null)return null;const u={...a},{left:g=0,top:f=0}=a;return o===m.Direction.UP?u.top=f-1:o===m.Direction.DOWN?u.top=f+1:o===m.Direction.LEFT?u.left=g-1:o===m.Direction.RIGHT&&(u.left=g+1),{...l,transform:u,sheetTransform:$(u,t)}}).filter(l=>l!=null);return r.syncExecuteCommand(se.id,{unitId:c,drawings:d})?(r.syncExecuteCommand(x.id,[c]),!0):!1}},Ye="addition-and-subtraction-single",Ne="sheet.menu.image";function Et(i){return{id:Ne,type:G.MenuItemType.SUBITEMS,icon:Ye,tooltip:"sheetImage.title",hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET),disabled$:U.getCurrentRangeDisable$(i,{workbookTypes:[D.WorkbookEditablePermission],worksheetTypes:[D.WorksheetEditPermission],rangeTypes:[D.RangeProtectionPermissionEditPoint]})}}function Ot(i){return{id:_e.id,title:"sheetImage.upload.float",type:G.MenuItemType.BUTTON,hidden$:G.getMenuHiddenObservable(i,m.UniverInstanceType.UNIVER_SHEET)}}const Pt="univer-image-common-panel",At="univer-image-common-panel-grid",Ut="univer-image-common-panel-border",Nt="univer-image-common-panel-title",jt="univer-image-common-panel-subtitle",Wt="univer-image-common-panel-row",Lt="univer-image-common-panel-row-vertical",xt="univer-image-common-panel-column",Bt="univer-image-common-panel-column-center",$t="univer-image-common-panel-inline",Gt="univer-image-common-panel-span2",kt="univer-image-common-panel-span3",Vt="univer-image-common-panel-input",Ft="univer-sheet-image-menu",Yt="univer-sheet-image-menu-input",J={imageCommonPanel:Pt,imageCommonPanelGrid:At,imageCommonPanelBorder:Ut,imageCommonPanelTitle:Nt,imageCommonPanelSubtitle:jt,imageCommonPanelRow:Wt,imageCommonPanelRowVertical:Lt,imageCommonPanelColumn:xt,imageCommonPanelColumnCenter:Bt,imageCommonPanelInline:$t,imageCommonPanelSpan2:Gt,imageCommonPanelSpan3:kt,imageCommonPanelInput:Vt,sheetImageMenu:Ft,sheetImageMenuInput:Yt};function He(i){var n,r,e="";if(typeof i=="string"||typeof i=="number")e+=i;else if(typeof i=="object")if(Array.isArray(i)){var t=i.length;for(n=0;n<t;n++)i[n]&&(r=He(i[n]))&&(e&&(e+=" "),e+=r)}else for(r in i)i[r]&&(e&&(e+=" "),e+=r);return e}function le(){for(var i,n,r=0,e="",t=arguments.length;r<t;r++)(i=arguments[r])&&(n=He(i))&&(e&&(e+=" "),e+=n);return e}const Ht=i=>{var I;const n=m.useDependency(m.ICommandService),r=m.useDependency(m.LocaleService),e=m.useDependency(E.IDrawingManagerService),t=m.useDependency(N.IRenderManagerService),{drawings:o}=i,s=o[0];if(s==null)return;const{unitId:c}=s,d=t.getRenderById(c),h=d==null?void 0:d.scene;if(h==null)return;const l=h.getTransformerByCreate(),[a,u]=H.useState(!0),g=(I=s.anchorType)!=null?I:p.SheetDrawingAnchorType.Position,[f,w]=H.useState(g);function S(T,_){const M=[];return T.forEach(v=>{const{oKey:P}=v,b=_.getDrawingOKey(P);if(b==null)return M.push(null),!0;const{unitId:j,subUnitId:A,drawingId:O,drawingType:R,anchorType:W,sheetTransform:B}=b;M.push({unitId:j,subUnitId:A,drawingId:O,anchorType:W,sheetTransform:B,drawingType:R})}),M}H.useEffect(()=>{const T=l.clearControl$.subscribe(M=>{M===!0&&u(!1)}),_=l.changeStart$.subscribe(M=>{var b;const{objects:v}=M,P=S(v,e);if(P.length===0)u(!1);else if(P.length>=1){u(!0);const j=((b=P[0])==null?void 0:b.anchorType)||p.SheetDrawingAnchorType.Position;w(j)}});return()=>{_.unsubscribe(),T.unsubscribe()}},[]);function C(T){w(T);const _=e.getFocusDrawings();if(_.length===0)return;const M=_.map(v=>({unitId:v.unitId,subUnitId:v.subUnitId,drawingId:v.drawingId,anchorType:T}));n.executeCommand(se.id,{unitId:_[0].unitId,drawings:M})}const y=T=>T?"block":"none";return k.jsxs("div",{className:le(J.imageCommonPanelGrid,J.imageCommonPanelBorder),style:{display:y(a)},children:[k.jsx("div",{className:J.imageCommonPanelRow,children:k.jsx("div",{className:le(J.imageCommonPanelColumn,J.imageCommonPanelTitle),children:k.jsx("div",{children:r.t("drawing-anchor.title")})})}),k.jsx("div",{className:le(J.imageCommonPanelRow),children:k.jsx("div",{className:le(J.imageCommonPanelColumn),children:k.jsxs(Z.RadioGroup,{value:f,onChange:C,direction:"vertical",children:[k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.Both,children:r.t("drawing-anchor.both")}),k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.Position,children:r.t("drawing-anchor.position")}),k.jsx(Z.Radio,{value:p.SheetDrawingAnchorType.None,children:r.t("drawing-anchor.none")})]})})})]})},Xt=()=>{const i=m.useDependency(E.IDrawingManagerService),n=i.getFocusDrawings(),[r,e]=H.useState(n);return H.useEffect(()=>{const t=i.focus$.subscribe(o=>{e(o)});return()=>{t.unsubscribe()}},[]),!!(r!=null&&r.length)&&k.jsxs("div",{className:J.imageCommonPanel,children:[k.jsx(te.DrawingCommonPanel,{drawings:r}),k.jsx(Ht,{drawings:r})]})},Kt={[G.RibbonStartGroup.FORMULAS_INSERT]:{[Ne]:{order:3,menuItemFactory:Et,[_e.id]:{order:0,menuItemFactory:Ot}}}};function ae(i){return!i.getContextValue(m.FOCUSING_FX_BAR_EDITOR)&&!i.getContextValue(m.EDITOR_ACTIVATED)&&!i.getContextValue(m.FOCUSING_PANEL_EDITOR)&&i.getContextValue(m.FOCUSING_COMMON_DRAWINGS)}const zt={id:ne.id,description:"shortcut.sheet.drawing-move-down",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_DOWN,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.DOWN}},qt={id:ne.id,description:"shortcut.sheet.drawing-move-up",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_UP,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.UP}},Jt={id:ne.id,description:"shortcut.sheet.drawing-move-left",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_LEFT,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.LEFT}},Zt={id:ne.id,description:"shortcut.sheet.drawing-move-right",group:"4_sheet-drawing-view",binding:G.KeyCode.ARROW_RIGHT,priority:100,preconditions:ae,staticParameters:{direction:m.Direction.RIGHT}},Qt={id:Oe.id,description:"shortcut.sheet.drawing-delete",group:"4_sheet-drawing-view",preconditions:ae,binding:G.KeyCode.DELETE,mac:G.KeyCode.BACKSPACE};var en=Object.defineProperty,tn=Object.getOwnPropertyDescriptor,nn=(i,n,r,e)=>{for(var t=e>1?void 0:e?tn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&en(n,r,t),t},ue=(i,n)=>(r,e)=>n(r,e,i);let pe=class extends m.Disposable{constructor(i,n,r,e){super(),this._componentManager=i,this._menuManagerService=n,this._commandService=r,this._shortcutService=e,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(Ye,Fe)),this.disposeWithMe(i.register(Be,Xt))}_initMenus(){this._menuManagerService.mergeMenu(Kt)}_initCommands(){[_e,oe,ie,se,be,x,Ee,Pe,Ue,ne,Oe,Ae].forEach(i=>this.disposeWithMe(this._commandService.registerCommand(i)))}_initShortcuts(){[zt,qt,Jt,Zt,Qt].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_init(){this._initCommands(),this._initCustomComponents(),this._initMenus(),this._initShortcuts()}};pe=nn([ue(0,m.Inject(G.ComponentManager)),ue(1,G.IMenuManagerService),ue(2,m.ICommandService),ue(3,G.IShortcutService)],pe);var rn=Object.defineProperty,on=Object.getOwnPropertyDescriptor,sn=(i,n,r,e)=>{for(var t=e>1?void 0:e?on(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&rn(n,r,t),t},Ce=(i,n)=>(r,e)=>n(r,e,i);let fe=class extends m.Disposable{constructor(n,r,e){super();Y(this,"_copyInfo");this._sheetClipboardService=n,this._renderManagerService=r,this._sheetDrawingService=e,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:"SHEET_IMAGE_UI_PLUGIN",onBeforeCopy:(n,r,e)=>this._collect(n,r,e),onPasteCells:(n,r,e,t)=>{const{copyType:o=U.COPY_TYPE.COPY,pasteType:s}=t,{range:c}=n||{},{range:d,unitId:h,subUnitId:l}=r;return this._generateMutations(d,{copyType:o,pasteType:s,copyRange:c,unitId:h,subUnitId:l})},onPastePlainText:(n,r)=>({undos:[],redos:[]})})}_collect(n,r,e){var u;const t=(u=this._renderManagerService.getRenderById(n))==null?void 0:u.with(U.SheetSkeletonManagerService);if(!t)return;const o=t.attachRangeWithCoord(e);if(!o)return;const{startX:s,endX:c,startY:d,endY:h}=o,l=this._sheetDrawingService.getDrawingData(n,r),a=[];Object.keys(l).forEach(g=>{const f=l[g],{transform:w}=f;if(f.anchorType!==p.SheetDrawingAnchorType.Both||!w)return;const{left:S=0,top:C=0,width:y=0,height:I=0}=w,{drawingStartX:T,drawingEndX:_,drawingStartY:M,drawingEndY:v}={drawingStartX:S,drawingEndX:S+y,drawingStartY:C,drawingEndY:C+I};s<=T&&_<=c&&d<=M&&v<=h&&a.push(f)}),a.length&&(this._copyInfo={drawings:a,unitId:n,subUnitId:r})}_generateMutations(n,r){var b;if(!this._copyInfo)return{redos:[],undos:[]};if([U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,U.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(r.pasteType))return{redos:[],undos:[]};const{copyRange:e}=r;if(!e)return{redos:[],undos:[]};const{drawings:t,unitId:o,subUnitId:s}=this._copyInfo,{ranges:[c,d],mapFunc:h}=U.virtualizeDiscreteRanges([e,n]),{row:l,col:a}=h(c.startRow,c.startColumn),{row:u,col:g}=h(d.startRow,d.startColumn),f=(b=this._renderManagerService.getRenderById(o))==null?void 0:b.with(U.SheetSkeletonManagerService);if(!f)return{redos:[],undos:[]};const w=f.attachRangeWithCoord({startRow:l,endRow:l,startColumn:a,endColumn:a}),S=f.attachRangeWithCoord({startRow:u,endRow:u,startColumn:g,endColumn:g});if(!w||!S)return{redos:[],undos:[]};const C=[],y=[],I=S.startX-w.startX,T=S.startY-w.startY,_=u-l,M=g-a,v=r.copyType===U.COPY_TYPE.CUT,{_sheetDrawingService:P}=this;return t.forEach(j=>{const{transform:A,sheetTransform:O}=j;if(!A)return;const R={...j,unitId:o,subUnitId:s,drawingId:v?j.drawingId:m.Tools.generateRandomId(),transform:{...A,left:A.left+I,top:A.top+T},sheetTransform:{to:{...O.to,row:O.to.row+_,column:O.to.column+M},from:{...O.from,row:O.from.row+_,column:O.from.column+M}}};if(v){const{undo:W,redo:B,objects:z}=P.getBatchUpdateOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:B,objects:z}}),y.push({id:p.SetDrawingApplyMutation.id,params:{unitId:o,subUnitId:s,type:p.DrawingApplyType.UPDATE,op:W,objects:z}})}else{const{undo:W,redo:B,objects:z}=P.getBatchAddOp([R]);C.push({id:p.SetDrawingApplyMutation.id,params:{op:B,unitId:o,subUnitId:s,objects:z,type:p.DrawingApplyType.INSERT}}),y.push({id:p.SetDrawingApplyMutation.id,params:{op:W,unitId:o,subUnitId:s,objects:z,type:p.DrawingApplyType.REMOVE}})}}),{redos:C,undos:y}}};fe=sn([Ce(0,U.ISheetClipboardService),Ce(1,N.IRenderManagerService),Ce(2,p.ISheetDrawingService)],fe);var an=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,dn=(i,n,r,e)=>{for(var t=e>1?void 0:e?cn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&an(n,r,t),t},re=(i,n)=>(r,e)=>n(r,e,i);let we=class extends m.Disposable{constructor(i,n,r,e,t){super(),this._drawingManagerService=i,this._renderManagerService=n,this._permissionService=r,this._univerInstanceService=e,this._userManagerService=t,this._initDrawingVisible(),this._initDrawingEditable(),this._initViewPermissionChange(),this._initEditPermissionChange()}_initDrawingVisible(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingVisible(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingVisible(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new D.WorkbookViewPermission(t).id,new D.WorksheetViewPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingVisible(!0);else{this._drawingManagerService.setDrawingVisible(!1);const c=n.getUnitId(),d=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,d),l=Object.values(h),a=this._renderManagerService.getRenderById(c),u=a==null?void 0:a.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(w=>f.oKey.includes(w.drawingId))&&u.removeObject(f)})}})}))}_initDrawingEditable(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{if(!n){this._drawingManagerService.setDrawingEditable(!1);return}n.activeSheet$.subscribe(e=>{if(!e){this._drawingManagerService.setDrawingEditable(!1);return}const t=n.getUnitId(),o=e.getSheetId();if(this._permissionService.composePermission([new D.WorkbookEditablePermission(t).id,new D.WorksheetEditPermission(t,o).id]).every(c=>c.value))this._drawingManagerService.setDrawingEditable(!0);else{this._drawingManagerService.setDrawingEditable(!1);const c=n.getUnitId(),d=e.getSheetId(),h=this._drawingManagerService.getDrawingData(c,d),l=Object.values(h),a=this._renderManagerService.getRenderById(c),u=a==null?void 0:a.scene;if(u==null)return;u.getAllObjectsByOrder().forEach(f=>{f.classType===N.RENDER_CLASS_TYPE.IMAGE&&l.some(w=>f.oKey.includes(w.drawingId))&&u.detachTransformerFrom(f)})}})}))}_initViewPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var a;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const h=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new D.WorkbookViewPermission(t).id,new D.WorksheetViewPermission(t,o).id]).pipe(L.map(u=>u.every(g=>g.value)));l==null||l.pipe(L.filter(u=>u!==s),L.distinctUntilChanged()).subscribe({next:u=>{s=u,this._drawingManagerService.setDrawingVisible(u);const g=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),w=Object.values(f);u?this._drawingManagerService.addNotification(w):(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.removeObject(S)}),h.clearSelectedObjects())}}),(a=this._permissionService.getPermissionPoint$(new D.WorksheetViewPermission(t,o).id))==null||a.pipe(L.filter(u=>u.value!==s),L.distinctUntilChanged()).subscribe({complete:()=>{s=!0,this._drawingManagerService.setDrawingVisible(!0);const u=this._drawingManagerService.getDrawingData(t,o),g=Object.values(u);this._drawingManagerService.addNotification(g)}})})}))}_initEditPermissionChange(){const i=this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET);this.disposeWithMe(L.combineLatest([i,this._userManagerService.currentUser$]).subscribe(([n,r])=>{n&&n.activeSheet$.subscribe(e=>{var a;if(!e)return;const t=n.getUnitId(),o=e.getSheetId();let s=!0;const c=this._renderManagerService.getRenderById(t),d=c==null?void 0:c.scene;if(d==null)return;const h=d.getTransformerByCreate(),l=this._permissionService.composePermission$([new D.WorkbookEditablePermission(t).id,new D.WorksheetEditPermission(t,o).id]).pipe(L.map(u=>u.every(g=>g.value)));l==null||l.pipe(L.filter(u=>u!==s),L.distinctUntilChanged()).subscribe({next:u=>{s=u,this._drawingManagerService.setDrawingEditable(u);const g=d.getAllObjectsByOrder(),f=this._drawingManagerService.getDrawingData(t,o),w=Object.values(f);u?(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.attachTransformerTo(S)}),this._drawingManagerService.addNotification(w)):(g.forEach(S=>{S.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(C=>S.oKey.includes(C.drawingId))&&d.detachTransformerFrom(S)}),h.clearSelectedObjects())}}),(a=this._permissionService.getPermissionPoint$(new D.WorksheetEditPermission(t,o).id))==null||a.pipe(L.filter(u=>u.value!==s),L.distinctUntilChanged()).subscribe({complete:()=>{s=!0;const u=n.getUnitId(),g=e.getSheetId(),f=this._drawingManagerService.getDrawingData(u,g),w=Object.values(f),S=this._renderManagerService.getRenderById(u),C=S==null?void 0:S.scene;if(C==null)return;this._drawingManagerService.setDrawingEditable(!0),C.getAllObjectsByOrder().forEach(I=>{I.classType===N.RENDER_CLASS_TYPE.IMAGE&&w.some(T=>I.oKey.includes(T.drawingId))&&C.detachTransformerFrom(I)})}})})}))}};we=dn([re(0,E.IDrawingManagerService),re(1,N.IRenderManagerService),re(2,m.IPermissionService),re(3,m.IUniverInstanceService),re(4,m.Inject(m.UserManagerService))],we);var ln=Object.defineProperty,un=Object.getOwnPropertyDescriptor,gn=(i,n,r,e)=>{for(var t=e>1?void 0:e?un(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&ln(n,r,t),t},ge=(i,n)=>(r,e)=>n(r,e,i);let Se=class extends m.Disposable{constructor(i,n,r,e){super(),this._sheetPrintInterceptorService=i,this._drawingRenderService=n,this._drawingManagerService=r,this._renderManagerService=e,this._initPrinting()}_initPrinting(){this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,{handler:(i,n,r)=>{const{unitId:e,scene:t,subUnitId:o}=n,s=this._drawingManagerService.getDrawingDataForUnit(e),c=s==null?void 0:s[o];return c&&c.order.forEach(d=>{this._drawingRenderService.renderDrawing(c.data[d],t)}),r()}})),this.disposeWithMe(this._sheetPrintInterceptorService.interceptor.intercept(this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,{handler:(i,n,r)=>{const{unitId:e,subUnitId:t}=n,o=this._renderManagerService.getRenderById(e);if(!o)return r(i);const s=o.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);if(!s)return r(i);const c=this._drawingManagerService.getDrawingDataForUnit(e),d=c==null?void 0:c[n.subUnitId];if(!d)return r(i);const{scaleX:h,scaleY:l}=o.scene,a=i?{...i}:{startColumn:0,endColumn:0,endRow:0,startRow:0},u=d.order.map(g=>d.data[g]).filter(g=>g.drawingType!==E.DrawingTypeEnum.DRAWING_DOM);return u.length?(u.forEach(g=>{if(!g.groupId&&g.transform&&m.Tools.isDefine(g.transform.left)&&m.Tools.isDefine(g.transform.top)&&m.Tools.isDefine(g.transform.width)&&m.Tools.isDefine(g.transform.height)){const f=s.skeleton.getCellPositionByOffset(g.transform.left,g.transform.top,h,l,{x:0,y:0}),w=s.skeleton.getCellPositionByOffset(g.transform.left+g.transform.width,g.transform.top+g.transform.height,h,l,{x:0,y:0});f.column<a.startColumn&&(a.startColumn=f.column),f.row<a.startRow&&(a.startRow=f.row),a.endRow<w.row&&(a.endRow=w.row),a.endColumn<w.column&&(a.endColumn=w.column)}}),r(a)):r(i)}}))}};Se=gn([ge(0,m.Inject(U.SheetPrintInterceptorService)),ge(1,m.Inject(te.DrawingRenderService)),ge(2,E.IDrawingManagerService),ge(3,N.IRenderManagerService)],Se);var hn=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,pn=(i,n,r,e)=>{for(var t=e>1?void 0:e?mn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&hn(n,r,t),t},q=(i,n)=>(r,e)=>n(r,e,i);const fn=[D.InsertRowCommand.id,D.InsertColCommand.id,D.RemoveRowCommand.id,D.RemoveColCommand.id,D.DeleteRangeMoveLeftCommand.id,D.DeleteRangeMoveUpCommand.id,D.InsertRangeMoveDownCommand.id,D.InsertRangeMoveRightCommand.id,D.DeltaRowHeightCommand.id,D.SetRowHeightCommand.id,D.DeltaColumnWidthCommand.id,D.SetColWidthCommand.id,D.SetRowHiddenCommand.id,D.SetSpecificRowsVisibleCommand.id,D.SetSpecificColsVisibleCommand.id,D.SetColHiddenCommand.id,D.MoveColsCommand.id,D.MoveRowsCommand.id,D.MoveRangeCommand.id],wn=[D.SetRowVisibleMutation.id,D.SetRowHiddenMutation.id,D.SetColVisibleMutation.id,D.SetColHiddenMutation.id,D.SetWorksheetRowHeightMutation.id,D.SetWorksheetColWidthMutation.id];let Te=class extends m.Disposable{constructor(i,n,r,e,t,o,s,c,d){super(),this._context=i,this._renderManagerService=n,this._commandService=r,this._selectionRenderService=e,this._skeletonManagerService=t,this._sheetInterceptorService=o,this._sheetDrawingService=s,this._drawingManagerService=c,this._univerInstanceService=d,this._sheetInterceptorListener(),this._commandListener(),this._sheetRefreshListener()}_sheetInterceptorListener(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:i=>{if(!fn.includes(i.id))return{redos:[],undos:[]};if(i.params==null)return{redos:[],undos:[]};const n=i.id;if(n===D.InsertRowCommand.id)return this._moveRowInterceptor(i.params,"insert");if([D.MoveColsCommand.id,D.MoveRowsCommand.id,D.MoveRangeCommand.id].includes(n))return this._moveRangeInterceptor(i.params);if(n===D.InsertColCommand.id)return this._moveColInterceptor(i.params,"insert");if(n===D.RemoveRowCommand.id)return this._moveRowInterceptor(i.params,"remove");if(n===D.RemoveColCommand.id)return this._moveColInterceptor(i.params,"remove");if(n===D.DeleteRangeMoveLeftCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,0)}else if(n===D.DeleteRangeMoveUpCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,1)}else if(n===D.InsertRangeMoveDownCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,2)}else if(n===D.InsertRangeMoveRightCommand.id){const{range:r}=i.params;return this._getRangeMoveUndo(r,3)}else if(n===D.SetRowHiddenCommand.id||n===D.SetSpecificRowsVisibleCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForRowVisible(e,t,o)}else if(n===D.SetSpecificColsVisibleCommand.id||n===D.SetColHiddenCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r;return this._getDrawingUndoForColVisible(e,t,o)}else if(n===D.DeltaRowHeightCommand.id||n===D.SetRowHeightCommand.id||n===D.DeltaColumnWidthCommand.id||n===D.SetColWidthCommand.id){const r=i.params,{unitId:e,subUnitId:t,ranges:o}=r,s=n===D.DeltaRowHeightCommand.id||n===D.SetRowHeightCommand.id;return this._getDrawingUndoForRowAndColSize(e,t,o,s)}return{redos:[],undos:[]}}}))}_getRangeMoveUndo(i,n){const r=D.getSheetCommandTarget(this._univerInstanceService);if(r==null)return{redos:[],undos:[]};const e=r.unitId,t=r.subUnitId,o=[],s=[],c=this._sheetDrawingService.getDrawingData(e,t),d=[],h=[];if(Object.keys(c).forEach(l=>{const a=c[l],{updateDrawings:u,deleteDrawings:g}=this._getUpdateOrDeleteDrawings(i,n,a);d.push(...u),h.push(...g)}),d.length===0&&h.length===0)return{redos:[],undos:[]};if(d.length>0){const l=this._sheetDrawingService.getBatchUpdateOp(d),{undo:a,redo:u,objects:g}=l;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:g,type:p.DrawingApplyType.UPDATE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:a,objects:g,type:p.DrawingApplyType.UPDATE}})}if(h.length>0){const l=this._sheetDrawingService.getBatchRemoveOp(h),a=l.undo,u=l.redo,g=l.objects;o.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:u,objects:g,type:p.DrawingApplyType.REMOVE}}),s.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:a,objects:g,type:p.DrawingApplyType.INSERT}})}return o.push({id:x.id,params:[e]}),s.push({id:x.id,params:[e]}),{redos:o,undos:s}}_getUpdateOrDeleteDrawings(i,n,r){const e=[],t=[],{sheetTransform:o,anchorType:s=p.SheetDrawingAnchorType.Position,transform:c,unitId:d,subUnitId:h,drawingId:l}=r,{from:a,to:u}=o,{row:g,column:f}=a,{row:w,column:S}=u;if(o==null||c==null)return{updateDrawings:e,deleteDrawings:t};const{startRow:C,endRow:y,startColumn:I,endColumn:T}=i;let _=null,M=null;if(n===0&&g>=C&&w<=y)if(f>=I&&S<=T)t.push({unitId:d,subUnitId:h,drawingId:l});else{const v=this._shrinkCol(o,c,I,T,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===1&&f>=I&&S<=T)if(g>=C&&w<=y)t.push({unitId:d,subUnitId:h,drawingId:l});else{const v=this._shrinkRow(o,c,C,y,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===2){const v=this._expandRow(o,c,C,y,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}else if(n===3){const v=this._expandCol(o,c,I,T,s);_=v==null?void 0:v.newSheetTransform,M=v==null?void 0:v.newTransform}if(_!=null&&M!=null){const v=V(_,this._selectionRenderService,this._skeletonManagerService);e.push({...r,sheetTransform:_,transform:v})}return{updateDrawings:e,deleteDrawings:t}}_remainDrawingSize(i,n,r){const e=$({...i},this._selectionRenderService);e!=null&&n.push({...r,sheetTransform:e})}_getDrawingUndoForColVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const a=e[l],{sheetTransform:u,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=a;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,a);else{const{from:w,to:S}=u,{row:C,column:y}=w,{row:I,column:T}=S;for(let _=0;_<r.length;_++){const M=r[_],{startRow:v,endRow:P,startColumn:b,endColumn:j}=M;if(T<b)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,W=null;if(y>=b&&y<=j){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:j,startRow:w.row,endRow:S.row});if(B==null)return;W={...g,left:B.startX}}if(W!=null&&(R=$(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...a,sheetTransform:R,transform:W});break}this._remainDrawingSize(g,t,a);continue}if(y>=b&&T<=j)continue;let A=null,O=null;if(y>=b&&y<=j){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:y,endColumn:j,startRow:w.row,endRow:S.row});if(R==null)return;O={...g,left:(R==null?void 0:R.startX)||0,width:((g==null?void 0:g.width)||0)-R.endX+R.startX}}else if(T>=b&&T<=j){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:T,startRow:w.row,endRow:S.row});if(R==null)return;O={...g,left:R.startX-((g==null?void 0:g.width)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:b,endColumn:j,startRow:w.row,endRow:S.row});if(R==null)return;if(O={...g,width:((g==null?void 0:g.width)||0)-R.endX+R.startX},A=$(O,this._selectionRenderService),A!=null&&O!=null){o.push({...a,sheetTransform:A,transform:O});break}}if(O!=null&&(A=$(O,this._selectionRenderService)),O!=null&&A!=null){t.push({...a,sheetTransform:A,transform:O});break}else this._remainDrawingSize(g,t,a)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],h=[];if(o.length>0){const{redos:l,undos:a}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),h.push(...a)}return{redos:s,undos:c,preRedos:d,preUndos:h}}_createUndoAndRedoMutation(i,n,r){const e=this._sheetDrawingService.getBatchUpdateOp(r),{undo:t,redo:o,objects:s}=e,c=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:o,objects:s,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[i]}],d=[{id:p.SetDrawingApplyMutation.id,params:{unitId:i,subUnitId:n,op:t,objects:s,type:p.DrawingApplyType.UPDATE}},{id:x.id,params:[i]}];return{redos:c,undos:d}}_getDrawingUndoForRowVisible(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[],o=[];if(Object.keys(e).forEach(l=>{const a=e[l],{sheetTransform:u,transform:g,anchorType:f=p.SheetDrawingAnchorType.Position}=a;if(f===p.SheetDrawingAnchorType.None)this._remainDrawingSize(g,t,a);else{const{from:w,to:S}=u,{row:C,column:y}=w,{row:I,column:T}=S;for(let _=0;_<r.length;_++){const M=r[_],{startRow:v,endRow:P,startColumn:b,endColumn:j}=M;if(I<v)continue;if(f===p.SheetDrawingAnchorType.Position){let R=null,W=null;if(C>=v&&C<=P){const B=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:C,endRow:P});if(B==null)return;W={...g,top:B.startY}}if(W!=null&&(R=$(W,this._selectionRenderService),R!=null&&W!=null)){t.push({...a,sheetTransform:R,transform:W});break}this._remainDrawingSize(g,t,a);continue}if(C>=v&&I<=P)continue;let A=null,O=null;if(C>=v&&C<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:C,endRow:P});if(R==null)return;O={...g,top:(R==null?void 0:R.startY)||0,height:((g==null?void 0:g.height)||0)-R.endY+R.startY}}else if(I>=v&&I<=P){const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:I});if(R==null)return;O={...g,top:R.startY-((g==null?void 0:g.height)||0)}}else{const R=this._skeletonManagerService.attachRangeWithCoord({startColumn:w.column,endColumn:S.column,startRow:v,endRow:P});if(R==null)return;if(O={...g,height:((g==null?void 0:g.height)||0)-R.endY+R.startY},A=$(O,this._selectionRenderService),A!=null&&O!=null){o.push({...a,sheetTransform:A,transform:O});break}}if(O!=null&&(A=$(O,this._selectionRenderService)),O!=null&&A!=null){t.push({...a,sheetTransform:A,transform:O});break}else this._remainDrawingSize(g,t,a)}}}),t.length===0&&o.length===0)return{redos:[],undos:[]};const{redos:s,undos:c}=this._createUndoAndRedoMutation(i,n,t),d=[],h=[];if(o.length>0){const{redos:l,undos:a}=this._createUndoAndRedoMutation(i,n,o);d.push(...l),h.push(...a)}return{redos:s,undos:c,preRedos:d,preUndos:h}}_getDrawingUndoForRowAndColSize(i,n,r,e){const t=this._drawingManagerService.getDrawingData(i,n),o=[];return Object.keys(t).forEach(s=>{const c=t[s],{sheetTransform:d,transform:h,anchorType:l=p.SheetDrawingAnchorType.Position}=c;if(l===p.SheetDrawingAnchorType.None)this._remainDrawingSize(h,o,c);else{const{from:a,to:u}=d,{row:g,column:f}=a,{row:w,column:S}=u;for(let C=0;C<r.length;C++){const y=r[C],{startRow:I,endRow:T,startColumn:_,endColumn:M}=y;if(w<I||S<_)continue;if(l===p.SheetDrawingAnchorType.Position&&(g<=I&&w>=T||f<=_&&S>=M)){this._remainDrawingSize(h,o,c);continue}const v=V({...d},this._selectionRenderService,this._skeletonManagerService);if(v!=null){o.push({...c,transform:v});break}}}}),o.length===0?{redos:[],undos:[]}:this._createUndoAndRedoMutation(i,n,o)}_getUnitIdAndSubUnitId(i,n){let r,e;if(n==="insert")r=i.unitId,e=i.subUnitId;else{const t=D.getSheetCommandTarget(this._univerInstanceService);if(t==null)return;r=t.unitId,e=t.subUnitId}return{unitId:r,subUnitId:e}}_moveRangeInterceptor(i){var I,T;const{toRange:n,fromRange:r}=i,e=D.getSheetCommandTarget(this._univerInstanceService);if(!e)return{redos:[],undos:[]};const{unitId:t,subUnitId:o}=e,s=(T=(I=this._renderManagerService.getRenderById(t))==null?void 0:I.with(U.SheetSkeletonManagerService))==null?void 0:T.getCurrentSkeleton();if(!s)return{redos:[],undos:[]};const c=U.attachRangeWithCoord(s,r);if(!c)return{redos:[],undos:[]};const{startX:d,endX:h,startY:l,endY:a}=c,u=this._sheetDrawingService.getDrawingData(t,o),g=[];Object.keys(u).forEach(_=>{const M=u[_];if(M.anchorType!==p.SheetDrawingAnchorType.Both)return;const{transform:v}=M;if(!v)return;const{left:P=0,top:b=0,width:j=0,height:A=0}=v,{drawingStartX:O,drawingEndX:R,drawingStartY:W,drawingEndY:B}={drawingStartX:P,drawingEndX:P+j,drawingStartY:b,drawingEndY:b+A};d<=O&&R<=h&&l<=W&&B<=a&&g.push(M)});const f=[],w=[],S=n.startRow-r.startRow,C=n.startColumn-r.startColumn,y=g.map(_=>{const M=_.sheetTransform,v={to:{...M.to,row:M.to.row+S,column:M.to.column+C},from:{...M.from,row:M.from.row+S,column:M.from.column+C}},P=V(v,this._selectionRenderService,this._skeletonManagerService);return{unitId:t,subUnitId:o,drawingId:_.drawingId,transform:P,sheetTransform:v}});if(y.length){const _=this._sheetDrawingService.getBatchUpdateOp(y),{undo:M,redo:v,objects:P}=_;f.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:v,objects:P,type:p.DrawingApplyType.UPDATE}}),w.push({id:p.SetDrawingApplyMutation.id,params:{unitId:t,subUnitId:o,op:M,objects:P,type:p.DrawingApplyType.UPDATE}})}return{redos:f,undos:w}}_moveRowInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,s=o.startRow,c=o.endRow,d=[],h=[],l=this._sheetDrawingService.getDrawingData(e,t),a=[],u=[];if(Object.keys(l).forEach(g=>{const f=l[g],{sheetTransform:w,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let y,I;if(n==="insert"){const _=this._expandRow(w,S,s,c,C);y=_==null?void 0:_.newSheetTransform,I=_==null?void 0:_.newTransform}else{const{from:_,to:M}=w,{row:v}=_,{row:P}=M;if(C===p.SheetDrawingAnchorType.Both&&v>=s&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:g});else{const b=this._shrinkRow(w,S,s,c,C);y=b==null?void 0:b.newSheetTransform,I=b==null?void 0:b.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:g,transform:I,sheetTransform:y};a.push(T)}),a.length===0&&u.length===0)return{redos:[],undos:[]};if(a.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(a),{undo:f,redo:w,objects:S}=g;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.UPDATE}})}if(u.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(u),f=g.undo,w=g.redo,S=g.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:x.id,params:[e]}),h.push({id:x.id,params:[e]}),{redos:d,undos:h}}_moveColInterceptor(i,n){const r=this._getUnitIdAndSubUnitId(i,n);if(r==null)return{redos:[],undos:[]};const{unitId:e,subUnitId:t}=r,{range:o}=i,s=o.startColumn,c=o.endColumn,d=[],h=[],l=this._sheetDrawingService.getDrawingData(e,t),a=[],u=[];if(Object.keys(l).forEach(g=>{const f=l[g],{sheetTransform:w,transform:S,anchorType:C=p.SheetDrawingAnchorType.Position}=f;if(w==null||S==null)return;let y,I;if(n==="insert"){const _=this._expandCol(w,S,s,c,C);y=_==null?void 0:_.newSheetTransform,I=_==null?void 0:_.newTransform}else{const{from:_,to:M}=w,{column:v}=_,{column:P}=M;if(C===p.SheetDrawingAnchorType.Both&&v>=s&&P<=c)u.push({unitId:e,subUnitId:t,drawingId:g});else{const b=this._shrinkCol(w,S,s,c,C);y=b==null?void 0:b.newSheetTransform,I=b==null?void 0:b.newTransform}}if(!y||!I)return;const T={unitId:e,subUnitId:t,drawingId:g,transform:I,sheetTransform:y};a.push(T)}),a.length===0&&u.length===0)return{redos:[],undos:[]};if(a.length>0){const g=this._sheetDrawingService.getBatchUpdateOp(a),{undo:f,redo:w,objects:S}=g;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.UPDATE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.UPDATE}})}if(u.length>0){const g=this._sheetDrawingService.getBatchRemoveOp(u),f=g.undo,w=g.redo,S=g.objects;d.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:w,objects:S,type:p.DrawingApplyType.REMOVE}}),h.push({id:p.SetDrawingApplyMutation.id,params:{unitId:e,subUnitId:t,op:f,objects:S,type:p.DrawingApplyType.INSERT}})}return d.push({id:x.id,params:[e]}),h.push({id:x.id,params:[e]}),{redos:d,undos:h}}_expandCol(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{column:d}=s,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:e,startRow:s.row,endRow:c.row});if(u==null)return;a={...n,left:(n.left||0)+u.endX-u.startX},l=$(a,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,column:h+o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_shrinkCol(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{column:d}=s,{column:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>e)l={from:{...s,column:d-o},to:{...c,column:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&h<=e)return null;if(d<r&&h>e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,column:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)a={...n,left:(n.left||0)-i.from.columnOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r,endColumn:d-1,startRow:s.row,endRow:c.row});if(u==null)return;a={...n,left:(n.left||0)-u.endX+u.startX-i.from.columnOffset}}l=$(a,this._selectionRenderService)}else if(h>=r&&h<=e&&t===p.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:r-1,endColumn:r-1,startRow:s.row,endRow:c.row});if(u==null)return;l={from:{...s},to:{...c,column:r-1,columnOffset:u.endX-u.startX}},a=V(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_expandRow(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{row:d}=s,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>=r){const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:e,startColumn:s.column,endColumn:c.column});if(u==null)return;a={...n,top:(n.top||0)+u.endY-u.startY},l=$(a,this._selectionRenderService)}else if(h>=e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,row:h+o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_shrinkRow(i,n,r,e,t=p.SheetDrawingAnchorType.Position){const o=e-r+1,{from:s,to:c}=i,{row:d}=s,{row:h}=c;if(t===p.SheetDrawingAnchorType.None)return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};let l=null,a=null;if(d>e)l={from:{...s,row:d-o},to:{...c,row:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else{if(d>=r&&h<=e)return null;if(d<r&&h>e)if(t===p.SheetDrawingAnchorType.Both)l={from:{...s},to:{...c,row:h-o}},a=V(l,this._selectionRenderService,this._skeletonManagerService);else return{newSheetTransform:$({...n},this._selectionRenderService),newTransform:n};else if(d>=r&&d<=e){if(d===r)a={...n,top:(n.top||0)-i.from.rowOffset};else{const u=this._skeletonManagerService.attachRangeWithCoord({startRow:r,endRow:d-1,startColumn:s.column,endColumn:c.column});if(u==null)return;a={...n,top:(n.top||0)-u.endY+u.startY-i.from.rowOffset}}l=$(a,this._selectionRenderService)}else if(h>=r&&h<=e&&t===p.SheetDrawingAnchorType.Both){const u=this._skeletonManagerService.attachRangeWithCoord({startColumn:s.column,endColumn:s.column,startRow:r-1,endRow:r-1});if(u==null)return;l={from:{...s},to:{...c,row:r-1,rowOffset:u.endY-u.startY}},a=V(l,this._selectionRenderService,this._skeletonManagerService)}}return l!=null&&a!=null?{newSheetTransform:l,newTransform:a}:null}_commandListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{i.id===D.SetWorksheetActiveOperation.id&&setTimeout(()=>{const n=i.params,{unitId:r,subUnitId:e}=n,t=this._drawingManagerService.drawingManagerData,o=[],s=[];Object.keys(t).forEach(c=>{const d=t[c];d!=null&&Object.keys(d).forEach(h=>{const l=d[h].data;l!=null&&Object.keys(l).forEach(a=>{if(c===r&&h===e){const u=l[a];u.transform=V(u.sheetTransform,this._selectionRenderService,this._skeletonManagerService),o.push(l[a])}else s.push(l[a])})})}),this._drawingManagerService.removeNotification(s),this._drawingManagerService.addNotification(o)},0)}))}_sheetRefreshListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{wn.includes(i.id)&&requestIdleCallback(()=>{const n=i.params,{unitId:r,subUnitId:e,ranges:t}=n;this._refreshDrawingTransform(r,e,t)})}))}_refreshDrawingTransform(i,n,r){const e=this._drawingManagerService.getDrawingData(i,n),t=[];Object.keys(e).forEach(o=>{const s=e[o],{sheetTransform:c,transform:d,anchorType:h=p.SheetDrawingAnchorType.Position}=s;if(h===p.SheetDrawingAnchorType.None)return!0;const{from:l,to:a}=c,{row:u,column:g}=l,{row:f,column:w}=a;for(let S=0;S<r.length;S++){const C=r[S],{startRow:y,endRow:I,startColumn:T,endColumn:_}=C;if(m.Rectangle.intersects({startRow:y,endRow:I,startColumn:T,endColumn:_},{startRow:u,endRow:f,startColumn:g,endColumn:w})||u>I||g>_){const M=h===p.SheetDrawingAnchorType.Position,v=V(c,this._selectionRenderService,this._skeletonManagerService);t.push({...s,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}}}),t.length!==0&&(this._drawingManagerService.refreshTransform(t),this._commandService.syncExecuteCommand(x.id,[i]))}};Te=pn([q(1,N.IRenderManagerService),q(2,m.ICommandService),q(3,U.ISheetSelectionRenderService),q(4,m.Inject(U.SheetSkeletonManagerService)),q(5,m.Inject(D.SheetInterceptorService)),q(6,p.ISheetDrawingService),q(7,E.IDrawingManagerService),q(8,m.IUniverInstanceService)],Te);var Sn=Object.defineProperty,vn=Object.getOwnPropertyDescriptor,_n=(i,n,r,e)=>{for(var t=e>1?void 0:e?vn(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Sn(n,r,t),t},ee=(i,n)=>(r,e)=>n(r,e,i);function Dn(i,n,r,e){const{scaleX:t,scaleY:o}=n.getAncestorScale(),s=n.getViewport(N.SHEET_VIEWPORT_KEY.VIEW_MAIN),c={left:!0,top:!0};if(!s)return{...i,absolute:c};const{left:d,right:h,top:l,bottom:a}=i,u=e.getFreeze(),{startColumn:g,startRow:f,xSplit:w,ySplit:S}=u,C=r.getNoMergeCellPositionByIndexWithNoHeader(f-S,g-w),y=r.getNoMergeCellPositionByIndexWithNoHeader(f,g),{rowHeaderWidth:I,columnHeaderHeight:T}=r,_=y.startX-C.startX,M=y.startY-C.startY,{top:v,left:P,viewportScrollX:b,viewportScrollY:j}=s;let A,O;d<P?(c.left=!0,A=(_+I+(d-P))*t,O=Math.max(Math.min((_+I+(h-P))*t,(_+I)*t),(h-b)*t)):(c.left=!1,A=Math.max((d-b)*t,(_+I)*t),O=Math.max((h-b)*t,(_+I)*t));let R,W;return l<v?(c.top=!0,R=(M+T+(l-v))*o,W=Math.max(Math.min((M+T+(h-v))*o,(M+T)*o),(a-j)*o)):(c.top=!1,R=Math.max((l-j)*o,(M+T)*o),W=Math.max((a-j)*o,(M+T)*o)),{left:A,right:O,top:R,bottom:W,absolute:c}}const ye=(i,n,r,e)=>{const{scene:t}=n,{left:o,top:s,width:c,height:d,angle:h}=i,l={left:o,right:o+c,top:s,bottom:s+d},a=Dn(l,t,r,e),{scaleX:u,scaleY:g}=t.getAncestorScale();return{startX:a.left,endX:a.right,startY:a.top,endY:a.bottom,rotate:h,width:c*u,height:d*g,absolute:a.absolute}};exports.SheetCanvasFloatDomManagerService=class extends m.Disposable{constructor(r,e,t,o,s,c,d){super();Y(this,"_domLayerMap",new Map);Y(this,"_domLayerInfoMap",new Map);Y(this,"_transformChange$",new L.Subject);Y(this,"transformChange$",this._transformChange$.asObservable());Y(this,"_add$",new L.Subject);Y(this,"add$",this._add$.asObservable());Y(this,"_remove$",new L.Subject);Y(this,"remove$",this._remove$.asObservable());Y(this,"_hooks",[]);this._renderManagerService=r,this._univerInstanceService=e,this._commandService=t,this._drawingManagerService=o,this._canvasFloatDomService=s,this._sheetDrawingService=c,this._lifecycleService=d,this._drawingAddListener(),this._featureUpdateListener(),this._deleteListener(),this._bindScrollEvent()}_bindScrollEvent(){this._lifecycleService.lifecycle$.pipe(L.filter(r=>r===m.LifecycleStages.Rendered),L.take(1)).subscribe(()=>{this._scrollUpdateListener()})}_ensureMap(r,e){let t=this._domLayerMap.get(r);t||(t=new Map,this._domLayerMap.set(r,t));let o=t.get(e);return o||(o=new Map,t.set(e,o)),o}getFloatDomInfo(r){return this._domLayerInfoMap.get(r)}_getSceneAndTransformerByDrawingSearch(r){if(r==null)return;const e=this._renderManagerService.getRenderById(r),t=e==null?void 0:e.scene;if(e==null||t==null)return null;const o=t.getTransformerByCreate(),s=e.engine.getCanvasElement();return{scene:t,transformer:o,renderObject:e,canvas:s}}_getFloatDomProps(r){let e;return this._hooks.forEach(t=>{e=t.onGetFloatDomProps(r)}),e}_drawingAddListener(){this.disposeWithMe(this._drawingManagerService.add$.subscribe(r=>{r.forEach(e=>{var We,Le,xe;const{unitId:t,subUnitId:o,drawingId:s}=e,c=D.getSheetCommandTarget(this._univerInstanceService,{unitId:t,subUnitId:o}),d=this._drawingManagerService.getDrawingByParam(e),h=this._univerInstanceService.getUnit(t);if(!h)return;const l=h.getActiveSheet().getSheetId();if(!d||!c)return;const a=(We=this._renderManagerService.getRenderById(t))==null?void 0:We.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(o);if(!a)return;const{transform:u,drawingType:g,data:f}=d;if(g!==E.DrawingTypeEnum.DRAWING_DOM&&g!==E.DrawingTypeEnum.DRAWING_CHART)return;const w=this._getSceneAndTransformerByDrawingSearch(t);if(w==null)return;const{scene:S,canvas:C}=w;if(u==null)return!0;if(l!==o)return;const{left:y,top:I,width:T,height:_,angle:M,flipX:v,flipY:P,skewX:b,skewY:j}=u,A=E.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:s}),O=S.getObject(A);if(O!=null){O.transformByState({left:y,top:I,width:T,height:_,angle:M,flipX:v,flipY:P,skewX:b,skewY:j});return}const R={left:y,top:I,width:T,height:_,zIndex:this._drawingManagerService.getDrawingOrder(t,o).length-1},W=g===E.DrawingTypeEnum.DRAWING_CHART;W&&(R.fill="white",R.rotateEnabled=!1,f&&f.border&&(R.stroke=f.border),R.paintFirst="stroke",R.strokeWidth=1,R.borderEnabled=!1,R.radius=8);const B=new N.Rect(A,R);W&&B.setObjectType(N.ObjectType.CHART),S.addObject(B,N.DRAWING_OBJECT_LAYER_INDEX),d.allowTransform!==!1&&S.attachTransformerTo(B);const z=this._ensureMap(t,o),De=new m.DisposableCollection,ze=ye(B,w.renderObject,a.skeleton,c.worksheet),Ie=new L.BehaviorSubject(ze),qe={dispose:De,rect:B,position$:Ie,unitId:t,subUnitId:o};this._canvasFloatDomService.addFloatDom({position$:Ie,id:s,componentKey:d.componentKey,onPointerDown:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onPointerMove:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onPointerUp:F=>{C.dispatchEvent(new PointerEvent(F.type,F))},onWheel:F=>{C.dispatchEvent(new WheelEvent(F.type,F))},props:(xe=(Le=z.get(s))==null?void 0:Le.props)!=null?xe:this._getFloatDomProps(s),data:f,unitId:t});const je=B.onTransformChange$.subscribeEvent(()=>{const F=ye(B,w.renderObject,a.skeleton,c.worksheet);Ie.next(F)});De.add(()=>{this._canvasFloatDomService.removeFloatDom(s)}),je&&De.add(je),this._domLayerInfoMap.set(s,qe),z.set(s,{...z.get(s)})})})),this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{const{unitId:t,subUnitId:o,drawingId:s}=e,c=E.getDrawingShapeKeyByDrawingSearch({unitId:t,subUnitId:o,drawingId:s}),d=this._getSceneAndTransformerByDrawingSearch(t);if(d==null)return;const{transformer:h,scene:l}=d,a=l.getObject(c);a!=null&&a.oKey&&h.clearControlByIds([a==null?void 0:a.oKey])})}))}_scrollUpdateListener(){const r=(e,t)=>{var l;const o=this._getSceneAndTransformerByDrawingSearch(e),s=this._ensureMap(e,t),c=Array.from(s.keys()),d=D.getSheetCommandTarget(this._univerInstanceService,{unitId:e,subUnitId:t}),h=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.with(U.SheetSkeletonManagerService).getWorksheetSkeleton(t);!o||!d||!h||c.forEach(a=>{const u=this._domLayerInfoMap.get(a);if(u){const g=ye(u.rect,o.renderObject,h.skeleton,d.worksheet);u.position$.next(g)}})};this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(m.UniverInstanceType.UNIVER_SHEET).pipe(L.filter(e=>!!e),L.map(e=>{const t=this._renderManagerService.getRenderById(e.getUnitId());return t?{render:t,unitId:e.getUnitId(),subUnitId:e.getActiveSheet().getSheetId()}:null}),L.filter(e=>!!e),L.switchMap(e=>m.fromEventSubject(e.render.scene.getViewport(U.VIEWPORT_KEY.VIEW_MAIN).onScrollAfter$).pipe(L.map(()=>({unitId:e.unitId,subUnitId:e.subUnitId}))))).subscribe(({unitId:e,subUnitId:t})=>{r(e,t)})),this.disposeWithMe(this._commandService.onCommandExecuted(e=>{var t,o;if(e.id===U.SetZoomRatioOperation.id){const s=e.params,{unitId:c}=s;Array.from((o=(t=this._domLayerMap.get(c))==null?void 0:t.keys())!=null?o:[]).forEach(h=>{r(c,h)})}else if(e.id===D.SetFrozenMutation.id){const{unitId:s,subUnitId:c}=e.params;r(s,c)}}))}_getPosition(r,e){var g;const{startX:t,endX:o,startY:s,endY:c}=r,d=(g=this._renderManagerService.getRenderById(e))==null?void 0:g.with(U.ISheetSelectionRenderService);if(d==null)return;const h=d.getSelectionCellByPosition(t,s);if(h==null)return;const l={column:h.actualColumn,columnOffset:t-h.startX,row:h.actualRow,rowOffset:s-h.startY},a=d.getSelectionCellByPosition(o,c);if(a==null)return;const u={column:a.actualColumn,columnOffset:o-a.startX,row:a.actualRow,rowOffset:c-a.startY};return{from:l,to:u}}_featureUpdateListener(){this.disposeWithMe(this._drawingManagerService.update$.subscribe(r=>{r.forEach(e=>{const t=this._drawingManagerService.getDrawingByParam(e);if(!t||t.drawingType!==E.DrawingTypeEnum.DRAWING_DOM&&t.drawingType!==E.DrawingTypeEnum.DRAWING_CHART)return;const o={...t.transform};this._transformChange$.next({id:e.drawingId,value:o})})}))}_deleteListener(){this.disposeWithMe(this._drawingManagerService.remove$.subscribe(r=>{r.forEach(e=>{this._removeDom(e.drawingId)})}))}updateFloatDomProps(r,e,t,o){const s=this._domLayerInfoMap.get(t),c=this._getSceneAndTransformerByDrawingSearch(r);if(s&&c){const{scene:d}=c,h=E.getDrawingShapeKeyByDrawingSearch({unitId:r,subUnitId:e,drawingId:t}),l=d.getObject(h);l&&l instanceof N.Rect&&l.setProps(o)}}addFloatDomToPosition(r,e){const t=D.getSheetCommandTarget(this._univerInstanceService,{unitId:r.unitId,subUnitId:r.subUnitId});if(!t)throw new Error("cannot find current target!");const{unitId:o,subUnitId:s}=t,{initPosition:c,componentKey:d,data:h,allowTransform:l=!0}=r,a=e!=null?e:m.generateRandomId(),u=this._getPosition(c,o);if(u==null)return;this._ensureMap(o,s).set(a,r);const f={unitId:o,subUnitId:s,drawingId:a,drawingType:r.type||E.DrawingTypeEnum.DRAWING_DOM,componentKey:d,sheetTransform:u,transform:{left:c.startX,top:c.startY,width:c.endX-c.startX,height:c.endY-c.startY},data:h,allowTransform:l};return this._commandService.executeCommand(oe.id,{unitId:o,drawings:[f]}),this._add$.next({unitId:o,subUnitId:s,id:a}),{id:a,dispose:()=>{this._removeDom(a,!0)}}}_removeDom(r,e=!1){const t=this._domLayerInfoMap.get(r);if(!t)return;const{unitId:o,subUnitId:s}=t;this._domLayerInfoMap.delete(r),t.dispose.dispose();const c=this._getSceneAndTransformerByDrawingSearch(o);if(c&&c.scene.removeObject(t.rect),e){this._ensureMap(o,s).delete(r);const h=this._drawingManagerService.getDrawingByParam({unitId:o,subUnitId:s,drawingId:r});if(!h)return;const l=this._sheetDrawingService.getBatchRemoveOp([h]),{redo:a,objects:u}=l;this._commandService.syncExecuteCommand(p.SetDrawingApplyMutation.id,{unitId:o,subUnitId:s,op:a,objects:u,type:p.DrawingApplyType.REMOVE})}}addHook(r){return this._hooks.push(r),{dispose:()=>{const e=this._hooks.findIndex(t=>t===r);this._hooks.splice(e,1)}}}};exports.SheetCanvasFloatDomManagerService=_n([ee(0,m.Inject(N.IRenderManagerService)),ee(1,m.IUniverInstanceService),ee(2,m.Inject(m.ICommandService)),ee(3,E.IDrawingManagerService),ee(4,m.Inject(G.CanvasFloatDomService)),ee(5,p.ISheetDrawingService),ee(6,m.Inject(m.LifecycleService))],exports.SheetCanvasFloatDomManagerService);var Xe=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Cn=(i,n,r)=>n in i?Xe(i,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[n]=r,yn=(i,n,r,e)=>{for(var t=e>1?void 0:e?In(n,r):n,o=i.length-1,s;o>=0;o--)(s=i[o])&&(t=(e?s(n,r,t):s(t))||t);return e&&t&&Xe(n,r,t),t},Me=(i,n)=>(r,e)=>n(r,e,i),Ke=(i,n,r)=>Cn(i,typeof n!="symbol"?n+"":n,r);const Mn="SHEET_IMAGE_UI_PLUGIN";exports.UniverSheetsDrawingUIPlugin=class extends m.Plugin{constructor(n=et,r,e,t){super(),this._config=n,this._injector=r,this._renderManagerService=e,this._configService=t;const{menu:o,...s}=this._config;o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(Qe,s)}onStarting(){m.registerDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService],[pe],[he],[Se],[we],[fe]]),m.touchDependencies(this._injector,[[exports.SheetCanvasFloatDomManagerService]])}onReady(){m.touchDependencies(this._injector,[[fe]])}onRendered(){this._registerRenderModules(),m.touchDependencies(this._injector,[[we],[Se],[pe]])}onSteady(){this._injector.get(he)}_registerRenderModules(){[[me],[Te],[Re]].forEach(n=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(m.UniverInstanceType.UNIVER_SHEET,n))})}};Ke(exports.UniverSheetsDrawingUIPlugin,"type",m.UniverInstanceType.UNIVER_SHEET);Ke(exports.UniverSheetsDrawingUIPlugin,"pluginName",Mn);exports.UniverSheetsDrawingUIPlugin=yn([m.DependentOn(E.UniverDrawingPlugin,te.UniverDrawingUIPlugin,p.UniverSheetsDrawingPlugin),Me(1,m.Inject(m.Injector)),Me(2,N.IRenderManagerService),Me(3,m.IConfigService)],exports.UniverSheetsDrawingUIPlugin);exports.ClearSheetDrawingTransformerOperation=x;exports.DeleteDrawingsCommand=Oe;exports.EditSheetDrawingOperation=Ee;exports.GroupSheetDrawingCommand=Pe;exports.IMAGE_MENU_ID=Ne;exports.InsertFloatImageCommand=_e;exports.InsertSheetDrawingCommand=oe;exports.MoveDrawingsCommand=ne;exports.RemoveSheetDrawingCommand=ie;exports.SetDrawingArrangeCommand=Ae;exports.SetSheetDrawingCommand=se;exports.SidebarSheetDrawingOperation=be;exports.UngroupSheetDrawingCommand=Ue;
@@ -0,0 +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"},"sheet-drawing-view":"Drawing",shortcut:{sheet:{"drawing-move-down":"Move Drawing down","drawing-move-up":"Move Drawing up","drawing-move-left":"Move Drawing left","drawing-move-right":"Move Drawing right","drawing-delete":"Delete Drawing"}}};module.exports=e;
@@ -0,0 +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:"تصویر نامعتبر است"},"sheet-drawing-view":"طراحی",shortcut:{sheet:{"drawing-move-down":"جابه‌جایی طراحی به پایین","drawing-move-up":"جابه‌جایی طراحی به بالا","drawing-move-left":"جابه‌جایی طراحی به چپ","drawing-move-right":"جابه‌جایی طراحی به راست","drawing-delete":"حذف طراحی"}}};module.exports=e;
@@ -0,0 +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}М",invalidImageType:"Недопустимый тип изображения",exceedMaxCount:"За один раз можно загрузить только {0} изображений",invalidImage:"Недопустимое изображение"},"sheet-drawing-view":"Drawing",shortcut:{sheet:{"drawing-move-down":"Move Drawing down","drawing-move-up":"Move Drawing up","drawing-move-left":"Move Drawing left","drawing-move-right":"Move Drawing right","drawing-delete":"Delete Drawing"}}};module.exports=e;
@@ -0,0 +1 @@
1
+ "use strict";const h={sheetImage:{title:"Hình ảnh",upload:{float:"Hình ảnh nổi",cell:"Hình ảnh trong ô"},panel:{title:"Chỉnh sửa hình ảnh"}},"image-popup":{replace:"Thay thế",delete:"Xóa",edit:"Chỉnh sửa",crop:"Cắt",reset:"Đặt lại kích thước"},"drawing-anchor":{title:"Thuộc tính neo",both:"Di chuyển và thay đổi kích thước cùng với ô",position:"Di chuyển nhưng không thay đổi kích thước với ô",none:"Không di chuyển hoặc thay đổi kích thước với ô"},"update-status":{exceedMaxSize:"Kích thước hình ảnh vượt quá giới hạn, giới hạn là {0}M",invalidImageType:"Loại hình ảnh không hợp lệ",exceedMaxCount:"Chỉ có thể tải lên {0} hình ảnh một lần",invalidImage:"Hình ảnh không hợp lệ"},"sheet-drawing-view":"Drawing",shortcut:{sheet:{"drawing-move-down":"Move Drawing down","drawing-move-up":"Move Drawing up","drawing-move-left":"Move Drawing left","drawing-move-right":"Move Drawing right","drawing-delete":"Delete Drawing"}}};module.exports=h;
@@ -0,0 +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:"无效图片"},"sheet-drawing-view":"绘图",shortcut:{sheet:{"drawing-move-down":"下移绘图","drawing-move-up":"上移绘图","drawing-move-left":"左移绘图","drawing-move-right":"下移绘图","drawing-delete":"删除绘图"}}};module.exports=e;
@@ -0,0 +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:"無效圖片"},"sheet-drawing-view":"繪圖",shortcut:{sheet:{"drawing-move-down":"下移繪圖","drawing-move-up":"上移繪圖","drawing-move-left":"左移繪圖","drawing-move-right":"下移繪圖","drawing-delete":"刪除繪圖"}}};module.exports=e;
package/lib/es/facade.js CHANGED
@@ -1,20 +1,16 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
3
- import { FWorksheet } from "@univerjs/sheets/facade";
4
- import { transformComponentKey } from "@univerjs/sheets-ui/facade";
5
- import { ComponentManager } from "@univerjs/ui";
6
- import { S as SheetCanvasFloatDomManagerService } from "../canvas-float-dom-manager.service-t4WyJLnC.mjs";
7
- const _FWorksheetLegacy = class _FWorksheetLegacy extends FWorksheet {
8
- addFloatDomToPosition(layer, id) {
9
- const unitId = this._workbook.getUnitId(), subUnitId = this._worksheet.getSheetId(), { key, disposableCollection } = transformComponentKey(layer, this._injector.get(ComponentManager)), res = this._injector.get(SheetCanvasFloatDomManagerService).addFloatDomToPosition({ ...layer, componentKey: key, unitId, subUnitId }, id);
10
- return res ? (disposableCollection.add(res.dispose), {
11
- id: res.id,
12
- dispose: /* @__PURE__ */ __name(() => {
13
- disposableCollection.dispose(), res.dispose();
14
- }, "dispose")
15
- }) : (disposableCollection.dispose(), null);
1
+ import { FWorksheet as s } from "@univerjs/sheets/facade";
2
+ import { SheetCanvasFloatDomManagerService as a } from "@univerjs/sheets-drawing-ui";
3
+ import { transformComponentKey as m } from "@univerjs/sheets-ui/facade";
4
+ import { ComponentManager as c } from "@univerjs/ui";
5
+ class p extends s {
6
+ addFloatDomToPosition(t, i) {
7
+ const n = this._workbook.getUnitId(), r = this._worksheet.getSheetId(), { key: d, disposableCollection: e } = m(t, this._injector.get(c)), o = this._injector.get(a).addFloatDomToPosition({ ...t, componentKey: d, unitId: n, subUnitId: r }, i);
8
+ return o ? (e.add(o.dispose), {
9
+ id: o.id,
10
+ dispose: () => {
11
+ e.dispose(), o.dispose();
12
+ }
13
+ }) : (e.dispose(), null);
16
14
  }
17
- };
18
- __name(_FWorksheetLegacy, "FWorksheetLegacy");
19
- let FWorksheetLegacy = _FWorksheetLegacy;
20
- FWorksheet.extend(FWorksheetLegacy);
15
+ }
16
+ s.extend(p);