@univerjs/drawing-ui 0.2.5 → 0.2.7

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,750 +1,760 @@
1
- var Mt = Object.defineProperty;
2
- var Ot = (a, n, e) => n in a ? Mt(a, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[n] = e;
3
- var te = (a, n, e) => Ot(a, typeof n != "symbol" ? n + "" : n, e);
4
- import { getDrawingShapeKeyByDrawingSearch as G, DrawingTypeEnum as re, ImageSourceType as Nt, IDrawingManagerService as ae, IImageIoService as ot, ArrangeTypeEnum as Pe } from "@univerjs/drawing";
5
- import { Group as ve, DRAWING_OBJECT_LAYER_INDEX as Ye, Image as Fe, IRenderManagerService as he, getGroupState as Dt, transformObjectOutOfGroup as Tt, RENDER_CLASS_TYPE as Qe, Shape as Bt, Rect as jt, Canvas as Ut, precisionTo as ye, CURSOR_TYPE as Ue, Vector2 as ke, degToRad as et } from "@univerjs/engine-render";
6
- import { UniverInstanceType as Ne, useDependency as V, LocaleService as Y, debounce as Ee, CommandType as Se, ICommandService as ue, Tools as Ht, Disposable as Ae, checkIfMove as st, toDisposable as _e, OnLifecycle as xe, LifecycleStages as Ve, IUniverInstanceService as Xe, Inject as ge, Injector as ct, Plugin as Lt } from "@univerjs/core";
7
- import c, { forwardRef as X, useRef as lt, createElement as J, useState as L, useEffect as be } from "react";
8
- import { Button as le, InputNumber as pe, Checkbox as At, Select as mt, Dropdown as xt, MessageType as tt } from "@univerjs/design";
9
- import O from "clsx";
10
- import { ComponentManager as Vt, IMenuService as Gt, IMessageService as Wt, IDialogService as $t } from "@univerjs/ui";
11
- import { filter as kt, switchMap as zt } from "rxjs";
12
- function Ft(a, n, e, t) {
13
- const r = t.getDrawingByParam(a);
14
- if (r == null)
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 { getDrawingShapeKeyByDrawingSearch, DrawingTypeEnum, ImageSourceType, IDrawingManagerService, IImageIoService, ArrangeTypeEnum } from "@univerjs/drawing";
6
+ import { Group, DRAWING_OBJECT_LAYER_INDEX, Image, IRenderManagerService, getGroupState, transformObjectOutOfGroup, RENDER_CLASS_TYPE, Shape, Rect, Canvas, precisionTo, CURSOR_TYPE, Vector2, degToRad } from "@univerjs/engine-render";
7
+ import { UniverInstanceType, useDependency, LocaleService, debounce, CommandType, ICommandService, Tools, Disposable, checkIfMove, toDisposable, OnLifecycle, LifecycleStages, IUniverInstanceService, Inject, Injector, Plugin } from "@univerjs/core";
8
+ import React, { forwardRef, useRef, createElement, useState, useEffect } from "react";
9
+ import { Button, InputNumber, Checkbox, Select, Dropdown, MessageType } from "@univerjs/design";
10
+ import clsx from "clsx";
11
+ import { ComponentManager, IMenuService, IMessageService, IDialogService } from "@univerjs/ui";
12
+ import { filter, switchMap } from "rxjs";
13
+ function insertGroupObject(objectParam, object, scene, drawingManagerService) {
14
+ const groupParam = drawingManagerService.getDrawingByParam(objectParam);
15
+ if (groupParam == null)
15
16
  return;
16
- const o = G(a), i = e.getObject(o);
17
- if (i && !(i instanceof ve))
17
+ const groupKey = getDrawingShapeKeyByDrawingSearch(objectParam), groupObject = scene.getObject(groupKey);
18
+ if (groupObject && !(groupObject instanceof Group))
18
19
  return;
19
- if (i != null) {
20
- i.addObject(n);
20
+ if (groupObject != null) {
21
+ groupObject.addObject(object);
21
22
  return;
22
23
  }
23
- const s = new ve(o);
24
- e.addObject(s, Ye).attachTransformerTo(s), s.addObject(n);
25
- const { transform: l } = r;
26
- l && s.transformByState(
24
+ const group = new Group(groupKey);
25
+ scene.addObject(group, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group), group.addObject(object);
26
+ const { transform } = groupParam;
27
+ transform && group.transformByState(
27
28
  {
28
- left: l.left,
29
- top: l.top,
30
- angle: l.angle
29
+ left: transform.left,
30
+ top: transform.top,
31
+ angle: transform.angle
31
32
  }
32
33
  );
33
34
  }
34
- function Ke(a) {
35
- var r;
36
- const n = a.getFocusedUnit();
37
- if (n == null)
35
+ __name(insertGroupObject, "insertGroupObject");
36
+ function getCurrentUnitInfo(currentUniverService) {
37
+ var _a7;
38
+ const current = currentUniverService.getFocusedUnit();
39
+ if (current == null)
38
40
  return;
39
- const e = n.getUnitId();
40
- let t;
41
- return n.type === Ne.UNIVER_SHEET ? t = (r = n.getActiveSheet()) == null ? void 0 : r.getSheetId() : (n.type === Ne.UNIVER_DOC || n.type === Ne.UNIVER_SLIDE) && (t = e), { unitId: e, subUnitId: t };
41
+ const unitId = current.getUnitId();
42
+ let subUnitId;
43
+ return current.type === UniverInstanceType.UNIVER_SHEET ? subUnitId = (_a7 = current.getActiveSheet()) == null ? void 0 : _a7.getSheetId() : (current.type === UniverInstanceType.UNIVER_DOC || current.type === UniverInstanceType.UNIVER_SLIDE) && (subUnitId = unitId), { unitId, subUnitId, current };
42
44
  }
43
- var Kt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Yt = (a, n, e, t) => {
44
- for (var r = t > 1 ? void 0 : t ? Zt(n, e) : n, o = a.length - 1, i; o >= 0; o--)
45
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
46
- return t && r && Kt(n, e, r), r;
47
- }, nt = (a, n) => (e, t) => n(e, t, a);
48
- let He = class {
49
- constructor(a, n) {
50
- this._drawingManagerService = a, this._imageIoService = n;
45
+ __name(getCurrentUnitInfo, "getCurrentUnitInfo");
46
+ var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
47
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
48
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
49
+ return kind && result && __defProp$5(target, key, result), result;
50
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a;
51
+ let DrawingRenderService = (_a = class {
52
+ constructor(_drawingManagerService, _imageIoService) {
53
+ this._drawingManagerService = _drawingManagerService, this._imageIoService = _imageIoService;
51
54
  }
52
55
  // eslint-disable-next-line max-lines-per-function
53
- async renderImages(a, n) {
56
+ async renderImages(imageParam, scene) {
54
57
  const {
55
- transform: e,
56
- drawingType: t,
57
- source: r,
58
- imageSourceType: o,
59
- srcRect: i,
60
- prstGeom: s,
61
- groupId: l,
62
- unitId: m,
63
- subUnitId: u,
64
- drawingId: d,
65
- isMultiTransform: h,
66
- transforms: f
67
- } = a;
68
- if (t !== re.DRAWING_IMAGE || !this._drawingManagerService.getDrawingVisible() || e == null)
58
+ transform: singleTransform,
59
+ drawingType,
60
+ source,
61
+ imageSourceType,
62
+ srcRect,
63
+ prstGeom,
64
+ groupId,
65
+ unitId,
66
+ subUnitId,
67
+ drawingId,
68
+ isMultiTransform,
69
+ transforms: multiTransforms
70
+ } = imageParam;
71
+ if (drawingType !== DrawingTypeEnum.DRAWING_IMAGE || !this._drawingManagerService.getDrawingVisible() || singleTransform == null)
69
72
  return;
70
- const v = h && f ? f : [e], w = [];
71
- for (const p of v) {
72
- const { left: S, top: _, width: R, height: b, angle: N, flipX: I, flipY: y, skewX: P, skewY: M } = p, D = v.indexOf(p), U = G({ unitId: m, subUnitId: u, drawingId: d }, h ? D : void 0), T = n.getObject(U);
73
- if (T != null) {
74
- T.transformByState({ left: S, top: _, width: R, height: b, angle: N, flipX: I, flipY: y, skewX: P, skewY: M });
73
+ const transforms = isMultiTransform && multiTransforms ? multiTransforms : [singleTransform], images = [];
74
+ for (const transform of transforms) {
75
+ const { left, top, width, height, angle, flipX, flipY, skewX, skewY } = transform, index = transforms.indexOf(transform), imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }, isMultiTransform ? index : void 0), imageShape = scene.getObject(imageShapeKey);
76
+ if (imageShape != null) {
77
+ imageShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
75
78
  continue;
76
79
  }
77
- const ie = this._drawingManagerService.getDrawingOrder(m, u), W = ie.indexOf(d), Q = { ...p, zIndex: W === -1 ? ie.length - 1 : W }, Ie = this._imageIoService.getImageSourceCache(r, o);
78
- let oe = !1;
79
- if (Ie != null)
80
- Q.image = Ie;
80
+ const orders = this._drawingManagerService.getDrawingOrder(unitId, subUnitId), zIndex = orders.indexOf(drawingId), imageConfig = { ...transform, zIndex: zIndex === -1 ? orders.length - 1 : zIndex }, imageNativeCache = this._imageIoService.getImageSourceCache(source, imageSourceType);
81
+ let shouldBeCache = !1;
82
+ if (imageNativeCache != null)
83
+ imageConfig.image = imageNativeCache;
81
84
  else {
82
- if (o === Nt.UUID)
85
+ if (imageSourceType === ImageSourceType.UUID)
83
86
  try {
84
- Q.url = await this._imageIoService.getImage(r);
85
- } catch ($e) {
86
- console.error($e);
87
+ imageConfig.url = await this._imageIoService.getImage(source);
88
+ } catch (error) {
89
+ console.error(error);
87
90
  continue;
88
91
  }
89
92
  else
90
- Q.url = r;
91
- oe = !0;
93
+ imageConfig.url = source;
94
+ shouldBeCache = !0;
92
95
  }
93
- Q.printable = !0;
94
- const F = new Fe(U, Q);
95
- if (oe && this._imageIoService.addImageSourceCache(r, o, F.getNative()), !this._drawingManagerService.getDrawingVisible())
96
+ imageConfig.printable = !0;
97
+ const image = new Image(imageShapeKey, imageConfig);
98
+ if (shouldBeCache && this._imageIoService.addImageSourceCache(source, imageSourceType, image.getNative()), !this._drawingManagerService.getDrawingVisible())
96
99
  continue;
97
- const We = n.addObject(F, Ye);
98
- this._drawingManagerService.getDrawingEditable() && We.attachTransformerTo(F), l && Ft({ drawingId: l, unitId: m, subUnitId: u }, F, n, this._drawingManagerService), s != null && F.setPrstGeom(s), i != null && F.setSrcRect(i), w.push(F);
100
+ const imageObject = scene.addObject(image, DRAWING_OBJECT_LAYER_INDEX);
101
+ this._drawingManagerService.getDrawingEditable() && imageObject.attachTransformerTo(image), groupId && insertGroupObject({ drawingId: groupId, unitId, subUnitId }, image, scene, this._drawingManagerService), prstGeom != null && image.setPrstGeom(prstGeom), srcRect != null && image.setSrcRect(srcRect), images.push(image);
99
102
  }
100
- return w;
101
- }
102
- renderDrawing(a, n) {
103
- const e = this._drawingManagerService.getDrawingByParam(a);
104
- if (e != null)
105
- switch (e.drawingType) {
106
- case re.DRAWING_IMAGE:
107
- return this.renderImages(e, n);
103
+ return images;
104
+ }
105
+ renderDrawing(param, scene) {
106
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
107
+ if (drawingParam != null)
108
+ switch (drawingParam.drawingType) {
109
+ case DrawingTypeEnum.DRAWING_IMAGE:
110
+ return this.renderImages(drawingParam, scene);
108
111
  }
109
112
  }
110
- };
111
- He = Yt([
112
- nt(0, ae),
113
- nt(1, ot)
114
- ], He);
115
- function Ge(a, n) {
116
- const e = [];
117
- return a.forEach((t) => {
118
- const { oKey: r, left: o, top: i, height: s, width: l, angle: m } = t, u = n.getDrawingOKey(r);
119
- if (u == null)
120
- return e.push(null), !0;
121
- const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = u, w = {
122
- unitId: d,
123
- subUnitId: h,
124
- drawingId: f,
125
- drawingType: v,
113
+ }, __name(_a, "DrawingRenderService"), _a);
114
+ DrawingRenderService = __decorateClass$5([
115
+ __decorateParam$5(0, IDrawingManagerService),
116
+ __decorateParam$5(1, IImageIoService)
117
+ ], DrawingRenderService);
118
+ function getUpdateParams(objects, drawingManagerService) {
119
+ const params = [];
120
+ return objects.forEach((object) => {
121
+ const { oKey, left, top, height, width, angle } = object, searchParam = drawingManagerService.getDrawingOKey(oKey);
122
+ if (searchParam == null)
123
+ return params.push(null), !0;
124
+ const { unitId, subUnitId, drawingId, drawingType } = searchParam, param = {
125
+ unitId,
126
+ subUnitId,
127
+ drawingId,
128
+ drawingType,
126
129
  transform: {
127
- left: o,
128
- top: i,
129
- height: s,
130
- width: l,
131
- angle: m
130
+ left,
131
+ top,
132
+ height,
133
+ width,
134
+ angle
132
135
  }
133
136
  };
134
- v === re.DRAWING_IMAGE && (w.srcRect = t.srcRect), e.push(w);
135
- }), e;
137
+ drawingType === DrawingTypeEnum.DRAWING_IMAGE && (param.srcRect = object.srcRect), params.push(param);
138
+ }), params;
136
139
  }
137
- var $ = function() {
138
- return $ = Object.assign || function(a) {
139
- for (var n, e = 1, t = arguments.length; e < t; e++) {
140
- n = arguments[e];
141
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (a[r] = n[r]);
140
+ __name(getUpdateParams, "getUpdateParams");
141
+ var __assign = function() {
142
+ return __assign = Object.assign || function(t) {
143
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
144
+ s = arguments[i];
145
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
142
146
  }
143
- return a;
144
- }, $.apply(this, arguments);
145
- }, Xt = function(a, n) {
146
- var e = {};
147
- for (var t in a) Object.prototype.hasOwnProperty.call(a, t) && n.indexOf(t) < 0 && (e[t] = a[t]);
148
- if (a != null && typeof Object.getOwnPropertySymbols == "function")
149
- for (var r = 0, t = Object.getOwnPropertySymbols(a); r < t.length; r++)
150
- n.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(a, t[r]) && (e[t[r]] = a[t[r]]);
151
- return e;
152
- }, q = X(function(a, n) {
153
- var e = a.icon, t = a.id, r = a.className, o = a.extend, i = Xt(a, ["icon", "id", "className", "extend"]), s = "univerjs-icon univerjs-icon-".concat(t, " ").concat(r || "").trim(), l = lt("_".concat(Qt()));
154
- return gt(e, "".concat(t), { defIds: e.defIds, idSuffix: l.current }, $({ ref: n, className: s }, i), o);
147
+ return t;
148
+ }, __assign.apply(this, arguments);
149
+ }, __rest = function(s, e) {
150
+ var t = {};
151
+ for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
152
+ if (s != null && typeof Object.getOwnPropertySymbols == "function")
153
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
154
+ e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
155
+ return t;
156
+ }, IconBase = forwardRef(function(props, ref) {
157
+ 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()));
158
+ return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
155
159
  });
156
- function gt(a, n, e, t, r) {
157
- return J(a.tag, $($({ key: n }, Jt(a, e, r)), t), (qt(a, e).children || []).map(function(o, i) {
158
- return gt(o, "".concat(n, "-").concat(a.tag, "-").concat(i), e, void 0, r);
160
+ function render(node, id, runtimeProps, rootProps, extend) {
161
+ return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
162
+ return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
159
163
  }));
160
164
  }
161
- function Jt(a, n, e) {
162
- var t = $({}, a.attrs);
163
- e != null && e.colorChannel1 && t.fill === "colorChannel1" && (t.fill = e.colorChannel1);
164
- var r = n.defIds;
165
- return !r || r.length === 0 || (a.tag === "use" && t["xlink:href"] && (t["xlink:href"] = t["xlink:href"] + n.idSuffix), Object.entries(t).forEach(function(o) {
166
- var i = o[0], s = o[1];
167
- typeof s == "string" && (t[i] = s.replace(/url\(#(.*)\)/, "url(#$1".concat(n.idSuffix, ")")));
168
- })), t;
165
+ __name(render, "render");
166
+ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
167
+ var attrs = __assign({}, node.attrs);
168
+ extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
169
+ var defIds = runtimeProps.defIds;
170
+ return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a7) {
171
+ var key = _a7[0], value = _a7[1];
172
+ typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
173
+ })), attrs;
169
174
  }
170
- function qt(a, n) {
171
- var e, t = n.defIds;
172
- return !t || t.length === 0 ? a : a.tag === "defs" && (!((e = a.children) === null || e === void 0) && e.length) ? $($({}, a), { children: a.children.map(function(r) {
173
- return typeof r.attrs.id == "string" && t && t.indexOf(r.attrs.id) > -1 ? $($({}, r), { attrs: $($({}, r.attrs), { id: r.attrs.id + n.idSuffix }) }) : r;
174
- }) }) : a;
175
+ __name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
176
+ function replaceRuntimeIdsInDefs(node, runtimeProps) {
177
+ var _a7, defIds = runtimeProps.defIds;
178
+ return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a7 = node.children) === null || _a7 === void 0) && _a7.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
179
+ 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;
180
+ }) }) : node;
175
181
  }
176
- function Qt() {
182
+ __name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
183
+ function generateShortUuid() {
177
184
  return Math.random().toString(36).substring(2, 8);
178
185
  }
179
- q.displayName = "UniverIcon";
180
- var en = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "colorChannel1", d: "M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ut = X(function(a, n) {
181
- return J(q, Object.assign({}, a, {
186
+ __name(generateShortUuid, "generateShortUuid");
187
+ IconBase.displayName = "UniverIcon";
188
+ var element$8 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "colorChannel1", d: "M11.0363 12.2367V14.0367C11.0363 14.3681 11.3049 14.6367 11.6363 14.6367C11.9676 14.6367 12.2363 14.3681 12.2363 14.0367V12.2367H14.0364C14.3677 12.2367 14.6364 11.9681 14.6364 11.6367C14.6364 11.3054 14.3677 11.0367 14.0364 11.0367H12.2363V9.23672C12.2363 8.90535 11.9676 8.63672 11.6363 8.63672C11.3049 8.63672 11.0363 8.90535 11.0363 9.23672V11.0367H9.23635C8.90498 11.0367 8.63635 11.3054 8.63635 11.6367C8.63635 11.9681 8.90498 12.2367 9.23635 12.2367H11.0363Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.56365 1.36377C1.90091 1.36377 1.36365 1.90103 1.36365 2.56377V6.16377C1.36365 6.82651 1.90091 7.36377 2.56365 7.36377H6.16365C6.82639 7.36377 7.36365 6.82651 7.36365 6.16377V2.56377C7.36365 1.90103 6.82639 1.36377 6.16365 1.36377H2.56365zM6.16365 2.56377H2.56365L2.56365 6.16377H6.16365V2.56377zM2.56365 8.63647C1.90091 8.63647 1.36365 9.17373 1.36365 9.83647V13.4365C1.36365 14.0992 1.90091 14.6365 2.56365 14.6365H6.16365C6.82639 14.6365 7.36365 14.0992 7.36365 13.4365V9.83647C7.36365 9.17373 6.82639 8.63647 6.16365 8.63647H2.56365zM6.16365 9.83647H2.56365L2.56365 13.4365H6.16365V9.83647zM9.83635 7.36377C9.17361 7.36377 8.63635 6.82651 8.63635 6.16377V2.56377C8.63635 1.90103 9.17361 1.36377 9.83635 1.36377H13.4364C14.0991 1.36377 14.6364 1.90103 14.6364 2.56377V6.16377C14.6364 6.82651 14.0991 7.36377 13.4364 7.36377H9.83635zM9.83635 6.16377V2.56377L13.4364 2.56377V6.16377H9.83635z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Autofill = forwardRef(function(props, ref) {
189
+ return createElement(IconBase, Object.assign({}, props, {
182
190
  id: "autofill",
183
- ref: n,
184
- icon: en
191
+ ref,
192
+ icon: element$8
185
193
  }));
186
194
  });
187
- ut.displayName = "Autofill";
188
- var tn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946" } }] }, dt = X(function(a, n) {
189
- return J(q, Object.assign({}, a, {
195
+ Autofill.displayName = "Autofill";
196
+ var element$7 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M14.0045 4.4334C14.8881 4.4334 15.6045 3.71705 15.6045 2.8334 15.6045 1.94974 14.8881 1.2334 14.0045 1.2334H3.70449C2.82084 1.2334 2.10449 1.94974 2.10449 2.8334 2.10449 3.71705 2.82084 4.4334 3.70449 4.4334H14.0045zM14.4045 2.8334C14.4045 3.05431 14.2254 3.2334 14.0045 3.2334H3.70449C3.48358 3.2334 3.30449 3.05431 3.30449 2.8334 3.30449 2.61248 3.48358 2.4334 3.70449 2.4334H14.0045C14.2254 2.4334 14.4045 2.61249 14.4045 2.8334zM14.1544 8.5999C15.038 8.5999 15.7544 7.88356 15.7544 6.9999 15.7544 6.11625 15.038 5.3999 14.1544 5.3999H3.85439C2.97074 5.3999 2.25439 6.11625 2.25439 6.9999 2.25439 7.88356 2.97074 8.5999 3.85439 8.5999H14.1544zM14.5544 6.9999C14.5544 7.22082 14.3753 7.3999 14.1544 7.3999H3.85439C3.63348 7.3999 3.45439 7.22082 3.45439 6.9999 3.45439 6.77899 3.63348 6.5999 3.85439 6.5999H14.1544C14.3753 6.5999 14.5544 6.77899 14.5544 6.9999z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M8.57975 14.5902L6.58023 12.5907C6.34591 12.3564 6.34591 11.9765 6.58023 11.7421 6.81454 11.5078 7.19444 11.5078 7.42876 11.7421L8.40449 12.7179V10.1664C8.40449 9.83504 8.67312 9.56641 9.00449 9.56641 9.33586 9.56641 9.60449 9.83504 9.60449 10.1664V12.7179L10.5802 11.7421C10.8145 11.5078 11.1944 11.5078 11.4288 11.7421 11.6631 11.9765 11.6631 12.3564 11.4288 12.5907L9.42923 14.5902M8.57975 14.5902C8.58121 14.5917 8.58268 14.5931 8.58416 14.5946 8.64077 14.6502 8.70566 14.6923 8.77482 14.7209 8.84557 14.7502 8.92314 14.7664 9.00449 14.7664 9.08585 14.7664 9.16342 14.7502 9.23416 14.7209 9.30332 14.6923 9.36821 14.6502 9.42482 14.5946" } }] }, BottomSingle = forwardRef(function(props, ref) {
197
+ return createElement(IconBase, Object.assign({}, props, {
190
198
  id: "bottom-single",
191
- ref: n,
192
- icon: tn
199
+ ref,
200
+ icon: element$7
193
201
  }));
194
202
  });
195
- dt.displayName = "BottomSingle";
196
- var nn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z" } }] }, ht = X(function(a, n) {
197
- return J(q, Object.assign({}, a, {
203
+ BottomSingle.displayName = "BottomSingle";
204
+ var element$6 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M5.97705 7.51296C5.97705 7.18159 6.24568 6.91296 6.57705 6.91296H8.48632C8.81769 6.91296 9.08632 7.18159 9.08632 7.51296 9.08632 7.84433 8.81769 8.11296 8.48632 8.11296H6.57705C6.24568 8.11296 5.97705 7.84433 5.97705 7.51296zM6.57705 9.41028C6.24568 9.41028 5.97705 9.67891 5.97705 10.0103 5.97705 10.3416 6.24568 10.6103 6.57705 10.6103H10.8199C11.1512 10.6103 11.4199 10.3416 11.4199 10.0103 11.4199 9.67891 11.1512 9.41028 10.8199 9.41028H6.57705z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.51074 2.37063C3.51074 1.48697 4.22709 0.77063 5.11074 0.77063H9.80318L9.81294 0.770708C9.97168 0.768161 10.1311 0.82824 10.2511 0.95055L14.4317 5.21408C14.5165 5.30049 14.5697 5.406 14.5917 5.51645C14.6041 5.5644 14.6106 5.61467 14.6106 5.66648V11.6406C14.6106 12.5243 13.8943 13.2406 13.0106 13.2406H5.11074C4.22709 13.2406 3.51074 12.5243 3.51074 11.6406V2.37063ZM10.4032 4.66648V2.81964L12.6063 5.06648H10.8032C10.5823 5.06648 10.4032 4.88739 10.4032 4.66648ZM5.11074 1.97063C4.88983 1.97063 4.71074 2.14972 4.71074 2.37063V11.6406C4.71074 11.8615 4.88983 12.0406 5.11074 12.0406H13.0106C13.2316 12.0406 13.4106 11.8615 13.4106 11.6406V6.26648H10.8032C9.91953 6.26648 9.20318 5.55013 9.20318 4.66648V1.97063H5.11074Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M2.58916 6.6741C2.58916 6.34273 2.32053 6.0741 1.98916 6.0741C1.65779 6.0741 1.38916 6.34273 1.38916 6.6741V12.6294C1.38916 14.0653 2.55322 15.2294 3.98916 15.2294H9.41408C9.74545 15.2294 10.0141 14.9607 10.0141 14.6294C10.0141 14.298 9.74545 14.0294 9.41408 14.0294H3.98916C3.21596 14.0294 2.58916 13.4026 2.58916 12.6294V6.6741Z" } }] }, CreateCopySingle = forwardRef(function(props, ref) {
205
+ return createElement(IconBase, Object.assign({}, props, {
198
206
  id: "create-copy-single",
199
- ref: n,
200
- icon: nn
207
+ ref,
208
+ icon: element$6
201
209
  }));
202
210
  });
203
- ht.displayName = "CreateCopySingle";
204
- var rn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, ft = X(function(a, n) {
205
- return J(q, Object.assign({}, a, {
211
+ CreateCopySingle.displayName = "CreateCopySingle";
212
+ var element$5 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.38125 1.16211C6.49759 1.16211 5.78125 1.87845 5.78125 2.76211V5.6377H2.87783C1.99418 5.6377 1.27783 6.35404 1.27783 7.2377V13.2377C1.27783 14.1214 1.99418 14.8377 2.87783 14.8377H8.87783C9.76149 14.8377 10.4778 14.1214 10.4778 13.2377V10.3621H13.3813C14.2649 10.3621 14.9813 9.64577 14.9813 8.76211V2.76211C14.9813 1.87845 14.2649 1.16211 13.3813 1.16211H7.38125ZM10.4778 9.16211H13.3813C13.6022 9.16211 13.7812 8.98302 13.7812 8.76211V2.76211C13.7812 2.5412 13.6022 2.36211 13.3813 2.36211H7.38125C7.16034 2.36211 6.98125 2.5412 6.98125 2.76211V5.6377H8.87783C9.76149 5.6377 10.4778 6.35404 10.4778 7.2377V9.16211ZM6.98125 6.8377H8.87783C9.09875 6.8377 9.27783 7.01678 9.27783 7.2377V9.16211H7.38125C7.16034 9.16211 6.98125 8.98302 6.98125 8.76211V6.8377ZM5.78125 6.8377V8.76211C5.78125 9.64577 6.49759 10.3621 7.38125 10.3621H9.27783V13.2377C9.27783 13.4586 9.09875 13.6377 8.87783 13.6377H2.87783C2.65692 13.6377 2.47783 13.4586 2.47783 13.2377V7.2377C2.47783 7.01678 2.65692 6.8377 2.87783 6.8377H5.78125Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, GroupSingle = forwardRef(function(props, ref) {
213
+ return createElement(IconBase, Object.assign({}, props, {
206
214
  id: "group-single",
207
- ref: n,
208
- icon: rn
215
+ ref,
216
+ icon: element$5
209
217
  }));
210
218
  });
211
- ft.displayName = "GroupSingle";
212
- var an = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, pt = X(function(a, n) {
213
- return J(q, Object.assign({}, a, {
219
+ GroupSingle.displayName = "GroupSingle";
220
+ var element$4 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, MoreDownSingle = forwardRef(function(props, ref) {
221
+ return createElement(IconBase, Object.assign({}, props, {
214
222
  id: "more-down-single",
215
- ref: n,
216
- icon: an
223
+ ref,
224
+ icon: element$4
217
225
  }));
218
226
  });
219
- pt.displayName = "MoreDownSingle";
220
- var on = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z" } }] }, Ct = X(function(a, n) {
221
- return J(q, Object.assign({}, a, {
227
+ MoreDownSingle.displayName = "MoreDownSingle";
228
+ var element$3 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 2.96401C1.25 3.84767 1.96634 4.56401 2.85 4.56401H13.15C14.0337 4.56401 14.75 3.84767 14.75 2.96401C14.75 2.08036 14.0337 1.36401 13.15 1.36401H2.85C1.96635 1.36401 1.25 2.08036 1.25 2.96401ZM2.85 3.36401C2.62909 3.36401 2.45 3.18493 2.45 2.96401C2.45 2.7431 2.62909 2.56401 2.85 2.56401H13.15C13.3709 2.56401 13.55 2.7431 13.55 2.96401C13.55 3.18493 13.3709 3.36401 13.15 3.36401H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 11.6118C5.80995 11.3774 6.18985 11.3774 6.42417 11.6118L7.3999 12.5875V6.36951C7.3999 6.03814 7.66853 5.76951 7.9999 5.76951C8.33127 5.76951 8.5999 6.03814 8.5999 6.36951V12.5875L9.57564 11.6118C9.80995 11.3774 10.1899 11.3774 10.4242 11.6118C10.6585 11.8461 10.6585 12.226 10.4242 12.4603L8.4324 14.452C8.32324 14.5655 8.16982 14.6362 7.9999 14.6362C7.82998 14.6362 7.67655 14.5655 7.56739 14.452L5.57564 12.4603C5.34132 12.226 5.34132 11.8461 5.57564 11.6118Z" } }] }, MoveDownSingle = forwardRef(function(props, ref) {
229
+ return createElement(IconBase, Object.assign({}, props, {
222
230
  id: "move-down-single",
223
- ref: n,
224
- icon: on
231
+ ref,
232
+ icon: element$3
225
233
  }));
226
234
  });
227
- Ct.displayName = "MoveDownSingle";
228
- var sn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z" } }] }, wt = X(function(a, n) {
229
- return J(q, Object.assign({}, a, {
235
+ MoveDownSingle.displayName = "MoveDownSingle";
236
+ var element$2 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 16 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M1.25 13.036C1.25 12.1523 1.96634 11.436 2.85 11.436H13.15C14.0337 11.436 14.75 12.1523 14.75 13.036C14.75 13.9196 14.0337 14.636 13.15 14.636H2.85C1.96635 14.636 1.25 13.9196 1.25 13.036ZM2.85 12.636C2.62909 12.636 2.45 12.8151 2.45 13.036C2.45 13.2569 2.62909 13.436 2.85 13.436H13.15C13.3709 13.436 13.55 13.2569 13.55 13.036C13.55 12.8151 13.3709 12.636 13.15 12.636H2.85Z", fillRule: "evenodd", clipRule: "evenodd" } }, { tag: "path", attrs: { fill: "currentColor", d: "M5.57564 4.38825C5.80995 4.62256 6.18985 4.62256 6.42417 4.38825L7.3999 3.41251V9.63049C7.3999 9.96186 7.66853 10.2305 7.9999 10.2305C8.33127 10.2305 8.5999 9.96186 8.5999 9.63049V3.41251L9.57564 4.38825C9.80995 4.62256 10.1899 4.62256 10.4242 4.38825C10.6585 4.15393 10.6585 3.77403 10.4242 3.53972L8.4324 1.54796C8.32324 1.43445 8.16982 1.36382 7.9999 1.36382C7.82998 1.36382 7.67655 1.43446 7.56739 1.54797L5.57564 3.53972C5.34132 3.77403 5.34132 4.15393 5.57564 4.38825Z" } }] }, MoveUpSingle = forwardRef(function(props, ref) {
237
+ return createElement(IconBase, Object.assign({}, props, {
230
238
  id: "move-up-single",
231
- ref: n,
232
- icon: sn
239
+ ref,
240
+ icon: element$2
233
241
  }));
234
242
  });
235
- wt.displayName = "MoveUpSingle";
236
- var cn = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z", fillRule: "evenodd", clipRule: "evenodd" } }] }, vt = X(function(a, n) {
237
- return J(q, Object.assign({}, a, {
243
+ MoveUpSingle.displayName = "MoveUpSingle";
244
+ var element$1 = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.82994 1.40913C7.88746 1.35161 7.95376 1.30821 8.02453 1.27893C8.09527 1.24959 8.17285 1.2334 8.2542 1.2334C8.33555 1.2334 8.41313 1.24959 8.48387 1.27893C8.55464 1.30821 8.62094 1.35161 8.67846 1.40913L10.6785 3.40913C10.9128 3.64345 10.9128 4.02335 10.6785 4.25766C10.4441 4.49198 10.0642 4.49198 9.82994 4.25766L8.8542 3.28193V5.8334C8.8542 6.16477 8.58557 6.4334 8.2542 6.4334C7.92283 6.4334 7.6542 6.16477 7.6542 5.8334V3.28193L6.67846 4.25766C6.44415 4.49198 6.06425 4.49198 5.82994 4.25766C5.59562 4.02335 5.59562 3.64345 5.82994 3.40913L7.82994 1.40913Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M1.50439 9C1.50439 8.11634 2.22074 7.4 3.10439 7.4H13.4044C14.288 7.4 15.0044 8.11634 15.0044 9 15.0044 9.88366 14.2881 10.6 13.4044 10.6H3.1044C2.22074 10.6 1.50439 9.88366 1.50439 9zM3.10439 8.6C2.88348 8.6 2.70439 8.77909 2.70439 9 2.70439 9.22091 2.88348 9.4 3.1044 9.4H13.4044C13.6253 9.4 13.8044 9.22091 13.8044 9 13.8044 8.77909 13.6253 8.6 13.4044 8.6H3.10439zM1.6543 13.1665C1.6543 12.2828 2.37064 11.5665 3.2543 11.5665H13.5543C14.438 11.5665 15.1543 12.2828 15.1543 13.1665 15.1543 14.0502 14.438 14.7665 13.5543 14.7665H3.2543C2.37064 14.7665 1.6543 14.0502 1.6543 13.1665zM3.2543 12.7665C3.03338 12.7665 2.8543 12.9456 2.8543 13.1665 2.8543 13.3874 3.03338 13.5665 3.2543 13.5665H13.5543C13.7752 13.5665 13.9543 13.3874 13.9543 13.1665 13.9543 12.9456 13.7752 12.7665 13.5543 12.7665H3.2543z", fillRule: "evenodd", clipRule: "evenodd" } }] }, TopmostSingle = forwardRef(function(props, ref) {
245
+ return createElement(IconBase, Object.assign({}, props, {
238
246
  id: "topmost-single",
239
- ref: n,
240
- icon: cn
247
+ ref,
248
+ icon: element$1
241
249
  }));
242
250
  });
243
- vt.displayName = "TopmostSingle";
244
- var ln = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, _t = X(function(a, n) {
245
- return J(q, Object.assign({}, a, {
251
+ TopmostSingle.displayName = "TopmostSingle";
252
+ var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M7.46855 2.83731C7.46855 2.61639 7.64764 2.4373 7.86855 2.4373H13.8603C14.0812 2.4373 14.2603 2.61639 14.2603 2.8373V9.5049C14.2603 9.72581 14.0812 9.90489 13.8603 9.90489H12.866C12.5346 9.90489 12.266 10.1735 12.266 10.5049C12.266 10.8363 12.5346 11.1049 12.866 11.1049H13.8603C14.7439 11.1049 15.4603 10.3886 15.4603 9.5049V2.8373C15.4603 1.95365 14.7439 1.2373 13.8603 1.2373H7.86855C6.9849 1.2373 6.26855 1.95365 6.26855 2.83731V3.48688C6.26855 3.81825 6.53718 4.08688 6.86855 4.08688C7.19993 4.08688 7.46855 3.81825 7.46855 3.48688V2.83731Z" } }, { tag: "path", attrs: { fill: "currentColor", d: "M3.19888 5.56299C2.31522 5.56299 1.59888 6.27933 1.59888 7.16299V13.163C1.59888 14.0466 2.31522 14.763 3.19888 14.763H9.19888C10.0825 14.763 10.7989 14.0466 10.7989 13.163V7.16299C10.7989 6.27933 10.0825 5.56299 9.19888 5.56299H3.19888ZM2.79888 7.16299C2.79888 6.94207 2.97796 6.76299 3.19888 6.76299H9.19888C9.41979 6.76299 9.59888 6.94207 9.59888 7.16299V13.163C9.59888 13.3839 9.41979 13.563 9.19888 13.563H3.19888C2.97796 13.563 2.79888 13.3839 2.79888 13.163V7.16299Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, UngroupSingle = forwardRef(function(props, ref) {
253
+ return createElement(IconBase, Object.assign({}, props, {
246
254
  id: "ungroup-single",
247
- ref: n,
248
- icon: ln
255
+ ref,
256
+ icon: element
249
257
  }));
250
258
  });
251
- _t.displayName = "UngroupSingle";
252
- const mn = "univer-image-common-panel", gn = "univer-image-common-panel-grid", un = "univer-image-common-panel-border", dn = "univer-image-common-panel-title", hn = "univer-image-common-panel-subtitle", fn = "univer-image-common-panel-row", pn = "univer-image-common-panel-row-vertical", Cn = "univer-image-common-panel-column", wn = "univer-image-common-panel-column-center", vn = "univer-image-common-panel-inline", _n = "univer-image-common-panel-span2", Sn = "univer-image-common-panel-span3", bn = "univer-image-common-panel-input", g = {
253
- imageCommonPanel: mn,
254
- imageCommonPanelGrid: gn,
255
- imageCommonPanelBorder: un,
256
- imageCommonPanelTitle: dn,
257
- imageCommonPanelSubtitle: hn,
258
- imageCommonPanelRow: fn,
259
- imageCommonPanelRowVertical: pn,
260
- imageCommonPanelColumn: Cn,
261
- imageCommonPanelColumnCenter: wn,
262
- imageCommonPanelInline: vn,
263
- imageCommonPanelSpan2: _n,
264
- imageCommonPanelSpan3: Sn,
265
- imageCommonPanelInput: bn
266
- }, In = (a) => {
267
- const { arrangeShow: n, drawings: e } = a, t = V(Y), r = V(ae), o = (m) => m ? "block" : "none", [i, s] = L(e);
268
- be(() => {
269
- const m = r.focus$.subscribe((u) => {
270
- s(u);
259
+ UngroupSingle.displayName = "UngroupSingle";
260
+ 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", styles$1 = {
261
+ imageCommonPanel,
262
+ imageCommonPanelGrid,
263
+ imageCommonPanelBorder,
264
+ imageCommonPanelTitle,
265
+ imageCommonPanelSubtitle,
266
+ imageCommonPanelRow,
267
+ imageCommonPanelRowVertical,
268
+ imageCommonPanelColumn,
269
+ imageCommonPanelColumnCenter,
270
+ imageCommonPanelInline,
271
+ imageCommonPanelSpan2,
272
+ imageCommonPanelSpan3,
273
+ imageCommonPanelInput
274
+ }, DrawingArrange = /* @__PURE__ */ __name((props) => {
275
+ const { arrangeShow, drawings: focusDrawings } = props, localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay"), [drawings, setDrawings] = useState(focusDrawings);
276
+ useEffect(() => {
277
+ const focusDispose = drawingManagerService.focus$.subscribe((drawings2) => {
278
+ setDrawings(drawings2);
271
279
  });
272
280
  return () => {
273
- m.unsubscribe();
281
+ focusDispose.unsubscribe();
274
282
  };
275
283
  }, []);
276
- const l = (m) => {
277
- const u = i[0].unitId, d = i[0].subUnitId, h = i.map((f) => f.drawingId);
278
- r.featurePluginOrderUpdateNotification({ unitId: u, subUnitId: d, drawingIds: h, arrangeType: m });
279
- };
280
- return /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelGrid, style: { display: o(n) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, t.t("image-panel.arrange.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
281
- l(Pe.forward);
282
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(wt, null), t.t("image-panel.arrange.forward")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
283
- l(Pe.backward);
284
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(Ct, null), t.t("image-panel.arrange.backward"))))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
285
- l(Pe.front);
286
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(vt, null), t.t("image-panel.arrange.front")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
287
- l(Pe.back);
288
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(dt, null), t.t("image-panel.arrange.back"))))));
289
- }, se = 20, Pn = 20, yn = [-3600, 3600], Re = 300, En = (a) => {
290
- var qe;
291
- const n = V(Y), e = V(ae), t = V(he), { drawings: r, transformShow: o } = a, i = r[0];
292
- if (i == null)
284
+ const onArrangeBtnClick = /* @__PURE__ */ __name((arrangeType) => {
285
+ const unitId = drawings[0].unitId, subUnitId = drawings[0].subUnitId, drawingIds = drawings.map((drawing) => drawing.drawingId);
286
+ drawingManagerService.featurePluginOrderUpdateNotification({ unitId, subUnitId, drawingIds, arrangeType });
287
+ }, "onArrangeBtnClick");
288
+ return /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelGrid, style: { display: gridDisplay(arrangeShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.arrange.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
289
+ onArrangeBtnClick(ArrangeTypeEnum.forward);
290
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(MoveUpSingle, null), localeService.t("image-panel.arrange.forward")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
291
+ onArrangeBtnClick(ArrangeTypeEnum.backward);
292
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(MoveDownSingle, null), localeService.t("image-panel.arrange.backward"))))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
293
+ onArrangeBtnClick(ArrangeTypeEnum.front);
294
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(TopmostSingle, null), localeService.t("image-panel.arrange.front")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
295
+ onArrangeBtnClick(ArrangeTypeEnum.back);
296
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(BottomSingle, null), localeService.t("image-panel.arrange.back"))))));
297
+ }, "DrawingArrange"), MIN_DRAWING_WIDTH_LIMIT = 20, MIN_DRAWING_HEIGHT_LIMIT = 20, RANGE_DRAWING_ROTATION_LIMIT = [-3600, 3600], INPUT_DEBOUNCE_TIME = 300, DrawingTransform = /* @__PURE__ */ __name((props) => {
298
+ var _a7;
299
+ const localeService = useDependency(LocaleService), drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), { drawings, transformShow } = props, drawingParam = drawings[0];
300
+ if (drawingParam == null)
293
301
  return;
294
- const s = i.transform;
295
- if (s == null)
302
+ const transform = drawingParam.transform;
303
+ if (transform == null)
296
304
  return;
297
- const { unitId: l, subUnitId: m, drawingId: u, drawingType: d } = i, h = t.getRenderById(l), f = h == null ? void 0 : h.scene;
298
- if (f == null)
305
+ const { unitId, subUnitId, drawingId, drawingType } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
306
+ if (scene == null)
299
307
  return;
300
- const v = (qe = f.getEngine()) == null ? void 0 : qe.activeScene;
301
- if (v == null)
308
+ const topScene = (_a7 = scene.getEngine()) == null ? void 0 : _a7.activeScene;
309
+ if (topScene == null)
302
310
  return;
303
- const w = f.getTransformerByCreate(), {
304
- width: p = 0,
305
- height: S = 0,
306
- left: _ = 0,
307
- top: R = 0,
308
- angle: b = 0
309
- } = s, [N, I] = L(p), [y, P] = L(S), [M, D] = L(_), [U, T] = L(R), [ie, W] = L(b), [Q, Ie] = L(w.keepRatio), oe = (C, A, x, H) => {
310
- const { width: j, height: ee } = v, { ancestorLeft: k, ancestorTop: z } = f;
311
- let K = C, Z = A, ne = x, fe = H;
312
- return C + k < 0 && (K = -k), A + z < 0 && (Z = -z), ne = j - K - k, ne < se && (ne = se), fe = ee - Z - z, fe < se && (fe = se), C + ne + k > j && (K = j - x - k), A + fe + z > ee && (Z = ee - H - z), {
313
- limitLeft: K,
314
- limitTop: Z,
315
- limitWidth: ne,
316
- limitHeight: fe
311
+ const transformer = scene.getTransformerByCreate(), {
312
+ width: originWidth = 0,
313
+ height: originHeight = 0,
314
+ left: originX = 0,
315
+ top: originY = 0,
316
+ angle: originRotation = 0
317
+ } = transform, [width, setWidth] = useState(originWidth), [height, setHeight] = useState(originHeight), [xPosition, setXPosition] = useState(originX), [yPosition, setYPosition] = useState(originY), [rotation, setRotation] = useState(originRotation), [lockRatio, setLockRatio] = useState(transformer.keepRatio), checkMoveBoundary = /* @__PURE__ */ __name((left, top, width2, height2) => {
318
+ const { width: topSceneWidth, height: topSceneHeight } = topScene, { ancestorLeft, ancestorTop } = scene;
319
+ let limitLeft = left, limitTop = top, limitWidth = width2, limitHeight = height2;
320
+ return left + ancestorLeft < 0 && (limitLeft = -ancestorLeft), top + ancestorTop < 0 && (limitTop = -ancestorTop), limitWidth = topSceneWidth - limitLeft - ancestorLeft, limitWidth < MIN_DRAWING_WIDTH_LIMIT && (limitWidth = MIN_DRAWING_WIDTH_LIMIT), limitHeight = topSceneHeight - limitTop - ancestorTop, limitHeight < MIN_DRAWING_WIDTH_LIMIT && (limitHeight = MIN_DRAWING_WIDTH_LIMIT), left + limitWidth + ancestorLeft > topSceneWidth && (limitLeft = topSceneWidth - width2 - ancestorLeft), top + limitHeight + ancestorTop > topSceneHeight && (limitTop = topSceneHeight - height2 - ancestorTop), {
321
+ limitLeft,
322
+ limitTop,
323
+ limitWidth,
324
+ limitHeight
317
325
  };
318
- }, F = (C) => {
319
- const { objects: A } = C, x = Ge(A, e);
320
- if (x.length !== 1)
326
+ }, "checkMoveBoundary"), changeObs = /* @__PURE__ */ __name((state) => {
327
+ const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
328
+ if (params.length !== 1)
321
329
  return;
322
- const H = x[0];
323
- if (H == null)
330
+ const drawingParam2 = params[0];
331
+ if (drawingParam2 == null)
324
332
  return;
325
- const { transform: j } = H;
326
- if (j == null)
333
+ const { transform: transform2 } = drawingParam2;
334
+ if (transform2 == null)
327
335
  return;
328
336
  const {
329
- width: ee,
330
- height: k,
331
- left: z,
332
- top: K,
333
- angle: Z
334
- } = j;
335
- ee != null && I(ee), k != null && P(k), z != null && D(z), K != null && T(K), Z != null && W(Z);
336
- };
337
- be(() => {
338
- const C = w.changeStart$.subscribe((H) => {
339
- F(H);
340
- }), A = w.changing$.subscribe((H) => {
341
- F(H);
342
- }), x = e.focus$.subscribe((H) => {
343
- if (H.length !== 1)
337
+ width: originWidth2,
338
+ height: originHeight2,
339
+ left: originX2,
340
+ top: originY2,
341
+ angle: originRotation2
342
+ } = transform2;
343
+ originWidth2 != null && setWidth(originWidth2), originHeight2 != null && setHeight(originHeight2), originX2 != null && setXPosition(originX2), originY2 != null && setYPosition(originY2), originRotation2 != null && setRotation(originRotation2);
344
+ }, "changeObs");
345
+ useEffect(() => {
346
+ const changeStartSub = transformer.changeStart$.subscribe((state) => {
347
+ changeObs(state);
348
+ }), changingSub = transformer.changing$.subscribe((state) => {
349
+ changeObs(state);
350
+ }), focusSub = drawingManagerService.focus$.subscribe((drawings2) => {
351
+ if (drawings2.length !== 1)
344
352
  return;
345
- const j = e.getDrawingByParam(H[0]);
346
- if (j == null)
353
+ const drawingParam2 = drawingManagerService.getDrawingByParam(drawings2[0]);
354
+ if (drawingParam2 == null)
347
355
  return;
348
- const ee = j.transform;
349
- if (ee == null)
356
+ const transform2 = drawingParam2.transform;
357
+ if (transform2 == null)
350
358
  return;
351
359
  const {
352
- width: k,
353
- height: z,
354
- left: K,
355
- top: Z,
356
- angle: ne
357
- } = ee;
358
- k != null && I(k), z != null && P(z), K != null && D(K), Z != null && T(Z), ne != null && W(ne);
360
+ width: originWidth2,
361
+ height: originHeight2,
362
+ left: originX2,
363
+ top: originY2,
364
+ angle: originRotation2
365
+ } = transform2;
366
+ originWidth2 != null && setWidth(originWidth2), originHeight2 != null && setHeight(originHeight2), originX2 != null && setXPosition(originX2), originY2 != null && setYPosition(originY2), originRotation2 != null && setRotation(originRotation2);
359
367
  });
360
368
  return () => {
361
- A.unsubscribe(), C.unsubscribe(), x.unsubscribe();
369
+ changingSub.unsubscribe(), changeStartSub.unsubscribe(), focusSub.unsubscribe();
362
370
  };
363
371
  }, []);
364
- const We = Ee((C) => {
365
- if (C == null)
372
+ const handleWidthChange = debounce((val) => {
373
+ if (val == null)
366
374
  return;
367
- C = Math.max(C, se);
368
- const { limitWidth: A, limitHeight: x } = oe(M, U, C, y);
369
- C = Math.min(C, A);
370
- const H = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { width: C } };
371
- if (Q) {
372
- let j = C / N * y;
373
- if (j = Math.max(j, Pn), j > x)
375
+ val = Math.max(val, MIN_DRAWING_WIDTH_LIMIT);
376
+ const { limitWidth, limitHeight } = checkMoveBoundary(xPosition, yPosition, val, height);
377
+ val = Math.min(val, limitWidth);
378
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { width: val } };
379
+ if (lockRatio) {
380
+ let heightFix = val / width * height;
381
+ if (heightFix = Math.max(heightFix, MIN_DRAWING_HEIGHT_LIMIT), heightFix > limitHeight)
374
382
  return;
375
- P(j), H.transform.height = j;
383
+ setHeight(heightFix), updateParam.transform.height = heightFix;
376
384
  }
377
- I(C), e.featurePluginUpdateNotification([H]), w.refreshControls().changeNotification();
378
- }, Re), $e = Ee((C) => {
379
- if (C == null)
385
+ setWidth(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
386
+ }, INPUT_DEBOUNCE_TIME), handleHeightChange = debounce((val) => {
387
+ if (val == null)
380
388
  return;
381
- C = Math.max(C, se);
382
- const { limitHeight: A, limitWidth: x } = oe(M, U, N, C);
383
- C = Math.min(C, A);
384
- const H = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { height: C } };
385
- if (Q) {
386
- let j = C / y * N;
387
- if (j = Math.max(j, se), j > x)
389
+ val = Math.max(val, MIN_DRAWING_WIDTH_LIMIT);
390
+ const { limitHeight, limitWidth } = checkMoveBoundary(xPosition, yPosition, width, val);
391
+ val = Math.min(val, limitHeight);
392
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { height: val } };
393
+ if (lockRatio) {
394
+ let widthFix = val / height * width;
395
+ if (widthFix = Math.max(widthFix, MIN_DRAWING_WIDTH_LIMIT), widthFix > limitWidth)
388
396
  return;
389
- I(j), H.transform.width = j;
397
+ setWidth(widthFix), updateParam.transform.width = widthFix;
390
398
  }
391
- P(C), e.featurePluginUpdateNotification([H]), w.refreshControls().changeNotification();
392
- }, Re), It = Ee((C) => {
393
- if (C == null)
399
+ setHeight(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
400
+ }, INPUT_DEBOUNCE_TIME), handleXChange = debounce((val) => {
401
+ if (val == null)
394
402
  return;
395
- const { limitLeft: A } = oe(C, U, N, y);
396
- C = A;
397
- const x = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { left: C } };
398
- D(C), e.featurePluginUpdateNotification([x]), w.refreshControls().changeNotification();
399
- }, Re), Pt = Ee((C) => {
400
- if (C == null)
403
+ const { limitLeft } = checkMoveBoundary(val, yPosition, width, height);
404
+ val = limitLeft;
405
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { left: val } };
406
+ setXPosition(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
407
+ }, INPUT_DEBOUNCE_TIME), handleYChange = debounce((val) => {
408
+ if (val == null)
401
409
  return;
402
- const { limitTop: A } = oe(M, C, N, y);
403
- C = A;
404
- const x = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { top: C } };
405
- T(C), e.featurePluginUpdateNotification([x]), w.refreshControls().changeNotification();
406
- }, Re), yt = (C) => {
407
- if (C == null)
410
+ const { limitTop } = checkMoveBoundary(xPosition, val, width, height);
411
+ val = limitTop;
412
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { top: val } };
413
+ setYPosition(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
414
+ }, INPUT_DEBOUNCE_TIME), handleRotationChange = /* @__PURE__ */ __name((val) => {
415
+ if (val == null)
408
416
  return;
409
- const [A, x] = yn;
410
- C < A && (C = A), C > x && (C = x);
411
- const H = { unitId: l, subUnitId: m, drawingId: u, drawingType: d, transform: { angle: C } };
412
- W(C), e.featurePluginUpdateNotification([H]), w.refreshControls().changeNotification();
413
- }, Et = (C) => {
414
- Ie(C), w.keepRatio = C;
415
- }, Rt = (C) => C ? "block" : "none";
416
- return /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: Rt(o) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, n.t("image-panel.transform.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.width"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: N, onChange: (C) => {
417
- We(C);
418
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.height"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: y, onChange: (C) => {
419
- $e(C);
420
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.lock"))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelRow, g.imageCommonPanelRowVertical) }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(At, { checked: Q, onChange: Et })))))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.x"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: M, onChange: (C) => {
421
- It(C);
422
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.y"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: U, onChange: (C) => {
423
- Pt(C);
424
- }, className: g.imageCommonPanelInput }))))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan3) }, /* @__PURE__ */ c.createElement("label", null, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, n.t("image-panel.transform.rotate"))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelColumn }, /* @__PURE__ */ c.createElement(pe, { precision: 1, value: ie, onChange: yt, className: g.imageCommonPanelInput })))))));
425
- };
426
- var E = /* @__PURE__ */ ((a) => (a.default = "0", a.left = "1", a.center = "2", a.right = "3", a.top = "4", a.middle = "5", a.bottom = "6", a.horizon = "7", a.vertical = "8", a))(E || {});
427
- const Je = {
417
+ const [min, max] = RANGE_DRAWING_ROTATION_LIMIT;
418
+ val < min && (val = min), val > max && (val = max);
419
+ const updateParam = { unitId, subUnitId, drawingId, drawingType, transform: { angle: val } };
420
+ setRotation(val), drawingManagerService.featurePluginUpdateNotification([updateParam]), transformer.refreshControls().changeNotification();
421
+ }, "handleRotationChange"), handleLockRatioChange = /* @__PURE__ */ __name((val) => {
422
+ setLockRatio(val), transformer.keepRatio = val;
423
+ }, "handleLockRatioChange"), gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
424
+ return /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(transformShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.transform.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.width"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: width, onChange: /* @__PURE__ */ __name((val) => {
425
+ handleWidthChange(val);
426
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.height"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: height, onChange: /* @__PURE__ */ __name((val) => {
427
+ handleHeightChange(val);
428
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.lock"))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelRow, styles$1.imageCommonPanelRowVertical) }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(Checkbox, { checked: lockRatio, onChange: handleLockRatioChange })))))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.x"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: xPosition, onChange: /* @__PURE__ */ __name((val) => {
429
+ handleXChange(val);
430
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.y"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: yPosition, onChange: /* @__PURE__ */ __name((val) => {
431
+ handleYChange(val);
432
+ }, "onChange"), className: styles$1.imageCommonPanelInput }))))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan3) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, localeService.t("image-panel.transform.rotate"))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelColumn }, /* @__PURE__ */ React.createElement(InputNumber, { precision: 1, value: rotation, onChange: handleRotationChange, className: styles$1.imageCommonPanelInput })))))));
433
+ }, "DrawingTransform");
434
+ var AlignType = /* @__PURE__ */ ((AlignType2) => (AlignType2.default = "0", AlignType2.left = "1", AlignType2.center = "2", AlignType2.right = "3", AlignType2.top = "4", AlignType2.middle = "5", AlignType2.bottom = "6", AlignType2.horizon = "7", AlignType2.vertical = "8", AlignType2))(AlignType || {});
435
+ const SetDrawingAlignOperation = {
428
436
  id: "sheet.operation.set-image-align",
429
- type: Se.OPERATION,
430
- handler: (a, n) => !0
431
- }, Rn = (a) => {
432
- const n = V(ue), e = V(Y), { alignShow: t } = a, [r, o] = L(E.default), i = [
437
+ type: CommandType.OPERATION,
438
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
439
+ }, DrawingAlign = /* @__PURE__ */ __name((props) => {
440
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), { alignShow } = props, [alignValue, setAlignValue] = useState(AlignType.default), alignOptions = [
433
441
  {
434
- label: e.t("image-panel.align.default"),
435
- value: E.default
442
+ label: localeService.t("image-panel.align.default"),
443
+ value: AlignType.default
436
444
  },
437
445
  {
438
446
  options: [
439
447
  {
440
- label: e.t("image-panel.align.left"),
441
- value: E.left
448
+ label: localeService.t("image-panel.align.left"),
449
+ value: AlignType.left
442
450
  },
443
451
  {
444
- label: e.t("image-panel.align.center"),
445
- value: E.center
452
+ label: localeService.t("image-panel.align.center"),
453
+ value: AlignType.center
446
454
  },
447
455
  {
448
- label: e.t("image-panel.align.right"),
449
- value: E.right
456
+ label: localeService.t("image-panel.align.right"),
457
+ value: AlignType.right
450
458
  }
451
459
  ]
452
460
  },
453
461
  {
454
462
  options: [
455
463
  {
456
- label: e.t("image-panel.align.top"),
457
- value: E.top
464
+ label: localeService.t("image-panel.align.top"),
465
+ value: AlignType.top
458
466
  },
459
467
  {
460
- label: e.t("image-panel.align.middle"),
461
- value: E.middle
468
+ label: localeService.t("image-panel.align.middle"),
469
+ value: AlignType.middle
462
470
  },
463
471
  {
464
- label: e.t("image-panel.align.bottom"),
465
- value: E.bottom
472
+ label: localeService.t("image-panel.align.bottom"),
473
+ value: AlignType.bottom
466
474
  }
467
475
  ]
468
476
  },
469
477
  {
470
478
  options: [
471
479
  {
472
- label: e.t("image-panel.align.horizon"),
473
- value: E.horizon
480
+ label: localeService.t("image-panel.align.horizon"),
481
+ value: AlignType.horizon
474
482
  },
475
483
  {
476
- label: e.t("image-panel.align.vertical"),
477
- value: E.vertical
484
+ label: localeService.t("image-panel.align.vertical"),
485
+ value: AlignType.vertical
478
486
  }
479
487
  ]
480
488
  }
481
489
  ];
482
- function s(m) {
483
- o(m), n.executeCommand(Je.id, {
484
- alignType: m
490
+ function handleAlignChange(value) {
491
+ setAlignValue(value), commandService.executeCommand(SetDrawingAlignOperation.id, {
492
+ alignType: value
485
493
  });
486
494
  }
487
- const l = (m) => m ? "block" : "none";
488
- return /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: l(t) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, e.t("image-panel.align.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn) }, /* @__PURE__ */ c.createElement(mt, { value: r, options: i, onChange: s }))));
489
- }, Ze = {
495
+ __name(handleAlignChange, "handleAlignChange");
496
+ const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay");
497
+ return /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(alignShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.align.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn) }, /* @__PURE__ */ React.createElement(Select, { value: alignValue, options: alignOptions, onChange: handleAlignChange }))));
498
+ }, "DrawingAlign"), OpenImageCropOperation = {
490
499
  id: "sheet.operation.open-image-crop",
491
- type: Se.OPERATION,
492
- handler: (a, n) => !0
493
- }, me = {
500
+ type: CommandType.OPERATION,
501
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
502
+ }, CloseImageCropOperation = {
494
503
  id: "sheet.operation.close-image-crop",
495
- type: Se.OPERATION,
496
- handler: (a, n) => !0
504
+ type: CommandType.OPERATION,
505
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
497
506
  };
