@aivex/ui 1.2.0-dev.36 → 1.2.0-dev.37
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/dist/components/ShapeEditor/_renderers/types.d.ts +2 -1
- package/dist/components/ShapeEditor/_state/createInteractionController.d.ts +0 -1
- package/dist/components/ShapeEditor/_state/useEditorHotkeys.d.ts +2 -2
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +9 -0
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +940 -935
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -6,9 +6,9 @@ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
|
|
|
6
6
|
import { memo as C, useCallback as w, useEffect as T, useId as E, useImperativeHandle as D, useLayoutEffect as O, useMemo as k, useReducer as A, useRef as j, useState as M } from "react";
|
|
7
7
|
import N from "konva";
|
|
8
8
|
import "pixi.js/unsafe-eval";
|
|
9
|
-
import { Application as
|
|
9
|
+
import { Application as P, ColorMatrixFilter as ee, Container as F, Graphics as I, Polygon as te, Rectangle as ne, Sprite as re, Texture as ie } from "pixi.js";
|
|
10
10
|
//#region src/components/ShapeEditor/_model/geometry.ts
|
|
11
|
-
var
|
|
11
|
+
var L = {
|
|
12
12
|
POINT: "POINT",
|
|
13
13
|
RECTANGLE: "RECTANGLE",
|
|
14
14
|
ROTATED_RECTANGLE: "ROTATED_RECTANGLE",
|
|
@@ -16,22 +16,22 @@ var R = {
|
|
|
16
16
|
ELLIPSE: "ELLIPSE",
|
|
17
17
|
LINE: "LINE"
|
|
18
18
|
};
|
|
19
|
-
function
|
|
19
|
+
function R(e) {
|
|
20
20
|
return e.interaction?.visible !== !1;
|
|
21
21
|
}
|
|
22
|
-
function ie(e) {
|
|
23
|
-
return z(e) && e.interaction?.hitTestDisabled !== !0;
|
|
24
|
-
}
|
|
25
|
-
function B(e) {
|
|
26
|
-
return ie(e) && e.interaction?.selectable !== !1;
|
|
27
|
-
}
|
|
28
22
|
function ae(e) {
|
|
29
|
-
return
|
|
23
|
+
return R(e) && e.interaction?.hitTestDisabled !== !0;
|
|
24
|
+
}
|
|
25
|
+
function z(e) {
|
|
26
|
+
return ae(e) && e.interaction?.selectable !== !1;
|
|
30
27
|
}
|
|
31
28
|
function oe(e) {
|
|
32
|
-
return
|
|
29
|
+
return z(e) && !e.readOnly && e.interaction?.editable !== !1;
|
|
33
30
|
}
|
|
34
31
|
function se(e) {
|
|
32
|
+
return oe(e) && e.interaction?.draggable !== !1;
|
|
33
|
+
}
|
|
34
|
+
function ce(e) {
|
|
35
35
|
return e.map((e, t) => ({
|
|
36
36
|
shape: e,
|
|
37
37
|
index: t
|
|
@@ -40,13 +40,13 @@ function se(e) {
|
|
|
40
40
|
return n === r ? e.index - t.index : n - r;
|
|
41
41
|
}).map((e) => e.shape);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function B(e, t, n) {
|
|
44
44
|
return Math.max(t, Math.min(n, e));
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function le() {
|
|
47
47
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `id_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
48
48
|
}
|
|
49
|
-
var
|
|
49
|
+
var V = [
|
|
50
50
|
"tl",
|
|
51
51
|
"t",
|
|
52
52
|
"tr",
|
|
@@ -56,7 +56,7 @@ var H = [
|
|
|
56
56
|
"bl",
|
|
57
57
|
"l"
|
|
58
58
|
];
|
|
59
|
-
function
|
|
59
|
+
function H(e) {
|
|
60
60
|
let t = e.map((e) => e.x), n = e.map((e) => e.y);
|
|
61
61
|
return {
|
|
62
62
|
minX: Math.min(...t),
|
|
@@ -65,33 +65,33 @@ function U(e) {
|
|
|
65
65
|
maxY: Math.max(...n)
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function ue(e, t) {
|
|
69
69
|
let n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2;
|
|
70
70
|
return {
|
|
71
71
|
x: e.includes("l") ? t.minX : e.includes("r") ? t.maxX : n,
|
|
72
72
|
y: e.includes("t") ? t.minY : e.includes("b") ? t.maxY : r
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function de(e, t, n, r) {
|
|
76
76
|
let i = { ...t };
|
|
77
77
|
return e.includes("l") && (i.minX = n), e.includes("r") && (i.maxX = n), e.includes("t") && (i.minY = r), e.includes("b") && (i.maxY = r), i;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function fe(e, t) {
|
|
80
80
|
let n = t.x - e.x, r = t.y - e.y, i = Math.max(Math.abs(n), Math.abs(r));
|
|
81
81
|
return {
|
|
82
82
|
x: e.x + (n < 0 ? -i : i),
|
|
83
83
|
y: e.y + (r < 0 ? -i : i)
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function pe(e, t, n) {
|
|
87
87
|
let r = Math.cos(n), i = Math.sin(n), a = e.x - t.x, o = e.y - t.y;
|
|
88
88
|
return {
|
|
89
89
|
x: t.x + a * r - o * i,
|
|
90
90
|
y: t.y + a * i + o * r
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
let t =
|
|
93
|
+
function me(e) {
|
|
94
|
+
let t = H(e);
|
|
95
95
|
return [
|
|
96
96
|
{
|
|
97
97
|
x: t.minX,
|
|
@@ -111,7 +111,7 @@ function pe(e) {
|
|
|
111
111
|
}
|
|
112
112
|
];
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function he(e, t, n = 32) {
|
|
115
115
|
let r = (e.x + t.x) / 2, i = (e.y + t.y) / 2, a = Math.abs(t.x - e.x) / 2, o = Math.abs(t.y - e.y) / 2;
|
|
116
116
|
return Array.from({ length: n }, (e, t) => {
|
|
117
117
|
let s = t / n * 2 * Math.PI;
|
|
@@ -121,7 +121,7 @@ function me(e, t, n = 32) {
|
|
|
121
121
|
};
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function ge(e) {
|
|
125
125
|
let t = [...e].sort((e, t) => e.x - t.x || e.y - t.y);
|
|
126
126
|
if (t.length <= 2) return t;
|
|
127
127
|
let n = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), r = [];
|
|
@@ -137,10 +137,10 @@ function he(e) {
|
|
|
137
137
|
}
|
|
138
138
|
return r.pop(), i.pop(), r.concat(i);
|
|
139
139
|
}
|
|
140
|
-
function
|
|
141
|
-
let t =
|
|
142
|
-
if (t.length < 3) return
|
|
143
|
-
let n = Infinity, r =
|
|
140
|
+
function _e(e) {
|
|
141
|
+
let t = ge(e);
|
|
142
|
+
if (t.length < 3) return me(e);
|
|
143
|
+
let n = Infinity, r = me(e);
|
|
144
144
|
for (let e = 0; e < t.length; e++) {
|
|
145
145
|
let i = t[e], a = t[(e + 1) % t.length], o = Math.hypot(a.x - i.x, a.y - i.y) || 1, s = (a.x - i.x) / o, c = (a.y - i.y) / o, l = Infinity, u = -Infinity, d = Infinity, f = -Infinity;
|
|
146
146
|
for (let e of t) {
|
|
@@ -164,19 +164,19 @@ function ge(e) {
|
|
|
164
164
|
}
|
|
165
165
|
return r;
|
|
166
166
|
}
|
|
167
|
-
var
|
|
167
|
+
var ve = (e, t) => ({
|
|
168
168
|
x: e.x - t.x,
|
|
169
169
|
y: e.y - t.y
|
|
170
|
-
}),
|
|
171
|
-
let t =
|
|
170
|
+
}), ye = (e, t) => e.x * t.x + e.y * t.y, be = (e) => Math.hypot(e.x, e.y), xe = (e) => {
|
|
171
|
+
let t = be(e) || 1;
|
|
172
172
|
return {
|
|
173
173
|
x: e.x / t,
|
|
174
174
|
y: e.y / t
|
|
175
175
|
};
|
|
176
|
-
},
|
|
176
|
+
}, Se = (e, t) => ({
|
|
177
177
|
x: (e.x + t.x) / 2,
|
|
178
178
|
y: (e.y + t.y) / 2
|
|
179
|
-
}),
|
|
179
|
+
}), Ce = (e) => {
|
|
180
180
|
let t = e.reduce((e, t) => ({
|
|
181
181
|
x: e.x + t.x,
|
|
182
182
|
y: e.y + t.y
|
|
@@ -189,26 +189,26 @@ var _e = (e, t) => ({
|
|
|
189
189
|
y: t.y / e.length
|
|
190
190
|
};
|
|
191
191
|
};
|
|
192
|
-
function
|
|
192
|
+
function we(e) {
|
|
193
193
|
return [
|
|
194
194
|
e[0],
|
|
195
|
-
|
|
195
|
+
Se(e[0], e[1]),
|
|
196
196
|
e[1],
|
|
197
|
-
|
|
197
|
+
Se(e[1], e[2]),
|
|
198
198
|
e[2],
|
|
199
|
-
|
|
199
|
+
Se(e[2], e[3]),
|
|
200
200
|
e[3],
|
|
201
|
-
|
|
201
|
+
Se(e[3], e[0])
|
|
202
202
|
];
|
|
203
203
|
}
|
|
204
|
-
function
|
|
205
|
-
let n =
|
|
204
|
+
function Te(e, t) {
|
|
205
|
+
let n = Se(e[0], e[1]), r = xe(ve(e[0], e[3]));
|
|
206
206
|
return {
|
|
207
207
|
x: n.x + r.x * t,
|
|
208
208
|
y: n.y + r.y * t
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function U(e, t, n, r) {
|
|
212
212
|
let i = (e, i) => ({
|
|
213
213
|
x: t.x + e * n.x + i * r.x,
|
|
214
214
|
y: t.y + e * n.y + i * r.y
|
|
@@ -220,24 +220,24 @@ function W(e, t, n, r) {
|
|
|
220
220
|
i(e.minX, e.maxY)
|
|
221
221
|
];
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function Ee(e, t, n) {
|
|
224
224
|
if (e.length < 4) return e;
|
|
225
|
-
let r = e[0], i =
|
|
226
|
-
return
|
|
225
|
+
let r = e[0], i = xe(ve(e[1], e[0])), a = xe(ve(e[3], e[0])), o = ye(ve(e[1], r), i), s = ye(ve(e[3], r), a), c = ve(n, r);
|
|
226
|
+
return U(de(t, {
|
|
227
227
|
minX: 0,
|
|
228
228
|
minY: 0,
|
|
229
229
|
maxX: o,
|
|
230
230
|
maxY: s
|
|
231
|
-
},
|
|
231
|
+
}, ye(c, i), ye(c, a)), r, i, a);
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function De(e, t, n) {
|
|
234
234
|
let r = t.maxX - t.minX || 1, i = t.maxY - t.minY || 1, a = n.maxX - n.minX, o = n.maxY - n.minY;
|
|
235
235
|
return e.map((e) => ({
|
|
236
236
|
x: n.minX + (e.x - t.minX) / r * a,
|
|
237
237
|
y: n.minY + (e.y - t.minY) / i * o
|
|
238
238
|
}));
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function Oe(e) {
|
|
241
241
|
let t = e.length, n = Array.from({ length: t }, (n, r) => {
|
|
242
242
|
let i = e[r], a = e[(r + 1) % t];
|
|
243
243
|
return {
|
|
@@ -255,7 +255,7 @@ function De(e) {
|
|
|
255
255
|
if (i.minY > a.maxY || i.maxY < a.minY) continue;
|
|
256
256
|
let s = Math.min(a.i, i.i), c = Math.max(a.i, i.i);
|
|
257
257
|
if (c === s + 1 || s === 0 && c === t - 1) continue;
|
|
258
|
-
let l =
|
|
258
|
+
let l = ke(e[s], e[(s + 1) % t], e[c], e[(c + 1) % t]);
|
|
259
259
|
l && r.push({
|
|
260
260
|
i: s,
|
|
261
261
|
j: c,
|
|
@@ -266,7 +266,7 @@ function De(e) {
|
|
|
266
266
|
}
|
|
267
267
|
return r;
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function ke(e, t, n, r) {
|
|
270
270
|
let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
|
|
271
271
|
if (!c) return null;
|
|
272
272
|
let l = ((n.x - e.x) * s - (n.y - e.y) * o) / c, u = ((n.x - e.x) * a - (n.y - e.y) * i) / c, d = 1e-9;
|
|
@@ -275,13 +275,13 @@ function Oe(e, t, n, r) {
|
|
|
275
275
|
tj: u
|
|
276
276
|
};
|
|
277
277
|
}
|
|
278
|
-
var
|
|
279
|
-
function
|
|
280
|
-
let i =
|
|
281
|
-
return (i > 0 && a < 0 || i < 0 && a > 0) && (o > 0 && s < 0 || o < 0 && s > 0) ? !0 :
|
|
278
|
+
var W = (e, t) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY, Ae = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), je = (e, t, n) => Ae(e, t, n) === 0 && Math.min(e.x, t.x) <= n.x && n.x <= Math.max(e.x, t.x) && Math.min(e.y, t.y) <= n.y && n.y <= Math.max(e.y, t.y);
|
|
279
|
+
function Me(e, t, n, r) {
|
|
280
|
+
let i = Ae(n, r, e), a = Ae(n, r, t), o = Ae(e, t, n), s = Ae(e, t, r);
|
|
281
|
+
return (i > 0 && a < 0 || i < 0 && a > 0) && (o > 0 && s < 0 || o < 0 && s > 0) ? !0 : je(n, r, e) || je(n, r, t) || je(e, t, n) || je(e, t, r);
|
|
282
282
|
}
|
|
283
|
-
function
|
|
284
|
-
if (
|
|
283
|
+
function G(e, t, n) {
|
|
284
|
+
if (W(e, n) || W(t, n)) return !0;
|
|
285
285
|
let r = {
|
|
286
286
|
x: n.minX,
|
|
287
287
|
y: n.minY
|
|
@@ -295,7 +295,7 @@ function Me(e, t, n) {
|
|
|
295
295
|
x: n.minX,
|
|
296
296
|
y: n.maxY
|
|
297
297
|
};
|
|
298
|
-
return
|
|
298
|
+
return Me(e, t, r, i) || Me(e, t, i, a) || Me(e, t, a, o) || Me(e, t, o, r);
|
|
299
299
|
}
|
|
300
300
|
function Ne(e, t) {
|
|
301
301
|
let n = !1;
|
|
@@ -306,28 +306,28 @@ function Ne(e, t) {
|
|
|
306
306
|
return n;
|
|
307
307
|
}
|
|
308
308
|
function Pe(e, t, n) {
|
|
309
|
-
if (e.some((e) =>
|
|
309
|
+
if (e.some((e) => W(e, t))) return !0;
|
|
310
310
|
let r = n ? e.length : e.length - 1;
|
|
311
|
-
for (let n = 0; n < r; n += 1) if (
|
|
311
|
+
for (let n = 0; n < r; n += 1) if (G(e[n], e[(n + 1) % e.length], t)) return !0;
|
|
312
312
|
return !1;
|
|
313
313
|
}
|
|
314
314
|
function Fe(e, t) {
|
|
315
315
|
let n = e.points;
|
|
316
316
|
if (!n.length) return !1;
|
|
317
|
-
let r =
|
|
317
|
+
let r = H(n);
|
|
318
318
|
if (r.minX > t.maxX || r.maxX < t.minX || r.minY > t.maxY || r.maxY < t.minY) return !1;
|
|
319
319
|
switch (e.type) {
|
|
320
|
-
case
|
|
321
|
-
case
|
|
322
|
-
case
|
|
320
|
+
case L.POINT: return W(n[0], t);
|
|
321
|
+
case L.RECTANGLE: return !0;
|
|
322
|
+
case L.ELLIPSE: {
|
|
323
323
|
let e = (r.maxX - r.minX) / 2, n = (r.maxY - r.minY) / 2;
|
|
324
324
|
if (e <= 0 || n <= 0) return !0;
|
|
325
|
-
let i = (r.minX + r.maxX) / 2, a = (r.minY + r.maxY) / 2, o =
|
|
325
|
+
let i = (r.minX + r.maxX) / 2, a = (r.minY + r.maxY) / 2, o = B(i, t.minX, t.maxX), s = B(a, t.minY, t.maxY);
|
|
326
326
|
return ((o - i) / e) ** 2 + ((s - a) / n) ** 2 <= 1;
|
|
327
327
|
}
|
|
328
|
-
case
|
|
329
|
-
case
|
|
330
|
-
case
|
|
328
|
+
case L.LINE: return Pe(n, t, !1);
|
|
329
|
+
case L.POLYGON:
|
|
330
|
+
case L.ROTATED_RECTANGLE: return Pe(n, t, !0) || n.length >= 3 && Ne({
|
|
331
331
|
x: t.minX,
|
|
332
332
|
y: t.minY
|
|
333
333
|
}, n);
|
|
@@ -365,7 +365,7 @@ function ze(e, t = 4096) {
|
|
|
365
365
|
layers: 1
|
|
366
366
|
}], r = e.length;
|
|
367
367
|
if (r < 4 || r > t) return n;
|
|
368
|
-
let i =
|
|
368
|
+
let i = Oe(e);
|
|
369
369
|
if (!i.length) return n;
|
|
370
370
|
let a = Array.from({ length: r }, () => []);
|
|
371
371
|
for (let t of i) {
|
|
@@ -421,7 +421,7 @@ function ze(e, t = 4096) {
|
|
|
421
421
|
for (let t of x) {
|
|
422
422
|
let n = Re(v[t]);
|
|
423
423
|
if (!n) continue;
|
|
424
|
-
let r = v[t][0], i = v[t][1], a = 1e-9 * (Math.abs(r.x - i.x) + Math.abs(r.y - i.y) + 1), o = Math.abs(Le(
|
|
424
|
+
let r = v[t][0], i = v[t][1], a = 1e-9 * (Math.abs(r.x - i.x) + Math.abs(r.y - i.y) + 1), o = Math.abs(Le(Se(r, i), n, e, a));
|
|
425
425
|
o % 2 == 0 && C(v[t]) === 1 || w.push({
|
|
426
426
|
outline: v[t],
|
|
427
427
|
holes: [],
|
|
@@ -870,11 +870,11 @@ var J = C(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
870
870
|
strokeWidth: a.strokeWidth,
|
|
871
871
|
strokeDasharray: a.dash?.join(" "),
|
|
872
872
|
opacity: a.opacity,
|
|
873
|
-
fill: a.fillVisible && r !==
|
|
873
|
+
fill: a.fillVisible && r !== L.LINE ? a.color : "none",
|
|
874
874
|
fillOpacity: a.fillAlpha,
|
|
875
875
|
vectorEffect: "non-scaling-stroke"
|
|
876
876
|
};
|
|
877
|
-
if (r ===
|
|
877
|
+
if (r === L.POINT) return /* @__PURE__ */ x("circle", {
|
|
878
878
|
ref: o,
|
|
879
879
|
cx: i[0].x,
|
|
880
880
|
cy: i[0].y,
|
|
@@ -882,9 +882,9 @@ var J = C(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
882
882
|
fill: a.color,
|
|
883
883
|
opacity: a.opacity
|
|
884
884
|
});
|
|
885
|
-
if (r ===
|
|
886
|
-
let e =
|
|
887
|
-
return r ===
|
|
885
|
+
if (r === L.RECTANGLE || r === L.ELLIPSE) {
|
|
886
|
+
let e = H(i);
|
|
887
|
+
return r === L.ELLIPSE ? /* @__PURE__ */ x("ellipse", {
|
|
888
888
|
cx: (e.minX + e.maxX) / 2,
|
|
889
889
|
cy: (e.minY + e.maxY) / 2,
|
|
890
890
|
rx: (e.maxX - e.minX) / 2,
|
|
@@ -899,7 +899,7 @@ var J = C(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
899
899
|
});
|
|
900
900
|
}
|
|
901
901
|
let c = i.map((e) => `${e.x},${e.y}`).join(" ");
|
|
902
|
-
return r ===
|
|
902
|
+
return r === L.LINE ? /* @__PURE__ */ x("polyline", {
|
|
903
903
|
points: c,
|
|
904
904
|
...s
|
|
905
905
|
}) : /* @__PURE__ */ x("polygon", {
|
|
@@ -1129,14 +1129,14 @@ var X = {
|
|
|
1129
1129
|
"top-left": "aivex:top-2 aivex:left-2",
|
|
1130
1130
|
"top-right": "aivex:top-2 aivex:right-2"
|
|
1131
1131
|
}, ht = C(function({ image: e, imageUrl: n, imageVisible: r = !0, loading: i = !1, region: s, roiMaskId: u, shapes: f, view: p, viewDefaults: m, onChangeView: h, nav: g, registerShape: _, rectRef: y, zoomLabelRef: b, onZoom100: C, open: w, onToggleOpen: T, position: E = "bottom-left", showSettings: D = !0, settingsOpen: O, onToggleSettings: k, onCloseSettings: A, labels: j = K.minimap, settingsLabels: M, settingsItems: N }) {
|
|
1132
|
-
let { offX:
|
|
1132
|
+
let { offX: P, offY: ee, dispW: F, dispH: I, zoomCentered: te } = g, ne = E.startsWith("top"), re = {
|
|
1133
1133
|
position: "absolute",
|
|
1134
|
-
left:
|
|
1135
|
-
top:
|
|
1134
|
+
left: P,
|
|
1135
|
+
top: ee,
|
|
1136
1136
|
width: F,
|
|
1137
1137
|
height: I
|
|
1138
|
-
},
|
|
1139
|
-
className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${
|
|
1138
|
+
}, ie = /* @__PURE__ */ x("div", {
|
|
1139
|
+
className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${ne ? "aivex:mt-md" : "aivex:mb-md"} aivex:opacity-100` : "aivex:opacity-0"}`,
|
|
1140
1140
|
style: { maxHeight: w ? 204 : 0 },
|
|
1141
1141
|
children: /* @__PURE__ */ x("div", {
|
|
1142
1142
|
style: {
|
|
@@ -1163,7 +1163,7 @@ var X = {
|
|
|
1163
1163
|
alt: "",
|
|
1164
1164
|
crossOrigin: "anonymous",
|
|
1165
1165
|
draggable: !1,
|
|
1166
|
-
style:
|
|
1166
|
+
style: re
|
|
1167
1167
|
}),
|
|
1168
1168
|
p.showRegionMask && s && s.rects.length > 0 && /* @__PURE__ */ x(st, {
|
|
1169
1169
|
image: e,
|
|
@@ -1175,8 +1175,8 @@ var X = {
|
|
|
1175
1175
|
strokeDasharray: "4 4",
|
|
1176
1176
|
style: {
|
|
1177
1177
|
position: "absolute",
|
|
1178
|
-
left:
|
|
1179
|
-
top:
|
|
1178
|
+
left: P,
|
|
1179
|
+
top: ee,
|
|
1180
1180
|
pointerEvents: "none"
|
|
1181
1181
|
}
|
|
1182
1182
|
}),
|
|
@@ -1186,12 +1186,12 @@ var X = {
|
|
|
1186
1186
|
height: I,
|
|
1187
1187
|
style: {
|
|
1188
1188
|
position: "absolute",
|
|
1189
|
-
left:
|
|
1190
|
-
top:
|
|
1189
|
+
left: P,
|
|
1190
|
+
top: ee,
|
|
1191
1191
|
pointerEvents: "none"
|
|
1192
1192
|
},
|
|
1193
1193
|
"aria-hidden": !0,
|
|
1194
|
-
children:
|
|
1194
|
+
children: ce(f).filter(R).map((e) => /* @__PURE__ */ x(J, {
|
|
1195
1195
|
shape: e,
|
|
1196
1196
|
strokeSize: p.strokeSize,
|
|
1197
1197
|
register: _
|
|
@@ -1210,7 +1210,7 @@ var X = {
|
|
|
1210
1210
|
]
|
|
1211
1211
|
})
|
|
1212
1212
|
})
|
|
1213
|
-
}),
|
|
1213
|
+
}), L = /* @__PURE__ */ S("div", {
|
|
1214
1214
|
className: "aivex:relative aivex:flex aivex:items-center aivex:gap-xs",
|
|
1215
1215
|
children: [
|
|
1216
1216
|
/* @__PURE__ */ x(d, {
|
|
@@ -1259,7 +1259,7 @@ var X = {
|
|
|
1259
1259
|
onChange: h,
|
|
1260
1260
|
labels: M,
|
|
1261
1261
|
items: N,
|
|
1262
|
-
openDown:
|
|
1262
|
+
openDown: ne,
|
|
1263
1263
|
alignEnd: E.endsWith("right")
|
|
1264
1264
|
})]
|
|
1265
1265
|
}),
|
|
@@ -1271,14 +1271,14 @@ var X = {
|
|
|
1271
1271
|
onClick: T,
|
|
1272
1272
|
children: w ? /* @__PURE__ */ x(c, {
|
|
1273
1273
|
size: 20,
|
|
1274
|
-
className:
|
|
1274
|
+
className: ne ? "aivex:rotate-180" : void 0
|
|
1275
1275
|
}) : /* @__PURE__ */ x(l, { size: 20 })
|
|
1276
1276
|
})
|
|
1277
1277
|
]
|
|
1278
1278
|
});
|
|
1279
1279
|
return /* @__PURE__ */ S("div", {
|
|
1280
1280
|
className: `aivex:absolute ${X[E]} aivex:w-[220px] aivex:rounded-[12px] aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:p-md aivex:shadow-[0_4px_12px_rgba(13,13,18,0.24)]`,
|
|
1281
|
-
children: [
|
|
1281
|
+
children: [ne ? L : ie, ne ? ie : L]
|
|
1282
1282
|
});
|
|
1283
1283
|
}), gt = "var(--editor-overlay-inverse-scale, 1)", _t = 6, Z = {
|
|
1284
1284
|
fontFamily: "Pretendard, sans-serif",
|
|
@@ -1290,7 +1290,7 @@ var X = {
|
|
|
1290
1290
|
whiteSpace: "nowrap"
|
|
1291
1291
|
};
|
|
1292
1292
|
function vt(e) {
|
|
1293
|
-
let t =
|
|
1293
|
+
let t = H(e);
|
|
1294
1294
|
return {
|
|
1295
1295
|
x: t.minX,
|
|
1296
1296
|
y: t.minY,
|
|
@@ -1330,7 +1330,7 @@ function Ct({ color: e, striped: t }) {
|
|
|
1330
1330
|
}
|
|
1331
1331
|
function wt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
1332
1332
|
return /* @__PURE__ */ x(b, { children: e.map((e) => {
|
|
1333
|
-
let a = vt(e.points), o = e.type ===
|
|
1333
|
+
let a = vt(e.points), o = e.type === L.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = xt(e, e.points), d = r ? r(u) : St(u);
|
|
1334
1334
|
return /* @__PURE__ */ S("div", {
|
|
1335
1335
|
ref: (t) => i(e.id, t),
|
|
1336
1336
|
style: {
|
|
@@ -1375,7 +1375,7 @@ function wt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1375
1375
|
}
|
|
1376
1376
|
//#endregion
|
|
1377
1377
|
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1378
|
-
var Tt = "AIVEX_SHAPE_EDITOR:", Et = 1, Dt = new Set(Object.values(
|
|
1378
|
+
var Tt = "AIVEX_SHAPE_EDITOR:", Et = 1, Dt = new Set(Object.values(L)), Ot = null, kt = "unavailable", At = 0;
|
|
1379
1379
|
function jt(e) {
|
|
1380
1380
|
if (!e || typeof e != "object") return !1;
|
|
1381
1381
|
let t = e;
|
|
@@ -1695,7 +1695,7 @@ function fn(e) {
|
|
|
1695
1695
|
}
|
|
1696
1696
|
function pn(e, t) {
|
|
1697
1697
|
if (!t.length) return null;
|
|
1698
|
-
if (e ===
|
|
1698
|
+
if (e === L.POINT) {
|
|
1699
1699
|
let e = t[0];
|
|
1700
1700
|
return {
|
|
1701
1701
|
x: e.x - 8,
|
|
@@ -1704,7 +1704,7 @@ function pn(e, t) {
|
|
|
1704
1704
|
height: 16
|
|
1705
1705
|
};
|
|
1706
1706
|
}
|
|
1707
|
-
let n =
|
|
1707
|
+
let n = H(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
|
|
1708
1708
|
return {
|
|
1709
1709
|
x: n.minX,
|
|
1710
1710
|
y: n.minY,
|
|
@@ -1715,7 +1715,7 @@ function pn(e, t) {
|
|
|
1715
1715
|
function mn(e) {
|
|
1716
1716
|
if (!e.length) return null;
|
|
1717
1717
|
let t = e.map((e) => pn(e.type, e.points)).filter((e) => e !== null);
|
|
1718
|
-
return t.length ? fn(
|
|
1718
|
+
return t.length ? fn(H(t.flatMap((e) => [{
|
|
1719
1719
|
x: e.x,
|
|
1720
1720
|
y: e.y
|
|
1721
1721
|
}, {
|
|
@@ -1756,282 +1756,282 @@ function _n(e, t, n, r = 300) {
|
|
|
1756
1756
|
//#endregion
|
|
1757
1757
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1758
1758
|
function vn(e) {
|
|
1759
|
-
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i,
|
|
1759
|
+
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, docRef: a, selRef: o, draftRef: s, readOnlyRef: c, disableMarqueeRef: l, lockedRef: u, onLockedInteraction: d, onDrawAttemptWithoutDraft: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = !1, N = "", P = null, ee = null, F = (e) => e === q.RECTANGLE || e === q.ROTATED_RECTANGLE || e === q.CIRCLE, I = (e) => e === q.ASSISTANT_POLYGON || e === q.ASSISTANT_RECT, te = (e) => e === q.POLYGON, ne = (e) => F(e) || I(e) || te(e) || e === q.PATH || e === q.BRUSH || e === q.POINT, re = (e, t) => {
|
|
1760
1760
|
let n = !1;
|
|
1761
|
-
|
|
1762
|
-
},
|
|
1761
|
+
D && !F(t) && !I(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== q.PATH || O === "scalar" && t !== q.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== q.SELECT && (A = null, j = null, M = !1, e.clearMarquee(), n = !0), P && t !== q.POINT && (P = null, n = !0), n && b("idle");
|
|
1762
|
+
}, ie = () => r.current.get(n.current), R = (e, t, n, r) => ({
|
|
1763
1763
|
point: t,
|
|
1764
1764
|
targetId: r,
|
|
1765
1765
|
event: n,
|
|
1766
|
-
readOnly:
|
|
1766
|
+
readOnly: c.current,
|
|
1767
1767
|
viewport: e.viewport
|
|
1768
1768
|
});
|
|
1769
1769
|
return {
|
|
1770
|
-
onCursorHint:
|
|
1771
|
-
onInteractionModeChange:
|
|
1772
|
-
onPointerDown: (e, r,
|
|
1773
|
-
let
|
|
1774
|
-
if (!
|
|
1775
|
-
let
|
|
1776
|
-
if (P = null, re(
|
|
1777
|
-
|
|
1778
|
-
px:
|
|
1779
|
-
py:
|
|
1770
|
+
onCursorHint: y,
|
|
1771
|
+
onInteractionModeChange: b,
|
|
1772
|
+
onPointerDown: (e, r, l) => {
|
|
1773
|
+
let p = t.current;
|
|
1774
|
+
if (!p) return;
|
|
1775
|
+
let _ = n.current;
|
|
1776
|
+
if (P = null, re(p, _), l.button === 1 || i.current) {
|
|
1777
|
+
b("panning"), y(null), E = {
|
|
1778
|
+
px: l.global.x,
|
|
1779
|
+
py: l.global.y
|
|
1780
1780
|
};
|
|
1781
1781
|
return;
|
|
1782
1782
|
}
|
|
1783
|
-
if (
|
|
1784
|
-
if (r && !
|
|
1785
|
-
let e =
|
|
1786
|
-
e &&
|
|
1783
|
+
if (l.button === 2 && !(_ === q.ASSISTANT_POINT && l.altKey)) {
|
|
1784
|
+
if (r && !o.current.includes(r)) {
|
|
1785
|
+
let e = a.current.getShapes().find((e) => e.id === r);
|
|
1786
|
+
e && z(e) && m.current([r]);
|
|
1787
1787
|
}
|
|
1788
1788
|
return;
|
|
1789
1789
|
}
|
|
1790
|
-
let
|
|
1791
|
-
if (
|
|
1792
|
-
|
|
1790
|
+
let v = ie();
|
|
1791
|
+
if (v) {
|
|
1792
|
+
w().reset(), m.current([]), v.onPointerDown?.(R(p, e, l, r));
|
|
1793
1793
|
return;
|
|
1794
1794
|
}
|
|
1795
|
-
if (
|
|
1796
|
-
|
|
1795
|
+
if (u.current && _ !== q.SELECT) {
|
|
1796
|
+
d();
|
|
1797
1797
|
return;
|
|
1798
1798
|
}
|
|
1799
|
-
if (
|
|
1800
|
-
let t =
|
|
1801
|
-
if (t &&
|
|
1802
|
-
|
|
1799
|
+
if (F(_) && r && o.current.includes(r) && !c.current) {
|
|
1800
|
+
let t = a.current.getShapes().find((e) => e.id === r);
|
|
1801
|
+
if (t && se(t)) {
|
|
1802
|
+
p.beginMove(e, o.current);
|
|
1803
1803
|
return;
|
|
1804
1804
|
}
|
|
1805
1805
|
}
|
|
1806
|
-
if (ne(
|
|
1807
|
-
|
|
1806
|
+
if (ne(_) && !s.current) {
|
|
1807
|
+
f();
|
|
1808
1808
|
return;
|
|
1809
1809
|
}
|
|
1810
|
-
if (
|
|
1811
|
-
|
|
1810
|
+
if (_ === q.ASSISTANT_POINT) {
|
|
1811
|
+
l.altKey ? T().addPoint(e, l.button !== 2) : T().newPolygon(e);
|
|
1812
1812
|
return;
|
|
1813
1813
|
}
|
|
1814
|
-
if (
|
|
1815
|
-
|
|
1814
|
+
if (I(_) && s.current) {
|
|
1815
|
+
D = e, b("drawing");
|
|
1816
1816
|
return;
|
|
1817
1817
|
}
|
|
1818
|
-
if (
|
|
1819
|
-
|
|
1818
|
+
if (_ === q.SELECT && g.current) {
|
|
1819
|
+
j = l.shiftKey ? p.getVertexSelection() : [], M = r === g.current, A = e, N = "", b("marquee"), y(null);
|
|
1820
1820
|
return;
|
|
1821
1821
|
}
|
|
1822
|
-
if (
|
|
1823
|
-
let t =
|
|
1824
|
-
if (!
|
|
1825
|
-
let n =
|
|
1822
|
+
if (_ === q.SELECT && l.altKey) {
|
|
1823
|
+
let t = ce(a.current.getShapes()).filter((t) => {
|
|
1824
|
+
if (!z(t)) return !1;
|
|
1825
|
+
let n = H(t.points);
|
|
1826
1826
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
1827
1827
|
});
|
|
1828
1828
|
if (t.length) {
|
|
1829
|
-
let e = [...t].reverse(), n = [e[(e.findIndex((e) =>
|
|
1830
|
-
|
|
1829
|
+
let e = [...t].reverse(), n = [e[(e.findIndex((e) => o.current.includes(e.id)) + 1) % e.length].id];
|
|
1830
|
+
m.current(n);
|
|
1831
1831
|
return;
|
|
1832
1832
|
}
|
|
1833
1833
|
}
|
|
1834
|
-
if (r &&
|
|
1835
|
-
let t =
|
|
1836
|
-
if (!t || !
|
|
1837
|
-
let n = typeof performance < "u" ? performance.now() : 0, i = !!
|
|
1838
|
-
|
|
1834
|
+
if (r && _ === q.SELECT) {
|
|
1835
|
+
let t = a.current.getShapes().find((e) => e.id === r);
|
|
1836
|
+
if (!t || !z(t)) return;
|
|
1837
|
+
let n = typeof performance < "u" ? performance.now() : 0, i = !!ee && ee.id === r && n - ee.t < 300;
|
|
1838
|
+
ee = {
|
|
1839
1839
|
id: r,
|
|
1840
1840
|
t: n
|
|
1841
1841
|
};
|
|
1842
|
-
let
|
|
1843
|
-
if (i &&
|
|
1844
|
-
|
|
1842
|
+
let s = (t.type === L.POLYGON || t.type === L.LINE) && !c.current && t.interaction?.editable !== !1 && !t.readOnly;
|
|
1843
|
+
if (i && s) {
|
|
1844
|
+
m.current([r]), h.current(r);
|
|
1845
1845
|
return;
|
|
1846
1846
|
}
|
|
1847
|
-
let u =
|
|
1848
|
-
if (
|
|
1847
|
+
let u = o.current;
|
|
1848
|
+
if (l.shiftKey) {
|
|
1849
1849
|
let e = new Set(u);
|
|
1850
1850
|
e.has(r) ? e.delete(r) : e.add(r), u = [...e];
|
|
1851
1851
|
} else u.includes(r) || (u = [r]);
|
|
1852
|
-
|
|
1852
|
+
m.current(u), !c.current && se(t) && p.beginMove(e, u);
|
|
1853
1853
|
return;
|
|
1854
1854
|
}
|
|
1855
|
-
if (
|
|
1856
|
-
|
|
1855
|
+
if (F(_) && s.current) {
|
|
1856
|
+
D = e, b("drawing");
|
|
1857
1857
|
return;
|
|
1858
1858
|
}
|
|
1859
|
-
if (
|
|
1860
|
-
if (!
|
|
1861
|
-
let t =
|
|
1859
|
+
if (te(_) && s.current) {
|
|
1860
|
+
if (!w().getDraftPointsSnapshot().length && o.current.length && m.current([]), w().tryClosePolygon(e, 12 / p.viewport.scale)) return;
|
|
1861
|
+
let t = w().hitDraftPoint(e);
|
|
1862
1862
|
if (t >= 0) {
|
|
1863
|
-
if (
|
|
1864
|
-
|
|
1863
|
+
if (l.altKey) {
|
|
1864
|
+
w().removeDraftPoint(t);
|
|
1865
1865
|
return;
|
|
1866
1866
|
}
|
|
1867
|
-
let n =
|
|
1867
|
+
let n = w().selectDraftPointForDrag(t, l.shiftKey || l.ctrlKey || l.metaKey);
|
|
1868
1868
|
if (!n) return;
|
|
1869
|
-
|
|
1869
|
+
k = {
|
|
1870
1870
|
start: e,
|
|
1871
1871
|
base: n.base,
|
|
1872
1872
|
indices: n.indices,
|
|
1873
1873
|
moved: !1
|
|
1874
|
-
},
|
|
1874
|
+
}, b("vertexDragging");
|
|
1875
1875
|
return;
|
|
1876
1876
|
}
|
|
1877
|
-
|
|
1877
|
+
w().appendPolygonPoint(e);
|
|
1878
1878
|
return;
|
|
1879
1879
|
}
|
|
1880
|
-
if (
|
|
1881
|
-
|
|
1880
|
+
if (_ === q.PATH && s.current) {
|
|
1881
|
+
o.current.length && m.current([]), O = "path", b("drawing"), w().beginStroke(e);
|
|
1882
1882
|
return;
|
|
1883
1883
|
}
|
|
1884
|
-
if (
|
|
1885
|
-
|
|
1884
|
+
if (_ === q.BRUSH && s.current && !c.current) {
|
|
1885
|
+
O = "scalar", b("drawing"), w().beginStroke(e);
|
|
1886
1886
|
return;
|
|
1887
1887
|
}
|
|
1888
|
-
if (
|
|
1888
|
+
if (_ === q.POINT && s.current && l.button === 0) {
|
|
1889
1889
|
P = {
|
|
1890
|
-
pointerId:
|
|
1891
|
-
global:
|
|
1890
|
+
pointerId: l.pointerId,
|
|
1891
|
+
global: l.global,
|
|
1892
1892
|
cancelled: !1
|
|
1893
1893
|
};
|
|
1894
1894
|
return;
|
|
1895
1895
|
}
|
|
1896
|
-
if (
|
|
1897
|
-
if (
|
|
1898
|
-
let t =
|
|
1896
|
+
if (_ === q.SELECT) {
|
|
1897
|
+
if (j = null, M = !1, !l.shiftKey && !c.current && o.current.length >= 2) {
|
|
1898
|
+
let t = a.current.getShapes().filter((e) => o.current.includes(e.id) && se(e));
|
|
1899
1899
|
if (t.length) {
|
|
1900
|
-
let n =
|
|
1900
|
+
let n = H(t.flatMap((e) => e.points));
|
|
1901
1901
|
if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
|
|
1902
|
-
|
|
1902
|
+
p.beginMove(e, o.current);
|
|
1903
1903
|
return;
|
|
1904
1904
|
}
|
|
1905
1905
|
}
|
|
1906
1906
|
}
|
|
1907
|
-
|
|
1907
|
+
A = e, N = "", b("marquee"), y(null);
|
|
1908
1908
|
}
|
|
1909
1909
|
},
|
|
1910
1910
|
onPointerMove: (e, r) => {
|
|
1911
1911
|
let i = t.current;
|
|
1912
1912
|
if (!i) return;
|
|
1913
|
-
if (P && P.pointerId === r.pointerId && Math.hypot(r.global.x - P.global.x, r.global.y - P.global.y) > 4 && (P.cancelled = !0),
|
|
1913
|
+
if (P && P.pointerId === r.pointerId && Math.hypot(r.global.x - P.global.x, r.global.y - P.global.y) > 4 && (P.cancelled = !0), E) {
|
|
1914
1914
|
i.applyViewport({
|
|
1915
1915
|
scale: i.viewport.scale,
|
|
1916
|
-
x: i.viewport.x + (r.global.x -
|
|
1917
|
-
y: i.viewport.y + (r.global.y -
|
|
1918
|
-
}),
|
|
1916
|
+
x: i.viewport.x + (r.global.x - E.px),
|
|
1917
|
+
y: i.viewport.y + (r.global.y - E.py)
|
|
1918
|
+
}), E.px = r.global.x, E.py = r.global.y;
|
|
1919
1919
|
return;
|
|
1920
1920
|
}
|
|
1921
|
-
let
|
|
1922
|
-
re(i,
|
|
1923
|
-
let
|
|
1924
|
-
if (
|
|
1925
|
-
|
|
1921
|
+
let o = n.current;
|
|
1922
|
+
re(i, o);
|
|
1923
|
+
let c = ie();
|
|
1924
|
+
if (c) {
|
|
1925
|
+
c.onPointerMove?.(R(i, e, r));
|
|
1926
1926
|
return;
|
|
1927
1927
|
}
|
|
1928
|
-
if (
|
|
1929
|
-
let t = e.x -
|
|
1930
|
-
|
|
1928
|
+
if (k) {
|
|
1929
|
+
let t = e.x - k.start.x, n = e.y - k.start.y;
|
|
1930
|
+
k.moved = k.moved || Math.hypot(t, n) > .5, w().moveDraftPoints(k.base, k.indices, t, n);
|
|
1931
1931
|
return;
|
|
1932
1932
|
}
|
|
1933
|
-
if (
|
|
1934
|
-
let t =
|
|
1935
|
-
i.previewBox(
|
|
1936
|
-
...
|
|
1937
|
-
color:
|
|
1938
|
-
}),
|
|
1939
|
-
type:
|
|
1940
|
-
points: [
|
|
1933
|
+
if (D && (F(o) || I(o))) {
|
|
1934
|
+
let t = r.shiftKey ? fe(D, e) : e;
|
|
1935
|
+
i.previewBox(o === q.CIRCLE ? "ellipse" : "rect", D, t, {
|
|
1936
|
+
...s.current,
|
|
1937
|
+
color: s.current?.color ?? "#00e5ff"
|
|
1938
|
+
}), F(o) && C({
|
|
1939
|
+
type: o === q.CIRCLE ? L.ELLIPSE : L.RECTANGLE,
|
|
1940
|
+
points: [D, t]
|
|
1941
1941
|
});
|
|
1942
1942
|
return;
|
|
1943
1943
|
}
|
|
1944
|
-
if (
|
|
1945
|
-
|
|
1944
|
+
if (O) {
|
|
1945
|
+
w().appendStrokePoint(e, 2 / i.viewport.scale);
|
|
1946
1946
|
return;
|
|
1947
1947
|
}
|
|
1948
|
-
if (
|
|
1949
|
-
|
|
1948
|
+
if (te(o) && w().hasDraftPoints()) {
|
|
1949
|
+
w().setDraftCursor(e);
|
|
1950
1950
|
return;
|
|
1951
1951
|
}
|
|
1952
|
-
if (
|
|
1953
|
-
if (
|
|
1952
|
+
if (A) {
|
|
1953
|
+
if (l?.current) return;
|
|
1954
1954
|
let t = {
|
|
1955
|
-
minX: Math.min(
|
|
1956
|
-
minY: Math.min(
|
|
1957
|
-
maxX: Math.max(
|
|
1958
|
-
maxY: Math.max(
|
|
1955
|
+
minX: Math.min(A.x, e.x),
|
|
1956
|
+
minY: Math.min(A.y, e.y),
|
|
1957
|
+
maxX: Math.max(A.x, e.x),
|
|
1958
|
+
maxY: Math.max(A.y, e.y)
|
|
1959
1959
|
};
|
|
1960
|
-
if (i.previewMarquee(
|
|
1961
|
-
let e = (
|
|
1962
|
-
r !==
|
|
1960
|
+
if (i.previewMarquee(A, e), j) {
|
|
1961
|
+
let e = (a.current.getShapes().find((e) => e.id === g.current)?.points ?? []).flatMap((e, n) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY ? [n] : []), n = [...new Set([...j, ...e])].sort((e, t) => e - t), r = n.join(",");
|
|
1962
|
+
r !== N && (N = r, i.setVertexSelection(n));
|
|
1963
1963
|
return;
|
|
1964
1964
|
}
|
|
1965
1965
|
let n = i.shapesIntersecting(t), r = n.join(",");
|
|
1966
|
-
r !==
|
|
1966
|
+
r !== N && (N = r, m.current(n));
|
|
1967
1967
|
}
|
|
1968
1968
|
},
|
|
1969
1969
|
onPointerUp: (e, r) => {
|
|
1970
1970
|
let i = t.current;
|
|
1971
1971
|
if (!i) return;
|
|
1972
|
-
let
|
|
1973
|
-
if (P = null,
|
|
1974
|
-
|
|
1972
|
+
let a = P;
|
|
1973
|
+
if (P = null, E) {
|
|
1974
|
+
E = null, b("idle");
|
|
1975
1975
|
return;
|
|
1976
1976
|
}
|
|
1977
|
-
let
|
|
1978
|
-
if (re(i,
|
|
1979
|
-
|
|
1977
|
+
let c = n.current;
|
|
1978
|
+
if (re(i, c), k) {
|
|
1979
|
+
w().commitDraftPointDrag(k.moved), k = null, b("idle");
|
|
1980
1980
|
return;
|
|
1981
1981
|
}
|
|
1982
|
-
let
|
|
1983
|
-
if (
|
|
1984
|
-
|
|
1982
|
+
let l = ie();
|
|
1983
|
+
if (l) {
|
|
1984
|
+
l.onPointerUp?.(R(i, e, r));
|
|
1985
1985
|
return;
|
|
1986
1986
|
}
|
|
1987
|
-
let
|
|
1988
|
-
if (
|
|
1989
|
-
|
|
1987
|
+
let u = a ? Math.hypot(r.global.x - a.global.x, r.global.y - a.global.y) : Infinity;
|
|
1988
|
+
if (c === q.POINT && s.current && a && !a.cancelled && a.pointerId === r.pointerId && r.insideCanvas && u <= 4) {
|
|
1989
|
+
p.current(L.POINT, [e]);
|
|
1990
1990
|
return;
|
|
1991
1991
|
}
|
|
1992
|
-
if (
|
|
1993
|
-
let e =
|
|
1994
|
-
|
|
1992
|
+
if (O) {
|
|
1993
|
+
let e = O;
|
|
1994
|
+
O = null, b("idle"), e === "path" ? w().completeFreehandStroke() : w().finishScalarStroke();
|
|
1995
1995
|
return;
|
|
1996
1996
|
}
|
|
1997
|
-
if (
|
|
1998
|
-
let t =
|
|
1999
|
-
|
|
2000
|
-
let n = {
|
|
2001
|
-
x: Math.min(t.x,
|
|
2002
|
-
y: Math.min(t.y,
|
|
2003
|
-
width: Math.abs(
|
|
2004
|
-
height: Math.abs(
|
|
1997
|
+
if (D && I(c)) {
|
|
1998
|
+
let t = D;
|
|
1999
|
+
D = null, b("idle"), i.clearPreview();
|
|
2000
|
+
let n = r.shiftKey ? fe(t, e) : e, a = {
|
|
2001
|
+
x: Math.min(t.x, n.x),
|
|
2002
|
+
y: Math.min(t.y, n.y),
|
|
2003
|
+
width: Math.abs(n.x - t.x),
|
|
2004
|
+
height: Math.abs(n.y - t.y)
|
|
2005
2005
|
};
|
|
2006
|
-
|
|
2006
|
+
a.width > 2 && a.height > 2 && T().beginBox(a, c === q.ASSISTANT_RECT ? "rect" : "polygon");
|
|
2007
2007
|
return;
|
|
2008
2008
|
}
|
|
2009
|
-
if (
|
|
2010
|
-
let t =
|
|
2011
|
-
|
|
2009
|
+
if (D && F(c)) {
|
|
2010
|
+
let t = r.shiftKey ? fe(D, e) : e, n = D;
|
|
2011
|
+
D = null, b("idle"), i.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (c === q.ROTATED_RECTANGLE ? p.current(L.ROTATED_RECTANGLE, me([n, t])) : c === q.CIRCLE ? p.current(L.POLYGON, he(n, t)) : p.current(L.RECTANGLE, [n, t]));
|
|
2012
2012
|
return;
|
|
2013
2013
|
}
|
|
2014
|
-
if (
|
|
2015
|
-
let t = Math.abs(e.x -
|
|
2016
|
-
if (
|
|
2014
|
+
if (A) {
|
|
2015
|
+
let t = Math.abs(e.x - A.x) > 3 || Math.abs(e.y - A.y) > 3, n = j !== null, r = M;
|
|
2016
|
+
if (A = null, j = null, M = !1, i.clearMarquee(), b("idle"), n && t) return;
|
|
2017
2017
|
if (n && r) {
|
|
2018
2018
|
i.setVertexSelection([]);
|
|
2019
2019
|
return;
|
|
2020
2020
|
}
|
|
2021
|
-
!t &&
|
|
2021
|
+
!t && o.current.length && m.current([]);
|
|
2022
2022
|
}
|
|
2023
2023
|
},
|
|
2024
|
-
onViewportChange:
|
|
2025
|
-
onTransformPreview:
|
|
2024
|
+
onViewportChange: x,
|
|
2025
|
+
onTransformPreview: S,
|
|
2026
2026
|
onTransformCommit: (e) => {
|
|
2027
|
-
let t =
|
|
2027
|
+
let t = a.current.getShapes(), n = e.map((e) => {
|
|
2028
2028
|
let n = t.find((t) => t.id === e.id);
|
|
2029
2029
|
return n ? {
|
|
2030
2030
|
...n,
|
|
2031
2031
|
points: e.points
|
|
2032
2032
|
} : null;
|
|
2033
2033
|
}).filter((e) => !!e);
|
|
2034
|
-
n.length &&
|
|
2034
|
+
n.length && a.current.update(n);
|
|
2035
2035
|
}
|
|
2036
2036
|
};
|
|
2037
2037
|
}
|
|
@@ -2046,17 +2046,17 @@ function yn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
2046
2046
|
let a = i.current?.rectResult === "rotatedRect";
|
|
2047
2047
|
return e.map((e) => {
|
|
2048
2048
|
if (t === "rect" && a) return {
|
|
2049
|
-
id:
|
|
2050
|
-
type:
|
|
2051
|
-
points:
|
|
2049
|
+
id: le(),
|
|
2050
|
+
type: L.ROTATED_RECTANGLE,
|
|
2051
|
+
points: _e(e),
|
|
2052
2052
|
style: r,
|
|
2053
2053
|
meta: n
|
|
2054
2054
|
};
|
|
2055
2055
|
if (t === "rect") {
|
|
2056
|
-
let t =
|
|
2056
|
+
let t = H(e);
|
|
2057
2057
|
return {
|
|
2058
|
-
id:
|
|
2059
|
-
type:
|
|
2058
|
+
id: le(),
|
|
2059
|
+
type: L.RECTANGLE,
|
|
2060
2060
|
points: [{
|
|
2061
2061
|
x: t.minX,
|
|
2062
2062
|
y: t.minY
|
|
@@ -2069,8 +2069,8 @@ function yn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
2069
2069
|
};
|
|
2070
2070
|
}
|
|
2071
2071
|
return {
|
|
2072
|
-
id:
|
|
2073
|
-
type:
|
|
2072
|
+
id: le(),
|
|
2073
|
+
type: L.POLYGON,
|
|
2074
2074
|
points: e,
|
|
2075
2075
|
style: r,
|
|
2076
2076
|
meta: n
|
|
@@ -2323,13 +2323,13 @@ function jn(e, t) {
|
|
|
2323
2323
|
}
|
|
2324
2324
|
function Mn(e) {
|
|
2325
2325
|
switch (e.type) {
|
|
2326
|
-
case
|
|
2327
|
-
case
|
|
2328
|
-
case
|
|
2329
|
-
case
|
|
2330
|
-
case
|
|
2326
|
+
case L.RECTANGLE: return e.points.length < 2 ? null : me(e.points);
|
|
2327
|
+
case L.POLYGON:
|
|
2328
|
+
case L.ROTATED_RECTANGLE:
|
|
2329
|
+
case L.ELLIPSE: return e.points.length >= 3 ? e.points : null;
|
|
2330
|
+
case L.POINT: {
|
|
2331
2331
|
let t = e.points[0];
|
|
2332
|
-
return t ?
|
|
2332
|
+
return t ? he({
|
|
2333
2333
|
x: t.x - 6,
|
|
2334
2334
|
y: t.y - 6
|
|
2335
2335
|
}, {
|
|
@@ -2347,7 +2347,7 @@ function Pn(e, t, n = []) {
|
|
|
2347
2347
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
2348
2348
|
let r = jn(e, n);
|
|
2349
2349
|
if (!r.length) return null;
|
|
2350
|
-
let i = t + 4, a =
|
|
2350
|
+
let i = t + 4, a = H(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, Sn / Math.max(o, s, 1));
|
|
2351
2351
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
2352
2352
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
2353
2353
|
x: (e.x - l) * c,
|
|
@@ -2439,21 +2439,21 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2439
2439
|
h.current = s;
|
|
2440
2440
|
let g = j(f);
|
|
2441
2441
|
g.current = f;
|
|
2442
|
-
let _ = j(null), v = j([]), y = j(null), b = j(/* @__PURE__ */ new Set()), x = j([[]]), S = j(0), C = j(null), T = j([]), E = j([]), D = j([]), O = j([[]]), k = j(0), A = j("draw"), M = () => A.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === q.BRUSH && v.current.length > 0,
|
|
2442
|
+
let _ = j(null), v = j([]), y = j(null), b = j(/* @__PURE__ */ new Set()), x = j([[]]), S = j(0), C = j(null), T = j([]), E = j([]), D = j([]), O = j([[]]), k = j(0), A = j("draw"), M = () => A.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === q.BRUSH && v.current.length > 0, P = () => {
|
|
2443
2443
|
let t = e.current;
|
|
2444
2444
|
return t === q.BRUSH && N() ? "brush" : t === q.POLYGON && v.current.length > 0 ? "polygon" : t === q.PATH && v.current.length > 0 ? "path" : "none";
|
|
2445
|
-
},
|
|
2445
|
+
}, ee = () => v.current.length > 0 || k.current > 0, F = () => v.current.length === 0 && k.current < O.current.length - 1, I = () => S.current > 0, te = () => S.current < x.current.length - 1, ne = () => {
|
|
2446
2446
|
let t = e.current;
|
|
2447
|
-
return t === q.BRUSH ?
|
|
2448
|
-
},
|
|
2447
|
+
return t === q.BRUSH ? ee() : t === q.POLYGON || t === q.PATH ? I() : !1;
|
|
2448
|
+
}, re = () => {
|
|
2449
2449
|
let t = e.current;
|
|
2450
2450
|
return t === q.BRUSH ? F() : t === q.POLYGON || t === q.PATH ? te() : !1;
|
|
2451
|
-
},
|
|
2452
|
-
let e =
|
|
2451
|
+
}, ie = () => P() !== "none", R = w(() => {
|
|
2452
|
+
let e = P(), t = {
|
|
2453
2453
|
active: e !== "none",
|
|
2454
2454
|
kind: e,
|
|
2455
|
-
canUndo:
|
|
2456
|
-
canRedo:
|
|
2455
|
+
canUndo: ne(),
|
|
2456
|
+
canRedo: re(),
|
|
2457
2457
|
brush: e === "brush" ? {
|
|
2458
2458
|
mode: A.current,
|
|
2459
2459
|
editing: D.current.length > 0,
|
|
@@ -2461,9 +2461,9 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2461
2461
|
} : void 0
|
|
2462
2462
|
}, n = _.current;
|
|
2463
2463
|
n && Hn(n, t) || (_.current = t, p.current?.(t));
|
|
2464
|
-
}, []),
|
|
2464
|
+
}, []), ae = w(() => {
|
|
2465
2465
|
O.current = [[]], k.current = 0;
|
|
2466
|
-
}, []),
|
|
2466
|
+
}, []), z = w(() => {
|
|
2467
2467
|
let t = c.current;
|
|
2468
2468
|
if (!t) return;
|
|
2469
2469
|
let n = e.current;
|
|
@@ -2497,7 +2497,7 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2497
2497
|
if (t.previewPoly(r, y.current, o, !1, s, l), n === q.POLYGON || n === q.PATH) {
|
|
2498
2498
|
let e = m.current;
|
|
2499
2499
|
e && r !== C.current && (C.current = r, e({
|
|
2500
|
-
type:
|
|
2500
|
+
type: L.POLYGON,
|
|
2501
2501
|
points: zn(r),
|
|
2502
2502
|
meta: h.current
|
|
2503
2503
|
}));
|
|
@@ -2507,82 +2507,82 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2507
2507
|
i,
|
|
2508
2508
|
c,
|
|
2509
2509
|
e
|
|
2510
|
-
]),
|
|
2510
|
+
]), se = w((e) => {
|
|
2511
2511
|
let t = Ln(e), n = O.current, r = k.current, i = n[r];
|
|
2512
|
-
i && Rn(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1,
|
|
2513
|
-
}, [
|
|
2512
|
+
i && Rn(i, t) || (O.current = [...n.slice(0, r + 1), t], k.current += 1, R());
|
|
2513
|
+
}, [R]), ce = w((e) => {
|
|
2514
2514
|
let t = x.current, n = S.current, r = t[n];
|
|
2515
2515
|
r && Bn(r, e) || (x.current = [...t.slice(0, n + 1), zn(e)], S.current += 1);
|
|
2516
|
-
}, []),
|
|
2517
|
-
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), x.current = [[]], S.current = 0, C.current = null,
|
|
2516
|
+
}, []), B = w(() => {
|
|
2517
|
+
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), x.current = [[]], S.current = 0, C.current = null, ae(), c.current?.clearPreview(), m.current?.(null), R();
|
|
2518
2518
|
}, [
|
|
2519
2519
|
c,
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
]),
|
|
2523
|
-
v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t &&
|
|
2520
|
+
R,
|
|
2521
|
+
ae
|
|
2522
|
+
]), V = w((e, t) => {
|
|
2523
|
+
v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && ce(e), z(), R();
|
|
2524
2524
|
}, [
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
]),
|
|
2525
|
+
R,
|
|
2526
|
+
ce,
|
|
2527
|
+
z
|
|
2528
|
+
]), H = w(() => zn(v.current), []), ue = w(() => v.current.length > 0, []), de = w((t, n) => {
|
|
2529
2529
|
if (e.current !== q.POLYGON) return !1;
|
|
2530
2530
|
let r = v.current;
|
|
2531
2531
|
if (r.length < 3) return !1;
|
|
2532
2532
|
let i = r[0];
|
|
2533
|
-
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(
|
|
2534
|
-
}, [
|
|
2533
|
+
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(L.POLYGON, r), B(), !0);
|
|
2534
|
+
}, [B, e]), fe = w((e) => {
|
|
2535
2535
|
let t = v.current;
|
|
2536
|
-
return e < 0 || e >= t.length ? !1 : (
|
|
2537
|
-
}, [
|
|
2536
|
+
return e < 0 || e >= t.length ? !1 : (V(t.filter((t, n) => n !== e), !0), !0);
|
|
2537
|
+
}, [V]), pe = w((e, t) => {
|
|
2538
2538
|
let n = v.current;
|
|
2539
2539
|
if (e < 0 || e >= n.length) return null;
|
|
2540
2540
|
let r = new Set(b.current);
|
|
2541
|
-
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null,
|
|
2541
|
+
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, z(), R(), {
|
|
2542
2542
|
base: zn(n),
|
|
2543
2543
|
indices: Array.from(r)
|
|
2544
2544
|
};
|
|
2545
|
-
}, [
|
|
2546
|
-
b.current = /* @__PURE__ */ new Set(), y.current = e,
|
|
2547
|
-
}, [
|
|
2548
|
-
y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }],
|
|
2549
|
-
}, [
|
|
2545
|
+
}, [R, z]), me = w((e) => {
|
|
2546
|
+
b.current = /* @__PURE__ */ new Set(), y.current = e, V([...v.current, e], !0);
|
|
2547
|
+
}, [V]), he = w((e) => {
|
|
2548
|
+
y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], z(), R();
|
|
2549
|
+
}, [R, z]), ge = w((e, t) => {
|
|
2550
2550
|
let n = v.current[v.current.length - 1];
|
|
2551
|
-
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null,
|
|
2552
|
-
}, [
|
|
2551
|
+
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, z(), R(), !0);
|
|
2552
|
+
}, [R, z]), _e = w((e, t, n, r) => {
|
|
2553
2553
|
let i = new Set(t);
|
|
2554
2554
|
v.current = e.map((e, t) => i.has(t) ? {
|
|
2555
2555
|
x: e.x + n,
|
|
2556
2556
|
y: e.y + r
|
|
2557
|
-
} : { ...e }), y.current = null,
|
|
2558
|
-
}, [
|
|
2559
|
-
e && (
|
|
2557
|
+
} : { ...e }), y.current = null, z(), R();
|
|
2558
|
+
}, [R, z]), ve = w((e) => {
|
|
2559
|
+
e && (ce(v.current), z(), R());
|
|
2560
2560
|
}, [
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
]),
|
|
2565
|
-
y.current = e ? { ...e } : null,
|
|
2566
|
-
}, [
|
|
2561
|
+
R,
|
|
2562
|
+
ce,
|
|
2563
|
+
z
|
|
2564
|
+
]), ye = w((e) => {
|
|
2565
|
+
y.current = e ? { ...e } : null, z();
|
|
2566
|
+
}, [z]), be = w(() => v.current.length > 0 ? (v.current = [], z(), R(), !0) : k.current <= 0 ? !1 : (--k.current, T.current = Ln(O.current[k.current]), z(), R(), !0), [R, z]), xe = w(() => v.current.length > 0 || k.current >= O.current.length - 1 ? !1 : (k.current += 1, T.current = Ln(O.current[k.current]), z(), R(), !0), [R, z]), Se = w(() => S.current <= 0 ? !1 : (--S.current, v.current = zn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), z(), R(), !0), [R, z]), Ce = w(() => S.current >= x.current.length - 1 ? !1 : (S.current += 1, v.current = zn(x.current[S.current]), b.current = /* @__PURE__ */ new Set(), z(), R(), !0), [R, z]), we = w(() => {
|
|
2567
2567
|
let t = e.current;
|
|
2568
|
-
return t === q.BRUSH ?
|
|
2568
|
+
return t === q.BRUSH ? be() : t === q.POLYGON || t === q.PATH ? Se() : !1;
|
|
2569
2569
|
}, [
|
|
2570
2570
|
e,
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
]),
|
|
2571
|
+
be,
|
|
2572
|
+
Se
|
|
2573
|
+
]), Te = w(() => {
|
|
2574
2574
|
let t = e.current;
|
|
2575
|
-
return t === q.BRUSH ?
|
|
2575
|
+
return t === q.BRUSH ? xe() : t === q.POLYGON || t === q.PATH ? Ce() : !1;
|
|
2576
2576
|
}, [
|
|
2577
|
-
|
|
2578
|
-
|
|
2577
|
+
xe,
|
|
2578
|
+
Ce,
|
|
2579
2579
|
e
|
|
2580
|
-
]),
|
|
2580
|
+
]), U = w(() => {
|
|
2581
2581
|
let e = t.current;
|
|
2582
2582
|
if (!e.length) return D.current.length > 0;
|
|
2583
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) &&
|
|
2583
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && oe(t)), i = Nn(r);
|
|
2584
2584
|
return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
|
|
2585
|
-
}, [n, t]),
|
|
2585
|
+
}, [n, t]), Ee = w(() => {
|
|
2586
2586
|
if (r.current) return !1;
|
|
2587
2587
|
let e = [...T.current];
|
|
2588
2588
|
v.current.length && e.push({
|
|
@@ -2592,11 +2592,11 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2592
2592
|
let t = E.current, c = [...D.current];
|
|
2593
2593
|
if (!e.length && !t.length) return !1;
|
|
2594
2594
|
let l = Pn(e, a.current, t);
|
|
2595
|
-
if (!l) return
|
|
2595
|
+
if (!l) return B(), !1;
|
|
2596
2596
|
let u = Fn(l, o.current);
|
|
2597
2597
|
if (c.length) {
|
|
2598
2598
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2599
|
-
if (!u.length) return n.current.remove(c),
|
|
2599
|
+
if (!u.length) return n.current.remove(c), B(), d([]), !0;
|
|
2600
2600
|
u.sort((e, t) => wn(t) - wn(e));
|
|
2601
2601
|
let t = [], r = [], i = [];
|
|
2602
2602
|
for (let n = 0; n < u.length; n++) {
|
|
@@ -2605,33 +2605,33 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2605
2605
|
let r = e[n];
|
|
2606
2606
|
t.push({
|
|
2607
2607
|
...r,
|
|
2608
|
-
type:
|
|
2608
|
+
type: L.POLYGON,
|
|
2609
2609
|
points: a
|
|
2610
2610
|
}), i.push(r.id);
|
|
2611
2611
|
} else {
|
|
2612
|
-
let t = e[0], n =
|
|
2612
|
+
let t = e[0], n = le();
|
|
2613
2613
|
r.push({
|
|
2614
2614
|
...t,
|
|
2615
2615
|
id: n,
|
|
2616
|
-
type:
|
|
2616
|
+
type: L.POLYGON,
|
|
2617
2617
|
points: a
|
|
2618
2618
|
}), i.push(n);
|
|
2619
2619
|
}
|
|
2620
2620
|
}
|
|
2621
2621
|
let a = e.slice(u.length).map((e) => e.id);
|
|
2622
|
-
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a),
|
|
2622
|
+
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), B(), d(i), !0;
|
|
2623
2623
|
}
|
|
2624
|
-
if (!u.length) return
|
|
2624
|
+
if (!u.length) return B(), !1;
|
|
2625
2625
|
let f = i.current;
|
|
2626
2626
|
if (!f) return !1;
|
|
2627
2627
|
let p = u.map((e) => ({
|
|
2628
|
-
id:
|
|
2629
|
-
type:
|
|
2628
|
+
id: le(),
|
|
2629
|
+
type: L.POLYGON,
|
|
2630
2630
|
points: e,
|
|
2631
2631
|
style: f,
|
|
2632
2632
|
meta: s
|
|
2633
2633
|
}));
|
|
2634
|
-
return n.current.create(p), d(p.map((e) => e.id)),
|
|
2634
|
+
return n.current.create(p), d(p.map((e) => e.id)), B(), !0;
|
|
2635
2635
|
}, [
|
|
2636
2636
|
a,
|
|
2637
2637
|
d,
|
|
@@ -2639,43 +2639,43 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2639
2639
|
s,
|
|
2640
2640
|
i,
|
|
2641
2641
|
r,
|
|
2642
|
-
|
|
2643
|
-
]),
|
|
2642
|
+
B
|
|
2643
|
+
]), De = w(() => {
|
|
2644
2644
|
let t = e.current;
|
|
2645
|
-
if (t === q.BRUSH) return
|
|
2645
|
+
if (t === q.BRUSH) return Ee();
|
|
2646
2646
|
let n = v.current;
|
|
2647
|
-
return t === q.POLYGON && n.length >= 3 ? (g.current(
|
|
2647
|
+
return t === q.POLYGON && n.length >= 3 ? (g.current(L.POLYGON, n), B(), !0) : !1;
|
|
2648
2648
|
}, [
|
|
2649
|
-
|
|
2650
|
-
|
|
2649
|
+
Ee,
|
|
2650
|
+
B,
|
|
2651
2651
|
e
|
|
2652
|
-
]),
|
|
2652
|
+
]), Oe = w(() => {
|
|
2653
2653
|
let t = v.current;
|
|
2654
2654
|
if (e.current === q.PATH && t.length >= 3) {
|
|
2655
2655
|
let e = xn(t, o.current);
|
|
2656
|
-
e.length >= 3 && g.current(
|
|
2656
|
+
e.length >= 3 && g.current(L.POLYGON, e);
|
|
2657
2657
|
}
|
|
2658
|
-
|
|
2659
|
-
}, [
|
|
2660
|
-
A.current = e,
|
|
2661
|
-
}, [
|
|
2658
|
+
B();
|
|
2659
|
+
}, [B, e]), ke = w((e) => {
|
|
2660
|
+
A.current = e, R(), z();
|
|
2661
|
+
}, [R, z]), W = w(() => {
|
|
2662
2662
|
if (r.current || e.current !== q.BRUSH) return !1;
|
|
2663
|
-
T.current = [], v.current = [],
|
|
2664
|
-
let t =
|
|
2665
|
-
return
|
|
2663
|
+
T.current = [], v.current = [], ae();
|
|
2664
|
+
let t = U();
|
|
2665
|
+
return R(), z(), t;
|
|
2666
2666
|
}, [
|
|
2667
|
-
|
|
2667
|
+
R,
|
|
2668
2668
|
r,
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2669
|
+
z,
|
|
2670
|
+
ae,
|
|
2671
|
+
U,
|
|
2672
2672
|
e
|
|
2673
|
-
]),
|
|
2673
|
+
]), Ae = w(() => {
|
|
2674
2674
|
let e = b.current;
|
|
2675
2675
|
if (!e.size) return !1;
|
|
2676
2676
|
let t = v.current.filter((t, n) => !e.has(n));
|
|
2677
|
-
return b.current = /* @__PURE__ */ new Set(),
|
|
2678
|
-
}, [
|
|
2677
|
+
return b.current = /* @__PURE__ */ new Set(), V(t, !0), !0;
|
|
2678
|
+
}, [V]), je = w((e) => {
|
|
2679
2679
|
let t = c.current, n = v.current;
|
|
2680
2680
|
if (!t || !n.length) return -1;
|
|
2681
2681
|
let r = Vn / (t.viewport.scale || 1);
|
|
@@ -2684,77 +2684,77 @@ function Un({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2684
2684
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
2685
2685
|
}
|
|
2686
2686
|
return -1;
|
|
2687
|
-
}, [c]),
|
|
2687
|
+
}, [c]), Me = w(() => {
|
|
2688
2688
|
v.current.length >= 1 && (T.current.push({
|
|
2689
2689
|
points: zn(v.current),
|
|
2690
2690
|
mode: M()
|
|
2691
|
-
}), v.current = [],
|
|
2691
|
+
}), v.current = [], se(T.current)), z(), R();
|
|
2692
2692
|
}, [
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2693
|
+
R,
|
|
2694
|
+
se,
|
|
2695
|
+
z
|
|
2696
2696
|
]);
|
|
2697
2697
|
return {
|
|
2698
|
-
reset:
|
|
2699
|
-
undoSession:
|
|
2700
|
-
redoSession:
|
|
2701
|
-
canUndoSession:
|
|
2702
|
-
canRedoSession:
|
|
2703
|
-
hasDraftSession:
|
|
2704
|
-
hasDraftPoints:
|
|
2705
|
-
commitDraftSession:
|
|
2706
|
-
completeFreehandStroke:
|
|
2707
|
-
setBrushScalarMode:
|
|
2698
|
+
reset: B,
|
|
2699
|
+
undoSession: we,
|
|
2700
|
+
redoSession: Te,
|
|
2701
|
+
canUndoSession: ne,
|
|
2702
|
+
canRedoSession: re,
|
|
2703
|
+
hasDraftSession: ie,
|
|
2704
|
+
hasDraftPoints: ue,
|
|
2705
|
+
commitDraftSession: De,
|
|
2706
|
+
completeFreehandStroke: Oe,
|
|
2707
|
+
setBrushScalarMode: ke,
|
|
2708
2708
|
getBrushScalarMode: () => A.current,
|
|
2709
2709
|
hasBrushSession: N,
|
|
2710
|
-
commitBrush:
|
|
2710
|
+
commitBrush: Ee,
|
|
2711
2711
|
cancelBrush: w(() => {
|
|
2712
|
-
e.current === q.BRUSH &&
|
|
2713
|
-
}, [
|
|
2714
|
-
beginBrushEditFromSelection:
|
|
2715
|
-
deleteDraftSelectedPoints:
|
|
2716
|
-
hitDraftPoint:
|
|
2717
|
-
getDraftPointsSnapshot:
|
|
2718
|
-
tryClosePolygon:
|
|
2719
|
-
removeDraftPoint:
|
|
2720
|
-
selectDraftPointForDrag:
|
|
2721
|
-
appendPolygonPoint:
|
|
2722
|
-
beginStroke:
|
|
2723
|
-
appendStrokePoint:
|
|
2724
|
-
moveDraftPoints:
|
|
2725
|
-
commitDraftPointDrag:
|
|
2726
|
-
setDraftCursor:
|
|
2727
|
-
finishScalarStroke:
|
|
2712
|
+
e.current === q.BRUSH && B();
|
|
2713
|
+
}, [B, e]),
|
|
2714
|
+
beginBrushEditFromSelection: W,
|
|
2715
|
+
deleteDraftSelectedPoints: Ae,
|
|
2716
|
+
hitDraftPoint: je,
|
|
2717
|
+
getDraftPointsSnapshot: H,
|
|
2718
|
+
tryClosePolygon: de,
|
|
2719
|
+
removeDraftPoint: fe,
|
|
2720
|
+
selectDraftPointForDrag: pe,
|
|
2721
|
+
appendPolygonPoint: me,
|
|
2722
|
+
beginStroke: he,
|
|
2723
|
+
appendStrokePoint: ge,
|
|
2724
|
+
moveDraftPoints: _e,
|
|
2725
|
+
commitDraftPointDrag: ve,
|
|
2726
|
+
setDraftCursor: ye,
|
|
2727
|
+
finishScalarStroke: Me,
|
|
2728
2728
|
handleToolChange: w((e, t) => {
|
|
2729
2729
|
if (t) {
|
|
2730
|
-
|
|
2730
|
+
B(), A.current = "draw";
|
|
2731
2731
|
return;
|
|
2732
2732
|
}
|
|
2733
2733
|
if (e !== q.BRUSH) {
|
|
2734
|
-
|
|
2734
|
+
B(), A.current = "draw";
|
|
2735
2735
|
return;
|
|
2736
2736
|
}
|
|
2737
|
-
A.current = "draw", T.current = [], v.current = [],
|
|
2737
|
+
A.current = "draw", T.current = [], v.current = [], ae(), U(), R(), z();
|
|
2738
2738
|
}, [
|
|
2739
|
+
R,
|
|
2739
2740
|
z,
|
|
2740
2741
|
B,
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
W
|
|
2742
|
+
ae,
|
|
2743
|
+
U
|
|
2744
2744
|
]),
|
|
2745
2745
|
handleBrushSelectionChange: w((t, n) => {
|
|
2746
2746
|
if (!(e.current !== q.BRUSH || n)) {
|
|
2747
2747
|
if (!t.length) {
|
|
2748
|
-
|
|
2748
|
+
R();
|
|
2749
2749
|
return;
|
|
2750
2750
|
}
|
|
2751
|
-
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [],
|
|
2751
|
+
[...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], ae(), U(), R(), z()));
|
|
2752
2752
|
}
|
|
2753
2753
|
}, [
|
|
2754
|
+
R,
|
|
2754
2755
|
z,
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
W,
|
|
2756
|
+
ae,
|
|
2757
|
+
U,
|
|
2758
2758
|
e
|
|
2759
2759
|
])
|
|
2760
2760
|
};
|
|
@@ -2768,7 +2768,7 @@ function Wn(e, t) {
|
|
|
2768
2768
|
future: []
|
|
2769
2769
|
};
|
|
2770
2770
|
}
|
|
2771
|
-
function
|
|
2771
|
+
function $(e, t) {
|
|
2772
2772
|
switch (t.type) {
|
|
2773
2773
|
case "CREATE": return Wn(e, [...e.shapes, ...t.shapes]);
|
|
2774
2774
|
case "UPDATE": {
|
|
@@ -2805,15 +2805,15 @@ function Gn(e, t) {
|
|
|
2805
2805
|
default: return e;
|
|
2806
2806
|
}
|
|
2807
2807
|
}
|
|
2808
|
-
function
|
|
2809
|
-
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = A(
|
|
2808
|
+
function Gn(e) {
|
|
2809
|
+
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = A($, {
|
|
2810
2810
|
shapes: [],
|
|
2811
2811
|
past: [],
|
|
2812
2812
|
future: []
|
|
2813
2813
|
}), o = j(i);
|
|
2814
2814
|
o.current = i;
|
|
2815
2815
|
let s = w((e) => {
|
|
2816
|
-
o.current =
|
|
2816
|
+
o.current = $(o.current, e), a(e);
|
|
2817
2817
|
}, []), c = w((e, i) => {
|
|
2818
2818
|
let a = new Map(e.map((e) => [e.id, e])), o = new Map(i.map((e) => [e.id, e])), s = i.filter((e) => !a.has(e.id));
|
|
2819
2819
|
s.length && t?.(s);
|
|
@@ -2882,7 +2882,7 @@ function Kn(e) {
|
|
|
2882
2882
|
}
|
|
2883
2883
|
//#endregion
|
|
2884
2884
|
//#region src/components/ShapeEditor/_model/keymap.ts
|
|
2885
|
-
var
|
|
2885
|
+
var Kn = {
|
|
2886
2886
|
undo: ["mod+z"],
|
|
2887
2887
|
redo: ["mod+shift+z"],
|
|
2888
2888
|
selectAll: ["mod+a"],
|
|
@@ -2945,8 +2945,8 @@ function Xn(e) {
|
|
|
2945
2945
|
}
|
|
2946
2946
|
function Zn(e) {
|
|
2947
2947
|
let t = /* @__PURE__ */ new Map();
|
|
2948
|
-
for (let n of Object.keys(
|
|
2949
|
-
let r = e?.[n], i = r === void 0 ?
|
|
2948
|
+
for (let n of Object.keys(Kn)) {
|
|
2949
|
+
let r = e?.[n], i = r === void 0 ? Kn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
|
|
2950
2950
|
for (let e of i) t.set(e.toLowerCase(), n);
|
|
2951
2951
|
}
|
|
2952
2952
|
return t;
|
|
@@ -2960,36 +2960,34 @@ var Qn = {
|
|
|
2960
2960
|
ArrowRight: [1, 0]
|
|
2961
2961
|
};
|
|
2962
2962
|
function $n(e) {
|
|
2963
|
-
let { spaceRef: t
|
|
2964
|
-
|
|
2965
|
-
let
|
|
2966
|
-
|
|
2967
|
-
let e =
|
|
2968
|
-
if (!e || !
|
|
2969
|
-
let
|
|
2970
|
-
if (
|
|
2971
|
-
|
|
2972
|
-
let
|
|
2973
|
-
if (
|
|
2974
|
-
let e =
|
|
2975
|
-
|
|
2963
|
+
let { spaceRef: t } = e, n = k(() => Zn(e.keymap), [e.keymap]), r = j(e);
|
|
2964
|
+
r.current = e;
|
|
2965
|
+
let i = j(n);
|
|
2966
|
+
i.current = n, T(() => {
|
|
2967
|
+
let e = r.current.hostRef.current, n = e?.ownerDocument.defaultView;
|
|
2968
|
+
if (!e || !n) return;
|
|
2969
|
+
let a = (n) => {
|
|
2970
|
+
if (n.defaultPrevented && n.key !== "Escape" || y(n.target) || !g(e, n.target)) return;
|
|
2971
|
+
n.code === "Space" && (t.current = !0, r.current.onSpaceDown());
|
|
2972
|
+
let a = Qn[n.key];
|
|
2973
|
+
if (a) {
|
|
2974
|
+
let e = n.shiftKey ? 10 : 1;
|
|
2975
|
+
r.current.nudge(a[0] * e, a[1] * e) !== !1 && n.preventDefault();
|
|
2976
2976
|
return;
|
|
2977
2977
|
}
|
|
2978
|
-
let
|
|
2979
|
-
if (!
|
|
2980
|
-
let
|
|
2981
|
-
|
|
2982
|
-
},
|
|
2983
|
-
e.code === "Space" && t.current && (t.current = !1,
|
|
2984
|
-
},
|
|
2985
|
-
|
|
2986
|
-
}, l = () => {
|
|
2987
|
-
n.current = !1, t.current && (t.current = !1, i.current.onSpaceUp());
|
|
2978
|
+
let o = Xn(n);
|
|
2979
|
+
if (!o) return;
|
|
2980
|
+
let s = i.current.get(o);
|
|
2981
|
+
s && r.current.actions[s]?.() !== !1 && n.preventDefault();
|
|
2982
|
+
}, o = (e) => {
|
|
2983
|
+
e.code === "Space" && t.current && (t.current = !1, r.current.onSpaceUp());
|
|
2984
|
+
}, s = () => {
|
|
2985
|
+
t.current && (t.current = !1, r.current.onSpaceUp());
|
|
2988
2986
|
};
|
|
2989
|
-
return e.addEventListener("keydown",
|
|
2990
|
-
e.removeEventListener("keydown",
|
|
2987
|
+
return e.addEventListener("keydown", a), n.addEventListener("keyup", o, !0), n.addEventListener("blur", s), () => {
|
|
2988
|
+
e.removeEventListener("keydown", a), n.removeEventListener("keyup", o, !0), n.removeEventListener("blur", s), s();
|
|
2991
2989
|
};
|
|
2992
|
-
}, [t
|
|
2990
|
+
}, [t]);
|
|
2993
2991
|
}
|
|
2994
2992
|
//#endregion
|
|
2995
2993
|
//#region src/components/ShapeEditor/_model/imageLoad.ts
|
|
@@ -3175,14 +3173,14 @@ function fr(e, t) {
|
|
|
3175
3173
|
//#endregion
|
|
3176
3174
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
3177
3175
|
function pr(e, t, n) {
|
|
3178
|
-
if (t ===
|
|
3176
|
+
if (t === L.POINT) {
|
|
3179
3177
|
e.setAttrs({
|
|
3180
3178
|
x: n[0].x,
|
|
3181
3179
|
y: n[0].y
|
|
3182
3180
|
});
|
|
3183
3181
|
return;
|
|
3184
3182
|
}
|
|
3185
|
-
if (t ===
|
|
3183
|
+
if (t === L.RECTANGLE) {
|
|
3186
3184
|
let [t, r] = n;
|
|
3187
3185
|
e.setAttrs({
|
|
3188
3186
|
x: Math.min(t.x, r.x),
|
|
@@ -3192,8 +3190,8 @@ function pr(e, t, n) {
|
|
|
3192
3190
|
});
|
|
3193
3191
|
return;
|
|
3194
3192
|
}
|
|
3195
|
-
if (t ===
|
|
3196
|
-
let t =
|
|
3193
|
+
if (t === L.ELLIPSE) {
|
|
3194
|
+
let t = H(n);
|
|
3197
3195
|
e.setAttrs({
|
|
3198
3196
|
x: (t.minX + t.maxX) / 2,
|
|
3199
3197
|
y: (t.minY + t.maxY) / 2,
|
|
@@ -3218,15 +3216,15 @@ function _r(e) {
|
|
|
3218
3216
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
3219
3217
|
var vr = Math.PI / 12;
|
|
3220
3218
|
function yr(e, t) {
|
|
3221
|
-
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type ===
|
|
3219
|
+
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === L.ROTATED_RECTANGLE;
|
|
3222
3220
|
}
|
|
3223
3221
|
function br(e, t, n) {
|
|
3224
3222
|
if (e.kind === "resize") {
|
|
3225
|
-
let r = n ? e.box :
|
|
3223
|
+
let r = n ? e.box : de(e.anchor, e.box, t.x, t.y);
|
|
3226
3224
|
return {
|
|
3227
3225
|
updates: e.shapes.map((i) => ({
|
|
3228
3226
|
id: i.id,
|
|
3229
|
-
points: n ?
|
|
3227
|
+
points: n ? Ee(i.points, e.anchor, t) : De(i.points, e.box, r)
|
|
3230
3228
|
})),
|
|
3231
3229
|
box: r
|
|
3232
3230
|
};
|
|
@@ -3254,7 +3252,7 @@ function br(e, t, n) {
|
|
|
3254
3252
|
return e.shiftKey && (n = Math.round(n / vr) * vr), {
|
|
3255
3253
|
updates: [{
|
|
3256
3254
|
id: e.id,
|
|
3257
|
-
points: e.points.map((t) =>
|
|
3255
|
+
points: e.points.map((t) => pe(t, e.center, n))
|
|
3258
3256
|
}],
|
|
3259
3257
|
box: null
|
|
3260
3258
|
};
|
|
@@ -3268,24 +3266,24 @@ function br(e, t, n) {
|
|
|
3268
3266
|
id: e.id,
|
|
3269
3267
|
points: a
|
|
3270
3268
|
}],
|
|
3271
|
-
box:
|
|
3269
|
+
box: H(a)
|
|
3272
3270
|
};
|
|
3273
3271
|
}
|
|
3274
3272
|
function xr(e, t) {
|
|
3275
3273
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
3276
3274
|
x: t.center.x + Math.cos(t.startAngle),
|
|
3277
3275
|
y: t.center.y + Math.sin(t.startAngle)
|
|
3278
|
-
} : yr(e, t) ?
|
|
3276
|
+
} : yr(e, t) ? we(t.shapes[0].points)[V.indexOf(t.anchor)] : ue(t.anchor, t.box);
|
|
3279
3277
|
}
|
|
3280
3278
|
function Sr(e, t, n) {
|
|
3281
|
-
let r = e.filter((e) => t.includes(e.id) &&
|
|
3279
|
+
let r = e.filter((e) => t.includes(e.id) && se(e)).map((e) => ({
|
|
3282
3280
|
id: e.id,
|
|
3283
3281
|
points: e.points
|
|
3284
3282
|
}));
|
|
3285
3283
|
return r.length ? {
|
|
3286
3284
|
kind: "move",
|
|
3287
3285
|
start: n,
|
|
3288
|
-
box:
|
|
3286
|
+
box: H(r.flatMap((e) => e.points)),
|
|
3289
3287
|
shapes: r
|
|
3290
3288
|
} : null;
|
|
3291
3289
|
}
|
|
@@ -3297,10 +3295,10 @@ function Cr(e) {
|
|
|
3297
3295
|
}
|
|
3298
3296
|
function wr(e, t) {
|
|
3299
3297
|
let n = new Set(t);
|
|
3300
|
-
return e.filter((e) => n.has(e.id) &&
|
|
3298
|
+
return e.filter((e) => n.has(e.id) && oe(e));
|
|
3301
3299
|
}
|
|
3302
3300
|
function Tr(e, t) {
|
|
3303
|
-
return e.filter((e) =>
|
|
3301
|
+
return e.filter((e) => z(e) && Fe(e, t)).map((e) => e.id);
|
|
3304
3302
|
}
|
|
3305
3303
|
function Er(e, t, n) {
|
|
3306
3304
|
return (e ? at(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
@@ -3314,9 +3312,9 @@ function Dr(e, t) {
|
|
|
3314
3312
|
};
|
|
3315
3313
|
}
|
|
3316
3314
|
function Or(e, t, n) {
|
|
3317
|
-
if (e.type ===
|
|
3318
|
-
let r = e.type ===
|
|
3319
|
-
return
|
|
3315
|
+
if (e.type === L.ROTATED_RECTANGLE) return t;
|
|
3316
|
+
let r = e.type === L.POINT ? Dr(t[0], n) : H(t);
|
|
3317
|
+
return me([{
|
|
3320
3318
|
x: r.minX,
|
|
3321
3319
|
y: r.minY
|
|
3322
3320
|
}, {
|
|
@@ -3359,7 +3357,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3359
3357
|
this.stage.on("mousedown", (t) => {
|
|
3360
3358
|
let n = t.target === this.stage ? null : t.target.id() || null;
|
|
3361
3359
|
this.cb.onPointerDown(this.toImage(), n, e(t));
|
|
3362
|
-
}), this.stage.on("mousemove", () => {
|
|
3360
|
+
}), this.stage.on("mousemove", (e) => {
|
|
3363
3361
|
if (this.lastImg = this.toImage(), this.activeDrag) {
|
|
3364
3362
|
this.lastDragImg = this.lastImg, this.dragTransform(this.lastImg);
|
|
3365
3363
|
return;
|
|
@@ -3369,7 +3367,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3369
3367
|
global: this.stage.getPointerPosition() ?? {
|
|
3370
3368
|
x: 0,
|
|
3371
3369
|
y: 0
|
|
3372
|
-
}
|
|
3370
|
+
},
|
|
3371
|
+
shiftKey: e.evt.shiftKey
|
|
3373
3372
|
});
|
|
3374
3373
|
});
|
|
3375
3374
|
let t = null, n = (e, n) => {
|
|
@@ -3384,6 +3383,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3384
3383
|
x: 0,
|
|
3385
3384
|
y: 0
|
|
3386
3385
|
},
|
|
3386
|
+
shiftKey: e.shiftKey,
|
|
3387
3387
|
insideCanvas: n
|
|
3388
3388
|
});
|
|
3389
3389
|
}
|
|
@@ -3426,7 +3426,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3426
3426
|
for (let e of this.stage.container().querySelectorAll("canvas")) e.style.cursor = this.baseCursor;
|
|
3427
3427
|
}
|
|
3428
3428
|
bindShapeCursor(e, t) {
|
|
3429
|
-
if (!
|
|
3429
|
+
if (!se(t)) return this.bindCursor(e, "default");
|
|
3430
3430
|
this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" : Wt);
|
|
3431
3431
|
}
|
|
3432
3432
|
bindCursor(e, t) {
|
|
@@ -3600,9 +3600,9 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3600
3600
|
setShapes(e, t) {
|
|
3601
3601
|
if (this.shapes = Cr(e), this.selected = t, !this.activeDrag) {
|
|
3602
3602
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3603
|
-
for (let t of
|
|
3603
|
+
for (let t of ce(e).filter(R)) {
|
|
3604
3604
|
let e = this.makeNode(t), n = at(t, { strokeWidth: this.strokeSize });
|
|
3605
|
-
if (t.style?.alternateColor && n.dash?.length && t.type !==
|
|
3605
|
+
if (t.style?.alternateColor && n.dash?.length && t.type !== L.POINT) {
|
|
3606
3606
|
let n = e.clone({
|
|
3607
3607
|
id: `${t.id}__alt`,
|
|
3608
3608
|
stroke: t.style.alternateColor,
|
|
@@ -3632,7 +3632,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3632
3632
|
t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
|
|
3633
3633
|
}
|
|
3634
3634
|
makeNode(e) {
|
|
3635
|
-
let { type: t, points: n } = e, r = at(e, { strokeWidth: this.strokeSize }), i =
|
|
3635
|
+
let { type: t, points: n } = e, r = at(e, { strokeWidth: this.strokeSize }), i = z(e), a = {
|
|
3636
3636
|
id: e.id,
|
|
3637
3637
|
stroke: r.color,
|
|
3638
3638
|
strokeWidth: r.strokeWidth,
|
|
@@ -3641,7 +3641,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3641
3641
|
strokeScaleEnabled: !1,
|
|
3642
3642
|
listening: i
|
|
3643
3643
|
}, o = r.fillVisible ? ot(r.color, r.fillAlpha) : void 0;
|
|
3644
|
-
if (t ===
|
|
3644
|
+
if (t === L.POINT) {
|
|
3645
3645
|
let t = 1 / (this.world.scaleX() || 1), a = new N.Path({
|
|
3646
3646
|
id: e.id,
|
|
3647
3647
|
data: mr,
|
|
@@ -3664,8 +3664,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3664
3664
|
});
|
|
3665
3665
|
return this.bindShapeCursor(a, e), a;
|
|
3666
3666
|
}
|
|
3667
|
-
if (t ===
|
|
3668
|
-
let t =
|
|
3667
|
+
if (t === L.RECTANGLE) {
|
|
3668
|
+
let t = H(n), r = new N.Rect({
|
|
3669
3669
|
x: t.minX,
|
|
3670
3670
|
y: t.minY,
|
|
3671
3671
|
width: t.maxX - t.minX,
|
|
@@ -3675,8 +3675,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3675
3675
|
});
|
|
3676
3676
|
return this.bindShapeCursor(r, e), r;
|
|
3677
3677
|
}
|
|
3678
|
-
if (t ===
|
|
3679
|
-
let t =
|
|
3678
|
+
if (t === L.ELLIPSE) {
|
|
3679
|
+
let t = H(n), r = new N.Ellipse({
|
|
3680
3680
|
x: (t.minX + t.maxX) / 2,
|
|
3681
3681
|
y: (t.minY + t.maxY) / 2,
|
|
3682
3682
|
radiusX: (t.maxX - t.minX) / 2,
|
|
@@ -3686,7 +3686,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3686
3686
|
});
|
|
3687
3687
|
return this.bindShapeCursor(r, e), r;
|
|
3688
3688
|
}
|
|
3689
|
-
let s = n.flatMap((e) => [e.x, e.y]), c = t !==
|
|
3689
|
+
let s = n.flatMap((e) => [e.x, e.y]), c = t !== L.LINE, l = new N.Line({
|
|
3690
3690
|
points: s,
|
|
3691
3691
|
closed: c,
|
|
3692
3692
|
fill: c ? o : void 0,
|
|
@@ -3701,7 +3701,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3701
3701
|
if (n && r) {
|
|
3702
3702
|
pr(n, r.type, t);
|
|
3703
3703
|
let i = this.altNodes.get(e);
|
|
3704
|
-
i && pr(i, r.type, t), r.type ===
|
|
3704
|
+
i && pr(i, r.type, t), r.type === L.POINT && n instanceof N.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3705
3705
|
}
|
|
3706
3706
|
}
|
|
3707
3707
|
pointRadius(e) {
|
|
@@ -3714,7 +3714,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3714
3714
|
let e = 1 / (this.world.scaleX() || 1);
|
|
3715
3715
|
for (let t of this.shapes) {
|
|
3716
3716
|
let n = this.nodes.get(t.id);
|
|
3717
|
-
if (t.type ===
|
|
3717
|
+
if (t.type === L.POINT) {
|
|
3718
3718
|
n?.scale({
|
|
3719
3719
|
x: e,
|
|
3720
3720
|
y: e
|
|
@@ -3728,7 +3728,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3728
3728
|
return Tr(this.shapes, e);
|
|
3729
3729
|
}
|
|
3730
3730
|
drawSelectionBorders() {
|
|
3731
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
3731
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && z(t)) : [];
|
|
3732
3732
|
if (this.selectionBorders.length !== t.length) {
|
|
3733
3733
|
for (let e of this.selectionBorders) e.destroy();
|
|
3734
3734
|
this.selectionBorders = t.map(() => {
|
|
@@ -3749,7 +3749,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3749
3749
|
updateSelectionBordersLive(e) {
|
|
3750
3750
|
let t = new Set(this.selected), n = 0;
|
|
3751
3751
|
for (let r of this.shapes) {
|
|
3752
|
-
if (!t.has(r.id) || !
|
|
3752
|
+
if (!t.has(r.id) || !z(r)) continue;
|
|
3753
3753
|
let i = this.selectionOutlinePoints(r, e(r)), a = this.selectionBorders[n++];
|
|
3754
3754
|
a && a.points(i.flatMap((e) => [e.x, e.y]));
|
|
3755
3755
|
}
|
|
@@ -3862,7 +3862,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3862
3862
|
}
|
|
3863
3863
|
setTransformerOutline(e) {
|
|
3864
3864
|
let t = Math.max(0, e.maxX - e.minX), n = Math.max(0, e.maxY - e.minY);
|
|
3865
|
-
!t && !n || this.setTransformerOutlinePoints(
|
|
3865
|
+
!t && !n || this.setTransformerOutlinePoints(me([{
|
|
3866
3866
|
x: e.minX,
|
|
3867
3867
|
y: e.minY
|
|
3868
3868
|
}, {
|
|
@@ -3883,10 +3883,10 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3883
3883
|
return kr(this.viewport.scale);
|
|
3884
3884
|
}
|
|
3885
3885
|
rotationHandleScreenPoint(e) {
|
|
3886
|
-
return this.imgToScreen(
|
|
3886
|
+
return this.imgToScreen(Te(e, this.rotationHandleGap()));
|
|
3887
3887
|
}
|
|
3888
3888
|
setRotationConnector(e) {
|
|
3889
|
-
let t = this.imgToScreen(
|
|
3889
|
+
let t = this.imgToScreen(Se(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
3890
3890
|
this.rotLineNode ? this.rotLineNode.points([
|
|
3891
3891
|
t.x,
|
|
3892
3892
|
t.y,
|
|
@@ -3918,7 +3918,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3918
3918
|
}
|
|
3919
3919
|
repositionOrientedHandles(e) {
|
|
3920
3920
|
let t = this.orientedHandleAngle(e);
|
|
3921
|
-
if (
|
|
3921
|
+
if (we(e).forEach((e, n) => {
|
|
3922
3922
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
3923
3923
|
i && this.layoutResizeHandle(i, r, t);
|
|
3924
3924
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -3937,12 +3937,12 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3937
3937
|
for (let e of this.midNodes) e.destroy();
|
|
3938
3938
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
3939
3939
|
let e = wr(this.shapes, this.selected);
|
|
3940
|
-
if (!e.length || e.length === 1 && e[0].type ===
|
|
3941
|
-
let t = e.length === 1 && (e[0].type ===
|
|
3940
|
+
if (!e.length || e.length === 1 && e[0].type === L.POINT) return;
|
|
3941
|
+
let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = H(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? we(r.points) : V.map((e) => ue(e, n));
|
|
3942
3942
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
3943
3943
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
3944
|
-
for (let e of t ? [] :
|
|
3945
|
-
let t = this.imgToScreen(i[
|
|
3944
|
+
for (let e of t ? [] : V) {
|
|
3945
|
+
let t = this.imgToScreen(i[V.indexOf(e)]), n = new N.Rect({
|
|
3946
3946
|
x: t.x,
|
|
3947
3947
|
y: t.y,
|
|
3948
3948
|
width: 8,
|
|
@@ -3960,7 +3960,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3960
3960
|
this.activeDrag = {
|
|
3961
3961
|
kind: "resize",
|
|
3962
3962
|
anchor: e,
|
|
3963
|
-
box:
|
|
3963
|
+
box: H(n.flatMap((e) => e.points)),
|
|
3964
3964
|
shapes: n.map((e) => ({
|
|
3965
3965
|
id: e.id,
|
|
3966
3966
|
points: e.points
|
|
@@ -3969,7 +3969,7 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
3969
3969
|
}), this.handleGroup.add(n), this.handleNodes.push(n);
|
|
3970
3970
|
}
|
|
3971
3971
|
if (t) {
|
|
3972
|
-
let e = t, n = e.points, r = e.type ===
|
|
3972
|
+
let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new N.Circle({
|
|
3973
3973
|
radius: i * .8,
|
|
3974
3974
|
fill: "#ffffff",
|
|
3975
3975
|
opacity: .6,
|
|
@@ -4053,8 +4053,8 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4053
4053
|
}), this.handleGroup.add(s), this.vertexNodes.push(s);
|
|
4054
4054
|
});
|
|
4055
4055
|
}
|
|
4056
|
-
if (e.length === 1 && e[0].type ===
|
|
4057
|
-
let t = e[0], n =
|
|
4056
|
+
if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
|
|
4057
|
+
let t = e[0], n = Ce(t.points), r = this.rotationHandleScreenPoint(t.points), i = new N.Circle({
|
|
4058
4058
|
x: r.x,
|
|
4059
4059
|
y: r.y,
|
|
4060
4060
|
radius: 6,
|
|
@@ -4079,11 +4079,11 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4079
4079
|
}
|
|
4080
4080
|
beginMove(e, t) {
|
|
4081
4081
|
let n = Sr(this.shapes, t, e);
|
|
4082
|
-
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type ===
|
|
4082
|
+
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4083
4083
|
}
|
|
4084
4084
|
repositionHandles(e) {
|
|
4085
|
-
|
|
4086
|
-
let r = this.imgToScreen(
|
|
4085
|
+
V.forEach((t, n) => {
|
|
4086
|
+
let r = this.imgToScreen(ue(t, e)), i = this.handleNodes[n];
|
|
4087
4087
|
i && this.layoutResizeHandle(i, r, 0);
|
|
4088
4088
|
}), this.setTransformerOutline(e);
|
|
4089
4089
|
}
|
|
@@ -4124,16 +4124,16 @@ var jr = 2, Mr = "#1e88e5", Nr = "#669def", Pr = class {
|
|
|
4124
4124
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
4125
4125
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
4126
4126
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
4127
|
-
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type ===
|
|
4128
|
-
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4127
|
+
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
|
|
4128
|
+
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
4129
4129
|
} else if (t.kind === "rotate") {
|
|
4130
4130
|
this.repositionOrientedHandles(r[0].points);
|
|
4131
4131
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4132
|
-
e && (e.type ===
|
|
4132
|
+
e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
|
|
4133
4133
|
} else {
|
|
4134
4134
|
i && this.repositionHandles(i);
|
|
4135
4135
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4136
|
-
this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4136
|
+
this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
4137
4137
|
}
|
|
4138
4138
|
this.layer.batchDraw();
|
|
4139
4139
|
}
|
|
@@ -4168,7 +4168,7 @@ function Rr(e) {
|
|
|
4168
4168
|
}
|
|
4169
4169
|
var zr = class {
|
|
4170
4170
|
constructor(e, t) {
|
|
4171
|
-
this.app = new
|
|
4171
|
+
this.app = new P(), this.world = new F(), this.bgLayer = new F(), this.overlayLayer = new F(), this.regionOverlayLayer = new F(), this.dimOverlayLayer = new F(), this.shapeLayer = new F(), this.selLayer = new F(), this.previewLayer = new F(), this.handleLayer = new F(), this.filter = new ee(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize = ur, this.region = null, this.regionDimMaskG = new I(), this.regionDimG = new I(), this.regionZoneMaskG = new I(), this.regionZoneG = new I(), this.regionOutlineG = new I(), this.baseCursor = "default", this.strokeSize = Fr, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.brightness = 1, this.contrast = 1, this.imageSmoothing = !0, this.destroyed = !1, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastDragImg = null, this.activeDrag = null, this.midNodes = [], this.ghostNode = null, this.selectedVertices = /* @__PURE__ */ new Set(), this.vertexPolygonId = null, this.editingId = null, this.rotNode = null, this.rotLineNode = null, this.transformerOutline = null, this.selectionBorderGfx = [], this.previewG = new I(), this.marqueeG = new I(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
4172
4172
|
}
|
|
4173
4173
|
ev(e) {
|
|
4174
4174
|
return {
|
|
@@ -4221,6 +4221,7 @@ var zr = class {
|
|
|
4221
4221
|
x: e.global.x,
|
|
4222
4222
|
y: e.global.y
|
|
4223
4223
|
},
|
|
4224
|
+
shiftKey: e.shiftKey,
|
|
4224
4225
|
insideCanvas: t
|
|
4225
4226
|
});
|
|
4226
4227
|
};
|
|
@@ -4228,7 +4229,7 @@ var zr = class {
|
|
|
4228
4229
|
}
|
|
4229
4230
|
syncHitArea() {
|
|
4230
4231
|
let { w: e, h: t } = this.screenSize;
|
|
4231
|
-
this.app.stage.hitArea = new
|
|
4232
|
+
this.app.stage.hitArea = new ne(0, 0, e, t);
|
|
4232
4233
|
}
|
|
4233
4234
|
destroy() {
|
|
4234
4235
|
this.destroyed = !0, this.clearImageTiles(), this.app.renderer && this.app.destroy(!0, { children: !0 });
|
|
@@ -4281,9 +4282,9 @@ var zr = class {
|
|
|
4281
4282
|
let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
|
|
4282
4283
|
this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
|
|
4283
4284
|
for (let e of dr(i.naturalWidth, i.naturalHeight, this.tileSize)) {
|
|
4284
|
-
let t =
|
|
4285
|
+
let t = ie.from(fr(i, e));
|
|
4285
4286
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
4286
|
-
let n = new
|
|
4287
|
+
let n = new re(t);
|
|
4287
4288
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
4288
4289
|
}
|
|
4289
4290
|
return this.applySpriteFilter(), !0;
|
|
@@ -4431,9 +4432,9 @@ var zr = class {
|
|
|
4431
4432
|
this.shapeLayer.removeChildren();
|
|
4432
4433
|
for (let e of this.nodes.values()) e.destroy();
|
|
4433
4434
|
this.nodes.clear();
|
|
4434
|
-
for (let e of
|
|
4435
|
+
for (let e of ce(this.shapes).filter(R)) {
|
|
4435
4436
|
let t = new I();
|
|
4436
|
-
this.paintShape(t, e), t.eventMode =
|
|
4437
|
+
this.paintShape(t, e), t.eventMode = z(e) ? "static" : "none", t.cursor = void 0, z(e) && se(e) && (t.on("pointerover", () => {
|
|
4437
4438
|
this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" : Wt);
|
|
4438
4439
|
}), t.on("pointerout", () => {
|
|
4439
4440
|
this.activeDrag || this.emitCursorHint(null);
|
|
@@ -4445,14 +4446,14 @@ var zr = class {
|
|
|
4445
4446
|
paintShape(e, t) {
|
|
4446
4447
|
e.clear();
|
|
4447
4448
|
let n = at(t, { strokeWidth: this.strokeSize }), r = Rr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4448
|
-
if (t.type ===
|
|
4449
|
+
if (t.type === L.POINT) {
|
|
4449
4450
|
e.svg(_r(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4450
4451
|
let r = 1 / (this.world.scale.x || 1);
|
|
4451
4452
|
e.scale.set(r, r), e.alpha = a;
|
|
4452
4453
|
return;
|
|
4453
4454
|
}
|
|
4454
|
-
if (n.fillVisible && t.type !==
|
|
4455
|
-
let i = t.type ===
|
|
4455
|
+
if (n.fillVisible && t.type !== L.LINE) {
|
|
4456
|
+
let i = t.type === L.POLYGON ? ze(t.points) : null;
|
|
4456
4457
|
if (i && (i.length > 1 || i[0].holes.length > 0)) for (let t of i) for (let i = 0; i < Math.min(t.layers, 4); i++) {
|
|
4457
4458
|
e.poly(t.outline.flatMap((e) => [e.x, e.y]), !0), e.fill({
|
|
4458
4459
|
color: r,
|
|
@@ -4464,7 +4465,7 @@ var zr = class {
|
|
|
4464
4465
|
color: r,
|
|
4465
4466
|
alpha: n.fillAlpha * a
|
|
4466
4467
|
});
|
|
4467
|
-
} else t.type !==
|
|
4468
|
+
} else t.type !== L.LINE && (this.path(e, t), e.fill({
|
|
4468
4469
|
color: r,
|
|
4469
4470
|
alpha: 0
|
|
4470
4471
|
}));
|
|
@@ -4494,7 +4495,7 @@ var zr = class {
|
|
|
4494
4495
|
}
|
|
4495
4496
|
shapesAt(e) {
|
|
4496
4497
|
return this.shapes.filter((t) => {
|
|
4497
|
-
let n =
|
|
4498
|
+
let n = H(t.points);
|
|
4498
4499
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
4499
4500
|
}).map((e) => e.id);
|
|
4500
4501
|
}
|
|
@@ -4521,7 +4522,7 @@ var zr = class {
|
|
|
4521
4522
|
}, this.ensurePreview(), this.previewG.clear();
|
|
4522
4523
|
let i = {
|
|
4523
4524
|
id: "__preview__",
|
|
4524
|
-
type: e === "ellipse" ?
|
|
4525
|
+
type: e === "ellipse" ? L.ELLIPSE : L.RECTANGLE,
|
|
4525
4526
|
points: [t, n],
|
|
4526
4527
|
style: r
|
|
4527
4528
|
}, a = this.strokeW(i);
|
|
@@ -4552,7 +4553,7 @@ var zr = class {
|
|
|
4552
4553
|
}, this.ensurePreview(), this.previewG.clear(), !e.length) return;
|
|
4553
4554
|
let o = t ? [...e, t] : e, s = {
|
|
4554
4555
|
id: "__preview__",
|
|
4555
|
-
type: r ?
|
|
4556
|
+
type: r ? L.POLYGON : L.LINE,
|
|
4556
4557
|
points: o,
|
|
4557
4558
|
style: n
|
|
4558
4559
|
}, c = this.strokeW(s);
|
|
@@ -4578,7 +4579,7 @@ var zr = class {
|
|
|
4578
4579
|
previewScalarMask(e, t) {
|
|
4579
4580
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
4580
4581
|
let n = In(e, t.length === 7 ? `${t}99` : t);
|
|
4581
|
-
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture =
|
|
4582
|
+
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = ie.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new re(this.previewMaskTexture), this.previewLayer.addChildAt(this.previewMaskSprite, 0)), this.previewMaskSprite.x = e.ox, this.previewMaskSprite.y = e.oy, this.previewMaskSprite.width = n.width / e.scale, this.previewMaskSprite.height = n.height / e.scale;
|
|
4582
4583
|
}
|
|
4583
4584
|
previewMarquee(e, t) {
|
|
4584
4585
|
this.ensurePreview(), this.marqueeG.clear();
|
|
@@ -4623,27 +4624,27 @@ var zr = class {
|
|
|
4623
4624
|
}
|
|
4624
4625
|
path(e, t) {
|
|
4625
4626
|
let { type: n, points: r } = t;
|
|
4626
|
-
if (n ===
|
|
4627
|
+
if (n === L.POINT) {
|
|
4627
4628
|
e.circle(r[0].x, r[0].y, this.pointRadius(t));
|
|
4628
4629
|
return;
|
|
4629
4630
|
}
|
|
4630
|
-
if (n ===
|
|
4631
|
-
let t =
|
|
4631
|
+
if (n === L.RECTANGLE) {
|
|
4632
|
+
let t = H(r);
|
|
4632
4633
|
e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
|
|
4633
4634
|
return;
|
|
4634
4635
|
}
|
|
4635
|
-
if (n ===
|
|
4636
|
-
let t =
|
|
4636
|
+
if (n === L.ELLIPSE) {
|
|
4637
|
+
let t = H(r);
|
|
4637
4638
|
e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
|
|
4638
4639
|
return;
|
|
4639
4640
|
}
|
|
4640
4641
|
let i = r.flatMap((e) => [e.x, e.y]);
|
|
4641
|
-
e.poly(i, n !==
|
|
4642
|
+
e.poly(i, n !== L.LINE);
|
|
4642
4643
|
}
|
|
4643
4644
|
dashedStrokeShape(e, t, n, r, i, a) {
|
|
4644
4645
|
let { type: o, points: s } = t;
|
|
4645
|
-
if (o ===
|
|
4646
|
-
let t =
|
|
4646
|
+
if (o === L.RECTANGLE) {
|
|
4647
|
+
let t = H(s);
|
|
4647
4648
|
this.strokeDashedPolyline(e, [
|
|
4648
4649
|
{
|
|
4649
4650
|
x: t.minX,
|
|
@@ -4664,8 +4665,8 @@ var zr = class {
|
|
|
4664
4665
|
], !0, n, r, i, a);
|
|
4665
4666
|
return;
|
|
4666
4667
|
}
|
|
4667
|
-
if (o ===
|
|
4668
|
-
let t =
|
|
4668
|
+
if (o === L.ELLIPSE) {
|
|
4669
|
+
let t = H(s), o = (t.minX + t.maxX) / 2, c = (t.minY + t.maxY) / 2, l = (t.maxX - t.minX) / 2, u = (t.maxY - t.minY) / 2, d = Array.from({ length: 96 }, (e, t) => {
|
|
4669
4670
|
let n = t / 96 * Math.PI * 2;
|
|
4670
4671
|
return {
|
|
4671
4672
|
x: o + Math.cos(n) * l,
|
|
@@ -4675,7 +4676,7 @@ var zr = class {
|
|
|
4675
4676
|
this.strokeDashedPolyline(e, d, !0, n, r, i, a);
|
|
4676
4677
|
return;
|
|
4677
4678
|
}
|
|
4678
|
-
this.strokeDashedPolyline(e, s, o !==
|
|
4679
|
+
this.strokeDashedPolyline(e, s, o !== L.LINE, n, r, i, a);
|
|
4679
4680
|
}
|
|
4680
4681
|
strokeDashedPolyline(e, t, n, r, i, a, o) {
|
|
4681
4682
|
if (t.length < 2) return;
|
|
@@ -4716,7 +4717,7 @@ var zr = class {
|
|
|
4716
4717
|
}
|
|
4717
4718
|
drawSelectionBorders() {
|
|
4718
4719
|
this.selLayer.position.set(0, 0);
|
|
4719
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
4720
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && z(t)) : [];
|
|
4720
4721
|
if (this.selectionBorderGfx.length !== t.length) {
|
|
4721
4722
|
for (let e of this.selectionBorderGfx) e.destroy();
|
|
4722
4723
|
this.selectionBorderGfx = t.map(() => {
|
|
@@ -4736,7 +4737,7 @@ var zr = class {
|
|
|
4736
4737
|
updateSelectionBordersLive(e) {
|
|
4737
4738
|
let t = new Set(this.selected), n = 1.5 / this.world.scale.x, r = 0;
|
|
4738
4739
|
for (let i of this.shapes) {
|
|
4739
|
-
if (!t.has(i.id) || !
|
|
4740
|
+
if (!t.has(i.id) || !z(i)) continue;
|
|
4740
4741
|
let a = this.selectionBorderGfx[r++];
|
|
4741
4742
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4742
4743
|
width: n,
|
|
@@ -4759,7 +4760,7 @@ var zr = class {
|
|
|
4759
4760
|
}
|
|
4760
4761
|
setTransformerOutline(e) {
|
|
4761
4762
|
let t = e.maxX - e.minX, n = e.maxY - e.minY;
|
|
4762
|
-
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(
|
|
4763
|
+
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(me([{
|
|
4763
4764
|
x: e.minX,
|
|
4764
4765
|
y: e.minY
|
|
4765
4766
|
}, {
|
|
@@ -4777,10 +4778,10 @@ var zr = class {
|
|
|
4777
4778
|
return kr(this.viewport.scale);
|
|
4778
4779
|
}
|
|
4779
4780
|
rotationHandleScreenPoint(e) {
|
|
4780
|
-
return this.imgToScreen(
|
|
4781
|
+
return this.imgToScreen(Te(e, this.rotationHandleGap()));
|
|
4781
4782
|
}
|
|
4782
4783
|
setRotationConnector(e) {
|
|
4783
|
-
let t = this.imgToScreen(
|
|
4784
|
+
let t = this.imgToScreen(Se(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
4784
4785
|
this.rotLineNode || (this.rotLineNode = new I(), this.rotLineNode.eventMode = "none", this.handleLayer.addChild(this.rotLineNode)), this.rotLineNode.clear(), this.rotLineNode.moveTo(t.x, t.y).lineTo(n.x, n.y).stroke({
|
|
4785
4786
|
width: 1,
|
|
4786
4787
|
color: 2001125
|
|
@@ -4799,12 +4800,12 @@ var zr = class {
|
|
|
4799
4800
|
for (let e of this.midNodes) e.destroy();
|
|
4800
4801
|
if (this.ghostNode?.destroy(), this.ghostNode = null, this.rotNode?.destroy(), this.rotNode = null, this.rotLineNode?.destroy(), this.rotLineNode = null, this.transformerOutline?.destroy(), this.transformerOutline = null, this.handleNodes = [], this.vertexNodes = [], this.midNodes = [], !this.transformEnabled) return;
|
|
4801
4802
|
let e = wr(this.shapes, this.selected);
|
|
4802
|
-
if (e.length === 0 || e.length === 1 && e[0].type ===
|
|
4803
|
-
let t = e.length === 1 && (e[0].type ===
|
|
4803
|
+
if (e.length === 0 || e.length === 1 && e[0].type === L.POINT) return;
|
|
4804
|
+
let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = H(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? we(r.points) : V.map((e) => ue(e, n));
|
|
4804
4805
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
4805
4806
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
4806
|
-
for (let e of t ? [] :
|
|
4807
|
-
let t = this.imgToScreen(i[
|
|
4807
|
+
for (let e of t ? [] : V) {
|
|
4808
|
+
let t = this.imgToScreen(i[V.indexOf(e)]), n = new I();
|
|
4808
4809
|
n.rect(-4, -4, 8, 8).fill({ color: 16777215 }).stroke({
|
|
4809
4810
|
width: 1,
|
|
4810
4811
|
color: 2001125
|
|
@@ -4816,7 +4817,7 @@ var zr = class {
|
|
|
4816
4817
|
this.activeDrag = {
|
|
4817
4818
|
kind: "resize",
|
|
4818
4819
|
anchor: e,
|
|
4819
|
-
box:
|
|
4820
|
+
box: H(n.flatMap((e) => e.points)),
|
|
4820
4821
|
shapes: n.map((e) => ({
|
|
4821
4822
|
id: e.id,
|
|
4822
4823
|
points: e.points
|
|
@@ -4825,7 +4826,7 @@ var zr = class {
|
|
|
4825
4826
|
}), this.handleLayer.addChild(n), this.handleNodes.push(n);
|
|
4826
4827
|
}
|
|
4827
4828
|
if (t) {
|
|
4828
|
-
let e = t, n = e.points, r = e.type ===
|
|
4829
|
+
let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new I();
|
|
4829
4830
|
a.circle(0, 0, i * .8).fill({
|
|
4830
4831
|
color: 16777215,
|
|
4831
4832
|
alpha: .6
|
|
@@ -4889,8 +4890,8 @@ var zr = class {
|
|
|
4889
4890
|
}), this.handleLayer.addChild(s), this.vertexNodes.push(s);
|
|
4890
4891
|
});
|
|
4891
4892
|
}
|
|
4892
|
-
if (e.length === 1 && e[0].type ===
|
|
4893
|
-
let t = e[0], n =
|
|
4893
|
+
if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
|
|
4894
|
+
let t = e[0], n = Ce(t.points), r = this.rotationHandleScreenPoint(t.points), i = new I();
|
|
4894
4895
|
i.circle(0, 0, 6).fill({ color: 16777215 }).stroke({
|
|
4895
4896
|
width: 1.5,
|
|
4896
4897
|
color: 2001125
|
|
@@ -4910,17 +4911,17 @@ var zr = class {
|
|
|
4910
4911
|
}
|
|
4911
4912
|
beginMove(e, t) {
|
|
4912
4913
|
let n = Sr(this.shapes, t, e);
|
|
4913
|
-
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type ===
|
|
4914
|
+
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4914
4915
|
}
|
|
4915
4916
|
repositionHandlesForBox(e) {
|
|
4916
|
-
|
|
4917
|
-
let r = this.imgToScreen(
|
|
4917
|
+
V.forEach((t, n) => {
|
|
4918
|
+
let r = this.imgToScreen(ue(t, e)), i = this.handleNodes[n];
|
|
4918
4919
|
i && this.layoutResizeHandle(i, r, 0);
|
|
4919
4920
|
}), this.setTransformerOutline(e);
|
|
4920
4921
|
}
|
|
4921
4922
|
repositionOrientedHandles(e) {
|
|
4922
4923
|
let t = this.orientedHandleAngle(e);
|
|
4923
|
-
if (
|
|
4924
|
+
if (we(e).forEach((e, n) => {
|
|
4924
4925
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
4925
4926
|
i && this.layoutResizeHandle(i, r, t);
|
|
4926
4927
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -4955,7 +4956,7 @@ var zr = class {
|
|
|
4955
4956
|
]);
|
|
4956
4957
|
}
|
|
4957
4958
|
resetMoveOffsets() {
|
|
4958
|
-
for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !==
|
|
4959
|
+
for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !== L.POINT && t.position.set(0, 0);
|
|
4959
4960
|
this.selLayer.position.set(0, 0);
|
|
4960
4961
|
}
|
|
4961
4962
|
commitTransformUpdates(e) {
|
|
@@ -4982,21 +4983,21 @@ var zr = class {
|
|
|
4982
4983
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4983
4984
|
for (let e of t.shapes) {
|
|
4984
4985
|
let t = this.nodes.get(e.id);
|
|
4985
|
-
t && (this.shapes.find((t) => t.id === e.id)?.type ===
|
|
4986
|
+
t && (this.shapes.find((t) => t.id === e.id)?.type === L.POINT ? t.position.set(e.points[0].x + n, e.points[0].y + r) : t.position.set(n, r));
|
|
4986
4987
|
}
|
|
4987
4988
|
} else for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
4988
4989
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
4989
4990
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandlesForBox(i);
|
|
4990
|
-
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type ===
|
|
4991
|
-
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
4991
|
+
let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
|
|
4992
|
+
(t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
4992
4993
|
} else if (t.kind === "rotate") {
|
|
4993
4994
|
this.repositionOrientedHandles(r[0].points);
|
|
4994
4995
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4995
|
-
e && (e.type ===
|
|
4996
|
+
e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
|
|
4996
4997
|
} else {
|
|
4997
4998
|
i && this.repositionHandlesForBox(i);
|
|
4998
4999
|
let e = this.shapes.find((e) => e.id === t.id);
|
|
4999
|
-
this.repositionPolygonHandles(r[0].points, e?.type ===
|
|
5000
|
+
this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
|
|
5000
5001
|
}
|
|
5001
5002
|
}
|
|
5002
5003
|
cancelTransform() {
|
|
@@ -5033,43 +5034,46 @@ function Br({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
|
|
|
5033
5034
|
docChange: i
|
|
5034
5035
|
};
|
|
5035
5036
|
}
|
|
5036
|
-
function Vr({
|
|
5037
|
+
function Vr({ keepZoomOnImageChange: e, viewportSeeded: t }) {
|
|
5038
|
+
return e && t;
|
|
5039
|
+
}
|
|
5040
|
+
function Hr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImageUrl: i, makeCallbacks: a, viewRef: o, readOnlyRef: s, toolRef: c, renderShapesRef: l, coordinateSizeRef: u, imageSizeRef: d, selRef: f, regionOverlayRef: p, dimmedRef: m, syncMinimap: h, setImage: g, setImageVisible: _, setReady: v, setImageStatus: y, onContextMenuRequest: b }) {
|
|
5037
5041
|
let x = j(i);
|
|
5038
5042
|
x.current = i;
|
|
5039
5043
|
let S = j(r);
|
|
5040
5044
|
S.current = r;
|
|
5041
|
-
let C = j(null), w = j(null), E = j(!1), D = j(null), O = j(a);
|
|
5042
|
-
|
|
5043
|
-
let
|
|
5044
|
-
|
|
5045
|
+
let C = j(null), w = j(null), E = j(!1), D = j(null), O = j(!1), k = j(a);
|
|
5046
|
+
k.current = a;
|
|
5047
|
+
let A = j(b);
|
|
5048
|
+
A.current = b, T(() => {
|
|
5045
5049
|
let r = t.current;
|
|
5046
5050
|
if (!r) return;
|
|
5047
|
-
let i = !1, a = null, b = null, T =
|
|
5048
|
-
return n.current =
|
|
5051
|
+
let i = !1, a = null, b = null, T = k.current(), j = e === "konva" ? new Pr(r, T) : new zr(r, T);
|
|
5052
|
+
return n.current = j, O.current = !1, (async () => {
|
|
5049
5053
|
try {
|
|
5050
|
-
await
|
|
5054
|
+
await j.init();
|
|
5051
5055
|
} catch (e) {
|
|
5052
5056
|
i || y("error", lr(e));
|
|
5053
5057
|
return;
|
|
5054
5058
|
}
|
|
5055
5059
|
if (i) return;
|
|
5056
|
-
if (
|
|
5060
|
+
if (j.setFilter(o.current.brightness, o.current.contrast), j.setRenderDefaults({ strokeWidth: o.current.strokeSize }), j.setImageSmoothing(o.current.imageSmoothing), j.setTransformEnabled(!s.current), E.current = !0, x.current) {
|
|
5057
5061
|
let e = x.current, t = S.current;
|
|
5058
5062
|
y("loading");
|
|
5059
5063
|
let n = null;
|
|
5060
5064
|
try {
|
|
5061
|
-
n = await
|
|
5065
|
+
n = await j.setImage(e, u.current, d.current);
|
|
5062
5066
|
} catch (t) {
|
|
5063
5067
|
!i && x.current === e && y("error", lr(t));
|
|
5064
5068
|
}
|
|
5065
5069
|
if (i) return;
|
|
5066
5070
|
if (n !== null) {
|
|
5067
5071
|
C.current = e, w.current = t, g({
|
|
5068
|
-
w:
|
|
5069
|
-
h:
|
|
5070
|
-
}), _(!0),
|
|
5072
|
+
w: j.imageWidth,
|
|
5073
|
+
h: j.imageHeight
|
|
5074
|
+
}), _(!0), j.setShapes(l.current, f.current), j.setOverlays(o.current.showRegionMask ? p.current : null, m.current);
|
|
5071
5075
|
let r = D.current;
|
|
5072
|
-
r?.viewport && (r.imageUrl === C.current || o.current.keepZoomOnImageChange) ?
|
|
5076
|
+
r?.viewport && (r.imageUrl === C.current || o.current.keepZoomOnImageChange) ? j.applyViewport(r.viewport) : j.fit(), O.current = !0, h(), v(!0);
|
|
5073
5077
|
let a = () => x.current === e;
|
|
5074
5078
|
n ? a() && y("ready") : or(e).then((e) => {
|
|
5075
5079
|
!i && a() && y("error", e);
|
|
@@ -5079,25 +5083,25 @@ function Vr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5079
5083
|
let e = (e, t) => Math.exp(-Math.sign(e) * Math.min(Math.abs(e) * .01, .1) * t);
|
|
5080
5084
|
a = (t) => {
|
|
5081
5085
|
t.preventDefault();
|
|
5082
|
-
let n =
|
|
5086
|
+
let n = j.dom.getBoundingClientRect(), r = o.current.zoomSensitivity ?? 1;
|
|
5083
5087
|
if (t.ctrlKey || t.metaKey) {
|
|
5084
|
-
|
|
5088
|
+
j.zoomAt(t.clientX - n.left, t.clientY - n.top, e(t.deltaY, r));
|
|
5085
5089
|
return;
|
|
5086
5090
|
}
|
|
5087
5091
|
if (!o.current.wheelZoom) {
|
|
5088
|
-
let e =
|
|
5089
|
-
|
|
5092
|
+
let e = j.viewport;
|
|
5093
|
+
j.applyViewport({
|
|
5090
5094
|
scale: e.scale,
|
|
5091
5095
|
x: e.x - t.deltaX,
|
|
5092
5096
|
y: e.y - t.deltaY
|
|
5093
5097
|
});
|
|
5094
5098
|
return;
|
|
5095
5099
|
}
|
|
5096
|
-
|
|
5097
|
-
},
|
|
5100
|
+
j.zoomAt(t.clientX - n.left, t.clientY - n.top, e(t.deltaY, r));
|
|
5101
|
+
}, j.dom.addEventListener("wheel", a, { passive: !1 }), b = (e) => {
|
|
5098
5102
|
if (e.preventDefault(), c.current === q.ASSISTANT_POINT && e.altKey) return;
|
|
5099
|
-
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a =
|
|
5100
|
-
|
|
5103
|
+
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a = j.viewport;
|
|
5104
|
+
A.current({
|
|
5101
5105
|
x: n,
|
|
5102
5106
|
y: i,
|
|
5103
5107
|
img: {
|
|
@@ -5105,12 +5109,12 @@ function Vr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5105
5109
|
y: (i - a.y) / a.scale
|
|
5106
5110
|
}
|
|
5107
5111
|
});
|
|
5108
|
-
},
|
|
5112
|
+
}, j.dom.addEventListener("contextmenu", b);
|
|
5109
5113
|
})(), () => {
|
|
5110
5114
|
i = !0, E.current = !1, D.current = {
|
|
5111
5115
|
imageUrl: C.current ?? "",
|
|
5112
|
-
viewport:
|
|
5113
|
-
}, n.current = null, a &&
|
|
5116
|
+
viewport: j.viewport
|
|
5117
|
+
}, n.current = null, a && j.dom && j.dom.removeEventListener("wheel", a), b && j.dom && j.dom.removeEventListener("contextmenu", b), j.destroy();
|
|
5114
5118
|
};
|
|
5115
5119
|
}, [e]), T(() => {
|
|
5116
5120
|
let e = n.current;
|
|
@@ -5159,7 +5163,10 @@ function Vr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5159
5163
|
w.current = r, g({
|
|
5160
5164
|
w: e.imageWidth,
|
|
5161
5165
|
h: e.imageHeight
|
|
5162
|
-
}), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current),
|
|
5166
|
+
}), _(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showRegionMask ? p.current : null, m.current), Vr({
|
|
5167
|
+
keepZoomOnImageChange: o.current.keepZoomOnImageChange,
|
|
5168
|
+
viewportSeeded: O.current
|
|
5169
|
+
}) || e.fit(), O.current = !0, h(), v(!0), a();
|
|
5163
5170
|
})(), () => {
|
|
5164
5171
|
c = !0;
|
|
5165
5172
|
};
|
|
@@ -5167,19 +5174,19 @@ function Vr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5167
5174
|
}
|
|
5168
5175
|
//#endregion
|
|
5169
5176
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
5170
|
-
var
|
|
5171
|
-
function
|
|
5177
|
+
var Ur = .05, Wr = 20;
|
|
5178
|
+
function Gr(e) {
|
|
5172
5179
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
5173
5180
|
return r === 0 ? Math.abs(t) < 10 || Math.abs(n) < 10 || !Number.isInteger(t) || !Number.isInteger(n) : r === 1 ? !1 : !Number.isInteger(t) || !Number.isInteger(n);
|
|
5174
5181
|
}
|
|
5175
|
-
function
|
|
5182
|
+
function Kr(e) {
|
|
5176
5183
|
let t = e.currentTarget.getBoundingClientRect();
|
|
5177
5184
|
return {
|
|
5178
5185
|
x: e.clientX - t.left,
|
|
5179
5186
|
y: e.clientY - t.top
|
|
5180
5187
|
};
|
|
5181
5188
|
}
|
|
5182
|
-
function
|
|
5189
|
+
function qr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
5183
5190
|
let i = j(null), a = !!t && t.w > 0 && t.h > 0, o = a ? Math.min(r / t.w, r / t.h) : 1, s = a ? t.w * o : 0, c = a ? t.h * o : 0, l = a ? (r - s) / 2 : 0, u = a ? (r - c) / 2 : 0, d = w(() => {
|
|
5184
5191
|
let t = e.current;
|
|
5185
5192
|
if (!t) return null;
|
|
@@ -5217,7 +5224,7 @@ function Kr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5217
5224
|
let n = e.current, r = d();
|
|
5218
5225
|
if (!n || !r) return;
|
|
5219
5226
|
t.preventDefault(), t.stopPropagation();
|
|
5220
|
-
let a =
|
|
5227
|
+
let a = Kr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
|
|
5221
5228
|
offsetX: a.x - r.x,
|
|
5222
5229
|
offsetY: a.y - r.y
|
|
5223
5230
|
} : {
|
|
@@ -5234,7 +5241,7 @@ function Kr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5234
5241
|
d
|
|
5235
5242
|
]), m = w((t) => {
|
|
5236
5243
|
let n = i.current, r = e.current;
|
|
5237
|
-
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(
|
|
5244
|
+
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(Kr(t), r.viewport.scale, n));
|
|
5238
5245
|
}, [f, e]), h = w((e) => {
|
|
5239
5246
|
let t = i.current;
|
|
5240
5247
|
!t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
|
|
@@ -5242,8 +5249,8 @@ function Kr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5242
5249
|
let r = e.current;
|
|
5243
5250
|
if (!r || !n) return;
|
|
5244
5251
|
t.preventDefault(), t.stopPropagation();
|
|
5245
|
-
let i =
|
|
5246
|
-
f(
|
|
5252
|
+
let i = Gr(t.nativeEvent) ? 2.5 : 1, a = t.deltaY * i, o = 1.05, s = a > 0 ? r.viewport.scale / o : r.viewport.scale * o, c = Math.max(Ur, Math.min(Wr, s));
|
|
5253
|
+
f(Kr(t), c);
|
|
5247
5254
|
}, [
|
|
5248
5255
|
f,
|
|
5249
5256
|
e,
|
|
@@ -5280,15 +5287,15 @@ function Kr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5280
5287
|
}
|
|
5281
5288
|
//#endregion
|
|
5282
5289
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
5283
|
-
function
|
|
5290
|
+
function Jr(e, t, n) {
|
|
5284
5291
|
if (!(!e || !n.length)) {
|
|
5285
|
-
if (t.type ===
|
|
5292
|
+
if (t.type === L.POINT) {
|
|
5286
5293
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
5287
5294
|
return;
|
|
5288
5295
|
}
|
|
5289
|
-
if (t.type ===
|
|
5290
|
-
let r =
|
|
5291
|
-
if (t.type ===
|
|
5296
|
+
if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
|
|
5297
|
+
let r = H(n);
|
|
5298
|
+
if (t.type === L.ELLIPSE) {
|
|
5292
5299
|
e.setAttribute("cx", String((r.minX + r.maxX) / 2)), e.setAttribute("cy", String((r.minY + r.maxY) / 2)), e.setAttribute("rx", String((r.maxX - r.minX) / 2)), e.setAttribute("ry", String((r.maxY - r.minY) / 2));
|
|
5293
5300
|
return;
|
|
5294
5301
|
}
|
|
@@ -5298,7 +5305,7 @@ function qr(e, t, n) {
|
|
|
5298
5305
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
5299
5306
|
}
|
|
5300
5307
|
}
|
|
5301
|
-
function
|
|
5308
|
+
function Yr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
5302
5309
|
let s = j(/* @__PURE__ */ new Map());
|
|
5303
5310
|
return {
|
|
5304
5311
|
registerMinimapShape: w((e, t) => {
|
|
@@ -5307,13 +5314,13 @@ function Jr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
5307
5314
|
applyMinimapPreview: w((e) => {
|
|
5308
5315
|
let n = t.current.getShapes();
|
|
5309
5316
|
if (!e.length) {
|
|
5310
|
-
for (let e of n)
|
|
5317
|
+
for (let e of n) Jr(s.current.get(e.id), e, e.points);
|
|
5311
5318
|
return;
|
|
5312
5319
|
}
|
|
5313
5320
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
5314
5321
|
for (let t of e) {
|
|
5315
5322
|
let e = r.get(t.id);
|
|
5316
|
-
e &&
|
|
5323
|
+
e && Jr(s.current.get(e.id), e, t.points);
|
|
5317
5324
|
}
|
|
5318
5325
|
}, [t]),
|
|
5319
5326
|
syncMinimap: w(() => {
|
|
@@ -5342,15 +5349,15 @@ function Jr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
5342
5349
|
}
|
|
5343
5350
|
//#endregion
|
|
5344
5351
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
5345
|
-
var
|
|
5346
|
-
function
|
|
5352
|
+
var Xr = 12;
|
|
5353
|
+
function Zr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
5347
5354
|
let s = j(0), c = j(!0), l = j(n), u = j(a), d = j(o);
|
|
5348
5355
|
l.current = n, u.current = a, d.current = o, T(() => (c.current = !0, () => {
|
|
5349
5356
|
c.current = !1;
|
|
5350
5357
|
}), []), T(() => {
|
|
5351
5358
|
s.current = 0;
|
|
5352
5359
|
}, [a]);
|
|
5353
|
-
let f = w(() => r(e.getShapes().filter((e) =>
|
|
5360
|
+
let f = w(() => r(e.getShapes().filter((e) => z(e)).map((e) => e.id)), [e, r]), p = w(() => r([]), [r]), m = w(() => e.getShapes().filter((e) => t.current.includes(e.id) && oe(e)), [e, t]), h = w(() => {
|
|
5354
5361
|
if (n || !t.current.length) return;
|
|
5355
5362
|
let i = m().map((e) => e.id);
|
|
5356
5363
|
i.length && (e.remove(i), r([]));
|
|
@@ -5374,15 +5381,15 @@ function Xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5374
5381
|
if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
|
|
5375
5382
|
let f, p, m = n.shapes.flatMap((e) => e.points);
|
|
5376
5383
|
if (t && m.length) {
|
|
5377
|
-
let e =
|
|
5384
|
+
let e = H(m);
|
|
5378
5385
|
f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
|
|
5379
5386
|
} else {
|
|
5380
|
-
let e = !!n.documentId && n.documentId !== a, t = Bt(s.current, e,
|
|
5387
|
+
let e = !!n.documentId && n.documentId !== a, t = Bt(s.current, e, Xr);
|
|
5381
5388
|
f = t.offset, s.current = t.nextPasteCount, p = f;
|
|
5382
5389
|
}
|
|
5383
5390
|
let h = n.shapes.map((e) => ({
|
|
5384
5391
|
...e,
|
|
5385
|
-
id:
|
|
5392
|
+
id: le(),
|
|
5386
5393
|
points: e.points.map((e) => ({
|
|
5387
5394
|
x: e.x + f,
|
|
5388
5395
|
y: e.y + p
|
|
@@ -5400,10 +5407,10 @@ function Xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5400
5407
|
if (n || !t.current.length) return;
|
|
5401
5408
|
let i = m().map((e) => ({
|
|
5402
5409
|
...e,
|
|
5403
|
-
id:
|
|
5410
|
+
id: le(),
|
|
5404
5411
|
points: e.points.map((e) => ({
|
|
5405
|
-
x: e.x +
|
|
5406
|
-
y: e.y +
|
|
5412
|
+
x: e.x + Xr,
|
|
5413
|
+
y: e.y + Xr
|
|
5407
5414
|
}))
|
|
5408
5415
|
}));
|
|
5409
5416
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -5431,7 +5438,7 @@ function Xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5431
5438
|
m
|
|
5432
5439
|
]), S = w((r, i) => {
|
|
5433
5440
|
if (n || !t.current.length) return !1;
|
|
5434
|
-
let a = e.getShapes().filter((e) => t.current.includes(e.id) &&
|
|
5441
|
+
let a = e.getShapes().filter((e) => t.current.includes(e.id) && oe(e));
|
|
5435
5442
|
return a.length ? (e.update(a.map((e) => ({
|
|
5436
5443
|
...e,
|
|
5437
5444
|
points: e.points.map((e) => ({
|
|
@@ -5443,7 +5450,7 @@ function Xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5443
5450
|
e,
|
|
5444
5451
|
n,
|
|
5445
5452
|
t
|
|
5446
|
-
]), C = w(() => m().filter((e) => e.type ===
|
|
5453
|
+
]), C = w(() => m().filter((e) => e.type === L.POLYGON || e.type === L.RECTANGLE || e.type === L.ROTATED_RECTANGLE || e.type === L.ELLIPSE), [m]);
|
|
5447
5454
|
return {
|
|
5448
5455
|
selectAll: f,
|
|
5449
5456
|
clearSelection: p,
|
|
@@ -5466,8 +5473,8 @@ function Xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5466
5473
|
let o = Fn(a, 1);
|
|
5467
5474
|
if (!o.length) return;
|
|
5468
5475
|
let s = t[0], c = o.map((e) => ({
|
|
5469
|
-
id:
|
|
5470
|
-
type:
|
|
5476
|
+
id: le(),
|
|
5477
|
+
type: L.POLYGON,
|
|
5471
5478
|
points: e,
|
|
5472
5479
|
style: s.style,
|
|
5473
5480
|
meta: s.meta
|
|
@@ -5484,7 +5491,7 @@ function Xr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5484
5491
|
}
|
|
5485
5492
|
//#endregion
|
|
5486
5493
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
5487
|
-
function
|
|
5494
|
+
function Qr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
5488
5495
|
let o = j(null), s = j(null), c = w(() => {
|
|
5489
5496
|
o.current?.(), o.current = null;
|
|
5490
5497
|
}, []), l = w((t, n = r) => {
|
|
@@ -5515,7 +5522,7 @@ function Zr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5515
5522
|
if (!r.length) return;
|
|
5516
5523
|
let i = e.current;
|
|
5517
5524
|
if (!i) return;
|
|
5518
|
-
let a = gn(
|
|
5525
|
+
let a = gn(H(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
5519
5526
|
a && l(a);
|
|
5520
5527
|
}, [
|
|
5521
5528
|
t,
|
|
@@ -5556,28 +5563,28 @@ function Zr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5556
5563
|
}
|
|
5557
5564
|
//#endregion
|
|
5558
5565
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
5559
|
-
var
|
|
5566
|
+
var $r = "__draft_preview__", ei = new Set([
|
|
5560
5567
|
"copy",
|
|
5561
5568
|
"selectAll",
|
|
5562
5569
|
"clearSelection",
|
|
5563
5570
|
"zoomToSelection"
|
|
5564
5571
|
]);
|
|
5565
|
-
function
|
|
5572
|
+
function ti(e, t) {
|
|
5566
5573
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5567
5574
|
}
|
|
5568
|
-
function
|
|
5569
|
-
let
|
|
5575
|
+
function ni({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: o, draftMeta: s, readOnly: c, disableMarquee: l, locked: u, onLockedInteraction: d, onDrawAttemptWithoutDraft: p, onIdleEscape: m, overrideShapeInteraction: h, defaultViewSettings: g, viewSettings: _, onViewSettingsChange: v, showMinimap: y = !0, minimapPosition: b = "bottom-left", showViewSettings: C = !0, getContextMenuItems: A, strings: N, viewSettingItems: P, canMergeSelection: ee, brushSize: F = 20, zoomBound: I, zoomAnimationDuration: te = 300, decorationShapes: ne, regionMask: re, overlayMarkers: ie, renderOverlayMarker: ae, onOverlayMarkerClick: se, renderImageOverlay: ce, getSelectionLabel: B, hideSelectionLabelDot: V, formatSelectionInfo: H, externalTools: ue, assistant: de, keymap: fe, handleRef: pe, backend: me = "pixi", onActiveToolChange: he, onSelectionChange: ge, onEditingChange: _e, onShapesCreated: ve, onShapesUpdated: ye, onShapesDeleted: be, onDrawSessionChange: xe, onDraftShapeChange: Se, onViewportChange: Ce, onShapesTransformPreview: we }) {
|
|
5576
|
+
let Te = j(null), U = j(null), Ee = j(null), De = j(null), Oe = j(null), ke = `${E()}-minimap`, [W, Ae] = M(null), [je, Me] = M(!1), [G, Ne] = M(!1), [Pe, Fe] = M(null), [Ie, Le] = M({
|
|
5570
5577
|
active: !1,
|
|
5571
5578
|
kind: "none",
|
|
5572
5579
|
canUndo: !1,
|
|
5573
5580
|
canRedo: !1
|
|
5574
5581
|
}), [Re, ze] = M(!0), [K, He] = M(!1), Ue = e?.id ?? "", Ge = e?.imageUrl ?? "", Ke = e?.displayImageUrl, qe = e?.coordinateSize, Je = e?.initialShapes, Xe = e?.initialSelectedIds, et = Ke ?? Ge, [tt, nt] = M("loading"), rt = tt === "loading" && e !== null && !et ? "missing" : tt, [it, at] = M(null), ot = w((e, t) => {
|
|
5575
5582
|
nt(e), at(e === "error" ? t ?? null : null);
|
|
5576
|
-
}, []), J =
|
|
5577
|
-
onShapesCreated:
|
|
5578
|
-
onShapesUpdated:
|
|
5579
|
-
onShapesDeleted:
|
|
5580
|
-
}), [st, ct] = M([]), Y = i ?? st, lt = i !== void 0, ut = k(() => new Map((
|
|
5583
|
+
}, []), J = Gn({
|
|
5584
|
+
onShapesCreated: ve,
|
|
5585
|
+
onShapesUpdated: ye,
|
|
5586
|
+
onShapesDeleted: be
|
|
5587
|
+
}), [st, ct] = M([]), Y = i ?? st, lt = i !== void 0, ut = k(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), dt = j(ut);
|
|
5581
5588
|
O(() => {
|
|
5582
5589
|
dt.current = ut;
|
|
5583
5590
|
}, [ut]);
|
|
@@ -5616,12 +5623,12 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5616
5623
|
}
|
|
5617
5624
|
vt.current?.(X);
|
|
5618
5625
|
}, [X]);
|
|
5619
|
-
let Ct = k(() => !
|
|
5626
|
+
let Ct = k(() => !W || !re ? null : cn(re, W.w, W.h), [W, re]), Tt = j(Ct);
|
|
5620
5627
|
Tt.current = Ct;
|
|
5621
5628
|
let Et = j(r);
|
|
5622
5629
|
Et.current = r;
|
|
5623
|
-
let Dt = j(
|
|
5624
|
-
Dt.current =
|
|
5630
|
+
let Dt = j(W);
|
|
5631
|
+
Dt.current = W;
|
|
5625
5632
|
let Ot = j(qe);
|
|
5626
5633
|
Ot.current = qe;
|
|
5627
5634
|
let kt = j(qe?.imageSize);
|
|
@@ -5654,23 +5661,23 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5654
5661
|
Ht.current = h;
|
|
5655
5662
|
let Ut = j(J);
|
|
5656
5663
|
Ut.current = J;
|
|
5657
|
-
let Wt = j(!1), Gt = j(
|
|
5658
|
-
let e =
|
|
5664
|
+
let Wt = j(!1), Gt = j("idle"), Kt = j(null), qt = w(() => {
|
|
5665
|
+
let e = U.current;
|
|
5659
5666
|
if (!e) return;
|
|
5660
5667
|
let t = jt.current, n = dt.current.get(t), r = ft.current;
|
|
5661
5668
|
e.setCursor(Jt({
|
|
5662
5669
|
tool: t,
|
|
5663
5670
|
externalToolCursor: n?.cursor,
|
|
5664
5671
|
isSpacePressed: Wt.current,
|
|
5665
|
-
interactionMode:
|
|
5666
|
-
rendererCursorHint:
|
|
5672
|
+
interactionMode: Gt.current,
|
|
5673
|
+
rendererCursorHint: Kt.current,
|
|
5667
5674
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
5668
5675
|
}));
|
|
5669
|
-
}, []),
|
|
5670
|
-
|
|
5671
|
-
}, [
|
|
5672
|
-
|
|
5673
|
-
}, [
|
|
5676
|
+
}, []), Yt = w((e) => {
|
|
5677
|
+
Gt.current !== e && (Gt.current = e, qt());
|
|
5678
|
+
}, [qt]), Xt = w((e) => {
|
|
5679
|
+
Kt.current !== e && (Kt.current = e, qt());
|
|
5680
|
+
}, [qt]), Zt = w((e) => {
|
|
5674
5681
|
let t = /* @__PURE__ */ new Set(), n = new Map(Ut.current.getShapes().map((e) => [e.id, e]));
|
|
5675
5682
|
return e.filter((e) => {
|
|
5676
5683
|
if (t.has(e)) return !1;
|
|
@@ -5678,7 +5685,7 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5678
5685
|
let r = n.get(e);
|
|
5679
5686
|
if (!r) return !1;
|
|
5680
5687
|
let i = Ht.current?.(r);
|
|
5681
|
-
return
|
|
5688
|
+
return z(i ? {
|
|
5682
5689
|
...r,
|
|
5683
5690
|
interaction: {
|
|
5684
5691
|
...r.interaction,
|
|
@@ -5686,95 +5693,95 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5686
5693
|
}
|
|
5687
5694
|
} : r);
|
|
5688
5695
|
});
|
|
5689
|
-
}, []),
|
|
5690
|
-
let t =
|
|
5691
|
-
|
|
5696
|
+
}, []), Qt = w((e) => {
|
|
5697
|
+
let t = Zt(e);
|
|
5698
|
+
ti(At.current, t) || (lt || ct(t), U.current?.setSelection(t), ge?.(t));
|
|
5692
5699
|
}, [
|
|
5693
|
-
|
|
5694
|
-
|
|
5700
|
+
Zt,
|
|
5701
|
+
ge,
|
|
5695
5702
|
lt
|
|
5696
|
-
]),
|
|
5697
|
-
|
|
5698
|
-
let [
|
|
5699
|
-
|
|
5700
|
-
let
|
|
5701
|
-
|
|
5703
|
+
]), $t = j(Qt);
|
|
5704
|
+
$t.current = Qt;
|
|
5705
|
+
let [en, tn] = M(null), nn = w((e) => tn(e), []), rn = j(nn);
|
|
5706
|
+
rn.current = nn;
|
|
5707
|
+
let an = j(null);
|
|
5708
|
+
an.current = en, T(() => {
|
|
5702
5709
|
if (!lt) return;
|
|
5703
|
-
let e =
|
|
5704
|
-
|
|
5710
|
+
let e = Zt(i);
|
|
5711
|
+
ti(i, e) || ge?.(e);
|
|
5705
5712
|
}, [
|
|
5706
5713
|
i,
|
|
5707
5714
|
J.shapes,
|
|
5708
|
-
|
|
5709
|
-
|
|
5715
|
+
Zt,
|
|
5716
|
+
ge,
|
|
5710
5717
|
lt
|
|
5711
5718
|
]);
|
|
5712
|
-
let
|
|
5713
|
-
|
|
5714
|
-
let { registerMinimapShape:
|
|
5715
|
-
engineRef:
|
|
5719
|
+
let on = j(Ce);
|
|
5720
|
+
on.current = Ce;
|
|
5721
|
+
let { registerMinimapShape: sn, applyMinimapPreview: ln, syncMinimap: un } = Yr({
|
|
5722
|
+
engineRef: U,
|
|
5716
5723
|
docRef: Ut,
|
|
5717
|
-
overlayRef:
|
|
5718
|
-
zoomLabelRef:
|
|
5719
|
-
minimapRectRef:
|
|
5724
|
+
overlayRef: De,
|
|
5725
|
+
zoomLabelRef: Oe,
|
|
5726
|
+
minimapRectRef: Ee,
|
|
5720
5727
|
minimapSize: 204,
|
|
5721
|
-
onViewportChangeRef:
|
|
5722
|
-
}),
|
|
5723
|
-
|
|
5724
|
-
let
|
|
5725
|
-
t ?
|
|
5726
|
-
}, []),
|
|
5728
|
+
onViewportChangeRef: on
|
|
5729
|
+
}), dn = j(/* @__PURE__ */ new Map()), fn = j(H);
|
|
5730
|
+
fn.current = H;
|
|
5731
|
+
let pn = w((e, t) => {
|
|
5732
|
+
t ? dn.current.set(e, t) : dn.current.delete(e);
|
|
5733
|
+
}, []), mn = j(null), [hn, gn] = M(null), _n = w((e) => {
|
|
5727
5734
|
if (!e.length) return;
|
|
5728
5735
|
let t = new Map(Ut.current.getShapes().map((e) => [e.id, e]));
|
|
5729
|
-
|
|
5736
|
+
mn.current && t.set(mn.current.id, mn.current);
|
|
5730
5737
|
for (let { id: n, points: r } of e) {
|
|
5731
|
-
let e =
|
|
5738
|
+
let e = dn.current.get(n), i = t.get(n);
|
|
5732
5739
|
if (!e || !i) continue;
|
|
5733
5740
|
let a = bt(e, r);
|
|
5734
5741
|
if (a) {
|
|
5735
5742
|
let e = xt(i, r);
|
|
5736
|
-
a.textContent =
|
|
5743
|
+
a.textContent = fn.current?.(e) ?? St(e);
|
|
5737
5744
|
}
|
|
5738
5745
|
}
|
|
5739
|
-
}, []),
|
|
5740
|
-
|
|
5746
|
+
}, []), bn = w((e) => {
|
|
5747
|
+
ln(e), _n(e), we?.(e);
|
|
5741
5748
|
}, [
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
]),
|
|
5746
|
-
if (
|
|
5749
|
+
ln,
|
|
5750
|
+
_n,
|
|
5751
|
+
we
|
|
5752
|
+
]), xn = w((e) => {
|
|
5753
|
+
if (Se?.(e ? {
|
|
5747
5754
|
...e,
|
|
5748
5755
|
meta: Nt.current
|
|
5749
5756
|
} : null), !e || !Mt.current) {
|
|
5750
|
-
|
|
5757
|
+
mn.current && (mn.current = null, gn(null));
|
|
5751
5758
|
return;
|
|
5752
5759
|
}
|
|
5753
5760
|
let t = {
|
|
5754
|
-
id:
|
|
5761
|
+
id: $r,
|
|
5755
5762
|
type: e.type,
|
|
5756
5763
|
points: e.points,
|
|
5757
5764
|
style: Mt.current,
|
|
5758
5765
|
meta: Nt.current
|
|
5759
|
-
}, n =
|
|
5760
|
-
|
|
5761
|
-
id:
|
|
5766
|
+
}, n = mn.current !== null;
|
|
5767
|
+
mn.current = t, n ? _n([{
|
|
5768
|
+
id: $r,
|
|
5762
5769
|
points: e.points
|
|
5763
|
-
}]) :
|
|
5764
|
-
}, [
|
|
5770
|
+
}]) : gn(t);
|
|
5771
|
+
}, [_n, Se]), Sn = w((e, t) => {
|
|
5765
5772
|
let n = Mt.current;
|
|
5766
5773
|
if (!n || Lt.current) return;
|
|
5767
|
-
let r =
|
|
5774
|
+
let r = le();
|
|
5768
5775
|
Ut.current.create({
|
|
5769
5776
|
id: r,
|
|
5770
5777
|
type: e,
|
|
5771
5778
|
points: t,
|
|
5772
5779
|
style: n,
|
|
5773
5780
|
meta: s
|
|
5774
|
-
}),
|
|
5775
|
-
}, [s]),
|
|
5776
|
-
|
|
5777
|
-
let
|
|
5781
|
+
}), $t.current([r]);
|
|
5782
|
+
}, [s]), Cn = j(Sn);
|
|
5783
|
+
Cn.current = Sn;
|
|
5784
|
+
let wn = Un({
|
|
5778
5785
|
toolRef: jt,
|
|
5779
5786
|
selRef: At,
|
|
5780
5787
|
docRef: Ut,
|
|
@@ -5783,136 +5790,135 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5783
5790
|
brushSizeRef: Ft,
|
|
5784
5791
|
simplifyEpsilonRef: It,
|
|
5785
5792
|
draftMeta: s,
|
|
5786
|
-
engineRef:
|
|
5793
|
+
engineRef: U,
|
|
5787
5794
|
onDrawSessionChange: w((e) => {
|
|
5788
|
-
Le(e),
|
|
5789
|
-
}, [
|
|
5790
|
-
onDraftShapeChange:
|
|
5791
|
-
changeSelection:
|
|
5792
|
-
createShape:
|
|
5793
|
-
}),
|
|
5794
|
-
|
|
5795
|
-
let { reset:
|
|
5796
|
-
|
|
5795
|
+
Le(e), xe?.(e);
|
|
5796
|
+
}, [xe]),
|
|
5797
|
+
onDraftShapeChange: Se,
|
|
5798
|
+
changeSelection: Qt,
|
|
5799
|
+
createShape: Sn
|
|
5800
|
+
}), Tn = j(wn);
|
|
5801
|
+
Tn.current = wn;
|
|
5802
|
+
let { reset: En, undoSession: Dn, redoSession: On, canUndoSession: kn, canRedoSession: An, hasDraftSession: jn, hasDraftPoints: Mn, commitDraftSession: Nn, setBrushScalarMode: Pn, getBrushScalarMode: Fn, hasBrushSession: In, commitBrush: Ln, cancelBrush: Rn, beginBrushEditFromSelection: zn, deleteDraftSelectedPoints: Bn, handleToolChange: Vn, handleBrushSelectionChange: Hn } = wn, Wn = j(de);
|
|
5803
|
+
Wn.current = de;
|
|
5797
5804
|
let $ = yn({
|
|
5798
5805
|
docRef: Ut,
|
|
5799
5806
|
draftRef: Mt,
|
|
5800
5807
|
draftMeta: s,
|
|
5801
|
-
changeSelection:
|
|
5802
|
-
assistantRef:
|
|
5803
|
-
}),
|
|
5804
|
-
|
|
5805
|
-
let
|
|
5808
|
+
changeSelection: Qt,
|
|
5809
|
+
assistantRef: Wn
|
|
5810
|
+
}), Kn = j($);
|
|
5811
|
+
Kn.current = $;
|
|
5812
|
+
let qn = k(() => Pt(Ue), [Ue]), { selectAll: Jn, clearSelection: Yn, deleteSelection: Xn, copySelection: Zn, canPaste: Qn, paste: er, duplicate: tr, bringToFront: nr, sendToBack: rr, nudgeSelection: ir, getMergeTargets: ar, mergeSelection: or } = Zr({
|
|
5806
5813
|
doc: J,
|
|
5807
5814
|
selRef: At,
|
|
5808
5815
|
effectiveReadOnly: Q,
|
|
5809
|
-
changeSelection:
|
|
5810
|
-
canMergeSelection:
|
|
5811
|
-
clipboardDocumentId:
|
|
5812
|
-
clipboardScope: t ??
|
|
5813
|
-
}), { zoomToBounds:
|
|
5814
|
-
engineRef:
|
|
5816
|
+
changeSelection: Qt,
|
|
5817
|
+
canMergeSelection: ee,
|
|
5818
|
+
clipboardDocumentId: qn,
|
|
5819
|
+
clipboardScope: t ?? qn
|
|
5820
|
+
}), { zoomToBounds: sr, zoomToShapes: cr, zoomToSelection: lr, zoomAtCenter: ur } = Qr({
|
|
5821
|
+
engineRef: U,
|
|
5815
5822
|
doc: J,
|
|
5816
5823
|
selRef: At,
|
|
5817
5824
|
zoomAnimationDuration: te,
|
|
5818
5825
|
zoomBound: I,
|
|
5819
|
-
ready:
|
|
5826
|
+
ready: G
|
|
5820
5827
|
});
|
|
5821
|
-
D(
|
|
5828
|
+
D(pe, () => ({
|
|
5822
5829
|
previewRegionMask: (e) => {
|
|
5823
5830
|
let t = Dt.current;
|
|
5824
5831
|
if (!t) return;
|
|
5825
5832
|
let n = e ? cn(e, t.w, t.h) : Tt.current;
|
|
5826
|
-
|
|
5833
|
+
U.current?.setRegionOverlay(dr.current.showRegionMask ? n : null);
|
|
5827
5834
|
},
|
|
5828
5835
|
undo: () => {
|
|
5829
|
-
|
|
5836
|
+
Dn() || J.undo();
|
|
5830
5837
|
},
|
|
5831
5838
|
redo: () => {
|
|
5832
|
-
|
|
5839
|
+
On() || J.redo();
|
|
5833
5840
|
},
|
|
5834
|
-
canUndo: () =>
|
|
5835
|
-
canRedo: () =>
|
|
5836
|
-
undoSession:
|
|
5837
|
-
redoSession:
|
|
5838
|
-
canUndoSession:
|
|
5839
|
-
canRedoSession:
|
|
5840
|
-
hasDraftSession:
|
|
5841
|
-
cancelDraftSession:
|
|
5842
|
-
commitDraftSession:
|
|
5843
|
-
setSelection:
|
|
5841
|
+
canUndo: () => kn() || J.canUndo(),
|
|
5842
|
+
canRedo: () => An() || J.canRedo(),
|
|
5843
|
+
undoSession: Dn,
|
|
5844
|
+
redoSession: On,
|
|
5845
|
+
canUndoSession: kn,
|
|
5846
|
+
canRedoSession: An,
|
|
5847
|
+
hasDraftSession: jn,
|
|
5848
|
+
cancelDraftSession: En,
|
|
5849
|
+
commitDraftSession: Nn,
|
|
5850
|
+
setSelection: Qt,
|
|
5844
5851
|
createShapes: (e) => {
|
|
5845
|
-
e.length && (J.create(e),
|
|
5852
|
+
e.length && (J.create(e), Qt(e.map((e) => e.id)));
|
|
5846
5853
|
},
|
|
5847
5854
|
updateShapes: J.update,
|
|
5848
5855
|
deleteShapes: J.remove,
|
|
5849
5856
|
getShapes: J.getShapes,
|
|
5850
|
-
selectAll:
|
|
5851
|
-
clearSelection:
|
|
5852
|
-
deleteSelection:
|
|
5853
|
-
copySelection:
|
|
5854
|
-
paste:
|
|
5855
|
-
duplicate:
|
|
5856
|
-
bringToFront:
|
|
5857
|
-
sendToBack:
|
|
5858
|
-
zoomFit: () =>
|
|
5859
|
-
zoom100: () =>
|
|
5857
|
+
selectAll: Jn,
|
|
5858
|
+
clearSelection: Yn,
|
|
5859
|
+
deleteSelection: Xn,
|
|
5860
|
+
copySelection: Zn,
|
|
5861
|
+
paste: er,
|
|
5862
|
+
duplicate: tr,
|
|
5863
|
+
bringToFront: nr,
|
|
5864
|
+
sendToBack: rr,
|
|
5865
|
+
zoomFit: () => U.current?.fit(),
|
|
5866
|
+
zoom100: () => U.current?.zoom100(),
|
|
5860
5867
|
zoomIn: () => {
|
|
5861
|
-
let e =
|
|
5868
|
+
let e = U.current;
|
|
5862
5869
|
if (!e) return;
|
|
5863
5870
|
let { w: t, h: n } = e.screenSize;
|
|
5864
5871
|
e.zoomAt(t / 2, n / 2, 1.2);
|
|
5865
5872
|
},
|
|
5866
5873
|
zoomOut: () => {
|
|
5867
|
-
let e =
|
|
5874
|
+
let e = U.current;
|
|
5868
5875
|
if (!e) return;
|
|
5869
5876
|
let { w: t, h: n } = e.screenSize;
|
|
5870
5877
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5871
5878
|
},
|
|
5872
|
-
zoomToSelection:
|
|
5873
|
-
zoomToShapes:
|
|
5874
|
-
zoomToBounds:
|
|
5879
|
+
zoomToSelection: lr,
|
|
5880
|
+
zoomToShapes: cr,
|
|
5881
|
+
zoomToBounds: sr,
|
|
5875
5882
|
brush: {
|
|
5876
|
-
setScalarMode:
|
|
5877
|
-
getScalarMode:
|
|
5878
|
-
hasSession:
|
|
5879
|
-
commit:
|
|
5880
|
-
cancel:
|
|
5881
|
-
beginEditFromSelection:
|
|
5883
|
+
setScalarMode: Pn,
|
|
5884
|
+
getScalarMode: Fn,
|
|
5885
|
+
hasSession: In,
|
|
5886
|
+
commit: Ln,
|
|
5887
|
+
cancel: Rn,
|
|
5888
|
+
beginEditFromSelection: zn
|
|
5882
5889
|
}
|
|
5883
5890
|
}), [
|
|
5884
5891
|
J,
|
|
5885
|
-
|
|
5886
|
-
On,
|
|
5887
|
-
kn,
|
|
5888
|
-
Pn,
|
|
5892
|
+
Qt,
|
|
5889
5893
|
Dn,
|
|
5894
|
+
On,
|
|
5895
|
+
Nn,
|
|
5896
|
+
En,
|
|
5897
|
+
Ln,
|
|
5890
5898
|
Rn,
|
|
5891
|
-
|
|
5899
|
+
Jn,
|
|
5892
5900
|
Yn,
|
|
5893
5901
|
Xn,
|
|
5894
5902
|
Zn,
|
|
5895
|
-
|
|
5903
|
+
er,
|
|
5896
5904
|
tr,
|
|
5897
5905
|
nr,
|
|
5898
5906
|
rr,
|
|
5899
|
-
ir,
|
|
5900
|
-
ur,
|
|
5901
5907
|
lr,
|
|
5902
5908
|
cr,
|
|
5909
|
+
sr,
|
|
5910
|
+
Pn,
|
|
5903
5911
|
Fn,
|
|
5904
5912
|
In,
|
|
5905
|
-
|
|
5906
|
-
Bn
|
|
5913
|
+
zn
|
|
5907
5914
|
]);
|
|
5908
|
-
let
|
|
5909
|
-
|
|
5910
|
-
let
|
|
5911
|
-
engineRef:
|
|
5915
|
+
let dr = j(X);
|
|
5916
|
+
dr.current = X;
|
|
5917
|
+
let fr = w(() => vn({
|
|
5918
|
+
engineRef: U,
|
|
5912
5919
|
toolRef: jt,
|
|
5913
5920
|
externalToolMapRef: dt,
|
|
5914
5921
|
spaceRef: Wt,
|
|
5915
|
-
shiftRef: Gt,
|
|
5916
5922
|
docRef: Ut,
|
|
5917
5923
|
selRef: At,
|
|
5918
5924
|
draftRef: Mt,
|
|
@@ -5921,48 +5927,48 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5921
5927
|
lockedRef: zt,
|
|
5922
5928
|
onLockedInteraction: () => Bt.current?.(),
|
|
5923
5929
|
onDrawAttemptWithoutDraft: () => Vt.current?.(),
|
|
5924
|
-
createRef:
|
|
5925
|
-
selectRef:
|
|
5926
|
-
enterEditRef:
|
|
5927
|
-
editingIdRef:
|
|
5928
|
-
drawSessionRef:
|
|
5929
|
-
assistantRef:
|
|
5930
|
-
setCursorHint:
|
|
5931
|
-
setInteractionMode:
|
|
5932
|
-
syncMinimap:
|
|
5933
|
-
onTransformPreview:
|
|
5934
|
-
onDrawPreview:
|
|
5930
|
+
createRef: Cn,
|
|
5931
|
+
selectRef: $t,
|
|
5932
|
+
enterEditRef: rn,
|
|
5933
|
+
editingIdRef: an,
|
|
5934
|
+
drawSessionRef: Tn,
|
|
5935
|
+
assistantRef: Kn,
|
|
5936
|
+
setCursorHint: Xt,
|
|
5937
|
+
setInteractionMode: Yt,
|
|
5938
|
+
syncMinimap: un,
|
|
5939
|
+
onTransformPreview: bn,
|
|
5940
|
+
onDrawPreview: xn
|
|
5935
5941
|
}), [
|
|
5936
|
-
Zt,
|
|
5937
5942
|
Xt,
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5943
|
+
Yt,
|
|
5944
|
+
un,
|
|
5945
|
+
bn,
|
|
5946
|
+
xn
|
|
5947
|
+
]), pr = j([]);
|
|
5948
|
+
Hr({
|
|
5949
|
+
backend: me,
|
|
5950
|
+
hostRef: Te,
|
|
5951
|
+
engineRef: U,
|
|
5946
5952
|
documentId: Ue,
|
|
5947
5953
|
renderedImageUrl: et,
|
|
5948
|
-
makeCallbacks:
|
|
5949
|
-
viewRef:
|
|
5954
|
+
makeCallbacks: fr,
|
|
5955
|
+
viewRef: dr,
|
|
5950
5956
|
readOnlyRef: Lt,
|
|
5951
5957
|
toolRef: jt,
|
|
5952
|
-
renderShapesRef:
|
|
5958
|
+
renderShapesRef: pr,
|
|
5953
5959
|
coordinateSizeRef: Ot,
|
|
5954
5960
|
imageSizeRef: kt,
|
|
5955
5961
|
selRef: At,
|
|
5956
5962
|
regionOverlayRef: Tt,
|
|
5957
5963
|
dimmedRef: Et,
|
|
5958
|
-
syncMinimap:
|
|
5959
|
-
setImage:
|
|
5960
|
-
setImageVisible:
|
|
5964
|
+
syncMinimap: un,
|
|
5965
|
+
setImage: Ae,
|
|
5966
|
+
setImageVisible: Me,
|
|
5961
5967
|
setReady: Ne,
|
|
5962
5968
|
setImageStatus: ot,
|
|
5963
5969
|
onContextMenuRequest: Fe
|
|
5964
5970
|
});
|
|
5965
|
-
let
|
|
5971
|
+
let mr = k(() => {
|
|
5966
5972
|
let e = h ? J.shapes.map((e) => {
|
|
5967
5973
|
let t = h(e);
|
|
5968
5974
|
return t ? {
|
|
@@ -5973,7 +5979,7 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5973
5979
|
}
|
|
5974
5980
|
} : e;
|
|
5975
5981
|
}) : J.shapes;
|
|
5976
|
-
return
|
|
5982
|
+
return ne?.length ? [...ne.map((e) => ({
|
|
5977
5983
|
...e,
|
|
5978
5984
|
interaction: {
|
|
5979
5985
|
...e.interaction,
|
|
@@ -5986,128 +5992,128 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5986
5992
|
}, [
|
|
5987
5993
|
J.shapes,
|
|
5988
5994
|
h,
|
|
5989
|
-
|
|
5995
|
+
ne
|
|
5990
5996
|
]);
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
}, [
|
|
5994
|
-
|
|
5997
|
+
pr.current = mr, T(() => {
|
|
5998
|
+
U.current?.setShapes(mr, At.current), un();
|
|
5999
|
+
}, [mr, un]), T(() => {
|
|
6000
|
+
U.current?.setSelection(Y);
|
|
5995
6001
|
}, [Y]), T(() => {
|
|
5996
|
-
|
|
5997
|
-
}, [
|
|
5998
|
-
let
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
}, [
|
|
6002
|
-
|
|
6002
|
+
U.current?.setEditing(en);
|
|
6003
|
+
}, [en, G]);
|
|
6004
|
+
let hr = j(_e);
|
|
6005
|
+
hr.current = _e, T(() => {
|
|
6006
|
+
hr.current?.(en);
|
|
6007
|
+
}, [en]), T(() => {
|
|
6008
|
+
tn(null);
|
|
6003
6009
|
}, [a]), T(() => {
|
|
6004
|
-
|
|
6005
|
-
}, [Y,
|
|
6006
|
-
let e =
|
|
6007
|
-
e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing),
|
|
6010
|
+
en && (Y.length !== 1 || Y[0] !== en) && tn(null);
|
|
6011
|
+
}, [Y, en]), T(() => {
|
|
6012
|
+
let e = U.current;
|
|
6013
|
+
e && (e.setFilter(X.brightness, X.contrast), e.setRenderDefaults({ strokeWidth: X.strokeSize }), e.setImageSmoothing(X.imageSmoothing), un());
|
|
6008
6014
|
}, [
|
|
6009
6015
|
X.brightness,
|
|
6010
6016
|
X.contrast,
|
|
6011
6017
|
X.strokeSize,
|
|
6012
6018
|
X.imageSmoothing,
|
|
6013
|
-
|
|
6019
|
+
un
|
|
6014
6020
|
]), O(() => {
|
|
6015
|
-
|
|
6021
|
+
G && U.current?.setOverlays(X.showRegionMask ? Ct : null, r);
|
|
6016
6022
|
}, [
|
|
6017
|
-
|
|
6023
|
+
G,
|
|
6018
6024
|
Ct,
|
|
6019
6025
|
X.showRegionMask,
|
|
6020
6026
|
r
|
|
6021
6027
|
]), T(() => {
|
|
6022
|
-
!
|
|
6028
|
+
!G || !W || un();
|
|
6023
6029
|
}, [
|
|
6024
|
-
Me,
|
|
6025
6030
|
G,
|
|
6031
|
+
W,
|
|
6026
6032
|
X.showRegionMask,
|
|
6027
|
-
|
|
6028
|
-
|
|
6033
|
+
re,
|
|
6034
|
+
un
|
|
6029
6035
|
]), T(() => {
|
|
6030
|
-
|
|
6036
|
+
G && U.current?.setTransformEnabled(!Q && a !== q.BRUSH);
|
|
6031
6037
|
}, [
|
|
6032
6038
|
Q,
|
|
6033
|
-
|
|
6039
|
+
G,
|
|
6034
6040
|
a
|
|
6035
6041
|
]), T(() => {
|
|
6036
|
-
|
|
6037
|
-
}, [a,
|
|
6038
|
-
let
|
|
6042
|
+
Vn(a, dt.current.has(a));
|
|
6043
|
+
}, [a, Vn]);
|
|
6044
|
+
let gr = $.finalize;
|
|
6039
6045
|
T(() => {
|
|
6040
|
-
|
|
6041
|
-
}, [a,
|
|
6042
|
-
|
|
6046
|
+
gr();
|
|
6047
|
+
}, [a, gr]), T(() => {
|
|
6048
|
+
Gt.current = "idle", Kt.current = null, qt();
|
|
6043
6049
|
}, [
|
|
6044
6050
|
a,
|
|
6045
|
-
|
|
6046
|
-
|
|
6051
|
+
me,
|
|
6052
|
+
qt
|
|
6047
6053
|
]), T(() => {
|
|
6048
|
-
|
|
6054
|
+
Hn(Y, Q);
|
|
6049
6055
|
}, [
|
|
6050
6056
|
Y,
|
|
6051
6057
|
a,
|
|
6052
6058
|
Q,
|
|
6053
|
-
|
|
6059
|
+
Hn
|
|
6054
6060
|
]), T(() => {
|
|
6055
|
-
|
|
6061
|
+
G && qt();
|
|
6056
6062
|
}, [
|
|
6057
6063
|
a,
|
|
6058
6064
|
Ie,
|
|
6059
6065
|
ut,
|
|
6060
|
-
|
|
6061
|
-
|
|
6066
|
+
G,
|
|
6067
|
+
qt
|
|
6062
6068
|
]);
|
|
6063
|
-
let
|
|
6064
|
-
|
|
6065
|
-
let
|
|
6069
|
+
let _r = j(Xe);
|
|
6070
|
+
_r.current = Xe;
|
|
6071
|
+
let vr = e !== null, yr = j(null);
|
|
6066
6072
|
T(() => {
|
|
6067
|
-
let e =
|
|
6068
|
-
|
|
6073
|
+
let e = vr ? Ue : null;
|
|
6074
|
+
yr.current !== e && (yr.current = e, Fe(null), tn(null), Gt.current = "idle", Kt.current = null, J.reset(vr ? Je ?? [] : []), Qt(vr ? _r.current ?? [] : []), En(), gr(), qt());
|
|
6069
6075
|
}, [
|
|
6070
|
-
|
|
6076
|
+
vr,
|
|
6071
6077
|
Ue,
|
|
6072
6078
|
Je,
|
|
6073
6079
|
J.reset,
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6080
|
+
Qt,
|
|
6081
|
+
En,
|
|
6082
|
+
gr,
|
|
6083
|
+
qt
|
|
6078
6084
|
]);
|
|
6079
|
-
let
|
|
6080
|
-
let e =
|
|
6085
|
+
let br = w(() => {
|
|
6086
|
+
let e = an.current;
|
|
6081
6087
|
if (!e || Q) return !1;
|
|
6082
|
-
let t =
|
|
6088
|
+
let t = U.current, n = new Set(t?.getVertexSelection() ?? []);
|
|
6083
6089
|
if (!n.size) return !1;
|
|
6084
6090
|
let r = Ut.current.getShapes().find((t) => t.id === e);
|
|
6085
6091
|
if (!r) return !1;
|
|
6086
|
-
let i = r.points.filter((e, t) => !n.has(t)), a = r.type ===
|
|
6092
|
+
let i = r.points.filter((e, t) => !n.has(t)), a = r.type === L.LINE ? 2 : 3;
|
|
6087
6093
|
return i.length < a ? !1 : (Ut.current.update([{
|
|
6088
6094
|
...r,
|
|
6089
6095
|
points: i
|
|
6090
6096
|
}]), t?.setVertexSelection([]), !0);
|
|
6091
6097
|
}, [Q]);
|
|
6092
6098
|
$n({
|
|
6093
|
-
keymap:
|
|
6094
|
-
hostRef:
|
|
6099
|
+
keymap: fe,
|
|
6100
|
+
hostRef: Te,
|
|
6095
6101
|
actions: {
|
|
6096
6102
|
undo: () => {
|
|
6097
|
-
Q ||
|
|
6103
|
+
Q || Dn() || J.undo();
|
|
6098
6104
|
},
|
|
6099
6105
|
redo: () => {
|
|
6100
|
-
Q ||
|
|
6106
|
+
Q || On() || J.redo();
|
|
6101
6107
|
},
|
|
6102
|
-
selectAll:
|
|
6103
|
-
copy:
|
|
6108
|
+
selectAll: Jn,
|
|
6109
|
+
copy: Zn,
|
|
6104
6110
|
cut: () => {
|
|
6105
|
-
|
|
6111
|
+
Zn(), Xn();
|
|
6106
6112
|
},
|
|
6107
|
-
paste:
|
|
6108
|
-
duplicate:
|
|
6113
|
+
paste: er,
|
|
6114
|
+
duplicate: tr,
|
|
6109
6115
|
delete: () => {
|
|
6110
|
-
|
|
6116
|
+
Mn() && Bn() || br() || Xn();
|
|
6111
6117
|
},
|
|
6112
6118
|
cancel: () => {
|
|
6113
6119
|
let e = dt.current.get(jt.current);
|
|
@@ -6116,16 +6122,16 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6116
6122
|
$.cancel();
|
|
6117
6123
|
return;
|
|
6118
6124
|
}
|
|
6119
|
-
if (
|
|
6120
|
-
|
|
6125
|
+
if (jn()) {
|
|
6126
|
+
En();
|
|
6121
6127
|
return;
|
|
6122
6128
|
}
|
|
6123
|
-
if (
|
|
6124
|
-
|
|
6129
|
+
if (en) {
|
|
6130
|
+
tn(null);
|
|
6125
6131
|
return;
|
|
6126
6132
|
}
|
|
6127
6133
|
if (At.current.length) {
|
|
6128
|
-
|
|
6134
|
+
Yn();
|
|
6129
6135
|
return;
|
|
6130
6136
|
}
|
|
6131
6137
|
m?.();
|
|
@@ -6136,26 +6142,26 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6136
6142
|
$.finalize();
|
|
6137
6143
|
return;
|
|
6138
6144
|
}
|
|
6139
|
-
if (
|
|
6140
|
-
|
|
6145
|
+
if (jn()) {
|
|
6146
|
+
Nn();
|
|
6141
6147
|
return;
|
|
6142
6148
|
}
|
|
6143
6149
|
if (Q) return;
|
|
6144
|
-
if (
|
|
6145
|
-
|
|
6150
|
+
if (en) {
|
|
6151
|
+
tn(null);
|
|
6146
6152
|
return;
|
|
6147
6153
|
}
|
|
6148
6154
|
let e = At.current;
|
|
6149
6155
|
if (e.length !== 1) return;
|
|
6150
6156
|
let t = Ut.current.getShapes().find((t) => t.id === e[0]);
|
|
6151
|
-
t && (t.type ===
|
|
6157
|
+
t && (t.type === L.POLYGON || t.type === L.LINE) && t.interaction?.editable !== !1 && !t.readOnly && tn(e[0]);
|
|
6152
6158
|
},
|
|
6153
|
-
bringToFront:
|
|
6154
|
-
sendToBack:
|
|
6155
|
-
zoomIn: () =>
|
|
6156
|
-
zoomOut: () =>
|
|
6157
|
-
zoom100: () =>
|
|
6158
|
-
zoomFit: () =>
|
|
6159
|
+
bringToFront: nr,
|
|
6160
|
+
sendToBack: rr,
|
|
6161
|
+
zoomIn: () => ur(1.2),
|
|
6162
|
+
zoomOut: () => ur(1 / 1.2),
|
|
6163
|
+
zoom100: () => U.current?.zoom100(),
|
|
6164
|
+
zoomFit: () => U.current?.fit(),
|
|
6159
6165
|
toggleMinimap: () => ze((e) => !e),
|
|
6160
6166
|
toggleCursorGuide: () => gt((e) => ({
|
|
6161
6167
|
...e,
|
|
@@ -6165,121 +6171,120 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6165
6171
|
...e,
|
|
6166
6172
|
imageSmoothing: !e.imageSmoothing
|
|
6167
6173
|
})),
|
|
6168
|
-
selectTool: () =>
|
|
6169
|
-
rectangleTool: () =>
|
|
6170
|
-
rotatedRectangleTool: () =>
|
|
6171
|
-
circleTool: () =>
|
|
6172
|
-
polygonTool: () =>
|
|
6173
|
-
pathTool: () =>
|
|
6174
|
-
brushTool: () =>
|
|
6175
|
-
pointTool: () =>
|
|
6174
|
+
selectTool: () => he?.(q.SELECT),
|
|
6175
|
+
rectangleTool: () => he?.(q.RECTANGLE),
|
|
6176
|
+
rotatedRectangleTool: () => he?.(q.ROTATED_RECTANGLE),
|
|
6177
|
+
circleTool: () => he?.(q.CIRCLE),
|
|
6178
|
+
polygonTool: () => he?.(q.POLYGON),
|
|
6179
|
+
pathTool: () => he?.(q.PATH),
|
|
6180
|
+
brushTool: () => he?.(q.BRUSH),
|
|
6181
|
+
pointTool: () => he?.(q.POINT)
|
|
6176
6182
|
},
|
|
6177
6183
|
spaceRef: Wt,
|
|
6178
|
-
shiftRef: Gt,
|
|
6179
6184
|
onSpaceDown: () => {
|
|
6180
|
-
|
|
6185
|
+
U.current?.setPanMode(!0), qt();
|
|
6181
6186
|
},
|
|
6182
6187
|
onSpaceUp: () => {
|
|
6183
|
-
|
|
6188
|
+
U.current?.setPanMode(!1), Gt.current === "panning" ? Yt("idle") : qt();
|
|
6184
6189
|
},
|
|
6185
|
-
nudge:
|
|
6190
|
+
nudge: ir
|
|
6186
6191
|
});
|
|
6187
|
-
let
|
|
6192
|
+
let xr = k(() => mr.filter((e) => Y.includes(e.id) && R(e)), [mr, Y]), Sr = k(() => hn ? [...xr, hn] : xr, [xr, hn]), Cr = Y.length > 0, wr = J.shapes.some((e) => Y.includes(e.id) && oe(e)), Tr = !Q && Y.length === 1 && (() => {
|
|
6188
6193
|
let e = J.shapes.find((e) => e.id === Y[0]);
|
|
6189
|
-
return !!e && (e.type ===
|
|
6190
|
-
})(),
|
|
6194
|
+
return !!e && (e.type === L.POLYGON || e.type === L.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
6195
|
+
})(), Er = ar(), Dr = Q || Er.length < 2 || (ee ? !ee(Er) : !1), Or = !!de && !Q, kr = Or && Y.length === 1 ? (() => {
|
|
6191
6196
|
let e = J.shapes.find((e) => e.id === Y[0]);
|
|
6192
|
-
return e && e.type ===
|
|
6193
|
-
})() : null,
|
|
6197
|
+
return e && e.type === L.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
6198
|
+
})() : null, Ar = [
|
|
6194
6199
|
{
|
|
6195
6200
|
id: "copy",
|
|
6196
6201
|
label: Z.contextMenu.copy,
|
|
6197
6202
|
shortcut: "⌘C",
|
|
6198
|
-
disabled: !
|
|
6199
|
-
onClick:
|
|
6203
|
+
disabled: !wr,
|
|
6204
|
+
onClick: Zn
|
|
6200
6205
|
},
|
|
6201
6206
|
{
|
|
6202
6207
|
id: "paste",
|
|
6203
6208
|
label: Z.contextMenu.paste,
|
|
6204
6209
|
shortcut: "⌘V",
|
|
6205
|
-
disabled: Q || !
|
|
6206
|
-
onClick: () =>
|
|
6210
|
+
disabled: Q || !Qn(),
|
|
6211
|
+
onClick: () => er(Pe?.img)
|
|
6207
6212
|
},
|
|
6208
6213
|
{
|
|
6209
6214
|
id: "duplicate",
|
|
6210
6215
|
label: Z.contextMenu.duplicate,
|
|
6211
6216
|
shortcut: "⌘D",
|
|
6212
|
-
disabled: !
|
|
6213
|
-
onClick:
|
|
6217
|
+
disabled: !wr || Q,
|
|
6218
|
+
onClick: tr
|
|
6214
6219
|
},
|
|
6215
6220
|
{
|
|
6216
6221
|
id: "delete",
|
|
6217
6222
|
label: Z.contextMenu.delete,
|
|
6218
6223
|
shortcut: "Del",
|
|
6219
6224
|
danger: !0,
|
|
6220
|
-
disabled: !
|
|
6221
|
-
onClick:
|
|
6225
|
+
disabled: !wr || Q,
|
|
6226
|
+
onClick: Xn
|
|
6222
6227
|
},
|
|
6223
6228
|
{ separator: !0 },
|
|
6224
6229
|
{
|
|
6225
6230
|
id: "editVertices",
|
|
6226
6231
|
label: Z.contextMenu.editVertices,
|
|
6227
6232
|
shortcut: "Enter",
|
|
6228
|
-
disabled: !
|
|
6229
|
-
onClick: () =>
|
|
6233
|
+
disabled: !Tr,
|
|
6234
|
+
onClick: () => tn(Y[0])
|
|
6230
6235
|
},
|
|
6231
6236
|
{
|
|
6232
6237
|
id: "merge",
|
|
6233
6238
|
label: Z.contextMenu.merge,
|
|
6234
|
-
disabled:
|
|
6235
|
-
onClick:
|
|
6239
|
+
disabled: Dr,
|
|
6240
|
+
onClick: or
|
|
6236
6241
|
},
|
|
6237
|
-
...
|
|
6242
|
+
...Or ? [{
|
|
6238
6243
|
id: "assistExpand",
|
|
6239
6244
|
label: Z.contextMenu.assistExpand,
|
|
6240
6245
|
icon: /* @__PURE__ */ x(f, { size: 14 }),
|
|
6241
|
-
disabled: !
|
|
6246
|
+
disabled: !kr,
|
|
6242
6247
|
onClick: () => {
|
|
6243
|
-
Pe &&
|
|
6248
|
+
Pe && kr && $.refineShape(kr, Pe.img, !0);
|
|
6244
6249
|
}
|
|
6245
6250
|
}, {
|
|
6246
6251
|
id: "assistExclude",
|
|
6247
6252
|
label: Z.contextMenu.assistExclude,
|
|
6248
6253
|
icon: /* @__PURE__ */ x(f, { size: 14 }),
|
|
6249
|
-
disabled: !
|
|
6254
|
+
disabled: !kr,
|
|
6250
6255
|
onClick: () => {
|
|
6251
|
-
Pe &&
|
|
6256
|
+
Pe && kr && $.refineShape(kr, Pe.img, !1);
|
|
6252
6257
|
}
|
|
6253
6258
|
}] : [],
|
|
6254
6259
|
{
|
|
6255
6260
|
id: "bringToFront",
|
|
6256
6261
|
label: Z.contextMenu.bringToFront,
|
|
6257
|
-
disabled: !
|
|
6258
|
-
onClick:
|
|
6262
|
+
disabled: !wr || Q,
|
|
6263
|
+
onClick: nr
|
|
6259
6264
|
},
|
|
6260
6265
|
{
|
|
6261
6266
|
id: "sendToBack",
|
|
6262
6267
|
label: Z.contextMenu.sendToBack,
|
|
6263
|
-
disabled: !
|
|
6264
|
-
onClick:
|
|
6268
|
+
disabled: !wr || Q,
|
|
6269
|
+
onClick: rr
|
|
6265
6270
|
},
|
|
6266
6271
|
{ separator: !0 },
|
|
6267
6272
|
{
|
|
6268
6273
|
id: "undo",
|
|
6269
6274
|
label: Z.contextMenu.undo,
|
|
6270
6275
|
shortcut: "⌘Z",
|
|
6271
|
-
disabled: Q || !
|
|
6276
|
+
disabled: Q || !kn() && !J.canUndo(),
|
|
6272
6277
|
onClick: () => {
|
|
6273
|
-
|
|
6278
|
+
Dn() || J.undo();
|
|
6274
6279
|
}
|
|
6275
6280
|
},
|
|
6276
6281
|
{
|
|
6277
6282
|
id: "redo",
|
|
6278
6283
|
label: Z.contextMenu.redo,
|
|
6279
6284
|
shortcut: "⇧⌘Z",
|
|
6280
|
-
disabled: Q || !
|
|
6285
|
+
disabled: Q || !An() && !J.canRedo(),
|
|
6281
6286
|
onClick: () => {
|
|
6282
|
-
|
|
6287
|
+
On() || J.redo();
|
|
6283
6288
|
}
|
|
6284
6289
|
},
|
|
6285
6290
|
{ separator: !0 },
|
|
@@ -6287,50 +6292,50 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6287
6292
|
id: "selectAll",
|
|
6288
6293
|
label: Z.contextMenu.selectAll,
|
|
6289
6294
|
shortcut: "⌘A",
|
|
6290
|
-
onClick:
|
|
6295
|
+
onClick: Jn
|
|
6291
6296
|
},
|
|
6292
6297
|
{
|
|
6293
6298
|
id: "clearSelection",
|
|
6294
6299
|
label: Z.contextMenu.clearSelection,
|
|
6295
|
-
disabled: !
|
|
6296
|
-
onClick:
|
|
6300
|
+
disabled: !Cr,
|
|
6301
|
+
onClick: Yn
|
|
6297
6302
|
},
|
|
6298
6303
|
{
|
|
6299
6304
|
id: "zoomToSelection",
|
|
6300
6305
|
label: Z.contextMenu.zoomToSelection,
|
|
6301
|
-
disabled: !
|
|
6302
|
-
onClick:
|
|
6306
|
+
disabled: !Cr,
|
|
6307
|
+
onClick: lr
|
|
6303
6308
|
}
|
|
6304
|
-
],
|
|
6309
|
+
], jr = c ? Ar.filter((e) => "separator" in e || !!e.id && ei.has(e.id)) : Ar, Mr = A ? A(jr, {
|
|
6305
6310
|
selectedIds: Y,
|
|
6306
6311
|
readOnly: Q
|
|
6307
|
-
}) :
|
|
6308
|
-
engineRef:
|
|
6309
|
-
image:
|
|
6312
|
+
}) : jr, Nr = qr({
|
|
6313
|
+
engineRef: U,
|
|
6314
|
+
image: W,
|
|
6310
6315
|
wheelZoom: X.wheelZoom,
|
|
6311
6316
|
minimapSize: 204
|
|
6312
|
-
}),
|
|
6313
|
-
|
|
6314
|
-
}, []),
|
|
6317
|
+
}), Pr = w(() => {
|
|
6318
|
+
U.current?.zoom100();
|
|
6319
|
+
}, []), Fr = w(() => {
|
|
6315
6320
|
ze((e) => !e);
|
|
6316
|
-
}, []),
|
|
6321
|
+
}, []), Ir = w(() => {
|
|
6317
6322
|
He((e) => !e);
|
|
6318
|
-
}, []),
|
|
6323
|
+
}, []), Lr = w(() => {
|
|
6319
6324
|
He(!1);
|
|
6320
6325
|
}, []);
|
|
6321
6326
|
return /* @__PURE__ */ S("div", {
|
|
6322
6327
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
6323
6328
|
children: [
|
|
6324
6329
|
/* @__PURE__ */ x("div", {
|
|
6325
|
-
ref:
|
|
6330
|
+
ref: Te,
|
|
6326
6331
|
role: "application",
|
|
6327
6332
|
"aria-label": Z.canvasLabel,
|
|
6328
6333
|
tabIndex: 0,
|
|
6329
6334
|
onPointerDownCapture: (e) => e.currentTarget.focus({ preventScroll: !0 }),
|
|
6330
6335
|
className: "aivex:h-full aivex:w-full",
|
|
6331
6336
|
style: {
|
|
6332
|
-
opacity: +!!
|
|
6333
|
-
transition:
|
|
6337
|
+
opacity: +!!je,
|
|
6338
|
+
transition: je ? "opacity 0.3s ease" : "none"
|
|
6334
6339
|
}
|
|
6335
6340
|
}),
|
|
6336
6341
|
rt !== "ready" && /* @__PURE__ */ x($e, {
|
|
@@ -6342,37 +6347,37 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6342
6347
|
errorLabel: Z.imageLoadError,
|
|
6343
6348
|
errorHints: Z.imageErrorHints
|
|
6344
6349
|
}),
|
|
6345
|
-
|
|
6350
|
+
G && W && /* @__PURE__ */ x("div", {
|
|
6346
6351
|
className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
|
|
6347
6352
|
children: /* @__PURE__ */ S("div", {
|
|
6348
|
-
ref:
|
|
6353
|
+
ref: De,
|
|
6349
6354
|
style: {
|
|
6350
6355
|
position: "absolute",
|
|
6351
6356
|
top: 0,
|
|
6352
6357
|
left: 0,
|
|
6353
|
-
width:
|
|
6354
|
-
height:
|
|
6358
|
+
width: W.w,
|
|
6359
|
+
height: W.h,
|
|
6355
6360
|
transformOrigin: "0 0"
|
|
6356
6361
|
},
|
|
6357
6362
|
children: [
|
|
6358
|
-
!!
|
|
6363
|
+
!!ie?.length && ae && /* @__PURE__ */ x("div", {
|
|
6359
6364
|
style: {
|
|
6360
6365
|
position: "absolute",
|
|
6361
6366
|
left: 0,
|
|
6362
6367
|
top: 0,
|
|
6363
|
-
width:
|
|
6364
|
-
height:
|
|
6368
|
+
width: W.w,
|
|
6369
|
+
height: W.h,
|
|
6365
6370
|
pointerEvents: "none"
|
|
6366
6371
|
},
|
|
6367
|
-
children:
|
|
6372
|
+
children: ie.map((e) => /* @__PURE__ */ x("div", {
|
|
6368
6373
|
role: e.disabled ? void 0 : "button",
|
|
6369
6374
|
tabIndex: e.disabled ? void 0 : 0,
|
|
6370
6375
|
"aria-pressed": e.selected || void 0,
|
|
6371
6376
|
onClick: (t) => {
|
|
6372
|
-
t.stopPropagation(), e.disabled ||
|
|
6377
|
+
t.stopPropagation(), e.disabled || se?.(e);
|
|
6373
6378
|
},
|
|
6374
6379
|
onKeyDown: (t) => {
|
|
6375
|
-
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(),
|
|
6380
|
+
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), se?.(e));
|
|
6376
6381
|
},
|
|
6377
6382
|
style: {
|
|
6378
6383
|
position: "absolute",
|
|
@@ -6384,26 +6389,26 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6384
6389
|
pointerEvents: e.disabled ? "none" : "auto",
|
|
6385
6390
|
cursor: e.disabled ? "default" : "pointer"
|
|
6386
6391
|
},
|
|
6387
|
-
children:
|
|
6392
|
+
children: ae(e)
|
|
6388
6393
|
}, e.id))
|
|
6389
6394
|
}),
|
|
6390
|
-
|
|
6391
|
-
image:
|
|
6392
|
-
viewport:
|
|
6395
|
+
ce?.({
|
|
6396
|
+
image: W,
|
|
6397
|
+
viewport: U.current?.viewport ?? {
|
|
6393
6398
|
scale: 1,
|
|
6394
6399
|
x: 0,
|
|
6395
6400
|
y: 0
|
|
6396
6401
|
}
|
|
6397
6402
|
}),
|
|
6398
|
-
|
|
6399
|
-
shapes:
|
|
6400
|
-
getLabel:
|
|
6401
|
-
hideDot:
|
|
6402
|
-
formatInfo:
|
|
6403
|
-
register:
|
|
6403
|
+
Sr.length > 0 && /* @__PURE__ */ x(wt, {
|
|
6404
|
+
shapes: Sr,
|
|
6405
|
+
getLabel: B,
|
|
6406
|
+
hideDot: V,
|
|
6407
|
+
formatInfo: H,
|
|
6408
|
+
register: pn
|
|
6404
6409
|
}),
|
|
6405
|
-
|
|
6406
|
-
image:
|
|
6410
|
+
de && ($.status === "loading" || $.boxes.length > 0) && /* @__PURE__ */ x(Ye, {
|
|
6411
|
+
image: W,
|
|
6407
6412
|
points: $.points,
|
|
6408
6413
|
boxes: $.boxes,
|
|
6409
6414
|
status: $.status
|
|
@@ -6411,38 +6416,38 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6411
6416
|
]
|
|
6412
6417
|
})
|
|
6413
6418
|
}),
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
image:
|
|
6419
|
+
G && X.showCursorGuide && /* @__PURE__ */ x(Qe, { color: "#1e88e5" }),
|
|
6420
|
+
W && y && /* @__PURE__ */ x(ht, {
|
|
6421
|
+
image: W,
|
|
6417
6422
|
imageUrl: et,
|
|
6418
|
-
imageVisible:
|
|
6419
|
-
loading: !
|
|
6423
|
+
imageVisible: je,
|
|
6424
|
+
loading: !G,
|
|
6420
6425
|
region: Ct,
|
|
6421
|
-
roiMaskId:
|
|
6422
|
-
shapes:
|
|
6426
|
+
roiMaskId: ke,
|
|
6427
|
+
shapes: mr,
|
|
6423
6428
|
view: X,
|
|
6424
6429
|
viewDefaults: pt,
|
|
6425
6430
|
onChangeView: _t,
|
|
6426
|
-
nav:
|
|
6427
|
-
registerShape:
|
|
6428
|
-
rectRef:
|
|
6429
|
-
zoomLabelRef:
|
|
6430
|
-
onZoom100:
|
|
6431
|
+
nav: Nr,
|
|
6432
|
+
registerShape: sn,
|
|
6433
|
+
rectRef: Ee,
|
|
6434
|
+
zoomLabelRef: Oe,
|
|
6435
|
+
onZoom100: Pr,
|
|
6431
6436
|
open: Re,
|
|
6432
|
-
onToggleOpen:
|
|
6437
|
+
onToggleOpen: Fr,
|
|
6433
6438
|
position: b,
|
|
6434
6439
|
labels: Z.minimap,
|
|
6435
6440
|
settingsLabels: Z.viewSettings,
|
|
6436
|
-
settingsItems:
|
|
6441
|
+
settingsItems: P,
|
|
6437
6442
|
showSettings: C,
|
|
6438
6443
|
settingsOpen: K,
|
|
6439
|
-
onToggleSettings:
|
|
6440
|
-
onCloseSettings:
|
|
6444
|
+
onToggleSettings: Ir,
|
|
6445
|
+
onCloseSettings: Lr
|
|
6441
6446
|
}),
|
|
6442
6447
|
Pe && /* @__PURE__ */ x(Ze, {
|
|
6443
6448
|
x: Pe.x,
|
|
6444
6449
|
y: Pe.y,
|
|
6445
|
-
items:
|
|
6450
|
+
items: Mr,
|
|
6446
6451
|
onClose: () => Fe(null)
|
|
6447
6452
|
})
|
|
6448
6453
|
]
|
|
@@ -6450,34 +6455,34 @@ function ti({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6450
6455
|
}
|
|
6451
6456
|
//#endregion
|
|
6452
6457
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
6453
|
-
function
|
|
6458
|
+
function ri(e, t, n) {
|
|
6454
6459
|
if (t.length !== 0) {
|
|
6455
6460
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
6456
6461
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
6457
6462
|
n && e.closePath();
|
|
6458
6463
|
}
|
|
6459
6464
|
}
|
|
6460
|
-
function
|
|
6465
|
+
function ii(e, t, n, r) {
|
|
6461
6466
|
if (t.interaction?.visible === !1) return;
|
|
6462
6467
|
let i = at(t, {
|
|
6463
6468
|
strokeWidth: r,
|
|
6464
6469
|
pointRadius: 2
|
|
6465
6470
|
});
|
|
6466
|
-
if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type ===
|
|
6471
|
+
if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type === L.POINT) {
|
|
6467
6472
|
let r = t.points[0];
|
|
6468
6473
|
r && (e.fillStyle = i.color, e.beginPath(), e.arc(r.x, r.y, i.pointRadius / n, 0, Math.PI * 2), e.fill()), e.restore();
|
|
6469
6474
|
return;
|
|
6470
6475
|
}
|
|
6471
|
-
if (t.type ===
|
|
6476
|
+
if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
|
|
6472
6477
|
let [n, r] = t.points;
|
|
6473
6478
|
if (n && r) {
|
|
6474
6479
|
let i = Math.min(n.x, r.x), a = Math.min(n.y, r.y), o = Math.abs(r.x - n.x), s = Math.abs(r.y - n.y);
|
|
6475
|
-
e.beginPath(), t.type ===
|
|
6480
|
+
e.beginPath(), t.type === L.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6476
6481
|
}
|
|
6477
|
-
} else
|
|
6482
|
+
} else ri(e, t.points, t.type !== L.LINE);
|
|
6478
6483
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill("evenodd"), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
|
|
6479
6484
|
}
|
|
6480
|
-
function
|
|
6485
|
+
function ai({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, focusedShapeId: a, focusFit: o = "contain", zoomPadding: s = .3, strokeSize: c = 1, brightness: l = 1, contrast: u = 1, imageSmoothing: d = !0, lazy: f = !0, className: p, style: m, renderImageState: h }) {
|
|
6481
6486
|
let g = j(null), _ = j(null), v = j(null), [y, b] = M(!f), [C, w] = M("loading"), [E, D] = M(null), [O, A] = M(0);
|
|
6482
6487
|
T(() => {
|
|
6483
6488
|
if (!f || y) return;
|
|
@@ -6532,7 +6537,7 @@ function ii({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6532
6537
|
if (!y || !b) return;
|
|
6533
6538
|
let x = Math.min(f / y, p / b), S = (f - y * x) / 2, w = (p - b * x) / 2;
|
|
6534
6539
|
if (N && N.points.length > 0) {
|
|
6535
|
-
let e =
|
|
6540
|
+
let e = H(N.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * s;
|
|
6536
6541
|
x = Math.min(f / (t + r * 2), p / (n + r * 2)), o === "cover" && (x = Math.max(x, Math.max(f / y, p / b))), S = f / 2 - (e.minX + e.maxX) / 2 * x, w = p / 2 - (e.minY + e.maxY) / 2 * x, o === "cover" && (S = Math.min(0, Math.max(S, f - y * x)), w = Math.min(0, Math.max(w, p - b * x)));
|
|
6537
6542
|
}
|
|
6538
6543
|
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, f, p), h.save(), h.translate(S, w), h.scale(x, x), h.imageSmoothingEnabled = d;
|
|
@@ -6546,15 +6551,15 @@ function ii({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6546
6551
|
let e = (e, t) => {
|
|
6547
6552
|
if (h.lineWidth = t.width / x, t.underlayColor) {
|
|
6548
6553
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
6549
|
-
for (let [t, n] of e)
|
|
6554
|
+
for (let [t, n] of e) ri(h, [t, n], !1), h.stroke();
|
|
6550
6555
|
}
|
|
6551
6556
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / x)), h.strokeStyle = t.color;
|
|
6552
|
-
for (let [t, n] of e)
|
|
6557
|
+
for (let [t, n] of e) ri(h, [t, n], !1), h.stroke();
|
|
6553
6558
|
h.restore();
|
|
6554
6559
|
};
|
|
6555
6560
|
e(E.visibleOutline, E.outlineStyles.visible), e(E.occludedOutline, E.outlineStyles.occluded);
|
|
6556
6561
|
}
|
|
6557
|
-
for (let e of
|
|
6562
|
+
for (let e of ce(r)) ii(h, e, x, c);
|
|
6558
6563
|
h.restore();
|
|
6559
6564
|
}, [
|
|
6560
6565
|
l,
|
|
@@ -6635,6 +6640,6 @@ function ii({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6635
6640
|
});
|
|
6636
6641
|
}
|
|
6637
6642
|
//#endregion
|
|
6638
|
-
export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS,
|
|
6643
|
+
export { K as DEFAULT_EDITOR_STRINGS, Ve as DEFAULT_VIEW_SETTINGS, L as SHAPE_TYPE, ni as ShapeEditor, ni as default, ai as ShapeViewer, q as TOOL, He as VIEW_SETTING_RANGES, We as clampViewSettings, le as generateId };
|
|
6639
6644
|
|
|
6640
6645
|
//# sourceMappingURL=shape-editor.js.map
|