@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.
package/lib/es/index.js CHANGED
@@ -1,1162 +1,1217 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { CommandType, ICommandService, IUndoRedoService, sequenceExecute, LocaleService, IUniverInstanceService, useDependency, Inject, Injector, IContextService, RxDisposable, UniverInstanceType, connectInjector, toDisposable, FOCUSING_COMMON_DRAWINGS, Disposable, Direction, FOCUSING_FX_BAR_EDITOR, EDITOR_ACTIVATED, Tools, UserManagerService, IPermissionService, Rectangle, DependentOn, Plugin, registerDependencies, touchDependencies, IConfigService } from "@univerjs/core";
6
- import { IDrawingManagerService, IImageIoService, DrawingTypeEnum, ArrangeTypeEnum, DRAWING_IMAGE_ALLOW_IMAGE_LIST, DRAWING_IMAGE_COUNT_LIMIT, ImageUploadStatusType, DRAWING_IMAGE_ALLOW_SIZE, getImageSize, DRAWING_IMAGE_WIDTH_LIMIT, DRAWING_IMAGE_HEIGHT_LIMIT, UniverDrawingPlugin } from "@univerjs/drawing";
7
- import { ImageCropperObject, COMPONENT_IMAGE_POPUP_MENU, OpenImageCropOperation, ImageResetSizeOperation, DrawingCommonPanel, DrawingRenderService, UniverDrawingUIPlugin } from "@univerjs/drawing-ui";
8
- import { IRenderManagerService, precisionTo, getGroupState, transformObjectOutOfGroup, RENDER_CLASS_TYPE } from "@univerjs/engine-render";
9
- import { ISheetDrawingService, SetDrawingApplyMutation, DrawingApplyType, SheetDrawingAnchorType, UniverSheetsDrawingPlugin } from "@univerjs/sheets-drawing";
10
- import { SheetCanvasPopManagerService, attachRangeWithCoord, ISheetSelectionRenderService, SheetSkeletonManagerService, getCurrentRangeDisable$, COPY_TYPE, PREDEFINED_HOOK_NAME, virtualizeDiscreteRanges, ISheetClipboardService, SheetPrintInterceptorService } from "@univerjs/sheets-ui";
11
- import { ISidebarService, IUIPartsService, BuiltInUIPart, ILocalFileService, IMessageService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, KeyCode, ComponentManager, IMenuManagerService, IShortcutService } from "@univerjs/ui";
12
- import { takeUntil, combineLatest, map, filter, distinctUntilChanged } from "rxjs";
13
- import { SheetInterceptorService, getSheetCommandTarget, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, RangeProtectionPermissionEditPoint, WorkbookViewPermission, WorksheetViewPermission, InsertRowCommand, InsertColCommand, RemoveRowCommand, RemoveColCommand, DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, DeltaRowHeightCommand, SetRowHeightCommand, DeltaColumnWidthCommand, SetColWidthCommand, SetRowHiddenCommand, SetSpecificRowsVisibleCommand, SetSpecificColsVisibleCommand, SetColHiddenCommand, MoveColsCommand, MoveRowsCommand, MoveRangeCommand, SetRowVisibleMutation, SetRowHiddenMutation, SetColVisibleMutation, SetColHiddenMutation, SetWorksheetRowHeightMutation, SetWorksheetColWidthMutation, SetWorksheetActiveOperation } from "@univerjs/sheets";
14
- import { C as ClearSheetDrawingTransformerOperation, I as InsertSheetDrawingCommand, S as SheetCanvasFloatDomManagerService } from "../canvas-float-dom-manager.service-t4WyJLnC.mjs";
15
- import React, { useEffect, forwardRef, useRef, createElement, useState } from "react";
16
- import { MessageType, RadioGroup, Radio } from "@univerjs/design";
17
- const PLUGIN_CONFIG_KEY = "sheets-drawing-ui.config", defaultPluginConfig = {}, RemoveSheetDrawingCommand = {
1
+ var gn = Object.defineProperty;
2
+ var mn = (i, e, n) => e in i ? gn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n;
3
+ var V = (i, e, n) => mn(i, typeof e != "symbol" ? e + "" : e, n);
4
+ import { CommandType as H, ICommandService as W, IUndoRedoService as ue, sequenceExecute as It, LocaleService as We, IUniverInstanceService as fe, useDependency as oe, Inject as x, Injector as Ct, IContextService as Rt, RxDisposable as fn, UniverInstanceType as Y, connectInjector as pn, toDisposable as wn, FOCUSING_COMMON_DRAWINGS as me, Disposable as re, Direction as te, FOCUSING_FX_BAR_EDITOR as _n, EDITOR_ACTIVATED as vn, FOCUSING_PANEL_EDITOR as Sn, Tools as ge, UserManagerService as In, IPermissionService as Cn, Rectangle as Rn, LifecycleService as Dn, LifecycleStages as Mn, DisposableCollection as bn, fromEventSubject as yn, generateRandomId as On, DependentOn as Pn, Plugin as Tn, registerDependencies as En, touchDependencies as Xe, IConfigService as Un } from "@univerjs/core";
5
+ import { IDrawingManagerService as K, IImageIoService as Dt, DrawingTypeEnum as k, ArrangeTypeEnum as ve, DRAWING_IMAGE_ALLOW_IMAGE_LIST as An, DRAWING_IMAGE_COUNT_LIMIT as mt, ImageUploadStatusType as He, DRAWING_IMAGE_ALLOW_SIZE as Nn, getImageSize as jn, DRAWING_IMAGE_WIDTH_LIMIT as ft, DRAWING_IMAGE_HEIGHT_LIMIT as pt, getDrawingShapeKeyByDrawingSearch as ze, UniverDrawingPlugin as xn } from "@univerjs/drawing";
6
+ import { ImageCropperObject as Ln, COMPONENT_IMAGE_POPUP_MENU as $n, OpenImageCropOperation as Bn, ImageResetSizeOperation as Wn, DrawingCommonPanel as Gn, DrawingRenderService as Vn, UniverDrawingUIPlugin as kn } from "@univerjs/drawing-ui";
7
+ import { IRenderManagerService as J, precisionTo as ne, getGroupState as Yn, transformObjectOutOfGroup as Fn, RENDER_CLASS_TYPE as de, Rect as wt, ObjectType as Xn, DRAWING_OBJECT_LAYER_INDEX as Hn, SHEET_VIEWPORT_KEY as zn } from "@univerjs/engine-render";
8
+ import { ISheetDrawingService as F, SetDrawingApplyMutation as P, DrawingApplyType as T, SheetDrawingAnchorType as y, UniverSheetsDrawingPlugin as Kn } from "@univerjs/sheets-drawing";
9
+ import { SheetCanvasPopManagerService as Jn, attachRangeWithCoord as Te, ISheetSelectionRenderService as pe, SheetSkeletonManagerService as q, getCurrentRangeDisable$ as Zn, COPY_TYPE as _t, PREDEFINED_HOOK_NAME as Se, virtualizeDiscreteRanges as qn, ISheetClipboardService as Qn, SheetPrintInterceptorService as er, VIEWPORT_KEY as tr, SetZoomRatioOperation as nr } from "@univerjs/sheets-ui";
10
+ import { ISidebarService as rr, IUIPartsService as ir, BuiltInUIPart as sr, ILocalFileService as or, IMessageService as ar, MenuItemType as Mt, getMenuHiddenObservable as bt, RibbonStartGroup as cr, KeyCode as le, ComponentManager as dr, IMenuManagerService as lr, IShortcutService as ur, CanvasFloatDomService as hr } from "@univerjs/ui";
11
+ import { takeUntil as vt, combineLatest as Ie, map as Ee, filter as ae, distinctUntilChanged as Ce, Subject as Ke, take as gr, BehaviorSubject as mr, switchMap as fr } from "rxjs";
12
+ import { SheetInterceptorService as at, getSheetCommandTarget as ce, SheetsSelectionsService as pr, WorkbookEditablePermission as tt, WorksheetEditPermission as Pe, RangeProtectionPermissionEditPoint as wr, WorkbookViewPermission as St, WorksheetViewPermission as Je, InsertRowCommand as yt, InsertColCommand as Ot, RemoveRowCommand as Pt, RemoveColCommand as Tt, DeleteRangeMoveLeftCommand as Et, DeleteRangeMoveUpCommand as Ut, InsertRangeMoveDownCommand as At, InsertRangeMoveRightCommand as Nt, DeltaRowHeightCommand as nt, SetRowHeightCommand as rt, DeltaColumnWidthCommand as jt, SetColWidthCommand as xt, SetRowHiddenCommand as Lt, SetSpecificRowsVisibleCommand as $t, SetSpecificColsVisibleCommand as Bt, SetColHiddenCommand as Wt, MoveColsCommand as Gt, MoveRowsCommand as Vt, MoveRangeCommand as kt, SetRowVisibleMutation as _r, SetRowHiddenMutation as vr, SetColVisibleMutation as Sr, SetColHiddenMutation as Ir, SetWorksheetRowHeightMutation as Cr, SetWorksheetColWidthMutation as Rr, SetWorksheetActiveOperation as Dr, SetFrozenMutation as Mr } from "@univerjs/sheets";
13
+ import Yt, { useEffect as ct, forwardRef as Ft, useRef as br, createElement as Xt, useState as it } from "react";
14
+ import { MessageType as Re, RadioGroup as yr, Radio as Ze } from "@univerjs/design";
15
+ const Or = "sheets-drawing-ui.config", Pr = {}, j = {
16
+ id: "sheet.operation.clear-drawing-transformer",
17
+ type: H.MUTATION,
18
+ handler: (i, e) => {
19
+ const n = i.get(J);
20
+ return e.forEach((t) => {
21
+ var r, s;
22
+ (s = (r = n.getRenderById(t)) == null ? void 0 : r.scene.getTransformer()) == null || s.debounceRefreshControls();
23
+ }), !0;
24
+ }
25
+ }, Ge = {
18
26
  id: "sheet.command.remove-sheet-image",
19
- type: CommandType.COMMAND,
20
- handler: /* @__PURE__ */ __name((accessor, params) => {
21
- var _a10, _b, _c;
22
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), sheetDrawingService = accessor.get(ISheetDrawingService);
23
- if (!params) return !1;
24
- const { drawings } = params, unitIds = [];
25
- drawings.forEach((param) => {
26
- const { unitId: unitId2 } = param;
27
- unitIds.push(unitId2);
27
+ type: H.COMMAND,
28
+ handler: (i, e) => {
29
+ var S, v, R;
30
+ const n = i.get(W), t = i.get(ue), r = i.get(at), s = i.get(F);
31
+ if (!e) return !1;
32
+ const { drawings: o } = e, d = [];
33
+ o.forEach((_) => {
34
+ const { unitId: C } = _;
35
+ d.push(C);
28
36
  });
29
- const jsonOp = sheetDrawingService.getBatchRemoveOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp, intercepted = sheetInterceptorService.onCommandExecute({ id: RemoveSheetDrawingCommand.id, params }), removeMutation = { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.REMOVE } }, undoRemoveMutation = { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.INSERT } };
30
- return sequenceExecute([...(_a10 = intercepted.preRedos) != null ? _a10 : [], removeMutation, ...intercepted.redos], commandService) ? (undoRedoService.pushUndoRedo({
31
- unitID: unitId,
37
+ const l = s.getBatchRemoveOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = r.onCommandExecute({ id: Ge.id, params: e }), f = { id: P.id, params: { unitId: g, subUnitId: c, op: h, objects: u, type: T.REMOVE } }, p = { id: P.id, params: { unitId: g, subUnitId: c, op: a, objects: u, type: T.INSERT } };
38
+ return It([...(S = m.preRedos) != null ? S : [], f, ...m.redos], n) ? (t.pushUndoRedo({
39
+ unitID: g,
32
40
  undoMutations: [
33
- ...(_b = intercepted.preUndos) != null ? _b : [],
34
- undoRemoveMutation,
35
- ...intercepted.undos,
36
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
41
+ ...(v = m.preUndos) != null ? v : [],
42
+ p,
43
+ ...m.undos,
44
+ { id: j.id, params: d }
37
45
  ],
38
46
  redoMutations: [
39
- ...(_c = intercepted.preRedos) != null ? _c : [],
40
- removeMutation,
41
- ...intercepted.redos,
42
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
47
+ ...(R = m.preRedos) != null ? R : [],
48
+ f,
49
+ ...m.redos,
50
+ { id: j.id, params: d }
43
51
  ]
44
52
  }), !0) : !1;
45
- }, "handler")
46
- }, COMPONENT_SHEET_DRAWING_PANEL = "COMPONENT_SHEET_DRAWING_PANEL", SidebarSheetDrawingOperation = {
53
+ }
54
+ }, Ht = "COMPONENT_SHEET_DRAWING_PANEL", zt = {
47
55
  id: "sidebar.operation.sheet-image",
48
- type: CommandType.COMMAND,
49
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
50
- const sidebarService = accessor.get(ISidebarService), localeService = accessor.get(LocaleService), univerInstanceService = accessor.get(IUniverInstanceService), drawingManagerService = accessor.get(IDrawingManagerService);
51
- if (!getSheetCommandTarget(univerInstanceService)) return !1;
52
- switch (params.value) {
56
+ type: H.COMMAND,
57
+ handler: async (i, e) => {
58
+ const n = i.get(rr), t = i.get(We), r = i.get(fe), s = i.get(K);
59
+ if (!ce(r)) return !1;
60
+ switch (e.value) {
53
61
  case "open":
54
- sidebarService.open({
55
- header: { title: localeService.t("sheetImage.panel.title") },
56
- children: { label: COMPONENT_SHEET_DRAWING_PANEL },
57
- onClose: /* @__PURE__ */ __name(() => {
58
- drawingManagerService.focusDrawing(null);
59
- }, "onClose"),
62
+ n.open({
63
+ header: { title: t.t("sheetImage.panel.title") },
64
+ children: { label: Ht },
65
+ onClose: () => {
66
+ s.focusDrawing(null);
67
+ },
60
68
  width: 360
61
69
  });
62
70
  break;
63
71
  case "close":
64
72
  default:
65
- sidebarService.close();
73
+ n.close();
66
74
  break;
67
75
  }
68
76
  return !0;
69
- }, "handler")
70
- }, EditSheetDrawingOperation = {
77
+ }
78
+ }, Kt = {
71
79
  id: "sheet.operation.edit-sheet-image",
72
- type: CommandType.OPERATION,
73
- handler: /* @__PURE__ */ __name((accessor, params) => {
74
- const drawingManagerService = accessor.get(IDrawingManagerService), commandService = accessor.get(ICommandService);
75
- return params == null ? !1 : (drawingManagerService.focusDrawing([params]), commandService.executeCommand(SidebarSheetDrawingOperation.id, { value: "open" }), !0);
76
- }, "handler")
77
- }, uploadLoading = "univer-upload-loading", uploadLoadingBody = "univer-upload-loading-body", uploadLoadingBodyAnimation = "univer-upload-loading-body-animation", univerCircleAnimation = "univer-UniverCircleAnimation", uploadLoadingBodyText = "univer-upload-loading-body-text", styles$1 = {
78
- uploadLoading,
79
- uploadLoadingBody,
80
- uploadLoadingBodyAnimation,
81
- univerCircleAnimation,
82
- uploadLoadingBodyText
83
- }, UploadLoading = /* @__PURE__ */ __name(() => {
84
- const imageIoService = useDependency(IImageIoService), localeService = useDependency(LocaleService), [remain, setRemain] = React.useState(0);
85
- return useEffect(() => {
86
- const sub = imageIoService.change$.subscribe((count) => {
87
- setRemain(count);
80
+ type: H.OPERATION,
81
+ handler: (i, e) => {
82
+ const n = i.get(K), t = i.get(W);
83
+ return e == null ? !1 : (n.focusDrawing([e]), t.executeCommand(zt.id, { value: "open" }), !0);
84
+ }
85
+ };
86
+ var Jt = { exports: {} }, Ve = {};
87
+ /**
88
+ * @license React
89
+ * react-jsx-runtime.production.min.js
90
+ *
91
+ * Copyright (c) Facebook, Inc. and its affiliates.
92
+ *
93
+ * This source code is licensed under the MIT license found in the
94
+ * LICENSE file in the root directory of this source tree.
95
+ */
96
+ var Tr = Yt, Er = Symbol.for("react.element"), Ur = Symbol.for("react.fragment"), Ar = Object.prototype.hasOwnProperty, Nr = Tr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, jr = { key: !0, ref: !0, __self: !0, __source: !0 };
97
+ function Zt(i, e, n) {
98
+ var t, r = {}, s = null, o = null;
99
+ n !== void 0 && (s = "" + n), e.key !== void 0 && (s = "" + e.key), e.ref !== void 0 && (o = e.ref);
100
+ for (t in e) Ar.call(e, t) && !jr.hasOwnProperty(t) && (r[t] = e[t]);
101
+ if (i && i.defaultProps) for (t in e = i.defaultProps, e) r[t] === void 0 && (r[t] = e[t]);
102
+ return { $$typeof: Er, type: i, key: s, ref: o, props: r, _owner: Nr.current };
103
+ }
104
+ Ve.Fragment = Ur;
105
+ Ve.jsx = Zt;
106
+ Ve.jsxs = Zt;
107
+ Jt.exports = Ve;
108
+ var $ = Jt.exports;
109
+ const xr = "univer-upload-loading", Lr = "univer-upload-loading-body", $r = "univer-upload-loading-body-animation", Br = "univer-UniverCircleAnimation", Wr = "univer-upload-loading-body-text", De = {
110
+ uploadLoading: xr,
111
+ uploadLoadingBody: Lr,
112
+ uploadLoadingBodyAnimation: $r,
113
+ univerCircleAnimation: Br,
114
+ uploadLoadingBodyText: Wr
115
+ }, Gr = () => {
116
+ const i = oe(Dt), e = oe(We), [n, t] = Yt.useState(0);
117
+ return ct(() => {
118
+ const r = i.change$.subscribe((s) => {
119
+ t(s);
88
120
  });
89
121
  return () => {
90
- sub.unsubscribe();
122
+ r.unsubscribe();
91
123
  };
92
- }, [imageIoService]), /* @__PURE__ */ React.createElement("div", { style: { display: remain > 0 ? "block" : "none" }, className: styles$1.uploadLoading }, /* @__PURE__ */ React.createElement("div", { className: styles$1.uploadLoadingBody }, /* @__PURE__ */ React.createElement("div", { className: styles$1.uploadLoadingBodyAnimation }), /* @__PURE__ */ React.createElement("div", { className: styles$1.uploadLoadingBodyText }, `${localeService.t("uploadLoading.loading")}: ${remain}`)));
93
- }, "UploadLoading");
94
- var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
95
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
96
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
97
- return kind && result && __defProp$8(target, key, result), result;
98
- }, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), _a;
99
- let DrawingPopupMenuController = (_a = class extends RxDisposable {
100
- constructor(_injector, _drawingManagerService, _canvasPopManagerService, _renderManagerService, _univerInstanceService, _contextService, _uiPartsService) {
124
+ }, [i]), /* @__PURE__ */ $.jsx("div", { style: { display: n > 0 ? "block" : "none" }, className: De.uploadLoading, children: /* @__PURE__ */ $.jsxs("div", { className: De.uploadLoadingBody, children: [
125
+ /* @__PURE__ */ $.jsx("div", { className: De.uploadLoadingBodyAnimation }),
126
+ /* @__PURE__ */ $.jsx("div", { className: De.uploadLoadingBodyText, children: `${e.t("uploadLoading.loading")}: ${n}` })
127
+ ] }) });
128
+ };
129
+ var Vr = Object.defineProperty, kr = Object.getOwnPropertyDescriptor, Yr = (i, e, n, t) => {
130
+ for (var r = t > 1 ? void 0 : t ? kr(e, n) : e, s = i.length - 1, o; s >= 0; s--)
131
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
132
+ return t && r && Vr(e, n, r), r;
133
+ }, ie = (i, e) => (n, t) => e(n, t, i);
134
+ let Ue = class extends fn {
135
+ constructor(e, n, t, r, s, o, d) {
101
136
  super();
102
- __publicField(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
103
- this._injector = _injector, this._drawingManagerService = _drawingManagerService, this._canvasPopManagerService = _canvasPopManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._contextService = _contextService, this._uiPartsService = _uiPartsService, this._init();
137
+ V(this, "_initImagePopupMenu", /* @__PURE__ */ new Set());
138
+ this._injector = e, this._drawingManagerService = n, this._canvasPopManagerService = t, this._renderManagerService = r, this._univerInstanceService = s, this._contextService = o, this._uiPartsService = d, this._init();
104
139
  }
105
140
  _init() {
106
- this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._create(workbook)), this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).pipe(takeUntil(this.dispose$)).subscribe((workbook) => this._dispose(workbook)), this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => this._create(workbook)), this._uiPartsService.registerComponent(BuiltInUIPart.CONTENT, () => connectInjector(UploadLoading, this._injector));
141
+ this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(vt(this.dispose$)).subscribe((e) => this._create(e)), this._univerInstanceService.getTypeOfUnitDisposed$(Y.UNIVER_SHEET).pipe(vt(this.dispose$)).subscribe((e) => this._dispose(e)), this._univerInstanceService.getAllUnitsForType(Y.UNIVER_SHEET).forEach((e) => this._create(e)), this._uiPartsService.registerComponent(sr.CONTENT, () => pn(Gr, this._injector));
107
142
  }
108
- _dispose(workbook) {
109
- const unitId = workbook.getUnitId();
110
- this._renderManagerService.removeRender(unitId);
143
+ _dispose(e) {
144
+ const n = e.getUnitId();
145
+ this._renderManagerService.removeRender(n);
111
146
  }
112
- _create(workbook) {
113
- if (!workbook)
147
+ _create(e) {
148
+ if (!e)
114
149
  return;
115
- const unitId = workbook.getUnitId();
116
- this._renderManagerService.has(unitId) && !this._initImagePopupMenu.has(unitId) && (this._popupMenuListener(unitId), this._initImagePopupMenu.add(unitId));
150
+ const n = e.getUnitId();
151
+ this._renderManagerService.has(n) && !this._initImagePopupMenu.has(n) && (this._popupMenuListener(n), this._initImagePopupMenu.add(n));
117
152
  }
118
- _hasCropObject(scene) {
119
- const objects = scene.getAllObjectsByOrder();
120
- for (const object of objects)
121
- if (object instanceof ImageCropperObject)
153
+ _hasCropObject(e) {
154
+ const n = e.getAllObjectsByOrder();
155
+ for (const t of n)
156
+ if (t instanceof Ln)
122
157
  return !0;
123
158
  return !1;
124
159
  }
125
- _popupMenuListener(unitId) {
126
- var _a10;
127
- const scene = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.scene;
128
- if (!scene)
160
+ _popupMenuListener(e) {
161
+ var s;
162
+ const n = (s = this._renderManagerService.getRenderById(e)) == null ? void 0 : s.scene;
163
+ if (!n)
129
164
  return;
130
- const transformer = scene.getTransformerByCreate();
131
- if (!transformer)
165
+ const t = n.getTransformerByCreate();
166
+ if (!t)
132
167
  return;
133
- let singletonPopupDisposer;
168
+ let r;
134
169
  this.disposeWithMe(
135
- toDisposable(
136
- transformer.createControl$.subscribe(() => {
137
- if (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._hasCropObject(scene))
170
+ wn(
171
+ t.createControl$.subscribe(() => {
172
+ if (this._contextService.setContextValue(me, !0), this._hasCropObject(n))
138
173
  return;
139
- const selectedObjects = transformer.getSelectedObjectMap();
140
- if (selectedObjects.size > 1) {
141
- singletonPopupDisposer == null || singletonPopupDisposer.dispose();
174
+ const o = t.getSelectedObjectMap();
175
+ if (o.size > 1) {
176
+ r == null || r.dispose();
142
177
  return;
143
178
  }
144
- const object = selectedObjects.values().next().value;
145
- if (!object)
179
+ const d = o.values().next().value;
180
+ if (!d)
146
181
  return;
147
- const oKey = object.oKey, drawingParam = this._drawingManagerService.getDrawingOKey(oKey);
148
- if (!drawingParam)
182
+ const l = d.oKey, g = this._drawingManagerService.getDrawingOKey(l);
183
+ if (!g)
149
184
  return;
150
- const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawingParam, data = drawingParam.data;
151
- data && data.disablePopup || (singletonPopupDisposer == null || singletonPopupDisposer.dispose(), singletonPopupDisposer = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(object, {
152
- componentKey: COMPONENT_IMAGE_POPUP_MENU,
185
+ const { unitId: c, subUnitId: a, drawingId: h, drawingType: u } = g, m = g.data;
186
+ m && m.disablePopup || (r == null || r.dispose(), r = this.disposeWithMe(this._canvasPopManagerService.attachPopupToObject(d, {
187
+ componentKey: $n,
153
188
  direction: "horizontal",
154
189
  offset: [2, 0],
155
190
  extraProps: {
156
- menuItems: this._getImageMenuItems(unitId2, subUnitId, drawingId, drawingType)
191
+ menuItems: this._getImageMenuItems(c, a, h, u)
157
192
  }
158
193
  })), this._drawingManagerService.focusDrawing([{
159
- unitId: unitId2,
160
- subUnitId,
161
- drawingId
194
+ unitId: c,
195
+ subUnitId: a,
196
+ drawingId: h
162
197
  }]));
163
198
  })
164
199
  )
165
200
  ), this.disposeWithMe(
166
- transformer.clearControl$.subscribe(() => {
167
- singletonPopupDisposer == null || singletonPopupDisposer.dispose(), this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._drawingManagerService.focusDrawing(null);
201
+ t.clearControl$.subscribe(() => {
202
+ r == null || r.dispose(), this._contextService.setContextValue(me, !1), this._drawingManagerService.focusDrawing(null);
168
203
  })
169
204
  ), this.disposeWithMe(
170
- transformer.changing$.subscribe(() => {
171
- singletonPopupDisposer == null || singletonPopupDisposer.dispose();
205
+ t.changing$.subscribe(() => {
206
+ r == null || r.dispose();
172
207
  })
173
208
  );
174
209
  }
175
- _getImageMenuItems(unitId, subUnitId, drawingId, drawingType) {
210
+ _getImageMenuItems(e, n, t, r) {
176
211
  return [
177
212
  {
178
213
  label: "image-popup.edit",
179
214
  index: 0,
180
- commandId: EditSheetDrawingOperation.id,
181
- commandParams: { unitId, subUnitId, drawingId },
182
- disable: drawingType === DrawingTypeEnum.DRAWING_DOM
215
+ commandId: Kt.id,
216
+ commandParams: { unitId: e, subUnitId: n, drawingId: t },
217
+ disable: r === k.DRAWING_DOM
183
218
  },
184
219
  {
185
220
  label: "image-popup.delete",
186
221
  index: 1,
187
- commandId: RemoveSheetDrawingCommand.id,
188
- commandParams: { unitId, drawings: [{ unitId, subUnitId, drawingId }] },
222
+ commandId: Ge.id,
223
+ commandParams: { unitId: e, drawings: [{ unitId: e, subUnitId: n, drawingId: t }] },
189
224
  disable: !1
190
225
  },
191
226
  {
192
227
  label: "image-popup.crop",
193
228
  index: 2,
194
- commandId: OpenImageCropOperation.id,
195
- commandParams: { unitId, subUnitId, drawingId },
196
- disable: drawingType === DrawingTypeEnum.DRAWING_DOM
229
+ commandId: Bn.id,
230
+ commandParams: { unitId: e, subUnitId: n, drawingId: t },
231
+ disable: r === k.DRAWING_DOM
197
232
  },
198
233
  {
199
234
  label: "image-popup.reset",
200
235
  index: 3,
201
- commandId: ImageResetSizeOperation.id,
202
- commandParams: [{ unitId, subUnitId, drawingId }],
203
- disable: drawingType === DrawingTypeEnum.DRAWING_DOM
236
+ commandId: Wn.id,
237
+ commandParams: [{ unitId: e, subUnitId: n, drawingId: t }],
238
+ disable: r === k.DRAWING_DOM
204
239
  }
205
240
  ];
206
241
  }
207
- }, __name(_a, "DrawingPopupMenuController"), _a);
208
- DrawingPopupMenuController = __decorateClass$8([
209
- __decorateParam$8(0, Inject(Injector)),
210
- __decorateParam$8(1, IDrawingManagerService),
211
- __decorateParam$8(2, Inject(SheetCanvasPopManagerService)),
212
- __decorateParam$8(3, IRenderManagerService),
213
- __decorateParam$8(4, IUniverInstanceService),
214
- __decorateParam$8(5, IContextService),
215
- __decorateParam$8(6, Inject(IUIPartsService))
216
- ], DrawingPopupMenuController);
217
- function drawingPositionToTransform(position, selectionRenderService, sheetSkeletonManagerService) {
218
- const { from, to, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = position, { column: fromColumn, columnOffset: fromColumnOffset, row: fromRow, rowOffset: fromRowOffset } = from, { column: toColumn, columnOffset: toColumnOffset, row: toRow, rowOffset: toRowOffset } = to, skeleton = sheetSkeletonManagerService.getCurrentSkeleton(), startSelectionCell = attachRangeWithCoord(skeleton, {
219
- startColumn: fromColumn,
220
- endColumn: fromColumn,
221
- startRow: fromRow,
222
- endRow: fromRow
242
+ };
243
+ Ue = Yr([
244
+ ie(0, x(Ct)),
245
+ ie(1, K),
246
+ ie(2, x(Jn)),
247
+ ie(3, J),
248
+ ie(4, fe),
249
+ ie(5, Rt),
250
+ ie(6, x(ir))
251
+ ], Ue);
252
+ function B(i, e, n) {
253
+ const { from: t, to: r, flipY: s = !1, flipX: o = !1, angle: d = 0, skewX: l = 0, skewY: g = 0 } = i, { column: c, columnOffset: a, row: h, rowOffset: u } = t, { column: m, columnOffset: f, row: p, rowOffset: I } = r, S = n.getCurrentSkeleton(), v = Te(S, {
254
+ startColumn: c,
255
+ endColumn: c,
256
+ startRow: h,
257
+ endRow: h
223
258
  });
224
- if (startSelectionCell == null)
259
+ if (v == null)
225
260
  return;
226
- const endSelectionCell = attachRangeWithCoord(skeleton, {
227
- startColumn: toColumn,
228
- endColumn: toColumn,
229
- startRow: toRow,
230
- endRow: toRow
261
+ const R = Te(S, {
262
+ startColumn: m,
263
+ endColumn: m,
264
+ startRow: p,
265
+ endRow: p
231
266
  });
232
- if (endSelectionCell == null)
267
+ if (R == null)
233
268
  return;
234
- const { startX: startSelectionX, startY: startSelectionY } = startSelectionCell, { startX: endSelectionX, startY: endSelectionY } = endSelectionCell;
235
- let left = precisionTo(startSelectionX + fromColumnOffset, 1), top = precisionTo(startSelectionY + fromRowOffset, 1), width = precisionTo(endSelectionX + toColumnOffset - left, 1), height = precisionTo(endSelectionY + toRowOffset - top, 1);
236
- startSelectionCell.startX === endSelectionCell.endX && (width = 0), startSelectionCell.startY === endSelectionCell.endY && (height = 0);
237
- const sheetWidth = skeleton.rowHeaderWidth + skeleton.columnTotalWidth, sheetHeight = skeleton.columnHeaderHeight + skeleton.rowTotalHeight;
238
- return left + width > sheetWidth && (left = sheetWidth - width), top + height > sheetHeight && (top = sheetHeight - height), {
239
- flipY,
240
- flipX,
241
- angle,
242
- skewX,
243
- skewY,
244
- left,
245
- top,
246
- width,
247
- height
269
+ const { startX: _, startY: C } = v, { startX: w, startY: O } = R;
270
+ let b = ne(_ + a, 1), A = ne(C + u, 1), E = ne(w + f - b, 1), M = ne(O + I - A, 1);
271
+ v.startX === R.endX && (E = 0), v.startY === R.endY && (M = 0);
272
+ const D = S.rowHeaderWidth + S.columnTotalWidth, U = S.columnHeaderHeight + S.rowTotalHeight;
273
+ return b + E > D && (b = D - E), A + M > U && (A = U - M), {
274
+ flipY: s,
275
+ flipX: o,
276
+ angle: d,
277
+ skewX: l,
278
+ skewY: g,
279
+ left: b,
280
+ top: A,
281
+ width: E,
282
+ height: M
248
283
  };
249
284
  }
250
- __name(drawingPositionToTransform, "drawingPositionToTransform");
251
- function transformToDrawingPosition(transform, selectionRenderService) {
252
- const { left = 0, top = 0, width = 0, height = 0, flipY = !1, flipX = !1, angle = 0, skewX = 0, skewY = 0 } = transform, startSelectionCell = selectionRenderService.getSelectionCellByPosition(left, top);
253
- if (startSelectionCell == null)
285
+ function N(i, e) {
286
+ const { left: n = 0, top: t = 0, width: r = 0, height: s = 0, flipY: o = !1, flipX: d = !1, angle: l = 0, skewX: g = 0, skewY: c = 0 } = i, a = e.getSelectionCellByPosition(n, t);
287
+ if (a == null)
254
288
  return;
255
- const from = {
256
- column: startSelectionCell.actualColumn,
257
- columnOffset: precisionTo(left - startSelectionCell.startX, 1),
258
- row: startSelectionCell.actualRow,
259
- rowOffset: precisionTo(top - startSelectionCell.startY, 1)
260
- }, endSelectionCell = selectionRenderService.getSelectionCellByPosition(left + width, top + height);
261
- if (endSelectionCell == null)
289
+ const h = {
290
+ column: a.actualColumn,
291
+ columnOffset: ne(n - a.startX, 1),
292
+ row: a.actualRow,
293
+ rowOffset: ne(t - a.startY, 1)
294
+ }, u = e.getSelectionCellByPosition(n + r, t + s);
295
+ if (u == null)
262
296
  return;
263
- const to = {
264
- column: endSelectionCell.actualColumn,
265
- columnOffset: precisionTo(left + width - endSelectionCell.startX, 1),
266
- row: endSelectionCell.actualRow,
267
- rowOffset: precisionTo(top + height - endSelectionCell.startY, 1)
297
+ const m = {
298
+ column: u.actualColumn,
299
+ columnOffset: ne(n + r - u.startX, 1),
300
+ row: u.actualRow,
301
+ rowOffset: ne(t + s - u.startY, 1)
268
302
  };
269
303
  return {
270
- flipY,
271
- flipX,
272
- angle,
273
- skewX,
274
- skewY,
275
- from,
276
- to
304
+ flipY: o,
305
+ flipX: d,
306
+ angle: l,
307
+ skewX: g,
308
+ skewY: c,
309
+ from: h,
310
+ to: m
277
311
  };
278
312
  }
279
- __name(transformToDrawingPosition, "transformToDrawingPosition");
280
- var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
281
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
282
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
283
- return kind && result && __defProp$7(target, key, result), result;
284
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a2;
285
- let SheetsDrawingRenderController = (_a2 = class extends Disposable {
286
- constructor(_context, _sheetDrawingService, _drawingManagerService, _sheetSelectionRenderService, _sheetSkeletonManagerService) {
287
- super(), this._context = _context, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._sheetSelectionRenderService = _sheetSelectionRenderService, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._init();
313
+ var Fr = Object.defineProperty, Xr = Object.getOwnPropertyDescriptor, Hr = (i, e, n, t) => {
314
+ for (var r = t > 1 ? void 0 : t ? Xr(e, n) : e, s = i.length - 1, o; s >= 0; s--)
315
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
316
+ return t && r && Fr(e, n, r), r;
317
+ }, Me = (i, e) => (n, t) => e(n, t, i);
318
+ let st = class extends re {
319
+ constructor(i, e, n, t, r) {
320
+ super(), this._context = i, this._sheetDrawingService = e, this._drawingManagerService = n, this._sheetSelectionRenderService = t, this._sheetSkeletonManagerService = r, this._init();
288
321
  }
289
322
  _init() {
290
323
  this._drawingInitializeListener();
291
324
  }
292
325
  _drawingInitializeListener() {
293
326
  this._sheetDrawingService.initializeNotification(this._context.unitId);
294
- const data = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
295
- for (const subUnit in data) {
296
- const subUnitData = data[subUnit];
297
- for (const drawingId in subUnitData.data) {
298
- const drawingData = subUnitData.data[drawingId];
299
- drawingData.transform = drawingPositionToTransform(drawingData.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);
327
+ const i = this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId);
328
+ for (const e in i) {
329
+ const n = i[e];
330
+ for (const t in n.data) {
331
+ const r = n.data[t];
332
+ r.transform = B(r.sheetTransform, this._sheetSelectionRenderService, this._sheetSkeletonManagerService);
300
333
  }
301
334
  }
302
335
  this._drawingManagerService.registerDrawingData(this._context.unitId, this._sheetDrawingService.getDrawingDataForUnit(this._context.unitId)), this._drawingManagerService.initializeNotification(this._context.unitId);
303
336
  }
304
- }, __name(_a2, "SheetsDrawingRenderController"), _a2);
305
- SheetsDrawingRenderController = __decorateClass$7([
306
- __decorateParam$7(1, ISheetDrawingService),
307
- __decorateParam$7(2, IDrawingManagerService),
308
- __decorateParam$7(3, Inject(ISheetSelectionRenderService)),
309
- __decorateParam$7(4, Inject(SheetSkeletonManagerService))
310
- ], SheetsDrawingRenderController);
311
- var __assign = function() {
312
- return __assign = Object.assign || function(t) {
313
- for (var s, i = 1, n = arguments.length; i < n; i++) {
314
- s = arguments[i];
315
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
337
+ };
338
+ st = Hr([
339
+ Me(1, F),
340
+ Me(2, K),
341
+ Me(3, x(pe)),
342
+ Me(4, x(q))
343
+ ], st);
344
+ var X = function() {
345
+ return X = Object.assign || function(i) {
346
+ for (var e, n = 1, t = arguments.length; n < t; n++) {
347
+ e = arguments[n];
348
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && (i[r] = e[r]);
316
349
  }
317
- return t;
318
- }, __assign.apply(this, arguments);
319
- }, __rest = function(s, e) {
320
- var t = {};
321
- for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
322
- if (s != null && typeof Object.getOwnPropertySymbols == "function")
323
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
324
- e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
325
- return t;
326
- }, IconBase = forwardRef(function(props, ref) {
327
- var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
328
- return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
350
+ return i;
351
+ }, X.apply(this, arguments);
352
+ }, zr = function(i, e) {
353
+ var n = {};
354
+ for (var t in i) Object.prototype.hasOwnProperty.call(i, t) && e.indexOf(t) < 0 && (n[t] = i[t]);
355
+ if (i != null && typeof Object.getOwnPropertySymbols == "function")
356
+ for (var r = 0, t = Object.getOwnPropertySymbols(i); r < t.length; r++)
357
+ e.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(i, t[r]) && (n[t[r]] = i[t[r]]);
358
+ return n;
359
+ }, qt = Ft(function(i, e) {
360
+ var n = i.icon, t = i.id, r = i.className, s = i.extend, o = zr(i, ["icon", "id", "className", "extend"]), d = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), l = br("_".concat(Zr()));
361
+ return Qt(n, "".concat(t), { defIds: n.defIds, idSuffix: l.current }, X({ ref: e, className: d }, o), s);
329
362
  });
330
- function render(node, id, runtimeProps, rootProps, extend) {
331
- return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
332
- return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
363
+ function Qt(i, e, n, t, r) {
364
+ return Xt(i.tag, X(X({ key: e }, Kr(i, n, r)), t), (Jr(i, n).children || []).map(function(s, o) {
365
+ return Qt(s, "".concat(e, "-").concat(i.tag, "-").concat(o), n, void 0, r);
333
366
  }));
334
367
  }
335
- __name(render, "render");
336
- function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
337
- var attrs = __assign({}, node.attrs);
338
- extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
339
- var defIds = runtimeProps.defIds;
340
- return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a10) {
341
- var key = _a10[0], value = _a10[1];
342
- typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
343
- })), attrs;
368
+ function Kr(i, e, n) {
369
+ var t = X({}, i.attrs);
370
+ n != null && n.colorChannel1 && t.fill === "colorChannel1" && (t.fill = n.colorChannel1);
371
+ var r = e.defIds;
372
+ return !r || r.length === 0 || (i.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + e.idSuffix), Object.entries(t).forEach(function(s) {
373
+ var o = s[0], d = s[1];
374
+ typeof d == "string" && (t[o] = d.replace(/url\(#(.*)\)/, "url(#$1".concat(e.idSuffix, ")")));
375
+ })), t;
344
376
  }
345
- __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
346
- function replaceRuntimeIdsInDefs(node, runtimeProps) {
347
- var _a10, defIds = runtimeProps.defIds;
348
- return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a10 = node.children) === null || _a10 === void 0) && _a10.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
349
- return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
350
- }) }) : node;
377
+ function Jr(i, e) {
378
+ var n, t = e.defIds;
379
+ return !t || t.length === 0 ? i : i.tag === "defs" && (!((n = i.children) === null || n === void 0) && n.length) ? X(X({}, i), { children: i.children.map(function(r) {
380
+ return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? X(X({}, r), { attrs: X(X({}, r.attrs), { id: r.attrs.id + e.idSuffix }) }) : r;
381
+ }) }) : i;
351
382
  }
352
- __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
353
- function generateShortUuid() {
383
+ function Zr() {
354
384
  return Math.random().toString(36).substring(2, 8);
355
385
  }
356
- __name(generateShortUuid, "generateShortUuid");
357
- IconBase.displayName = "UniverIcon";
358
- var element = { 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" } }] }, AddImageSingle = forwardRef(function(props, ref) {
359
- return createElement(IconBase, Object.assign({}, props, {
386
+ qt.displayName = "UniverIcon";
387
+ var qr = { 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" } }] }, en = Ft(function(i, e) {
388
+ return Xt(qt, Object.assign({}, i, {
360
389
  id: "add-image-single",
361
- ref,
362
- icon: element
390
+ ref: e,
391
+ icon: qr
363
392
  }));
364
393
  });
365
- AddImageSingle.displayName = "AddImageSingle";
366
- const DeleteDrawingsCommand = {
394
+ en.displayName = "AddImageSingle";
395
+ const tn = {
367
396
  id: "sheet.command.delete-drawing",
368
- type: CommandType.COMMAND,
369
- handler: /* @__PURE__ */ __name((accessor) => {
370
- const commandService = accessor.get(ICommandService), drawings = accessor.get(ISheetDrawingService).getFocusDrawings();
371
- if (drawings.length === 0)
397
+ type: H.COMMAND,
398
+ handler: (i) => {
399
+ const e = i.get(W), t = i.get(F).getFocusDrawings();
400
+ if (t.length === 0)
372
401
  return !1;
373
- const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
374
- const { unitId: unitId2, subUnitId, drawingId, drawingType } = drawing;
402
+ const r = t[0].unitId, s = t.map((o) => {
403
+ const { unitId: d, subUnitId: l, drawingId: g, drawingType: c } = o;
375
404
  return {
376
- unitId: unitId2,
377
- subUnitId,
378
- drawingId,
379
- drawingType
405
+ unitId: d,
406
+ subUnitId: l,
407
+ drawingId: g,
408
+ drawingType: c
380
409
  };
381
410
  });
382
- return commandService.executeCommand(RemoveSheetDrawingCommand.id, {
383
- unitId,
384
- drawings: newDrawings
411
+ return e.executeCommand(Ge.id, {
412
+ unitId: r,
413
+ drawings: s
385
414
  });
386
- }, "handler")
415
+ }
387
416
  };
388
- function ungroupToGroup(ungroupParams) {
389
- const newGroupParams = [];
390
- return ungroupParams.forEach((ungroupParam) => {
391
- const { parent, children } = ungroupParam, { unitId, subUnitId, drawingId: groupId } = parent, groupTransform = getGroupState(0, 0, children.map((o) => o.transform || {})), newChildren = children.map((drawing) => {
392
- const transform = drawing.transform || { left: 0, top: 0 }, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = drawing;
417
+ function Qr(i) {
418
+ const e = [];
419
+ return i.forEach((n) => {
420
+ const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: d } = t, l = Yn(0, 0, r.map((a) => a.transform || {})), g = r.map((a) => {
421
+ const h = a.transform || { left: 0, top: 0 }, { unitId: u, subUnitId: m, drawingId: f } = a;
393
422
  return {
394
- unitId: unitId2,
395
- subUnitId: subUnitId2,
396
- drawingId,
423
+ unitId: u,
424
+ subUnitId: m,
425
+ drawingId: f,
397
426
  transform: {
398
- ...transform,
399
- left: transform.left - groupTransform.left,
400
- top: transform.top - groupTransform.top
427
+ ...h,
428
+ left: h.left - l.left,
429
+ top: h.top - l.top
401
430
  },
402
- groupId
431
+ groupId: d
403
432
  };
404
- }), groupParam = {
405
- unitId,
406
- subUnitId,
407
- drawingId: groupId,
408
- drawingType: DrawingTypeEnum.DRAWING_GROUP,
409
- transform: groupTransform
433
+ }), c = {
434
+ unitId: s,
435
+ subUnitId: o,
436
+ drawingId: d,
437
+ drawingType: k.DRAWING_GROUP,
438
+ transform: l
410
439
  };
411
- newGroupParams.push({
412
- parent: groupParam,
413
- children: newChildren
440
+ e.push({
441
+ parent: c,
442
+ children: g
414
443
  });
415
- }), newGroupParams;
444
+ }), e;
416
445
  }
417
- __name(ungroupToGroup, "ungroupToGroup");
418
- function groupToUngroup(groupParams) {
419
- const newGroupParams = [];
420
- return groupParams.forEach((groupParam) => {
421
- const { parent, children } = groupParam, { unitId, subUnitId, drawingId: groupId, transform: groupTransform = { width: 0, height: 0 } } = parent;
422
- if (groupTransform == null)
446
+ function ei(i) {
447
+ const e = [];
448
+ return i.forEach((n) => {
449
+ const { parent: t, children: r } = n, { unitId: s, subUnitId: o, drawingId: d, transform: l = { width: 0, height: 0 } } = t;
450
+ if (l == null)
423
451
  return;
424
- const newChildren = children.map((object) => {
425
- const { transform } = object, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = object, newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
452
+ const g = r.map((a) => {
453
+ const { transform: h } = a, { unitId: u, subUnitId: m, drawingId: f } = a, p = Fn(h || {}, l, l.width || 0, l.height || 0);
426
454
  return {
427
- unitId: unitId2,
428
- subUnitId: subUnitId2,
429
- drawingId,
430
- transform: newTransform,
455
+ unitId: u,
456
+ subUnitId: m,
457
+ drawingId: f,
458
+ transform: p,
431
459
  groupId: void 0
432
460
  };
433
- }), ungroupParam = {
434
- unitId,
435
- subUnitId,
436
- drawingId: groupId,
437
- drawingType: DrawingTypeEnum.DRAWING_GROUP,
461
+ }), c = {
462
+ unitId: s,
463
+ subUnitId: o,
464
+ drawingId: d,
465
+ drawingType: k.DRAWING_GROUP,
438
466
  transform: {
439
467
  left: 0,
440
468
  top: 0
441
469
  }
442
470
  };
443
- newGroupParams.push({
444
- parent: ungroupParam,
445
- children: newChildren
471
+ e.push({
472
+ parent: c,
473
+ children: g
446
474
  });
447
- }), newGroupParams;
475
+ }), e;
448
476
  }
449
- __name(groupToUngroup, "groupToUngroup");
450
- const GroupSheetDrawingCommand = {
477
+ const nn = {
451
478
  id: "sheet.command.group-sheet-image",
452
- type: CommandType.COMMAND,
453
- handler: /* @__PURE__ */ __name((accessor, params) => {
454
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
455
- if (!params) return !1;
456
- const unitIds = [];
457
- params.forEach(({ parent, children }) => {
458
- unitIds.push(parent.unitId), children.forEach((child) => {
459
- unitIds.push(child.unitId);
479
+ type: H.COMMAND,
480
+ handler: (i, e) => {
481
+ const n = i.get(W), t = i.get(ue), r = i.get(F);
482
+ if (!e) return !1;
483
+ const s = [];
484
+ e.forEach(({ parent: u, children: m }) => {
485
+ s.push(u.unitId), m.forEach((f) => {
486
+ s.push(f.unitId);
460
487
  });
461
488
  });
462
- const jsonOp = sheetDrawingService.getGroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
463
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP }) ? (undoRedoService.pushUndoRedo({
464
- unitID: unitId,
489
+ const o = r.getGroupDrawingOp(e), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
490
+ return n.syncExecuteCommand(P.id, { op: c, unitId: d, subUnitId: l, objects: a, type: T.GROUP }) ? (t.pushUndoRedo({
491
+ unitID: d,
492
+ undoMutations: [
493
+ { id: P.id, params: { op: g, unitId: d, subUnitId: l, objects: ei(a), type: T.UNGROUP } },
494
+ { id: j.id, params: s }
495
+ ],
496
+ redoMutations: [
497
+ { id: P.id, params: { op: c, unitId: d, subUnitId: l, objects: a, type: T.GROUP } },
498
+ { id: j.id, params: s }
499
+ ]
500
+ }), !0) : !1;
501
+ }
502
+ }, ke = {
503
+ id: "sheet.command.insert-sheet-image",
504
+ type: H.COMMAND,
505
+ handler: (i, e) => {
506
+ var S, v, R;
507
+ const n = i.get(W), t = i.get(ue), r = i.get(F), s = i.get(at);
508
+ if (!e) return !1;
509
+ const o = e.drawings, d = o.map((_) => _.unitId), l = r.getBatchAddOp(o), { unitId: g, subUnitId: c, undo: a, redo: h, objects: u } = l, m = s.onCommandExecute({ id: ke.id, params: e }), f = { id: P.id, params: { op: h, unitId: g, subUnitId: c, objects: u, type: T.INSERT } }, p = { id: P.id, params: { op: a, unitId: g, subUnitId: c, objects: u, type: T.REMOVE } };
510
+ return It([...(S = m.preRedos) != null ? S : [], f, ...m.redos], n) ? (t.pushUndoRedo({
511
+ unitID: g,
465
512
  undoMutations: [
466
- { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: groupToUngroup(objects), type: DrawingApplyType.UNGROUP } },
467
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
513
+ ...(v = m.preUndos) != null ? v : [],
514
+ p,
515
+ ...m.undos,
516
+ { id: j.id, params: d }
468
517
  ],
469
518
  redoMutations: [
470
- { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.GROUP } },
471
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
519
+ ...(R = m.preRedos) != null ? R : [],
520
+ f,
521
+ ...m.redos,
522
+ { id: j.id, params: d }
472
523
  ]
473
524
  }), !0) : !1;
474
- }, "handler")
475
- }, SetDrawingArrangeCommand = {
525
+ }
526
+ }, rn = {
476
527
  id: "sheet.command.set-drawing-arrange",
477
- type: CommandType.COMMAND,
478
- handler: /* @__PURE__ */ __name((accessor, params) => {
479
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService);
480
- if (!params) return !1;
481
- const sheetDrawingService = accessor.get(ISheetDrawingService), { unitId, subUnitId, drawingIds, arrangeType } = params, drawingOrderMapParam = { unitId, subUnitId, drawingIds };
482
- let jsonOp;
483
- if (arrangeType === ArrangeTypeEnum.forward ? jsonOp = sheetDrawingService.getForwardDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.backward ? jsonOp = sheetDrawingService.getBackwardDrawingOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.front ? jsonOp = sheetDrawingService.getFrontDrawingsOp(drawingOrderMapParam) : arrangeType === ArrangeTypeEnum.back && (jsonOp = sheetDrawingService.getBackDrawingsOp(drawingOrderMapParam)), jsonOp == null)
528
+ type: H.COMMAND,
529
+ handler: (i, e) => {
530
+ const n = i.get(W), t = i.get(ue);
531
+ if (!e) return !1;
532
+ const r = i.get(F), { unitId: s, subUnitId: o, drawingIds: d, arrangeType: l } = e, g = { unitId: s, subUnitId: o, drawingIds: d };
533
+ let c;
534
+ if (l === ve.forward ? c = r.getForwardDrawingsOp(g) : l === ve.backward ? c = r.getBackwardDrawingOp(g) : l === ve.front ? c = r.getFrontDrawingsOp(g) : l === ve.back && (c = r.getBackDrawingsOp(g)), c == null)
484
535
  return !1;
485
- const { objects, redo, undo } = jsonOp;
486
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE }) ? (undoRedoService.pushUndoRedo({
487
- unitID: unitId,
536
+ const { objects: a, redo: h, undo: u } = c;
537
+ return n.syncExecuteCommand(P.id, { op: h, unitId: s, subUnitId: o, objects: a, type: T.ARRANGE }) ? (t.pushUndoRedo({
538
+ unitID: s,
488
539
  undoMutations: [
489
- { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
540
+ { id: P.id, params: { op: u, unitId: s, subUnitId: o, objects: a, type: T.ARRANGE } }
490
541
  ],
491
542
  redoMutations: [
492
- { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.ARRANGE } }
543
+ { id: P.id, params: { op: h, unitId: s, subUnitId: o, objects: a, type: T.ARRANGE } }
493
544
  ]
494
545
  }), !0) : !1;
495
- }, "handler")
496
- }, SetSheetDrawingCommand = {
546
+ }
547
+ }, Ye = {
497
548
  id: "sheet.command.set-sheet-image",
498
- type: CommandType.COMMAND,
499
- handler: /* @__PURE__ */ __name((accessor, params) => {
500
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
501
- if (!params) return !1;
502
- const { drawings } = params, jsonOp = sheetDrawingService.getBatchUpdateOp(drawings), { unitId, subUnitId, undo, redo, objects } = jsonOp;
503
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE }) ? (undoRedoService.pushUndoRedo({
504
- unitID: unitId,
549
+ type: H.COMMAND,
550
+ handler: (i, e) => {
551
+ const n = i.get(W), t = i.get(ue), r = i.get(F);
552
+ if (!e) return !1;
553
+ const { drawings: s } = e, o = r.getBatchUpdateOp(s), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
554
+ return n.syncExecuteCommand(P.id, { unitId: d, subUnitId: l, op: c, objects: a, type: T.UPDATE }) ? (t.pushUndoRedo({
555
+ unitID: d,
505
556
  undoMutations: [
506
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
507
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
557
+ { id: P.id, params: { unitId: d, subUnitId: l, op: g, objects: a, type: T.UPDATE } },
558
+ { id: j.id, params: [d] }
508
559
  ],
509
560
  redoMutations: [
510
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
511
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
561
+ { id: P.id, params: { unitId: d, subUnitId: l, op: c, objects: a, type: T.UPDATE } },
562
+ { id: j.id, params: [d] }
512
563
  ]
513
564
  }), !0) : !1;
514
- }, "handler")
515
- }, UngroupSheetDrawingCommand = {
565
+ }
566
+ }, sn = {
516
567
  id: "sheet.command.ungroup-sheet-image",
517
- type: CommandType.COMMAND,
518
- handler: /* @__PURE__ */ __name((accessor, params) => {
519
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetDrawingService = accessor.get(ISheetDrawingService);
520
- if (!params) return !1;
521
- const unitIds = [];
522
- params.forEach(({ parent, children }) => {
523
- unitIds.push(parent.unitId), children.forEach((child) => {
524
- unitIds.push(child.unitId);
568
+ type: H.COMMAND,
569
+ handler: (i, e) => {
570
+ const n = i.get(W), t = i.get(ue), r = i.get(F);
571
+ if (!e) return !1;
572
+ const s = [];
573
+ e.forEach(({ parent: u, children: m }) => {
574
+ s.push(u.unitId), m.forEach((f) => {
575
+ s.push(f.unitId);
525
576
  });
526
577
  });
527
- const jsonOp = sheetDrawingService.getUngroupDrawingOp(params), { unitId, subUnitId, undo, redo, objects } = jsonOp;
528
- return commandService.syncExecuteCommand(SetDrawingApplyMutation.id, { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP }) ? (undoRedoService.pushUndoRedo({
529
- unitID: unitId,
578
+ const o = r.getUngroupDrawingOp(e), { unitId: d, subUnitId: l, undo: g, redo: c, objects: a } = o;
579
+ return n.syncExecuteCommand(P.id, { op: c, unitId: d, subUnitId: l, objects: a, type: T.UNGROUP }) ? (t.pushUndoRedo({
580
+ unitID: d,
530
581
  undoMutations: [
531
- { id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects: ungroupToGroup(objects), type: DrawingApplyType.GROUP } },
532
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
582
+ { id: P.id, params: { op: g, unitId: d, subUnitId: l, objects: Qr(a), type: T.GROUP } },
583
+ { id: j.id, params: s }
533
584
  ],
534
585
  redoMutations: [
535
- { id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.UNGROUP } },
536
- { id: ClearSheetDrawingTransformerOperation.id, params: unitIds }
586
+ { id: P.id, params: { op: c, unitId: d, subUnitId: l, objects: a, type: T.UNGROUP } },
587
+ { id: j.id, params: s }
537
588
  ]
538
589
  }), !0) : !1;
539
- }, "handler")
590
+ }
540
591
  };
541
- var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
542
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
543
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
544
- return kind && result && __defProp$6(target, key, result), result;
545
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a3;
546
- let SheetDrawingUpdateController = (_a3 = class extends Disposable {
547
- constructor(_context, _skeletonManagerService, _commandService, _selectionRenderService, _imageIoService, _fileOpenerService, _sheetDrawingService, _drawingManagerService, _contextService, _messageService, _localeService, selectionManagerService) {
592
+ var ti = Object.defineProperty, ni = Object.getOwnPropertyDescriptor, ri = (i, e, n, t) => {
593
+ for (var r = t > 1 ? void 0 : t ? ni(e, n) : e, s = i.length - 1, o; s >= 0; s--)
594
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
595
+ return t && r && ti(e, n, r), r;
596
+ }, z = (i, e) => (n, t) => e(n, t, i);
597
+ let Ae = class extends re {
598
+ constructor(e, n, t, r, s, o, d, l, g, c, a, h) {
548
599
  super();
549
- __publicField(this, "_workbookSelections");
550
- this._context = _context, this._skeletonManagerService = _skeletonManagerService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._imageIoService = _imageIoService, this._fileOpenerService = _fileOpenerService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._contextService = _contextService, this._messageService = _messageService, this._localeService = _localeService, this._workbookSelections = selectionManagerService.getWorkbookSelections(this._context.unitId), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
600
+ V(this, "_workbookSelections");
601
+ this._context = e, this._skeletonManagerService = n, this._commandService = t, this._selectionRenderService = r, this._imageIoService = s, this._fileOpenerService = o, this._sheetDrawingService = d, this._drawingManagerService = l, this._contextService = g, this._messageService = c, this._localeService = a, this._workbookSelections = h.getWorkbookSelections(this._context.unitId), this._updateImageListener(), this._updateOrderListener(), this._groupDrawingListener(), this._focusDrawingListener();
551
602
  }
552
603
  async insertFloatImage() {
553
- const files = await this._fileOpenerService.openFile({
604
+ const e = await this._fileOpenerService.openFile({
554
605
  multiple: !0,
555
- accept: DRAWING_IMAGE_ALLOW_IMAGE_LIST.map((image) => `.${image.replace("image/", "")}`).join(",")
556
- }), fileLength = files.length;
557
- return fileLength > DRAWING_IMAGE_COUNT_LIMIT ? (this._messageService.show({
558
- type: MessageType.Error,
559
- content: this._localeService.t("update-status.exceedMaxCount", String(DRAWING_IMAGE_COUNT_LIMIT))
560
- }), !1) : fileLength === 0 ? !1 : (files.forEach(async (file) => await this._insertFloatImage(file)), !0);
561
- }
562
- async _insertFloatImage(file) {
563
- let imageParam;
606
+ accept: An.map((t) => `.${t.replace("image/", "")}`).join(",")
607
+ }), n = e.length;
608
+ return n > mt ? (this._messageService.show({
609
+ type: Re.Error,
610
+ content: this._localeService.t("update-status.exceedMaxCount", String(mt))
611
+ }), !1) : n === 0 ? !1 : (e.forEach(async (t) => await this._insertFloatImage(t)), !0);
612
+ }
613
+ async _insertFloatImage(e) {
614
+ let n;
564
615
  try {
565
- imageParam = await this._imageIoService.saveImage(file);
566
- } catch (error) {
567
- const type = error.message;
568
- type === ImageUploadStatusType.ERROR_EXCEED_SIZE ? this._messageService.show({
569
- type: MessageType.Error,
570
- content: this._localeService.t("update-status.exceedMaxSize", String(DRAWING_IMAGE_ALLOW_SIZE / (1024 * 1024)))
571
- }) : type === ImageUploadStatusType.ERROR_IMAGE_TYPE ? this._messageService.show({
572
- type: MessageType.Error,
616
+ n = await this._imageIoService.saveImage(e);
617
+ } catch (S) {
618
+ const v = S.message;
619
+ v === He.ERROR_EXCEED_SIZE ? this._messageService.show({
620
+ type: Re.Error,
621
+ content: this._localeService.t("update-status.exceedMaxSize", String(Nn / (1024 * 1024)))
622
+ }) : v === He.ERROR_IMAGE_TYPE ? this._messageService.show({
623
+ type: Re.Error,
573
624
  content: this._localeService.t("update-status.invalidImageType")
574
- }) : type === ImageUploadStatusType.ERROR_IMAGE && this._messageService.show({
575
- type: MessageType.Error,
625
+ }) : v === He.ERROR_IMAGE && this._messageService.show({
626
+ type: Re.Error,
576
627
  content: this._localeService.t("update-status.invalidImage")
577
628
  });
578
629
  }
579
- if (imageParam == null)
630
+ if (n == null)
580
631
  return;
581
- const info = this._getUnitInfo(), { unitId, subUnitId } = info, { imageId, imageSourceType, source, base64Cache } = imageParam, { width, height, image } = await getImageSize(base64Cache || ""), { width: sceneWidth, height: sceneHeight } = this._context.scene;
582
- this._imageIoService.addImageSourceCache(source, imageSourceType, image);
583
- let scale = 1;
584
- if (width > DRAWING_IMAGE_WIDTH_LIMIT || height > DRAWING_IMAGE_HEIGHT_LIMIT) {
585
- const scaleWidth = DRAWING_IMAGE_WIDTH_LIMIT / width, scaleHeight = DRAWING_IMAGE_HEIGHT_LIMIT / height;
586
- scale = Math.max(scaleWidth, scaleHeight);
632
+ const t = this._getUnitInfo(), { unitId: r, subUnitId: s } = t, { imageId: o, imageSourceType: d, source: l, base64Cache: g } = n, { width: c, height: a, image: h } = await jn(g || ""), { width: u, height: m } = this._context.scene;
633
+ this._imageIoService.addImageSourceCache(l, d, h);
634
+ let f = 1;
635
+ if (c > ft || a > pt) {
636
+ const S = ft / c, v = pt / a;
637
+ f = Math.max(S, v);
587
638
  }
588
- const sheetTransform = this._getImagePosition(width * scale, height * scale, sceneWidth, sceneHeight);
589
- if (sheetTransform == null)
639
+ const p = this._getImagePosition(c * f, a * f, u, m);
640
+ if (p == null)
590
641
  return;
591
- const sheetDrawingParam = {
592
- unitId,
593
- subUnitId,
594
- drawingId: imageId,
595
- drawingType: DrawingTypeEnum.DRAWING_IMAGE,
596
- imageSourceType,
597
- source,
598
- transform: drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService),
599
- sheetTransform
642
+ const I = {
643
+ unitId: r,
644
+ subUnitId: s,
645
+ drawingId: o,
646
+ drawingType: k.DRAWING_IMAGE,
647
+ imageSourceType: d,
648
+ source: l,
649
+ transform: B(p, this._selectionRenderService, this._skeletonManagerService),
650
+ sheetTransform: p
600
651
  };
601
- this._commandService.executeCommand(InsertSheetDrawingCommand.id, {
602
- unitId,
603
- drawings: [sheetDrawingParam]
652
+ this._commandService.executeCommand(ke.id, {
653
+ unitId: r,
654
+ drawings: [I]
604
655
  });
605
656
  }
606
657
  _getUnitInfo() {
607
- const workbook = this._context.unit, worksheet = workbook.getActiveSheet(), unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId();
658
+ const e = this._context.unit, n = e.getActiveSheet(), t = e.getUnitId(), r = n.getSheetId();
608
659
  return {
609
- unitId,
610
- subUnitId
660
+ unitId: t,
661
+ subUnitId: r
611
662
  };
612
663
  }
613
- _getImagePosition(imageWidth, imageHeight, sceneWidth, sceneHeight) {
614
- const selections = this._workbookSelections.getCurrentSelections();
615
- let range = {
664
+ _getImagePosition(e, n, t, r) {
665
+ const s = this._workbookSelections.getCurrentSelections();
666
+ let o = {
616
667
  startRow: 0,
617
668
  endRow: 0,
618
669
  startColumn: 0,
619
670
  endColumn: 0
620
671
  };
621
- selections && selections.length > 0 && (range = selections[selections.length - 1].range);
622
- const rangeWithCoord = attachRangeWithCoord(this._skeletonManagerService.getCurrent().skeleton, range);
623
- if (rangeWithCoord == null)
672
+ s && s.length > 0 && (o = s[s.length - 1].range);
673
+ const d = Te(this._skeletonManagerService.getCurrent().skeleton, o);
674
+ if (d == null)
624
675
  return;
625
- let { startColumn, startRow, startX, startY } = rangeWithCoord, isChangeStart = !1;
626
- if (startX + imageWidth > sceneWidth && (startX = sceneWidth - imageWidth, startX < 0 && (startX = 0, imageWidth = sceneWidth), isChangeStart = !0), startY + imageHeight > sceneHeight && (startY = sceneHeight - imageHeight, startY < 0 && (startY = 0, imageHeight = sceneHeight), isChangeStart = !0), isChangeStart) {
627
- const newCoord = this._selectionRenderService.getSelectionCellByPosition(startX, startY);
628
- if (newCoord == null)
676
+ let { startColumn: l, startRow: g, startX: c, startY: a } = d, h = !1;
677
+ if (c + e > t && (c = t - e, c < 0 && (c = 0, e = t), h = !0), a + n > r && (a = r - n, a < 0 && (a = 0, n = r), h = !0), h) {
678
+ const p = this._selectionRenderService.getSelectionCellByPosition(c, a);
679
+ if (p == null)
629
680
  return;
630
- startX = newCoord.startX, startY = newCoord.startY, startColumn = newCoord.actualColumn, startRow = newCoord.actualRow;
681
+ c = p.startX, a = p.startY, l = p.actualColumn, g = p.actualRow;
631
682
  }
632
- const from = {
633
- column: startColumn,
683
+ const u = {
684
+ column: l,
634
685
  columnOffset: 0,
635
- row: startRow,
686
+ row: g,
636
687
  rowOffset: 0
637
- }, endSelectionCell = this._selectionRenderService.getSelectionCellByPosition(startX + imageWidth, startY + imageHeight);
638
- if (endSelectionCell == null)
688
+ }, m = this._selectionRenderService.getSelectionCellByPosition(c + e, a + n);
689
+ if (m == null)
639
690
  return;
640
- const to = {
641
- column: endSelectionCell.actualColumn,
642
- columnOffset: startX + imageWidth - endSelectionCell.startX,
643
- row: endSelectionCell.actualRow,
644
- rowOffset: startY + imageHeight - endSelectionCell.startY
691
+ const f = {
692
+ column: m.actualColumn,
693
+ columnOffset: c + e - m.startX,
694
+ row: m.actualRow,
695
+ rowOffset: a + n - m.startY
645
696
  };
646
697
  return {
647
- from,
648
- to
698
+ from: u,
699
+ to: f
649
700
  };
650
701
  }
651
702
  _updateOrderListener() {
652
- this._drawingManagerService.featurePluginOrderUpdate$.subscribe((params) => {
653
- const { unitId, subUnitId, drawingIds, arrangeType } = params;
654
- this._commandService.executeCommand(SetDrawingArrangeCommand.id, {
655
- unitId,
656
- subUnitId,
657
- drawingIds,
658
- arrangeType
703
+ this._drawingManagerService.featurePluginOrderUpdate$.subscribe((e) => {
704
+ const { unitId: n, subUnitId: t, drawingIds: r, arrangeType: s } = e;
705
+ this._commandService.executeCommand(rn.id, {
706
+ unitId: n,
707
+ subUnitId: t,
708
+ drawingIds: r,
709
+ arrangeType: s
659
710
  });
660
711
  });
661
712
  }
662
713
  _updateImageListener() {
663
- this._drawingManagerService.featurePluginUpdate$.subscribe((params) => {
664
- const drawings = [];
665
- params.length !== 0 && (params.forEach((param) => {
666
- const { unitId, subUnitId, drawingId, drawingType, transform } = param;
667
- if (transform == null)
714
+ this._drawingManagerService.featurePluginUpdate$.subscribe((e) => {
715
+ const n = [];
716
+ e.length !== 0 && (e.forEach((t) => {
717
+ const { unitId: r, subUnitId: s, drawingId: o, drawingType: d, transform: l } = t;
718
+ if (l == null)
668
719
  return;
669
- const sheetDrawing = this._sheetDrawingService.getDrawingByParam({ unitId, subUnitId, drawingId });
670
- if (sheetDrawing == null || sheetDrawing.unitId !== this._context.unitId)
720
+ const g = this._sheetDrawingService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: o });
721
+ if (g == null || g.unitId !== this._context.unitId)
671
722
  return;
672
- const sheetTransform = transformToDrawingPosition({ ...sheetDrawing.transform, ...transform }, this._selectionRenderService);
673
- if (sheetTransform == null)
723
+ const c = N({ ...g.transform, ...l }, this._selectionRenderService);
724
+ if (c == null)
674
725
  return;
675
- const newDrawing = {
676
- ...param,
677
- transform: { ...sheetDrawing.transform, ...transform, ...drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService) },
678
- sheetTransform: { ...sheetTransform }
726
+ const a = {
727
+ ...t,
728
+ transform: { ...g.transform, ...l, ...B(c, this._selectionRenderService, this._skeletonManagerService) },
729
+ sheetTransform: { ...c }
679
730
  };
680
- drawings.push(newDrawing);
681
- }), drawings.length > 0 && this._commandService.executeCommand(SetSheetDrawingCommand.id, {
682
- unitId: params[0].unitId,
683
- drawings
731
+ n.push(a);
732
+ }), n.length > 0 && this._commandService.executeCommand(Ye.id, {
733
+ unitId: e[0].unitId,
734
+ drawings: n
684
735
  }));
685
736
  });
686
737
  }
687
738
  _groupDrawingListener() {
688
- this._drawingManagerService.featurePluginGroupUpdate$.subscribe((params) => {
689
- this._commandService.executeCommand(GroupSheetDrawingCommand.id, params);
690
- const { unitId, subUnitId, drawingId } = params[0].parent;
691
- this._drawingManagerService.focusDrawing([{ unitId, subUnitId, drawingId }]);
692
- }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((params) => {
693
- this._commandService.executeCommand(UngroupSheetDrawingCommand.id, params);
739
+ this._drawingManagerService.featurePluginGroupUpdate$.subscribe((e) => {
740
+ this._commandService.executeCommand(nn.id, e);
741
+ const { unitId: n, subUnitId: t, drawingId: r } = e[0].parent;
742
+ this._drawingManagerService.focusDrawing([{ unitId: n, subUnitId: t, drawingId: r }]);
743
+ }), this._drawingManagerService.featurePluginUngroupUpdate$.subscribe((e) => {
744
+ this._commandService.executeCommand(sn.id, e);
694
745
  });
695
746
  }
696
747
  _focusDrawingListener() {
697
748
  this.disposeWithMe(
698
- this._drawingManagerService.focus$.subscribe((params) => {
699
- params == null || params.length === 0 ? (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(FOCUSING_COMMON_DRAWINGS, !0), this._sheetDrawingService.focusDrawing(params));
749
+ this._drawingManagerService.focus$.subscribe((e) => {
750
+ e == null || e.length === 0 ? (this._contextService.setContextValue(me, !1), this._sheetDrawingService.focusDrawing([])) : (this._contextService.setContextValue(me, !0), this._sheetDrawingService.focusDrawing(e));
700
751
  })
701
752
  );
702
753
  }
703
- }, __name(_a3, "SheetDrawingUpdateController"), _a3);
704
- SheetDrawingUpdateController = __decorateClass$6([
705
- __decorateParam$6(1, Inject(SheetSkeletonManagerService)),
706
- __decorateParam$6(2, ICommandService),
707
- __decorateParam$6(3, ISheetSelectionRenderService),
708
- __decorateParam$6(4, IImageIoService),
709
- __decorateParam$6(5, ILocalFileService),
710
- __decorateParam$6(6, ISheetDrawingService),
711
- __decorateParam$6(7, IDrawingManagerService),
712
- __decorateParam$6(8, IContextService),
713
- __decorateParam$6(9, IMessageService),
714
- __decorateParam$6(10, Inject(LocaleService)),
715
- __decorateParam$6(11, Inject(SheetsSelectionsService))
716
- ], SheetDrawingUpdateController);
717
- const InsertFloatImageCommand = {
754
+ };
755
+ Ae = ri([
756
+ z(1, x(q)),
757
+ z(2, W),
758
+ z(3, pe),
759
+ z(4, Dt),
760
+ z(5, or),
761
+ z(6, F),
762
+ z(7, K),
763
+ z(8, Rt),
764
+ z(9, ar),
765
+ z(10, x(We)),
766
+ z(11, x(pr))
767
+ ], Ae);
768
+ const dt = {
718
769
  id: "sheet.command.insert-float-image",
719
- type: CommandType.COMMAND,
720
- handler: /* @__PURE__ */ __name((accessor) => {
721
- var _a10, _b;
722
- return (_b = (_a10 = accessor.get(IRenderManagerService).getCurrentTypeOfRenderer(UniverInstanceType.UNIVER_SHEET)) == null ? void 0 : _a10.with(SheetDrawingUpdateController).insertFloatImage()) != null ? _b : !1;
723
- }, "handler")
724
- }, MoveDrawingsCommand = {
770
+ type: H.COMMAND,
771
+ handler: (i) => {
772
+ var n, t;
773
+ return (t = (n = i.get(J).getCurrentTypeOfRenderer(Y.UNIVER_SHEET)) == null ? void 0 : n.with(Ae).insertFloatImage()) != null ? t : !1;
774
+ }
775
+ }, we = {
725
776
  id: "sheet.command.move-drawing",
726
- type: CommandType.COMMAND,
727
- handler: /* @__PURE__ */ __name((accessor, params) => {
728
- const commandService = accessor.get(ICommandService), drawingManagerService = accessor.get(ISheetDrawingService), selectionRenderService = accessor.get(ISheetSelectionRenderService), { direction } = params, drawings = drawingManagerService.getFocusDrawings();
729
- if (drawings.length === 0)
777
+ type: H.COMMAND,
778
+ handler: (i, e) => {
779
+ const n = i.get(W), t = i.get(F), r = i.get(pe), { direction: s } = e, o = t.getFocusDrawings();
780
+ if (o.length === 0)
730
781
  return !1;
731
- const unitId = drawings[0].unitId, newDrawings = drawings.map((drawing) => {
732
- const { transform } = drawing;
733
- if (transform == null)
782
+ const d = o[0].unitId, l = o.map((c) => {
783
+ const { transform: a } = c;
784
+ if (a == null)
734
785
  return null;
735
- const newTransform = { ...transform }, { left = 0, top = 0 } = transform;
736
- return direction === Direction.UP ? newTransform.top = top - 1 : direction === Direction.DOWN ? newTransform.top = top + 1 : direction === Direction.LEFT ? newTransform.left = left - 1 : direction === Direction.RIGHT && (newTransform.left = left + 1), {
737
- ...drawing,
738
- transform: newTransform,
739
- sheetTransform: transformToDrawingPosition(newTransform, selectionRenderService)
786
+ const h = { ...a }, { left: u = 0, top: m = 0 } = a;
787
+ return s === te.UP ? h.top = m - 1 : s === te.DOWN ? h.top = m + 1 : s === te.LEFT ? h.left = u - 1 : s === te.RIGHT && (h.left = u + 1), {
788
+ ...c,
789
+ transform: h,
790
+ sheetTransform: N(h, r)
740
791
  };
741
- }).filter((drawing) => drawing != null);
742
- return commandService.syncExecuteCommand(SetSheetDrawingCommand.id, {
743
- unitId,
744
- drawings: newDrawings
745
- }) ? (commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]), !0) : !1;
746
- }, "handler")
747
- }, IMAGE_UPLOAD_ICON = "addition-and-subtraction-single", IMAGE_MENU_ID = "sheet.menu.image";
748
- function ImageMenuFactory(accessor) {
792
+ }).filter((c) => c != null);
793
+ return n.syncExecuteCommand(Ye.id, {
794
+ unitId: d,
795
+ drawings: l
796
+ }) ? (n.syncExecuteCommand(j.id, [d]), !0) : !1;
797
+ }
798
+ }, on = "addition-and-subtraction-single", an = "sheet.menu.image";
799
+ function ii(i) {
749
800
  return {
750
- id: IMAGE_MENU_ID,
751
- type: MenuItemType.SUBITEMS,
752
- icon: IMAGE_UPLOAD_ICON,
801
+ id: an,
802
+ type: Mt.SUBITEMS,
803
+ icon: on,
753
804
  tooltip: "sheetImage.title",
754
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
755
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
805
+ hidden$: bt(i, Y.UNIVER_SHEET),
806
+ disabled$: Zn(i, { workbookTypes: [tt], worksheetTypes: [Pe], rangeTypes: [wr] })
756
807
  };
757
808
  }
758
- __name(ImageMenuFactory, "ImageMenuFactory");
759
- function UploadFloatImageMenuFactory(_accessor) {
809
+ function si(i) {
760
810
  return {
761
- id: InsertFloatImageCommand.id,
811
+ id: dt.id,
762
812
  title: "sheetImage.upload.float",
763
- type: MenuItemType.BUTTON,
764
- hidden$: getMenuHiddenObservable(_accessor, UniverInstanceType.UNIVER_SHEET)
813
+ type: Mt.BUTTON,
814
+ hidden$: bt(i, Y.UNIVER_SHEET)
765
815
  };
766
816
  }
767
- __name(UploadFloatImageMenuFactory, "UploadFloatImageMenuFactory");
768
- const imageCommonPanel = "univer-image-common-panel", imageCommonPanelGrid = "univer-image-common-panel-grid", imageCommonPanelBorder = "univer-image-common-panel-border", imageCommonPanelTitle = "univer-image-common-panel-title", imageCommonPanelSubtitle = "univer-image-common-panel-subtitle", imageCommonPanelRow = "univer-image-common-panel-row", imageCommonPanelRowVertical = "univer-image-common-panel-row-vertical", imageCommonPanelColumn = "univer-image-common-panel-column", imageCommonPanelColumnCenter = "univer-image-common-panel-column-center", imageCommonPanelInline = "univer-image-common-panel-inline", imageCommonPanelSpan2 = "univer-image-common-panel-span2", imageCommonPanelSpan3 = "univer-image-common-panel-span3", imageCommonPanelInput = "univer-image-common-panel-input", sheetImageMenu = "univer-sheet-image-menu", sheetImageMenuInput = "univer-sheet-image-menu-input", styles = {
769
- imageCommonPanel,
770
- imageCommonPanelGrid,
771
- imageCommonPanelBorder,
772
- imageCommonPanelTitle,
773
- imageCommonPanelSubtitle,
774
- imageCommonPanelRow,
775
- imageCommonPanelRowVertical,
776
- imageCommonPanelColumn,
777
- imageCommonPanelColumnCenter,
778
- imageCommonPanelInline,
779
- imageCommonPanelSpan2,
780
- imageCommonPanelSpan3,
781
- imageCommonPanelInput,
782
- sheetImageMenu,
783
- sheetImageMenuInput
817
+ const oi = "univer-image-common-panel", ai = "univer-image-common-panel-grid", ci = "univer-image-common-panel-border", di = "univer-image-common-panel-title", li = "univer-image-common-panel-subtitle", ui = "univer-image-common-panel-row", hi = "univer-image-common-panel-row-vertical", gi = "univer-image-common-panel-column", mi = "univer-image-common-panel-column-center", fi = "univer-image-common-panel-inline", pi = "univer-image-common-panel-span2", wi = "univer-image-common-panel-span3", _i = "univer-image-common-panel-input", vi = "univer-sheet-image-menu", Si = "univer-sheet-image-menu-input", ee = {
818
+ imageCommonPanel: oi,
819
+ imageCommonPanelGrid: ai,
820
+ imageCommonPanelBorder: ci,
821
+ imageCommonPanelTitle: di,
822
+ imageCommonPanelSubtitle: li,
823
+ imageCommonPanelRow: ui,
824
+ imageCommonPanelRowVertical: hi,
825
+ imageCommonPanelColumn: gi,
826
+ imageCommonPanelColumnCenter: mi,
827
+ imageCommonPanelInline: fi,
828
+ imageCommonPanelSpan2: pi,
829
+ imageCommonPanelSpan3: wi,
830
+ imageCommonPanelInput: _i,
831
+ sheetImageMenu: vi,
832
+ sheetImageMenuInput: Si
784
833
  };
785
- function r(e) {
786
- var t, f, n = "";
787
- if (typeof e == "string" || typeof e == "number") n += e;
788
- else if (typeof e == "object") if (Array.isArray(e)) {
789
- var o = e.length;
790
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
791
- } else for (f in e) e[f] && (n && (n += " "), n += f);
792
- return n;
834
+ function cn(i) {
835
+ var e, n, t = "";
836
+ if (typeof i == "string" || typeof i == "number") t += i;
837
+ else if (typeof i == "object") if (Array.isArray(i)) {
838
+ var r = i.length;
839
+ for (e = 0; e < r; e++) i[e] && (n = cn(i[e])) && (t && (t += " "), t += n);
840
+ } else for (n in i) i[n] && (t && (t += " "), t += n);
841
+ return t;
793
842
  }
794
- __name(r, "r");
795
- function clsx() {
796
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
797
- return n;
843
+ function be() {
844
+ for (var i, e, n = 0, t = "", r = arguments.length; n < r; n++) (i = arguments[n]) && (e = cn(i)) && (t && (t += " "), t += e);
845
+ return t;
798
846
  }
799
- __name(clsx, "clsx");
800
- const SheetDrawingAnchor = /* @__PURE__ */ __name((props) => {
801
- var _a10;
802
- const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), { drawings } = props, drawingParam = drawings[0];
803
- if (drawingParam == null)
847
+ const Ii = (i) => {
848
+ var v;
849
+ const e = oe(W), n = oe(We), t = oe(K), r = oe(J), { drawings: s } = i, o = s[0];
850
+ if (o == null)
804
851
  return;
805
- const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
806
- if (scene == null)
852
+ const { unitId: d } = o, l = r.getRenderById(d), g = l == null ? void 0 : l.scene;
853
+ if (g == null)
807
854
  return;
808
- const transformer = scene.getTransformerByCreate(), [anchorShow, setAnchorShow] = useState(!0), type = (_a10 = drawingParam.anchorType) != null ? _a10 : SheetDrawingAnchorType.Position, [value, setValue] = useState(type);
809
- function getUpdateParams(objects, drawingManagerService2) {
810
- const params = [];
811
- return objects.forEach((object) => {
812
- const { oKey } = object, searchParam = drawingManagerService2.getDrawingOKey(oKey);
813
- if (searchParam == null)
814
- return params.push(null), !0;
815
- const { unitId: unitId2, subUnitId, drawingId, drawingType, anchorType, sheetTransform } = searchParam;
816
- params.push({
817
- unitId: unitId2,
818
- subUnitId,
819
- drawingId,
820
- anchorType,
821
- sheetTransform,
822
- drawingType
855
+ const c = g.getTransformerByCreate(), [a, h] = it(!0), u = (v = o.anchorType) != null ? v : y.Position, [m, f] = it(u);
856
+ function p(R, _) {
857
+ const C = [];
858
+ return R.forEach((w) => {
859
+ const { oKey: O } = w, b = _.getDrawingOKey(O);
860
+ if (b == null)
861
+ return C.push(null), !0;
862
+ const { unitId: A, subUnitId: E, drawingId: M, drawingType: D, anchorType: U, sheetTransform: L } = b;
863
+ C.push({
864
+ unitId: A,
865
+ subUnitId: E,
866
+ drawingId: M,
867
+ anchorType: U,
868
+ sheetTransform: L,
869
+ drawingType: D
823
870
  });
824
- }), params;
825
- }
826
- __name(getUpdateParams, "getUpdateParams"), useEffect(() => {
827
- const onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
828
- changeSelf === !0 && setAnchorShow(!1);
829
- }), onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
830
- var _a11;
831
- const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
832
- if (params.length === 0)
833
- setAnchorShow(!1);
834
- else if (params.length >= 1) {
835
- setAnchorShow(!0);
836
- const anchorType = ((_a11 = params[0]) == null ? void 0 : _a11.anchorType) || SheetDrawingAnchorType.Position;
837
- setValue(anchorType);
871
+ }), C;
872
+ }
873
+ ct(() => {
874
+ const R = c.clearControl$.subscribe((C) => {
875
+ C === !0 && h(!1);
876
+ }), _ = c.changeStart$.subscribe((C) => {
877
+ var b;
878
+ const { objects: w } = C, O = p(w, t);
879
+ if (O.length === 0)
880
+ h(!1);
881
+ else if (O.length >= 1) {
882
+ h(!0);
883
+ const A = ((b = O[0]) == null ? void 0 : b.anchorType) || y.Position;
884
+ f(A);
838
885
  }
839
886
  });
840
887
  return () => {
841
- onChangeStartObserver.unsubscribe(), onClearControlObserver.unsubscribe();
888
+ _.unsubscribe(), R.unsubscribe();
842
889
  };
843
890
  }, []);
844
- function handleChange(value2) {
845
- setValue(value2);
846
- const focusDrawings = drawingManagerService.getFocusDrawings();
847
- if (focusDrawings.length === 0)
891
+ function I(R) {
892
+ f(R);
893
+ const _ = t.getFocusDrawings();
894
+ if (_.length === 0)
848
895
  return;
849
- const updateParams = focusDrawings.map((drawing) => ({
850
- unitId: drawing.unitId,
851
- subUnitId: drawing.subUnitId,
852
- drawingId: drawing.drawingId,
853
- anchorType: value2
896
+ const C = _.map((w) => ({
897
+ unitId: w.unitId,
898
+ subUnitId: w.subUnitId,
899
+ drawingId: w.drawingId,
900
+ anchorType: R
854
901
  }));
855
- commandService.executeCommand(SetSheetDrawingCommand.id, {
856
- unitId: focusDrawings[0].unitId,
857
- drawings: updateParams
902
+ e.executeCommand(Ye.id, {
903
+ unitId: _[0].unitId,
904
+ drawings: C
858
905
  });
859
906
  }
860
- __name(handleChange, "handleChange");
861
- const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
862
- return /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelGrid, styles.imageCommonPanelBorder), style: { display: gridDisplay(anchorShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn, styles.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("drawing-anchor.title")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelRow) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(RadioGroup, { value, onChange: handleChange, direction: "vertical" }, /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Both }, localeService.t("drawing-anchor.both")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.Position }, localeService.t("drawing-anchor.position")), /* @__PURE__ */ React.createElement(Radio, { value: SheetDrawingAnchorType.None }, localeService.t("drawing-anchor.none"))))));
863
- }, "SheetDrawingAnchor"), SheetDrawingPanel = /* @__PURE__ */ __name(() => {
864
- const drawingManagerService = useDependency(IDrawingManagerService), focusDrawings = drawingManagerService.getFocusDrawings(), [drawings, setDrawings] = useState(focusDrawings);
865
- return useEffect(() => {
866
- const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
867
- setDrawings(drawings2);
907
+ const S = (R) => R ? "block" : "none";
908
+ return /* @__PURE__ */ $.jsxs("div", { className: be(ee.imageCommonPanelGrid, ee.imageCommonPanelBorder), style: { display: S(a) }, children: [
909
+ /* @__PURE__ */ $.jsx("div", { className: ee.imageCommonPanelRow, children: /* @__PURE__ */ $.jsx("div", { className: be(ee.imageCommonPanelColumn, ee.imageCommonPanelTitle), children: /* @__PURE__ */ $.jsx("div", { children: n.t("drawing-anchor.title") }) }) }),
910
+ /* @__PURE__ */ $.jsx("div", { className: be(ee.imageCommonPanelRow), children: /* @__PURE__ */ $.jsx("div", { className: be(ee.imageCommonPanelColumn), children: /* @__PURE__ */ $.jsxs(yr, { value: m, onChange: I, direction: "vertical", children: [
911
+ /* @__PURE__ */ $.jsx(Ze, { value: y.Both, children: n.t("drawing-anchor.both") }),
912
+ /* @__PURE__ */ $.jsx(Ze, { value: y.Position, children: n.t("drawing-anchor.position") }),
913
+ /* @__PURE__ */ $.jsx(Ze, { value: y.None, children: n.t("drawing-anchor.none") })
914
+ ] }) }) })
915
+ ] });
916
+ }, Ci = () => {
917
+ const i = oe(K), e = i.getFocusDrawings(), [n, t] = it(e);
918
+ return ct(() => {
919
+ const r = i.focus$.subscribe((s) => {
920
+ t(s);
868
921
  });
869
922
  return () => {
870
- focusDispose.unsubscribe();
923
+ r.unsubscribe();
871
924
  };
872
- }, []), !!(drawings != null && drawings.length) && /* @__PURE__ */ React.createElement("div", { className: styles.imageCommonPanel }, /* @__PURE__ */ React.createElement(DrawingCommonPanel, { drawings }), /* @__PURE__ */ React.createElement(SheetDrawingAnchor, { drawings }));
873
- }, "SheetDrawingPanel"), menuSchema = {
874
- [RibbonStartGroup.FORMULAS_INSERT]: {
875
- [IMAGE_MENU_ID]: {
925
+ }, []), !!(n != null && n.length) && /* @__PURE__ */ $.jsxs("div", { className: ee.imageCommonPanel, children: [
926
+ /* @__PURE__ */ $.jsx(Gn, { drawings: n }),
927
+ /* @__PURE__ */ $.jsx(Ii, { drawings: n })
928
+ ] });
929
+ }, Ri = {
930
+ [cr.FORMULAS_INSERT]: {
931
+ [an]: {
876
932
  order: 3,
877
- menuItemFactory: ImageMenuFactory,
878
- [InsertFloatImageCommand.id]: {
933
+ menuItemFactory: ii,
934
+ [dt.id]: {
879
935
  order: 0,
880
- menuItemFactory: UploadFloatImageMenuFactory
936
+ menuItemFactory: si
881
937
  }
882
938
  }
883
939
  }
884
940
  };
885
- function whenSheetDrawingFocused(contextService) {
886
- return !contextService.getContextValue(FOCUSING_FX_BAR_EDITOR) && !contextService.getContextValue(EDITOR_ACTIVATED) && contextService.getContextValue(FOCUSING_COMMON_DRAWINGS);
941
+ function _e(i) {
942
+ return !i.getContextValue(_n) && !i.getContextValue(vn) && !i.getContextValue(Sn) && i.getContextValue(me);
887
943
  }
888
- __name(whenSheetDrawingFocused, "whenSheetDrawingFocused");
889
- const MoveDrawingDownShortcutItem = {
890
- id: MoveDrawingsCommand.id,
944
+ const Di = {
945
+ id: we.id,
891
946
  description: "shortcut.sheet.drawing-move-down",
892
947
  group: "4_sheet-drawing-view",
893
- binding: KeyCode.ARROW_DOWN,
948
+ binding: le.ARROW_DOWN,
894
949
  priority: 100,
895
- preconditions: whenSheetDrawingFocused,
950
+ preconditions: _e,
896
951
  staticParameters: {
897
- direction: Direction.DOWN
952
+ direction: te.DOWN
898
953
  }
899
- }, MoveDrawingUpShortcutItem = {
900
- id: MoveDrawingsCommand.id,
954
+ }, Mi = {
955
+ id: we.id,
901
956
  description: "shortcut.sheet.drawing-move-up",
902
957
  group: "4_sheet-drawing-view",
903
- binding: KeyCode.ARROW_UP,
958
+ binding: le.ARROW_UP,
904
959
  priority: 100,
905
- preconditions: whenSheetDrawingFocused,
960
+ preconditions: _e,
906
961
  staticParameters: {
907
- direction: Direction.UP
962
+ direction: te.UP
908
963
  }
909
- }, MoveDrawingLeftShortcutItem = {
910
- id: MoveDrawingsCommand.id,
964
+ }, bi = {
965
+ id: we.id,
911
966
  description: "shortcut.sheet.drawing-move-left",
912
967
  group: "4_sheet-drawing-view",
913
- binding: KeyCode.ARROW_LEFT,
968
+ binding: le.ARROW_LEFT,
914
969
  priority: 100,
915
- preconditions: whenSheetDrawingFocused,
970
+ preconditions: _e,
916
971
  staticParameters: {
917
- direction: Direction.LEFT
972
+ direction: te.LEFT
918
973
  }
919
- }, MoveDrawingRightShortcutItem = {
920
- id: MoveDrawingsCommand.id,
974
+ }, yi = {
975
+ id: we.id,
921
976
  description: "shortcut.sheet.drawing-move-right",
922
977
  group: "4_sheet-drawing-view",
923
- binding: KeyCode.ARROW_RIGHT,
978
+ binding: le.ARROW_RIGHT,
924
979
  priority: 100,
925
- preconditions: whenSheetDrawingFocused,
980
+ preconditions: _e,
926
981
  staticParameters: {
927
- direction: Direction.RIGHT
982
+ direction: te.RIGHT
928
983
  }
929
- }, DeleteDrawingsShortcutItem = {
930
- id: DeleteDrawingsCommand.id,
984
+ }, Oi = {
985
+ id: tn.id,
931
986
  description: "shortcut.sheet.drawing-delete",
932
987
  group: "4_sheet-drawing-view",
933
988
  // when focusing on any other input tag do not trigger this shortcut
934
- preconditions: whenSheetDrawingFocused,
935
- binding: KeyCode.DELETE,
936
- mac: KeyCode.BACKSPACE
989
+ preconditions: _e,
990
+ binding: le.DELETE,
991
+ mac: le.BACKSPACE
937
992
  };
938
- var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
939
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
940
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
941
- return kind && result && __defProp$5(target, key, result), result;
942
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a4;
943
- let SheetDrawingUIController = (_a4 = class extends Disposable {
944
- constructor(_componentManager, _menuManagerService, _commandService, _shortcutService) {
945
- super(), this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._commandService = _commandService, this._shortcutService = _shortcutService, this._init();
993
+ var Pi = Object.defineProperty, Ti = Object.getOwnPropertyDescriptor, Ei = (i, e, n, t) => {
994
+ for (var r = t > 1 ? void 0 : t ? Ti(e, n) : e, s = i.length - 1, o; s >= 0; s--)
995
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
996
+ return t && r && Pi(e, n, r), r;
997
+ }, ye = (i, e) => (n, t) => e(n, t, i);
998
+ let Ne = class extends re {
999
+ constructor(i, e, n, t) {
1000
+ super(), this._componentManager = i, this._menuManagerService = e, this._commandService = n, this._shortcutService = t, this._init();
946
1001
  }
947
1002
  _initCustomComponents() {
948
- const componentManager = this._componentManager;
949
- this.disposeWithMe(componentManager.register(IMAGE_UPLOAD_ICON, AddImageSingle)), this.disposeWithMe(componentManager.register(COMPONENT_SHEET_DRAWING_PANEL, SheetDrawingPanel));
1003
+ const i = this._componentManager;
1004
+ this.disposeWithMe(i.register(on, en)), this.disposeWithMe(i.register(Ht, Ci));
950
1005
  }
951
1006
  _initMenus() {
952
- this._menuManagerService.mergeMenu(menuSchema);
1007
+ this._menuManagerService.mergeMenu(Ri);
953
1008
  }
954
1009
  _initCommands() {
955
1010
  [
956
- InsertFloatImageCommand,
957
- InsertSheetDrawingCommand,
958
- RemoveSheetDrawingCommand,
959
- SetSheetDrawingCommand,
960
- SidebarSheetDrawingOperation,
961
- ClearSheetDrawingTransformerOperation,
962
- EditSheetDrawingOperation,
963
- GroupSheetDrawingCommand,
964
- UngroupSheetDrawingCommand,
965
- MoveDrawingsCommand,
966
- DeleteDrawingsCommand,
967
- SetDrawingArrangeCommand
968
- ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1011
+ dt,
1012
+ ke,
1013
+ Ge,
1014
+ Ye,
1015
+ zt,
1016
+ j,
1017
+ Kt,
1018
+ nn,
1019
+ sn,
1020
+ we,
1021
+ tn,
1022
+ rn
1023
+ ].forEach((i) => this.disposeWithMe(this._commandService.registerCommand(i)));
969
1024
  }
970
1025
  _initShortcuts() {
971
1026
  [
972
1027
  // sheet drawing shortcuts
973
- MoveDrawingDownShortcutItem,
974
- MoveDrawingUpShortcutItem,
975
- MoveDrawingLeftShortcutItem,
976
- MoveDrawingRightShortcutItem,
977
- DeleteDrawingsShortcutItem
978
- ].forEach((item) => {
979
- this.disposeWithMe(this._shortcutService.registerShortcut(item));
1028
+ Di,
1029
+ Mi,
1030
+ bi,
1031
+ yi,
1032
+ Oi
1033
+ ].forEach((i) => {
1034
+ this.disposeWithMe(this._shortcutService.registerShortcut(i));
980
1035
  });
981
1036
  }
982
1037
  _init() {
983
1038
  this._initCommands(), this._initCustomComponents(), this._initMenus(), this._initShortcuts();
984
1039
  }
985
- }, __name(_a4, "SheetDrawingUIController"), _a4);
986
- SheetDrawingUIController = __decorateClass$5([
987
- __decorateParam$5(0, Inject(ComponentManager)),
988
- __decorateParam$5(1, IMenuManagerService),
989
- __decorateParam$5(2, ICommandService),
990
- __decorateParam$5(3, IShortcutService)
991
- ], SheetDrawingUIController);
992
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
993
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
994
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
995
- return kind && result && __defProp$4(target, key, result), result;
996
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a5;
997
- let SheetsDrawingCopyPasteController = (_a5 = class extends Disposable {
998
- constructor(_sheetClipboardService, _renderManagerService, _sheetDrawingService) {
1040
+ };
1041
+ Ne = Ei([
1042
+ ye(0, x(dr)),
1043
+ ye(1, lr),
1044
+ ye(2, W),
1045
+ ye(3, ur)
1046
+ ], Ne);
1047
+ var Ui = Object.defineProperty, Ai = Object.getOwnPropertyDescriptor, Ni = (i, e, n, t) => {
1048
+ for (var r = t > 1 ? void 0 : t ? Ai(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1049
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1050
+ return t && r && Ui(e, n, r), r;
1051
+ }, qe = (i, e) => (n, t) => e(n, t, i);
1052
+ let je = class extends re {
1053
+ constructor(e, n, t) {
999
1054
  super();
1000
- __publicField(this, "_copyInfo");
1001
- this._sheetClipboardService = _sheetClipboardService, this._renderManagerService = _renderManagerService, this._sheetDrawingService = _sheetDrawingService, this._initCopyPaste();
1055
+ V(this, "_copyInfo");
1056
+ this._sheetClipboardService = e, this._renderManagerService = n, this._sheetDrawingService = t, this._initCopyPaste();
1002
1057
  }
1003
1058
  _initCopyPaste() {
1004
1059
  this._sheetClipboardService.addClipboardHook({
1005
1060
  id: "SHEET_IMAGE_UI_PLUGIN",
1006
- onBeforeCopy: /* @__PURE__ */ __name((unitId, subUnitId, range) => this._collect(unitId, subUnitId, range), "onBeforeCopy"),
1007
- onPasteCells: /* @__PURE__ */ __name((pasteFrom, pasteTo, data, payload) => {
1008
- const { copyType = COPY_TYPE.COPY, pasteType } = payload, { range: copyRange } = pasteFrom || {}, { range: pastedRange, unitId, subUnitId } = pasteTo;
1009
- return this._generateMutations(pastedRange, { copyType, pasteType, copyRange, unitId, subUnitId });
1010
- }, "onPasteCells"),
1011
- onPastePlainText: /* @__PURE__ */ __name((pasteTo, clipText) => ({ undos: [], redos: [] }), "onPastePlainText")
1061
+ onBeforeCopy: (e, n, t) => this._collect(e, n, t),
1062
+ onPasteCells: (e, n, t, r) => {
1063
+ const { copyType: s = _t.COPY, pasteType: o } = r, { range: d } = e || {}, { range: l, unitId: g, subUnitId: c } = n;
1064
+ return this._generateMutations(l, { copyType: s, pasteType: o, copyRange: d, unitId: g, subUnitId: c });
1065
+ },
1066
+ onPastePlainText: (e, n) => ({ undos: [], redos: [] })
1012
1067
  });
1013
1068
  }
1014
- _collect(unitId, subUnitId, range) {
1015
- var _a10;
1016
- const skeletonManagerService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService);
1017
- if (!skeletonManagerService) return;
1018
- const selectionRect = skeletonManagerService.attachRangeWithCoord(range);
1019
- if (!selectionRect)
1069
+ _collect(e, n, t) {
1070
+ var h;
1071
+ const r = (h = this._renderManagerService.getRenderById(e)) == null ? void 0 : h.with(q);
1072
+ if (!r) return;
1073
+ const s = r.attachRangeWithCoord(t);
1074
+ if (!s)
1020
1075
  return;
1021
- const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
1022
- Object.keys(drawings).forEach((drawingId) => {
1023
- const drawing = drawings[drawingId], { transform } = drawing;
1024
- if (drawing.anchorType !== SheetDrawingAnchorType.Both || !transform)
1076
+ const { startX: o, endX: d, startY: l, endY: g } = s, c = this._sheetDrawingService.getDrawingData(e, n), a = [];
1077
+ Object.keys(c).forEach((u) => {
1078
+ const m = c[u], { transform: f } = m;
1079
+ if (m.anchorType !== y.Both || !f)
1025
1080
  return;
1026
- const { left = 0, top = 0, width = 0, height = 0 } = transform, { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
1027
- drawingStartX: left,
1028
- drawingEndX: left + width,
1029
- drawingStartY: top,
1030
- drawingEndY: top + height
1081
+ const { left: p = 0, top: I = 0, width: S = 0, height: v = 0 } = f, { drawingStartX: R, drawingEndX: _, drawingStartY: C, drawingEndY: w } = {
1082
+ drawingStartX: p,
1083
+ drawingEndX: p + S,
1084
+ drawingStartY: I,
1085
+ drawingEndY: I + v
1031
1086
  };
1032
- startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY && containedDrawings.push(drawing);
1033
- }), containedDrawings.length && (this._copyInfo = {
1034
- drawings: containedDrawings,
1035
- unitId,
1036
- subUnitId
1087
+ o <= R && _ <= d && l <= C && w <= g && a.push(m);
1088
+ }), a.length && (this._copyInfo = {
1089
+ drawings: a,
1090
+ unitId: e,
1091
+ subUnitId: n
1037
1092
  });
1038
1093
  }
1039
1094
  // eslint-disable-next-line max-lines-per-function
1040
- _generateMutations(pastedRange, copyInfo) {
1041
- var _a10;
1095
+ _generateMutations(e, n) {
1096
+ var b;
1042
1097
  if (!this._copyInfo)
1043
1098
  return { redos: [], undos: [] };
1044
1099
  if ([
1045
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,
1046
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,
1047
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,
1048
- PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA
1100
+ Se.SPECIAL_PASTE_COL_WIDTH,
1101
+ Se.SPECIAL_PASTE_VALUE,
1102
+ Se.SPECIAL_PASTE_FORMAT,
1103
+ Se.SPECIAL_PASTE_FORMULA
1049
1104
  ].includes(
1050
- copyInfo.pasteType
1105
+ n.pasteType
1051
1106
  ))
1052
1107
  return { redos: [], undos: [] };
1053
- const { copyRange } = copyInfo;
1054
- if (!copyRange)
1108
+ const { copyRange: t } = n;
1109
+ if (!t)
1055
1110
  return { redos: [], undos: [] };
1056
- const { drawings, unitId, subUnitId } = this._copyInfo, { ranges: [vCopyRange, vPastedRange], mapFunc } = virtualizeDiscreteRanges([copyRange, pastedRange]), { row: copyRow, col: copyCol } = mapFunc(vCopyRange.startRow, vCopyRange.startColumn), { row: pasteRow, col: pasteCol } = mapFunc(vPastedRange.startRow, vPastedRange.startColumn), skeletonManagerService = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService);
1057
- if (!skeletonManagerService)
1111
+ const { drawings: r, unitId: s, subUnitId: o } = this._copyInfo, { ranges: [d, l], mapFunc: g } = qn([t, e]), { row: c, col: a } = g(d.startRow, d.startColumn), { row: h, col: u } = g(l.startRow, l.startColumn), m = (b = this._renderManagerService.getRenderById(s)) == null ? void 0 : b.with(q);
1112
+ if (!m)
1058
1113
  return { redos: [], undos: [] };
1059
- const copyRect = skeletonManagerService.attachRangeWithCoord({
1060
- startRow: copyRow,
1061
- endRow: copyRow,
1062
- startColumn: copyCol,
1063
- endColumn: copyCol
1064
- }), pasteRect = skeletonManagerService.attachRangeWithCoord({
1065
- startRow: pasteRow,
1066
- endRow: pasteRow,
1067
- startColumn: pasteCol,
1068
- endColumn: pasteCol
1114
+ const f = m.attachRangeWithCoord({
1115
+ startRow: c,
1116
+ endRow: c,
1117
+ startColumn: a,
1118
+ endColumn: a
1119
+ }), p = m.attachRangeWithCoord({
1120
+ startRow: h,
1121
+ endRow: h,
1122
+ startColumn: u,
1123
+ endColumn: u
1069
1124
  });
1070
- if (!copyRect || !pasteRect)
1125
+ if (!f || !p)
1071
1126
  return { redos: [], undos: [] };
1072
- const redos = [], undos = [], leftOffset = pasteRect.startX - copyRect.startX, topOffset = pasteRect.startY - copyRect.startY, rowOffset = pasteRow - copyRow, columnOffset = pasteCol - copyCol, isCut = copyInfo.copyType === COPY_TYPE.CUT, { _sheetDrawingService } = this;
1073
- return drawings.forEach((drawing) => {
1074
- const { transform, sheetTransform } = drawing;
1075
- if (!transform)
1127
+ const I = [], S = [], v = p.startX - f.startX, R = p.startY - f.startY, _ = h - c, C = u - a, w = n.copyType === _t.CUT, { _sheetDrawingService: O } = this;
1128
+ return r.forEach((A) => {
1129
+ const { transform: E, sheetTransform: M } = A;
1130
+ if (!E)
1076
1131
  return;
1077
- const drawingObject = {
1078
- ...drawing,
1079
- unitId,
1080
- subUnitId,
1081
- drawingId: isCut ? drawing.drawingId : Tools.generateRandomId(),
1132
+ const D = {
1133
+ ...A,
1134
+ unitId: s,
1135
+ subUnitId: o,
1136
+ drawingId: w ? A.drawingId : ge.generateRandomId(),
1082
1137
  transform: {
1083
- ...transform,
1084
- left: transform.left + leftOffset,
1085
- top: transform.top + topOffset
1138
+ ...E,
1139
+ left: E.left + v,
1140
+ top: E.top + R
1086
1141
  },
1087
1142
  sheetTransform: {
1088
- to: { ...sheetTransform.to, row: sheetTransform.to.row + rowOffset, column: sheetTransform.to.column + columnOffset },
1089
- from: { ...sheetTransform.from, row: sheetTransform.from.row + rowOffset, column: sheetTransform.from.column + columnOffset }
1143
+ to: { ...M.to, row: M.to.row + _, column: M.to.column + C },
1144
+ from: { ...M.from, row: M.from.row + _, column: M.from.column + C }
1090
1145
  }
1091
1146
  };
1092
- if (isCut) {
1093
- const { undo, redo, objects } = _sheetDrawingService.getBatchUpdateOp([drawingObject]);
1094
- redos.push({
1095
- id: SetDrawingApplyMutation.id,
1147
+ if (w) {
1148
+ const { undo: U, redo: L, objects: Z } = O.getBatchUpdateOp([D]);
1149
+ I.push({
1150
+ id: P.id,
1096
1151
  params: {
1097
- unitId,
1098
- subUnitId,
1099
- type: DrawingApplyType.UPDATE,
1100
- op: redo,
1101
- objects
1152
+ unitId: s,
1153
+ subUnitId: o,
1154
+ type: T.UPDATE,
1155
+ op: L,
1156
+ objects: Z
1102
1157
  }
1103
- }), undos.push({
1104
- id: SetDrawingApplyMutation.id,
1158
+ }), S.push({
1159
+ id: P.id,
1105
1160
  params: {
1106
- unitId,
1107
- subUnitId,
1108
- type: DrawingApplyType.UPDATE,
1109
- op: undo,
1110
- objects
1161
+ unitId: s,
1162
+ subUnitId: o,
1163
+ type: T.UPDATE,
1164
+ op: U,
1165
+ objects: Z
1111
1166
  }
1112
1167
  });
1113
1168
  } else {
1114
- const { undo, redo, objects } = _sheetDrawingService.getBatchAddOp([drawingObject]);
1115
- redos.push({ id: SetDrawingApplyMutation.id, params: { op: redo, unitId, subUnitId, objects, type: DrawingApplyType.INSERT } }), undos.push({ id: SetDrawingApplyMutation.id, params: { op: undo, unitId, subUnitId, objects, type: DrawingApplyType.REMOVE } });
1169
+ const { undo: U, redo: L, objects: Z } = O.getBatchAddOp([D]);
1170
+ I.push({ id: P.id, params: { op: L, unitId: s, subUnitId: o, objects: Z, type: T.INSERT } }), S.push({ id: P.id, params: { op: U, unitId: s, subUnitId: o, objects: Z, type: T.REMOVE } });
1116
1171
  }
1117
1172
  }), {
1118
- redos,
1119
- undos
1173
+ redos: I,
1174
+ undos: S
1120
1175
  };
1121
1176
  }
1122
- }, __name(_a5, "SheetsDrawingCopyPasteController"), _a5);
1123
- SheetsDrawingCopyPasteController = __decorateClass$4([
1124
- __decorateParam$4(0, ISheetClipboardService),
1125
- __decorateParam$4(1, IRenderManagerService),
1126
- __decorateParam$4(2, ISheetDrawingService)
1127
- ], SheetsDrawingCopyPasteController);
1128
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1129
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1130
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1131
- return kind && result && __defProp$3(target, key, result), result;
1132
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a6;
1133
- let SheetDrawingPermissionController = (_a6 = class extends Disposable {
1134
- constructor(_drawingManagerService, _renderManagerService, _permissionService, _univerInstanceService, _userManagerService) {
1135
- super(), this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._userManagerService = _userManagerService, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
1177
+ };
1178
+ je = Ni([
1179
+ qe(0, Qn),
1180
+ qe(1, J),
1181
+ qe(2, F)
1182
+ ], je);
1183
+ var ji = Object.defineProperty, xi = Object.getOwnPropertyDescriptor, Li = (i, e, n, t) => {
1184
+ for (var r = t > 1 ? void 0 : t ? xi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1185
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1186
+ return t && r && ji(e, n, r), r;
1187
+ }, he = (i, e) => (n, t) => e(n, t, i);
1188
+ let xe = class extends re {
1189
+ constructor(i, e, n, t, r) {
1190
+ super(), this._drawingManagerService = i, this._renderManagerService = e, this._permissionService = n, this._univerInstanceService = t, this._userManagerService = r, this._initDrawingVisible(), this._initDrawingEditable(), this._initViewPermissionChange(), this._initEditPermissionChange();
1136
1191
  }
1137
1192
  _initDrawingVisible() {
1138
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1193
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1139
1194
  this.disposeWithMe(
1140
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1141
- if (!workbook) {
1195
+ Ie([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1196
+ if (!e) {
1142
1197
  this._drawingManagerService.setDrawingVisible(!1);
1143
1198
  return;
1144
1199
  }
1145
- workbook.activeSheet$.subscribe((sheet) => {
1146
- if (!sheet) {
1200
+ e.activeSheet$.subscribe((t) => {
1201
+ if (!t) {
1147
1202
  this._drawingManagerService.setDrawingVisible(!1);
1148
1203
  return;
1149
1204
  }
1150
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1151
- if (this._permissionService.composePermission([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).every((permission) => permission.value))
1205
+ const r = e.getUnitId(), s = t.getSheetId();
1206
+ if (this._permissionService.composePermission([new St(r).id, new Je(r, s).id]).every((d) => d.value))
1152
1207
  this._drawingManagerService.setDrawingVisible(!0);
1153
1208
  else {
1154
1209
  this._drawingManagerService.setDrawingVisible(!1);
1155
- const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
1156
- if (scene == null)
1210
+ const d = e.getUnitId(), l = t.getSheetId(), g = this._drawingManagerService.getDrawingData(d, l), c = Object.values(g), a = this._renderManagerService.getRenderById(d), h = a == null ? void 0 : a.scene;
1211
+ if (h == null)
1157
1212
  return;
1158
- scene.getAllObjectsByOrder().forEach((object) => {
1159
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
1213
+ h.getAllObjectsByOrder().forEach((m) => {
1214
+ m.classType === de.IMAGE && c.some((f) => m.oKey.includes(f.drawingId)) && h.removeObject(m);
1160
1215
  });
1161
1216
  }
1162
1217
  });
@@ -1164,28 +1219,28 @@ let SheetDrawingPermissionController = (_a6 = class extends Disposable {
1164
1219
  );
1165
1220
  }
1166
1221
  _initDrawingEditable() {
1167
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1222
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1168
1223
  this.disposeWithMe(
1169
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1170
- if (!workbook) {
1224
+ Ie([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1225
+ if (!e) {
1171
1226
  this._drawingManagerService.setDrawingEditable(!1);
1172
1227
  return;
1173
1228
  }
1174
- workbook.activeSheet$.subscribe((sheet) => {
1175
- if (!sheet) {
1229
+ e.activeSheet$.subscribe((t) => {
1230
+ if (!t) {
1176
1231
  this._drawingManagerService.setDrawingEditable(!1);
1177
1232
  return;
1178
1233
  }
1179
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1180
- if (this._permissionService.composePermission([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).every((permission) => permission.value))
1234
+ const r = e.getUnitId(), s = t.getSheetId();
1235
+ if (this._permissionService.composePermission([new tt(r).id, new Pe(r, s).id]).every((d) => d.value))
1181
1236
  this._drawingManagerService.setDrawingEditable(!0);
1182
1237
  else {
1183
1238
  this._drawingManagerService.setDrawingEditable(!1);
1184
- const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject = this._renderManagerService.getRenderById(unitId2), scene = renderObject == null ? void 0 : renderObject.scene;
1185
- if (scene == null)
1239
+ const d = e.getUnitId(), l = t.getSheetId(), g = this._drawingManagerService.getDrawingData(d, l), c = Object.values(g), a = this._renderManagerService.getRenderById(d), h = a == null ? void 0 : a.scene;
1240
+ if (h == null)
1186
1241
  return;
1187
- scene.getAllObjectsByOrder().forEach((object) => {
1188
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
1242
+ h.getAllObjectsByOrder().forEach((m) => {
1243
+ m.classType === de.IMAGE && c.some((f) => m.oKey.includes(f.drawingId)) && h.detachTransformerFrom(m);
1189
1244
  });
1190
1245
  }
1191
1246
  });
@@ -1193,984 +1248,1344 @@ let SheetDrawingPermissionController = (_a6 = class extends Disposable {
1193
1248
  );
1194
1249
  }
1195
1250
  _initViewPermissionChange() {
1196
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1251
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1197
1252
  this.disposeWithMe(
1198
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1199
- workbook && workbook.activeSheet$.subscribe((sheet) => {
1200
- var _a10;
1201
- if (!sheet)
1253
+ Ie([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1254
+ e && e.activeSheet$.subscribe((t) => {
1255
+ var a;
1256
+ if (!t)
1202
1257
  return;
1203
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1204
- let initialViewPermission = !0;
1205
- const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1206
- if (scene == null)
1258
+ const r = e.getUnitId(), s = t.getSheetId();
1259
+ let o = !0;
1260
+ const d = this._renderManagerService.getRenderById(r), l = d == null ? void 0 : d.scene;
1261
+ if (l == null)
1207
1262
  return;
1208
- const transformer = scene.getTransformerByCreate(), worksheetViewPermission$ = this._permissionService.composePermission$([new WorkbookViewPermission(unitId).id, new WorksheetViewPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
1209
- worksheetViewPermission$ == null || worksheetViewPermission$.pipe(
1210
- filter((permission) => permission !== initialViewPermission),
1211
- distinctUntilChanged()
1263
+ const g = l.getTransformerByCreate(), c = this._permissionService.composePermission$([new St(r).id, new Je(r, s).id]).pipe(Ee((h) => h.every((u) => u.value)));
1264
+ c == null || c.pipe(
1265
+ ae((h) => h !== o),
1266
+ Ce()
1212
1267
  ).subscribe({
1213
- next: /* @__PURE__ */ __name((permission) => {
1214
- initialViewPermission = permission, this._drawingManagerService.setDrawingVisible(permission);
1215
- const objects = scene.getAllObjectsByOrder(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
1216
- permission ? this._drawingManagerService.addNotification(drawingDataValues) : (objects.forEach((object) => {
1217
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.removeObject(object);
1218
- }), transformer.clearSelectedObjects());
1219
- }, "next")
1220
- }), (_a10 = this._permissionService.getPermissionPoint$(new WorksheetViewPermission(unitId, subUnitId).id)) == null || _a10.pipe(
1221
- filter((permission) => permission.value !== initialViewPermission),
1222
- distinctUntilChanged()
1268
+ next: (h) => {
1269
+ o = h, this._drawingManagerService.setDrawingVisible(h);
1270
+ const u = l.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), f = Object.values(m);
1271
+ h ? this._drawingManagerService.addNotification(f) : (u.forEach((p) => {
1272
+ p.classType === de.IMAGE && f.some((I) => p.oKey.includes(I.drawingId)) && l.removeObject(p);
1273
+ }), g.clearSelectedObjects());
1274
+ }
1275
+ }), (a = this._permissionService.getPermissionPoint$(new Je(r, s).id)) == null || a.pipe(
1276
+ ae((h) => h.value !== o),
1277
+ Ce()
1223
1278
  ).subscribe({
1224
- complete: /* @__PURE__ */ __name(() => {
1225
- initialViewPermission = !0, this._drawingManagerService.setDrawingVisible(!0);
1226
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
1227
- this._drawingManagerService.addNotification(drawingDataValues);
1228
- }, "complete")
1279
+ complete: () => {
1280
+ o = !0, this._drawingManagerService.setDrawingVisible(!0);
1281
+ const h = this._drawingManagerService.getDrawingData(r, s), u = Object.values(h);
1282
+ this._drawingManagerService.addNotification(u);
1283
+ }
1229
1284
  });
1230
1285
  });
1231
1286
  })
1232
1287
  );
1233
1288
  }
1234
1289
  _initEditPermissionChange() {
1235
- const workbook$ = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET);
1290
+ const i = this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET);
1236
1291
  this.disposeWithMe(
1237
- combineLatest([workbook$, this._userManagerService.currentUser$]).subscribe(([workbook, _]) => {
1238
- workbook && workbook.activeSheet$.subscribe((sheet) => {
1239
- var _a10;
1240
- if (!sheet)
1292
+ Ie([i, this._userManagerService.currentUser$]).subscribe(([e, n]) => {
1293
+ e && e.activeSheet$.subscribe((t) => {
1294
+ var a;
1295
+ if (!t)
1241
1296
  return;
1242
- const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
1243
- let initialEditPermission = !0;
1244
- const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1245
- if (scene == null)
1297
+ const r = e.getUnitId(), s = t.getSheetId();
1298
+ let o = !0;
1299
+ const d = this._renderManagerService.getRenderById(r), l = d == null ? void 0 : d.scene;
1300
+ if (l == null)
1246
1301
  return;
1247
- const transformer = scene.getTransformerByCreate(), composeWorksheetEditPermission = this._permissionService.composePermission$([new WorkbookEditablePermission(unitId).id, new WorksheetEditPermission(unitId, subUnitId).id]).pipe(map((permissions) => permissions.every((item) => item.value)));
1248
- composeWorksheetEditPermission == null || composeWorksheetEditPermission.pipe(
1249
- filter((permission) => permission !== initialEditPermission),
1250
- distinctUntilChanged()
1302
+ const g = l.getTransformerByCreate(), c = this._permissionService.composePermission$([new tt(r).id, new Pe(r, s).id]).pipe(Ee((h) => h.every((u) => u.value)));
1303
+ c == null || c.pipe(
1304
+ ae((h) => h !== o),
1305
+ Ce()
1251
1306
  ).subscribe({
1252
- next: /* @__PURE__ */ __name((permission) => {
1253
- initialEditPermission = permission, this._drawingManagerService.setDrawingEditable(permission);
1254
- const objects = scene.getAllObjectsByOrder(), drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), drawingDataValues = Object.values(drawingData);
1255
- permission ? (objects.forEach((object) => {
1256
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.attachTransformerTo(object);
1257
- }), this._drawingManagerService.addNotification(drawingDataValues)) : (objects.forEach((object) => {
1258
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene.detachTransformerFrom(object);
1259
- }), transformer.clearSelectedObjects());
1260
- }, "next")
1261
- }), (_a10 = this._permissionService.getPermissionPoint$(new WorksheetEditPermission(unitId, subUnitId).id)) == null || _a10.pipe(
1262
- filter((permission) => permission.value !== initialEditPermission),
1263
- distinctUntilChanged()
1307
+ next: (h) => {
1308
+ o = h, this._drawingManagerService.setDrawingEditable(h);
1309
+ const u = l.getAllObjectsByOrder(), m = this._drawingManagerService.getDrawingData(r, s), f = Object.values(m);
1310
+ h ? (u.forEach((p) => {
1311
+ p.classType === de.IMAGE && f.some((I) => p.oKey.includes(I.drawingId)) && l.attachTransformerTo(p);
1312
+ }), this._drawingManagerService.addNotification(f)) : (u.forEach((p) => {
1313
+ p.classType === de.IMAGE && f.some((I) => p.oKey.includes(I.drawingId)) && l.detachTransformerFrom(p);
1314
+ }), g.clearSelectedObjects());
1315
+ }
1316
+ }), (a = this._permissionService.getPermissionPoint$(new Pe(r, s).id)) == null || a.pipe(
1317
+ ae((h) => h.value !== o),
1318
+ Ce()
1264
1319
  ).subscribe({
1265
- complete: /* @__PURE__ */ __name(() => {
1266
- initialEditPermission = !0;
1267
- const unitId2 = workbook.getUnitId(), subUnitId2 = sheet.getSheetId(), drawingData = this._drawingManagerService.getDrawingData(unitId2, subUnitId2), drawingDataValues = Object.values(drawingData), renderObject2 = this._renderManagerService.getRenderById(unitId2), scene2 = renderObject2 == null ? void 0 : renderObject2.scene;
1268
- if (scene2 == null)
1320
+ complete: () => {
1321
+ o = !0;
1322
+ const h = e.getUnitId(), u = t.getSheetId(), m = this._drawingManagerService.getDrawingData(h, u), f = Object.values(m), p = this._renderManagerService.getRenderById(h), I = p == null ? void 0 : p.scene;
1323
+ if (I == null)
1269
1324
  return;
1270
- this._drawingManagerService.setDrawingEditable(!0), scene2.getAllObjectsByOrder().forEach((object) => {
1271
- object.classType === RENDER_CLASS_TYPE.IMAGE && drawingDataValues.some((item) => object.oKey.includes(item.drawingId)) && scene2.detachTransformerFrom(object);
1325
+ this._drawingManagerService.setDrawingEditable(!0), I.getAllObjectsByOrder().forEach((v) => {
1326
+ v.classType === de.IMAGE && f.some((R) => v.oKey.includes(R.drawingId)) && I.detachTransformerFrom(v);
1272
1327
  });
1273
- }, "complete")
1328
+ }
1274
1329
  });
1275
1330
  });
1276
1331
  })
1277
1332
  );
1278
1333
  }
1279
- }, __name(_a6, "SheetDrawingPermissionController"), _a6);
1280
- SheetDrawingPermissionController = __decorateClass$3([
1281
- __decorateParam$3(0, IDrawingManagerService),
1282
- __decorateParam$3(1, IRenderManagerService),
1283
- __decorateParam$3(2, IPermissionService),
1284
- __decorateParam$3(3, IUniverInstanceService),
1285
- __decorateParam$3(4, Inject(UserManagerService))
1286
- ], SheetDrawingPermissionController);
1287
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1288
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1289
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1290
- return kind && result && __defProp$2(target, key, result), result;
1291
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a7;
1292
- let SheetDrawingPrintingController = (_a7 = class extends Disposable {
1293
- constructor(_sheetPrintInterceptorService, _drawingRenderService, _drawingManagerService, _renderManagerService) {
1294
- super(), this._sheetPrintInterceptorService = _sheetPrintInterceptorService, this._drawingRenderService = _drawingRenderService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._initPrinting();
1334
+ };
1335
+ xe = Li([
1336
+ he(0, K),
1337
+ he(1, J),
1338
+ he(2, Cn),
1339
+ he(3, fe),
1340
+ he(4, x(In))
1341
+ ], xe);
1342
+ var $i = Object.defineProperty, Bi = Object.getOwnPropertyDescriptor, Wi = (i, e, n, t) => {
1343
+ for (var r = t > 1 ? void 0 : t ? Bi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1344
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1345
+ return t && r && $i(e, n, r), r;
1346
+ }, Oe = (i, e) => (n, t) => e(n, t, i);
1347
+ let Le = class extends re {
1348
+ constructor(i, e, n, t) {
1349
+ super(), this._sheetPrintInterceptorService = i, this._drawingRenderService = e, this._drawingManagerService = n, this._renderManagerService = t, this._initPrinting();
1295
1350
  }
1296
1351
  _initPrinting() {
1297
1352
  this.disposeWithMe(
1298
1353
  this._sheetPrintInterceptorService.interceptor.intercept(
1299
1354
  this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_COMPONENT_COLLECT,
1300
1355
  {
1301
- handler: /* @__PURE__ */ __name((_param, pos, next) => {
1302
- const { unitId, scene, subUnitId } = pos, unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[subUnitId];
1303
- return subUnitData && subUnitData.order.forEach((id) => {
1304
- this._drawingRenderService.renderDrawing(subUnitData.data[id], scene);
1305
- }), next();
1306
- }, "handler")
1356
+ handler: (i, e, n) => {
1357
+ const { unitId: t, scene: r, subUnitId: s } = e, o = this._drawingManagerService.getDrawingDataForUnit(t), d = o == null ? void 0 : o[s];
1358
+ return d && d.order.forEach((l) => {
1359
+ this._drawingRenderService.renderDrawing(d.data[l], r);
1360
+ }), n();
1361
+ }
1307
1362
  }
1308
1363
  )
1309
1364
  ), this.disposeWithMe(
1310
1365
  this._sheetPrintInterceptorService.interceptor.intercept(
1311
1366
  this._sheetPrintInterceptorService.interceptor.getInterceptPoints().PRINTING_RANGE,
1312
1367
  {
1313
- handler: /* @__PURE__ */ __name((range, pos, next) => {
1314
- const { unitId, subUnitId } = pos, renderer = this._renderManagerService.getRenderById(unitId);
1315
- if (!renderer)
1316
- return next(range);
1317
- const skeleton = renderer.with(SheetSkeletonManagerService).getWorksheetSkeleton(subUnitId);
1318
- if (!skeleton)
1319
- return next(range);
1320
- const unitData = this._drawingManagerService.getDrawingDataForUnit(unitId), subUnitData = unitData == null ? void 0 : unitData[pos.subUnitId];
1321
- if (!subUnitData)
1322
- return next(range);
1323
- const { scaleX, scaleY } = renderer.scene, newRange = range ? { ...range } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, data = subUnitData.order.map((key) => subUnitData.data[key]).filter((item) => item.drawingType !== DrawingTypeEnum.DRAWING_DOM);
1324
- return data.length ? (data.forEach((param) => {
1325
- if (!param.groupId && param.transform && Tools.isDefine(param.transform.left) && Tools.isDefine(param.transform.top) && Tools.isDefine(param.transform.width) && Tools.isDefine(param.transform.height)) {
1326
- const start = skeleton.skeleton.getCellPositionByOffset(param.transform.left, param.transform.top, scaleX, scaleY, { x: 0, y: 0 }), end = skeleton.skeleton.getCellPositionByOffset(param.transform.left + param.transform.width, param.transform.top + param.transform.height, scaleX, scaleY, { x: 0, y: 0 });
1327
- start.column < newRange.startColumn && (newRange.startColumn = start.column), start.row < newRange.startRow && (newRange.startRow = start.row), newRange.endRow < end.row && (newRange.endRow = end.row), newRange.endColumn < end.column && (newRange.endColumn = end.column);
1368
+ handler: (i, e, n) => {
1369
+ const { unitId: t, subUnitId: r } = e, s = this._renderManagerService.getRenderById(t);
1370
+ if (!s)
1371
+ return n(i);
1372
+ const o = s.with(q).getWorksheetSkeleton(r);
1373
+ if (!o)
1374
+ return n(i);
1375
+ const d = this._drawingManagerService.getDrawingDataForUnit(t), l = d == null ? void 0 : d[e.subUnitId];
1376
+ if (!l)
1377
+ return n(i);
1378
+ const { scaleX: g, scaleY: c } = s.scene, a = i ? { ...i } : { startColumn: 0, endColumn: 0, endRow: 0, startRow: 0 }, h = l.order.map((u) => l.data[u]).filter((u) => u.drawingType !== k.DRAWING_DOM);
1379
+ return h.length ? (h.forEach((u) => {
1380
+ if (!u.groupId && u.transform && ge.isDefine(u.transform.left) && ge.isDefine(u.transform.top) && ge.isDefine(u.transform.width) && ge.isDefine(u.transform.height)) {
1381
+ const m = o.skeleton.getCellPositionByOffset(u.transform.left, u.transform.top, g, c, { x: 0, y: 0 }), f = o.skeleton.getCellPositionByOffset(u.transform.left + u.transform.width, u.transform.top + u.transform.height, g, c, { x: 0, y: 0 });
1382
+ m.column < a.startColumn && (a.startColumn = m.column), m.row < a.startRow && (a.startRow = m.row), a.endRow < f.row && (a.endRow = f.row), a.endColumn < f.column && (a.endColumn = f.column);
1328
1383
  }
1329
- }), next(newRange)) : next(range);
1330
- }, "handler")
1384
+ }), n(a)) : n(i);
1385
+ }
1331
1386
  }
1332
1387
  )
1333
1388
  );
1334
1389
  }
1335
- }, __name(_a7, "SheetDrawingPrintingController"), _a7);
1336
- SheetDrawingPrintingController = __decorateClass$2([
1337
- __decorateParam$2(0, Inject(SheetPrintInterceptorService)),
1338
- __decorateParam$2(1, Inject(DrawingRenderService)),
1339
- __decorateParam$2(2, IDrawingManagerService),
1340
- __decorateParam$2(3, IRenderManagerService)
1341
- ], SheetDrawingPrintingController);
1342
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1343
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1344
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1345
- return kind && result && __defProp$1(target, key, result), result;
1346
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
1347
- const UPDATE_COMMANDS = [
1348
- InsertRowCommand.id,
1349
- InsertColCommand.id,
1350
- RemoveRowCommand.id,
1351
- RemoveColCommand.id,
1352
- DeleteRangeMoveLeftCommand.id,
1353
- DeleteRangeMoveUpCommand.id,
1354
- InsertRangeMoveDownCommand.id,
1355
- InsertRangeMoveRightCommand.id,
1356
- DeltaRowHeightCommand.id,
1357
- SetRowHeightCommand.id,
1358
- DeltaColumnWidthCommand.id,
1359
- SetColWidthCommand.id,
1360
- SetRowHiddenCommand.id,
1361
- SetSpecificRowsVisibleCommand.id,
1362
- SetSpecificColsVisibleCommand.id,
1363
- SetColHiddenCommand.id,
1364
- MoveColsCommand.id,
1365
- MoveRowsCommand.id,
1366
- MoveRangeCommand.id
1367
- ], REFRESH_MUTATIONS = [
1368
- SetRowVisibleMutation.id,
1369
- SetRowHiddenMutation.id,
1370
- SetColVisibleMutation.id,
1371
- SetColHiddenMutation.id,
1372
- SetWorksheetRowHeightMutation.id,
1373
- SetWorksheetColWidthMutation.id
1390
+ };
1391
+ Le = Wi([
1392
+ Oe(0, x(er)),
1393
+ Oe(1, x(Vn)),
1394
+ Oe(2, K),
1395
+ Oe(3, J)
1396
+ ], Le);
1397
+ var Gi = Object.defineProperty, Vi = Object.getOwnPropertyDescriptor, ki = (i, e, n, t) => {
1398
+ for (var r = t > 1 ? void 0 : t ? Vi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
1399
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
1400
+ return t && r && Gi(e, n, r), r;
1401
+ }, Q = (i, e) => (n, t) => e(n, t, i);
1402
+ const Yi = [
1403
+ yt.id,
1404
+ Ot.id,
1405
+ Pt.id,
1406
+ Tt.id,
1407
+ Et.id,
1408
+ Ut.id,
1409
+ At.id,
1410
+ Nt.id,
1411
+ nt.id,
1412
+ rt.id,
1413
+ jt.id,
1414
+ xt.id,
1415
+ Lt.id,
1416
+ $t.id,
1417
+ Bt.id,
1418
+ Wt.id,
1419
+ Gt.id,
1420
+ Vt.id,
1421
+ kt.id
1422
+ ], Fi = [
1423
+ _r.id,
1424
+ vr.id,
1425
+ Sr.id,
1426
+ Ir.id,
1427
+ Cr.id,
1428
+ Rr.id
1374
1429
  ];
1375
- var _a8;
1376
- let SheetDrawingTransformAffectedController = (_a8 = class extends Disposable {
1377
- constructor(_context, _renderManagerService, _commandService, _selectionRenderService, _skeletonManagerService, _sheetInterceptorService, _sheetDrawingService, _drawingManagerService, _univerInstanceService) {
1378
- super(), this._context = _context, this._renderManagerService = _renderManagerService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._skeletonManagerService = _skeletonManagerService, this._sheetInterceptorService = _sheetInterceptorService, this._sheetDrawingService = _sheetDrawingService, this._drawingManagerService = _drawingManagerService, this._univerInstanceService = _univerInstanceService, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1430
+ let ot = class extends re {
1431
+ constructor(i, e, n, t, r, s, o, d, l) {
1432
+ super(), this._context = i, this._renderManagerService = e, this._commandService = n, this._selectionRenderService = t, this._skeletonManagerService = r, this._sheetInterceptorService = s, this._sheetDrawingService = o, this._drawingManagerService = d, this._univerInstanceService = l, this._sheetInterceptorListener(), this._commandListener(), this._sheetRefreshListener();
1379
1433
  }
1380
1434
  _sheetInterceptorListener() {
1381
1435
  this.disposeWithMe(
1382
1436
  this._sheetInterceptorService.interceptCommand({
1383
- getMutations: /* @__PURE__ */ __name((commandInfo) => {
1384
- if (!UPDATE_COMMANDS.includes(commandInfo.id))
1437
+ getMutations: (i) => {
1438
+ if (!Yi.includes(i.id))
1385
1439
  return { redos: [], undos: [] };
1386
- if (commandInfo.params == null)
1440
+ if (i.params == null)
1387
1441
  return { redos: [], undos: [] };
1388
- const cId = commandInfo.id;
1389
- if (cId === InsertRowCommand.id)
1390
- return this._moveRowInterceptor(commandInfo.params, "insert");
1391
- if ([MoveColsCommand.id, MoveRowsCommand.id, MoveRangeCommand.id].includes(cId))
1392
- return this._moveRangeInterceptor(commandInfo.params);
1393
- if (cId === InsertColCommand.id)
1394
- return this._moveColInterceptor(commandInfo.params, "insert");
1395
- if (cId === RemoveRowCommand.id)
1396
- return this._moveRowInterceptor(commandInfo.params, "remove");
1397
- if (cId === RemoveColCommand.id)
1398
- return this._moveColInterceptor(commandInfo.params, "remove");
1399
- if (cId === DeleteRangeMoveLeftCommand.id) {
1400
- const { range } = commandInfo.params;
1442
+ const e = i.id;
1443
+ if (e === yt.id)
1444
+ return this._moveRowInterceptor(i.params, "insert");
1445
+ if ([Gt.id, Vt.id, kt.id].includes(e))
1446
+ return this._moveRangeInterceptor(i.params);
1447
+ if (e === Ot.id)
1448
+ return this._moveColInterceptor(i.params, "insert");
1449
+ if (e === Pt.id)
1450
+ return this._moveRowInterceptor(i.params, "remove");
1451
+ if (e === Tt.id)
1452
+ return this._moveColInterceptor(i.params, "remove");
1453
+ if (e === Et.id) {
1454
+ const { range: n } = i.params;
1401
1455
  return this._getRangeMoveUndo(
1402
- range,
1456
+ n,
1403
1457
  0
1404
1458
  /* deleteLeft */
1405
1459
  );
1406
- } else if (cId === DeleteRangeMoveUpCommand.id) {
1407
- const { range } = commandInfo.params;
1460
+ } else if (e === Ut.id) {
1461
+ const { range: n } = i.params;
1408
1462
  return this._getRangeMoveUndo(
1409
- range,
1463
+ n,
1410
1464
  1
1411
1465
  /* deleteUp */
1412
1466
  );
1413
- } else if (cId === InsertRangeMoveDownCommand.id) {
1414
- const { range } = commandInfo.params;
1467
+ } else if (e === At.id) {
1468
+ const { range: n } = i.params;
1415
1469
  return this._getRangeMoveUndo(
1416
- range,
1470
+ n,
1417
1471
  2
1418
1472
  /* insertDown */
1419
1473
  );
1420
- } else if (cId === InsertRangeMoveRightCommand.id) {
1421
- const { range } = commandInfo.params;
1474
+ } else if (e === Nt.id) {
1475
+ const { range: n } = i.params;
1422
1476
  return this._getRangeMoveUndo(
1423
- range,
1477
+ n,
1424
1478
  3
1425
1479
  /* insertRight */
1426
1480
  );
1427
- } else if (cId === SetRowHiddenCommand.id || cId === SetSpecificRowsVisibleCommand.id) {
1428
- const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
1429
- return this._getDrawingUndoForRowVisible(unitId, subUnitId, ranges);
1430
- } else if (cId === SetSpecificColsVisibleCommand.id || cId === SetColHiddenCommand.id) {
1431
- const params = commandInfo.params, { unitId, subUnitId, ranges } = params;
1432
- return this._getDrawingUndoForColVisible(unitId, subUnitId, ranges);
1433
- } else if (cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id || cId === DeltaColumnWidthCommand.id || cId === SetColWidthCommand.id) {
1434
- const params = commandInfo.params, { unitId, subUnitId, ranges } = params, isRow = cId === DeltaRowHeightCommand.id || cId === SetRowHeightCommand.id;
1435
- return this._getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow);
1481
+ } else if (e === Lt.id || e === $t.id) {
1482
+ const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
1483
+ return this._getDrawingUndoForRowVisible(t, r, s);
1484
+ } else if (e === Bt.id || e === Wt.id) {
1485
+ const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n;
1486
+ return this._getDrawingUndoForColVisible(t, r, s);
1487
+ } else if (e === nt.id || e === rt.id || e === jt.id || e === xt.id) {
1488
+ const n = i.params, { unitId: t, subUnitId: r, ranges: s } = n, o = e === nt.id || e === rt.id;
1489
+ return this._getDrawingUndoForRowAndColSize(t, r, s, o);
1436
1490
  }
1437
1491
  return { redos: [], undos: [] };
1438
- }, "getMutations")
1492
+ }
1439
1493
  })
1440
1494
  );
1441
1495
  }
1442
- _getRangeMoveUndo(range, type) {
1443
- const newParams = getSheetCommandTarget(this._univerInstanceService);
1444
- if (newParams == null)
1496
+ _getRangeMoveUndo(i, e) {
1497
+ const n = ce(this._univerInstanceService);
1498
+ if (n == null)
1445
1499
  return { redos: [], undos: [] };
1446
- const unitId = newParams.unitId, subUnitId = newParams.subUnitId, redos = [], undos = [], drawingData = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1447
- if (Object.keys(drawingData).forEach((drawingId) => {
1448
- const drawing = drawingData[drawingId], { updateDrawings: updateDrawingsPart, deleteDrawings: deleteDrawingsPart } = this._getUpdateOrDeleteDrawings(range, type, drawing);
1449
- updateDrawings.push(...updateDrawingsPart), deleteDrawings.push(...deleteDrawingsPart);
1450
- }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1500
+ const t = n.unitId, r = n.subUnitId, s = [], o = [], d = this._sheetDrawingService.getDrawingData(t, r), l = [], g = [];
1501
+ if (Object.keys(d).forEach((c) => {
1502
+ const a = d[c], { updateDrawings: h, deleteDrawings: u } = this._getUpdateOrDeleteDrawings(i, e, a);
1503
+ l.push(...h), g.push(...u);
1504
+ }), l.length === 0 && g.length === 0)
1451
1505
  return { redos: [], undos: [] };
1452
- if (updateDrawings.length > 0) {
1453
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1454
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1506
+ if (l.length > 0) {
1507
+ const c = this._sheetDrawingService.getBatchUpdateOp(l), { undo: a, redo: h, objects: u } = c;
1508
+ s.push({ id: P.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: T.UPDATE } }), o.push({ id: P.id, params: { unitId: t, subUnitId: r, op: a, objects: u, type: T.UPDATE } });
1455
1509
  }
1456
- if (deleteDrawings.length > 0) {
1457
- const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1458
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1510
+ if (g.length > 0) {
1511
+ const c = this._sheetDrawingService.getBatchRemoveOp(g), a = c.undo, h = c.redo, u = c.objects;
1512
+ s.push({ id: P.id, params: { unitId: t, subUnitId: r, op: h, objects: u, type: T.REMOVE } }), o.push({ id: P.id, params: { unitId: t, subUnitId: r, op: a, objects: u, type: T.INSERT } });
1459
1513
  }
1460
- return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
1461
- redos,
1462
- undos
1514
+ return s.push({ id: j.id, params: [t] }), o.push({ id: j.id, params: [t] }), {
1515
+ redos: s,
1516
+ undos: o
1463
1517
  };
1464
1518
  }
1465
- _getUpdateOrDeleteDrawings(range, type, drawing) {
1466
- const updateDrawings = [], deleteDrawings = [], { sheetTransform, anchorType = SheetDrawingAnchorType.Position, transform, unitId, subUnitId, drawingId } = drawing, { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1467
- if (sheetTransform == null || transform == null)
1519
+ _getUpdateOrDeleteDrawings(i, e, n) {
1520
+ const t = [], r = [], { sheetTransform: s, anchorType: o = y.Position, transform: d, unitId: l, subUnitId: g, drawingId: c } = n, { from: a, to: h } = s, { row: u, column: m } = a, { row: f, column: p } = h;
1521
+ if (s == null || d == null)
1468
1522
  return {
1469
- updateDrawings,
1470
- deleteDrawings
1523
+ updateDrawings: t,
1524
+ deleteDrawings: r
1471
1525
  };
1472
- const { startRow, endRow, startColumn, endColumn } = range;
1473
- let newSheetTransform = null, newTransform = null;
1474
- if (type === 0 && fromRow >= startRow && toRow <= endRow)
1475
- if (fromColumn >= startColumn && toColumn <= endColumn)
1476
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1526
+ const { startRow: I, endRow: S, startColumn: v, endColumn: R } = i;
1527
+ let _ = null, C = null;
1528
+ if (e === 0 && u >= I && f <= S)
1529
+ if (m >= v && p <= R)
1530
+ r.push({ unitId: l, subUnitId: g, drawingId: c });
1477
1531
  else {
1478
- const param = this._shrinkCol(sheetTransform, transform, startColumn, endColumn, anchorType);
1479
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1532
+ const w = this._shrinkCol(s, d, v, R, o);
1533
+ _ = w == null ? void 0 : w.newSheetTransform, C = w == null ? void 0 : w.newTransform;
1480
1534
  }
1481
- else if (type === 1 && fromColumn >= startColumn && toColumn <= endColumn)
1482
- if (fromRow >= startRow && toRow <= endRow)
1483
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1535
+ else if (e === 1 && m >= v && p <= R)
1536
+ if (u >= I && f <= S)
1537
+ r.push({ unitId: l, subUnitId: g, drawingId: c });
1484
1538
  else {
1485
- const param = this._shrinkRow(sheetTransform, transform, startRow, endRow, anchorType);
1486
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1539
+ const w = this._shrinkRow(s, d, I, S, o);
1540
+ _ = w == null ? void 0 : w.newSheetTransform, C = w == null ? void 0 : w.newTransform;
1487
1541
  }
1488
- else if (type === 2) {
1489
- const param = this._expandRow(sheetTransform, transform, startRow, endRow, anchorType);
1490
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1491
- } else if (type === 3) {
1492
- const param = this._expandCol(sheetTransform, transform, startColumn, endColumn, anchorType);
1493
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1542
+ else if (e === 2) {
1543
+ const w = this._expandRow(s, d, I, S, o);
1544
+ _ = w == null ? void 0 : w.newSheetTransform, C = w == null ? void 0 : w.newTransform;
1545
+ } else if (e === 3) {
1546
+ const w = this._expandCol(s, d, v, R, o);
1547
+ _ = w == null ? void 0 : w.newSheetTransform, C = w == null ? void 0 : w.newTransform;
1494
1548
  }
1495
- if (newSheetTransform != null && newTransform != null) {
1496
- const newTransform2 = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1497
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform2 });
1549
+ if (_ != null && C != null) {
1550
+ const w = B(_, this._selectionRenderService, this._skeletonManagerService);
1551
+ t.push({ ...n, sheetTransform: _, transform: w });
1498
1552
  }
1499
- return { updateDrawings, deleteDrawings };
1553
+ return { updateDrawings: t, deleteDrawings: r };
1500
1554
  }
1501
- _remainDrawingSize(transform, updateDrawings, drawing) {
1502
- const newSheetTransform = transformToDrawingPosition({ ...transform }, this._selectionRenderService);
1503
- newSheetTransform != null && updateDrawings.push({
1504
- ...drawing,
1505
- sheetTransform: newSheetTransform
1555
+ _remainDrawingSize(i, e, n) {
1556
+ const t = N({ ...i }, this._selectionRenderService);
1557
+ t != null && e.push({
1558
+ ...n,
1559
+ sheetTransform: t
1506
1560
  });
1507
1561
  }
1508
1562
  // eslint-disable-next-line max-lines-per-function
1509
- _getDrawingUndoForColVisible(unitId, subUnitId, ranges) {
1510
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
1511
- if (Object.keys(drawingData).forEach((drawingId) => {
1512
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1513
- if (anchorType === SheetDrawingAnchorType.None)
1514
- this._remainDrawingSize(transform, updateDrawings, drawing);
1563
+ _getDrawingUndoForColVisible(i, e, n) {
1564
+ const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
1565
+ if (Object.keys(t).forEach((c) => {
1566
+ const a = t[c], { sheetTransform: h, transform: u, anchorType: m = y.Position } = a;
1567
+ if (m === y.None)
1568
+ this._remainDrawingSize(u, r, a);
1515
1569
  else {
1516
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1517
- for (let i = 0; i < ranges.length; i++) {
1518
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1519
- if (toColumn < startColumn)
1570
+ const { from: f, to: p } = h, { row: I, column: S } = f, { row: v, column: R } = p;
1571
+ for (let _ = 0; _ < n.length; _++) {
1572
+ const C = n[_], { startRow: w, endRow: O, startColumn: b, endColumn: A } = C;
1573
+ if (R < b)
1520
1574
  continue;
1521
- if (anchorType === SheetDrawingAnchorType.Position) {
1522
- let newSheetTransform2 = null, newTransform2 = null;
1523
- if (fromColumn >= startColumn && fromColumn <= endColumn) {
1524
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
1525
- if (selectionCell == null)
1575
+ if (m === y.Position) {
1576
+ let D = null, U = null;
1577
+ if (S >= b && S <= A) {
1578
+ const L = this._skeletonManagerService.attachRangeWithCoord({ startColumn: S, endColumn: A, startRow: f.row, endRow: p.row });
1579
+ if (L == null)
1526
1580
  return;
1527
- newTransform2 = { ...transform, left: selectionCell.startX };
1581
+ U = { ...u, left: L.startX };
1528
1582
  }
1529
- if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
1530
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
1583
+ if (U != null && (D = N(U, this._selectionRenderService), D != null && U != null)) {
1584
+ r.push({ ...a, sheetTransform: D, transform: U });
1531
1585
  break;
1532
1586
  }
1533
- this._remainDrawingSize(transform, updateDrawings, drawing);
1587
+ this._remainDrawingSize(u, r, a);
1534
1588
  continue;
1535
1589
  }
1536
- if (fromColumn >= startColumn && toColumn <= endColumn)
1590
+ if (S >= b && R <= A)
1537
1591
  continue;
1538
- let newSheetTransform = null, newTransform = null;
1539
- if (fromColumn >= startColumn && fromColumn <= endColumn) {
1540
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: fromColumn, endColumn, startRow: from.row, endRow: to.row });
1541
- if (selectionCell == null)
1592
+ let E = null, M = null;
1593
+ if (S >= b && S <= A) {
1594
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: S, endColumn: A, startRow: f.row, endRow: p.row });
1595
+ if (D == null)
1542
1596
  return;
1543
- newTransform = {
1544
- ...transform,
1545
- left: (selectionCell == null ? void 0 : selectionCell.startX) || 0,
1546
- width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
1597
+ M = {
1598
+ ...u,
1599
+ left: (D == null ? void 0 : D.startX) || 0,
1600
+ width: ((u == null ? void 0 : u.width) || 0) - D.endX + D.startX
1547
1601
  };
1548
- } else if (toColumn >= startColumn && toColumn <= endColumn) {
1549
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn: toColumn, startRow: from.row, endRow: to.row });
1550
- if (selectionCell == null)
1602
+ } else if (R >= b && R <= A) {
1603
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: b, endColumn: R, startRow: f.row, endRow: p.row });
1604
+ if (D == null)
1551
1605
  return;
1552
- newTransform = {
1553
- ...transform,
1554
- left: selectionCell.startX - ((transform == null ? void 0 : transform.width) || 0)
1606
+ M = {
1607
+ ...u,
1608
+ left: D.startX - ((u == null ? void 0 : u.width) || 0)
1555
1609
  };
1556
1610
  } else {
1557
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn, endColumn, startRow: from.row, endRow: to.row });
1558
- if (selectionCell == null)
1611
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: b, endColumn: A, startRow: f.row, endRow: p.row });
1612
+ if (D == null)
1559
1613
  return;
1560
- if (newTransform = {
1561
- ...transform,
1562
- width: ((transform == null ? void 0 : transform.width) || 0) - selectionCell.endX + selectionCell.startX
1563
- }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
1564
- preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1614
+ if (M = {
1615
+ ...u,
1616
+ width: ((u == null ? void 0 : u.width) || 0) - D.endX + D.startX
1617
+ }, E = N(M, this._selectionRenderService), E != null && M != null) {
1618
+ s.push({ ...a, sheetTransform: E, transform: M });
1565
1619
  break;
1566
1620
  }
1567
1621
  }
1568
- if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
1569
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1622
+ if (M != null && (E = N(M, this._selectionRenderService)), M != null && E != null) {
1623
+ r.push({ ...a, sheetTransform: E, transform: M });
1570
1624
  break;
1571
1625
  } else
1572
- this._remainDrawingSize(transform, updateDrawings, drawing);
1626
+ this._remainDrawingSize(u, r, a);
1573
1627
  }
1574
1628
  }
1575
- }), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
1629
+ }), r.length === 0 && s.length === 0)
1576
1630
  return { redos: [], undos: [] };
1577
- const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
1578
- if (preUpdateDrawings.length > 0) {
1579
- const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
1580
- preRedos.push(...redos2), preUndos.push(...undos2);
1631
+ const { redos: o, undos: d } = this._createUndoAndRedoMutation(i, e, r), l = [], g = [];
1632
+ if (s.length > 0) {
1633
+ const { redos: c, undos: a } = this._createUndoAndRedoMutation(i, e, s);
1634
+ l.push(...c), g.push(...a);
1581
1635
  }
1582
1636
  return {
1583
- redos,
1584
- undos,
1585
- preRedos,
1586
- preUndos
1637
+ redos: o,
1638
+ undos: d,
1639
+ preRedos: l,
1640
+ preUndos: g
1587
1641
  };
1588
1642
  }
1589
- _createUndoAndRedoMutation(unitId, subUnitId, updateDrawings) {
1590
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp, redos = [
1591
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } },
1592
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
1593
- ], undos = [
1594
- { id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } },
1595
- { id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }
1643
+ _createUndoAndRedoMutation(i, e, n) {
1644
+ const t = this._sheetDrawingService.getBatchUpdateOp(n), { undo: r, redo: s, objects: o } = t, d = [
1645
+ { id: P.id, params: { unitId: i, subUnitId: e, op: s, objects: o, type: T.UPDATE } },
1646
+ { id: j.id, params: [i] }
1647
+ ], l = [
1648
+ { id: P.id, params: { unitId: i, subUnitId: e, op: r, objects: o, type: T.UPDATE } },
1649
+ { id: j.id, params: [i] }
1596
1650
  ];
1597
1651
  return {
1598
- redos,
1599
- undos
1652
+ redos: d,
1653
+ undos: l
1600
1654
  };
1601
1655
  }
1602
1656
  // eslint-disable-next-line max-lines-per-function
1603
- _getDrawingUndoForRowVisible(unitId, subUnitId, ranges) {
1604
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [], preUpdateDrawings = [];
1605
- if (Object.keys(drawingData).forEach((drawingId) => {
1606
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1607
- if (anchorType === SheetDrawingAnchorType.None)
1608
- this._remainDrawingSize(transform, updateDrawings, drawing);
1657
+ _getDrawingUndoForRowVisible(i, e, n) {
1658
+ const t = this._drawingManagerService.getDrawingData(i, e), r = [], s = [];
1659
+ if (Object.keys(t).forEach((c) => {
1660
+ const a = t[c], { sheetTransform: h, transform: u, anchorType: m = y.Position } = a;
1661
+ if (m === y.None)
1662
+ this._remainDrawingSize(u, r, a);
1609
1663
  else {
1610
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1611
- for (let i = 0; i < ranges.length; i++) {
1612
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1613
- if (toRow < startRow)
1664
+ const { from: f, to: p } = h, { row: I, column: S } = f, { row: v, column: R } = p;
1665
+ for (let _ = 0; _ < n.length; _++) {
1666
+ const C = n[_], { startRow: w, endRow: O, startColumn: b, endColumn: A } = C;
1667
+ if (v < w)
1614
1668
  continue;
1615
- if (anchorType === SheetDrawingAnchorType.Position) {
1616
- let newSheetTransform2 = null, newTransform2 = null;
1617
- if (fromRow >= startRow && fromRow <= endRow) {
1618
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
1619
- if (selectionCell == null)
1669
+ if (m === y.Position) {
1670
+ let D = null, U = null;
1671
+ if (I >= w && I <= O) {
1672
+ const L = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: I, endRow: O });
1673
+ if (L == null)
1620
1674
  return;
1621
- newTransform2 = { ...transform, top: selectionCell.startY };
1675
+ U = { ...u, top: L.startY };
1622
1676
  }
1623
- if (newTransform2 != null && (newSheetTransform2 = transformToDrawingPosition(newTransform2, this._selectionRenderService), newSheetTransform2 != null && newTransform2 != null)) {
1624
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform2, transform: newTransform2 });
1677
+ if (U != null && (D = N(U, this._selectionRenderService), D != null && U != null)) {
1678
+ r.push({ ...a, sheetTransform: D, transform: U });
1625
1679
  break;
1626
1680
  }
1627
- this._remainDrawingSize(transform, updateDrawings, drawing);
1681
+ this._remainDrawingSize(u, r, a);
1628
1682
  continue;
1629
1683
  }
1630
- if (fromRow >= startRow && toRow <= endRow)
1684
+ if (I >= w && v <= O)
1631
1685
  continue;
1632
- let newSheetTransform = null, newTransform = null;
1633
- if (fromRow >= startRow && fromRow <= endRow) {
1634
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow: fromRow, endRow });
1635
- if (selectionCell == null)
1686
+ let E = null, M = null;
1687
+ if (I >= w && I <= O) {
1688
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: I, endRow: O });
1689
+ if (D == null)
1636
1690
  return;
1637
- newTransform = {
1638
- ...transform,
1639
- top: (selectionCell == null ? void 0 : selectionCell.startY) || 0,
1640
- height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
1691
+ M = {
1692
+ ...u,
1693
+ top: (D == null ? void 0 : D.startY) || 0,
1694
+ height: ((u == null ? void 0 : u.height) || 0) - D.endY + D.startY
1641
1695
  };
1642
- } else if (toRow >= startRow && toRow <= endRow) {
1643
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow: toRow });
1644
- if (selectionCell == null)
1696
+ } else if (v >= w && v <= O) {
1697
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: w, endRow: v });
1698
+ if (D == null)
1645
1699
  return;
1646
- newTransform = {
1647
- ...transform,
1648
- top: selectionCell.startY - ((transform == null ? void 0 : transform.height) || 0)
1700
+ M = {
1701
+ ...u,
1702
+ top: D.startY - ((u == null ? void 0 : u.height) || 0)
1649
1703
  };
1650
1704
  } else {
1651
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: to.column, startRow, endRow });
1652
- if (selectionCell == null)
1705
+ const D = this._skeletonManagerService.attachRangeWithCoord({ startColumn: f.column, endColumn: p.column, startRow: w, endRow: O });
1706
+ if (D == null)
1653
1707
  return;
1654
- if (newTransform = {
1655
- ...transform,
1656
- height: ((transform == null ? void 0 : transform.height) || 0) - selectionCell.endY + selectionCell.startY
1657
- }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService), newSheetTransform != null && newTransform != null) {
1658
- preUpdateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1708
+ if (M = {
1709
+ ...u,
1710
+ height: ((u == null ? void 0 : u.height) || 0) - D.endY + D.startY
1711
+ }, E = N(M, this._selectionRenderService), E != null && M != null) {
1712
+ s.push({ ...a, sheetTransform: E, transform: M });
1659
1713
  break;
1660
1714
  }
1661
1715
  }
1662
- if (newTransform != null && (newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService)), newTransform != null && newSheetTransform != null) {
1663
- updateDrawings.push({ ...drawing, sheetTransform: newSheetTransform, transform: newTransform });
1716
+ if (M != null && (E = N(M, this._selectionRenderService)), M != null && E != null) {
1717
+ r.push({ ...a, sheetTransform: E, transform: M });
1664
1718
  break;
1665
1719
  } else
1666
- this._remainDrawingSize(transform, updateDrawings, drawing);
1720
+ this._remainDrawingSize(u, r, a);
1667
1721
  }
1668
1722
  }
1669
- }), updateDrawings.length === 0 && preUpdateDrawings.length === 0)
1723
+ }), r.length === 0 && s.length === 0)
1670
1724
  return { redos: [], undos: [] };
1671
- const { redos, undos } = this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings), preRedos = [], preUndos = [];
1672
- if (preUpdateDrawings.length > 0) {
1673
- const { redos: redos2, undos: undos2 } = this._createUndoAndRedoMutation(unitId, subUnitId, preUpdateDrawings);
1674
- preRedos.push(...redos2), preUndos.push(...undos2);
1725
+ const { redos: o, undos: d } = this._createUndoAndRedoMutation(i, e, r), l = [], g = [];
1726
+ if (s.length > 0) {
1727
+ const { redos: c, undos: a } = this._createUndoAndRedoMutation(i, e, s);
1728
+ l.push(...c), g.push(...a);
1675
1729
  }
1676
1730
  return {
1677
- redos,
1678
- undos,
1679
- preRedos,
1680
- preUndos
1731
+ redos: o,
1732
+ undos: d,
1733
+ preRedos: l,
1734
+ preUndos: g
1681
1735
  };
1682
1736
  }
1683
- _getDrawingUndoForRowAndColSize(unitId, subUnitId, ranges, isRow) {
1684
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
1685
- return Object.keys(drawingData).forEach((drawingId) => {
1686
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1687
- if (anchorType === SheetDrawingAnchorType.None)
1688
- this._remainDrawingSize(transform, updateDrawings, drawing);
1737
+ _getDrawingUndoForRowAndColSize(i, e, n, t) {
1738
+ const r = this._drawingManagerService.getDrawingData(i, e), s = [];
1739
+ return Object.keys(r).forEach((o) => {
1740
+ const d = r[o], { sheetTransform: l, transform: g, anchorType: c = y.Position } = d;
1741
+ if (c === y.None)
1742
+ this._remainDrawingSize(g, s, d);
1689
1743
  else {
1690
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
1691
- for (let i = 0; i < ranges.length; i++) {
1692
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
1693
- if (toRow < startRow || toColumn < startColumn)
1744
+ const { from: a, to: h } = l, { row: u, column: m } = a, { row: f, column: p } = h;
1745
+ for (let I = 0; I < n.length; I++) {
1746
+ const S = n[I], { startRow: v, endRow: R, startColumn: _, endColumn: C } = S;
1747
+ if (f < v || p < _)
1694
1748
  continue;
1695
- if (anchorType === SheetDrawingAnchorType.Position && (fromRow <= startRow && toRow >= endRow || fromColumn <= startColumn && toColumn >= endColumn)) {
1696
- this._remainDrawingSize(transform, updateDrawings, drawing);
1749
+ if (c === y.Position && (u <= v && f >= R || m <= _ && p >= C)) {
1750
+ this._remainDrawingSize(g, s, d);
1697
1751
  continue;
1698
1752
  }
1699
- const newTransform = drawingPositionToTransform(
1700
- { ...sheetTransform },
1753
+ const w = B(
1754
+ { ...l },
1701
1755
  this._selectionRenderService,
1702
1756
  this._skeletonManagerService
1703
1757
  );
1704
- if (newTransform != null) {
1705
- updateDrawings.push({
1706
- ...drawing,
1707
- transform: newTransform
1758
+ if (w != null) {
1759
+ s.push({
1760
+ ...d,
1761
+ transform: w
1708
1762
  });
1709
1763
  break;
1710
1764
  }
1711
1765
  }
1712
1766
  }
1713
- }), updateDrawings.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(unitId, subUnitId, updateDrawings);
1767
+ }), s.length === 0 ? { redos: [], undos: [] } : this._createUndoAndRedoMutation(i, e, s);
1714
1768
  }
1715
- _getUnitIdAndSubUnitId(params, type) {
1716
- let unitId, subUnitId;
1717
- if (type === "insert")
1718
- unitId = params.unitId, subUnitId = params.subUnitId;
1769
+ _getUnitIdAndSubUnitId(i, e) {
1770
+ let n, t;
1771
+ if (e === "insert")
1772
+ n = i.unitId, t = i.subUnitId;
1719
1773
  else {
1720
- const newParams = getSheetCommandTarget(this._univerInstanceService);
1721
- if (newParams == null)
1774
+ const r = ce(this._univerInstanceService);
1775
+ if (r == null)
1722
1776
  return;
1723
- unitId = newParams.unitId, subUnitId = newParams.subUnitId;
1777
+ n = r.unitId, t = r.subUnitId;
1724
1778
  }
1725
- return { unitId, subUnitId };
1779
+ return { unitId: n, subUnitId: t };
1726
1780
  }
1727
- _moveRangeInterceptor(params) {
1728
- var _a10, _b;
1729
- const { toRange, fromRange } = params, target = getSheetCommandTarget(this._univerInstanceService);
1730
- if (!target)
1781
+ _moveRangeInterceptor(i) {
1782
+ var v, R;
1783
+ const { toRange: e, fromRange: n } = i, t = ce(this._univerInstanceService);
1784
+ if (!t)
1731
1785
  return { redos: [], undos: [] };
1732
- const { unitId, subUnitId } = target, skeleton = (_b = (_a10 = this._renderManagerService.getRenderById(unitId)) == null ? void 0 : _a10.with(SheetSkeletonManagerService)) == null ? void 0 : _b.getCurrentSkeleton();
1733
- if (!skeleton)
1786
+ const { unitId: r, subUnitId: s } = t, o = (R = (v = this._renderManagerService.getRenderById(r)) == null ? void 0 : v.with(q)) == null ? void 0 : R.getCurrentSkeleton();
1787
+ if (!o)
1734
1788
  return { redos: [], undos: [] };
1735
- const selectionRect = attachRangeWithCoord(skeleton, fromRange);
1736
- if (!selectionRect)
1789
+ const d = Te(o, n);
1790
+ if (!d)
1737
1791
  return { redos: [], undos: [] };
1738
- const { startX, endX, startY, endY } = selectionRect, drawings = this._sheetDrawingService.getDrawingData(unitId, subUnitId), containedDrawings = [];
1739
- Object.keys(drawings).forEach((drawingId) => {
1740
- const drawing = drawings[drawingId];
1741
- if (drawing.anchorType !== SheetDrawingAnchorType.Both)
1792
+ const { startX: l, endX: g, startY: c, endY: a } = d, h = this._sheetDrawingService.getDrawingData(r, s), u = [];
1793
+ Object.keys(h).forEach((_) => {
1794
+ const C = h[_];
1795
+ if (C.anchorType !== y.Both)
1742
1796
  return;
1743
- const { transform } = drawing;
1744
- if (!transform)
1797
+ const { transform: w } = C;
1798
+ if (!w)
1745
1799
  return;
1746
- const { left = 0, top = 0, width = 0, height = 0 } = transform, { drawingStartX, drawingEndX, drawingStartY, drawingEndY } = {
1747
- drawingStartX: left,
1748
- drawingEndX: left + width,
1749
- drawingStartY: top,
1750
- drawingEndY: top + height
1800
+ const { left: O = 0, top: b = 0, width: A = 0, height: E = 0 } = w, { drawingStartX: M, drawingEndX: D, drawingStartY: U, drawingEndY: L } = {
1801
+ drawingStartX: O,
1802
+ drawingEndX: O + A,
1803
+ drawingStartY: b,
1804
+ drawingEndY: b + E
1751
1805
  };
1752
- startX <= drawingStartX && drawingEndX <= endX && startY <= drawingStartY && drawingEndY <= endY && containedDrawings.push(drawing);
1806
+ l <= M && D <= g && c <= U && L <= a && u.push(C);
1753
1807
  });
1754
- const redos = [], undos = [], rowOffset = toRange.startRow - fromRange.startRow, colOffset = toRange.startColumn - fromRange.startColumn, updateDrawings = containedDrawings.map((drawing) => {
1755
- const oldSheetTransform = drawing.sheetTransform, sheetTransform = {
1756
- to: { ...oldSheetTransform.to, row: oldSheetTransform.to.row + rowOffset, column: oldSheetTransform.to.column + colOffset },
1757
- from: { ...oldSheetTransform.from, row: oldSheetTransform.from.row + rowOffset, column: oldSheetTransform.from.column + colOffset }
1758
- }, transform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
1808
+ const m = [], f = [], p = e.startRow - n.startRow, I = e.startColumn - n.startColumn, S = u.map((_) => {
1809
+ const C = _.sheetTransform, w = {
1810
+ to: { ...C.to, row: C.to.row + p, column: C.to.column + I },
1811
+ from: { ...C.from, row: C.from.row + p, column: C.from.column + I }
1812
+ }, O = B(w, this._selectionRenderService, this._skeletonManagerService);
1759
1813
  return {
1760
- unitId,
1761
- subUnitId,
1762
- drawingId: drawing.drawingId,
1763
- transform,
1764
- sheetTransform
1814
+ unitId: r,
1815
+ subUnitId: s,
1816
+ drawingId: _.drawingId,
1817
+ transform: O,
1818
+ sheetTransform: w
1765
1819
  };
1766
1820
  });
1767
- if (updateDrawings.length) {
1768
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1769
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1821
+ if (S.length) {
1822
+ const _ = this._sheetDrawingService.getBatchUpdateOp(S), { undo: C, redo: w, objects: O } = _;
1823
+ m.push({ id: P.id, params: { unitId: r, subUnitId: s, op: w, objects: O, type: T.UPDATE } }), f.push({ id: P.id, params: { unitId: r, subUnitId: s, op: C, objects: O, type: T.UPDATE } });
1770
1824
  }
1771
- return { redos, undos };
1825
+ return { redos: m, undos: f };
1772
1826
  }
1773
- _moveRowInterceptor(params, type) {
1774
- const ids = this._getUnitIdAndSubUnitId(params, type);
1775
- if (ids == null)
1827
+ _moveRowInterceptor(i, e) {
1828
+ const n = this._getUnitIdAndSubUnitId(i, e);
1829
+ if (n == null)
1776
1830
  return { redos: [], undos: [] };
1777
- const { unitId, subUnitId } = ids, { range } = params, rowStartIndex = range.startRow, rowEndIndex = range.endRow, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1778
- if (Object.keys(data).forEach((drawingId) => {
1779
- const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1780
- if (sheetTransform == null || transform == null)
1831
+ const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startRow, d = s.endRow, l = [], g = [], c = this._sheetDrawingService.getDrawingData(t, r), a = [], h = [];
1832
+ if (Object.keys(c).forEach((u) => {
1833
+ const m = c[u], { sheetTransform: f, transform: p, anchorType: I = y.Position } = m;
1834
+ if (f == null || p == null)
1781
1835
  return;
1782
- let newSheetTransform, newTransform;
1783
- if (type === "insert") {
1784
- const param = this._expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
1785
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1836
+ let S, v;
1837
+ if (e === "insert") {
1838
+ const _ = this._expandRow(f, p, o, d, I);
1839
+ S = _ == null ? void 0 : _.newSheetTransform, v = _ == null ? void 0 : _.newTransform;
1786
1840
  } else {
1787
- const { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1788
- if (anchorType === SheetDrawingAnchorType.Both && fromRow >= rowStartIndex && toRow <= rowEndIndex)
1789
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1841
+ const { from: _, to: C } = f, { row: w } = _, { row: O } = C;
1842
+ if (I === y.Both && w >= o && O <= d)
1843
+ h.push({ unitId: t, subUnitId: r, drawingId: u });
1790
1844
  else {
1791
- const param = this._shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType);
1792
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1845
+ const b = this._shrinkRow(f, p, o, d, I);
1846
+ S = b == null ? void 0 : b.newSheetTransform, v = b == null ? void 0 : b.newTransform;
1793
1847
  }
1794
1848
  }
1795
- if (!newSheetTransform || !newTransform)
1849
+ if (!S || !v)
1796
1850
  return;
1797
- const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
1798
- updateDrawings.push(params2);
1799
- }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1851
+ const R = { unitId: t, subUnitId: r, drawingId: u, transform: v, sheetTransform: S };
1852
+ a.push(R);
1853
+ }), a.length === 0 && h.length === 0)
1800
1854
  return { redos: [], undos: [] };
1801
- if (updateDrawings.length > 0) {
1802
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1803
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1855
+ if (a.length > 0) {
1856
+ const u = this._sheetDrawingService.getBatchUpdateOp(a), { undo: m, redo: f, objects: p } = u;
1857
+ l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.UPDATE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.UPDATE } });
1804
1858
  }
1805
- if (deleteDrawings.length > 0) {
1806
- const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1807
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1859
+ if (h.length > 0) {
1860
+ const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, f = u.redo, p = u.objects;
1861
+ l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.REMOVE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.INSERT } });
1808
1862
  }
1809
- return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), {
1810
- redos,
1811
- undos
1863
+ return l.push({ id: j.id, params: [t] }), g.push({ id: j.id, params: [t] }), {
1864
+ redos: l,
1865
+ undos: g
1812
1866
  };
1813
1867
  }
1814
- _moveColInterceptor(params, type) {
1815
- const ids = this._getUnitIdAndSubUnitId(params, type);
1816
- if (ids == null)
1868
+ _moveColInterceptor(i, e) {
1869
+ const n = this._getUnitIdAndSubUnitId(i, e);
1870
+ if (n == null)
1817
1871
  return { redos: [], undos: [] };
1818
- const { unitId, subUnitId } = ids, { range } = params, colStartIndex = range.startColumn, colEndIndex = range.endColumn, redos = [], undos = [], data = this._sheetDrawingService.getDrawingData(unitId, subUnitId), updateDrawings = [], deleteDrawings = [];
1819
- if (Object.keys(data).forEach((drawingId) => {
1820
- const drawing = data[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
1821
- if (sheetTransform == null || transform == null)
1872
+ const { unitId: t, subUnitId: r } = n, { range: s } = i, o = s.startColumn, d = s.endColumn, l = [], g = [], c = this._sheetDrawingService.getDrawingData(t, r), a = [], h = [];
1873
+ if (Object.keys(c).forEach((u) => {
1874
+ const m = c[u], { sheetTransform: f, transform: p, anchorType: I = y.Position } = m;
1875
+ if (f == null || p == null)
1822
1876
  return;
1823
- let newSheetTransform, newTransform;
1824
- if (type === "insert") {
1825
- const param = this._expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
1826
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1877
+ let S, v;
1878
+ if (e === "insert") {
1879
+ const _ = this._expandCol(f, p, o, d, I);
1880
+ S = _ == null ? void 0 : _.newSheetTransform, v = _ == null ? void 0 : _.newTransform;
1827
1881
  } else {
1828
- const { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1829
- if (anchorType === SheetDrawingAnchorType.Both && fromColumn >= colStartIndex && toColumn <= colEndIndex)
1830
- deleteDrawings.push({ unitId, subUnitId, drawingId });
1882
+ const { from: _, to: C } = f, { column: w } = _, { column: O } = C;
1883
+ if (I === y.Both && w >= o && O <= d)
1884
+ h.push({ unitId: t, subUnitId: r, drawingId: u });
1831
1885
  else {
1832
- const param = this._shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType);
1833
- newSheetTransform = param == null ? void 0 : param.newSheetTransform, newTransform = param == null ? void 0 : param.newTransform;
1886
+ const b = this._shrinkCol(f, p, o, d, I);
1887
+ S = b == null ? void 0 : b.newSheetTransform, v = b == null ? void 0 : b.newTransform;
1834
1888
  }
1835
1889
  }
1836
- if (!newSheetTransform || !newTransform)
1890
+ if (!S || !v)
1837
1891
  return;
1838
- const params2 = { unitId, subUnitId, drawingId, transform: newTransform, sheetTransform: newSheetTransform };
1839
- updateDrawings.push(params2);
1840
- }), updateDrawings.length === 0 && deleteDrawings.length === 0)
1892
+ const R = { unitId: t, subUnitId: r, drawingId: u, transform: v, sheetTransform: S };
1893
+ a.push(R);
1894
+ }), a.length === 0 && h.length === 0)
1841
1895
  return { redos: [], undos: [] };
1842
- if (updateDrawings.length > 0) {
1843
- const updateJsonOp = this._sheetDrawingService.getBatchUpdateOp(updateDrawings), { undo, redo, objects } = updateJsonOp;
1844
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: redo, objects, type: DrawingApplyType.UPDATE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: undo, objects, type: DrawingApplyType.UPDATE } });
1896
+ if (a.length > 0) {
1897
+ const u = this._sheetDrawingService.getBatchUpdateOp(a), { undo: m, redo: f, objects: p } = u;
1898
+ l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.UPDATE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.UPDATE } });
1845
1899
  }
1846
- if (deleteDrawings.length > 0) {
1847
- const deleteJsonOp = this._sheetDrawingService.getBatchRemoveOp(deleteDrawings), deleteUndo = deleteJsonOp.undo, deleteRedo = deleteJsonOp.redo, deleteObjects = deleteJsonOp.objects;
1848
- redos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteRedo, objects: deleteObjects, type: DrawingApplyType.REMOVE } }), undos.push({ id: SetDrawingApplyMutation.id, params: { unitId, subUnitId, op: deleteUndo, objects: deleteObjects, type: DrawingApplyType.INSERT } });
1900
+ if (h.length > 0) {
1901
+ const u = this._sheetDrawingService.getBatchRemoveOp(h), m = u.undo, f = u.redo, p = u.objects;
1902
+ l.push({ id: P.id, params: { unitId: t, subUnitId: r, op: f, objects: p, type: T.REMOVE } }), g.push({ id: P.id, params: { unitId: t, subUnitId: r, op: m, objects: p, type: T.INSERT } });
1849
1903
  }
1850
- return redos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), undos.push({ id: ClearSheetDrawingTransformerOperation.id, params: [unitId] }), { redos, undos };
1904
+ return l.push({ id: j.id, params: [t] }), g.push({ id: j.id, params: [t] }), { redos: l, undos: g };
1851
1905
  }
1852
- _expandCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1853
- const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1854
- if (anchorType === SheetDrawingAnchorType.None)
1906
+ _expandCol(i, e, n, t, r = y.Position) {
1907
+ const s = t - n + 1, { from: o, to: d } = i, { column: l } = o, { column: g } = d;
1908
+ if (r === y.None)
1855
1909
  return {
1856
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1857
- newTransform: transform
1910
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1911
+ newTransform: e
1858
1912
  };
1859
- let newSheetTransform = null, newTransform = null;
1860
- if (fromColumn >= colStartIndex) {
1861
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: colEndIndex, startRow: from.row, endRow: to.row });
1862
- if (selectionCell == null)
1913
+ let c = null, a = null;
1914
+ if (l >= n) {
1915
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: t, startRow: o.row, endRow: d.row });
1916
+ if (h == null)
1863
1917
  return;
1864
- newTransform = { ...transform, left: (transform.left || 0) + selectionCell.endX - selectionCell.startX }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1865
- } else if (toColumn >= colEndIndex)
1866
- if (anchorType === SheetDrawingAnchorType.Both)
1867
- newSheetTransform = {
1868
- from: { ...from },
1869
- to: { ...to, column: toColumn + colCount }
1870
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1918
+ a = { ...e, left: (e.left || 0) + h.endX - h.startX }, c = N(a, this._selectionRenderService);
1919
+ } else if (g >= t)
1920
+ if (r === y.Both)
1921
+ c = {
1922
+ from: { ...o },
1923
+ to: { ...d, column: g + s }
1924
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
1871
1925
  else
1872
1926
  return {
1873
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1874
- newTransform: transform
1927
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1928
+ newTransform: e
1875
1929
  };
1876
- return newSheetTransform != null && newTransform != null ? {
1877
- newSheetTransform,
1878
- newTransform
1930
+ return c != null && a != null ? {
1931
+ newSheetTransform: c,
1932
+ newTransform: a
1879
1933
  } : null;
1880
1934
  }
1881
- _shrinkCol(sheetTransform, transform, colStartIndex, colEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1882
- const colCount = colEndIndex - colStartIndex + 1, { from, to } = sheetTransform, { column: fromColumn } = from, { column: toColumn } = to;
1883
- if (anchorType === SheetDrawingAnchorType.None)
1935
+ _shrinkCol(i, e, n, t, r = y.Position) {
1936
+ const s = t - n + 1, { from: o, to: d } = i, { column: l } = o, { column: g } = d;
1937
+ if (r === y.None)
1884
1938
  return {
1885
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1886
- newTransform: transform
1939
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1940
+ newTransform: e
1887
1941
  };
1888
- let newSheetTransform = null, newTransform = null;
1889
- if (fromColumn > colEndIndex)
1890
- newSheetTransform = {
1891
- from: { ...from, column: fromColumn - colCount },
1892
- to: { ...to, column: toColumn - colCount }
1893
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1942
+ let c = null, a = null;
1943
+ if (l > t)
1944
+ c = {
1945
+ from: { ...o, column: l - s },
1946
+ to: { ...d, column: g - s }
1947
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
1894
1948
  else {
1895
- if (fromColumn >= colStartIndex && toColumn <= colEndIndex)
1949
+ if (l >= n && g <= t)
1896
1950
  return null;
1897
- if (fromColumn < colStartIndex && toColumn > colEndIndex)
1898
- if (anchorType === SheetDrawingAnchorType.Both)
1899
- newSheetTransform = {
1900
- from: { ...from },
1901
- to: { ...to, column: toColumn - colCount }
1902
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1951
+ if (l < n && g > t)
1952
+ if (r === y.Both)
1953
+ c = {
1954
+ from: { ...o },
1955
+ to: { ...d, column: g - s }
1956
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
1903
1957
  else
1904
1958
  return {
1905
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1906
- newTransform: transform
1959
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1960
+ newTransform: e
1907
1961
  };
1908
- else if (fromColumn >= colStartIndex && fromColumn <= colEndIndex) {
1909
- if (fromColumn === colStartIndex)
1910
- newTransform = { ...transform, left: (transform.left || 0) - sheetTransform.from.columnOffset };
1962
+ else if (l >= n && l <= t) {
1963
+ if (l === n)
1964
+ a = { ...e, left: (e.left || 0) - i.from.columnOffset };
1911
1965
  else {
1912
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: colStartIndex, endColumn: fromColumn - 1, startRow: from.row, endRow: to.row });
1913
- if (selectionCell == null)
1966
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: n, endColumn: l - 1, startRow: o.row, endRow: d.row });
1967
+ if (h == null)
1914
1968
  return;
1915
- newTransform = { ...transform, left: (transform.left || 0) - selectionCell.endX + selectionCell.startX - sheetTransform.from.columnOffset };
1969
+ a = { ...e, left: (e.left || 0) - h.endX + h.startX - i.from.columnOffset };
1916
1970
  }
1917
- newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1918
- } else if (toColumn >= colStartIndex && toColumn <= colEndIndex && anchorType === SheetDrawingAnchorType.Both) {
1919
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({
1920
- startColumn: colStartIndex - 1,
1921
- endColumn: colStartIndex - 1,
1922
- startRow: from.row,
1923
- endRow: to.row
1971
+ c = N(a, this._selectionRenderService);
1972
+ } else if (g >= n && g <= t && r === y.Both) {
1973
+ const h = this._skeletonManagerService.attachRangeWithCoord({
1974
+ startColumn: n - 1,
1975
+ endColumn: n - 1,
1976
+ startRow: o.row,
1977
+ endRow: d.row
1924
1978
  });
1925
- if (selectionCell == null)
1979
+ if (h == null)
1926
1980
  return;
1927
- newSheetTransform = {
1928
- from: { ...from },
1929
- to: { ...to, column: colStartIndex - 1, columnOffset: selectionCell.endX - selectionCell.startX }
1930
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
1981
+ c = {
1982
+ from: { ...o },
1983
+ to: { ...d, column: n - 1, columnOffset: h.endX - h.startX }
1984
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
1931
1985
  }
1932
1986
  }
1933
- return newSheetTransform != null && newTransform != null ? {
1934
- newSheetTransform,
1935
- newTransform
1987
+ return c != null && a != null ? {
1988
+ newSheetTransform: c,
1989
+ newTransform: a
1936
1990
  } : null;
1937
1991
  }
1938
- _expandRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1939
- const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1940
- if (anchorType === SheetDrawingAnchorType.None)
1992
+ _expandRow(i, e, n, t, r = y.Position) {
1993
+ const s = t - n + 1, { from: o, to: d } = i, { row: l } = o, { row: g } = d;
1994
+ if (r === y.None)
1941
1995
  return {
1942
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1943
- newTransform: transform
1996
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
1997
+ newTransform: e
1944
1998
  };
1945
- let newSheetTransform = null, newTransform = null;
1946
- if (fromRow >= rowStartIndex) {
1947
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: rowEndIndex, startColumn: from.column, endColumn: to.column });
1948
- if (selectionCell == null)
1999
+ let c = null, a = null;
2000
+ if (l >= n) {
2001
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: t, startColumn: o.column, endColumn: d.column });
2002
+ if (h == null)
1949
2003
  return;
1950
- newTransform = { ...transform, top: (transform.top || 0) + selectionCell.endY - selectionCell.startY }, newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
1951
- } else if (toRow >= rowEndIndex)
1952
- if (anchorType === SheetDrawingAnchorType.Both)
1953
- newSheetTransform = {
1954
- from: { ...from },
2004
+ a = { ...e, top: (e.top || 0) + h.endY - h.startY }, c = N(a, this._selectionRenderService);
2005
+ } else if (g >= t)
2006
+ if (r === y.Both)
2007
+ c = {
2008
+ from: { ...o },
1955
2009
  to: {
1956
- ...to,
1957
- row: toRow + rowCount
2010
+ ...d,
2011
+ row: g + s
1958
2012
  }
1959
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2013
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
1960
2014
  else
1961
2015
  return {
1962
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1963
- newTransform: transform
2016
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
2017
+ newTransform: e
1964
2018
  };
1965
- return newSheetTransform != null && newTransform != null ? {
1966
- newSheetTransform,
1967
- newTransform
2019
+ return c != null && a != null ? {
2020
+ newSheetTransform: c,
2021
+ newTransform: a
1968
2022
  } : null;
1969
2023
  }
1970
- _shrinkRow(sheetTransform, transform, rowStartIndex, rowEndIndex, anchorType = SheetDrawingAnchorType.Position) {
1971
- const rowCount = rowEndIndex - rowStartIndex + 1, { from, to } = sheetTransform, { row: fromRow } = from, { row: toRow } = to;
1972
- if (anchorType === SheetDrawingAnchorType.None)
2024
+ _shrinkRow(i, e, n, t, r = y.Position) {
2025
+ const s = t - n + 1, { from: o, to: d } = i, { row: l } = o, { row: g } = d;
2026
+ if (r === y.None)
1973
2027
  return {
1974
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1975
- newTransform: transform
2028
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
2029
+ newTransform: e
1976
2030
  };
1977
- let newSheetTransform = null, newTransform = null;
1978
- if (fromRow > rowEndIndex)
1979
- newSheetTransform = {
1980
- from: { ...from, row: fromRow - rowCount },
1981
- to: { ...to, row: toRow - rowCount }
1982
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2031
+ let c = null, a = null;
2032
+ if (l > t)
2033
+ c = {
2034
+ from: { ...o, row: l - s },
2035
+ to: { ...d, row: g - s }
2036
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
1983
2037
  else {
1984
- if (fromRow >= rowStartIndex && toRow <= rowEndIndex)
2038
+ if (l >= n && g <= t)
1985
2039
  return null;
1986
- if (fromRow < rowStartIndex && toRow > rowEndIndex)
1987
- if (anchorType === SheetDrawingAnchorType.Both)
1988
- newSheetTransform = {
1989
- from: { ...from },
1990
- to: { ...to, row: toRow - rowCount }
1991
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2040
+ if (l < n && g > t)
2041
+ if (r === y.Both)
2042
+ c = {
2043
+ from: { ...o },
2044
+ to: { ...d, row: g - s }
2045
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
1992
2046
  else
1993
2047
  return {
1994
- newSheetTransform: transformToDrawingPosition({ ...transform }, this._selectionRenderService),
1995
- newTransform: transform
2048
+ newSheetTransform: N({ ...e }, this._selectionRenderService),
2049
+ newTransform: e
1996
2050
  };
1997
- else if (fromRow >= rowStartIndex && fromRow <= rowEndIndex) {
1998
- if (fromRow === rowStartIndex)
1999
- newTransform = { ...transform, top: (transform.top || 0) - sheetTransform.from.rowOffset };
2051
+ else if (l >= n && l <= t) {
2052
+ if (l === n)
2053
+ a = { ...e, top: (e.top || 0) - i.from.rowOffset };
2000
2054
  else {
2001
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startRow: rowStartIndex, endRow: fromRow - 1, startColumn: from.column, endColumn: to.column });
2002
- if (selectionCell == null)
2055
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startRow: n, endRow: l - 1, startColumn: o.column, endColumn: d.column });
2056
+ if (h == null)
2003
2057
  return;
2004
- newTransform = { ...transform, top: (transform.top || 0) - selectionCell.endY + selectionCell.startY - sheetTransform.from.rowOffset };
2058
+ a = { ...e, top: (e.top || 0) - h.endY + h.startY - i.from.rowOffset };
2005
2059
  }
2006
- newSheetTransform = transformToDrawingPosition(newTransform, this._selectionRenderService);
2007
- } else if (toRow >= rowStartIndex && toRow <= rowEndIndex && anchorType === SheetDrawingAnchorType.Both) {
2008
- const selectionCell = this._skeletonManagerService.attachRangeWithCoord({ startColumn: from.column, endColumn: from.column, startRow: rowStartIndex - 1, endRow: rowStartIndex - 1 });
2009
- if (selectionCell == null)
2060
+ c = N(a, this._selectionRenderService);
2061
+ } else if (g >= n && g <= t && r === y.Both) {
2062
+ const h = this._skeletonManagerService.attachRangeWithCoord({ startColumn: o.column, endColumn: o.column, startRow: n - 1, endRow: n - 1 });
2063
+ if (h == null)
2010
2064
  return;
2011
- newSheetTransform = {
2012
- from: { ...from },
2013
- to: { ...to, row: rowStartIndex - 1, rowOffset: selectionCell.endY - selectionCell.startY }
2014
- }, newTransform = drawingPositionToTransform(newSheetTransform, this._selectionRenderService, this._skeletonManagerService);
2065
+ c = {
2066
+ from: { ...o },
2067
+ to: { ...d, row: n - 1, rowOffset: h.endY - h.startY }
2068
+ }, a = B(c, this._selectionRenderService, this._skeletonManagerService);
2015
2069
  }
2016
2070
  }
2017
- return newSheetTransform != null && newTransform != null ? {
2018
- newSheetTransform,
2019
- newTransform
2071
+ return c != null && a != null ? {
2072
+ newSheetTransform: c,
2073
+ newTransform: a
2020
2074
  } : null;
2021
2075
  }
2022
2076
  _commandListener() {
2023
2077
  this.disposeWithMe(
2024
- this._commandService.onCommandExecuted((command) => {
2025
- command.id === SetWorksheetActiveOperation.id && setTimeout(() => {
2026
- const params = command.params, { unitId: showUnitId, subUnitId: showSubunitId } = params, drawingMap = this._drawingManagerService.drawingManagerData, insertDrawings = [], removeDrawings = [];
2027
- Object.keys(drawingMap).forEach((unitId) => {
2028
- const subUnitMap = drawingMap[unitId];
2029
- subUnitMap != null && Object.keys(subUnitMap).forEach((subUnitId) => {
2030
- const drawingData = subUnitMap[subUnitId].data;
2031
- drawingData != null && Object.keys(drawingData).forEach((drawingId) => {
2032
- if (unitId === showUnitId && subUnitId === showSubunitId) {
2033
- const drawing = drawingData[drawingId];
2034
- drawing.transform = drawingPositionToTransform(drawing.sheetTransform, this._selectionRenderService, this._skeletonManagerService), insertDrawings.push(drawingData[drawingId]);
2078
+ this._commandService.onCommandExecuted((i) => {
2079
+ i.id === Dr.id && setTimeout(() => {
2080
+ const e = i.params, { unitId: n, subUnitId: t } = e, r = this._drawingManagerService.drawingManagerData, s = [], o = [];
2081
+ Object.keys(r).forEach((d) => {
2082
+ const l = r[d];
2083
+ l != null && Object.keys(l).forEach((g) => {
2084
+ const c = l[g].data;
2085
+ c != null && Object.keys(c).forEach((a) => {
2086
+ if (d === n && g === t) {
2087
+ const h = c[a];
2088
+ h.transform = B(h.sheetTransform, this._selectionRenderService, this._skeletonManagerService), s.push(c[a]);
2035
2089
  } else
2036
- removeDrawings.push(drawingData[drawingId]);
2090
+ o.push(c[a]);
2037
2091
  });
2038
2092
  });
2039
- }), this._drawingManagerService.removeNotification(removeDrawings), this._drawingManagerService.addNotification(insertDrawings);
2093
+ }), this._drawingManagerService.removeNotification(o), this._drawingManagerService.addNotification(s);
2040
2094
  }, 0);
2041
2095
  })
2042
2096
  );
2043
2097
  }
2044
2098
  _sheetRefreshListener() {
2045
2099
  this.disposeWithMe(
2046
- this._commandService.onCommandExecuted((command) => {
2047
- REFRESH_MUTATIONS.includes(command.id) && requestIdleCallback(() => {
2048
- const params = command.params, { unitId, subUnitId, ranges } = params;
2049
- this._refreshDrawingTransform(unitId, subUnitId, ranges);
2100
+ this._commandService.onCommandExecuted((i) => {
2101
+ Fi.includes(i.id) && requestIdleCallback(() => {
2102
+ const e = i.params, { unitId: n, subUnitId: t, ranges: r } = e;
2103
+ this._refreshDrawingTransform(n, t, r);
2050
2104
  });
2051
2105
  })
2052
2106
  );
2053
2107
  }
2054
- _refreshDrawingTransform(unitId, subUnitId, ranges) {
2055
- const drawingData = this._drawingManagerService.getDrawingData(unitId, subUnitId), updateDrawings = [];
2056
- Object.keys(drawingData).forEach((drawingId) => {
2057
- const drawing = drawingData[drawingId], { sheetTransform, transform, anchorType = SheetDrawingAnchorType.Position } = drawing;
2058
- if (anchorType === SheetDrawingAnchorType.None)
2108
+ _refreshDrawingTransform(i, e, n) {
2109
+ const t = this._drawingManagerService.getDrawingData(i, e), r = [];
2110
+ Object.keys(t).forEach((s) => {
2111
+ const o = t[s], { sheetTransform: d, transform: l, anchorType: g = y.Position } = o;
2112
+ if (g === y.None)
2059
2113
  return !0;
2060
- const { from, to } = sheetTransform, { row: fromRow, column: fromColumn } = from, { row: toRow, column: toColumn } = to;
2061
- for (let i = 0; i < ranges.length; i++) {
2062
- const range = ranges[i], { startRow, endRow, startColumn, endColumn } = range;
2063
- if (Rectangle.intersects(
2114
+ const { from: c, to: a } = d, { row: h, column: u } = c, { row: m, column: f } = a;
2115
+ for (let p = 0; p < n.length; p++) {
2116
+ const I = n[p], { startRow: S, endRow: v, startColumn: R, endColumn: _ } = I;
2117
+ if (Rn.intersects(
2064
2118
  {
2065
- startRow,
2066
- endRow,
2067
- startColumn,
2068
- endColumn
2119
+ startRow: S,
2120
+ endRow: v,
2121
+ startColumn: R,
2122
+ endColumn: _
2069
2123
  },
2070
2124
  {
2071
- startRow: fromRow,
2072
- endRow: toRow,
2073
- startColumn: fromColumn,
2074
- endColumn: toColumn
2125
+ startRow: h,
2126
+ endRow: m,
2127
+ startColumn: u,
2128
+ endColumn: f
2075
2129
  }
2076
- ) || fromRow > endRow || fromColumn > endColumn) {
2077
- const isPositionAnchor = anchorType === SheetDrawingAnchorType.Position, newTransform = drawingPositionToTransform(sheetTransform, this._selectionRenderService, this._skeletonManagerService);
2078
- updateDrawings.push({
2079
- ...drawing,
2130
+ ) || h > v || u > _) {
2131
+ const C = g === y.Position, w = B(d, this._selectionRenderService, this._skeletonManagerService);
2132
+ r.push({
2133
+ ...o,
2080
2134
  transform: {
2081
- ...newTransform,
2082
- width: isPositionAnchor ? transform == null ? void 0 : transform.width : newTransform == null ? void 0 : newTransform.width,
2083
- height: isPositionAnchor ? transform == null ? void 0 : transform.height : newTransform == null ? void 0 : newTransform.height
2135
+ ...w,
2136
+ width: C ? l == null ? void 0 : l.width : w == null ? void 0 : w.width,
2137
+ height: C ? l == null ? void 0 : l.height : w == null ? void 0 : w.height
2084
2138
  }
2085
2139
  });
2086
2140
  break;
2087
2141
  }
2088
2142
  }
2089
- }), updateDrawings.length !== 0 && (this._drawingManagerService.refreshTransform(updateDrawings), this._commandService.syncExecuteCommand(ClearSheetDrawingTransformerOperation.id, [unitId]));
2090
- }
2091
- }, __name(_a8, "SheetDrawingTransformAffectedController"), _a8);
2092
- SheetDrawingTransformAffectedController = __decorateClass$1([
2093
- __decorateParam$1(1, IRenderManagerService),
2094
- __decorateParam$1(2, ICommandService),
2095
- __decorateParam$1(3, ISheetSelectionRenderService),
2096
- __decorateParam$1(4, Inject(SheetSkeletonManagerService)),
2097
- __decorateParam$1(5, Inject(SheetInterceptorService)),
2098
- __decorateParam$1(6, ISheetDrawingService),
2099
- __decorateParam$1(7, IDrawingManagerService),
2100
- __decorateParam$1(8, IUniverInstanceService)
2101
- ], SheetDrawingTransformAffectedController);
2102
- var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
2103
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
2104
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
2105
- return kind && result && __defProp2(target, key, result), result;
2106
- }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
2107
- const PLUGIN_NAME = "SHEET_IMAGE_UI_PLUGIN";
2108
- var _a9;
2109
- let UniverSheetsDrawingUIPlugin = (_a9 = class extends Plugin {
2110
- constructor(_config = defaultPluginConfig, _injector, _renderManagerService, _configService) {
2111
- super(), this._config = _config, this._injector = _injector, this._renderManagerService = _renderManagerService, this._configService = _configService;
2112
- const { menu, ...rest } = this._config;
2113
- menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
2143
+ }), r.length !== 0 && (this._drawingManagerService.refreshTransform(r), this._commandService.syncExecuteCommand(j.id, [i]));
2144
+ }
2145
+ };
2146
+ ot = ki([
2147
+ Q(1, J),
2148
+ Q(2, W),
2149
+ Q(3, pe),
2150
+ Q(4, x(q)),
2151
+ Q(5, x(at)),
2152
+ Q(6, F),
2153
+ Q(7, K),
2154
+ Q(8, fe)
2155
+ ], ot);
2156
+ var Xi = Object.defineProperty, Hi = Object.getOwnPropertyDescriptor, zi = (i, e, n, t) => {
2157
+ for (var r = t > 1 ? void 0 : t ? Hi(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2158
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2159
+ return t && r && Xi(e, n, r), r;
2160
+ }, se = (i, e) => (n, t) => e(n, t, i);
2161
+ function Ki(i, e, n, t) {
2162
+ const { scaleX: r, scaleY: s } = e.getAncestorScale(), o = e.getViewport(zn.VIEW_MAIN), d = {
2163
+ left: !0,
2164
+ top: !0
2165
+ };
2166
+ if (!o)
2167
+ return {
2168
+ ...i,
2169
+ absolute: d
2170
+ };
2171
+ const { left: l, right: g, top: c, bottom: a } = i, h = t.getFreeze(), { startColumn: u, startRow: m, xSplit: f, ySplit: p } = h, I = n.getNoMergeCellPositionByIndexWithNoHeader(m - p, u - f), S = n.getNoMergeCellPositionByIndexWithNoHeader(m, u), { rowHeaderWidth: v, columnHeaderHeight: R } = n, _ = S.startX - I.startX, C = S.startY - I.startY, { top: w, left: O, viewportScrollX: b, viewportScrollY: A } = o;
2172
+ let E, M;
2173
+ l < O ? (d.left = !0, E = (_ + v + (l - O)) * r, M = Math.max(
2174
+ Math.min(
2175
+ (_ + v + (g - O)) * r,
2176
+ (_ + v) * r
2177
+ ),
2178
+ (g - b) * r
2179
+ )) : (d.left = !1, E = Math.max((l - b) * r, (_ + v) * r), M = Math.max((g - b) * r, (_ + v) * r));
2180
+ let D, U;
2181
+ return c < w ? (d.top = !0, D = (C + R + (c - w)) * s, U = Math.max(
2182
+ Math.min(
2183
+ (C + R + (g - w)) * s,
2184
+ (C + R) * s
2185
+ ),
2186
+ (a - A) * s
2187
+ )) : (d.top = !1, D = Math.max((c - A) * s, (C + R) * s), U = Math.max((a - A) * s, (C + R) * s)), {
2188
+ left: E,
2189
+ right: M,
2190
+ top: D,
2191
+ bottom: U,
2192
+ absolute: d
2193
+ };
2194
+ }
2195
+ const Qe = (i, e, n, t) => {
2196
+ const { scene: r } = e, { left: s, top: o, width: d, height: l, angle: g } = i, c = {
2197
+ left: s,
2198
+ right: s + d,
2199
+ top: o,
2200
+ bottom: o + l
2201
+ }, a = Ki(c, r, n, t), { scaleX: h, scaleY: u } = r.getAncestorScale();
2202
+ return {
2203
+ startX: a.left,
2204
+ endX: a.right,
2205
+ startY: a.top,
2206
+ endY: a.bottom,
2207
+ rotate: g,
2208
+ width: d * h,
2209
+ height: l * u,
2210
+ absolute: a.absolute
2211
+ };
2212
+ };
2213
+ let $e = class extends re {
2214
+ constructor(e, n, t, r, s, o, d) {
2215
+ super();
2216
+ V(this, "_domLayerMap", /* @__PURE__ */ new Map());
2217
+ V(this, "_domLayerInfoMap", /* @__PURE__ */ new Map());
2218
+ V(this, "_transformChange$", new Ke());
2219
+ V(this, "transformChange$", this._transformChange$.asObservable());
2220
+ V(this, "_add$", new Ke());
2221
+ V(this, "add$", this._add$.asObservable());
2222
+ V(this, "_remove$", new Ke());
2223
+ V(this, "remove$", this._remove$.asObservable());
2224
+ V(this, "_hooks", []);
2225
+ this._renderManagerService = e, this._univerInstanceService = n, this._commandService = t, this._drawingManagerService = r, this._canvasFloatDomService = s, this._sheetDrawingService = o, this._lifecycleService = d, this._drawingAddListener(), this._featureUpdateListener(), this._deleteListener(), this._bindScrollEvent();
2226
+ }
2227
+ _bindScrollEvent() {
2228
+ this._lifecycleService.lifecycle$.pipe(ae((e) => e === Mn.Rendered), gr(1)).subscribe(() => {
2229
+ this._scrollUpdateListener();
2230
+ });
2231
+ }
2232
+ _ensureMap(e, n) {
2233
+ let t = this._domLayerMap.get(e);
2234
+ t || (t = /* @__PURE__ */ new Map(), this._domLayerMap.set(e, t));
2235
+ let r = t.get(n);
2236
+ return r || (r = /* @__PURE__ */ new Map(), t.set(n, r)), r;
2237
+ }
2238
+ getFloatDomInfo(e) {
2239
+ return this._domLayerInfoMap.get(e);
2240
+ }
2241
+ _getSceneAndTransformerByDrawingSearch(e) {
2242
+ if (e == null)
2243
+ return;
2244
+ const n = this._renderManagerService.getRenderById(e), t = n == null ? void 0 : n.scene;
2245
+ if (n == null || t == null)
2246
+ return null;
2247
+ const r = t.getTransformerByCreate(), s = n.engine.getCanvasElement();
2248
+ return { scene: t, transformer: r, renderObject: n, canvas: s };
2249
+ }
2250
+ _getFloatDomProps(e) {
2251
+ let n;
2252
+ return this._hooks.forEach((t) => {
2253
+ n = t.onGetFloatDomProps(e);
2254
+ }), n;
2255
+ }
2256
+ // eslint-disable-next-line max-lines-per-function
2257
+ _drawingAddListener() {
2258
+ this.disposeWithMe(
2259
+ // eslint-disable-next-line max-lines-per-function
2260
+ this._drawingManagerService.add$.subscribe((e) => {
2261
+ e.forEach((n) => {
2262
+ var ut, ht, gt;
2263
+ const { unitId: t, subUnitId: r, drawingId: s } = n, o = ce(this._univerInstanceService, { unitId: t, subUnitId: r }), d = this._drawingManagerService.getDrawingByParam(n), l = this._univerInstanceService.getUnit(t);
2264
+ if (!l)
2265
+ return;
2266
+ const g = l.getActiveSheet().getSheetId();
2267
+ if (!d || !o)
2268
+ return;
2269
+ const c = (ut = this._renderManagerService.getRenderById(t)) == null ? void 0 : ut.with(q).getWorksheetSkeleton(r);
2270
+ if (!c)
2271
+ return;
2272
+ const { transform: a, drawingType: h, data: u } = d;
2273
+ if (h !== k.DRAWING_DOM && h !== k.DRAWING_CHART)
2274
+ return;
2275
+ const m = this._getSceneAndTransformerByDrawingSearch(t);
2276
+ if (m == null)
2277
+ return;
2278
+ const { scene: f, canvas: p } = m;
2279
+ if (a == null)
2280
+ return !0;
2281
+ if (g !== r)
2282
+ return;
2283
+ const { left: I, top: S, width: v, height: R, angle: _, flipX: C, flipY: w, skewX: O, skewY: b } = a, A = ze({ unitId: t, subUnitId: r, drawingId: s }), E = f.getObject(A);
2284
+ if (E != null) {
2285
+ E.transformByState({ left: I, top: S, width: v, height: R, angle: _, flipX: C, flipY: w, skewX: O, skewY: b });
2286
+ return;
2287
+ }
2288
+ const M = {
2289
+ left: I,
2290
+ top: S,
2291
+ width: v,
2292
+ height: R,
2293
+ zIndex: this._drawingManagerService.getDrawingOrder(t, r).length - 1
2294
+ }, D = h === k.DRAWING_CHART;
2295
+ D && (M.fill = "white", M.rotateEnabled = !1, u && u.border && (M.stroke = u.border), M.paintFirst = "stroke", M.strokeWidth = 1, M.borderEnabled = !1, M.radius = 8);
2296
+ const U = new wt(A, M);
2297
+ D && U.setObjectType(Xn.CHART), f.addObject(U, Hn), d.allowTransform !== !1 && f.attachTransformerTo(U);
2298
+ const L = this._ensureMap(t, r), Z = new bn(), un = Qe(U, m.renderObject, c.skeleton, o.worksheet), Fe = new mr(un), hn = {
2299
+ dispose: Z,
2300
+ rect: U,
2301
+ position$: Fe,
2302
+ unitId: t,
2303
+ subUnitId: r
2304
+ };
2305
+ this._canvasFloatDomService.addFloatDom({
2306
+ position$: Fe,
2307
+ id: s,
2308
+ componentKey: d.componentKey,
2309
+ onPointerDown: (G) => {
2310
+ p.dispatchEvent(new PointerEvent(G.type, G));
2311
+ },
2312
+ onPointerMove: (G) => {
2313
+ p.dispatchEvent(new PointerEvent(G.type, G));
2314
+ },
2315
+ onPointerUp: (G) => {
2316
+ p.dispatchEvent(new PointerEvent(G.type, G));
2317
+ },
2318
+ onWheel: (G) => {
2319
+ p.dispatchEvent(new WheelEvent(G.type, G));
2320
+ },
2321
+ props: (gt = (ht = L.get(s)) == null ? void 0 : ht.props) != null ? gt : this._getFloatDomProps(s),
2322
+ data: u,
2323
+ unitId: t
2324
+ });
2325
+ const lt = U.onTransformChange$.subscribeEvent(() => {
2326
+ const G = Qe(U, m.renderObject, c.skeleton, o.worksheet);
2327
+ Fe.next(
2328
+ G
2329
+ );
2330
+ });
2331
+ Z.add(() => {
2332
+ this._canvasFloatDomService.removeFloatDom(s);
2333
+ }), lt && Z.add(lt), this._domLayerInfoMap.set(s, hn), L.set(s, {
2334
+ ...L.get(s)
2335
+ });
2336
+ });
2337
+ })
2338
+ ), this.disposeWithMe(
2339
+ this._drawingManagerService.remove$.subscribe((e) => {
2340
+ e.forEach((n) => {
2341
+ const { unitId: t, subUnitId: r, drawingId: s } = n, o = ze({ unitId: t, subUnitId: r, drawingId: s }), d = this._getSceneAndTransformerByDrawingSearch(t);
2342
+ if (d == null)
2343
+ return;
2344
+ const { transformer: l, scene: g } = d, c = g.getObject(o);
2345
+ c != null && c.oKey && l.clearControlByIds([c == null ? void 0 : c.oKey]);
2346
+ });
2347
+ })
2348
+ );
2349
+ }
2350
+ _scrollUpdateListener() {
2351
+ const e = (n, t) => {
2352
+ var g;
2353
+ const r = this._getSceneAndTransformerByDrawingSearch(n), s = this._ensureMap(n, t), o = Array.from(s.keys()), d = ce(this._univerInstanceService, { unitId: n, subUnitId: t }), l = (g = this._renderManagerService.getRenderById(n)) == null ? void 0 : g.with(q).getWorksheetSkeleton(t);
2354
+ !r || !d || !l || o.forEach((c) => {
2355
+ const a = this._domLayerInfoMap.get(c);
2356
+ if (a) {
2357
+ const h = Qe(a.rect, r.renderObject, l.skeleton, d.worksheet);
2358
+ a.position$.next(h);
2359
+ }
2360
+ });
2361
+ };
2362
+ this.disposeWithMe(
2363
+ this._univerInstanceService.getCurrentTypeOfUnit$(Y.UNIVER_SHEET).pipe(
2364
+ ae((n) => !!n),
2365
+ Ee((n) => {
2366
+ const t = this._renderManagerService.getRenderById(n.getUnitId());
2367
+ return t ? { render: t, unitId: n.getUnitId(), subUnitId: n.getActiveSheet().getSheetId() } : null;
2368
+ }),
2369
+ ae((n) => !!n),
2370
+ fr(
2371
+ (n) => yn(n.render.scene.getViewport(tr.VIEW_MAIN).onScrollAfter$).pipe(Ee(() => ({ unitId: n.unitId, subUnitId: n.subUnitId })))
2372
+ )
2373
+ ).subscribe(({ unitId: n, subUnitId: t }) => {
2374
+ e(n, t);
2375
+ })
2376
+ ), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
2377
+ var t, r;
2378
+ if (n.id === nr.id) {
2379
+ const s = n.params, { unitId: o } = s;
2380
+ Array.from((r = (t = this._domLayerMap.get(o)) == null ? void 0 : t.keys()) != null ? r : []).forEach((l) => {
2381
+ e(o, l);
2382
+ });
2383
+ } else if (n.id === Mr.id) {
2384
+ const { unitId: s, subUnitId: o } = n.params;
2385
+ e(s, o);
2386
+ }
2387
+ }));
2388
+ }
2389
+ _getPosition(e, n) {
2390
+ var h;
2391
+ const { startX: t, endX: r, startY: s, endY: o } = e, d = (h = this._renderManagerService.getRenderById(n)) == null ? void 0 : h.with(pe);
2392
+ if (d == null)
2393
+ return;
2394
+ const l = d.getSelectionCellByPosition(t, s);
2395
+ if (l == null)
2396
+ return;
2397
+ const g = {
2398
+ column: l.actualColumn,
2399
+ columnOffset: t - l.startX,
2400
+ row: l.actualRow,
2401
+ rowOffset: s - l.startY
2402
+ }, c = d.getSelectionCellByPosition(r, o);
2403
+ if (c == null)
2404
+ return;
2405
+ const a = {
2406
+ column: c.actualColumn,
2407
+ columnOffset: r - c.startX,
2408
+ row: c.actualRow,
2409
+ rowOffset: o - c.startY
2410
+ };
2411
+ return {
2412
+ from: g,
2413
+ to: a
2414
+ };
2415
+ }
2416
+ _featureUpdateListener() {
2417
+ this.disposeWithMe(
2418
+ this._drawingManagerService.update$.subscribe((e) => {
2419
+ e.forEach((n) => {
2420
+ const t = this._drawingManagerService.getDrawingByParam(n);
2421
+ if (!t || t.drawingType !== k.DRAWING_DOM && t.drawingType !== k.DRAWING_CHART)
2422
+ return;
2423
+ const r = {
2424
+ ...t.transform
2425
+ };
2426
+ this._transformChange$.next({ id: n.drawingId, value: r });
2427
+ });
2428
+ })
2429
+ );
2430
+ }
2431
+ _deleteListener() {
2432
+ this.disposeWithMe(
2433
+ this._drawingManagerService.remove$.subscribe((e) => {
2434
+ e.forEach((n) => {
2435
+ this._removeDom(n.drawingId);
2436
+ });
2437
+ })
2438
+ );
2439
+ }
2440
+ updateFloatDomProps(e, n, t, r) {
2441
+ const s = this._domLayerInfoMap.get(t), o = this._getSceneAndTransformerByDrawingSearch(e);
2442
+ if (s && o) {
2443
+ const { scene: d } = o, l = ze({ unitId: e, subUnitId: n, drawingId: t }), g = d.getObject(l);
2444
+ g && g instanceof wt && g.setProps(r);
2445
+ }
2446
+ }
2447
+ addFloatDomToPosition(e, n) {
2448
+ const t = ce(this._univerInstanceService, {
2449
+ unitId: e.unitId,
2450
+ subUnitId: e.subUnitId
2451
+ });
2452
+ if (!t)
2453
+ throw new Error("cannot find current target!");
2454
+ const { unitId: r, subUnitId: s } = t, { initPosition: o, componentKey: d, data: l, allowTransform: g = !0 } = e, c = n != null ? n : On(), a = this._getPosition(o, r);
2455
+ if (a == null)
2456
+ return;
2457
+ this._ensureMap(r, s).set(c, e);
2458
+ const u = {
2459
+ unitId: r,
2460
+ subUnitId: s,
2461
+ drawingId: c,
2462
+ drawingType: e.type || k.DRAWING_DOM,
2463
+ componentKey: d,
2464
+ sheetTransform: a,
2465
+ transform: {
2466
+ left: o.startX,
2467
+ top: o.startY,
2468
+ width: o.endX - o.startX,
2469
+ height: o.endY - o.startY
2470
+ },
2471
+ data: l,
2472
+ allowTransform: g
2473
+ };
2474
+ return this._commandService.executeCommand(ke.id, {
2475
+ unitId: r,
2476
+ drawings: [u]
2477
+ }), this._add$.next({ unitId: r, subUnitId: s, id: c }), {
2478
+ id: c,
2479
+ dispose: () => {
2480
+ this._removeDom(c, !0);
2481
+ }
2482
+ };
2483
+ }
2484
+ _removeDom(e, n = !1) {
2485
+ const t = this._domLayerInfoMap.get(e);
2486
+ if (!t)
2487
+ return;
2488
+ const { unitId: r, subUnitId: s } = t;
2489
+ this._domLayerInfoMap.delete(e), t.dispose.dispose();
2490
+ const o = this._getSceneAndTransformerByDrawingSearch(r);
2491
+ if (o && o.scene.removeObject(t.rect), n) {
2492
+ this._ensureMap(r, s).delete(e);
2493
+ const l = this._drawingManagerService.getDrawingByParam({ unitId: r, subUnitId: s, drawingId: e });
2494
+ if (!l)
2495
+ return;
2496
+ const g = this._sheetDrawingService.getBatchRemoveOp([l]), { redo: c, objects: a } = g;
2497
+ this._commandService.syncExecuteCommand(P.id, { unitId: r, subUnitId: s, op: c, objects: a, type: T.REMOVE });
2498
+ }
2499
+ }
2500
+ addHook(e) {
2501
+ return this._hooks.push(e), {
2502
+ dispose: () => {
2503
+ const n = this._hooks.findIndex((t) => t === e);
2504
+ this._hooks.splice(n, 1);
2505
+ }
2506
+ };
2507
+ }
2508
+ };
2509
+ $e = zi([
2510
+ se(0, x(J)),
2511
+ se(1, fe),
2512
+ se(2, x(W)),
2513
+ se(3, K),
2514
+ se(4, x(hr)),
2515
+ se(5, F),
2516
+ se(6, x(Dn))
2517
+ ], $e);
2518
+ var dn = Object.defineProperty, Ji = Object.getOwnPropertyDescriptor, Zi = (i, e, n) => e in i ? dn(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, qi = (i, e, n, t) => {
2519
+ for (var r = t > 1 ? void 0 : t ? Ji(e, n) : e, s = i.length - 1, o; s >= 0; s--)
2520
+ (o = i[s]) && (r = (t ? o(e, n, r) : o(r)) || r);
2521
+ return t && r && dn(e, n, r), r;
2522
+ }, et = (i, e) => (n, t) => e(n, t, i), ln = (i, e, n) => Zi(i, typeof e != "symbol" ? e + "" : e, n);
2523
+ const Qi = "SHEET_IMAGE_UI_PLUGIN";
2524
+ let Be = class extends Tn {
2525
+ constructor(i = Pr, e, n, t) {
2526
+ super(), this._config = i, this._injector = e, this._renderManagerService = n, this._configService = t;
2527
+ const { menu: r, ...s } = this._config;
2528
+ r && this._configService.setConfig("menu", r, { merge: !0 }), this._configService.setConfig(Or, s);
2114
2529
  }
2115
2530
  onStarting() {
2116
- registerDependencies(this._injector, [
2117
- [SheetCanvasFloatDomManagerService],
2118
- [SheetDrawingUIController],
2119
- [DrawingPopupMenuController],
2120
- [SheetDrawingPrintingController],
2121
- [SheetDrawingPermissionController],
2122
- [SheetsDrawingCopyPasteController]
2123
- ]), touchDependencies(this._injector, [
2124
- [SheetCanvasFloatDomManagerService]
2531
+ En(this._injector, [
2532
+ [$e],
2533
+ [Ne],
2534
+ [Ue],
2535
+ [Le],
2536
+ [xe],
2537
+ [je]
2538
+ ]), Xe(this._injector, [
2539
+ [$e]
2125
2540
  ]);
2126
2541
  }
2127
2542
  onReady() {
2128
- touchDependencies(this._injector, [
2129
- [SheetsDrawingCopyPasteController]
2543
+ Xe(this._injector, [
2544
+ [je]
2130
2545
  ]);
2131
2546
  }
2132
2547
  onRendered() {
2133
- this._registerRenderModules(), touchDependencies(this._injector, [
2134
- [SheetDrawingPermissionController],
2135
- [SheetDrawingPrintingController],
2136
- [SheetDrawingUIController]
2548
+ this._registerRenderModules(), Xe(this._injector, [
2549
+ [xe],
2550
+ [Le],
2551
+ [Ne]
2137
2552
  ]);
2138
2553
  }
2139
2554
  onSteady() {
2140
- this._injector.get(DrawingPopupMenuController);
2555
+ this._injector.get(Ue);
2141
2556
  }
2142
2557
  _registerRenderModules() {
2143
2558
  [
2144
- [SheetDrawingUpdateController],
2145
- [SheetDrawingTransformAffectedController],
2146
- [SheetsDrawingRenderController]
2147
- ].forEach((m) => {
2148
- this.disposeWithMe(this._renderManagerService.registerRenderModule(UniverInstanceType.UNIVER_SHEET, m));
2559
+ [Ae],
2560
+ [ot],
2561
+ [st]
2562
+ ].forEach((i) => {
2563
+ this.disposeWithMe(this._renderManagerService.registerRenderModule(Y.UNIVER_SHEET, i));
2149
2564
  });
2150
2565
  }
2151
- }, __name(_a9, "UniverSheetsDrawingUIPlugin"), _a9);
2152
- __publicField2(UniverSheetsDrawingUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
2153
- __publicField2(UniverSheetsDrawingUIPlugin, "pluginName", PLUGIN_NAME);
2154
- UniverSheetsDrawingUIPlugin = __decorateClass([
2155
- DependentOn(UniverDrawingPlugin, UniverDrawingUIPlugin, UniverSheetsDrawingPlugin),
2156
- __decorateParam(1, Inject(Injector)),
2157
- __decorateParam(2, IRenderManagerService),
2158
- __decorateParam(3, IConfigService)
2159
- ], UniverSheetsDrawingUIPlugin);
2566
+ };
2567
+ ln(Be, "type", Y.UNIVER_SHEET);
2568
+ ln(Be, "pluginName", Qi);
2569
+ Be = qi([
2570
+ Pn(xn, kn, Kn),
2571
+ et(1, x(Ct)),
2572
+ et(2, J),
2573
+ et(3, Un)
2574
+ ], Be);
2160
2575
  export {
2161
- ClearSheetDrawingTransformerOperation,
2162
- DeleteDrawingsCommand,
2163
- EditSheetDrawingOperation,
2164
- GroupSheetDrawingCommand,
2165
- IMAGE_MENU_ID,
2166
- InsertFloatImageCommand,
2167
- InsertSheetDrawingCommand,
2168
- MoveDrawingsCommand,
2169
- RemoveSheetDrawingCommand,
2170
- SetDrawingArrangeCommand,
2171
- SetSheetDrawingCommand,
2172
- SheetCanvasFloatDomManagerService,
2173
- SidebarSheetDrawingOperation,
2174
- UngroupSheetDrawingCommand,
2175
- UniverSheetsDrawingUIPlugin
2576
+ j as ClearSheetDrawingTransformerOperation,
2577
+ tn as DeleteDrawingsCommand,
2578
+ Kt as EditSheetDrawingOperation,
2579
+ nn as GroupSheetDrawingCommand,
2580
+ an as IMAGE_MENU_ID,
2581
+ dt as InsertFloatImageCommand,
2582
+ ke as InsertSheetDrawingCommand,
2583
+ we as MoveDrawingsCommand,
2584
+ Ge as RemoveSheetDrawingCommand,
2585
+ rn as SetDrawingArrangeCommand,
2586
+ Ye as SetSheetDrawingCommand,
2587
+ $e as SheetCanvasFloatDomManagerService,
2588
+ zt as SidebarSheetDrawingOperation,
2589
+ sn as UngroupSheetDrawingCommand,
2590
+ Be as UniverSheetsDrawingUIPlugin
2176
2591
  };