498
- var B = /* @__PURE__ */ ((a) => (a.FREE = "0", a.R1_1 = "1", a.R16_9 = "2", a.R9_16 = "3", a.R5_4 = "4", a.R4_5 = "5", a.R4_3 = "6", a.R3_4 = "7", a.R3_2 = "8", a.R2_3 = "9", a))(B || {});
499
- const Le = {
507
+ var CropType = /* @__PURE__ */ ((CropType2) => (CropType2.FREE = "0", CropType2.R1_1 = "1", CropType2.R16_9 = "2", CropType2.R9_16 = "3", CropType2.R5_4 = "4", CropType2.R4_5 = "5", CropType2.R4_3 = "6", CropType2.R3_4 = "7", CropType2.R3_2 = "8", CropType2.R2_3 = "9", CropType2))(CropType || {});
508
+ const AutoImageCropOperation = {
500
509
  id: "sheet.operation.Auto-image-crop",
501
- type: Se.OPERATION,
502
- handler: (a, n) => !0
503
- }, Mn = (a) => {
504
- const n = V(ue), e = V(Y), { drawings: t, cropperShow: r } = a;
505
- if (t[0] == null)
510
+ type: CommandType.OPERATION,
511
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
512
+ }, ImageCropper = /* @__PURE__ */ __name((props) => {
513
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), { drawings, cropperShow } = props;
514
+ if (drawings[0] == null)
506
515
  return;
507
- const [i, s] = L(B.FREE), l = lt(!1), m = [
516
+ const [cropValue, setCropValue] = useState(CropType.FREE), cropStateRef = useRef(!1), cropOptions = [
508
517
  {
509
- label: e.t("image-panel.crop.mode"),
510
- value: B.FREE
518
+ label: localeService.t("image-panel.crop.mode"),
519
+ value: CropType.FREE
511
520
  },
512
521
  {
513
522
  label: "1:1",
514
- value: B.R1_1
523
+ value: CropType.R1_1
515
524
  },
516
525
  {
517
526
  label: "16:9",
518
- value: B.R16_9
527
+ value: CropType.R16_9
519
528
  },
520
529
  {
521
530
  label: "9:16",
522
- value: B.R9_16
531
+ value: CropType.R9_16
523
532
  },
524
533
  {
525
534
  label: "5:4",
526
- value: B.R5_4
535
+ value: CropType.R5_4
527
536
  },
528
537
  {
529
538
  label: "4:5",
530
- value: B.R4_5
539
+ value: CropType.R4_5
531
540
  },
532
541
  {
533
542
  label: "4:3",
534
- value: B.R4_3
543
+ value: CropType.R4_3
535
544
  },
536
545
  {
537
546
  label: "3:4",
538
- value: B.R3_4
547
+ value: CropType.R3_4
539
548
  },
540
549
  {
541
550
  label: "3:2",
542
- value: B.R3_2
551
+ value: CropType.R3_2
543
552
  },
544
553
  {
545
554
  label: "2:3",
546
- value: B.R2_3
555
+ value: CropType.R2_3
547
556
  }
548
557
  ];
549
- be(() => {
550
- const f = n.onCommandExecuted((v) => {
551
- if (v.id === me.id) {
552
- const w = v.params;
553
- w != null && w.isAuto || (l.current = !1);
558
+ useEffect(() => {
559
+ const onChangeStartObserver = commandService.onCommandExecuted((command) => {
560
+ if (command.id === CloseImageCropOperation.id) {
561
+ const params = command.params;
562
+ params != null && params.isAuto || (cropStateRef.current = !1);
554
563
  }
555
564
  });
556
565
  return () => {
557
- f == null || f.dispose();
566
+ onChangeStartObserver == null || onChangeStartObserver.dispose();
558
567
  };
559
568
  }, []);
560
- function u(f) {
561
- s(f), l.current && n.executeCommand(Le.id, {
562
- cropType: f
569
+ function handleCropChange(value) {
570
+ setCropValue(value), cropStateRef.current && commandService.executeCommand(AutoImageCropOperation.id, {
571
+ cropType: value
563
572
  });
564
573
  }
565
- const d = (f) => f ? "block" : "none", h = (f) => {
566
- n.executeCommand(Le.id, {
567
- cropType: f
568
- }), l.current = !0;
569
- };
570
- return /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: d(r) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, e.t("image-panel.crop.title")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelRow, g.imageCommonPanelRowVertical) }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
571
- h(i);
572
- } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(ht, null), e.t("image-panel.crop.start")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2) }, /* @__PURE__ */ c.createElement(mt, { value: i, options: m, onChange: u }))));
573
- }, On = (a) => {
574
- const n = V(Y), e = V(he), t = V(ae), { hasGroup: r, drawings: o } = a, [i, s] = L(!1), [l, m] = L(!0), [u, d] = L(!0), h = (p) => p ? "block" : "none", f = () => {
575
- const p = t.getFocusDrawings(), { unitId: S, subUnitId: _ } = p[0], R = Ht.generateRandomId(10), b = Dt(0, 0, p.map((y) => y.transform || {})), N = {
576
- unitId: S,
577
- subUnitId: _,
578
- drawingId: R,
579
- drawingType: re.DRAWING_GROUP,
580
- transform: b
581
- }, I = p.map((y) => {
582
- const P = y.transform || { left: 0, top: 0 }, { unitId: M, subUnitId: D, drawingId: U } = y;
574
+ __name(handleCropChange, "handleCropChange");
575
+ const gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay"), onCropperBtnClick = /* @__PURE__ */ __name((val) => {
576
+ commandService.executeCommand(AutoImageCropOperation.id, {
577
+ cropType: val
578
+ }), cropStateRef.current = !0;
579
+ }, "onCropperBtnClick");
580
+ return /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(cropperShow) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.crop.title")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelRow, styles$1.imageCommonPanelRowVertical) }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
581
+ onCropperBtnClick(cropValue);
582
+ }, "onClick") }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(CreateCopySingle, null), localeService.t("image-panel.crop.start")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2) }, /* @__PURE__ */ React.createElement(Select, { value: cropValue, options: cropOptions, onChange: handleCropChange }))));
583
+ }, "ImageCropper"), DrawingGroup = /* @__PURE__ */ __name((props) => {
584
+ const localeService = useDependency(LocaleService), renderManagerService = useDependency(IRenderManagerService), drawingManagerService = useDependency(IDrawingManagerService), { hasGroup, drawings } = props, [groupShow, setGroupShow] = useState(!1), [groupBtnShow, setGroupBtnShow] = useState(!0), [ungroupBtnShow, setUngroupBtnShow] = useState(!0), gridDisplay = /* @__PURE__ */ __name((isShow) => isShow ? "block" : "none", "gridDisplay"), onGroupBtnClick = /* @__PURE__ */ __name(() => {
585
+ const focusDrawings = drawingManagerService.getFocusDrawings(), { unitId, subUnitId } = focusDrawings[0], groupId = Tools.generateRandomId(10), groupTransform = getGroupState(0, 0, focusDrawings.map((o) => o.transform || {})), groupParam = {
586
+ unitId,
587
+ subUnitId,
588
+ drawingId: groupId,
589
+ drawingType: DrawingTypeEnum.DRAWING_GROUP,
590
+ transform: groupTransform
591
+ }, children = focusDrawings.map((drawing) => {
592
+ const transform = drawing.transform || { left: 0, top: 0 }, { unitId: unitId2, subUnitId: subUnitId2, drawingId } = drawing;
583
593
  return {
584
- unitId: M,
585
- subUnitId: D,
586
- drawingId: U,
594
+ unitId: unitId2,
595
+ subUnitId: subUnitId2,
596
+ drawingId,
587
597
  transform: {
588
- ...P,
589
- left: P.left - b.left,
590
- top: P.top - b.top
598
+ ...transform,
599
+ left: transform.left - groupTransform.left,
600
+ top: transform.top - groupTransform.top
591
601
  },
592
- groupId: R
602
+ groupId
593
603
  };
594
604
  });
595
- t.featurePluginGroupUpdateNotification([{
596
- parent: N,
597
- children: I
605
+ drawingManagerService.featurePluginGroupUpdateNotification([{
606
+ parent: groupParam,
607
+ children
598
608
  }]);
599
- }, v = (p) => {
600
- if (p.drawingType !== re.DRAWING_GROUP)
609
+ }, "onGroupBtnClick"), ungroup = /* @__PURE__ */ __name((param) => {
610
+ if (param.drawingType !== DrawingTypeEnum.DRAWING_GROUP)
601
611
  return;
602
- const { unitId: S, subUnitId: _, drawingId: R, transform: b = { width: 0, height: 0 } } = p;
603
- if (b == null)
612
+ const { unitId, subUnitId, drawingId, transform: groupTransform = { width: 0, height: 0 } } = param;
613
+ if (groupTransform == null)
604
614
  return;
605
- const N = t.getDrawingsByGroup({ unitId: S, subUnitId: _, drawingId: R });
606
- if (N.length === 0)
615
+ const objects = drawingManagerService.getDrawingsByGroup({ unitId, subUnitId, drawingId });
616
+ if (objects.length === 0)
607
617
  return;
608
- const I = N.map((y) => {
609
- const { transform: P } = y, { unitId: M, subUnitId: D, drawingId: U } = y, T = Tt(P || {}, b, b.width || 0, b.height || 0);
618
+ const children = objects.map((object) => {
619
+ const { transform } = object, { unitId: unitId2, subUnitId: subUnitId2, drawingId: drawingId2 } = object, newTransform = transformObjectOutOfGroup(transform || {}, groupTransform, groupTransform.width || 0, groupTransform.height || 0);
610
620
  return {
611
- unitId: M,
612
- subUnitId: D,
613
- drawingId: U,
621
+ unitId: unitId2,
622
+ subUnitId: subUnitId2,
623
+ drawingId: drawingId2,
614
624
  transform: {
615
- ...P,
616
- ...T
625
+ ...transform,
626
+ ...newTransform
617
627
  },
618
628
  groupId: void 0
619
629
  };
620
630
  });
621
631
  return {
622
- parent: p,
623
- children: I
632
+ parent: param,
633
+ children
624
634
  };
625
- }, w = () => {
626
- const S = t.getFocusDrawings().map(
627
- (_) => v(_)
628
- ).filter((_) => _ != null);
629
- S.length !== 0 && t.featurePluginUngroupUpdateNotification(S);
630
- };
631
- return be(() => {
632
- const p = o[0];
633
- if (p == null)
635
+ }, "ungroup"), onUngroupBtnClick = /* @__PURE__ */ __name(() => {
636
+ const params = drawingManagerService.getFocusDrawings().map(
637
+ (drawing) => ungroup(drawing)
638
+ ).filter((o) => o != null);
639
+ params.length !== 0 && drawingManagerService.featurePluginUngroupUpdateNotification(params);
640
+ }, "onUngroupBtnClick");
641
+ return useEffect(() => {
642
+ const drawingParam = drawings[0];
643
+ if (drawingParam == null)
634
644
  return;
635
- const { unitId: S } = p, _ = e.getRenderById(S), R = _ == null ? void 0 : _.scene;
636
- if (R == null)
645
+ const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
646
+ if (scene == null)
637
647
  return;
638
- const b = R.getTransformerByCreate(), N = b.clearControl$.subscribe((y) => {
639
- y === !0 && s(!1);
640
- }), I = b.changeStart$.subscribe((y) => {
641
- const { objects: P } = y, M = Ge(P, t), D = M.filter((W) => (W == null ? void 0 : W.drawingType) === re.DRAWING_GROUP);
642
- let U = !1, T = !1;
643
- M.length > 1 && (U = !0), D.length > 0 && (T = !0), s(U || T), m(U), d(T);
648
+ const transformer = scene.getTransformerByCreate(), onClearControlObserver = transformer.clearControl$.subscribe((changeSelf) => {
649
+ changeSelf === !0 && setGroupShow(!1);
650
+ }), onChangeStartObserver = transformer.changeStart$.subscribe((state) => {
651
+ const { objects } = state, params = getUpdateParams(objects, drawingManagerService), groupParams = params.filter((o) => (o == null ? void 0 : o.drawingType) === DrawingTypeEnum.DRAWING_GROUP);
652
+ let groupBtnShow2 = !1, ungroupBtnShow2 = !1;
653
+ params.length > 1 && (groupBtnShow2 = !0), groupParams.length > 0 && (ungroupBtnShow2 = !0), setGroupShow(groupBtnShow2 || ungroupBtnShow2), setGroupBtnShow(groupBtnShow2), setUngroupBtnShow(ungroupBtnShow2);
644
654
  });
645
655
  return () => {
646
- I.unsubscribe(), N.unsubscribe();
656
+ onChangeStartObserver.unsubscribe(), onClearControlObserver.unsubscribe();
647
657
  };
648
- }, []), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelGrid, g.imageCommonPanelBorder), style: { display: h(r === !0 ? i : !1) } }, /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelTitle) }, /* @__PURE__ */ c.createElement("div", null, n.t("image-panel.group.title")))), /* @__PURE__ */ c.createElement("div", { className: g.imageCommonPanelRow }, /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2, g.imageCommonPanelColumnCenter) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
649
- f();
650
- }, style: { display: h(l) } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(ft, null), n.t("image-panel.group.group")))), /* @__PURE__ */ c.createElement("div", { className: O(g.imageCommonPanelColumn, g.imageCommonPanelSpan2, g.imageCommonPanelColumnCenter) }, /* @__PURE__ */ c.createElement(le, { size: "small", onClick: () => {
651
- w();
652
- }, style: { display: h(u) } }, /* @__PURE__ */ c.createElement("span", { className: g.imageCommonPanelInline }, /* @__PURE__ */ c.createElement(_t, null), n.t("image-panel.group.unGroup"))))));
653
- }, gr = (a) => {
654
- const n = V(ae), e = V(he), t = V(Y), { drawings: r, hasArrange: o = !0, hasTransform: i = !0, hasAlign: s = !0, hasCropper: l = !0, hasGroup: m = !0 } = a, u = r[0];
655
- if (u == null)
658
+ }, []), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelGrid, styles$1.imageCommonPanelBorder), style: { display: gridDisplay(hasGroup === !0 ? groupShow : !1) } }, /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelTitle) }, /* @__PURE__ */ React.createElement("div", null, localeService.t("image-panel.group.title")))), /* @__PURE__ */ React.createElement("div", { className: styles$1.imageCommonPanelRow }, /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2, styles$1.imageCommonPanelColumnCenter) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
659
+ onGroupBtnClick();
660
+ }, "onClick"), style: { display: gridDisplay(groupBtnShow) } }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(GroupSingle, null), localeService.t("image-panel.group.group")))), /* @__PURE__ */ React.createElement("div", { className: clsx(styles$1.imageCommonPanelColumn, styles$1.imageCommonPanelSpan2, styles$1.imageCommonPanelColumnCenter) }, /* @__PURE__ */ React.createElement(Button, { size: "small", onClick: /* @__PURE__ */ __name(() => {
661
+ onUngroupBtnClick();
662
+ }, "onClick"), style: { display: gridDisplay(ungroupBtnShow) } }, /* @__PURE__ */ React.createElement("span", { className: styles$1.imageCommonPanelInline }, /* @__PURE__ */ React.createElement(UngroupSingle, null), localeService.t("image-panel.group.unGroup"))))));
663
+ }, "DrawingGroup"), DrawingCommonPanel = /* @__PURE__ */ __name((props) => {
664
+ const drawingManagerService = useDependency(IDrawingManagerService), renderManagerService = useDependency(IRenderManagerService), localeService = useDependency(LocaleService), { drawings, hasArrange = !0, hasTransform = !0, hasAlign = !0, hasCropper = !0, hasGroup = !0 } = props, drawingParam = drawings[0];
665
+ if (drawingParam == null)
656
666
  return;
657
- const { unitId: d } = u, h = e.getRenderById(d), f = h == null ? void 0 : h.scene;
658
- if (f == null)
667
+ const { unitId } = drawingParam, renderObject = renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
668
+ if (scene == null)
659
669
  return;
660
- const v = f.getTransformerByCreate(), [w, p] = L(!0), [S, _] = L(!0), [R, b] = L(!1), [N, I] = L(!0), [y, P] = L(!1);
661
- return be(() => {
662
- const M = v.clearControl$.subscribe((T) => {
663
- T === !0 && (p(!1), _(!1), b(!1), I(!1), P(!0));
664
- }), D = v.changeStart$.subscribe((T) => {
665
- const { objects: ie } = T, W = Ge(ie, n);
666
- W.length === 0 ? (p(!1), _(!1), b(!1), I(!1), P(!0)) : W.length === 1 ? (p(!0), _(!0), b(!1), I(!0), P(!1)) : (p(!0), _(!1), b(!0), I(!1), P(!1));
667
- }), U = n.focus$.subscribe((T) => {
668
- T.length === 0 ? (p(!1), _(!1), b(!1), I(!1), P(!0)) : T.length === 1 ? (p(!0), _(!0), b(!1), I(!0), P(!1)) : (p(!0), _(!1), b(!0), I(!1), P(!1));
670
+ const transformer = scene.getTransformerByCreate(), [arrangeShow, setArrangeShow] = useState(!0), [transformShow, setTransformShow] = useState(!0), [alignShow, setAlignShow] = useState(!1), [cropperShow, setCropperShow] = useState(!0), [nullShow, setNullShow] = useState(!1);
671
+ return useEffect(() => {
672
+ const clearControlSub = transformer.clearControl$.subscribe((changeSelf) => {
673
+ changeSelf === !0 && (setArrangeShow(!1), setTransformShow(!1), setAlignShow(!1), setCropperShow(!1), setNullShow(!0));
674
+ }), changeStartSub = transformer.changeStart$.subscribe((state) => {
675
+ const { objects } = state, params = getUpdateParams(objects, drawingManagerService);
676
+ params.length === 0 ? (setArrangeShow(!1), setTransformShow(!1), setAlignShow(!1), setCropperShow(!1), setNullShow(!0)) : params.length === 1 ? (setArrangeShow(!0), setTransformShow(!0), setAlignShow(!1), setCropperShow(!0), setNullShow(!1)) : (setArrangeShow(!0), setTransformShow(!1), setAlignShow(!0), setCropperShow(!1), setNullShow(!1));
677
+ }), focusSub = drawingManagerService.focus$.subscribe((drawings2) => {
678
+ drawings2.length === 0 ? (setArrangeShow(!1), setTransformShow(!1), setAlignShow(!1), setCropperShow(!1), setNullShow(!0)) : drawings2.length === 1 ? (setArrangeShow(!0), setTransformShow(!0), setAlignShow(!1), setCropperShow(!0), setNullShow(!1)) : (setArrangeShow(!0), setTransformShow(!1), setAlignShow(!0), setCropperShow(!1), setNullShow(!1));
669
679
  });
670
680
  return () => {
671
- D.unsubscribe(), M.unsubscribe(), U.unsubscribe();
681
+ changeStartSub.unsubscribe(), clearControlSub.unsubscribe(), focusSub.unsubscribe();
672
682
  };
673
- }, []), /* @__PURE__ */ c.createElement(c.Fragment, null, /* @__PURE__ */ c.createElement("div", { style: { display: y === !0 ? "block" : "none", height: "100%" } }, /* @__PURE__ */ c.createElement("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", top: "50%", marginTop: "-100px" } }, /* @__PURE__ */ c.createElement("span", null, t.t("image-panel.null")))), /* @__PURE__ */ c.createElement(In, { arrangeShow: o === !0 ? w : !1, drawings: r }), /* @__PURE__ */ c.createElement(En, { transformShow: i === !0 ? S : !1, drawings: r }), /* @__PURE__ */ c.createElement(Rn, { alignShow: s === !0 ? R : !1, drawings: r }), /* @__PURE__ */ c.createElement(Mn, { cropperShow: l === !0 ? N : !1, drawings: r }), /* @__PURE__ */ c.createElement(On, { hasGroup: m, drawings: r }));
674
- }, Nn = "univer-image-popup-menu", Dn = "univer-image-popup-menu-item", Tn = "univer-image-popup-menu-item-icon", Bn = "univer-image-popup-menu-item-title", jn = "univer-image-popup-menu-item-hide", Un = "univer-btn-container", Hn = "univer-btn-container-expand", Ce = {
675
- imagePopupMenu: Nn,
676
- imagePopupMenuItem: Dn,
677
- imagePopupMenuItemIcon: Tn,
678
- imagePopupMenuItemTitle: Bn,
679
- imagePopupMenuItemHide: jn,
680
- btnContainer: Un,
681
- btnContainerExpand: Hn
682
- }, Ln = (a) => {
683
- var v, w;
684
- const n = (w = (v = a.popup) == null ? void 0 : v.extraProps) == null ? void 0 : w.menuItems;
685
- if (!n)
683
+ }, []), /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { style: { display: nullShow === !0 ? "block" : "none", height: "100%" } }, /* @__PURE__ */ React.createElement("div", { style: { display: "flex", justifyContent: "center", alignItems: "center", height: "100%", top: "50%", marginTop: "-100px" } }, /* @__PURE__ */ React.createElement("span", null, localeService.t("image-panel.null")))), /* @__PURE__ */ React.createElement(DrawingArrange, { arrangeShow: hasArrange === !0 ? arrangeShow : !1, drawings }), /* @__PURE__ */ React.createElement(DrawingTransform, { transformShow: hasTransform === !0 ? transformShow : !1, drawings }), /* @__PURE__ */ React.createElement(DrawingAlign, { alignShow: hasAlign === !0 ? alignShow : !1, drawings }), /* @__PURE__ */ React.createElement(ImageCropper, { cropperShow: hasCropper === !0 ? cropperShow : !1, drawings }), /* @__PURE__ */ React.createElement(DrawingGroup, { hasGroup, drawings }));
684
+ }, "DrawingCommonPanel"), imagePopupMenu = "univer-image-popup-menu", imagePopupMenuItem = "univer-image-popup-menu-item", imagePopupMenuItemIcon = "univer-image-popup-menu-item-icon", imagePopupMenuItemTitle = "univer-image-popup-menu-item-title", imagePopupMenuItemHide = "univer-image-popup-menu-item-hide", btnContainer = "univer-btn-container", btnContainerExpand = "univer-btn-container-expand", styles = {
685
+ imagePopupMenu,
686
+ imagePopupMenuItem,
687
+ imagePopupMenuItemIcon,
688
+ imagePopupMenuItemTitle,
689
+ imagePopupMenuItemHide,
690
+ btnContainer,
691
+ btnContainerExpand
692
+ }, ImagePopupMenu = /* @__PURE__ */ __name((props) => {
693
+ var _a7, _b;
694
+ const menuItems = (_b = (_a7 = props.popup) == null ? void 0 : _a7.extraProps) == null ? void 0 : _b.menuItems;
695
+ if (!menuItems)
686
696
  return null;
687
- const e = V(ue), t = V(Y), [r, o] = L(!1), [i, s] = L(!1), l = () => {
688
- s(!0);
689
- }, m = () => {
690
- s(!1);
691
- }, u = (p) => {
692
- o(p);
693
- }, d = (p) => {
694
- e.executeCommand(p.commandId, p.commandParams), o(!1);
695
- }, h = r || i, f = n.filter((p) => !p.disable);
696
- return /* @__PURE__ */ c.createElement(
697
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), [visible, setVisible] = useState(!1), [isHovered, setHovered] = useState(!1), handleMouseEnter = /* @__PURE__ */ __name(() => {
698
+ setHovered(!0);
699
+ }, "handleMouseEnter"), handleMouseLeave = /* @__PURE__ */ __name(() => {
700
+ setHovered(!1);
701
+ }, "handleMouseLeave"), onVisibleChange = /* @__PURE__ */ __name((visible2) => {
702
+ setVisible(visible2);
703
+ }, "onVisibleChange"), handleClick = /* @__PURE__ */ __name((item) => {
704
+ commandService.executeCommand(item.commandId, item.commandParams), setVisible(!1);
705
+ }, "handleClick"), showMore = visible || isHovered, availableMenu = menuItems.filter((item) => !item.disable);
706
+ return /* @__PURE__ */ React.createElement(
697
707
  "div",
698
708
  {
699
- onMouseEnter: l,
700
- onMouseLeave: m
709
+ onMouseEnter: handleMouseEnter,
710
+ onMouseLeave: handleMouseLeave
701
711
  },
702
- /* @__PURE__ */ c.createElement(
703
- xt,
712
+ /* @__PURE__ */ React.createElement(
713
+ Dropdown,
704
714
  {
705
715
  placement: "bottomLeft",
706
716
  trigger: ["click"],
707
- overlay: /* @__PURE__ */ c.createElement("ul", { className: Ce.imagePopupMenu }, f.map((p) => /* @__PURE__ */ c.createElement(
717
+ overlay: /* @__PURE__ */ React.createElement("ul", { className: styles.imagePopupMenu }, availableMenu.map((item) => /* @__PURE__ */ React.createElement(
708
718
  "li",
709
719
  {
710
- key: p.index,
711
- onClick: () => d(p),
712
- className: Ce.imagePopupMenuItem
720
+ key: item.index,
721
+ onClick: /* @__PURE__ */ __name(() => handleClick(item), "onClick"),
722
+ className: styles.imagePopupMenuItem
713
723
  },
714
- /* @__PURE__ */ c.createElement("span", { className: Ce.imagePopupMenuItemTitle }, t.t(p.label))
724
+ /* @__PURE__ */ React.createElement("span", { className: styles.imagePopupMenuItemTitle }, localeService.t(item.label))
715
725
  ))),
716
- visible: r,
717
- onVisibleChange: u
726
+ visible,
727
+ onVisibleChange
718
728
  },
719
- /* @__PURE__ */ c.createElement(
729
+ /* @__PURE__ */ React.createElement(
720
730
  "div",
721
731
  {
722
- className: O(Ce.btnContainer, {
723
- [Ce.btnContainerExpand]: r
732
+ className: clsx(styles.btnContainer, {
733
+ [styles.btnContainerExpand]: visible
724
734
  })
725
735
  },
726
- /* @__PURE__ */ c.createElement(
727
- ut,
736
+ /* @__PURE__ */ React.createElement(
737
+ Autofill,
728
738
  {
729
739
  style: { color: "#35322B" },
730
740
  extend: { colorChannel1: "rgb(var(--green-700, #409f11))" }
731
741
  }
732
742
  ),
733
- h && /* @__PURE__ */ c.createElement(pt, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
743
+ showMore && /* @__PURE__ */ React.createElement(MoreDownSingle, { style: { color: "#CCCCCC", fontSize: "8px", marginLeft: "8px" } })
734
744
  )
735
745
  )
736
746
  );
737
- }, An = "COMPONENT_IMAGE_POPUP_MENU";
738
- var xn = Object.defineProperty, Vn = Object.getOwnPropertyDescriptor, Gn = (a, n, e, t) => {
739
- for (var r = t > 1 ? void 0 : t ? Vn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
740
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
741
- return t && r && xn(n, e, r), r;
742
- }, Me = (a, n) => (e, t) => n(e, t, a);
743
- let De = class extends Ae {
744
- constructor(n, e, t, r) {
747
+ }, "ImagePopupMenu"), COMPONENT_IMAGE_POPUP_MENU = "COMPONENT_IMAGE_POPUP_MENU";
748
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
749
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
750
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
751
+ return kind && result && __defProp$4(target, key, result), result;
752
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a2;
753
+ let DrawingUpdateController = (_a2 = class extends Disposable {
754
+ constructor(_currentUniverService, _commandService, _renderManagerService, _drawingManagerService) {
745
755
  super();
746
- te(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
747
- this._currentUniverService = n, this._commandService = e, this._renderManagerService = t, this._drawingManagerService = r, this._initialize();
756
+ __publicField(this, "_sceneListenerOnDrawingMap", /* @__PURE__ */ new WeakSet());
757
+ this._currentUniverService = _currentUniverService, this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._drawingManagerService = _drawingManagerService, this._initialize();
748
758
  }
749
759
  dispose() {
750
760
  super.dispose();
@@ -753,39 +763,39 @@ let De = class extends Ae {
753
763
  this._recoveryImages(), this._drawingAddListener(), this._drawingRemoveListener(), this._drawingUpdateListener(), this._commandExecutedListener(), this._drawingArrangeListener(), this._drawingGroupListener(), this._drawingRefreshListener(), this._drawingVisibleListener();
754
764
  }
755
765
  _recoveryImages() {
756
- const n = this._drawingManagerService.drawingManagerData, e = Ke(this._currentUniverService);
757
- if (e == null)
766
+ const drawingList = this._drawingManagerService.drawingManagerData, info = getCurrentUnitInfo(this._currentUniverService);
767
+ if (info == null)
758
768
  return;
759
- const { unitId: t, subUnitId: r } = e;
760
- Object.keys(n).forEach((o) => {
761
- Object.keys(n[o]).forEach((i) => {
762
- const s = n[o][i].data;
763
- s == null || o !== t || i !== r || Object.keys(s).forEach((l) => {
764
- s[l] && this._insertDrawing([{ unitId: o, subUnitId: i, drawingId: l }]);
769
+ const { unitId: currentUnitId, subUnitId: currentSubUnitId } = info;
770
+ Object.keys(drawingList).forEach((unitId) => {
771
+ Object.keys(drawingList[unitId]).forEach((subUnitId) => {
772
+ const drawingMap = drawingList[unitId][subUnitId].data;
773
+ drawingMap == null || unitId !== currentUnitId || subUnitId !== currentSubUnitId || Object.keys(drawingMap).forEach((drawingId) => {
774
+ drawingMap[drawingId] && this._insertDrawing([{ unitId, subUnitId, drawingId }]);
765
775
  });
766
776
  });
767
777
  });
768
778
  }
769
779
  _commandExecutedListener() {
770
780
  this.disposeWithMe(
771
- this._commandService.onCommandExecuted((n) => {
772
- if (n.id === Je.id) {
773
- const e = n.params;
774
- if (e == null)
781
+ this._commandService.onCommandExecuted((command) => {
782
+ if (command.id === SetDrawingAlignOperation.id) {
783
+ const params = command.params;
784
+ if (params == null)
775
785
  return;
776
- this._drawingAlign(e);
786
+ this._drawingAlign(params);
777
787
  }
778
788
  })
779
789
  );
780
790
  }
781
791
  _drawingGroupListener() {
782
792
  this.disposeWithMe(
783
- this._drawingManagerService.group$.subscribe((n) => {
784
- this._groupDrawings(n);
793
+ this._drawingManagerService.group$.subscribe((params) => {
794
+ this._groupDrawings(params);
785
795
  })
786
796
  ), this.disposeWithMe(
787
- this._drawingManagerService.ungroup$.subscribe((n) => {
788
- this._ungroupDrawings(n);
797
+ this._drawingManagerService.ungroup$.subscribe((params) => {
798
+ this._ungroupDrawings(params);
789
799
  })
790
800
  );
791
801
  }
@@ -809,38 +819,38 @@ let De = class extends Ae {
809
819
  // break;
810
820
  // }
811
821
  // }
812
- _getSceneAndTransformerByDrawingSearch(n) {
813
- if (n == null)
822
+ _getSceneAndTransformerByDrawingSearch(unitId) {
823
+ if (unitId == null)
814
824
  return;
815
- const e = this._renderManagerService.getRenderById(n), t = e == null ? void 0 : e.scene;
816
- if (t == null)
825
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
826
+ if (scene == null)
817
827
  return null;
818
- const r = t.getTransformerByCreate();
819
- return { scene: t, transformer: r };
828
+ const transformer = scene.getTransformerByCreate();
829
+ return { scene, transformer };
820
830
  }
821
- _groupDrawings(n) {
822
- n.forEach((e) => {
823
- this._groupDrawing(e);
831
+ _groupDrawings(drawings) {
832
+ drawings.forEach((drawing) => {
833
+ this._groupDrawing(drawing);
824
834
  });
825
835
  }
826
- _groupDrawing(n) {
827
- const { parent: e, children: t } = n, { unitId: r, subUnitId: o, drawingId: i } = e, s = this._getSceneAndTransformerByDrawingSearch(e.unitId);
828
- if (s == null)
836
+ _groupDrawing(params) {
837
+ const { parent, children } = params, { unitId, subUnitId, drawingId } = parent, renderObject = this._getSceneAndTransformerByDrawingSearch(parent.unitId);
838
+ if (renderObject == null)
829
839
  return;
830
- const { scene: l, transformer: m } = s;
831
- this._commandService.syncExecuteCommand(me.id);
832
- const u = [];
833
- if (t.forEach((f) => {
834
- const v = G(f), w = l.getObjectIncludeInGroup(v);
835
- if (w == null || u.includes(w))
840
+ const { scene, transformer } = renderObject;
841
+ this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
842
+ const objects = [];
843
+ if (children.forEach((drawing) => {
844
+ const drawingShapeKey = getDrawingShapeKeyByDrawingSearch(drawing), object = scene.getObjectIncludeInGroup(drawingShapeKey);
845
+ if (object == null || objects.includes(object))
836
846
  return;
837
- u.push(w);
838
- const { transform: p } = f;
839
- p != null && (w.classType === Qe.GROUP ? w.transformByState({ left: p.left, top: p.top }) : w.transformByState(p));
840
- }), u.length === 0)
847
+ objects.push(object);
848
+ const { transform } = drawing;
849
+ transform != null && (object.classType === RENDER_CLASS_TYPE.GROUP ? object.transformByState({ left: transform.left, top: transform.top }) : object.transformByState(transform));
850
+ }), objects.length === 0)
841
851
  return;
842
- const d = G({ unitId: r, subUnitId: o, drawingId: i }), h = new ve(d);
843
- l.addObject(h, Ye).attachTransformerTo(h), h.addObjects(...u), e.transform && h.transformByState({ left: e.transform.left, top: e.transform.top }), m.clearSelectedObjects(), m.setSelectedControl(h);
852
+ const groupKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), group = new Group(groupKey);
853
+ scene.addObject(group, DRAWING_OBJECT_LAYER_INDEX).attachTransformerTo(group), group.addObjects(...objects), parent.transform && group.transformByState({ left: parent.transform.left, top: parent.transform.top }), transformer.clearSelectedObjects(), transformer.setSelectedControl(group);
844
854
  }
845
855
  // private _regroupDrawings(drawings: IDrawingSearch[]) {
846
856
  // const renderObject = this._getSceneAndTransformerByDrawingSearch(drawings[0].unitId);
@@ -876,127 +886,127 @@ let De = class extends Ae {
876
886
  // transformer.clearSelectedObjects();
877
887
  // transformer.setSelectedControl(firstGroup);
878
888
  // }
879
- _ungroupDrawings(n) {
880
- n.forEach((e) => {
881
- this._ungroupDrawing(e);
889
+ _ungroupDrawings(drawings) {
890
+ drawings.forEach((drawing) => {
891
+ this._ungroupDrawing(drawing);
882
892
  });
883
893
  }
884
- _ungroupDrawing(n) {
885
- const { parent: e, children: t } = n, r = this._getSceneAndTransformerByDrawingSearch(e.unitId);
886
- if (r == null)
894
+ _ungroupDrawing(drawing) {
895
+ const { parent, children } = drawing, renderObject = this._getSceneAndTransformerByDrawingSearch(parent.unitId);
896
+ if (renderObject == null)
887
897
  return;
888
- const { scene: o, transformer: i } = r;
889
- t.forEach((d) => {
890
- const h = G(d), f = o.getObjectIncludeInGroup(h);
891
- if (f == null)
898
+ const { scene, transformer } = renderObject;
899
+ children.forEach((drawing2) => {
900
+ const drawingKey = getDrawingShapeKeyByDrawingSearch(drawing2), object = scene.getObjectIncludeInGroup(drawingKey);
901
+ if (object == null)
892
902
  return !0;
893
- if (f == null)
903
+ if (object == null)
894
904
  return;
895
- const { transform: v } = d;
896
- v != null && (f.classType === Qe.GROUP ? f.transformByState({ left: v.left, top: v.top }) : f.transformByState(v));
905
+ const { transform } = drawing2;
906
+ transform != null && (object.classType === RENDER_CLASS_TYPE.GROUP ? object.transformByState({ left: transform.left, top: transform.top }) : object.transformByState(transform));
897
907
  });
898
- const s = G(e), l = o.getObject(s), { width: m, height: u } = l;
899
- l.getObjects().forEach((d) => {
900
- l.removeSelfObjectAndTransform(d.oKey, m, u);
901
- }), l.dispose(), i.clearSelectedObjects();
902
- }
903
- _drawingAlign(n) {
904
- const { alignType: e } = n, t = this._drawingManagerService.getFocusDrawings();
905
- if (e === E.default)
908
+ const groupKey = getDrawingShapeKeyByDrawingSearch(parent), group = scene.getObject(groupKey), { width, height } = group;
909
+ group.getObjects().forEach((object) => {
910
+ group.removeSelfObjectAndTransform(object.oKey, width, height);
911
+ }), group.dispose(), transformer.clearSelectedObjects();
912
+ }
913
+ _drawingAlign(params) {
914
+ const { alignType } = params, drawings = this._drawingManagerService.getFocusDrawings();
915
+ if (alignType === AlignType.default)
906
916
  return;
907
- const r = [];
908
- let o = Number.POSITIVE_INFINITY, i = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, l = Number.NEGATIVE_INFINITY, m = 0;
909
- t.forEach((u) => {
910
- const { unitId: d, subUnitId: h, drawingId: f, drawingType: v } = u, w = this._drawingManagerService.getDrawingByParam({ unitId: d, subUnitId: h, drawingId: f });
911
- if (w == null || w.transform == null)
917
+ const drawingTransformCaches = [];
918
+ let minLeft = Number.POSITIVE_INFINITY, minTop = Number.POSITIVE_INFINITY, maxRight = Number.NEGATIVE_INFINITY, maxBottom = Number.NEGATIVE_INFINITY, drawingCount = 0;
919
+ drawings.forEach((drawing) => {
920
+ const { unitId, subUnitId, drawingId, drawingType } = drawing, drawingParam = this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId });
921
+ if (drawingParam == null || drawingParam.transform == null)
912
922
  return;
913
- r.push({
914
- unitId: d,
915
- subUnitId: h,
916
- drawingId: f,
917
- drawingType: v,
918
- transform: w.transform
923
+ drawingTransformCaches.push({
924
+ unitId,
925
+ subUnitId,
926
+ drawingId,
927
+ drawingType,
928
+ transform: drawingParam.transform
919
929
  });
920
- const { left: p = 0, top: S = 0, width: _ = 0, height: R = 0 } = w.transform;
921
- o = Math.min(o, p), i = Math.min(i, S), s = Math.max(s, p + _), l = Math.max(l, S + R), m++;
922
- }), m !== 0 && (this._sortDrawingTransform(r, e), this._applyAlignType(r, e, o, i, s, l, m));
930
+ const { left = 0, top = 0, width = 0, height = 0 } = drawingParam.transform;
931
+ minLeft = Math.min(minLeft, left), minTop = Math.min(minTop, top), maxRight = Math.max(maxRight, left + width), maxBottom = Math.max(maxBottom, top + height), drawingCount++;
932
+ }), drawingCount !== 0 && (this._sortDrawingTransform(drawingTransformCaches, alignType), this._applyAlignType(drawingTransformCaches, alignType, minLeft, minTop, maxRight, maxBottom, drawingCount));
923
933
  }
924
- _applyAlignType(n, e, t, r, o, i, s) {
925
- const l = Math.round((o - t) / s * 10) / 10, m = Math.round((i - r) / s * 10) / 10, u = [], d = this._getSceneAndTransformerByDrawingSearch(n[0].unitId);
926
- if (d == null)
934
+ _applyAlignType(drawingTransformCaches, alignType, minLeft, minTop, maxRight, maxBottom, drawingCount) {
935
+ const averageHorizon = Math.round((maxRight - minLeft) / drawingCount * 10) / 10, averageVertical = Math.round((maxBottom - minTop) / drawingCount * 10) / 10, updateParams = [], renderObject = this._getSceneAndTransformerByDrawingSearch(drawingTransformCaches[0].unitId);
936
+ if (renderObject == null)
927
937
  return;
928
- const { scene: h, transformer: f } = d;
929
- n.forEach((v, w) => {
930
- const { unitId: p, subUnitId: S, drawingId: _, transform: R, drawingType: b } = v, { left: N = 0, top: I = 0, width: y = 0, height: P = 0 } = R;
931
- let M = N, D = I;
932
- switch (e) {
933
- case E.left:
934
- M = t;
938
+ const { scene, transformer } = renderObject;
939
+ drawingTransformCaches.forEach((drawingTransformCache, index) => {
940
+ const { unitId, subUnitId, drawingId, transform, drawingType } = drawingTransformCache, { left = 0, top = 0, width = 0, height = 0 } = transform;
941
+ let newLeft = left, newTop = top;
942
+ switch (alignType) {
943
+ case AlignType.left:
944
+ newLeft = minLeft;
935
945
  break;
936
- case E.center:
937
- M = t + (o - t) / 2 - y / 2;
946
+ case AlignType.center:
947
+ newLeft = minLeft + (maxRight - minLeft) / 2 - width / 2;
938
948
  break;
939
- case E.right:
940
- M = o - y;
949
+ case AlignType.right:
950
+ newLeft = maxRight - width;
941
951
  break;
942
- case E.top:
943
- D = r;
952
+ case AlignType.top:
953
+ newTop = minTop;
944
954
  break;
945
- case E.middle:
946
- D = r + (i - r) / 2 - P / 2;
955
+ case AlignType.middle:
956
+ newTop = minTop + (maxBottom - minTop) / 2 - height / 2;
947
957
  break;
948
- case E.bottom:
949
- D = i - P;
958
+ case AlignType.bottom:
959
+ newTop = maxBottom - height;
950
960
  break;
951
- case E.horizon:
952
- M = t + l * w;
961
+ case AlignType.horizon:
962
+ newLeft = minLeft + averageHorizon * index;
953
963
  break;
954
- case E.vertical:
955
- D = r + m * w;
964
+ case AlignType.vertical:
965
+ newTop = minTop + averageVertical * index;
956
966
  break;
957
967
  }
958
- (M !== N || D !== I) && u.push({
959
- unitId: p,
960
- subUnitId: S,
961
- drawingId: _,
962
- drawingType: b,
968
+ (newLeft !== left || newTop !== top) && updateParams.push({
969
+ unitId,
970
+ subUnitId,
971
+ drawingId,
972
+ drawingType,
963
973
  transform: {
964
- left: M,
965
- top: D
974
+ left: newLeft,
975
+ top: newTop
966
976
  }
967
977
  });
968
- }), this._drawingManagerService.featurePluginUpdateNotification(u), f.refreshControls().changeNotification();
969
- }
970
- _sortDrawingTransform(n, e) {
971
- n.sort((t, r) => {
972
- const o = t.transform, i = r.transform, {
973
- left: s = 0,
974
- top: l = 0,
975
- width: m = 0,
976
- height: u = 0
977
- } = o, {
978
- left: d = 0,
979
- top: h = 0,
980
- width: f = 0,
981
- height: v = 0
982
- } = i;
983
- switch (e) {
984
- case E.left:
985
- return s - d;
986
- case E.center:
987
- return s + m / 2 - (d + f / 2);
988
- case E.right:
989
- return s + m - (d + f);
990
- case E.top:
991
- return l - h;
992
- case E.middle:
993
- return l + u / 2 - (h + v / 2);
994
- case E.bottom:
995
- return l + u - (h + v);
996
- case E.horizon:
997
- return s + m / 2 - (d + f / 2);
998
- case E.vertical:
999
- return l + u / 2 - (h + v / 2);
978
+ }), this._drawingManagerService.featurePluginUpdateNotification(updateParams), transformer.refreshControls().changeNotification();
979
+ }
980
+ _sortDrawingTransform(drawingTransformCaches, alignType) {
981
+ drawingTransformCaches.sort((a, b) => {
982
+ const aTransform = a.transform, bTransform = b.transform, {
983
+ left: aLeft = 0,
984
+ top: aTop = 0,
985
+ width: aWidth = 0,
986
+ height: aHeight = 0
987
+ } = aTransform, {
988
+ left: bLeft = 0,
989
+ top: bTop = 0,
990
+ width: bWidth = 0,
991
+ height: bHeight = 0
992
+ } = bTransform;
993
+ switch (alignType) {
994
+ case AlignType.left:
995
+ return aLeft - bLeft;
996
+ case AlignType.center:
997
+ return aLeft + aWidth / 2 - (bLeft + bWidth / 2);
998
+ case AlignType.right:
999
+ return aLeft + aWidth - (bLeft + bWidth);
1000
+ case AlignType.top:
1001
+ return aTop - bTop;
1002
+ case AlignType.middle:
1003
+ return aTop + aHeight / 2 - (bTop + bHeight / 2);
1004
+ case AlignType.bottom:
1005
+ return aTop + aHeight - (bTop + bHeight);
1006
+ case AlignType.horizon:
1007
+ return aLeft + aWidth / 2 - (bLeft + bWidth / 2);
1008
+ case AlignType.vertical:
1009
+ return aTop + aHeight / 2 - (bTop + bHeight / 2);
1000
1010
  default:
1001
1011
  return 0;
1002
1012
  }
@@ -1004,60 +1014,60 @@ let De = class extends Ae {
1004
1014
  }
1005
1015
  _drawingArrangeListener() {
1006
1016
  this.disposeWithMe(
1007
- this._drawingManagerService.order$.subscribe((n) => {
1008
- this._drawingArrange(n);
1017
+ this._drawingManagerService.order$.subscribe((params) => {
1018
+ this._drawingArrange(params);
1009
1019
  })
1010
1020
  );
1011
1021
  }
1012
- _drawingArrange(n) {
1013
- const { unitId: e, subUnitId: t, drawingIds: r } = n, o = this._getSceneAndTransformerByDrawingSearch(e);
1014
- if (o == null)
1022
+ _drawingArrange(params) {
1023
+ const { unitId, subUnitId, drawingIds } = params, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1024
+ if (renderObject == null)
1015
1025
  return;
1016
- const { scene: i } = o;
1017
- r.forEach((s) => {
1018
- const l = G({ unitId: e, subUnitId: t, drawingId: s }), m = i.fuzzyMathObjects(l, !0);
1019
- if (m == null || m.length === 0)
1026
+ const { scene } = renderObject;
1027
+ drawingIds.forEach((drawingId) => {
1028
+ const oKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShapes = scene.fuzzyMathObjects(oKey, !0);
1029
+ if (drawingShapes == null || drawingShapes.length === 0)
1020
1030
  return;
1021
- const u = this._drawingManagerService.getDrawingOrder(e, t).indexOf(s);
1022
- for (const d of m)
1023
- d.setProps({ zIndex: u }), d.makeDirty();
1031
+ const index = this._drawingManagerService.getDrawingOrder(unitId, subUnitId).indexOf(drawingId);
1032
+ for (const shape of drawingShapes)
1033
+ shape.setProps({ zIndex: index }), shape.makeDirty();
1024
1034
  });
1025
1035
  }
1026
1036
  _drawingAddListener() {
1027
1037
  this.disposeWithMe(
1028
- this._drawingManagerService.add$.subscribe((n) => {
1029
- this._insertDrawing(n);
1038
+ this._drawingManagerService.add$.subscribe((params) => {
1039
+ this._insertDrawing(params);
1030
1040
  })
1031
1041
  );
1032
1042
  }
1033
- _insertDrawing(n) {
1034
- const e = [];
1035
- n.forEach((t) => {
1036
- const { unitId: r, subUnitId: o, drawingId: i } = t;
1037
- if (this._drawingManagerService.getDrawingByParam(t) == null)
1043
+ _insertDrawing(params) {
1044
+ const sceneList = [];
1045
+ params.forEach((param) => {
1046
+ const { unitId, subUnitId, drawingId } = param;
1047
+ if (this._drawingManagerService.getDrawingByParam(param) == null)
1038
1048
  return;
1039
- const l = this._getSceneAndTransformerByDrawingSearch(r);
1040
- if (l == null)
1049
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1050
+ if (renderObject == null)
1041
1051
  return;
1042
- const { scene: m, transformer: u } = l;
1043
- e.includes(m) || e.push(m);
1044
- }), e.forEach((t) => {
1045
- this._sceneListenerOnDrawingMap.has(t) || (this._addListenerOnDrawing(t), this._sceneListenerOnDrawingMap.add(t));
1052
+ const { scene, transformer } = renderObject;
1053
+ sceneList.includes(scene) || sceneList.push(scene);
1054
+ }), sceneList.forEach((scene) => {
1055
+ this._sceneListenerOnDrawingMap.has(scene) || (this._addListenerOnDrawing(scene), this._sceneListenerOnDrawingMap.add(scene));
1046
1056
  });
1047
1057
  }
1048
1058
  _drawingRemoveListener() {
1049
1059
  this.disposeWithMe(
1050
- this._drawingManagerService.remove$.subscribe((n) => {
1051
- n.forEach((e) => {
1052
- var u;
1053
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._getSceneAndTransformerByDrawingSearch(t);
1054
- if (i == null)
1060
+ this._drawingManagerService.remove$.subscribe((params) => {
1061
+ params.forEach((param) => {
1062
+ var _a7;
1063
+ const { unitId, subUnitId, drawingId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1064
+ if (renderObject == null)
1055
1065
  return;
1056
- const { scene: s } = i, l = G({ unitId: t, subUnitId: r, drawingId: o }), m = s.fuzzyMathObjects(l, !0);
1057
- if (m.length > 0) {
1058
- for (const d of m)
1059
- d.dispose();
1060
- (u = s.getTransformer()) == null || u.clearSelectedObjects();
1066
+ const { scene } = renderObject, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShapes = scene.fuzzyMathObjects(drawingShapeKey, !0);
1067
+ if (drawingShapes.length > 0) {
1068
+ for (const drawingShape of drawingShapes)
1069
+ drawingShape.dispose();
1070
+ (_a7 = scene.getTransformer()) == null || _a7.clearSelectedObjects();
1061
1071
  }
1062
1072
  });
1063
1073
  })
@@ -1065,75 +1075,75 @@ let De = class extends Ae {
1065
1075
  }
1066
1076
  _drawingUpdateListener() {
1067
1077
  this.disposeWithMe(
1068
- this._drawingManagerService.update$.subscribe((n) => {
1069
- n.forEach((e) => {
1070
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._drawingManagerService.getDrawingByParam(e);
1071
- if (i == null)
1078
+ this._drawingManagerService.update$.subscribe((params) => {
1079
+ params.forEach((param) => {
1080
+ const { unitId, subUnitId, drawingId } = param, drawingParam = this._drawingManagerService.getDrawingByParam(param);
1081
+ if (drawingParam == null)
1072
1082
  return;
1073
- const { transform: s, drawingType: l } = i, m = this._getSceneAndTransformerByDrawingSearch(t);
1074
- if (m == null)
1083
+ const { transform, drawingType } = drawingParam, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1084
+ if (renderObject == null)
1075
1085
  return;
1076
- const { scene: u, transformer: d } = m;
1077
- if (s == null)
1086
+ const { scene, transformer } = renderObject;
1087
+ if (transform == null)
1078
1088
  return !0;
1079
- const { left: h = 0, top: f = 0, width: v = 0, height: w = 0, angle: p = 0, flipX: S = !1, flipY: _ = !1, skewX: R = 0, skewY: b = 0 } = s, N = G({ unitId: t, subUnitId: r, drawingId: o }), I = u.getObject(N);
1080
- if (I == null)
1089
+ const { left = 0, top = 0, width = 0, height = 0, angle = 0, flipX = !1, flipY = !1, skewX = 0, skewY = 0 } = transform, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShape = scene.getObject(drawingShapeKey);
1090
+ if (drawingShape == null)
1081
1091
  return !0;
1082
- I.transformByState({ left: h, top: f, width: v, height: w, angle: p, flipX: S, flipY: _, skewX: R, skewY: b });
1092
+ drawingShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
1083
1093
  });
1084
1094
  })
1085
1095
  );
1086
1096
  }
1087
1097
  _drawingRefreshListener() {
1088
1098
  this.disposeWithMe(
1089
- this._drawingManagerService.refreshTransform$.subscribe((n) => {
1090
- n.forEach((e) => {
1091
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._getSceneAndTransformerByDrawingSearch(t);
1092
- if (i == null)
1099
+ this._drawingManagerService.refreshTransform$.subscribe((params) => {
1100
+ params.forEach((param) => {
1101
+ const { unitId, subUnitId, drawingId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1102
+ if (renderObject == null)
1093
1103
  return;
1094
- const s = this._drawingManagerService.getDrawingByParam(e);
1095
- if (s == null)
1104
+ const drawingParam = this._drawingManagerService.getDrawingByParam(param);
1105
+ if (drawingParam == null)
1096
1106
  return;
1097
- const { transform: l } = s, { scene: m } = i, u = G({ unitId: t, subUnitId: r, drawingId: o }), d = m.getObject(u);
1098
- if (d == null || l == null)
1107
+ const { transform } = drawingParam, { scene } = renderObject, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShape = scene.getObject(drawingShapeKey);
1108
+ if (drawingShape == null || transform == null)
1099
1109
  return !0;
1100
1110
  const {
1101
- left: h = 0,
1102
- top: f = 0,
1103
- width: v = 0,
1104
- height: w = 0,
1105
- angle: p = 0,
1106
- flipX: S = !1,
1107
- flipY: _ = !1,
1108
- skewX: R = 0,
1109
- skewY: b = 0
1110
- } = l;
1111
- d.transformByState({ left: h, top: f, width: v, height: w, angle: p, flipX: S, flipY: _, skewX: R, skewY: b });
1111
+ left = 0,
1112
+ top = 0,
1113
+ width = 0,
1114
+ height = 0,
1115
+ angle = 0,
1116
+ flipX = !1,
1117
+ flipY = !1,
1118
+ skewX = 0,
1119
+ skewY = 0
1120
+ } = transform;
1121
+ drawingShape.transformByState({ left, top, width, height, angle, flipX, flipY, skewX, skewY });
1112
1122
  });
1113
1123
  })
1114
1124
  );
1115
1125
  }
1116
1126
  _drawingVisibleListener() {
1117
1127
  this.disposeWithMe(
1118
- this._drawingManagerService.visible$.subscribe((n) => {
1119
- n.forEach((e) => {
1120
- const { unitId: t, subUnitId: r, drawingId: o, visible: i } = e, s = this._getSceneAndTransformerByDrawingSearch(t);
1121
- if (s == null)
1128
+ this._drawingManagerService.visible$.subscribe((params) => {
1129
+ params.forEach((param) => {
1130
+ const { unitId, subUnitId, drawingId, visible } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1131
+ if (renderObject == null)
1122
1132
  return;
1123
- const { scene: l } = s, m = G({ unitId: t, subUnitId: r, drawingId: o }), u = l.getObject(m);
1124
- if (u == null)
1133
+ const { scene } = renderObject, drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), drawingShape = scene.getObject(drawingShapeKey);
1134
+ if (drawingShape == null)
1125
1135
  return !0;
1126
- i ? u.show() : u.hide();
1136
+ visible ? drawingShape.show() : drawingShape.hide();
1127
1137
  });
1128
1138
  })
1129
1139
  );
1130
1140
  }
1131
- _filterUpdateParams(n, e) {
1132
- return n.filter((t, r) => {
1133
- if (t == null)
1141
+ _filterUpdateParams(params, startTransforms) {
1142
+ return params.filter((param, index) => {
1143
+ if (param == null)
1134
1144
  return !1;
1135
- const { transform: o } = t;
1136
- return st(o, e == null ? void 0 : e[r]);
1145
+ const { transform } = param;
1146
+ return checkIfMove(transform, startTransforms == null ? void 0 : startTransforms[index]);
1137
1147
  });
1138
1148
  }
1139
1149
  // group?.getObjects().forEach((o) => {
@@ -1143,459 +1153,462 @@ let De = class extends Ae {
1143
1153
  // drawings.push({ unitId, subUnitId, drawingId });
1144
1154
  // }
1145
1155
  // });
1146
- _addListenerOnDrawing(n) {
1147
- const e = n.getTransformerByCreate();
1148
- let t = null;
1156
+ _addListenerOnDrawing(scene) {
1157
+ const transformer = scene.getTransformerByCreate();
1158
+ let startTransforms = null;
1149
1159
  this.disposeWithMe(
1150
- _e(
1151
- e.changeStart$.subscribe((r) => {
1152
- const { objects: o } = r, i = Array.from(o.values()), s = [];
1153
- t = i.map((l) => {
1154
- const { left: m, top: u, height: d, width: h, angle: f, oKey: v, isInGroup: w } = l, p = this._drawingManagerService.getDrawingOKey(v);
1155
- if (w || l instanceof ve) {
1156
- let S = l.ancestorGroup;
1157
- if (S == null && l instanceof ve && (S = l), S == null)
1160
+ toDisposable(
1161
+ transformer.changeStart$.subscribe((state) => {
1162
+ const { objects } = state, objectArray = Array.from(objects.values()), drawings = [];
1163
+ startTransforms = objectArray.map((object) => {
1164
+ const { left, top, height, width, angle, oKey, isInGroup } = object, drawing = this._drawingManagerService.getDrawingOKey(oKey);
1165
+ if (isInGroup || object instanceof Group) {
1166
+ let group = object.ancestorGroup;
1167
+ if (group == null && object instanceof Group && (group = object), group == null)
1158
1168
  return null;
1159
- const _ = this._drawingManagerService.getDrawingOKey(S.oKey);
1160
- if (_) {
1161
- const { unitId: R, subUnitId: b, drawingId: N } = _;
1162
- s.push({ unitId: R, subUnitId: b, drawingId: N });
1163
- const { left: I, top: y, height: P, width: M, angle: D } = S;
1164
- return { left: I, top: y, height: P, width: M, angle: D };
1169
+ const groupDrawing = this._drawingManagerService.getDrawingOKey(group.oKey);
1170
+ if (groupDrawing) {
1171
+ const { unitId, subUnitId, drawingId } = groupDrawing;
1172
+ drawings.push({ unitId, subUnitId, drawingId });
1173
+ const { left: left2, top: top2, height: height2, width: width2, angle: angle2 } = group;
1174
+ return { left: left2, top: top2, height: height2, width: width2, angle: angle2 };
1165
1175
  }
1166
- } else if (p != null) {
1167
- const { unitId: S, subUnitId: _, drawingId: R } = p;
1168
- return s.push({ unitId: S, subUnitId: _, drawingId: R }), { left: m, top: u, height: d, width: h, angle: f };
1176
+ } else if (drawing != null) {
1177
+ const { unitId, subUnitId, drawingId } = drawing;
1178
+ return drawings.push({ unitId, subUnitId, drawingId }), { left, top, height, width, angle };
1169
1179
  }
1170
1180
  return null;
1171
- }).filter((l) => l != null), s.length > 0 ? this._drawingManagerService.focusDrawing(s) : this._drawingManagerService.focusDrawing(null);
1181
+ }).filter((transform) => transform != null), drawings.length > 0 ? this._drawingManagerService.focusDrawing(drawings) : this._drawingManagerService.focusDrawing(null);
1172
1182
  })
1173
1183
  )
1174
1184
  ), this.disposeWithMe(
1175
- _e(
1176
- e.changeEnd$.subscribe((r) => {
1177
- const { objects: o } = r;
1178
- this._filterUpdateParams(Ge(o, this._drawingManagerService), t).length > 0;
1185
+ toDisposable(
1186
+ transformer.changeEnd$.subscribe((state) => {
1187
+ const { objects } = state, params = this._filterUpdateParams(getUpdateParams(objects, this._drawingManagerService), startTransforms);
1188
+ params.length > 0 && this._drawingManagerService.featurePluginUpdateNotification(params);
1179
1189
  })
1180
1190
  )
1181
1191
  );
1182
1192
  }
1183
- };
1184
- De = Gn([
1185
- xe(Ve.Rendered, De),
1186
- Me(0, Xe),
1187
- Me(1, ue),
1188
- Me(2, he),
1189
- Me(3, ae)
1190
- ], De);
1191
- const Wn = (a) => {
1192
- const { src: n } = a;
1193
- return n ? /* @__PURE__ */ c.createElement("div", null, /* @__PURE__ */ c.createElement("img", { src: n, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } })) : null;
1194
- }, St = "COMPONENT_IMAGE_VIEWER", bt = {
1193
+ }, __name(_a2, "DrawingUpdateController"), _a2);
1194
+ DrawingUpdateController = __decorateClass$4([
1195
+ OnLifecycle(LifecycleStages.Rendered, DrawingUpdateController),
1196
+ __decorateParam$4(0, IUniverInstanceService),
1197
+ __decorateParam$4(1, ICommandService),
1198
+ __decorateParam$4(2, IRenderManagerService),
1199
+ __decorateParam$4(3, IDrawingManagerService)
1200
+ ], DrawingUpdateController);
1201
+ const ImageViewer = /* @__PURE__ */ __name((props) => {
1202
+ const { src } = props;
1203
+ return src ? /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("img", { src, alt: "Univer Image Viewer", style: { width: "100%", height: "100%", position: "relative" } })) : null;
1204
+ }, "ImageViewer"), COMPONENT_IMAGE_VIEWER = "COMPONENT_IMAGE_VIEWER", ImageResetSizeOperation = {
1195
1205
  id: "sheet.operation.image-reset-size",
1196
- type: Se.OPERATION,
1197
- handler: (a, n) => !0
1206
+ type: CommandType.OPERATION,
1207
+ handler: /* @__PURE__ */ __name((accessor, params) => !0, "handler")
1198
1208
  };
1199
- var $n = Object.defineProperty, kn = Object.getOwnPropertyDescriptor, zn = (a, n, e, t) => {
1200
- for (var r = t > 1 ? void 0 : t ? kn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1201
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1202
- return t && r && $n(n, e, r), r;
1203
- }, we = (a, n) => (e, t) => n(e, t, a);
1204
- let Te = class extends Ae {
1205
- constructor(a, n, e, t, r) {
1206
- super(), this._injector = a, this._componentManager = n, this._menuService = e, this._commandService = t, this._localeService = r, this._init();
1209
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1210
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1211
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1212
+ return kind && result && __defProp$3(target, key, result), result;
1213
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3"), _a3;
1214
+ let DrawingUIController = (_a3 = class extends Disposable {
1215
+ constructor(_injector, _componentManager, _menuService, _commandService, _localeService) {
1216
+ super(), this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._commandService = _commandService, this._localeService = _localeService, this._init();
1207
1217
  }
1208
1218
  _initCustomComponents() {
1209
- const a = this._componentManager;
1210
- this.disposeWithMe(a.register(An, Ln)), this.disposeWithMe(a.register(St, Wn));
1219
+ const componentManager = this._componentManager;
1220
+ this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_POPUP_MENU, ImagePopupMenu)), this.disposeWithMe(componentManager.register(COMPONENT_IMAGE_VIEWER, ImageViewer));
1211
1221
  }
1212
1222
  _initMenus() {
1213
1223
  }
1214
1224
  _initCommands() {
1215
1225
  [
1216
- Ze,
1217
- me,
1218
- bt,
1219
- Je,
1220
- Le
1221
- ].forEach((a) => this.disposeWithMe(this._commandService.registerCommand(a)));
1226
+ OpenImageCropOperation,
1227
+ CloseImageCropOperation,
1228
+ ImageResetSizeOperation,
1229
+ SetDrawingAlignOperation,
1230
+ AutoImageCropOperation
1231
+ ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command)));
1222
1232
  }
1223
1233
  _init() {
1224
1234
  this._initCommands(), this._initCustomComponents(), this._initMenus();
1225
1235
  }
1226
- };
1227
- Te = zn([
1228
- xe(Ve.Rendered, Te),
1229
- we(0, ge(ct)),
1230
- we(1, ge(Vt)),
1231
- we(2, Gt),
1232
- we(3, ue),
1233
- we(4, ge(Y))
1234
- ], Te);
1235
- class Oe extends Bt {
1236
- constructor(e, t) {
1237
- t == null && (t = {}), t.transformerConfig = {
1236
+ }, __name(_a3, "DrawingUIController"), _a3);
1237
+ DrawingUIController = __decorateClass$3([
1238
+ OnLifecycle(LifecycleStages.Rendered, DrawingUIController),
1239
+ __decorateParam$3(0, Inject(Injector)),
1240
+ __decorateParam$3(1, Inject(ComponentManager)),
1241
+ __decorateParam$3(2, IMenuService),
1242
+ __decorateParam$3(3, ICommandService),
1243
+ __decorateParam$3(4, Inject(LocaleService))
1244
+ ], DrawingUIController);
1245
+ const _ImageCropperObject = class _ImageCropperObject extends Shape {
1246
+ constructor(key, props) {
1247
+ props == null && (props = {}), props.transformerConfig = {
1238
1248
  keepRatio: !1,
1239
1249
  isCropper: !0,
1240
1250
  anchorFill: "rgb(0, 0, 0)",
1241
1251
  anchorStroke: "rgb(255, 255, 255)",
1242
1252
  anchorSize: 24
1243
1253
  };
1244
- super(e, t);
1245
- te(this, "_srcRect");
1246
- te(this, "_prstGeom");
1247
- te(this, "_applyTransform");
1248
- te(this, "_dragPadding", 8);
1249
- te(this, "_cacheCanvas");
1250
- t != null && t.srcRect && (this._srcRect = t.srcRect), t != null && t.prstGeom && (this._prstGeom = t.prstGeom), t != null && t.applyTransform && (this._applyTransform = t.applyTransform), t != null && t.dragPadding && (this._dragPadding = t.dragPadding), this._applyProps();
1254
+ super(key, props);
1255
+ __publicField(this, "_srcRect");
1256
+ __publicField(this, "_prstGeom");
1257
+ __publicField(this, "_applyTransform");
1258
+ __publicField(this, "_dragPadding", 8);
1259
+ __publicField(this, "_cacheCanvas");
1260
+ props != null && props.srcRect && (this._srcRect = props.srcRect), props != null && props.prstGeom && (this._prstGeom = props.prstGeom), props != null && props.applyTransform && (this._applyTransform = props.applyTransform), props != null && props.dragPadding && (this._dragPadding = props.dragPadding), this._applyProps();
1251
1261
  }
1252
- refreshSrcRect(e, t) {
1253
- this._srcRect = e, this._applyTransform = t, this._applyProps();
1262
+ refreshSrcRect(value, transform) {
1263
+ this._srcRect = value, this._applyTransform = transform, this._applyProps();
1254
1264
  }
1255
1265
  get srcRect() {
1256
1266
  return this._srcRect;
1257
1267
  }
1258
1268
  dispose() {
1259
- var e;
1260
- super.dispose(), (e = this._cacheCanvas) == null || e.dispose(), this._srcRect = null;
1261
- }
1262
- isHit(e) {
1263
- const t = this.getInverseCoord(e);
1264
- return t.x >= -this.strokeWidth / 2 && t.x <= this.width + this.strokeWidth / 2 && t.y >= -this.strokeWidth / 2 && t.y <= this.height + this.strokeWidth / 2 && !this._inSurround(t);
1265
- }
1266
- _inSurround(e) {
1267
- const t = this._dragPadding;
1268
- return e.x >= t - this.strokeWidth / 2 && e.x <= this.width + this.strokeWidth / 2 - t && e.y >= t - this.strokeWidth / 2 && e.y <= this.height + this.strokeWidth / 2 - t;
1269
- }
1270
- render(e, t) {
1271
- return this.visible ? (e.save(), this._draw(e), e.restore(), this.makeDirty(!1), this) : (this.makeDirty(!1), this);
1272
- }
1273
- _draw(e) {
1274
- var l, m;
1275
- const r = this.getScene().getEngine(), { width: o, height: i } = r;
1276
- this._initialCacheCanvas(), (l = this._cacheCanvas) == null || l.clear();
1277
- const s = (m = this._cacheCanvas) == null ? void 0 : m.getContext();
1278
- s != null && (s.save(), jt.drawWith(s, {
1269
+ var _a7;
1270
+ super.dispose(), (_a7 = this._cacheCanvas) == null || _a7.dispose(), this._srcRect = null;
1271
+ }
1272
+ isHit(coord) {
1273
+ const oCoord = this.getInverseCoord(coord);
1274
+ return oCoord.x >= -this.strokeWidth / 2 && oCoord.x <= this.width + this.strokeWidth / 2 && oCoord.y >= -this.strokeWidth / 2 && oCoord.y <= this.height + this.strokeWidth / 2 && !this._inSurround(oCoord);
1275
+ }
1276
+ _inSurround(oCoord) {
1277
+ const padding = this._dragPadding;
1278
+ return oCoord.x >= padding - this.strokeWidth / 2 && oCoord.x <= this.width + this.strokeWidth / 2 - padding && oCoord.y >= padding - this.strokeWidth / 2 && oCoord.y <= this.height + this.strokeWidth / 2 - padding;
1279
+ }
1280
+ render(mainCtx, bounds) {
1281
+ return this.visible ? (mainCtx.save(), this._draw(mainCtx), mainCtx.restore(), this.makeDirty(!1), this) : (this.makeDirty(!1), this);
1282
+ }
1283
+ _draw(ctx) {
1284
+ var _a7, _b;
1285
+ const engine = this.getScene().getEngine(), { width: engineWidth, height: engineHeight } = engine;
1286
+ this._initialCacheCanvas(), (_a7 = this._cacheCanvas) == null || _a7.clear();
1287
+ const cacheCtx = (_b = this._cacheCanvas) == null ? void 0 : _b.getContext();
1288
+ cacheCtx != null && (cacheCtx.save(), Rect.drawWith(cacheCtx, {
1279
1289
  left: 0,
1280
1290
  top: 0,
1281
- width: o,
1282
- height: i,
1291
+ width: engineWidth,
1292
+ height: engineHeight,
1283
1293
  fill: "rgba(0, 0, 0, 0.5)"
1284
- }), s.setTransform(e.getTransform()), this._clipForApplyObject(s), this._applyCache(e), s.restore());
1294
+ }), cacheCtx.setTransform(ctx.getTransform()), this._clipForApplyObject(cacheCtx), this._applyCache(ctx), cacheCtx.restore());
1285
1295
  }
1286
- _clipForApplyObject(e) {
1287
- let t = 0;
1288
- if (this._prstGeom != null && (t = 1), e.globalCompositeOperation = "destination-out", e.beginPath(), t === 0) {
1289
- const r = this.transform.getMatrix();
1290
- e.transform(r[0], r[1], r[2], r[3], r[4], r[5]), e.rect(0, 0, this.width, this.height), e.fill();
1296
+ _clipForApplyObject(cacheCtx) {
1297
+ let objectType = 0;
1298
+ if (this._prstGeom != null && (objectType = 1), cacheCtx.globalCompositeOperation = "destination-out", cacheCtx.beginPath(), objectType === 0) {
1299
+ const m = this.transform.getMatrix();
1300
+ cacheCtx.transform(m[0], m[1], m[2], m[3], m[4], m[5]), cacheCtx.rect(0, 0, this.width, this.height), cacheCtx.fill();
1291
1301
  }
1292
1302
  }
1293
1303
  _applyProps() {
1294
1304
  if (this._applyTransform == null)
1295
1305
  return;
1296
- let e = 0, t = 0, r = 0, o = 0;
1297
- const { left: i = 0, top: s = 0, width: l = 0, height: m = 0, angle: u } = this._applyTransform;
1306
+ let cropLeft = 0, cropTop = 0, cropRight = 0, cropBottom = 0;
1307
+ const { left: applyLeft = 0, top: applyTop = 0, width: applyWidth = 0, height: applyHeight = 0, angle } = this._applyTransform;
1298
1308
  if (this._srcRect != null) {
1299
- const { left: f = 0, top: v = 0, right: w = 0, bottom: p = 0 } = this._srcRect;
1300
- e = f, t = v, r = w, o = p;
1309
+ const { left: left2 = 0, top: top2 = 0, right = 0, bottom = 0 } = this._srcRect;
1310
+ cropLeft = left2, cropTop = top2, cropRight = right, cropBottom = bottom;
1301
1311
  }
1302
- const d = i + e, h = s + t;
1312
+ const left = applyLeft + cropLeft, top = applyTop + cropTop;
1303
1313
  this.transformByState({
1304
- left: d,
1305
- top: h,
1306
- width: i + l - r - d,
1307
- height: s + m - o - h,
1308
- angle: u
1314
+ left,
1315
+ top,
1316
+ width: applyLeft + applyWidth - cropRight - left,
1317
+ height: applyTop + applyHeight - cropBottom - top,
1318
+ angle
1309
1319
  });
1310
1320
  }
1311
- _applyCache(e) {
1312
- if (!e || this._cacheCanvas == null)
1321
+ _applyCache(ctx) {
1322
+ if (!ctx || this._cacheCanvas == null)
1313
1323
  return;
1314
- const t = this._cacheCanvas.getContext();
1315
- t.save(), e.save(), e.setTransform(1, 0, 0, 1, 0, 0), t.setTransform(1, 0, 0, 1, 0, 0), e.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), e.restore(), t.restore();
1324
+ const cacheCtx = this._cacheCanvas.getContext();
1325
+ cacheCtx.save(), ctx.save(), ctx.setTransform(1, 0, 0, 1, 0, 0), cacheCtx.setTransform(1, 0, 0, 1, 0, 0), ctx.drawImage(this._cacheCanvas.getCanvasEle(), 0, 0), ctx.restore(), cacheCtx.restore();
1316
1326
  }
1317
1327
  _initialCacheCanvas() {
1318
1328
  if (this._cacheCanvas != null)
1319
1329
  return;
1320
- this._cacheCanvas = new Ut();
1321
- const e = this.getScene().getEngine();
1322
- this._cacheCanvas.setSize(e.width, e.height), e.onTransformChange$.subscribeEvent(() => {
1323
- var t;
1324
- (t = this._cacheCanvas) == null || t.setSize(e.width, e.height), this.makeDirty(!0);
1330
+ this._cacheCanvas = new Canvas();
1331
+ const engine = this.getScene().getEngine();
1332
+ this._cacheCanvas.setSize(engine.width, engine.height), engine.onTransformChange$.subscribeEvent(() => {
1333
+ var _a7;
1334
+ (_a7 = this._cacheCanvas) == null || _a7.setSize(engine.width, engine.height), this.makeDirty(!0);
1325
1335
  });
1326
1336
  }
1327
- }
1328
- var Fn = Object.defineProperty, Kn = Object.getOwnPropertyDescriptor, Zn = (a, n, e, t) => {
1329
- for (var r = t > 1 ? void 0 : t ? Kn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1330
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1331
- return t && r && Fn(n, e, r), r;
1332
- }, de = (a, n) => (e, t) => n(e, t, a);
1333
- let Be = class extends Ae {
1334
- constructor(n, e, t, r, o, i) {
1337
+ };
1338
+ __name(_ImageCropperObject, "ImageCropperObject");
1339
+ let ImageCropperObject = _ImageCropperObject;
1340
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1341
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1342
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1343
+ return kind && result && __defProp$2(target, key, result), result;
1344
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), _a4;
1345
+ let ImageCropperController = (_a4 = class extends Disposable {
1346
+ constructor(_commandService, _drawingManagerService, _renderManagerService, _univerInstanceService, _messageService, _localeService) {
1335
1347
  super();
1336
- te(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1337
- this._commandService = n, this._drawingManagerService = e, this._renderManagerService = t, this._univerInstanceService = r, this._messageService = o, this._localeService = i, this._init();
1348
+ __publicField(this, "_sceneListenerOnImageMap", /* @__PURE__ */ new WeakSet());
1349
+ this._commandService = _commandService, this._drawingManagerService = _drawingManagerService, this._renderManagerService = _renderManagerService, this._univerInstanceService = _univerInstanceService, this._messageService = _messageService, this._localeService = _localeService, this._init();
1338
1350
  }
1339
1351
  _init() {
1340
1352
  this._initOpenCrop(), this._initCloseCrop(), this._initAutoCrop();
1341
1353
  }
1342
1354
  _initAutoCrop() {
1343
1355
  this.disposeWithMe(
1344
- this._commandService.onCommandExecuted((n) => {
1345
- if (n.id !== Le.id)
1356
+ this._commandService.onCommandExecuted((command) => {
1357
+ if (command.id !== AutoImageCropOperation.id)
1346
1358
  return;
1347
- const e = n.params;
1348
- if (e == null)
1359
+ const params = command.params;
1360
+ if (params == null)
1349
1361
  return;
1350
- const { cropType: t } = e, r = this._drawingManagerService.getFocusDrawings();
1351
- if (r.length !== 1)
1362
+ const { cropType } = params, drawingParams = this._drawingManagerService.getFocusDrawings();
1363
+ if (drawingParams.length !== 1)
1352
1364
  return;
1353
- const o = r[0], { unitId: i, subUnitId: s, drawingId: l } = o, m = this._renderManagerService.getRenderById(i), u = m == null ? void 0 : m.scene;
1354
- if (u == null)
1365
+ const drawingParam = drawingParams[0], { unitId, subUnitId, drawingId } = drawingParam, renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1366
+ if (scene == null)
1355
1367
  return !0;
1356
- this._searchCropObject(u) != null && this._commandService.syncExecuteCommand(me.id, { isAuto: !0 });
1357
- const h = G({ unitId: i, subUnitId: s, drawingId: l }), f = u.getObject(h);
1358
- if (!(f instanceof Fe)) {
1368
+ this._searchCropObject(scene) != null && this._commandService.syncExecuteCommand(CloseImageCropOperation.id, { isAuto: !0 });
1369
+ const imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(imageShapeKey);
1370
+ if (!(imageShape instanceof Image)) {
1359
1371
  this._messageService.show({
1360
- type: tt.Error,
1372
+ type: MessageType.Error,
1361
1373
  content: this._localeService.t("image-cropper.error")
1362
1374
  });
1363
1375
  return;
1364
1376
  }
1365
- f != null && (this._updateCropperObject(t, f), this._commandService.executeCommand(Ze.id, { unitId: i, subUnitId: s, drawingId: l }));
1377
+ imageShape != null && (this._updateCropperObject(cropType, imageShape), this._commandService.executeCommand(OpenImageCropOperation.id, { unitId, subUnitId, drawingId }));
1366
1378
  })
1367
1379
  );
1368
1380
  }
1369
- _calculateSrcRectByRatio(n, e, t, r, o, i) {
1370
- const s = t / r, l = o / i;
1371
- let m = t, u = r;
1372
- s > l ? m = r * l : u = t / l;
1373
- const d = (t - m) / 2, h = (r - u) / 2;
1381
+ _calculateSrcRectByRatio(left, top, width, height, numerator, denominator) {
1382
+ const srcRatio = width / height, ratio = numerator / denominator;
1383
+ let newWidth = width, newHeight = height;
1384
+ srcRatio > ratio ? newWidth = height * ratio : newHeight = width / ratio;
1385
+ const newLeft = (width - newWidth) / 2, newTop = (height - newHeight) / 2;
1374
1386
  return {
1375
- left: ye(d, 1),
1376
- top: ye(h, 1),
1377
- right: ye(t - (d + m), 1),
1378
- bottom: ye(r - (h + u), 1)
1387
+ left: precisionTo(newLeft, 1),
1388
+ top: precisionTo(newTop, 1),
1389
+ right: precisionTo(width - (newLeft + newWidth), 1),
1390
+ bottom: precisionTo(height - (newTop + newHeight), 1)
1379
1391
  };
1380
1392
  }
1381
- _updateCropperObject(n, e) {
1382
- const { left: t, top: r, width: o, height: i } = e.calculateTransformWithSrcRect();
1383
- let s;
1384
- switch (n) {
1385
- case B.R1_1:
1386
- s = this._calculateSrcRectByRatio(t, r, o, i, 1, 1);
1393
+ _updateCropperObject(cropType, imageShape) {
1394
+ const { left, top, width, height } = imageShape.calculateTransformWithSrcRect();
1395
+ let newSrcRect;
1396
+ switch (cropType) {
1397
+ case CropType.R1_1:
1398
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 1, 1);
1387
1399
  break;
1388
- case B.R16_9:
1389
- s = this._calculateSrcRectByRatio(t, r, o, i, 16, 9);
1400
+ case CropType.R16_9:
1401
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 16, 9);
1390
1402
  break;
1391
- case B.R9_16:
1392
- s = this._calculateSrcRectByRatio(t, r, o, i, 9, 16);
1403
+ case CropType.R9_16:
1404
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 9, 16);
1393
1405
  break;
1394
- case B.R5_4:
1395
- s = this._calculateSrcRectByRatio(t, r, o, i, 5, 4);
1406
+ case CropType.R5_4:
1407
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 5, 4);
1396
1408
  break;
1397
- case B.R4_5:
1398
- s = this._calculateSrcRectByRatio(t, r, o, i, 4, 5);
1409
+ case CropType.R4_5:
1410
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 4, 5);
1399
1411
  break;
1400
- case B.R4_3:
1401
- s = this._calculateSrcRectByRatio(t, r, o, i, 4, 3);
1412
+ case CropType.R4_3:
1413
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 4, 3);
1402
1414
  break;
1403
- case B.R3_4:
1404
- s = this._calculateSrcRectByRatio(t, r, o, i, 3, 4);
1415
+ case CropType.R3_4:
1416
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 3, 4);
1405
1417
  break;
1406
- case B.R3_2:
1407
- s = this._calculateSrcRectByRatio(t, r, o, i, 3, 2);
1418
+ case CropType.R3_2:
1419
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 3, 2);
1408
1420
  break;
1409
- case B.R2_3:
1410
- s = this._calculateSrcRectByRatio(t, r, o, i, 2, 3);
1421
+ case CropType.R2_3:
1422
+ newSrcRect = this._calculateSrcRectByRatio(left, top, width, height, 2, 3);
1411
1423
  break;
1412
- case B.FREE:
1424
+ case CropType.FREE:
1413
1425
  }
1414
- if (s == null)
1426
+ if (newSrcRect == null)
1415
1427
  return;
1416
- e.setSrcRect(s);
1417
- const { left: l = 0, top: m = 0, bottom: u = 0, right: d = 0 } = s;
1418
- e.transformByStateCloseCropper({
1419
- left: t + l,
1420
- top: r + m,
1421
- width: o - d - l,
1422
- height: i - u - m
1428
+ imageShape.setSrcRect(newSrcRect);
1429
+ const { left: newLeft = 0, top: newTop = 0, bottom: newBottom = 0, right: newRight = 0 } = newSrcRect;
1430
+ imageShape.transformByStateCloseCropper({
1431
+ left: left + newLeft,
1432
+ top: top + newTop,
1433
+ width: width - newRight - newLeft,
1434
+ height: height - newBottom - newTop
1423
1435
  });
1424
1436
  }
1425
1437
  _initOpenCrop() {
1426
1438
  this.disposeWithMe(
1427
- this._commandService.onCommandExecuted((n) => {
1428
- if (n.id !== Ze.id)
1439
+ this._commandService.onCommandExecuted((command) => {
1440
+ if (command.id !== OpenImageCropOperation.id)
1429
1441
  return;
1430
- const e = n.params;
1431
- if (e == null)
1442
+ const params = command.params;
1443
+ if (params == null)
1432
1444
  return;
1433
- const { unitId: t, subUnitId: r, drawingId: o } = e, i = this._renderManagerService.getRenderById(t), s = i == null ? void 0 : i.scene;
1434
- if (s == null)
1445
+ const { unitId, subUnitId, drawingId } = params, renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1446
+ if (scene == null)
1435
1447
  return !0;
1436
- if (this._sceneListenerOnImageMap.has(s) || (this._addListenerOnImage(s), this._sceneListenerOnImageMap.add(s)), this._drawingManagerService.getDrawingByParam({ unitId: t, subUnitId: r, drawingId: o }) == null)
1448
+ if (this._sceneListenerOnImageMap.has(scene) || (this._addListenerOnImage(scene), this._sceneListenerOnImageMap.add(scene)), this._drawingManagerService.getDrawingByParam({ unitId, subUnitId, drawingId }) == null)
1437
1449
  return;
1438
- const m = G({ unitId: t, subUnitId: r, drawingId: o }), u = s.getObject(m);
1439
- if (u == null)
1450
+ const imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(imageShapeKey);
1451
+ if (imageShape == null)
1440
1452
  return;
1441
- if (!(u instanceof Fe)) {
1453
+ if (!(imageShape instanceof Image)) {
1442
1454
  this._messageService.show({
1443
- type: tt.Error,
1455
+ type: MessageType.Error,
1444
1456
  content: this._localeService.t("image-cropper.error")
1445
1457
  });
1446
1458
  return;
1447
1459
  }
1448
- const d = s.getTransformer();
1449
- d == null || d.clearControls();
1450
- const h = new Oe(`${m}-crop`, {
1451
- srcRect: u.srcRect,
1452
- prstGeom: u.prstGeom,
1453
- applyTransform: u.calculateTransformWithSrcRect()
1460
+ const transformer = scene.getTransformer();
1461
+ transformer == null || transformer.clearControls();
1462
+ const imageCropperObject = new ImageCropperObject(`${imageShapeKey}-crop`, {
1463
+ srcRect: imageShape.srcRect,
1464
+ prstGeom: imageShape.prstGeom,
1465
+ applyTransform: imageShape.calculateTransformWithSrcRect()
1454
1466
  });
1455
- s.addObject(h, u.getLayerIndex() + 1).attachTransformerTo(h), d == null || d.createControlForCopper(h), this._addHoverForImageCopper(h), u.openRenderByCropper(), d == null || d.refreshControls(), h.makeDirty(!0), this._drawingManagerService.focusDrawing([{ unitId: t, subUnitId: r, drawingId: o }]);
1467
+ scene.addObject(imageCropperObject, imageShape.getLayerIndex() + 1).attachTransformerTo(imageCropperObject), transformer == null || transformer.createControlForCopper(imageCropperObject), this._addHoverForImageCopper(imageCropperObject), imageShape.openRenderByCropper(), transformer == null || transformer.refreshControls(), imageCropperObject.makeDirty(!0), this._drawingManagerService.focusDrawing([{ unitId, subUnitId, drawingId }]);
1456
1468
  })
1457
1469
  );
1458
1470
  }
1459
- _searchCropObject(n) {
1460
- const e = n.getAllObjects();
1461
- for (const t of e)
1462
- if (t instanceof Oe)
1463
- return t;
1471
+ _searchCropObject(scene) {
1472
+ const objects = scene.getAllObjects();
1473
+ for (const object of objects)
1474
+ if (object instanceof ImageCropperObject)
1475
+ return object;
1464
1476
  }
1465
1477
  _initCloseCrop() {
1466
1478
  this.disposeWithMe(
1467
- this._commandService.onCommandExecuted((e) => {
1468
- if (e.id !== me.id)
1479
+ this._commandService.onCommandExecuted((command) => {
1480
+ if (command.id !== CloseImageCropOperation.id)
1469
1481
  return;
1470
- const t = this._univerInstanceService.getFocusedUnit();
1471
- if (t == null)
1482
+ const currentUnit = this._univerInstanceService.getFocusedUnit();
1483
+ if (currentUnit == null)
1472
1484
  return;
1473
- const r = t.getUnitId(), o = this._renderManagerService.getRenderById(r), i = o == null ? void 0 : o.scene;
1474
- if (i == null)
1485
+ const unitId = currentUnit.getUnitId(), renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1486
+ if (scene == null)
1475
1487
  return !0;
1476
- const s = this._searchCropObject(i);
1477
- if (s == null)
1488
+ const imageCropperObject = this._searchCropObject(scene);
1489
+ if (imageCropperObject == null)
1478
1490
  return;
1479
- const l = this._getApplyObjectByCropObject(s);
1480
- if (l == null)
1491
+ const imageShape = this._getApplyObjectByCropObject(imageCropperObject);
1492
+ if (imageShape == null)
1481
1493
  return;
1482
- const m = i.getTransformerByCreate();
1483
- m.detachFrom(s), m.clearCopperControl();
1484
- const u = this._getSrcRectByTransformState(l, s), d = this._drawingManagerService.getDrawingOKey(l.oKey);
1485
- if (d != null) {
1486
- const { left: h, top: f, height: v, width: w } = s;
1494
+ const transformer = scene.getTransformerByCreate();
1495
+ transformer.detachFrom(imageCropperObject), transformer.clearCopperControl();
1496
+ const srcRect = this._getSrcRectByTransformState(imageShape, imageCropperObject), drawingParam = this._drawingManagerService.getDrawingOKey(imageShape.oKey);
1497
+ if (drawingParam != null) {
1498
+ const { left, top, height, width } = imageCropperObject;
1487
1499
  this._drawingManagerService.featurePluginUpdateNotification([{
1488
- ...d,
1500
+ ...drawingParam,
1489
1501
  transform: {
1490
- ...d.transform,
1491
- left: h,
1492
- top: f,
1493
- height: v,
1494
- width: w
1502
+ ...drawingParam.transform,
1503
+ left,
1504
+ top,
1505
+ height,
1506
+ width
1495
1507
  },
1496
- srcRect: u.srcRectAngle
1508
+ srcRect: srcRect.srcRectAngle
1497
1509
  }]);
1498
1510
  }
1499
- l.setSrcRect({ ...u.srcRectAngle }), l.closeRenderByCropper(), l.makeDirty(!0), s == null || s.dispose();
1511
+ imageShape.setSrcRect({ ...srcRect.srcRectAngle }), imageShape.closeRenderByCropper(), imageShape.makeDirty(!0), imageCropperObject == null || imageCropperObject.dispose();
1500
1512
  })
1501
1513
  );
1502
- const n = this._univerInstanceService.getCurrentTypeOfUnit$(Ne.UNIVER_SHEET).pipe(
1503
- kt((e) => !!e),
1504
- zt((e) => e.activeSheet$)
1514
+ const sheetUnit = this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
1515
+ filter((workbook) => !!workbook),
1516
+ switchMap((workbook) => workbook.activeSheet$)
1505
1517
  );
1506
- this.disposeWithMe(n.subscribe(() => {
1507
- this._commandService.syncExecuteCommand(me.id);
1518
+ this.disposeWithMe(sheetUnit.subscribe(() => {
1519
+ this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
1508
1520
  }));
1509
1521
  }
1510
- _getApplyObjectByCropObject(n) {
1511
- const e = n.oKey, t = e.slice(0, e.length - 5), r = n.getScene().getObject(t);
1512
- return r == null ? null : r;
1522
+ _getApplyObjectByCropObject(cropObject) {
1523
+ const cropOKey = cropObject.oKey, applyOKey = cropOKey.slice(0, cropOKey.length - 5), applyObject = cropObject.getScene().getObject(applyOKey);
1524
+ return applyObject == null ? null : applyObject;
1513
1525
  }
1514
- _addListenerOnImage(n) {
1515
- const e = n.getTransformerByCreate();
1516
- let t = null;
1526
+ _addListenerOnImage(scene) {
1527
+ const transformer = scene.getTransformerByCreate();
1528
+ let startTransform = null;
1517
1529
  this.disposeWithMe(
1518
- e.changeStart$.subscribe((r) => {
1519
- const { objects: o } = r, i = o.values().next().value;
1520
- if (i == null || !(i instanceof Oe))
1530
+ transformer.changeStart$.subscribe((state) => {
1531
+ const { objects } = state, cropObject = objects.values().next().value;
1532
+ if (cropObject == null || !(cropObject instanceof ImageCropperObject))
1521
1533
  return;
1522
- const { left: s, top: l, height: m, width: u, angle: d } = i;
1523
- t = { left: s, top: l, height: m, width: u, angle: d }, e.clearCopperControl();
1534
+ const { left, top, height, width, angle } = cropObject;
1535
+ startTransform = { left, top, height, width, angle }, transformer.clearCopperControl();
1524
1536
  })
1525
1537
  ), this.disposeWithMe(
1526
- e.changeEnd$.subscribe((r) => {
1527
- const { objects: o } = r, i = o.values().next().value;
1528
- if (i == null || !(i instanceof Oe))
1538
+ transformer.changeEnd$.subscribe((state) => {
1539
+ const { objects } = state, cropObject = objects.values().next().value;
1540
+ if (cropObject == null || !(cropObject instanceof ImageCropperObject))
1529
1541
  return;
1530
- const { left: s, top: l, height: m, width: u, angle: d } = i;
1531
- if (!st({ left: s, top: l, height: m, width: u, angle: d }, t))
1542
+ const { left, top, height, width, angle } = cropObject;
1543
+ if (!checkIfMove({ left, top, height, width, angle }, startTransform))
1532
1544
  return;
1533
- const h = this._getApplyObjectByCropObject(i);
1534
- if (h == null)
1545
+ const applyObject = this._getApplyObjectByCropObject(cropObject);
1546
+ if (applyObject == null)
1535
1547
  return;
1536
- const f = this._getSrcRectByTransformState(h, i);
1537
- i.refreshSrcRect(f.srcRect, h.getState()), e.createControlForCopper(i);
1548
+ const srcRect = this._getSrcRectByTransformState(applyObject, cropObject);
1549
+ cropObject.refreshSrcRect(srcRect.srcRect, applyObject.getState()), transformer.createControlForCopper(cropObject);
1538
1550
  })
1539
- ), this._endCropListener(n);
1551
+ ), this._endCropListener(scene);
1540
1552
  }
1541
- _addHoverForImageCopper(n) {
1553
+ _addHoverForImageCopper(o) {
1542
1554
  this.disposeWithMe(
1543
- n.onPointerEnter$.subscribeEvent(() => {
1544
- n.cursor = Ue.MOVE;
1555
+ o.onPointerEnter$.subscribeEvent(() => {
1556
+ o.cursor = CURSOR_TYPE.MOVE;
1545
1557
  })
1546
1558
  ), this.disposeWithMe(
1547
- n.onPointerLeave$.subscribeEvent(() => {
1548
- n.cursor = Ue.DEFAULT;
1559
+ o.onPointerLeave$.subscribeEvent(() => {
1560
+ o.cursor = CURSOR_TYPE.DEFAULT;
1549
1561
  })
1550
1562
  );
1551
1563
  }
1552
- _endCropListener(n) {
1553
- const e = n.getTransformerByCreate();
1564
+ _endCropListener(scene) {
1565
+ const transformer = scene.getTransformerByCreate();
1554
1566
  this.disposeWithMe(
1555
- e.clearControl$.subscribe((t) => {
1556
- t === !0 && this._commandService.syncExecuteCommand(me.id);
1567
+ transformer.clearControl$.subscribe((changeSelf) => {
1568
+ changeSelf === !0 && this._commandService.syncExecuteCommand(CloseImageCropOperation.id);
1557
1569
  })
1558
1570
  );
1559
1571
  }
1560
- _getSrcRectByTransformState(n, e) {
1561
- const { left: t, top: r, height: o, width: i, strokeWidth: s, angle: l } = e, { left: m, top: u, width: d, height: h, angle: f, strokeWidth: v } = n, w = t - m, p = r - u, S = {
1562
- left: w,
1563
- top: p,
1564
- right: d - w - i,
1565
- bottom: h - p - o
1566
- }, _ = { ...S };
1567
- if (f !== 0) {
1568
- const R = t + i / 2, b = r + o / 2, N = new ke(R, b), I = d / 2 + m, y = h / 2 + u, P = new ke(I, y), M = new ke(m, u);
1569
- M.rotateByPoint(et(f), P);
1570
- const D = M.clone();
1571
- D.rotateByPoint(et(-f), N);
1572
- const U = t - D.x, T = r - D.y;
1573
- _.left = U, _.top = T, _.right = d - U - i, _.bottom = h - T - o;
1572
+ _getSrcRectByTransformState(applyObject, imageCropperObject) {
1573
+ const { left, top, height, width, strokeWidth, angle: copperAngle } = imageCropperObject, { left: applyLeft, top: applyTop, width: applyWidth, height: applyHeight, angle: applyAngle, strokeWidth: applyStrokeWidth } = applyObject, newLeft = left - applyLeft, newTop = top - applyTop, srcRect = {
1574
+ left: newLeft,
1575
+ top: newTop,
1576
+ right: applyWidth - newLeft - width,
1577
+ bottom: applyHeight - newTop - height
1578
+ }, srcRectAngle = { ...srcRect };
1579
+ if (applyAngle !== 0) {
1580
+ const cx = left + width / 2, cy = top + height / 2, centerPoint = new Vector2(cx, cy), newCx = applyWidth / 2 + applyLeft, newCy = applyHeight / 2 + applyTop, newCenterPoint = new Vector2(newCx, newCy), vertexPoint = new Vector2(applyLeft, applyTop);
1581
+ vertexPoint.rotateByPoint(degToRad(applyAngle), newCenterPoint);
1582
+ const applyFinalPoint = vertexPoint.clone();
1583
+ applyFinalPoint.rotateByPoint(degToRad(-applyAngle), centerPoint);
1584
+ const newAngleLeft = left - applyFinalPoint.x, newAngleTop = top - applyFinalPoint.y;
1585
+ srcRectAngle.left = newAngleLeft, srcRectAngle.top = newAngleTop, srcRectAngle.right = applyWidth - newAngleLeft - width, srcRectAngle.bottom = applyHeight - newAngleTop - height;
1574
1586
  }
1575
1587
  return {
1576
- srcRect: S,
1577
- srcRectAngle: _
1588
+ srcRect,
1589
+ srcRectAngle
1578
1590
  };
1579
1591
  }
1580
- };
1581
- Be = Zn([
1582
- xe(Ve.Rendered, Be),
1583
- de(0, ue),
1584
- de(1, ae),
1585
- de(2, he),
1586
- de(3, Xe),
1587
- de(4, Wt),
1588
- de(5, ge(Y))
1589
- ], Be);
1590
- var Yn = Object.defineProperty, Xn = Object.getOwnPropertyDescriptor, Jn = (a, n, e, t) => {
1591
- for (var r = t > 1 ? void 0 : t ? Xn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1592
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1593
- return t && r && Yn(n, e, r), r;
1594
- }, ce = (a, n) => (e, t) => n(e, t, a);
1595
- const rt = 50;
1596
- let je = class extends Ae {
1597
- constructor(a, n, e, t, r, o, i) {
1598
- super(), this._commandService = a, this._renderManagerService = n, this._drawingManagerService = e, this._dialogService = t, this._imageIoService = r, this._currentUniverService = o, this._drawingRenderService = i, this._initialize();
1592
+ }, __name(_a4, "ImageCropperController"), _a4);
1593
+ ImageCropperController = __decorateClass$2([
1594
+ OnLifecycle(LifecycleStages.Rendered, ImageCropperController),
1595
+ __decorateParam$2(0, ICommandService),
1596
+ __decorateParam$2(1, IDrawingManagerService),
1597
+ __decorateParam$2(2, IRenderManagerService),
1598
+ __decorateParam$2(3, IUniverInstanceService),
1599
+ __decorateParam$2(4, IMessageService),
1600
+ __decorateParam$2(5, Inject(LocaleService))
1601
+ ], ImageCropperController);
1602
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1603
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1604
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1605
+ return kind && result && __defProp$1(target, key, result), result;
1606
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1");
1607
+ const IMAGE_VIEWER_DROPDOWN_PADDING = 50;
1608
+ var _a5;
1609
+ let ImageUpdateController = (_a5 = class extends Disposable {
1610
+ constructor(_commandService, _renderManagerService, _drawingManagerService, _dialogService, _imageIoService, _currentUniverService, _drawingRenderService) {
1611
+ super(), this._commandService = _commandService, this._renderManagerService = _renderManagerService, this._drawingManagerService = _drawingManagerService, this._dialogService = _dialogService, this._imageIoService = _imageIoService, this._currentUniverService = _currentUniverService, this._drawingRenderService = _drawingRenderService, this._initialize();
1599
1612
  }
1600
1613
  dispose() {
1601
1614
  super.dispose();
@@ -1604,225 +1617,225 @@ let je = class extends Ae {
1604
1617
  this._recoveryImages(), this._drawingAddListener(), this._commandExecutedListener(), this._imageUpdateListener();
1605
1618
  }
1606
1619
  _recoveryImages() {
1607
- const a = this._drawingManagerService.drawingManagerData, n = Ke(this._currentUniverService);
1608
- if (n == null)
1620
+ const drawingList = this._drawingManagerService.drawingManagerData, info = getCurrentUnitInfo(this._currentUniverService);
1621
+ if (info == null)
1609
1622
  return;
1610
- const { unitId: e, subUnitId: t } = n;
1611
- Object.keys(a).forEach((r) => {
1612
- Object.keys(a[r]).forEach((o) => {
1613
- const i = a[r][o].data;
1614
- i == null || r !== e || o !== t || Object.keys(i).forEach((s) => {
1615
- i[s] && this._insertImages([{ unitId: r, subUnitId: o, drawingId: s }]);
1623
+ const { unitId: currentUnitId, subUnitId: currentSubUnitId, current } = info;
1624
+ current.type !== UniverInstanceType.UNIVER_DOC && Object.keys(drawingList).forEach((unitId) => {
1625
+ Object.keys(drawingList[unitId]).forEach((subUnitId) => {
1626
+ const drawingMap = drawingList[unitId][subUnitId].data;
1627
+ drawingMap == null || unitId !== currentUnitId || subUnitId !== currentSubUnitId || Object.keys(drawingMap).forEach((drawingId) => {
1628
+ drawingMap[drawingId] && this._insertImages([{ unitId, subUnitId, drawingId }]);
1616
1629
  });
1617
1630
  });
1618
1631
  });
1619
1632
  }
1620
1633
  _commandExecutedListener() {
1621
1634
  this.disposeWithMe(
1622
- this._commandService.onCommandExecuted((a) => {
1623
- if (a.id === bt.id) {
1624
- const n = a.params;
1625
- if (n == null)
1635
+ this._commandService.onCommandExecuted((command) => {
1636
+ if (command.id === ImageResetSizeOperation.id) {
1637
+ const params = command.params;
1638
+ if (params == null)
1626
1639
  return;
1627
- this._resetImageSize(n);
1640
+ this._resetImageSize(params);
1628
1641
  }
1629
1642
  })
1630
1643
  );
1631
1644
  }
1632
- _getSceneAndTransformerByDrawingSearch(a) {
1633
- if (a == null)
1645
+ _getSceneAndTransformerByDrawingSearch(unitId) {
1646
+ if (unitId == null)
1634
1647
  return;
1635
- const n = this._renderManagerService.getRenderById(a), e = n == null ? void 0 : n.scene;
1636
- if (e == null)
1648
+ const renderObject = this._renderManagerService.getRenderById(unitId), scene = renderObject == null ? void 0 : renderObject.scene;
1649
+ if (scene == null)
1637
1650
  return null;
1638
- const t = e.getTransformerByCreate();
1639
- return { scene: e, transformer: t };
1640
- }
1641
- _resetImageSize(a) {
1642
- const n = [], e = [];
1643
- a.forEach((t) => {
1644
- const { unitId: r, subUnitId: o, drawingId: i } = t, s = this._getSceneAndTransformerByDrawingSearch(r);
1645
- if (s == null)
1651
+ const transformer = scene.getTransformerByCreate();
1652
+ return { scene, transformer };
1653
+ }
1654
+ _resetImageSize(params) {
1655
+ const updateParams = [], sceneList = [];
1656
+ params.forEach((param) => {
1657
+ const { unitId, subUnitId, drawingId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1658
+ if (renderObject == null)
1646
1659
  return;
1647
- const { scene: l } = s, m = G({ unitId: r, subUnitId: o, drawingId: i }), u = l.getObject(m);
1648
- if (u == null)
1660
+ const { scene } = renderObject, imageShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(imageShapeKey);
1661
+ if (imageShape == null)
1649
1662
  return !0;
1650
- const d = this._drawingManagerService.getDrawingByParam(t);
1651
- if (d == null)
1663
+ const imageData = this._drawingManagerService.getDrawingByParam(param);
1664
+ if (imageData == null)
1652
1665
  return !0;
1653
- if (d.drawingType !== re.DRAWING_IMAGE)
1666
+ if (imageData.drawingType !== DrawingTypeEnum.DRAWING_IMAGE)
1654
1667
  return;
1655
- u.resetSize();
1656
- const { width: h, height: f } = u.getNativeSize();
1657
- e.includes(l) === !1 && e.push(l), n.push({
1658
- ...d,
1668
+ imageShape.resetSize();
1669
+ const { width, height } = imageShape.getNativeSize();
1670
+ sceneList.includes(scene) === !1 && sceneList.push(scene), updateParams.push({
1671
+ ...imageData,
1659
1672
  transform: {
1660
- ...d.transform,
1661
- height: f,
1662
- width: h,
1673
+ ...imageData.transform,
1674
+ height,
1675
+ width,
1663
1676
  angle: 0
1664
1677
  },
1665
1678
  srcRect: null,
1666
1679
  prstGeom: null
1667
1680
  });
1668
- }), this._drawingManagerService.featurePluginUpdateNotification(n), e.forEach((t) => {
1669
- t.getTransformerByCreate().refreshControls().changeNotification();
1670
- }), this._drawingManagerService.focusDrawing(a);
1681
+ }), this._drawingManagerService.featurePluginUpdateNotification(updateParams), sceneList.forEach((scene) => {
1682
+ scene.getTransformerByCreate().refreshControls().changeNotification();
1683
+ }), this._drawingManagerService.focusDrawing(params);
1671
1684
  }
1672
1685
  _drawingAddListener() {
1673
1686
  this.disposeWithMe(
1674
- this._drawingManagerService.add$.subscribe((a) => {
1675
- this._insertImages(a);
1687
+ this._drawingManagerService.add$.subscribe((params) => {
1688
+ this._insertImages(params);
1676
1689
  })
1677
1690
  );
1678
1691
  }
1679
- _insertImages(a) {
1680
- a.forEach(async (n) => {
1681
- var l;
1682
- const { unitId: e, subUnitId: t } = n, r = this._getSceneAndTransformerByDrawingSearch(e), o = (l = Ke(this._currentUniverService)) == null ? void 0 : l.subUnitId;
1683
- if (r == null || o !== t)
1692
+ _insertImages(params) {
1693
+ params.forEach(async (param) => {
1694
+ var _a7;
1695
+ const { unitId, subUnitId, drawingId } = param, renderObject = this._getSceneAndTransformerByDrawingSearch(unitId), currentSubUnitId = (_a7 = getCurrentUnitInfo(this._currentUniverService)) == null ? void 0 : _a7.subUnitId;
1696
+ if (renderObject == null || currentSubUnitId !== subUnitId)
1684
1697
  return;
1685
- const i = this._drawingManagerService.getDrawingByParam(n);
1686
- if (i == null)
1698
+ const imageParam = this._drawingManagerService.getDrawingByParam(param);
1699
+ if (imageParam == null)
1687
1700
  return;
1688
- const s = await this._drawingRenderService.renderImages(i, r.scene);
1689
- if (!(s == null || s.length === 0))
1690
- for (const m of s)
1691
- this._addHoverForImage(m), this._addDialogForImage(m);
1701
+ const images = await this._drawingRenderService.renderImages(imageParam, renderObject.scene);
1702
+ if (!(images == null || images.length === 0))
1703
+ for (const image of images)
1704
+ this._addHoverForImage(image), this._addDialogForImage(image);
1692
1705
  });
1693
1706
  }
1694
1707
  _imageUpdateListener() {
1695
1708
  this.disposeWithMe(
1696
- this._drawingManagerService.update$.subscribe((a) => {
1697
- a.forEach((n) => {
1698
- const { unitId: e, subUnitId: t, drawingId: r } = n, o = this._drawingManagerService.getDrawingByParam(n);
1699
- if (o == null)
1709
+ this._drawingManagerService.update$.subscribe((params) => {
1710
+ params.forEach((param) => {
1711
+ const { unitId, subUnitId, drawingId } = param, drawingParam = this._drawingManagerService.getDrawingByParam(param);
1712
+ if (drawingParam == null)
1700
1713
  return;
1701
- const { transform: i, drawingType: s, srcRect: l, prstGeom: m, source: u, imageSourceType: d } = o;
1702
- if (s !== re.DRAWING_IMAGE)
1714
+ const { transform, drawingType, srcRect, prstGeom, source, imageSourceType } = drawingParam;
1715
+ if (drawingType !== DrawingTypeEnum.DRAWING_IMAGE)
1703
1716
  return;
1704
- const h = this._getSceneAndTransformerByDrawingSearch(e);
1705
- if (h == null)
1717
+ const renderObject = this._getSceneAndTransformerByDrawingSearch(unitId);
1718
+ if (renderObject == null)
1706
1719
  return;
1707
- const { scene: f, transformer: v } = h;
1708
- if (i == null)
1720
+ const { scene, transformer } = renderObject;
1721
+ if (transform == null)
1709
1722
  return !0;
1710
- const w = G({ unitId: e, subUnitId: t, drawingId: r }), p = f.getObject(w);
1711
- if (p == null)
1723
+ const drawingShapeKey = getDrawingShapeKeyByDrawingSearch({ unitId, subUnitId, drawingId }), imageShape = scene.getObject(drawingShapeKey);
1724
+ if (imageShape == null)
1712
1725
  return !0;
1713
- p.setSrcRect(l), p.setPrstGeom(m);
1726
+ imageShape.setSrcRect(srcRect), imageShape.setPrstGeom(prstGeom);
1714
1727
  });
1715
1728
  })
1716
1729
  );
1717
1730
  }
1718
- _addHoverForImage(a) {
1731
+ _addHoverForImage(o) {
1719
1732
  this.disposeWithMe(
1720
- _e(
1721
- a.onPointerEnter$.subscribeEvent(() => {
1722
- a.cursor = Ue.GRAB;
1733
+ toDisposable(
1734
+ o.onPointerEnter$.subscribeEvent(() => {
1735
+ o.cursor = CURSOR_TYPE.GRAB;
1723
1736
  })
1724
1737
  )
1725
1738
  ), this.disposeWithMe(
1726
- _e(
1727
- a.onPointerLeave$.subscribeEvent(() => {
1728
- a.cursor = Ue.DEFAULT;
1739
+ toDisposable(
1740
+ o.onPointerLeave$.subscribeEvent(() => {
1741
+ o.cursor = CURSOR_TYPE.DEFAULT;
1729
1742
  })
1730
1743
  )
1731
1744
  );
1732
1745
  }
1733
- _addDialogForImage(a) {
1746
+ _addDialogForImage(o) {
1734
1747
  this.disposeWithMe(
1735
- _e(
1736
- a.onDblclick$.subscribeEvent(() => {
1737
- var s;
1738
- const n = `${a.oKey}-viewer-dialog`, e = a.getNativeSize(), t = window.innerWidth - rt, r = window.innerHeight - rt, o = this._adjustImageSize(e.width, e.height, t, r), i = this._dialogService.open({
1739
- width: o.width,
1740
- id: n,
1748
+ toDisposable(
1749
+ o.onDblclick$.subscribeEvent(() => {
1750
+ var _a7;
1751
+ const dialogId = `${o.oKey}-viewer-dialog`, nativeSize = o.getNativeSize(), screenWidth = window.innerWidth - IMAGE_VIEWER_DROPDOWN_PADDING, screenHeight = window.innerHeight - IMAGE_VIEWER_DROPDOWN_PADDING, adjustSize = this._adjustImageSize(nativeSize.width, nativeSize.height, screenWidth, screenHeight), dialog = this._dialogService.open({
1752
+ width: adjustSize.width,
1753
+ id: dialogId,
1741
1754
  style: { margin: "0", top: "50%", left: "50%", transform: "translate(-50%, -50%)" },
1742
1755
  children: {
1743
1756
  label: {
1744
- name: St,
1757
+ name: COMPONENT_IMAGE_VIEWER,
1745
1758
  props: {
1746
- src: (s = a.getNative()) == null ? void 0 : s.src,
1747
- width: o.width,
1748
- height: o.height
1759
+ src: (_a7 = o.getNative()) == null ? void 0 : _a7.src,
1760
+ width: adjustSize.width,
1761
+ height: adjustSize.height
1749
1762
  }
1750
1763
  }
1751
1764
  },
1752
1765
  destroyOnClose: !0,
1753
1766
  draggable: !1,
1754
- onClose: () => {
1755
- this._dialogService.close(n), i.dispose();
1756
- }
1767
+ onClose: /* @__PURE__ */ __name(() => {
1768
+ this._dialogService.close(dialogId), dialog.dispose();
1769
+ }, "onClose")
1757
1770
  });
1758
1771
  })
1759
1772
  )
1760
1773
  );
1761
1774
  }
1762
- _adjustImageSize(a, n, e, t) {
1763
- if (a <= e && n <= t)
1775
+ _adjustImageSize(nativeWidth, nativeHeight, screenWidth, screenHeight) {
1776
+ if (nativeWidth <= screenWidth && nativeHeight <= screenHeight)
1764
1777
  return {
1765
- width: a,
1766
- height: n
1778
+ width: nativeWidth,
1779
+ height: nativeHeight
1767
1780
  };
1768
- const r = e / a, o = t / n, i = Math.min(r, o);
1781
+ const widthRatio = screenWidth / nativeWidth, heightRatio = screenHeight / nativeHeight, scale = Math.min(widthRatio, heightRatio);
1769
1782
  return {
1770
- width: Math.floor(a * i),
1771
- height: Math.floor(n * i)
1783
+ width: Math.floor(nativeWidth * scale),
1784
+ height: Math.floor(nativeHeight * scale)
1772
1785
  };
1773
1786
  }
1774
- };
1775
- je = Jn([
1776
- xe(Ve.Rendered, je),
1777
- ce(0, ue),
1778
- ce(1, he),
1779
- ce(2, ae),
1780
- ce(3, $t),
1781
- ce(4, ot),
1782
- ce(5, Xe),
1783
- ce(6, ge(He))
1784
- ], je);
1785
- var qn = Object.defineProperty, Qn = Object.getOwnPropertyDescriptor, er = (a, n, e, t) => {
1786
- for (var r = t > 1 ? void 0 : t ? Qn(n, e) : n, o = a.length - 1, i; o >= 0; o--)
1787
- (i = a[o]) && (r = (t ? i(n, e, r) : i(r)) || r);
1788
- return t && r && qn(n, e, r), r;
1789
- }, at = (a, n) => (e, t) => n(e, t, a);
1790
- const tr = "DRAWING_UI_PLUGIN";
1791
- var ze;
1792
- let it = (ze = class extends Lt {
1793
- constructor(a, n, e) {
1794
- super(), this._injector = n, this._localeService = e;
1795
- }
1796
- onStarting(a) {
1797
- this._initDependencies(a);
1798
- }
1799
- _initDependencies(a) {
1787
+ }, __name(_a5, "ImageUpdateController"), _a5);
1788
+ ImageUpdateController = __decorateClass$1([
1789
+ OnLifecycle(LifecycleStages.Rendered, ImageUpdateController),
1790
+ __decorateParam$1(0, ICommandService),
1791
+ __decorateParam$1(1, IRenderManagerService),
1792
+ __decorateParam$1(2, IDrawingManagerService),
1793
+ __decorateParam$1(3, IDialogService),
1794
+ __decorateParam$1(4, IImageIoService),
1795
+ __decorateParam$1(5, IUniverInstanceService),
1796
+ __decorateParam$1(6, Inject(DrawingRenderService))
1797
+ ], ImageUpdateController);
1798
+ var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
1799
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1800
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
1801
+ return kind && result && __defProp2(target, key, result), result;
1802
+ }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam");
1803
+ const PLUGIN_NAME = "DRAWING_UI_PLUGIN";
1804
+ var _a6;
1805
+ let UniverDrawingUIPlugin = (_a6 = class extends Plugin {
1806
+ constructor(config, _injector, _localeService) {
1807
+ super(), this._injector = _injector, this._localeService = _localeService;
1808
+ }
1809
+ onStarting() {
1810
+ this._initDependencies();
1811
+ }
1812
+ _initDependencies() {
1800
1813
  [
1801
1814
  // services
1802
- [He],
1815
+ [DrawingRenderService],
1803
1816
  // controllers
1804
- [De],
1805
- [Te],
1806
- [Be],
1807
- [je]
1808
- ].forEach((e) => a.add(e));
1809
- }
1810
- }, te(ze, "pluginName", tr), ze);
1811
- it = er([
1812
- at(1, ge(ct)),
1813
- at(2, ge(Y))
1814
- ], it);
1817
+ [DrawingUpdateController],
1818
+ [DrawingUIController],
1819
+ [ImageCropperController],
1820
+ [ImageUpdateController]
1821
+ ].forEach((dependency) => this._injector.add(dependency));
1822
+ }
1823
+ }, __name(_a6, "UniverDrawingUIPlugin"), __publicField(_a6, "pluginName", PLUGIN_NAME), _a6);
1824
+ UniverDrawingUIPlugin = __decorateClass([
1825
+ __decorateParam(1, Inject(Injector)),
1826
+ __decorateParam(2, Inject(LocaleService))
1827
+ ], UniverDrawingUIPlugin);
1815
1828
  export {
1816
- Le as AutoImageCropOperation,
1817
- An as COMPONENT_IMAGE_POPUP_MENU,
1818
- me as CloseImageCropOperation,
1819
- gr as DrawingCommonPanel,
1820
- He as DrawingRenderService,
1821
- Oe as ImageCropperObject,
1822
- Ln as ImagePopupMenu,
1823
- bt as ImageResetSizeOperation,
1824
- Ze as OpenImageCropOperation,
1825
- Je as SetDrawingAlignOperation,
1826
- it as UniverDrawingUIPlugin,
1827
- Ge as getUpdateParams
1829
+ AutoImageCropOperation,
1830
+ COMPONENT_IMAGE_POPUP_MENU,
1831
+ CloseImageCropOperation,
1832
+ DrawingCommonPanel,
1833
+ DrawingRenderService,
1834
+ ImageCropperObject,
1835
+ ImagePopupMenu,
1836
+ ImageResetSizeOperation,
1837
+ OpenImageCropOperation,
1838
+ SetDrawingAlignOperation,
1839
+ UniverDrawingUIPlugin,
1840
+ getUpdateParams
1828
1841
  };