@aivex/ui 1.2.0-dev.16 → 1.2.0-dev.17
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/ShapeEditor.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/props.d.ts +26 -12
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +21 -3
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.test.d.ts +1 -0
- package/dist/components/ShapeEditor/index.d.ts +1 -1
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +1235 -1217
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -18,19 +18,19 @@ var N = {
|
|
|
18
18
|
function P(e) {
|
|
19
19
|
return e.interaction?.visible !== !1;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function ee(e) {
|
|
22
22
|
return P(e) && e.interaction?.hitTestDisabled !== !0;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
function ee(e) {
|
|
28
|
-
return I(e) && !e.readOnly && e.interaction?.editable !== !1;
|
|
24
|
+
function F(e) {
|
|
25
|
+
return ee(e) && e.interaction?.selectable !== !1;
|
|
29
26
|
}
|
|
30
27
|
function te(e) {
|
|
31
|
-
return
|
|
28
|
+
return F(e) && !e.readOnly && e.interaction?.editable !== !1;
|
|
32
29
|
}
|
|
33
30
|
function ne(e) {
|
|
31
|
+
return te(e) && e.interaction?.draggable !== !1;
|
|
32
|
+
}
|
|
33
|
+
function re(e) {
|
|
34
34
|
return e.map((e, t) => ({
|
|
35
35
|
shape: e,
|
|
36
36
|
index: t
|
|
@@ -39,10 +39,10 @@ function ne(e) {
|
|
|
39
39
|
return n === r ? e.index - t.index : n - r;
|
|
40
40
|
}).map((e) => e.shape);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function ie() {
|
|
43
43
|
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `id_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
44
44
|
}
|
|
45
|
-
var
|
|
45
|
+
var I = [
|
|
46
46
|
"tl",
|
|
47
47
|
"t",
|
|
48
48
|
"tr",
|
|
@@ -52,7 +52,7 @@ var L = [
|
|
|
52
52
|
"bl",
|
|
53
53
|
"l"
|
|
54
54
|
];
|
|
55
|
-
function
|
|
55
|
+
function L(e) {
|
|
56
56
|
let t = e.map((e) => e.x), n = e.map((e) => e.y);
|
|
57
57
|
return {
|
|
58
58
|
minX: Math.min(...t),
|
|
@@ -61,33 +61,33 @@ function R(e) {
|
|
|
61
61
|
maxY: Math.max(...n)
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function ae(e, t) {
|
|
65
65
|
let n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2;
|
|
66
66
|
return {
|
|
67
67
|
x: e.includes("l") ? t.minX : e.includes("r") ? t.maxX : n,
|
|
68
68
|
y: e.includes("t") ? t.minY : e.includes("b") ? t.maxY : r
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function oe(e, t, n, r) {
|
|
72
72
|
let i = { ...t };
|
|
73
73
|
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;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function R(e, t) {
|
|
76
76
|
let n = t.x - e.x, r = t.y - e.y, i = Math.max(Math.abs(n), Math.abs(r));
|
|
77
77
|
return {
|
|
78
78
|
x: e.x + (n < 0 ? -i : i),
|
|
79
79
|
y: e.y + (r < 0 ? -i : i)
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function se(e, t, n) {
|
|
83
83
|
let r = Math.cos(n), i = Math.sin(n), a = e.x - t.x, o = e.y - t.y;
|
|
84
84
|
return {
|
|
85
85
|
x: t.x + a * r - o * i,
|
|
86
86
|
y: t.y + a * i + o * r
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
function
|
|
90
|
-
let t =
|
|
89
|
+
function z(e) {
|
|
90
|
+
let t = L(e);
|
|
91
91
|
return [
|
|
92
92
|
{
|
|
93
93
|
x: t.minX,
|
|
@@ -107,7 +107,7 @@ function B(e) {
|
|
|
107
107
|
}
|
|
108
108
|
];
|
|
109
109
|
}
|
|
110
|
-
function
|
|
110
|
+
function ce(e, t, n = 32) {
|
|
111
111
|
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;
|
|
112
112
|
return Array.from({ length: n }, (e, t) => {
|
|
113
113
|
let s = t / n * 2 * Math.PI;
|
|
@@ -117,7 +117,7 @@ function se(e, t, n = 32) {
|
|
|
117
117
|
};
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function le(e) {
|
|
121
121
|
let t = [...e].sort((e, t) => e.x - t.x || e.y - t.y);
|
|
122
122
|
if (t.length <= 2) return t;
|
|
123
123
|
let n = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), r = [];
|
|
@@ -133,10 +133,10 @@ function ce(e) {
|
|
|
133
133
|
}
|
|
134
134
|
return r.pop(), i.pop(), r.concat(i);
|
|
135
135
|
}
|
|
136
|
-
function
|
|
137
|
-
let t =
|
|
138
|
-
if (t.length < 3) return
|
|
139
|
-
let n = Infinity, r =
|
|
136
|
+
function B(e) {
|
|
137
|
+
let t = le(e);
|
|
138
|
+
if (t.length < 3) return z(e);
|
|
139
|
+
let n = Infinity, r = z(e);
|
|
140
140
|
for (let e = 0; e < t.length; e++) {
|
|
141
141
|
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;
|
|
142
142
|
for (let e of t) {
|
|
@@ -160,7 +160,7 @@ function V(e) {
|
|
|
160
160
|
}
|
|
161
161
|
return r;
|
|
162
162
|
}
|
|
163
|
-
var
|
|
163
|
+
var V = (e, t) => ({
|
|
164
164
|
x: e.x - t.x,
|
|
165
165
|
y: e.y - t.y
|
|
166
166
|
}), ue = (e, t) => e.x * t.x + e.y * t.y, de = (e) => Math.hypot(e.x, e.y), fe = (e) => {
|
|
@@ -185,7 +185,7 @@ var le = (e, t) => ({
|
|
|
185
185
|
y: t.y / e.length
|
|
186
186
|
};
|
|
187
187
|
};
|
|
188
|
-
function
|
|
188
|
+
function H(e) {
|
|
189
189
|
return [
|
|
190
190
|
e[0],
|
|
191
191
|
pe(e[0], e[1]),
|
|
@@ -197,14 +197,14 @@ function he(e) {
|
|
|
197
197
|
pe(e[3], e[0])
|
|
198
198
|
];
|
|
199
199
|
}
|
|
200
|
-
function
|
|
201
|
-
let n = pe(e[0], e[1]), r = fe(
|
|
200
|
+
function he(e, t) {
|
|
201
|
+
let n = pe(e[0], e[1]), r = fe(V(e[0], e[3]));
|
|
202
202
|
return {
|
|
203
203
|
x: n.x + r.x * t,
|
|
204
204
|
y: n.y + r.y * t
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
function
|
|
207
|
+
function ge(e, t, n, r) {
|
|
208
208
|
let i = (e, i) => ({
|
|
209
209
|
x: t.x + e * n.x + i * r.x,
|
|
210
210
|
y: t.y + e * n.y + i * r.y
|
|
@@ -216,37 +216,37 @@ function _e(e, t, n, r) {
|
|
|
216
216
|
i(e.minX, e.maxY)
|
|
217
217
|
];
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function _e(e, t, n) {
|
|
220
220
|
if (e.length < 4) return e;
|
|
221
|
-
let r = e[0], i = fe(
|
|
222
|
-
return
|
|
221
|
+
let r = e[0], i = fe(V(e[1], e[0])), a = fe(V(e[3], e[0])), o = ue(V(e[1], r), i), s = ue(V(e[3], r), a), c = V(n, r);
|
|
222
|
+
return ge(oe(t, {
|
|
223
223
|
minX: 0,
|
|
224
224
|
minY: 0,
|
|
225
225
|
maxX: o,
|
|
226
226
|
maxY: s
|
|
227
227
|
}, ue(c, i), ue(c, a)), r, i, a);
|
|
228
228
|
}
|
|
229
|
-
function
|
|
229
|
+
function ve(e, t, n) {
|
|
230
230
|
let r = t.maxX - t.minX || 1, i = t.maxY - t.minY || 1, a = n.maxX - n.minX, o = n.maxY - n.minY;
|
|
231
231
|
return e.map((e) => ({
|
|
232
232
|
x: n.minX + (e.x - t.minX) / r * a,
|
|
233
233
|
y: n.minY + (e.y - t.minY) / i * o
|
|
234
234
|
}));
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function ye(e, t, n, r) {
|
|
237
237
|
let i = (e, t, n) => Math.sign((t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x)), a = i(e, t, n), o = i(e, t, r), s = i(n, r, e), c = i(n, r, t);
|
|
238
238
|
return a !== o && s !== c && !(a === 0 && o === 0);
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function be(e, t = 256) {
|
|
241
241
|
let n = e.length;
|
|
242
242
|
if (n < 4 || n > t) return !1;
|
|
243
243
|
for (let t = 0; t < n; t++) {
|
|
244
244
|
let r = e[t], i = e[(t + 1) % n];
|
|
245
|
-
for (let a = t + 2; a < n; a++) if (!(t === 0 && a === n - 1) &&
|
|
245
|
+
for (let a = t + 2; a < n; a++) if (!(t === 0 && a === n - 1) && ye(r, i, e[a], e[(a + 1) % n])) return !0;
|
|
246
246
|
}
|
|
247
247
|
return !1;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function xe(e, t, n, r) {
|
|
250
250
|
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;
|
|
251
251
|
if (!c) return null;
|
|
252
252
|
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;
|
|
@@ -255,15 +255,15 @@ function Se(e, t, n, r) {
|
|
|
255
255
|
tj: u
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function Se(e, t = 256) {
|
|
259
259
|
let n = e.length;
|
|
260
|
-
if (n < 4 || n > t || !
|
|
260
|
+
if (n < 4 || n > t || !be(e, t)) return [e];
|
|
261
261
|
let r = Array.from({ length: n }, () => []), i = 0;
|
|
262
262
|
for (let t = 0; t < n; t++) {
|
|
263
263
|
let a = e[t], o = e[(t + 1) % n];
|
|
264
264
|
for (let s = t + 2; s < n; s++) {
|
|
265
265
|
if (t === 0 && s === n - 1) continue;
|
|
266
|
-
let c =
|
|
266
|
+
let c = xe(a, o, e[s], e[(s + 1) % n]);
|
|
267
267
|
c && (r[t].push({
|
|
268
268
|
t: c.ti,
|
|
269
269
|
id: i
|
|
@@ -318,7 +318,7 @@ function Ce(e, t = 256) {
|
|
|
318
318
|
}
|
|
319
319
|
//#endregion
|
|
320
320
|
//#region src/components/ShapeEditor/_model/strings.ts
|
|
321
|
-
var
|
|
321
|
+
var U = {
|
|
322
322
|
contextMenu: {
|
|
323
323
|
copy: "복사",
|
|
324
324
|
paste: "붙여넣기",
|
|
@@ -361,27 +361,27 @@ var H = {
|
|
|
361
361
|
imageLoading: "이미지를 불러오는 중…",
|
|
362
362
|
imageLoadError: "이미지를 불러올 수 없습니다"
|
|
363
363
|
};
|
|
364
|
-
function
|
|
364
|
+
function Ce(e) {
|
|
365
365
|
return e ? {
|
|
366
366
|
contextMenu: {
|
|
367
|
-
...
|
|
367
|
+
...U.contextMenu,
|
|
368
368
|
...e.contextMenu
|
|
369
369
|
},
|
|
370
370
|
viewSettings: {
|
|
371
|
-
...
|
|
371
|
+
...U.viewSettings,
|
|
372
372
|
...e.viewSettings
|
|
373
373
|
},
|
|
374
374
|
minimap: {
|
|
375
|
-
...
|
|
375
|
+
...U.minimap,
|
|
376
376
|
...e.minimap
|
|
377
377
|
},
|
|
378
|
-
imageLoading: e.imageLoading ??
|
|
379
|
-
imageLoadError: e.imageLoadError ??
|
|
380
|
-
} :
|
|
378
|
+
imageLoading: e.imageLoading ?? U.imageLoading,
|
|
379
|
+
imageLoadError: e.imageLoadError ?? U.imageLoadError
|
|
380
|
+
} : U;
|
|
381
381
|
}
|
|
382
382
|
//#endregion
|
|
383
383
|
//#region src/components/ShapeEditor/_model/tools.ts
|
|
384
|
-
var
|
|
384
|
+
var W = {
|
|
385
385
|
SELECT: "SELECT",
|
|
386
386
|
POLYGON: "POLYGON",
|
|
387
387
|
PATH: "PATH",
|
|
@@ -393,7 +393,7 @@ var U = {
|
|
|
393
393
|
ASSISTANT_POLYGON: "ASSISTANT_POLYGON",
|
|
394
394
|
ASSISTANT_RECT: "ASSISTANT_RECT",
|
|
395
395
|
ASSISTANT_POINT: "ASSISTANT_POINT"
|
|
396
|
-
},
|
|
396
|
+
}, we = {
|
|
397
397
|
brightness: 1,
|
|
398
398
|
contrast: 1,
|
|
399
399
|
showCursorGuide: !1,
|
|
@@ -405,9 +405,9 @@ var U = {
|
|
|
405
405
|
keepZoomOnImageChange: !1,
|
|
406
406
|
wheelZoom: !0,
|
|
407
407
|
zoomSensitivity: 1
|
|
408
|
-
},
|
|
409
|
-
function
|
|
410
|
-
let t = e.positive ?
|
|
408
|
+
}, Te = "var(--editor-overlay-inverse-scale, 1)", G = "#377be2", Ee = "#e23c3c";
|
|
409
|
+
function De({ point: e }) {
|
|
410
|
+
let t = e.positive ? G : Ee;
|
|
411
411
|
return /* @__PURE__ */ S("div", {
|
|
412
412
|
style: {
|
|
413
413
|
position: "absolute",
|
|
@@ -428,13 +428,13 @@ function ke({ point: e }) {
|
|
|
428
428
|
display: "flex",
|
|
429
429
|
alignItems: "center",
|
|
430
430
|
justifyContent: "center",
|
|
431
|
-
transform: `scale(${
|
|
431
|
+
transform: `scale(${Te})`,
|
|
432
432
|
transformOrigin: "center"
|
|
433
433
|
},
|
|
434
434
|
children: e.positive ? "+" : "−"
|
|
435
435
|
});
|
|
436
436
|
}
|
|
437
|
-
function
|
|
437
|
+
function Oe({ image: e, points: t, boxes: n, status: r }) {
|
|
438
438
|
return /* @__PURE__ */ C("div", {
|
|
439
439
|
style: {
|
|
440
440
|
position: "absolute",
|
|
@@ -458,13 +458,13 @@ function Ae({ image: e, points: t, boxes: n, status: r }) {
|
|
|
458
458
|
backgroundSize: "200% 100%",
|
|
459
459
|
animation: "editorv2-assistant-shimmer 1.4s linear infinite"
|
|
460
460
|
} }, `box-${t}-${e.x}-${e.y}-${e.width}-${e.height}`)),
|
|
461
|
-
r === "loading" && t.map((e, t) => /* @__PURE__ */ S(
|
|
461
|
+
r === "loading" && t.map((e, t) => /* @__PURE__ */ S(De, { point: e }, `pt-${t}-${e.x}-${e.y}`))
|
|
462
462
|
]
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
465
|
//#endregion
|
|
466
466
|
//#region src/components/ShapeEditor/_components/ContextMenu.tsx
|
|
467
|
-
function
|
|
467
|
+
function ke(e) {
|
|
468
468
|
let t = [];
|
|
469
469
|
for (let n of e) if ("separator" in n) {
|
|
470
470
|
if (!t.length || "separator" in t[t.length - 1]) continue;
|
|
@@ -473,8 +473,8 @@ function W(e) {
|
|
|
473
473
|
for (; t.length && "separator" in t[t.length - 1];) t.pop();
|
|
474
474
|
return t;
|
|
475
475
|
}
|
|
476
|
-
function
|
|
477
|
-
let i =
|
|
476
|
+
function Ae({ x: e, y: t, items: n, onClose: r }) {
|
|
477
|
+
let i = ke(n);
|
|
478
478
|
return /* @__PURE__ */ C(c, {
|
|
479
479
|
open: !0,
|
|
480
480
|
modal: !1,
|
|
@@ -525,7 +525,7 @@ function je({ x: e, y: t, items: n, onClose: r }) {
|
|
|
525
525
|
}
|
|
526
526
|
//#endregion
|
|
527
527
|
//#region src/components/ShapeEditor/_components/CursorGuide.tsx
|
|
528
|
-
function
|
|
528
|
+
function je({ color: e = "#1e88e5" }) {
|
|
529
529
|
let t = y(null), n = y(null), r = y(null);
|
|
530
530
|
return p(() => {
|
|
531
531
|
let e = t.current, i = n.current, a = r.current;
|
|
@@ -575,7 +575,7 @@ function Me({ color: e = "#1e88e5" }) {
|
|
|
575
575
|
}
|
|
576
576
|
//#endregion
|
|
577
577
|
//#region src/components/ShapeEditor/_components/ImageStateOverlay.tsx
|
|
578
|
-
function
|
|
578
|
+
function Me({ status: e, render: t, loadingLabel: n = U.imageLoading, errorLabel: r = U.imageLoadError }) {
|
|
579
579
|
return /* @__PURE__ */ S("div", {
|
|
580
580
|
"data-track-id": e === "loading" ? "editor-image-loading-wrap" : "editor-image-error-wrap",
|
|
581
581
|
style: {
|
|
@@ -628,11 +628,11 @@ function Ne({ status: e, render: t, loadingLabel: n = H.imageLoading, errorLabel
|
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
Math.PI / 12;
|
|
631
|
-
var
|
|
631
|
+
var Ne = "#669DEF", K = .1, Pe = .7, Fe = 2.5;
|
|
632
632
|
//#endregion
|
|
633
633
|
//#region src/components/ShapeEditor/_model/shapeRenderStyle.ts
|
|
634
|
-
function
|
|
635
|
-
let n = e.style?.color ?? "#00e5ff", r = !!e.readOnly, i = e.style?.strokeWidth ?? t.strokeWidth ?? 2, a = r ? i *
|
|
634
|
+
function Ie(e, t = {}) {
|
|
635
|
+
let n = e.style?.color ?? "#00e5ff", r = !!e.readOnly, i = e.style?.strokeWidth ?? t.strokeWidth ?? 2, a = r ? i * Fe : i, o = r ? Pe : e.style?.opacity ?? 1, s = e.style?.fillOpacity ?? .12549019607843137, c = e.style?.dash ?? (r ? [a, a * 2] : void 0);
|
|
636
636
|
return {
|
|
637
637
|
color: n,
|
|
638
638
|
strokeWidth: a,
|
|
@@ -643,7 +643,7 @@ function G(e, t = {}) {
|
|
|
643
643
|
pointRadius: e.style?.pointRadius ?? t.pointRadius ?? 5
|
|
644
644
|
};
|
|
645
645
|
}
|
|
646
|
-
function
|
|
646
|
+
function q(e, t) {
|
|
647
647
|
let n = Math.max(0, Math.min(1, t)), r = e.trim().replace("#", "");
|
|
648
648
|
if (r.length === 3 || r.length === 6) {
|
|
649
649
|
let e = r.length === 3 ? r.replace(/./g, (e) => e + e) : r, t = Number.parseInt(e, 16);
|
|
@@ -653,8 +653,8 @@ function Re(e, t) {
|
|
|
653
653
|
}
|
|
654
654
|
//#endregion
|
|
655
655
|
//#region src/components/ShapeEditor/_components/MinimapShape.tsx
|
|
656
|
-
var
|
|
657
|
-
let { type: r, points: i } = e, a =
|
|
656
|
+
var Le = d(function({ shape: e, strokeSize: t, register: n }) {
|
|
657
|
+
let { type: r, points: i } = e, a = Ie(e, { strokeWidth: t }), o = (t) => n?.(e.id, t), s = {
|
|
658
658
|
ref: o,
|
|
659
659
|
stroke: a.color,
|
|
660
660
|
strokeWidth: a.strokeWidth,
|
|
@@ -673,7 +673,7 @@ var ze = d(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
673
673
|
opacity: a.opacity
|
|
674
674
|
});
|
|
675
675
|
if (r === N.RECTANGLE || r === N.ELLIPSE) {
|
|
676
|
-
let e =
|
|
676
|
+
let e = L(i);
|
|
677
677
|
return r === N.ELLIPSE ? /* @__PURE__ */ S("ellipse", {
|
|
678
678
|
cx: (e.minX + e.maxX) / 2,
|
|
679
679
|
cy: (e.minY + e.maxY) / 2,
|
|
@@ -699,7 +699,7 @@ var ze = d(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
699
699
|
});
|
|
700
700
|
//#endregion
|
|
701
701
|
//#region src/components/ShapeEditor/_components/RegionOverlay.tsx
|
|
702
|
-
function
|
|
702
|
+
function Re({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth: a, strokeDasharray: o, style: s }) {
|
|
703
703
|
let c = [...t.visibleOutline, ...t.occludedOutline];
|
|
704
704
|
return /* @__PURE__ */ C("svg", {
|
|
705
705
|
width: r,
|
|
@@ -753,11 +753,11 @@ function Be({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth:
|
|
|
753
753
|
}
|
|
754
754
|
//#endregion
|
|
755
755
|
//#region src/components/ShapeEditor/_components/SettingsPanel.tsx
|
|
756
|
-
var
|
|
756
|
+
var ze = {
|
|
757
757
|
trackRootClassName: "aivex:h-1.5",
|
|
758
758
|
thumbClassName: "aivex:h-4 aivex:w-4 aivex:border"
|
|
759
759
|
};
|
|
760
|
-
function
|
|
760
|
+
function Be({ value: e, onChange: t, onClose: n, labels: r = U.viewSettings }) {
|
|
761
761
|
return p(() => {
|
|
762
762
|
let e = (e) => {
|
|
763
763
|
e.key === "Escape" && n();
|
|
@@ -777,11 +777,11 @@ function Ve({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
777
777
|
}), /* @__PURE__ */ S(a, {
|
|
778
778
|
variant: "ghost",
|
|
779
779
|
size: "sm",
|
|
780
|
-
onClick: () => t({ ...
|
|
780
|
+
onClick: () => t({ ...we }),
|
|
781
781
|
children: r.reset
|
|
782
782
|
})]
|
|
783
783
|
}),
|
|
784
|
-
/* @__PURE__ */ S(
|
|
784
|
+
/* @__PURE__ */ S(Ve, {
|
|
785
785
|
label: `${r.brightness} ${e.brightness.toFixed(2)}`,
|
|
786
786
|
children: /* @__PURE__ */ S(l, {
|
|
787
787
|
min: 0,
|
|
@@ -789,10 +789,10 @@ function Ve({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
789
789
|
step: .05,
|
|
790
790
|
value: [e.brightness],
|
|
791
791
|
onValueChange: ([e]) => t({ brightness: e }),
|
|
792
|
-
...
|
|
792
|
+
...ze
|
|
793
793
|
})
|
|
794
794
|
}),
|
|
795
|
-
/* @__PURE__ */ S(
|
|
795
|
+
/* @__PURE__ */ S(Ve, {
|
|
796
796
|
label: `${r.contrast} ${e.contrast.toFixed(2)}`,
|
|
797
797
|
children: /* @__PURE__ */ S(l, {
|
|
798
798
|
min: 0,
|
|
@@ -800,10 +800,10 @@ function Ve({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
800
800
|
step: .05,
|
|
801
801
|
value: [e.contrast],
|
|
802
802
|
onValueChange: ([e]) => t({ contrast: e }),
|
|
803
|
-
...
|
|
803
|
+
...ze
|
|
804
804
|
})
|
|
805
805
|
}),
|
|
806
|
-
/* @__PURE__ */ S(
|
|
806
|
+
/* @__PURE__ */ S(Ve, {
|
|
807
807
|
label: `${r.strokeSize} ${e.strokeSize}`,
|
|
808
808
|
children: /* @__PURE__ */ S(l, {
|
|
809
809
|
min: 1,
|
|
@@ -811,10 +811,10 @@ function Ve({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
811
811
|
step: .5,
|
|
812
812
|
value: [e.strokeSize],
|
|
813
813
|
onValueChange: ([e]) => t({ strokeSize: e }),
|
|
814
|
-
...
|
|
814
|
+
...ze
|
|
815
815
|
})
|
|
816
816
|
}),
|
|
817
|
-
/* @__PURE__ */ S(
|
|
817
|
+
/* @__PURE__ */ S(Ve, {
|
|
818
818
|
label: `${r.simplifyStrength} ${e.simplifyStrength}`,
|
|
819
819
|
children: /* @__PURE__ */ S(l, {
|
|
820
820
|
min: .5,
|
|
@@ -822,10 +822,10 @@ function Ve({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
822
822
|
step: .5,
|
|
823
823
|
value: [e.simplifyStrength],
|
|
824
824
|
onValueChange: ([e]) => t({ simplifyStrength: e }),
|
|
825
|
-
...
|
|
825
|
+
...ze
|
|
826
826
|
})
|
|
827
827
|
}),
|
|
828
|
-
/* @__PURE__ */ S(
|
|
828
|
+
/* @__PURE__ */ S(Ve, {
|
|
829
829
|
label: `${r.zoomSensitivity} ${e.zoomSensitivity.toFixed(1)}`,
|
|
830
830
|
children: /* @__PURE__ */ S(l, {
|
|
831
831
|
min: .2,
|
|
@@ -833,39 +833,39 @@ function Ve({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
833
833
|
step: .1,
|
|
834
834
|
value: [e.zoomSensitivity],
|
|
835
835
|
onValueChange: ([e]) => t({ zoomSensitivity: e }),
|
|
836
|
-
...
|
|
836
|
+
...ze
|
|
837
837
|
})
|
|
838
838
|
}),
|
|
839
839
|
/* @__PURE__ */ S("div", {
|
|
840
840
|
className: "aivex:my-2",
|
|
841
841
|
children: /* @__PURE__ */ S(s, {})
|
|
842
842
|
}),
|
|
843
|
-
/* @__PURE__ */ S(
|
|
843
|
+
/* @__PURE__ */ S(He, {
|
|
844
844
|
label: r.pixelation,
|
|
845
845
|
checked: !e.imageSmoothing,
|
|
846
846
|
onChange: (e) => t({ imageSmoothing: !e })
|
|
847
847
|
}),
|
|
848
|
-
/* @__PURE__ */ S(
|
|
848
|
+
/* @__PURE__ */ S(He, {
|
|
849
849
|
label: r.cursorGuide,
|
|
850
850
|
checked: e.showCursorGuide,
|
|
851
851
|
onChange: (e) => t({ showCursorGuide: e })
|
|
852
852
|
}),
|
|
853
|
-
/* @__PURE__ */ S(
|
|
853
|
+
/* @__PURE__ */ S(He, {
|
|
854
854
|
label: r.guideMask,
|
|
855
855
|
checked: e.showGuide,
|
|
856
856
|
onChange: (e) => t({ showGuide: e })
|
|
857
857
|
}),
|
|
858
|
-
/* @__PURE__ */ S(
|
|
858
|
+
/* @__PURE__ */ S(He, {
|
|
859
859
|
label: r.regionMask,
|
|
860
860
|
checked: e.showRegionMask,
|
|
861
861
|
onChange: (e) => t({ showRegionMask: e })
|
|
862
862
|
}),
|
|
863
|
-
/* @__PURE__ */ S(
|
|
863
|
+
/* @__PURE__ */ S(He, {
|
|
864
864
|
label: r.keepZoomOnImageChange,
|
|
865
865
|
checked: e.keepZoomOnImageChange,
|
|
866
866
|
onChange: (e) => t({ keepZoomOnImageChange: e })
|
|
867
867
|
}),
|
|
868
|
-
/* @__PURE__ */ S(
|
|
868
|
+
/* @__PURE__ */ S(He, {
|
|
869
869
|
label: r.wheelZoom,
|
|
870
870
|
checked: e.wheelZoom,
|
|
871
871
|
onChange: (e) => t({ wheelZoom: e })
|
|
@@ -873,7 +873,7 @@ function Ve({ value: e, onChange: t, onClose: n, labels: r = H.viewSettings }) {
|
|
|
873
873
|
]
|
|
874
874
|
});
|
|
875
875
|
}
|
|
876
|
-
function
|
|
876
|
+
function Ve({ label: e, children: t }) {
|
|
877
877
|
return /* @__PURE__ */ C("div", {
|
|
878
878
|
className: "aivex:mb-2 aivex:block",
|
|
879
879
|
children: [/* @__PURE__ */ S("span", {
|
|
@@ -882,7 +882,7 @@ function He({ label: e, children: t }) {
|
|
|
882
882
|
}), t]
|
|
883
883
|
});
|
|
884
884
|
}
|
|
885
|
-
function
|
|
885
|
+
function He({ label: e, checked: t, onChange: n }) {
|
|
886
886
|
return /* @__PURE__ */ C("div", {
|
|
887
887
|
className: "aivex:flex aivex:items-center aivex:justify-between aivex:py-1",
|
|
888
888
|
children: [/* @__PURE__ */ S("span", { children: e }), /* @__PURE__ */ S(u, {
|
|
@@ -894,13 +894,13 @@ function Ue({ label: e, checked: t, onChange: n }) {
|
|
|
894
894
|
}
|
|
895
895
|
//#endregion
|
|
896
896
|
//#region src/components/ShapeEditor/_components/Minimap.tsx
|
|
897
|
-
var
|
|
898
|
-
let { offX: j, offY: M, dispW: N, dispH:
|
|
897
|
+
var Ue = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l = !1, maskDataUrl: u, region: d, roiMaskId: f, shapes: p, view: m, onChangeView: h, nav: g, registerShape: _, rectRef: v, zoomLabelRef: y, onZoom100: b, open: x, onToggleOpen: w, showSettings: T = !0, settingsOpen: E, onToggleSettings: D, onCloseSettings: O, labels: k = U.minimap, settingsLabels: A }) {
|
|
898
|
+
let { offX: j, offY: M, dispW: N, dispH: ee, zoomCentered: F } = g, te = {
|
|
899
899
|
position: "absolute",
|
|
900
900
|
left: j,
|
|
901
901
|
top: M,
|
|
902
902
|
width: N,
|
|
903
|
-
height:
|
|
903
|
+
height: ee
|
|
904
904
|
};
|
|
905
905
|
return /* @__PURE__ */ C("div", {
|
|
906
906
|
className: "aivex:absolute aivex:bottom-2 aivex:left-2 aivex:w-[188px] aivex:rounded-[8px] aivex:border aivex:border-border-default aivex:bg-bg-primary aivex:p-[4px] aivex:shadow-lg",
|
|
@@ -926,25 +926,25 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
926
926
|
src: s,
|
|
927
927
|
alt: "",
|
|
928
928
|
draggable: !1,
|
|
929
|
-
style:
|
|
929
|
+
style: te
|
|
930
930
|
}),
|
|
931
931
|
u && m.showGuide && /* @__PURE__ */ S("img", {
|
|
932
932
|
src: u,
|
|
933
933
|
alt: "",
|
|
934
934
|
draggable: !1,
|
|
935
935
|
style: {
|
|
936
|
-
...
|
|
936
|
+
...te,
|
|
937
937
|
opacity: .55,
|
|
938
938
|
imageRendering: "pixelated",
|
|
939
939
|
pointerEvents: "none"
|
|
940
940
|
}
|
|
941
941
|
}),
|
|
942
|
-
m.showRegionMask && d && d.rects.length > 0 && /* @__PURE__ */ S(
|
|
942
|
+
m.showRegionMask && d && d.rects.length > 0 && /* @__PURE__ */ S(Re, {
|
|
943
943
|
image: e,
|
|
944
944
|
region: d,
|
|
945
945
|
maskId: f,
|
|
946
946
|
width: N,
|
|
947
|
-
height:
|
|
947
|
+
height: ee,
|
|
948
948
|
strokeWidth: 1,
|
|
949
949
|
strokeDasharray: "4 4",
|
|
950
950
|
style: {
|
|
@@ -957,7 +957,7 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
957
957
|
/* @__PURE__ */ S("svg", {
|
|
958
958
|
viewBox: `0 0 ${e.w} ${e.h}`,
|
|
959
959
|
width: N,
|
|
960
|
-
height:
|
|
960
|
+
height: ee,
|
|
961
961
|
style: {
|
|
962
962
|
position: "absolute",
|
|
963
963
|
left: j,
|
|
@@ -965,7 +965,7 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
965
965
|
pointerEvents: "none"
|
|
966
966
|
},
|
|
967
967
|
"aria-hidden": !0,
|
|
968
|
-
children:
|
|
968
|
+
children: re(p).filter(P).map((e) => /* @__PURE__ */ S(Le, {
|
|
969
969
|
shape: e,
|
|
970
970
|
strokeSize: m.strokeSize,
|
|
971
971
|
register: _
|
|
@@ -993,7 +993,7 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
993
993
|
variant: "ghost",
|
|
994
994
|
size: "icon-sm",
|
|
995
995
|
"aria-label": k.zoomOut,
|
|
996
|
-
onClick: () =>
|
|
996
|
+
onClick: () => F(1 / 1.2),
|
|
997
997
|
disabled: l,
|
|
998
998
|
children: /* @__PURE__ */ S(r, { size: 16 })
|
|
999
999
|
}),
|
|
@@ -1013,7 +1013,7 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
1013
1013
|
variant: "ghost",
|
|
1014
1014
|
size: "icon-sm",
|
|
1015
1015
|
"aria-label": k.zoomIn,
|
|
1016
|
-
onClick: () =>
|
|
1016
|
+
onClick: () => F(1.2),
|
|
1017
1017
|
disabled: l,
|
|
1018
1018
|
children: /* @__PURE__ */ S(o, { size: 16 })
|
|
1019
1019
|
})
|
|
@@ -1038,7 +1038,7 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
1038
1038
|
onClick: w,
|
|
1039
1039
|
children: S(x ? i : t, { size: 16 })
|
|
1040
1040
|
}),
|
|
1041
|
-
T && E && /* @__PURE__ */ S(
|
|
1041
|
+
T && E && /* @__PURE__ */ S(Be, {
|
|
1042
1042
|
value: m,
|
|
1043
1043
|
onChange: h,
|
|
1044
1044
|
onClose: O,
|
|
@@ -1048,7 +1048,7 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
1048
1048
|
})]
|
|
1049
1049
|
})]
|
|
1050
1050
|
});
|
|
1051
|
-
}),
|
|
1051
|
+
}), We = "var(--editor-overlay-inverse-scale, 1)", Ge = 6, Ke = {
|
|
1052
1052
|
fontFamily: "Pretendard, sans-serif",
|
|
1053
1053
|
fontSize: 12,
|
|
1054
1054
|
fontWeight: 500,
|
|
@@ -1057,8 +1057,8 @@ var We = d(function({ image: e, imageUrl: s, imageVisible: c = !0, loading: l =
|
|
|
1057
1057
|
textShadow: "0 0 4px #000, 0 0 4px #000",
|
|
1058
1058
|
whiteSpace: "nowrap"
|
|
1059
1059
|
};
|
|
1060
|
-
function
|
|
1061
|
-
let t =
|
|
1060
|
+
function qe(e) {
|
|
1061
|
+
let t = L(e);
|
|
1062
1062
|
return {
|
|
1063
1063
|
x: t.minX,
|
|
1064
1064
|
y: t.minY,
|
|
@@ -1066,25 +1066,25 @@ function Je(e) {
|
|
|
1066
1066
|
height: t.maxY - t.minY
|
|
1067
1067
|
};
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1070
|
-
return `translate3d(${e.width}px, ${e.height}px, 0) scale(${
|
|
1069
|
+
function Je(e) {
|
|
1070
|
+
return `translate3d(${e.width}px, ${e.height}px, 0) scale(${We}) translate(-100%, ${Ge}px)`;
|
|
1071
1071
|
}
|
|
1072
|
-
function
|
|
1073
|
-
let n =
|
|
1072
|
+
function Ye(e, t) {
|
|
1073
|
+
let n = qe(t);
|
|
1074
1074
|
e.style.transform = `translate3d(${n.x}px, ${n.y}px, 0)`;
|
|
1075
1075
|
let r = e.querySelector("[data-selinfo-dim]");
|
|
1076
|
-
return r && (r.style.transform =
|
|
1076
|
+
return r && (r.style.transform = Je(n)), r;
|
|
1077
1077
|
}
|
|
1078
|
-
function
|
|
1078
|
+
function Xe(e, t) {
|
|
1079
1079
|
return {
|
|
1080
1080
|
shape: e,
|
|
1081
|
-
...
|
|
1081
|
+
...qe(t)
|
|
1082
1082
|
};
|
|
1083
1083
|
}
|
|
1084
|
-
function
|
|
1084
|
+
function Ze(e) {
|
|
1085
1085
|
return `${Math.round(e.width)} x ${Math.round(e.height)} px`;
|
|
1086
1086
|
}
|
|
1087
|
-
function
|
|
1087
|
+
function Qe({ color: e, striped: t }) {
|
|
1088
1088
|
return /* @__PURE__ */ S("span", { style: {
|
|
1089
1089
|
display: "inline-block",
|
|
1090
1090
|
width: 12,
|
|
@@ -1096,9 +1096,9 @@ function $e({ color: e, striped: t }) {
|
|
|
1096
1096
|
} : { background: e }
|
|
1097
1097
|
} });
|
|
1098
1098
|
}
|
|
1099
|
-
function
|
|
1099
|
+
function $e({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
1100
1100
|
return /* @__PURE__ */ S(x, { children: e.map((e) => {
|
|
1101
|
-
let a =
|
|
1101
|
+
let a = qe(e.points), o = e.type === N.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.readOnly || !!e.style?.dash, u = Xe(e, e.points), d = r ? r(u) : Ze(u);
|
|
1102
1102
|
return /* @__PURE__ */ C("div", {
|
|
1103
1103
|
ref: (t) => i(e.id, t),
|
|
1104
1104
|
style: {
|
|
@@ -1117,11 +1117,11 @@ function et({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1117
1117
|
display: "flex",
|
|
1118
1118
|
alignItems: "center",
|
|
1119
1119
|
gap: 4,
|
|
1120
|
-
transform: `scale(${
|
|
1120
|
+
transform: `scale(${We}) translateY(calc(-100% - ${Ge}px))`,
|
|
1121
1121
|
transformOrigin: "left top",
|
|
1122
|
-
...
|
|
1122
|
+
...Ke
|
|
1123
1123
|
},
|
|
1124
|
-
children: [!n && /* @__PURE__ */ S(
|
|
1124
|
+
children: [!n && /* @__PURE__ */ S(Qe, {
|
|
1125
1125
|
color: c,
|
|
1126
1126
|
striped: l
|
|
1127
1127
|
}), /* @__PURE__ */ S("span", { children: s })]
|
|
@@ -1131,10 +1131,10 @@ function et({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1131
1131
|
position: "absolute",
|
|
1132
1132
|
left: 0,
|
|
1133
1133
|
top: 0,
|
|
1134
|
-
transform:
|
|
1134
|
+
transform: Je(a),
|
|
1135
1135
|
transformOrigin: "left top",
|
|
1136
1136
|
willChange: "transform",
|
|
1137
|
-
...
|
|
1137
|
+
...Ke
|
|
1138
1138
|
},
|
|
1139
1139
|
children: d
|
|
1140
1140
|
})]
|
|
@@ -1143,7 +1143,7 @@ function et({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1143
1143
|
}
|
|
1144
1144
|
//#endregion
|
|
1145
1145
|
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1146
|
-
var
|
|
1146
|
+
var et = "AIVEX_SHAPE_EDITOR:", tt = 1, nt = new Set(Object.values(N)), rt = null, it = "unavailable", at = 0;
|
|
1147
1147
|
function J(e) {
|
|
1148
1148
|
if (!e || typeof e != "object") return !1;
|
|
1149
1149
|
let t = e;
|
|
@@ -1152,12 +1152,12 @@ function J(e) {
|
|
|
1152
1152
|
function ot(e) {
|
|
1153
1153
|
if (!e || typeof e != "object") return !1;
|
|
1154
1154
|
let t = e;
|
|
1155
|
-
return typeof t.type == "string" &&
|
|
1155
|
+
return typeof t.type == "string" && nt.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(J);
|
|
1156
1156
|
}
|
|
1157
1157
|
function st(e, t, n) {
|
|
1158
1158
|
return {
|
|
1159
1159
|
kind: "aivex-shape-editor",
|
|
1160
|
-
version:
|
|
1160
|
+
version: tt,
|
|
1161
1161
|
scope: n,
|
|
1162
1162
|
documentId: t,
|
|
1163
1163
|
shapes: e
|
|
@@ -1168,20 +1168,20 @@ function ct(e) {
|
|
|
1168
1168
|
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
1169
1169
|
return `fnv1a:${(t >>> 0).toString(36)}`;
|
|
1170
1170
|
}
|
|
1171
|
-
function
|
|
1172
|
-
return `${
|
|
1171
|
+
function Y(e) {
|
|
1172
|
+
return `${et}${JSON.stringify(e)}`;
|
|
1173
1173
|
}
|
|
1174
|
-
function
|
|
1175
|
-
if (!e.startsWith(
|
|
1174
|
+
function lt(e) {
|
|
1175
|
+
if (!e.startsWith(et)) return null;
|
|
1176
1176
|
try {
|
|
1177
1177
|
let t = JSON.parse(e.slice(19));
|
|
1178
|
-
return t.kind !== "aivex-shape-editor" || t.version !==
|
|
1178
|
+
return t.kind !== "aivex-shape-editor" || t.version !== tt || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(ot) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
|
|
1179
1179
|
} catch {
|
|
1180
1180
|
return null;
|
|
1181
1181
|
}
|
|
1182
1182
|
}
|
|
1183
|
-
function
|
|
1184
|
-
|
|
1183
|
+
function ut(e) {
|
|
1184
|
+
rt = e;
|
|
1185
1185
|
let t = ++at;
|
|
1186
1186
|
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
1187
1187
|
it = "unavailable";
|
|
@@ -1189,7 +1189,7 @@ function Y(e) {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
let n;
|
|
1191
1191
|
try {
|
|
1192
|
-
n =
|
|
1192
|
+
n = Y(e);
|
|
1193
1193
|
} catch {
|
|
1194
1194
|
it = "unavailable";
|
|
1195
1195
|
return;
|
|
@@ -1204,14 +1204,14 @@ function dt(e, t) {
|
|
|
1204
1204
|
return !!e && e.scope === t;
|
|
1205
1205
|
}
|
|
1206
1206
|
function ft(e) {
|
|
1207
|
-
return dt(
|
|
1207
|
+
return dt(rt, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
|
|
1208
1208
|
}
|
|
1209
1209
|
async function X(e) {
|
|
1210
|
-
let t = dt(
|
|
1210
|
+
let t = dt(rt, e) ? rt : null;
|
|
1211
1211
|
if (t && it !== "written") return t;
|
|
1212
1212
|
if (typeof navigator < "u" && navigator.clipboard?.readText) try {
|
|
1213
|
-
let t =
|
|
1214
|
-
return t?.scope === e ? (
|
|
1213
|
+
let t = lt(await navigator.clipboard.readText());
|
|
1214
|
+
return t?.scope === e ? (rt = t, t) : null;
|
|
1215
1215
|
} catch {}
|
|
1216
1216
|
return t;
|
|
1217
1217
|
}
|
|
@@ -1224,17 +1224,17 @@ function pt(e, t, n) {
|
|
|
1224
1224
|
//#endregion
|
|
1225
1225
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1226
1226
|
var mt = new Set([
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
]),
|
|
1227
|
+
W.RECTANGLE,
|
|
1228
|
+
W.ROTATED_RECTANGLE,
|
|
1229
|
+
W.CIRCLE,
|
|
1230
|
+
W.POLYGON,
|
|
1231
|
+
W.PATH,
|
|
1232
|
+
W.BRUSH,
|
|
1233
|
+
W.POINT,
|
|
1234
|
+
W.ASSISTANT_POLYGON,
|
|
1235
|
+
W.ASSISTANT_RECT,
|
|
1236
|
+
W.ASSISTANT_POINT
|
|
1237
|
+
]), Z = {
|
|
1238
1238
|
tl: -135,
|
|
1239
1239
|
t: -90,
|
|
1240
1240
|
tr: -45,
|
|
@@ -1243,21 +1243,21 @@ var mt = new Set([
|
|
|
1243
1243
|
b: 90,
|
|
1244
1244
|
bl: 135,
|
|
1245
1245
|
l: 180
|
|
1246
|
-
},
|
|
1246
|
+
}, ht = [
|
|
1247
1247
|
"ew-resize",
|
|
1248
1248
|
"nwse-resize",
|
|
1249
1249
|
"ns-resize",
|
|
1250
1250
|
"nesw-resize"
|
|
1251
1251
|
];
|
|
1252
|
-
function
|
|
1253
|
-
let n = ((
|
|
1254
|
-
return
|
|
1252
|
+
function gt(e, t = 0) {
|
|
1253
|
+
let n = ((Z[e] + t * 180 / Math.PI) % 180 + 180) % 180;
|
|
1254
|
+
return ht[Math.round(n / 45) % 4];
|
|
1255
1255
|
}
|
|
1256
|
-
function
|
|
1257
|
-
return n ? "grab" : t || (e ===
|
|
1256
|
+
function _t({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1257
|
+
return n ? "grab" : t || (e === W.SELECT ? "default" : mt.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1258
1258
|
}
|
|
1259
|
-
function
|
|
1260
|
-
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e ===
|
|
1259
|
+
function vt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1260
|
+
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === W.SELECT && i ? i : _t({
|
|
1261
1261
|
tool: e,
|
|
1262
1262
|
externalToolCursor: t,
|
|
1263
1263
|
isSpacePressed: n,
|
|
@@ -1266,7 +1266,7 @@ function yt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode
|
|
|
1266
1266
|
}
|
|
1267
1267
|
//#endregion
|
|
1268
1268
|
//#region src/components/ShapeEditor/_model/overlays.ts
|
|
1269
|
-
var
|
|
1269
|
+
var yt = (e) => Math.min(255, Math.max(0, e)), bt = (e) => {
|
|
1270
1270
|
let t = e.replace("#", "").trim();
|
|
1271
1271
|
if (![
|
|
1272
1272
|
3,
|
|
@@ -1280,13 +1280,13 @@ var bt = (e) => Math.min(255, Math.max(0, e)), xt = (e) => {
|
|
|
1280
1280
|
c(o),
|
|
1281
1281
|
c(s)
|
|
1282
1282
|
];
|
|
1283
|
-
return l.some((e) => Number.isNaN(e)) ? null : l.map(
|
|
1284
|
-
},
|
|
1283
|
+
return l.some((e) => Number.isNaN(e)) ? null : l.map(yt);
|
|
1284
|
+
}, xt = (e, t) => {
|
|
1285
1285
|
let { width: n, height: r, indices: i, transparent: a } = e;
|
|
1286
1286
|
if (!n || !r || i.length < n * r) return null;
|
|
1287
1287
|
let o = {};
|
|
1288
1288
|
for (let [e, n] of Object.entries(t)) {
|
|
1289
|
-
let t =
|
|
1289
|
+
let t = bt(n);
|
|
1290
1290
|
t && (o[Number(e)] = t);
|
|
1291
1291
|
}
|
|
1292
1292
|
if (!Object.keys(o).length) return null;
|
|
@@ -1305,12 +1305,12 @@ var bt = (e) => Math.min(255, Math.max(0, e)), xt = (e) => {
|
|
|
1305
1305
|
}
|
|
1306
1306
|
return c.putImageData(new ImageData(l, n, r), 0, 0), s;
|
|
1307
1307
|
};
|
|
1308
|
-
function
|
|
1308
|
+
function St(e, t) {
|
|
1309
1309
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
1310
1310
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
1311
1311
|
e.closePath();
|
|
1312
1312
|
}
|
|
1313
|
-
var
|
|
1313
|
+
var Ct = (e) => [
|
|
1314
1314
|
{
|
|
1315
1315
|
x: e.x,
|
|
1316
1316
|
y: e.y
|
|
@@ -1328,7 +1328,7 @@ var wt = (e) => [
|
|
|
1328
1328
|
y: e.y + e.h
|
|
1329
1329
|
}
|
|
1330
1330
|
];
|
|
1331
|
-
function
|
|
1331
|
+
function wt(e, t) {
|
|
1332
1332
|
let n = !1;
|
|
1333
1333
|
for (let r = 0, i = t.length - 1; r < t.length; i = r, r += 1) {
|
|
1334
1334
|
let a = t[r], o = t[i];
|
|
@@ -1339,7 +1339,7 @@ function Tt(e, t) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
return n;
|
|
1341
1341
|
}
|
|
1342
|
-
function
|
|
1342
|
+
function Tt(e, t, n) {
|
|
1343
1343
|
let r = [], i = t.x - e.x, a = t.y - e.y;
|
|
1344
1344
|
for (let t = 0; t < n.length; t += 1) {
|
|
1345
1345
|
let o = n[t], s = n[(t + 1) % n.length], c = s.x - o.x, l = s.y - o.y, u = i * l - a * c;
|
|
@@ -1349,15 +1349,15 @@ function Et(e, t, n) {
|
|
|
1349
1349
|
}
|
|
1350
1350
|
return r;
|
|
1351
1351
|
}
|
|
1352
|
-
function
|
|
1352
|
+
function Et(e, t, n) {
|
|
1353
1353
|
let r = .001, i = [], a = (e, t, n) => ({
|
|
1354
1354
|
x: e.x + (t.x - e.x) * n,
|
|
1355
1355
|
y: e.y + (t.y - e.y) * n
|
|
1356
1356
|
});
|
|
1357
1357
|
for (let o of e) if (!(o.length < 2)) for (let e = 0; e < o.length; e += 1) {
|
|
1358
1358
|
let s = o[e], c = o[(e + 1) % o.length], l = [0, 1];
|
|
1359
|
-
for (let e of t) e !== o && l.push(...
|
|
1360
|
-
if (n) for (let e of n) l.push(...
|
|
1359
|
+
for (let e of t) e !== o && l.push(...Tt(s, c, e));
|
|
1360
|
+
if (n) for (let e of n) l.push(...Tt(s, c, e));
|
|
1361
1361
|
let u = Math.hypot(c.x - s.x, c.y - s.y);
|
|
1362
1362
|
if (!u) continue;
|
|
1363
1363
|
let d = -(c.y - s.y) / u * r, f = (c.x - s.x) / u * r;
|
|
@@ -1371,13 +1371,13 @@ function Dt(e, t, n) {
|
|
|
1371
1371
|
}, h = {
|
|
1372
1372
|
x: p.x - d,
|
|
1373
1373
|
y: p.y - f
|
|
1374
|
-
}, g =
|
|
1375
|
-
t.some((e) => e !== o &&
|
|
1374
|
+
}, g = wt(m, o) ? m : h, _ = g === m ? h : m;
|
|
1375
|
+
t.some((e) => e !== o && wt(_, e)) || n && !n.some((e) => wt(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
|
|
1376
1376
|
}
|
|
1377
1377
|
}
|
|
1378
1378
|
return i;
|
|
1379
1379
|
}
|
|
1380
|
-
function
|
|
1380
|
+
function Dt(e) {
|
|
1381
1381
|
let t = [...new Set(e.flatMap((e) => [e.x, e.x + e.w]))].sort((e, t) => e - t), n = [];
|
|
1382
1382
|
for (let r = 0; r + 1 < t.length; r += 1) {
|
|
1383
1383
|
let i = t[r], a = t[r + 1];
|
|
@@ -1398,26 +1398,26 @@ function Ot(e) {
|
|
|
1398
1398
|
}
|
|
1399
1399
|
return n;
|
|
1400
1400
|
}
|
|
1401
|
-
function
|
|
1401
|
+
function Ot(e, t, n, r) {
|
|
1402
1402
|
e.save(), e.globalAlpha *= t.dim.opacity, e.fillStyle = t.dim.color, e.beginPath(), e.rect(0, 0, n, r);
|
|
1403
1403
|
for (let n of t.dimHoles) e.moveTo(n.x, n.y), e.lineTo(n.x, n.y + n.h), e.lineTo(n.x + n.w, n.y + n.h), e.lineTo(n.x + n.w, n.y), e.closePath();
|
|
1404
1404
|
if (e.fill(), t.zones.length) {
|
|
1405
1405
|
e.beginPath();
|
|
1406
1406
|
for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h);
|
|
1407
1407
|
e.clip();
|
|
1408
|
-
for (let n of t.zones)
|
|
1408
|
+
for (let n of t.zones) St(e, n.points), e.fill();
|
|
1409
1409
|
}
|
|
1410
1410
|
e.restore();
|
|
1411
1411
|
}
|
|
1412
|
-
function
|
|
1412
|
+
function kt(e) {
|
|
1413
1413
|
let t = [];
|
|
1414
1414
|
for (let n of e) if (!(n.length < 2)) for (let e = 0; e < n.length; e += 1) t.push([n[e], n[(e + 1) % n.length]]);
|
|
1415
1415
|
return t;
|
|
1416
1416
|
}
|
|
1417
|
-
var
|
|
1417
|
+
var At = {
|
|
1418
1418
|
color: "#000000",
|
|
1419
1419
|
opacity: .5
|
|
1420
|
-
},
|
|
1420
|
+
}, jt = {
|
|
1421
1421
|
color: "#ffffff",
|
|
1422
1422
|
opacity: 1,
|
|
1423
1423
|
width: 2,
|
|
@@ -1437,8 +1437,8 @@ var jt = {
|
|
|
1437
1437
|
y: 0,
|
|
1438
1438
|
w: t,
|
|
1439
1439
|
h: n
|
|
1440
|
-
}], o =
|
|
1441
|
-
...
|
|
1440
|
+
}], o = Dt(a), s = {
|
|
1441
|
+
...At,
|
|
1442
1442
|
...e.dim
|
|
1443
1443
|
}, c = e.outline;
|
|
1444
1444
|
if (c === !1) return {
|
|
@@ -1452,36 +1452,36 @@ var jt = {
|
|
|
1452
1452
|
};
|
|
1453
1453
|
let l = {
|
|
1454
1454
|
visible: {
|
|
1455
|
-
...
|
|
1455
|
+
...jt,
|
|
1456
1456
|
...c?.visibleStyle
|
|
1457
1457
|
},
|
|
1458
1458
|
occluded: {
|
|
1459
1459
|
...Mt,
|
|
1460
1460
|
...c?.occludedStyle
|
|
1461
1461
|
}
|
|
1462
|
-
}, u = i.map(
|
|
1462
|
+
}, u = i.map(Ct), d = a.map(Ct), f = r.map((e) => e.points);
|
|
1463
1463
|
return c?.mode === "separate" ? {
|
|
1464
1464
|
rects: a,
|
|
1465
1465
|
zones: r,
|
|
1466
1466
|
dimHoles: o,
|
|
1467
1467
|
dim: s,
|
|
1468
|
-
visibleOutline:
|
|
1469
|
-
occludedOutline:
|
|
1468
|
+
visibleOutline: kt(u),
|
|
1469
|
+
occludedOutline: kt(f),
|
|
1470
1470
|
outlineStyles: l
|
|
1471
1471
|
} : {
|
|
1472
1472
|
rects: a,
|
|
1473
1473
|
zones: r,
|
|
1474
1474
|
dimHoles: o,
|
|
1475
1475
|
dim: s,
|
|
1476
|
-
visibleOutline: [...
|
|
1476
|
+
visibleOutline: [...Et(u, [...u, ...f], null), ...Et(f, f, d)],
|
|
1477
1477
|
occludedOutline: [],
|
|
1478
1478
|
outlineStyles: l
|
|
1479
1479
|
};
|
|
1480
|
-
}, Pt = .3,
|
|
1481
|
-
function
|
|
1480
|
+
}, Pt = .3, Q = .05;
|
|
1481
|
+
function Ft(e) {
|
|
1482
1482
|
return 1 - (1 - e) ** 3;
|
|
1483
1483
|
}
|
|
1484
|
-
function
|
|
1484
|
+
function It(e) {
|
|
1485
1485
|
return {
|
|
1486
1486
|
x: e.minX,
|
|
1487
1487
|
y: e.minY,
|
|
@@ -1489,7 +1489,7 @@ function Lt(e) {
|
|
|
1489
1489
|
height: Math.max(0, e.maxY - e.minY)
|
|
1490
1490
|
};
|
|
1491
1491
|
}
|
|
1492
|
-
function
|
|
1492
|
+
function Lt(e, t) {
|
|
1493
1493
|
if (!t.length) return null;
|
|
1494
1494
|
if (e === N.POINT) {
|
|
1495
1495
|
let e = t[0];
|
|
@@ -1500,7 +1500,7 @@ function Rt(e, t) {
|
|
|
1500
1500
|
height: 16
|
|
1501
1501
|
};
|
|
1502
1502
|
}
|
|
1503
|
-
let n =
|
|
1503
|
+
let n = L(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
|
|
1504
1504
|
return {
|
|
1505
1505
|
x: n.minX,
|
|
1506
1506
|
y: n.minY,
|
|
@@ -1508,10 +1508,10 @@ function Rt(e, t) {
|
|
|
1508
1508
|
height: i
|
|
1509
1509
|
};
|
|
1510
1510
|
}
|
|
1511
|
-
function
|
|
1511
|
+
function Rt(e) {
|
|
1512
1512
|
if (!e.length) return null;
|
|
1513
|
-
let t = e.map((e) =>
|
|
1514
|
-
return t.length ?
|
|
1513
|
+
let t = e.map((e) => Lt(e.type, e.points)).filter((e) => e !== null);
|
|
1514
|
+
return t.length ? It(L(t.flatMap((e) => [{
|
|
1515
1515
|
x: e.x,
|
|
1516
1516
|
y: e.y
|
|
1517
1517
|
}, {
|
|
@@ -1519,8 +1519,8 @@ function zt(e) {
|
|
|
1519
1519
|
y: e.y + e.height
|
|
1520
1520
|
}]))) : null;
|
|
1521
1521
|
}
|
|
1522
|
-
function
|
|
1523
|
-
let { containerRatio: i = Pt, minScale: a =
|
|
1522
|
+
function zt(e, t, n, r = {}) {
|
|
1523
|
+
let { containerRatio: i = Pt, minScale: a = Q, maxScale: o = 20 } = r;
|
|
1524
1524
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1525
1525
|
let s = Math.min(t * i / e.width, n * i / e.height), c = Math.max(a, Math.min(o, s)), l = e.x + e.width / 2, u = e.y + e.height / 2;
|
|
1526
1526
|
return {
|
|
@@ -1529,18 +1529,18 @@ function Bt(e, t, n, r = {}) {
|
|
|
1529
1529
|
y: n / 2 - u * c
|
|
1530
1530
|
};
|
|
1531
1531
|
}
|
|
1532
|
-
function
|
|
1532
|
+
function Bt(e, t, n, r = 80) {
|
|
1533
1533
|
if (!t || !n) return null;
|
|
1534
|
-
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(
|
|
1534
|
+
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(Q, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
|
|
1535
1535
|
return {
|
|
1536
1536
|
scale: o,
|
|
1537
1537
|
x: t / 2 - s * o,
|
|
1538
1538
|
y: n / 2 - c * o
|
|
1539
1539
|
};
|
|
1540
1540
|
}
|
|
1541
|
-
function
|
|
1541
|
+
function Vt(e, t, n, r = 300) {
|
|
1542
1542
|
let i = Date.now(), a = 0, o = () => {
|
|
1543
|
-
let s = Date.now() - i, c = Math.min(s / r, 1), l =
|
|
1543
|
+
let s = Date.now() - i, c = Math.min(s / r, 1), l = Ft(c);
|
|
1544
1544
|
n({
|
|
1545
1545
|
scale: e.scale + (t.scale - e.scale) * l,
|
|
1546
1546
|
x: e.x + (t.x - e.x) * l,
|
|
@@ -1551,11 +1551,11 @@ function Ht(e, t, n, r = 300) {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
//#endregion
|
|
1553
1553
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1554
|
-
function
|
|
1555
|
-
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: 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 = "", P = null,
|
|
1554
|
+
function Ht(e) {
|
|
1555
|
+
let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: 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 = "", P = null, ee = (e) => e === W.RECTANGLE || e === W.ROTATED_RECTANGLE || e === W.CIRCLE, te = (e) => e === W.ASSISTANT_POLYGON || e === W.ASSISTANT_RECT, ie = (e) => e === W.POLYGON, I = (e, t) => {
|
|
1556
1556
|
let n = !1;
|
|
1557
|
-
D && !
|
|
1558
|
-
},
|
|
1557
|
+
D && !ee(t) && !te(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== W.PATH || O === "scalar" && t !== W.BRUSH) && (O = null, n = !0), k && !ie(t) && (k = null, n = !0), A && t !== W.SELECT && (A = null, j = null, e.clearMarquee(), n = !0), n && b("idle");
|
|
1558
|
+
}, ae = () => r.current.get(n.current), oe = (e, t, n, r) => ({
|
|
1559
1559
|
point: t,
|
|
1560
1560
|
targetId: r,
|
|
1561
1561
|
event: n,
|
|
@@ -1569,41 +1569,41 @@ function Ut(e) {
|
|
|
1569
1569
|
let p = t.current;
|
|
1570
1570
|
if (!p) return;
|
|
1571
1571
|
let _ = n.current;
|
|
1572
|
-
if (
|
|
1572
|
+
if (I(p, _), u.button === 1 || i.current) {
|
|
1573
1573
|
b("panning"), y(null), E = {
|
|
1574
1574
|
px: u.global.x,
|
|
1575
1575
|
py: u.global.y
|
|
1576
1576
|
};
|
|
1577
1577
|
return;
|
|
1578
1578
|
}
|
|
1579
|
-
if (u.button === 2 && !(_ ===
|
|
1579
|
+
if (u.button === 2 && !(_ === W.ASSISTANT_POINT && u.altKey)) {
|
|
1580
1580
|
if (r && !s.current.includes(r)) {
|
|
1581
1581
|
let e = o.current.getShapes().find((e) => e.id === r);
|
|
1582
|
-
e &&
|
|
1582
|
+
e && F(e) && m.current([r]);
|
|
1583
1583
|
}
|
|
1584
1584
|
return;
|
|
1585
1585
|
}
|
|
1586
|
-
let v =
|
|
1586
|
+
let v = ae();
|
|
1587
1587
|
if (v) {
|
|
1588
|
-
w().reset(), m.current([]), v.onPointerDown?.(
|
|
1588
|
+
w().reset(), m.current([]), v.onPointerDown?.(oe(p, e, u, r));
|
|
1589
1589
|
return;
|
|
1590
1590
|
}
|
|
1591
1591
|
if (d.current) {
|
|
1592
1592
|
f();
|
|
1593
1593
|
return;
|
|
1594
1594
|
}
|
|
1595
|
-
if (_ ===
|
|
1595
|
+
if (_ === W.ASSISTANT_POINT) {
|
|
1596
1596
|
u.altKey ? T().addPoint(e, u.button !== 2) : T().newPolygon(e);
|
|
1597
1597
|
return;
|
|
1598
1598
|
}
|
|
1599
|
-
if (
|
|
1599
|
+
if (te(_) && c.current) {
|
|
1600
1600
|
D = e, b("drawing");
|
|
1601
1601
|
return;
|
|
1602
1602
|
}
|
|
1603
|
-
if (_ ===
|
|
1604
|
-
let t =
|
|
1605
|
-
if (!
|
|
1606
|
-
let n =
|
|
1603
|
+
if (_ === W.SELECT && u.altKey) {
|
|
1604
|
+
let t = re(o.current.getShapes()).filter((t) => {
|
|
1605
|
+
if (!F(t)) return !1;
|
|
1606
|
+
let n = L(t.points);
|
|
1607
1607
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
1608
1608
|
});
|
|
1609
1609
|
if (t.length) {
|
|
@@ -1612,9 +1612,9 @@ function Ut(e) {
|
|
|
1612
1612
|
return;
|
|
1613
1613
|
}
|
|
1614
1614
|
}
|
|
1615
|
-
if (r && _ ===
|
|
1615
|
+
if (r && _ === W.SELECT) {
|
|
1616
1616
|
let t = o.current.getShapes().find((e) => e.id === r);
|
|
1617
|
-
if (!t || !
|
|
1617
|
+
if (!t || !F(t)) return;
|
|
1618
1618
|
let n = typeof performance < "u" ? performance.now() : 0, i = !!P && P.id === r && n - P.t < 300;
|
|
1619
1619
|
P = {
|
|
1620
1620
|
id: r,
|
|
@@ -1630,14 +1630,14 @@ function Ut(e) {
|
|
|
1630
1630
|
let e = new Set(u);
|
|
1631
1631
|
e.has(r) ? e.delete(r) : e.add(r), u = [...e];
|
|
1632
1632
|
} else u.includes(r) || (u = [r]);
|
|
1633
|
-
m.current(u), !l.current &&
|
|
1633
|
+
m.current(u), !l.current && ne(t) && p.beginMove(e, u);
|
|
1634
1634
|
return;
|
|
1635
1635
|
}
|
|
1636
|
-
if (
|
|
1636
|
+
if (ee(_) && c.current) {
|
|
1637
1637
|
D = e, b("drawing");
|
|
1638
1638
|
return;
|
|
1639
1639
|
}
|
|
1640
|
-
if (
|
|
1640
|
+
if (ie(_) && c.current) {
|
|
1641
1641
|
if (!w().getDraftPointsSnapshot().length && s.current.length && m.current([]), w().tryClosePolygon(e, 12 / p.viewport.scale)) return;
|
|
1642
1642
|
let t = w().hitDraftPoint(e);
|
|
1643
1643
|
if (t >= 0) {
|
|
@@ -1658,19 +1658,19 @@ function Ut(e) {
|
|
|
1658
1658
|
w().appendPolygonPoint(e);
|
|
1659
1659
|
return;
|
|
1660
1660
|
}
|
|
1661
|
-
if (_ ===
|
|
1661
|
+
if (_ === W.PATH && c.current) {
|
|
1662
1662
|
s.current.length && m.current([]), O = "path", b("drawing"), w().beginStroke(e);
|
|
1663
1663
|
return;
|
|
1664
1664
|
}
|
|
1665
|
-
if (_ ===
|
|
1665
|
+
if (_ === W.BRUSH && c.current && !l.current) {
|
|
1666
1666
|
O = "scalar", b("drawing"), w().beginStroke(e);
|
|
1667
1667
|
return;
|
|
1668
1668
|
}
|
|
1669
|
-
if (_ ===
|
|
1669
|
+
if (_ === W.SELECT) {
|
|
1670
1670
|
if (j = g.current ? a.current ? p.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
|
|
1671
|
-
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) &&
|
|
1671
|
+
let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && ne(e));
|
|
1672
1672
|
if (t.length) {
|
|
1673
|
-
let n =
|
|
1673
|
+
let n = L(t.flatMap((e) => e.points));
|
|
1674
1674
|
if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
|
|
1675
1675
|
p.beginMove(e, s.current);
|
|
1676
1676
|
return;
|
|
@@ -1692,10 +1692,10 @@ function Ut(e) {
|
|
|
1692
1692
|
return;
|
|
1693
1693
|
}
|
|
1694
1694
|
let s = n.current;
|
|
1695
|
-
|
|
1696
|
-
let l =
|
|
1695
|
+
I(i, s);
|
|
1696
|
+
let l = ae();
|
|
1697
1697
|
if (l) {
|
|
1698
|
-
l.onPointerMove?.(
|
|
1698
|
+
l.onPointerMove?.(oe(i, e, r));
|
|
1699
1699
|
return;
|
|
1700
1700
|
}
|
|
1701
1701
|
if (k) {
|
|
@@ -1703,13 +1703,13 @@ function Ut(e) {
|
|
|
1703
1703
|
k.moved = k.moved || Math.hypot(t, n) > .5, w().moveDraftPoints(k.base, k.indices, t, n);
|
|
1704
1704
|
return;
|
|
1705
1705
|
}
|
|
1706
|
-
if (D && (
|
|
1707
|
-
let t = a.current ?
|
|
1708
|
-
i.previewBox(s ===
|
|
1706
|
+
if (D && (ee(s) || te(s))) {
|
|
1707
|
+
let t = a.current ? R(D, e) : e;
|
|
1708
|
+
i.previewBox(s === W.CIRCLE ? "ellipse" : "rect", D, t, {
|
|
1709
1709
|
...c.current,
|
|
1710
1710
|
color: c.current?.color ?? "#00e5ff"
|
|
1711
|
-
}),
|
|
1712
|
-
type: s ===
|
|
1711
|
+
}), ee(s) && C({
|
|
1712
|
+
type: s === W.CIRCLE ? N.ELLIPSE : N.RECTANGLE,
|
|
1713
1713
|
points: [D, t]
|
|
1714
1714
|
});
|
|
1715
1715
|
return;
|
|
@@ -1718,7 +1718,7 @@ function Ut(e) {
|
|
|
1718
1718
|
w().appendStrokePoint(e, 2 / i.viewport.scale);
|
|
1719
1719
|
return;
|
|
1720
1720
|
}
|
|
1721
|
-
if (
|
|
1721
|
+
if (ie(s) && w().hasDraftPoints()) {
|
|
1722
1722
|
w().setDraftCursor(e);
|
|
1723
1723
|
return;
|
|
1724
1724
|
}
|
|
@@ -1747,16 +1747,16 @@ function Ut(e) {
|
|
|
1747
1747
|
return;
|
|
1748
1748
|
}
|
|
1749
1749
|
let i = n.current;
|
|
1750
|
-
if (
|
|
1750
|
+
if (I(r, i), k) {
|
|
1751
1751
|
w().commitDraftPointDrag(k.moved), k = null, b("idle");
|
|
1752
1752
|
return;
|
|
1753
1753
|
}
|
|
1754
|
-
let o =
|
|
1754
|
+
let o = ae();
|
|
1755
1755
|
if (o) {
|
|
1756
|
-
o.onPointerUp?.(
|
|
1756
|
+
o.onPointerUp?.(oe(r, e, {}));
|
|
1757
1757
|
return;
|
|
1758
1758
|
}
|
|
1759
|
-
if (i ===
|
|
1759
|
+
if (i === W.POINT && c.current) {
|
|
1760
1760
|
p.current(N.POINT, [e]);
|
|
1761
1761
|
return;
|
|
1762
1762
|
}
|
|
@@ -1765,7 +1765,7 @@ function Ut(e) {
|
|
|
1765
1765
|
O = null, b("idle"), e === "path" ? w().completeFreehandStroke() : w().finishScalarStroke();
|
|
1766
1766
|
return;
|
|
1767
1767
|
}
|
|
1768
|
-
if (D &&
|
|
1768
|
+
if (D && te(i)) {
|
|
1769
1769
|
let t = D;
|
|
1770
1770
|
D = null, b("idle"), r.clearPreview();
|
|
1771
1771
|
let n = {
|
|
@@ -1774,12 +1774,12 @@ function Ut(e) {
|
|
|
1774
1774
|
width: Math.abs(e.x - t.x),
|
|
1775
1775
|
height: Math.abs(e.y - t.y)
|
|
1776
1776
|
};
|
|
1777
|
-
n.width > 2 && n.height > 2 && T().beginBox(n, i ===
|
|
1777
|
+
n.width > 2 && n.height > 2 && T().beginBox(n, i === W.ASSISTANT_RECT ? "rect" : "polygon");
|
|
1778
1778
|
return;
|
|
1779
1779
|
}
|
|
1780
|
-
if (D &&
|
|
1781
|
-
let t = a.current ?
|
|
1782
|
-
D = null, b("idle"), r.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (i ===
|
|
1780
|
+
if (D && ee(i)) {
|
|
1781
|
+
let t = a.current ? R(D, e) : e, n = D;
|
|
1782
|
+
D = null, b("idle"), r.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (i === W.ROTATED_RECTANGLE ? p.current(N.ROTATED_RECTANGLE, z([n, t])) : i === W.CIRCLE ? p.current(N.POLYGON, ce(n, t)) : p.current(N.RECTANGLE, [n, t]));
|
|
1783
1783
|
return;
|
|
1784
1784
|
}
|
|
1785
1785
|
if (A) {
|
|
@@ -1804,7 +1804,7 @@ function Ut(e) {
|
|
|
1804
1804
|
}
|
|
1805
1805
|
//#endregion
|
|
1806
1806
|
//#region src/components/ShapeEditor/_state/useAssistant.ts
|
|
1807
|
-
function
|
|
1807
|
+
function Ut({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
|
|
1808
1808
|
let [a, o] = b("idle"), [s, c] = b([]), [l, u] = b([]), d = y([]), p = y([]), m = y([]), h = y("idle"), g = y(0), _ = y(null), v = y(null), x = y(0), S = f((e) => {
|
|
1809
1809
|
d.current = e(d.current), u(d.current);
|
|
1810
1810
|
}, []), C = f((e) => {
|
|
@@ -1813,16 +1813,16 @@ function Wt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1813
1813
|
let a = i.current?.rectResult === "rotatedRect";
|
|
1814
1814
|
return e.map((e) => {
|
|
1815
1815
|
if (t === "rect" && a) return {
|
|
1816
|
-
id:
|
|
1816
|
+
id: ie(),
|
|
1817
1817
|
type: N.ROTATED_RECTANGLE,
|
|
1818
|
-
points:
|
|
1818
|
+
points: B(e),
|
|
1819
1819
|
style: r,
|
|
1820
1820
|
meta: n
|
|
1821
1821
|
};
|
|
1822
1822
|
if (t === "rect") {
|
|
1823
|
-
let t =
|
|
1823
|
+
let t = L(e);
|
|
1824
1824
|
return {
|
|
1825
|
-
id:
|
|
1825
|
+
id: ie(),
|
|
1826
1826
|
type: N.RECTANGLE,
|
|
1827
1827
|
points: [{
|
|
1828
1828
|
x: t.minX,
|
|
@@ -1836,7 +1836,7 @@ function Wt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1836
1836
|
};
|
|
1837
1837
|
}
|
|
1838
1838
|
return {
|
|
1839
|
-
id:
|
|
1839
|
+
id: ie(),
|
|
1840
1840
|
type: N.POLYGON,
|
|
1841
1841
|
points: e,
|
|
1842
1842
|
style: r,
|
|
@@ -1969,17 +1969,17 @@ function Wt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
1969
1969
|
}
|
|
1970
1970
|
//#endregion
|
|
1971
1971
|
//#region src/components/ShapeEditor/_model/brush.ts
|
|
1972
|
-
function
|
|
1972
|
+
function Wt(e, t, n) {
|
|
1973
1973
|
let r = Math.abs(.5 * (t.x * n.y + n.x * e.y + e.x * t.y - n.x * t.y - e.x * n.y - t.x * e.y)), i = Math.hypot(t.x - n.x, t.y - n.y);
|
|
1974
1974
|
return i === 0 ? 0 : r * 2 / i;
|
|
1975
1975
|
}
|
|
1976
|
-
function
|
|
1976
|
+
function Gt(e, t = 1.5) {
|
|
1977
1977
|
if (e.length <= 2) return e;
|
|
1978
1978
|
let n = (e, t) => {
|
|
1979
1979
|
if (e.length < 3) return e;
|
|
1980
1980
|
let r = 0, i = 0, a = e.length - 1;
|
|
1981
1981
|
for (let t = 1; t < a; t++) {
|
|
1982
|
-
let n =
|
|
1982
|
+
let n = Wt(e[t], e[0], e[a]);
|
|
1983
1983
|
n > r && (i = t, r = n);
|
|
1984
1984
|
}
|
|
1985
1985
|
if (r > t) {
|
|
@@ -1992,8 +1992,8 @@ function Kt(e, t = 1.5) {
|
|
|
1992
1992
|
}
|
|
1993
1993
|
//#endregion
|
|
1994
1994
|
//#region src/components/ShapeEditor/_model/scalarMask.ts
|
|
1995
|
-
var
|
|
1996
|
-
function
|
|
1995
|
+
var Kt = 4096, qt = 4;
|
|
1996
|
+
function Jt(e) {
|
|
1997
1997
|
let t = 0;
|
|
1998
1998
|
for (let n = 0; n < e.length; n++) {
|
|
1999
1999
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -2001,17 +2001,17 @@ function Yt(e) {
|
|
|
2001
2001
|
}
|
|
2002
2002
|
return Math.abs(t / 2);
|
|
2003
2003
|
}
|
|
2004
|
-
function
|
|
2004
|
+
function Yt(e, t, n) {
|
|
2005
2005
|
let r = new Uint8Array(t * n);
|
|
2006
2006
|
for (let i = 0; i < t * n; i++) r[i] = e[i * 4 + 3] > 128 ? 255 : 0;
|
|
2007
2007
|
return r;
|
|
2008
2008
|
}
|
|
2009
|
-
function
|
|
2009
|
+
function Xt(e) {
|
|
2010
2010
|
let t = new Uint8ClampedArray(e.length * 4);
|
|
2011
2011
|
for (let n = 0; n < e.length; n++) e[n] > 128 && (t[n * 4 + 3] = 255);
|
|
2012
2012
|
return t;
|
|
2013
2013
|
}
|
|
2014
|
-
function
|
|
2014
|
+
function Zt(e, t, n, r, i) {
|
|
2015
2015
|
let a = new Uint8Array(t * n), o = [[r, i]];
|
|
2016
2016
|
for (; o.length;) {
|
|
2017
2017
|
let [r, i] = o.pop(), s = i * t + r;
|
|
@@ -2019,8 +2019,8 @@ function Qt(e, t, n, r, i) {
|
|
|
2019
2019
|
}
|
|
2020
2020
|
return a;
|
|
2021
2021
|
}
|
|
2022
|
-
function
|
|
2023
|
-
let r =
|
|
2022
|
+
function Qt(e, t, n) {
|
|
2023
|
+
let r = Yt(e, t, n), i = [];
|
|
2024
2024
|
for (;;) {
|
|
2025
2025
|
let e = -1, a = -1;
|
|
2026
2026
|
outer: for (let i = 0; i < n; i++) for (let n = 0; n < t; n++) if (r[i * t + n] > 128) {
|
|
@@ -2028,17 +2028,17 @@ function $t(e, t, n) {
|
|
|
2028
2028
|
break outer;
|
|
2029
2029
|
}
|
|
2030
2030
|
if (e < 0) break;
|
|
2031
|
-
let o =
|
|
2031
|
+
let o = en(Xt(Zt(r, t, n, e, a)), t, n);
|
|
2032
2032
|
o.length >= 3 && i.push(o);
|
|
2033
2033
|
}
|
|
2034
2034
|
return i;
|
|
2035
2035
|
}
|
|
2036
|
-
function
|
|
2036
|
+
function $t(e, t, n, r, i) {
|
|
2037
2037
|
return r < 0 || i < 0 || r >= t || i >= n ? !1 : e[(i * t + r) * 4 + 3] > 128;
|
|
2038
2038
|
}
|
|
2039
|
-
function
|
|
2039
|
+
function en(e, t, n) {
|
|
2040
2040
|
let r = -1, i = -1;
|
|
2041
|
-
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (
|
|
2041
|
+
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if ($t(e, t, n, o, a)) {
|
|
2042
2042
|
r = o, i = a;
|
|
2043
2043
|
break outer;
|
|
2044
2044
|
}
|
|
@@ -2073,7 +2073,7 @@ function tn(e, t, n) {
|
|
|
2073
2073
|
let r = !1;
|
|
2074
2074
|
for (let i = 0; i < 8; i++) {
|
|
2075
2075
|
let s = (u + i) % 8, d = c + a[s], f = l + o[s];
|
|
2076
|
-
if (
|
|
2076
|
+
if ($t(e, t, n, d, f)) {
|
|
2077
2077
|
c = d, l = f, u = (s + 6) % 8, r = !0;
|
|
2078
2078
|
break;
|
|
2079
2079
|
}
|
|
@@ -2082,21 +2082,21 @@ function tn(e, t, n) {
|
|
|
2082
2082
|
} while (c !== d.x || l !== d.y || s.length === 1);
|
|
2083
2083
|
return s;
|
|
2084
2084
|
}
|
|
2085
|
-
function
|
|
2085
|
+
function tn(e, t) {
|
|
2086
2086
|
let n = [];
|
|
2087
2087
|
for (let t of e) for (let e of t.points) n.push(e);
|
|
2088
2088
|
for (let e of t) for (let t of e) n.push(t);
|
|
2089
2089
|
return n;
|
|
2090
2090
|
}
|
|
2091
|
-
function
|
|
2091
|
+
function nn(e) {
|
|
2092
2092
|
switch (e.type) {
|
|
2093
|
-
case N.RECTANGLE: return e.points.length < 2 ? null :
|
|
2093
|
+
case N.RECTANGLE: return e.points.length < 2 ? null : z(e.points);
|
|
2094
2094
|
case N.POLYGON:
|
|
2095
2095
|
case N.ROTATED_RECTANGLE:
|
|
2096
2096
|
case N.ELLIPSE: return e.points.length >= 3 ? e.points : null;
|
|
2097
2097
|
case N.POINT: {
|
|
2098
2098
|
let t = e.points[0];
|
|
2099
|
-
return t ?
|
|
2099
|
+
return t ? ce({
|
|
2100
2100
|
x: t.x - 6,
|
|
2101
2101
|
y: t.y - 6
|
|
2102
2102
|
}, {
|
|
@@ -2107,14 +2107,14 @@ function rn(e) {
|
|
|
2107
2107
|
default: return null;
|
|
2108
2108
|
}
|
|
2109
2109
|
}
|
|
2110
|
-
function
|
|
2111
|
-
return e.map(
|
|
2110
|
+
function rn(e) {
|
|
2111
|
+
return e.map(nn).filter((e) => !!e && e.length >= 3);
|
|
2112
2112
|
}
|
|
2113
|
-
function
|
|
2113
|
+
function an(e, t, n = []) {
|
|
2114
2114
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
2115
|
-
let r =
|
|
2115
|
+
let r = tn(e, n);
|
|
2116
2116
|
if (!r.length) return null;
|
|
2117
|
-
let i = t + 4, a =
|
|
2117
|
+
let i = t + 4, a = L(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, Kt / Math.max(o, s, 1));
|
|
2118
2118
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
2119
2119
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
2120
2120
|
x: (e.x - l) * c,
|
|
@@ -2153,20 +2153,20 @@ function on(e, t, n = []) {
|
|
|
2153
2153
|
scale: c
|
|
2154
2154
|
};
|
|
2155
2155
|
}
|
|
2156
|
-
function
|
|
2157
|
-
let { canvas: n, ox: r, oy: i, scale: a } = e, o =
|
|
2156
|
+
function on(e, t = 1.5) {
|
|
2157
|
+
let { canvas: n, ox: r, oy: i, scale: a } = e, o = Qt(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
|
|
2158
2158
|
if (!o.length) return [];
|
|
2159
2159
|
let s = (e) => ({
|
|
2160
2160
|
x: e.x / a + r,
|
|
2161
2161
|
y: e.y / a + i
|
|
2162
2162
|
}), c = [];
|
|
2163
2163
|
for (let e of o) {
|
|
2164
|
-
let n = e.map(s), r =
|
|
2165
|
-
i.length >= 3 &&
|
|
2164
|
+
let n = e.map(s), r = Gt(n, t), i = r.length >= 3 ? r : n;
|
|
2165
|
+
i.length >= 3 && Jt(i) >= qt && c.push(i);
|
|
2166
2166
|
}
|
|
2167
2167
|
return c;
|
|
2168
2168
|
}
|
|
2169
|
-
function
|
|
2169
|
+
function sn(e, t) {
|
|
2170
2170
|
let { canvas: n } = e, r = document.createElement("canvas");
|
|
2171
2171
|
r.width = n.width, r.height = n.height;
|
|
2172
2172
|
let i = r.getContext("2d");
|
|
@@ -2174,30 +2174,30 @@ function cn(e, t) {
|
|
|
2174
2174
|
}
|
|
2175
2175
|
//#endregion
|
|
2176
2176
|
//#region src/components/ShapeEditor/_state/drawSessionState.ts
|
|
2177
|
-
function
|
|
2177
|
+
function cn(e) {
|
|
2178
2178
|
return e.map((e) => ({
|
|
2179
2179
|
mode: e.mode,
|
|
2180
2180
|
points: e.points.map((e) => ({ ...e }))
|
|
2181
2181
|
}));
|
|
2182
2182
|
}
|
|
2183
|
-
function
|
|
2183
|
+
function ln(e, t) {
|
|
2184
2184
|
return e.length === t.length && e.every((e, n) => e.mode === t[n].mode && e.points.length === t[n].points.length && e.points.every((e, r) => e.x === t[n].points[r].x && e.y === t[n].points[r].y));
|
|
2185
2185
|
}
|
|
2186
|
-
function
|
|
2186
|
+
function un(e) {
|
|
2187
2187
|
return e.map((e) => ({ ...e }));
|
|
2188
2188
|
}
|
|
2189
|
-
function
|
|
2189
|
+
function dn(e, t) {
|
|
2190
2190
|
return e.length === t.length && e.every((e, n) => e.x === t[n].x && e.y === t[n].y);
|
|
2191
2191
|
}
|
|
2192
2192
|
//#endregion
|
|
2193
2193
|
//#region src/components/ShapeEditor/_state/useDrawSession.ts
|
|
2194
|
-
var
|
|
2195
|
-
function
|
|
2194
|
+
var fn = 10;
|
|
2195
|
+
function pn(e, t) {
|
|
2196
2196
|
if (e.active !== t.active || e.kind !== t.kind || e.canUndo !== t.canUndo || e.canRedo !== t.canRedo) return !1;
|
|
2197
2197
|
let n = e.brush, r = t.brush;
|
|
2198
2198
|
return !n || !r ? n === r : n.mode === r.mode && n.editing === r.editing && n.editTargetIds.length === r.editTargetIds.length && n.editTargetIds.every((e, t) => e === r.editTargetIds[t]);
|
|
2199
2199
|
}
|
|
2200
|
-
function
|
|
2200
|
+
function mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, brushSizeRef: a, simplifyEpsilonRef: o, draftMeta: s, engineRef: c, onDrawSessionChange: l, onDraftShapeChange: u, changeSelection: d, createShape: p }) {
|
|
2201
2201
|
let m = y(l);
|
|
2202
2202
|
m.current = l;
|
|
2203
2203
|
let h = y(u);
|
|
@@ -2206,35 +2206,35 @@ function hn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2206
2206
|
g.current = s;
|
|
2207
2207
|
let _ = y(p);
|
|
2208
2208
|
_.current = p;
|
|
2209
|
-
let v = y(null), b = y([]), x = y(null), S = y(/* @__PURE__ */ new Set()), C = y([[]]), w = y(0), T = y(null), E = y([]), D = y([]), O = y([]), k = y([[]]), A = y(0), j = y("draw"), M = () => j.current === "erase" ? "erase" : "add", P = () => O.current.length > 0 || E.current.length > 0 || e.current ===
|
|
2209
|
+
let v = y(null), b = y([]), x = y(null), S = y(/* @__PURE__ */ new Set()), C = y([[]]), w = y(0), T = y(null), E = y([]), D = y([]), O = y([]), k = y([[]]), A = y(0), j = y("draw"), M = () => j.current === "erase" ? "erase" : "add", P = () => O.current.length > 0 || E.current.length > 0 || e.current === W.BRUSH && b.current.length > 0, ee = () => {
|
|
2210
2210
|
let t = e.current;
|
|
2211
|
-
return t ===
|
|
2212
|
-
},
|
|
2211
|
+
return t === W.BRUSH && P() ? "brush" : t === W.POLYGON && b.current.length > 0 ? "polygon" : t === W.PATH && b.current.length > 0 ? "path" : "none";
|
|
2212
|
+
}, F = () => b.current.length > 0 || A.current > 0, ne = () => b.current.length === 0 && A.current < k.current.length - 1, re = () => w.current > 0, I = () => w.current < C.current.length - 1, L = () => {
|
|
2213
2213
|
let t = e.current;
|
|
2214
|
-
return t ===
|
|
2215
|
-
},
|
|
2214
|
+
return t === W.BRUSH ? F() : t === W.POLYGON || t === W.PATH ? re() : !1;
|
|
2215
|
+
}, ae = () => {
|
|
2216
2216
|
let t = e.current;
|
|
2217
|
-
return t ===
|
|
2218
|
-
},
|
|
2219
|
-
let e =
|
|
2217
|
+
return t === W.BRUSH ? ne() : t === W.POLYGON || t === W.PATH ? I() : !1;
|
|
2218
|
+
}, oe = () => ee() !== "none", R = f(() => {
|
|
2219
|
+
let e = ee(), t = {
|
|
2220
2220
|
active: e !== "none",
|
|
2221
2221
|
kind: e,
|
|
2222
|
-
canUndo:
|
|
2223
|
-
canRedo:
|
|
2222
|
+
canUndo: L(),
|
|
2223
|
+
canRedo: ae(),
|
|
2224
2224
|
brush: e === "brush" ? {
|
|
2225
2225
|
mode: j.current,
|
|
2226
2226
|
editing: O.current.length > 0,
|
|
2227
2227
|
editTargetIds: [...O.current]
|
|
2228
2228
|
} : void 0
|
|
2229
2229
|
}, n = v.current;
|
|
2230
|
-
n &&
|
|
2231
|
-
}, []),
|
|
2230
|
+
n && pn(n, t) || (v.current = t, m.current?.(t));
|
|
2231
|
+
}, []), se = f(() => {
|
|
2232
2232
|
k.current = [[]], A.current = 0;
|
|
2233
|
-
}, []),
|
|
2233
|
+
}, []), z = f(() => {
|
|
2234
2234
|
let t = c.current;
|
|
2235
2235
|
if (!t) return;
|
|
2236
2236
|
let n = e.current;
|
|
2237
|
-
if (n ===
|
|
2237
|
+
if (n === W.BRUSH) {
|
|
2238
2238
|
let e = [...E.current];
|
|
2239
2239
|
if (b.current.length && e.push({
|
|
2240
2240
|
points: b.current,
|
|
@@ -2243,7 +2243,7 @@ function hn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2243
2243
|
t.clearPreview();
|
|
2244
2244
|
return;
|
|
2245
2245
|
}
|
|
2246
|
-
let n =
|
|
2246
|
+
let n = an(e, a.current, D.current);
|
|
2247
2247
|
if (!n) {
|
|
2248
2248
|
t.clearPreview();
|
|
2249
2249
|
return;
|
|
@@ -2260,12 +2260,12 @@ function hn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2260
2260
|
let o = {
|
|
2261
2261
|
...i.current,
|
|
2262
2262
|
color: i.current?.color ?? "#00e5ff"
|
|
2263
|
-
}, s = Array.from(S.current), l = n !==
|
|
2264
|
-
if (t.previewPoly(r, x.current, o, !1, s, l), n ===
|
|
2263
|
+
}, s = Array.from(S.current), l = n !== W.PATH;
|
|
2264
|
+
if (t.previewPoly(r, x.current, o, !1, s, l), n === W.POLYGON || n === W.PATH) {
|
|
2265
2265
|
let e = h.current;
|
|
2266
2266
|
e && r !== T.current && (T.current = r, e({
|
|
2267
2267
|
type: N.POLYGON,
|
|
2268
|
-
points:
|
|
2268
|
+
points: un(r),
|
|
2269
2269
|
meta: g.current
|
|
2270
2270
|
}));
|
|
2271
2271
|
}
|
|
@@ -2274,97 +2274,97 @@ function hn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2274
2274
|
i,
|
|
2275
2275
|
c,
|
|
2276
2276
|
e
|
|
2277
|
-
]),
|
|
2278
|
-
let t =
|
|
2279
|
-
i &&
|
|
2280
|
-
}, [
|
|
2277
|
+
]), ce = f((e) => {
|
|
2278
|
+
let t = cn(e), n = k.current, r = A.current, i = n[r];
|
|
2279
|
+
i && ln(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, R());
|
|
2280
|
+
}, [R]), le = f((e) => {
|
|
2281
2281
|
let t = C.current, n = w.current, r = t[n];
|
|
2282
|
-
r &&
|
|
2283
|
-
}, []),
|
|
2284
|
-
b.current = [], E.current = [], D.current = [], O.current = [], x.current = null, S.current = /* @__PURE__ */ new Set(), C.current = [[]], w.current = 0, T.current = null,
|
|
2282
|
+
r && dn(r, e) || (C.current = [...t.slice(0, n + 1), un(e)], w.current += 1);
|
|
2283
|
+
}, []), B = f(() => {
|
|
2284
|
+
b.current = [], E.current = [], D.current = [], O.current = [], x.current = null, S.current = /* @__PURE__ */ new Set(), C.current = [[]], w.current = 0, T.current = null, se(), c.current?.clearPreview(), h.current?.(null), R();
|
|
2285
2285
|
}, [
|
|
2286
2286
|
c,
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
]),
|
|
2290
|
-
b.current = e, S.current = new Set(Array.from(S.current).filter((t) => t >= 0 && t < e.length)), t &&
|
|
2287
|
+
R,
|
|
2288
|
+
se
|
|
2289
|
+
]), V = f((e, t) => {
|
|
2290
|
+
b.current = e, S.current = new Set(Array.from(S.current).filter((t) => t >= 0 && t < e.length)), t && le(e), z(), R();
|
|
2291
2291
|
}, [
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
]), ue = f(() =>
|
|
2296
|
-
if (e.current !==
|
|
2292
|
+
R,
|
|
2293
|
+
le,
|
|
2294
|
+
z
|
|
2295
|
+
]), ue = f(() => un(b.current), []), de = f(() => b.current.length > 0, []), fe = f((t, n) => {
|
|
2296
|
+
if (e.current !== W.POLYGON) return !1;
|
|
2297
2297
|
let r = b.current;
|
|
2298
2298
|
if (r.length < 3) return !1;
|
|
2299
2299
|
let i = r[0];
|
|
2300
|
-
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (_.current(N.POLYGON, r),
|
|
2301
|
-
}, [
|
|
2300
|
+
return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (_.current(N.POLYGON, r), B(), !0);
|
|
2301
|
+
}, [B, e]), pe = f((e) => {
|
|
2302
2302
|
let t = b.current;
|
|
2303
|
-
return e < 0 || e >= t.length ? !1 : (
|
|
2304
|
-
}, [
|
|
2303
|
+
return e < 0 || e >= t.length ? !1 : (V(t.filter((t, n) => n !== e), !0), !0);
|
|
2304
|
+
}, [V]), me = f((e, t) => {
|
|
2305
2305
|
let n = b.current;
|
|
2306
2306
|
if (e < 0 || e >= n.length) return null;
|
|
2307
2307
|
let r = new Set(S.current);
|
|
2308
|
-
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), S.current = r, x.current = null,
|
|
2309
|
-
base:
|
|
2308
|
+
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), S.current = r, x.current = null, z(), R(), {
|
|
2309
|
+
base: un(n),
|
|
2310
2310
|
indices: Array.from(r)
|
|
2311
2311
|
};
|
|
2312
|
-
}, [
|
|
2313
|
-
S.current = /* @__PURE__ */ new Set(), x.current = e,
|
|
2314
|
-
}, [
|
|
2315
|
-
x.current = null, S.current = /* @__PURE__ */ new Set(), b.current = [{ ...e }],
|
|
2316
|
-
}, [
|
|
2312
|
+
}, [R, z]), H = f((e) => {
|
|
2313
|
+
S.current = /* @__PURE__ */ new Set(), x.current = e, V([...b.current, e], !0);
|
|
2314
|
+
}, [V]), he = f((e) => {
|
|
2315
|
+
x.current = null, S.current = /* @__PURE__ */ new Set(), b.current = [{ ...e }], z(), R();
|
|
2316
|
+
}, [R, z]), ge = f((e, t) => {
|
|
2317
2317
|
let n = b.current[b.current.length - 1];
|
|
2318
|
-
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (b.current = [...b.current, { ...e }], x.current = null,
|
|
2319
|
-
}, [
|
|
2318
|
+
return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (b.current = [...b.current, { ...e }], x.current = null, z(), R(), !0);
|
|
2319
|
+
}, [R, z]), _e = f((e, t, n, r) => {
|
|
2320
2320
|
let i = new Set(t);
|
|
2321
2321
|
b.current = e.map((e, t) => i.has(t) ? {
|
|
2322
2322
|
x: e.x + n,
|
|
2323
2323
|
y: e.y + r
|
|
2324
|
-
} : { ...e }), x.current = null,
|
|
2325
|
-
}, [
|
|
2326
|
-
e && (
|
|
2324
|
+
} : { ...e }), x.current = null, z(), R();
|
|
2325
|
+
}, [R, z]), ve = f((e) => {
|
|
2326
|
+
e && (le(b.current), z(), R());
|
|
2327
2327
|
}, [
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
]),
|
|
2332
|
-
x.current = e ? { ...e } : null,
|
|
2333
|
-
}, [
|
|
2328
|
+
R,
|
|
2329
|
+
le,
|
|
2330
|
+
z
|
|
2331
|
+
]), ye = f((e) => {
|
|
2332
|
+
x.current = e ? { ...e } : null, z();
|
|
2333
|
+
}, [z]), be = f(() => b.current.length > 0 ? (b.current = [], z(), R(), !0) : A.current <= 0 ? !1 : (--A.current, E.current = cn(k.current[A.current]), z(), R(), !0), [R, z]), xe = f(() => b.current.length > 0 || A.current >= k.current.length - 1 ? !1 : (A.current += 1, E.current = cn(k.current[A.current]), z(), R(), !0), [R, z]), Se = f(() => w.current <= 0 ? !1 : (--w.current, b.current = un(C.current[w.current]), S.current = /* @__PURE__ */ new Set(), z(), R(), !0), [R, z]), U = f(() => w.current >= C.current.length - 1 ? !1 : (w.current += 1, b.current = un(C.current[w.current]), S.current = /* @__PURE__ */ new Set(), z(), R(), !0), [R, z]), Ce = f(() => {
|
|
2334
2334
|
let t = e.current;
|
|
2335
|
-
return t ===
|
|
2335
|
+
return t === W.BRUSH ? be() : t === W.POLYGON || t === W.PATH ? Se() : !1;
|
|
2336
2336
|
}, [
|
|
2337
2337
|
e,
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
]),
|
|
2338
|
+
be,
|
|
2339
|
+
Se
|
|
2340
|
+
]), we = f(() => {
|
|
2341
2341
|
let t = e.current;
|
|
2342
|
-
return t ===
|
|
2342
|
+
return t === W.BRUSH ? xe() : t === W.POLYGON || t === W.PATH ? U() : !1;
|
|
2343
2343
|
}, [
|
|
2344
|
-
|
|
2345
|
-
|
|
2344
|
+
xe,
|
|
2345
|
+
U,
|
|
2346
2346
|
e
|
|
2347
|
-
]),
|
|
2347
|
+
]), Te = f(() => {
|
|
2348
2348
|
let e = t.current;
|
|
2349
2349
|
if (!e.length) return O.current.length > 0;
|
|
2350
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) &&
|
|
2350
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && te(t)), i = rn(r);
|
|
2351
2351
|
return i.length ? (O.current = r.map((e) => e.id), D.current = i, !0) : (O.current = [], D.current = [], !1);
|
|
2352
|
-
}, [n, t]),
|
|
2352
|
+
}, [n, t]), G = f(() => {
|
|
2353
2353
|
if (r.current) return !1;
|
|
2354
2354
|
let e = [...E.current];
|
|
2355
2355
|
b.current.length && e.push({
|
|
2356
|
-
points:
|
|
2356
|
+
points: un(b.current),
|
|
2357
2357
|
mode: M()
|
|
2358
2358
|
});
|
|
2359
2359
|
let t = D.current, c = [...O.current];
|
|
2360
2360
|
if (!e.length && !t.length) return !1;
|
|
2361
|
-
let l =
|
|
2362
|
-
if (!l) return
|
|
2363
|
-
let u =
|
|
2361
|
+
let l = an(e, a.current, t);
|
|
2362
|
+
if (!l) return B(), !1;
|
|
2363
|
+
let u = on(l, o.current);
|
|
2364
2364
|
if (c.length) {
|
|
2365
2365
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2366
|
-
if (!u.length) return n.current.remove(c),
|
|
2367
|
-
u.sort((e, t) =>
|
|
2366
|
+
if (!u.length) return n.current.remove(c), B(), d([]), !0;
|
|
2367
|
+
u.sort((e, t) => Jt(t) - Jt(e));
|
|
2368
2368
|
let t = [], r = [], i = [];
|
|
2369
2369
|
for (let n = 0; n < u.length; n++) {
|
|
2370
2370
|
let a = u[n];
|
|
@@ -2376,7 +2376,7 @@ function hn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2376
2376
|
points: a
|
|
2377
2377
|
}), i.push(r.id);
|
|
2378
2378
|
} else {
|
|
2379
|
-
let t = e[0], n =
|
|
2379
|
+
let t = e[0], n = ie();
|
|
2380
2380
|
r.push({
|
|
2381
2381
|
...t,
|
|
2382
2382
|
id: n,
|
|
@@ -2386,19 +2386,19 @@ function hn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2386
2386
|
}
|
|
2387
2387
|
}
|
|
2388
2388
|
let a = e.slice(u.length).map((e) => e.id);
|
|
2389
|
-
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a),
|
|
2389
|
+
return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), B(), d(i), !0;
|
|
2390
2390
|
}
|
|
2391
|
-
if (!u.length) return
|
|
2391
|
+
if (!u.length) return B(), !1;
|
|
2392
2392
|
let f = i.current;
|
|
2393
2393
|
if (!f) return !1;
|
|
2394
2394
|
let p = u.map((e) => ({
|
|
2395
|
-
id:
|
|
2395
|
+
id: ie(),
|
|
2396
2396
|
type: N.POLYGON,
|
|
2397
2397
|
points: e,
|
|
2398
2398
|
style: f,
|
|
2399
2399
|
meta: s
|
|
2400
2400
|
}));
|
|
2401
|
-
return n.current.create(p), d(p.map((e) => e.id)),
|
|
2401
|
+
return n.current.create(p), d(p.map((e) => e.id)), B(), !0;
|
|
2402
2402
|
}, [
|
|
2403
2403
|
a,
|
|
2404
2404
|
d,
|
|
@@ -2406,153 +2406,153 @@ function hn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2406
2406
|
s,
|
|
2407
2407
|
i,
|
|
2408
2408
|
r,
|
|
2409
|
-
|
|
2410
|
-
]),
|
|
2409
|
+
B
|
|
2410
|
+
]), Ee = f(() => {
|
|
2411
2411
|
let t = e.current;
|
|
2412
|
-
if (t ===
|
|
2412
|
+
if (t === W.BRUSH) return G();
|
|
2413
2413
|
let n = b.current;
|
|
2414
|
-
return t ===
|
|
2414
|
+
return t === W.POLYGON && n.length >= 3 ? (_.current(N.POLYGON, n), B(), !0) : !1;
|
|
2415
2415
|
}, [
|
|
2416
|
-
|
|
2417
|
-
|
|
2416
|
+
G,
|
|
2417
|
+
B,
|
|
2418
2418
|
e
|
|
2419
|
-
]),
|
|
2419
|
+
]), De = f(() => {
|
|
2420
2420
|
let t = b.current;
|
|
2421
|
-
if (e.current ===
|
|
2422
|
-
let e =
|
|
2421
|
+
if (e.current === W.PATH && t.length >= 3) {
|
|
2422
|
+
let e = Gt(t, o.current);
|
|
2423
2423
|
e.length >= 3 && _.current(N.POLYGON, e);
|
|
2424
2424
|
}
|
|
2425
|
-
|
|
2426
|
-
}, [
|
|
2427
|
-
j.current = e,
|
|
2428
|
-
}, [
|
|
2429
|
-
if (r.current || e.current !==
|
|
2430
|
-
E.current = [], b.current = [],
|
|
2431
|
-
let t =
|
|
2432
|
-
return
|
|
2425
|
+
B();
|
|
2426
|
+
}, [B, e]), Oe = f((e) => {
|
|
2427
|
+
j.current = e, R(), z();
|
|
2428
|
+
}, [R, z]), ke = f(() => {
|
|
2429
|
+
if (r.current || e.current !== W.BRUSH) return !1;
|
|
2430
|
+
E.current = [], b.current = [], se();
|
|
2431
|
+
let t = Te();
|
|
2432
|
+
return R(), z(), t;
|
|
2433
2433
|
}, [
|
|
2434
|
-
|
|
2434
|
+
R,
|
|
2435
2435
|
r,
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2436
|
+
z,
|
|
2437
|
+
se,
|
|
2438
|
+
Te,
|
|
2439
2439
|
e
|
|
2440
|
-
]),
|
|
2440
|
+
]), Ae = f(() => {
|
|
2441
2441
|
let e = S.current;
|
|
2442
2442
|
if (!e.size) return !1;
|
|
2443
2443
|
let t = b.current.filter((t, n) => !e.has(n));
|
|
2444
|
-
return S.current = /* @__PURE__ */ new Set(),
|
|
2445
|
-
}, [
|
|
2444
|
+
return S.current = /* @__PURE__ */ new Set(), V(t, !0), !0;
|
|
2445
|
+
}, [V]), je = f((e) => {
|
|
2446
2446
|
let t = c.current, n = b.current;
|
|
2447
2447
|
if (!t || !n.length) return -1;
|
|
2448
|
-
let r =
|
|
2448
|
+
let r = fn / (t.viewport.scale || 1);
|
|
2449
2449
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
2450
2450
|
let i = n[t];
|
|
2451
2451
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
2452
2452
|
}
|
|
2453
2453
|
return -1;
|
|
2454
|
-
}, [c]),
|
|
2454
|
+
}, [c]), Me = f(() => {
|
|
2455
2455
|
b.current.length >= 1 && (E.current.push({
|
|
2456
|
-
points:
|
|
2456
|
+
points: un(b.current),
|
|
2457
2457
|
mode: M()
|
|
2458
|
-
}), b.current = [],
|
|
2458
|
+
}), b.current = [], ce(E.current)), z(), R();
|
|
2459
2459
|
}, [
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2460
|
+
R,
|
|
2461
|
+
ce,
|
|
2462
|
+
z
|
|
2463
2463
|
]);
|
|
2464
2464
|
return {
|
|
2465
|
-
reset:
|
|
2466
|
-
undoSession:
|
|
2467
|
-
redoSession:
|
|
2468
|
-
canUndoSession:
|
|
2469
|
-
canRedoSession:
|
|
2470
|
-
hasDraftSession:
|
|
2465
|
+
reset: B,
|
|
2466
|
+
undoSession: Ce,
|
|
2467
|
+
redoSession: we,
|
|
2468
|
+
canUndoSession: L,
|
|
2469
|
+
canRedoSession: ae,
|
|
2470
|
+
hasDraftSession: oe,
|
|
2471
2471
|
hasDraftPoints: de,
|
|
2472
|
-
commitDraftSession:
|
|
2473
|
-
completeFreehandStroke:
|
|
2474
|
-
setBrushScalarMode:
|
|
2472
|
+
commitDraftSession: Ee,
|
|
2473
|
+
completeFreehandStroke: De,
|
|
2474
|
+
setBrushScalarMode: Oe,
|
|
2475
2475
|
getBrushScalarMode: () => j.current,
|
|
2476
2476
|
hasBrushSession: P,
|
|
2477
|
-
commitBrush:
|
|
2477
|
+
commitBrush: G,
|
|
2478
2478
|
cancelBrush: f(() => {
|
|
2479
|
-
e.current ===
|
|
2480
|
-
}, [
|
|
2481
|
-
beginBrushEditFromSelection:
|
|
2482
|
-
deleteDraftSelectedPoints:
|
|
2483
|
-
hitDraftPoint:
|
|
2479
|
+
e.current === W.BRUSH && B();
|
|
2480
|
+
}, [B, e]),
|
|
2481
|
+
beginBrushEditFromSelection: ke,
|
|
2482
|
+
deleteDraftSelectedPoints: Ae,
|
|
2483
|
+
hitDraftPoint: je,
|
|
2484
2484
|
getDraftPointsSnapshot: ue,
|
|
2485
2485
|
tryClosePolygon: fe,
|
|
2486
2486
|
removeDraftPoint: pe,
|
|
2487
2487
|
selectDraftPointForDrag: me,
|
|
2488
|
-
appendPolygonPoint:
|
|
2489
|
-
beginStroke:
|
|
2490
|
-
appendStrokePoint:
|
|
2491
|
-
moveDraftPoints:
|
|
2492
|
-
commitDraftPointDrag:
|
|
2493
|
-
setDraftCursor:
|
|
2494
|
-
finishScalarStroke:
|
|
2488
|
+
appendPolygonPoint: H,
|
|
2489
|
+
beginStroke: he,
|
|
2490
|
+
appendStrokePoint: ge,
|
|
2491
|
+
moveDraftPoints: _e,
|
|
2492
|
+
commitDraftPointDrag: ve,
|
|
2493
|
+
setDraftCursor: ye,
|
|
2494
|
+
finishScalarStroke: Me,
|
|
2495
2495
|
handleToolChange: f((e, t) => {
|
|
2496
2496
|
if (t) {
|
|
2497
|
-
|
|
2497
|
+
B(), j.current = "draw";
|
|
2498
2498
|
return;
|
|
2499
2499
|
}
|
|
2500
|
-
if (e !==
|
|
2501
|
-
|
|
2500
|
+
if (e !== W.BRUSH) {
|
|
2501
|
+
B(), j.current = "draw";
|
|
2502
2502
|
return;
|
|
2503
2503
|
}
|
|
2504
|
-
j.current = "draw", E.current = [], b.current = [],
|
|
2504
|
+
j.current = "draw", E.current = [], b.current = [], se(), Te(), R(), z();
|
|
2505
2505
|
}, [
|
|
2506
|
+
R,
|
|
2506
2507
|
z,
|
|
2507
2508
|
B,
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
Ee
|
|
2509
|
+
se,
|
|
2510
|
+
Te
|
|
2511
2511
|
]),
|
|
2512
2512
|
handleBrushSelectionChange: f((t, n) => {
|
|
2513
|
-
if (!(e.current !==
|
|
2513
|
+
if (!(e.current !== W.BRUSH || n)) {
|
|
2514
2514
|
if (!t.length) {
|
|
2515
|
-
|
|
2515
|
+
R();
|
|
2516
2516
|
return;
|
|
2517
2517
|
}
|
|
2518
|
-
[...t].sort().join(",") !== [...O.current].sort().join(",") && (E.current.length || b.current.length || (E.current = [], b.current = [],
|
|
2518
|
+
[...t].sort().join(",") !== [...O.current].sort().join(",") && (E.current.length || b.current.length || (E.current = [], b.current = [], se(), Te(), R(), z()));
|
|
2519
2519
|
}
|
|
2520
2520
|
}, [
|
|
2521
|
+
R,
|
|
2521
2522
|
z,
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
Ee,
|
|
2523
|
+
se,
|
|
2524
|
+
Te,
|
|
2525
2525
|
e
|
|
2526
2526
|
])
|
|
2527
2527
|
};
|
|
2528
2528
|
}
|
|
2529
2529
|
//#endregion
|
|
2530
2530
|
//#region src/components/ShapeEditor/_state/useEditorDocument.ts
|
|
2531
|
-
function
|
|
2531
|
+
function hn(e, t) {
|
|
2532
2532
|
return {
|
|
2533
2533
|
shapes: t,
|
|
2534
2534
|
past: [...e.past, e.shapes],
|
|
2535
2535
|
future: []
|
|
2536
2536
|
};
|
|
2537
2537
|
}
|
|
2538
|
-
function
|
|
2538
|
+
function gn(e, t) {
|
|
2539
2539
|
switch (t.type) {
|
|
2540
|
-
case "CREATE": return
|
|
2540
|
+
case "CREATE": return hn(e, [...e.shapes, ...t.shapes]);
|
|
2541
2541
|
case "UPDATE": {
|
|
2542
2542
|
let n = new Map(t.shapes.map((e) => [e.id, e]));
|
|
2543
|
-
return
|
|
2543
|
+
return hn(e, e.shapes.map((e) => n.get(e.id) ?? e));
|
|
2544
2544
|
}
|
|
2545
2545
|
case "DELETE": {
|
|
2546
2546
|
let n = new Set(t.ids);
|
|
2547
|
-
return
|
|
2547
|
+
return hn(e, e.shapes.filter((e) => !n.has(e.id)));
|
|
2548
2548
|
}
|
|
2549
2549
|
case "REPLACE": {
|
|
2550
2550
|
let n = new Set(t.removeIds);
|
|
2551
|
-
return
|
|
2551
|
+
return hn(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
|
|
2552
2552
|
}
|
|
2553
2553
|
case "REORDER": {
|
|
2554
2554
|
let n = new Set(t.ids), r = e.shapes.filter((e) => n.has(e.id)), i = e.shapes.filter((e) => !n.has(e.id));
|
|
2555
|
-
return r.length === 0 ? e :
|
|
2555
|
+
return r.length === 0 ? e : hn(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
|
|
2556
2556
|
}
|
|
2557
2557
|
case "RESET": return {
|
|
2558
2558
|
shapes: t.shapes,
|
|
@@ -2572,15 +2572,15 @@ function _n(e, t) {
|
|
|
2572
2572
|
default: return e;
|
|
2573
2573
|
}
|
|
2574
2574
|
}
|
|
2575
|
-
function
|
|
2576
|
-
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = v(
|
|
2575
|
+
function _n(e) {
|
|
2576
|
+
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = v(gn, {
|
|
2577
2577
|
shapes: [],
|
|
2578
2578
|
past: [],
|
|
2579
2579
|
future: []
|
|
2580
2580
|
}), o = y(i);
|
|
2581
2581
|
o.current = i;
|
|
2582
2582
|
let s = f((e) => {
|
|
2583
|
-
o.current =
|
|
2583
|
+
o.current = gn(o.current, e), a(e);
|
|
2584
2584
|
}, []), c = f((e, i) => {
|
|
2585
2585
|
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));
|
|
2586
2586
|
s.length && t?.(s);
|
|
@@ -2649,7 +2649,7 @@ function vn(e) {
|
|
|
2649
2649
|
}
|
|
2650
2650
|
//#endregion
|
|
2651
2651
|
//#region src/components/ShapeEditor/_model/keymap.ts
|
|
2652
|
-
var
|
|
2652
|
+
var vn = {
|
|
2653
2653
|
undo: ["mod+z"],
|
|
2654
2654
|
redo: ["mod+shift+z"],
|
|
2655
2655
|
selectAll: ["mod+a"],
|
|
@@ -2677,7 +2677,7 @@ var yn = {
|
|
|
2677
2677
|
pathTool: ["g"],
|
|
2678
2678
|
brushTool: ["b"],
|
|
2679
2679
|
pointTool: ["i"]
|
|
2680
|
-
},
|
|
2680
|
+
}, yn = {
|
|
2681
2681
|
Equal: "=",
|
|
2682
2682
|
Minus: "-",
|
|
2683
2683
|
BracketLeft: "[",
|
|
@@ -2687,7 +2687,7 @@ var yn = {
|
|
|
2687
2687
|
Comma: ",",
|
|
2688
2688
|
Slash: "/",
|
|
2689
2689
|
Backquote: "`"
|
|
2690
|
-
},
|
|
2690
|
+
}, bn = {
|
|
2691
2691
|
Escape: "escape",
|
|
2692
2692
|
Enter: "enter",
|
|
2693
2693
|
Backspace: "backspace",
|
|
@@ -2698,58 +2698,58 @@ var yn = {
|
|
|
2698
2698
|
ArrowLeft: "arrowleft",
|
|
2699
2699
|
ArrowRight: "arrowright"
|
|
2700
2700
|
};
|
|
2701
|
-
function
|
|
2701
|
+
function xn(e) {
|
|
2702
2702
|
let t = e.code, n = /^Key([A-Z])$/.exec(t);
|
|
2703
2703
|
if (n) return n[1].toLowerCase();
|
|
2704
2704
|
let r = /^Digit([0-9])$/.exec(t);
|
|
2705
|
-
return r ? r[1] :
|
|
2705
|
+
return r ? r[1] : yn[t] ? yn[t] : bn[e.key] ? bn[e.key] : null;
|
|
2706
2706
|
}
|
|
2707
|
-
function
|
|
2708
|
-
let t =
|
|
2707
|
+
function Sn(e) {
|
|
2708
|
+
let t = xn(e);
|
|
2709
2709
|
if (!t) return null;
|
|
2710
2710
|
let n = [];
|
|
2711
2711
|
return (e.metaKey || e.ctrlKey) && n.push("mod"), e.shiftKey && n.push("shift"), e.altKey && n.push("alt"), n.push(t), n.join("+");
|
|
2712
2712
|
}
|
|
2713
|
-
function
|
|
2713
|
+
function Cn(e) {
|
|
2714
2714
|
let t = /* @__PURE__ */ new Map();
|
|
2715
|
-
for (let n of Object.keys(
|
|
2716
|
-
let r = e?.[n], i = r === void 0 ?
|
|
2715
|
+
for (let n of Object.keys(vn)) {
|
|
2716
|
+
let r = e?.[n], i = r === void 0 ? vn[n] : r === null ? [] : Array.isArray(r) ? r : [r];
|
|
2717
2717
|
for (let e of i) t.set(e.toLowerCase(), n);
|
|
2718
2718
|
}
|
|
2719
2719
|
return t;
|
|
2720
2720
|
}
|
|
2721
2721
|
//#endregion
|
|
2722
2722
|
//#region src/components/ShapeEditor/_state/useEditorHotkeys.ts
|
|
2723
|
-
var
|
|
2723
|
+
var wn = {
|
|
2724
2724
|
ArrowUp: [0, -1],
|
|
2725
2725
|
ArrowDown: [0, 1],
|
|
2726
2726
|
ArrowLeft: [-1, 0],
|
|
2727
2727
|
ArrowRight: [1, 0]
|
|
2728
2728
|
};
|
|
2729
|
-
function
|
|
2729
|
+
function Tn() {
|
|
2730
2730
|
let e = document.activeElement;
|
|
2731
2731
|
return !!e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable);
|
|
2732
2732
|
}
|
|
2733
|
-
function
|
|
2733
|
+
function En(e, t) {
|
|
2734
2734
|
if (!t || !(e instanceof Element)) return !1;
|
|
2735
2735
|
let n = e.closest("[role=\"dialog\"],[aria-modal=\"true\"]");
|
|
2736
2736
|
return !!n && !n.contains(t);
|
|
2737
2737
|
}
|
|
2738
|
-
function
|
|
2739
|
-
let { spaceRef: t, shiftRef: n } = e, r = _(() =>
|
|
2738
|
+
function Dn(e) {
|
|
2739
|
+
let { spaceRef: t, shiftRef: n } = e, r = _(() => Cn(e.keymap), [e.keymap]), i = y(e);
|
|
2740
2740
|
i.current = e;
|
|
2741
2741
|
let a = y(r);
|
|
2742
2742
|
a.current = r, p(() => {
|
|
2743
2743
|
let e = (e) => {
|
|
2744
|
-
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0),
|
|
2745
|
-
let r =
|
|
2744
|
+
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0), Tn() || En(e.target, i.current.hostRef.current)) return;
|
|
2745
|
+
let r = wn[e.key];
|
|
2746
2746
|
if (r) {
|
|
2747
2747
|
e.preventDefault();
|
|
2748
2748
|
let t = e.shiftKey ? 10 : 1;
|
|
2749
2749
|
i.current.nudge(r[0] * t, r[1] * t);
|
|
2750
2750
|
return;
|
|
2751
2751
|
}
|
|
2752
|
-
let o =
|
|
2752
|
+
let o = Sn(e);
|
|
2753
2753
|
if (!o) return;
|
|
2754
2754
|
let s = a.current.get(o);
|
|
2755
2755
|
s && i.current.actions[s]?.() !== !1 && e.preventDefault();
|
|
@@ -2763,7 +2763,7 @@ function On(e) {
|
|
|
2763
2763
|
}
|
|
2764
2764
|
//#endregion
|
|
2765
2765
|
//#region src/components/ShapeEditor/_model/imageFetch.ts
|
|
2766
|
-
async function
|
|
2766
|
+
async function On(e) {
|
|
2767
2767
|
for (let t of ["default", "reload"]) try {
|
|
2768
2768
|
let n = await fetch(e, {
|
|
2769
2769
|
mode: "cors",
|
|
@@ -2776,8 +2776,8 @@ async function kn(e) {
|
|
|
2776
2776
|
}
|
|
2777
2777
|
//#endregion
|
|
2778
2778
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
2779
|
-
var
|
|
2780
|
-
function
|
|
2779
|
+
var kn = 4e3;
|
|
2780
|
+
function An(e, t, n = kn) {
|
|
2781
2781
|
if (e <= 0 || t <= 0) return [];
|
|
2782
2782
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
2783
2783
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -2792,7 +2792,7 @@ function jn(e, t, n = An) {
|
|
|
2792
2792
|
};
|
|
2793
2793
|
})).flat();
|
|
2794
2794
|
}
|
|
2795
|
-
function
|
|
2795
|
+
function jn(e, t) {
|
|
2796
2796
|
let n = document.createElement("canvas");
|
|
2797
2797
|
n.width = t.width, n.height = t.height;
|
|
2798
2798
|
let r = n.getContext("2d");
|
|
@@ -2800,7 +2800,7 @@ function Mn(e, t) {
|
|
|
2800
2800
|
}
|
|
2801
2801
|
//#endregion
|
|
2802
2802
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
2803
|
-
function
|
|
2803
|
+
function Mn(e, t, n) {
|
|
2804
2804
|
if (t === N.POINT) {
|
|
2805
2805
|
e.setAttrs({
|
|
2806
2806
|
x: n[0].x,
|
|
@@ -2819,7 +2819,7 @@ function Nn(e, t, n) {
|
|
|
2819
2819
|
return;
|
|
2820
2820
|
}
|
|
2821
2821
|
if (t === N.ELLIPSE) {
|
|
2822
|
-
let t =
|
|
2822
|
+
let t = L(n);
|
|
2823
2823
|
e.setAttrs({
|
|
2824
2824
|
x: (t.minX + t.maxX) / 2,
|
|
2825
2825
|
y: (t.minY + t.maxY) / 2,
|
|
@@ -2836,23 +2836,23 @@ function Nn(e, t, n) {
|
|
|
2836
2836
|
}
|
|
2837
2837
|
//#endregion
|
|
2838
2838
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
2839
|
-
var
|
|
2840
|
-
function
|
|
2841
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
2839
|
+
var Nn = "M8 0C12.4183 0 16 3.58172 16 8C16 11.5323 13.71 14.5277 10.5342 15.5879L10.166 20.0068C10.0721 21.1334 9.13046 22 8 22C6.86954 22 5.92786 21.1334 5.83398 20.0068L5.46484 15.5879C2.28949 14.5275 0 11.532 0 8C0 3.58172 3.58172 0 8 0Z", Pn = "#ffffff", Fn = 1.5;
|
|
2840
|
+
function In(e) {
|
|
2841
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Nn}" fill="${e}" stroke="${Pn}" stroke-width="${Fn}"/></svg>`;
|
|
2842
2842
|
}
|
|
2843
2843
|
//#endregion
|
|
2844
2844
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
2845
|
-
var
|
|
2846
|
-
function
|
|
2845
|
+
var Ln = Math.PI / 12;
|
|
2846
|
+
function Rn(e, t) {
|
|
2847
2847
|
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === N.ROTATED_RECTANGLE;
|
|
2848
2848
|
}
|
|
2849
|
-
function
|
|
2849
|
+
function zn(e, t, n) {
|
|
2850
2850
|
if (e.kind === "resize") {
|
|
2851
|
-
let r = n ? e.box :
|
|
2851
|
+
let r = n ? e.box : oe(e.anchor, e.box, t.x, t.y);
|
|
2852
2852
|
return {
|
|
2853
2853
|
updates: e.shapes.map((i) => ({
|
|
2854
2854
|
id: i.id,
|
|
2855
|
-
points: n ?
|
|
2855
|
+
points: n ? _e(i.points, e.anchor, t) : ve(i.points, e.box, r)
|
|
2856
2856
|
})),
|
|
2857
2857
|
box: r
|
|
2858
2858
|
};
|
|
@@ -2877,10 +2877,10 @@ function Bn(e, t, n) {
|
|
|
2877
2877
|
}
|
|
2878
2878
|
if (e.kind === "rotate") {
|
|
2879
2879
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
2880
|
-
return e.shiftKey && (n = Math.round(n /
|
|
2880
|
+
return e.shiftKey && (n = Math.round(n / Ln) * Ln), {
|
|
2881
2881
|
updates: [{
|
|
2882
2882
|
id: e.id,
|
|
2883
|
-
points: e.points.map((t) =>
|
|
2883
|
+
points: e.points.map((t) => se(t, e.center, n))
|
|
2884
2884
|
}],
|
|
2885
2885
|
box: null
|
|
2886
2886
|
};
|
|
@@ -2894,24 +2894,24 @@ function Bn(e, t, n) {
|
|
|
2894
2894
|
id: e.id,
|
|
2895
2895
|
points: a
|
|
2896
2896
|
}],
|
|
2897
|
-
box:
|
|
2897
|
+
box: L(a)
|
|
2898
2898
|
};
|
|
2899
2899
|
}
|
|
2900
|
-
function
|
|
2900
|
+
function Bn(e, t) {
|
|
2901
2901
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
2902
2902
|
x: t.center.x + Math.cos(t.startAngle),
|
|
2903
2903
|
y: t.center.y + Math.sin(t.startAngle)
|
|
2904
|
-
} :
|
|
2904
|
+
} : Rn(e, t) ? H(t.shapes[0].points)[I.indexOf(t.anchor)] : ae(t.anchor, t.box);
|
|
2905
2905
|
}
|
|
2906
2906
|
function Vn(e, t, n) {
|
|
2907
|
-
let r = e.filter((e) => t.includes(e.id) &&
|
|
2907
|
+
let r = e.filter((e) => t.includes(e.id) && ne(e)).map((e) => ({
|
|
2908
2908
|
id: e.id,
|
|
2909
2909
|
points: e.points
|
|
2910
2910
|
}));
|
|
2911
2911
|
return r.length ? {
|
|
2912
2912
|
kind: "move",
|
|
2913
2913
|
start: n,
|
|
2914
|
-
box:
|
|
2914
|
+
box: L(r.flatMap((e) => e.points)),
|
|
2915
2915
|
shapes: r
|
|
2916
2916
|
} : null;
|
|
2917
2917
|
}
|
|
@@ -2921,21 +2921,21 @@ function Hn(e) {
|
|
|
2921
2921
|
points: e.points.map((e) => ({ ...e }))
|
|
2922
2922
|
}));
|
|
2923
2923
|
}
|
|
2924
|
-
function
|
|
2924
|
+
function $(e, t) {
|
|
2925
2925
|
let n = new Set(t);
|
|
2926
|
-
return e.filter((e) => n.has(e.id) &&
|
|
2926
|
+
return e.filter((e) => n.has(e.id) && te(e));
|
|
2927
2927
|
}
|
|
2928
|
-
function
|
|
2928
|
+
function Un(e, t) {
|
|
2929
2929
|
return e.filter((e) => {
|
|
2930
|
-
if (!
|
|
2931
|
-
let n =
|
|
2930
|
+
if (!F(e)) return !1;
|
|
2931
|
+
let n = L(e.points);
|
|
2932
2932
|
return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
|
|
2933
2933
|
}).map((e) => e.id);
|
|
2934
2934
|
}
|
|
2935
|
-
function
|
|
2936
|
-
return (e ?
|
|
2935
|
+
function Wn(e, t, n) {
|
|
2936
|
+
return (e ? Ie(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
2937
2937
|
}
|
|
2938
|
-
function
|
|
2938
|
+
function Gn(e, t) {
|
|
2939
2939
|
return {
|
|
2940
2940
|
minX: e.x - t,
|
|
2941
2941
|
minY: e.y - t,
|
|
@@ -2943,10 +2943,10 @@ function Kn(e, t) {
|
|
|
2943
2943
|
maxY: e.y + t
|
|
2944
2944
|
};
|
|
2945
2945
|
}
|
|
2946
|
-
function
|
|
2946
|
+
function Kn(e, t, n) {
|
|
2947
2947
|
if (e.type === N.ROTATED_RECTANGLE) return t;
|
|
2948
|
-
let r = e.type === N.POINT ?
|
|
2949
|
-
return
|
|
2948
|
+
let r = e.type === N.POINT ? Gn(t[0], n) : L(t);
|
|
2949
|
+
return z([{
|
|
2950
2950
|
x: r.minX,
|
|
2951
2951
|
y: r.minY
|
|
2952
2952
|
}, {
|
|
@@ -2954,17 +2954,17 @@ function qn(e, t, n) {
|
|
|
2954
2954
|
y: r.maxY
|
|
2955
2955
|
}]);
|
|
2956
2956
|
}
|
|
2957
|
-
function
|
|
2957
|
+
function qn(e) {
|
|
2958
2958
|
return 24 / (e || 1);
|
|
2959
2959
|
}
|
|
2960
|
-
function
|
|
2960
|
+
function Jn(e, t) {
|
|
2961
2961
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
2962
2962
|
}
|
|
2963
2963
|
//#endregion
|
|
2964
2964
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
2965
|
-
var
|
|
2965
|
+
var Yn = 2, Xn = "#1e88e5", Zn = "#669def", Qn = class {
|
|
2966
2966
|
constructor(e, t) {
|
|
2967
|
-
this.layer = new w.Layer(), this.world = new w.Group(), this.bgGroup = new w.Group(), this.overlayGroup = new w.Group({ listening: !1 }), this.guideOverlayGroup = new w.Group({ listening: !1 }), this.regionOverlayGroup = new w.Group({ listening: !1 }), this.dimOverlayGroup = new w.Group({ listening: !1 }), this.shapeGroup = new w.Group(), this.selGroup = new w.Group(), this.previewGroup = new w.Group(), this.handleGroup = new w.Group(), this.baseCursor = "default", this.strokeSize =
|
|
2967
|
+
this.layer = new w.Layer(), this.world = new w.Group(), this.bgGroup = new w.Group(), this.overlayGroup = new w.Group({ listening: !1 }), this.guideOverlayGroup = new w.Group({ listening: !1 }), this.regionOverlayGroup = new w.Group({ listening: !1 }), this.dimOverlayGroup = new w.Group({ listening: !1 }), this.shapeGroup = new w.Group(), this.selGroup = new w.Group(), this.previewGroup = new w.Group(), this.handleGroup = new w.Group(), this.baseCursor = "default", this.strokeSize = Yn, this.imageSmoothing = !0, this.imageWidth = 0, this.imageHeight = 0, this.shapes = [], this.selected = [], this.nodes = /* @__PURE__ */ new Map(), this.altNodes = /* @__PURE__ */ new Map(), this.lastAppliedScale = -1, this.imageLoadToken = 0, this.transformEnabled = !1, this.handleNodes = [], this.vertexNodes = [], this.lastImg = {
|
|
2968
2968
|
x: 0,
|
|
2969
2969
|
y: 0
|
|
2970
2970
|
}, this.lastDragImg = null, this.ro = 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.selectionBorders = [], this.upCleanup = null, this.lastPreviewPoly = null, this.preview = null, this.marquee = null, this.host = e, this.cb = t, this.stage = new w.Stage({
|
|
@@ -3056,7 +3056,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3056
3056
|
return this.world.getAbsoluteTransform().point(e);
|
|
3057
3057
|
}
|
|
3058
3058
|
async setImage(e, t, n) {
|
|
3059
|
-
let r = ++this.imageLoadToken, i = await
|
|
3059
|
+
let r = ++this.imageLoadToken, i = await On(e);
|
|
3060
3060
|
await new Promise((a) => {
|
|
3061
3061
|
let o = new Image();
|
|
3062
3062
|
i || (o.crossOrigin = "anonymous"), o.onload = () => {
|
|
@@ -3067,7 +3067,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3067
3067
|
x: e / o.naturalWidth,
|
|
3068
3068
|
y: s / o.naturalHeight
|
|
3069
3069
|
}), this.bgGroup.destroyChildren();
|
|
3070
|
-
for (let e of
|
|
3070
|
+
for (let e of An(o.naturalWidth, o.naturalHeight)) this.bgGroup.add(new w.Image({
|
|
3071
3071
|
image: o,
|
|
3072
3072
|
x: e.x,
|
|
3073
3073
|
y: e.y,
|
|
@@ -3125,7 +3125,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3125
3125
|
if (this.regionOverlayGroup.add(new w.Shape({
|
|
3126
3126
|
listening: !1,
|
|
3127
3127
|
sceneFunc: (r) => {
|
|
3128
|
-
|
|
3128
|
+
Ot(r._context, e, t, n);
|
|
3129
3129
|
}
|
|
3130
3130
|
})), e.outlineStyles) {
|
|
3131
3131
|
let t = (e, t) => {
|
|
@@ -3181,7 +3181,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3181
3181
|
let e = this.lastPreviewPoly;
|
|
3182
3182
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
3183
3183
|
}
|
|
3184
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3184
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? Bn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
3185
3185
|
}
|
|
3186
3186
|
fit() {
|
|
3187
3187
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3212,8 +3212,8 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3212
3212
|
setShapes(e, t) {
|
|
3213
3213
|
if (this.shapes = Hn(e), this.selected = t, !this.activeDrag) {
|
|
3214
3214
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3215
|
-
for (let t of
|
|
3216
|
-
let e = this.makeNode(t), n =
|
|
3215
|
+
for (let t of re(e).filter(P)) {
|
|
3216
|
+
let e = this.makeNode(t), n = Ie(t, { strokeWidth: this.strokeSize });
|
|
3217
3217
|
if (t.style?.alternateColor && n.dash?.length && t.type !== N.POINT) {
|
|
3218
3218
|
let n = e.clone({
|
|
3219
3219
|
id: `${t.id}__alt`,
|
|
@@ -3244,7 +3244,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3244
3244
|
t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
|
|
3245
3245
|
}
|
|
3246
3246
|
makeNode(e) {
|
|
3247
|
-
let { type: t, points: n } = e, r =
|
|
3247
|
+
let { type: t, points: n } = e, r = Ie(e, { strokeWidth: this.strokeSize }), i = F(e), a = {
|
|
3248
3248
|
id: e.id,
|
|
3249
3249
|
stroke: r.color,
|
|
3250
3250
|
strokeWidth: r.strokeWidth,
|
|
@@ -3252,11 +3252,11 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3252
3252
|
opacity: r.opacity,
|
|
3253
3253
|
strokeScaleEnabled: !1,
|
|
3254
3254
|
listening: i
|
|
3255
|
-
}, o = r.fillVisible ?
|
|
3255
|
+
}, o = r.fillVisible ? q(r.color, r.fillAlpha) : void 0;
|
|
3256
3256
|
if (t === N.POINT) {
|
|
3257
3257
|
let t = 1 / (this.world.scaleX() || 1), a = new w.Path({
|
|
3258
3258
|
id: e.id,
|
|
3259
|
-
data:
|
|
3259
|
+
data: Nn,
|
|
3260
3260
|
x: n[0].x,
|
|
3261
3261
|
y: n[0].y,
|
|
3262
3262
|
offsetX: 16 / 2,
|
|
@@ -3264,8 +3264,8 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3264
3264
|
scaleX: t,
|
|
3265
3265
|
scaleY: t,
|
|
3266
3266
|
fill: r.color,
|
|
3267
|
-
stroke:
|
|
3268
|
-
strokeWidth:
|
|
3267
|
+
stroke: Pn,
|
|
3268
|
+
strokeWidth: Fn,
|
|
3269
3269
|
strokeScaleEnabled: !1,
|
|
3270
3270
|
shadowColor: "#000",
|
|
3271
3271
|
shadowBlur: 2,
|
|
@@ -3274,10 +3274,10 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3274
3274
|
opacity: r.opacity,
|
|
3275
3275
|
listening: i
|
|
3276
3276
|
});
|
|
3277
|
-
return this.bindCursor(a,
|
|
3277
|
+
return this.bindCursor(a, ne(e) ? "grab" : "default"), a;
|
|
3278
3278
|
}
|
|
3279
3279
|
if (t === N.RECTANGLE) {
|
|
3280
|
-
let t =
|
|
3280
|
+
let t = L(n), r = new w.Rect({
|
|
3281
3281
|
x: t.minX,
|
|
3282
3282
|
y: t.minY,
|
|
3283
3283
|
width: t.maxX - t.minX,
|
|
@@ -3285,10 +3285,10 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3285
3285
|
fill: o,
|
|
3286
3286
|
...a
|
|
3287
3287
|
});
|
|
3288
|
-
return this.bindCursor(r,
|
|
3288
|
+
return this.bindCursor(r, ne(e) ? "grab" : "default"), r;
|
|
3289
3289
|
}
|
|
3290
3290
|
if (t === N.ELLIPSE) {
|
|
3291
|
-
let t =
|
|
3291
|
+
let t = L(n), r = new w.Ellipse({
|
|
3292
3292
|
x: (t.minX + t.maxX) / 2,
|
|
3293
3293
|
y: (t.minY + t.maxY) / 2,
|
|
3294
3294
|
radiusX: (t.maxX - t.minX) / 2,
|
|
@@ -3296,7 +3296,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3296
3296
|
fill: o,
|
|
3297
3297
|
...a
|
|
3298
3298
|
});
|
|
3299
|
-
return this.bindCursor(r,
|
|
3299
|
+
return this.bindCursor(r, ne(e) ? "grab" : "default"), r;
|
|
3300
3300
|
}
|
|
3301
3301
|
let s = n.flatMap((e) => [e.x, e.y]), c = t !== N.LINE, l = new w.Line({
|
|
3302
3302
|
points: s,
|
|
@@ -3305,18 +3305,18 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3305
3305
|
lineJoin: "round",
|
|
3306
3306
|
...a
|
|
3307
3307
|
});
|
|
3308
|
-
return this.bindCursor(l,
|
|
3308
|
+
return this.bindCursor(l, ne(e) ? "grab" : "default"), l;
|
|
3309
3309
|
}
|
|
3310
3310
|
liveUpdateShape(e, t) {
|
|
3311
3311
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3312
3312
|
if (n && r) {
|
|
3313
|
-
|
|
3313
|
+
Mn(n, r.type, t);
|
|
3314
3314
|
let i = this.altNodes.get(e);
|
|
3315
|
-
i &&
|
|
3315
|
+
i && Mn(i, r.type, t), r.type === N.POINT && n instanceof w.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3316
3316
|
}
|
|
3317
3317
|
}
|
|
3318
3318
|
pointRadius(e) {
|
|
3319
|
-
return
|
|
3319
|
+
return Wn(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3320
3320
|
}
|
|
3321
3321
|
scaledDash(e) {
|
|
3322
3322
|
return e;
|
|
@@ -3332,20 +3332,20 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3332
3332
|
});
|
|
3333
3333
|
continue;
|
|
3334
3334
|
}
|
|
3335
|
-
n?.dash(this.scaledDash(
|
|
3335
|
+
n?.dash(this.scaledDash(Ie(t, { strokeWidth: this.strokeSize }).dash));
|
|
3336
3336
|
}
|
|
3337
3337
|
}
|
|
3338
3338
|
shapesIntersecting(e) {
|
|
3339
|
-
return
|
|
3339
|
+
return Un(this.shapes, e);
|
|
3340
3340
|
}
|
|
3341
3341
|
drawSelectionBorders() {
|
|
3342
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
3342
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && F(t)) : [];
|
|
3343
3343
|
if (this.selectionBorders.length !== t.length) {
|
|
3344
3344
|
for (let e of this.selectionBorders) e.destroy();
|
|
3345
3345
|
this.selectionBorders = t.map(() => {
|
|
3346
3346
|
let e = new w.Line({
|
|
3347
3347
|
closed: !0,
|
|
3348
|
-
stroke:
|
|
3348
|
+
stroke: Zn,
|
|
3349
3349
|
strokeWidth: 1.5,
|
|
3350
3350
|
strokeScaleEnabled: !1,
|
|
3351
3351
|
listening: !1
|
|
@@ -3360,13 +3360,13 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3360
3360
|
updateSelectionBordersLive(e) {
|
|
3361
3361
|
let t = new Set(this.selected), n = 0;
|
|
3362
3362
|
for (let r of this.shapes) {
|
|
3363
|
-
if (!t.has(r.id) || !
|
|
3363
|
+
if (!t.has(r.id) || !F(r)) continue;
|
|
3364
3364
|
let i = this.selectionOutlinePoints(r, e(r)), a = this.selectionBorders[n++];
|
|
3365
3365
|
a && a.points(i.flatMap((e) => [e.x, e.y]));
|
|
3366
3366
|
}
|
|
3367
3367
|
}
|
|
3368
3368
|
selectionOutlinePoints(e, t) {
|
|
3369
|
-
return
|
|
3369
|
+
return Kn(e, t, this.pointRadius(e));
|
|
3370
3370
|
}
|
|
3371
3371
|
clearPreview() {
|
|
3372
3372
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3429,8 +3429,8 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3429
3429
|
x: n.x,
|
|
3430
3430
|
y: n.y,
|
|
3431
3431
|
radius: (r ? 6 : 5) / l,
|
|
3432
|
-
fill: r ?
|
|
3433
|
-
stroke: r ? "#ffffff" :
|
|
3432
|
+
fill: r ? Xn : "#ffffff",
|
|
3433
|
+
stroke: r ? "#ffffff" : Xn,
|
|
3434
3434
|
strokeWidth: 1.5,
|
|
3435
3435
|
strokeScaleEnabled: !1,
|
|
3436
3436
|
listening: !1
|
|
@@ -3440,7 +3440,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3440
3440
|
}
|
|
3441
3441
|
previewScalarMask(e, t) {
|
|
3442
3442
|
this.previewGroup.destroyChildren();
|
|
3443
|
-
let n =
|
|
3443
|
+
let n = sn(e, t.length === 7 ? `${t}99` : t);
|
|
3444
3444
|
this.previewGroup.add(new w.Image({
|
|
3445
3445
|
image: n,
|
|
3446
3446
|
x: e.ox,
|
|
@@ -3452,8 +3452,8 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3452
3452
|
}
|
|
3453
3453
|
previewMarquee(e, t) {
|
|
3454
3454
|
this.marquee || (this.marquee = new w.Rect({
|
|
3455
|
-
fill:
|
|
3456
|
-
stroke:
|
|
3455
|
+
fill: q(Ne, K),
|
|
3456
|
+
stroke: Ne,
|
|
3457
3457
|
strokeWidth: 1,
|
|
3458
3458
|
strokeScaleEnabled: !1,
|
|
3459
3459
|
listening: !1,
|
|
@@ -3473,7 +3473,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3473
3473
|
}
|
|
3474
3474
|
setTransformerOutline(e) {
|
|
3475
3475
|
let t = Math.max(0, e.maxX - e.minX), n = Math.max(0, e.maxY - e.minY);
|
|
3476
|
-
!t && !n || this.setTransformerOutlinePoints(
|
|
3476
|
+
!t && !n || this.setTransformerOutlinePoints(z([{
|
|
3477
3477
|
x: e.minX,
|
|
3478
3478
|
y: e.minY
|
|
3479
3479
|
}, {
|
|
@@ -3484,17 +3484,17 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3484
3484
|
setTransformerOutlinePoints(e) {
|
|
3485
3485
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new w.Line({
|
|
3486
3486
|
closed: !0,
|
|
3487
|
-
stroke:
|
|
3487
|
+
stroke: Xn,
|
|
3488
3488
|
strokeWidth: 1,
|
|
3489
3489
|
strokeScaleEnabled: !1,
|
|
3490
3490
|
listening: !1
|
|
3491
3491
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3492
3492
|
}
|
|
3493
3493
|
rotationHandleGap() {
|
|
3494
|
-
return
|
|
3494
|
+
return qn(this.viewport.scale);
|
|
3495
3495
|
}
|
|
3496
3496
|
rotationHandleScreenPoint(e) {
|
|
3497
|
-
return this.imgToScreen(
|
|
3497
|
+
return this.imgToScreen(he(e, this.rotationHandleGap()));
|
|
3498
3498
|
}
|
|
3499
3499
|
setRotationConnector(e) {
|
|
3500
3500
|
let t = this.imgToScreen(pe(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
@@ -3510,7 +3510,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3510
3510
|
n.x,
|
|
3511
3511
|
n.y
|
|
3512
3512
|
],
|
|
3513
|
-
stroke:
|
|
3513
|
+
stroke: Xn,
|
|
3514
3514
|
strokeWidth: 1,
|
|
3515
3515
|
listening: !1
|
|
3516
3516
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3525,11 +3525,11 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3525
3525
|
}), e.rotation(n * 180 / Math.PI);
|
|
3526
3526
|
}
|
|
3527
3527
|
orientedHandleAngle(e) {
|
|
3528
|
-
return
|
|
3528
|
+
return Jn(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3529
3529
|
}
|
|
3530
3530
|
repositionOrientedHandles(e) {
|
|
3531
3531
|
let t = this.orientedHandleAngle(e);
|
|
3532
|
-
if (
|
|
3532
|
+
if (H(e).forEach((e, n) => {
|
|
3533
3533
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
3534
3534
|
i && this.layoutResizeHandle(i, r, t);
|
|
3535
3535
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -3547,13 +3547,13 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3547
3547
|
for (let e of this.vertexNodes) e.destroy();
|
|
3548
3548
|
for (let e of this.midNodes) e.destroy();
|
|
3549
3549
|
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;
|
|
3550
|
-
let e =
|
|
3550
|
+
let e = $(this.shapes, this.selected);
|
|
3551
3551
|
if (!e.length || e.length === 1 && e[0].type === N.POINT) return;
|
|
3552
|
-
let t = e.length === 1 && (e[0].type === N.POLYGON || e[0].type === N.LINE) && this.editingId === e[0].id ? e[0] : null, n =
|
|
3552
|
+
let t = e.length === 1 && (e[0].type === N.POLYGON || e[0].type === N.LINE) && this.editingId === e[0].id ? e[0] : null, n = L(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === N.ROTATED_RECTANGLE ? e[0] : null, i = r ? H(r.points) : I.map((e) => ae(e, n));
|
|
3553
3553
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
3554
3554
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
3555
|
-
for (let e of t ? [] :
|
|
3556
|
-
let t = this.imgToScreen(i[
|
|
3555
|
+
for (let e of t ? [] : I) {
|
|
3556
|
+
let t = this.imgToScreen(i[I.indexOf(e)]), n = new w.Rect({
|
|
3557
3557
|
x: t.x,
|
|
3558
3558
|
y: t.y,
|
|
3559
3559
|
width: 8,
|
|
@@ -3562,16 +3562,16 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3562
3562
|
offsetY: 4,
|
|
3563
3563
|
rotation: a * 180 / Math.PI,
|
|
3564
3564
|
fill: "#ffffff",
|
|
3565
|
-
stroke:
|
|
3565
|
+
stroke: Xn,
|
|
3566
3566
|
strokeWidth: 1
|
|
3567
|
-
}), r =
|
|
3567
|
+
}), r = gt(e, a);
|
|
3568
3568
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
3569
3569
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
3570
|
-
let n =
|
|
3570
|
+
let n = $(this.shapes, this.selected);
|
|
3571
3571
|
this.activeDrag = {
|
|
3572
3572
|
kind: "resize",
|
|
3573
3573
|
anchor: e,
|
|
3574
|
-
box:
|
|
3574
|
+
box: L(n.flatMap((e) => e.points)),
|
|
3575
3575
|
shapes: n.map((e) => ({
|
|
3576
3576
|
id: e.id,
|
|
3577
3577
|
points: e.points
|
|
@@ -3584,7 +3584,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3584
3584
|
radius: i * .8,
|
|
3585
3585
|
fill: "#ffffff",
|
|
3586
3586
|
opacity: .6,
|
|
3587
|
-
stroke:
|
|
3587
|
+
stroke: Xn,
|
|
3588
3588
|
strokeWidth: 1,
|
|
3589
3589
|
visible: !1,
|
|
3590
3590
|
listening: !1
|
|
@@ -3644,8 +3644,8 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3644
3644
|
x: a.x,
|
|
3645
3645
|
y: a.y,
|
|
3646
3646
|
radius: i,
|
|
3647
|
-
fill: o ?
|
|
3648
|
-
stroke: o ? "#ffffff" :
|
|
3647
|
+
fill: o ? Xn : "#ffffff",
|
|
3648
|
+
stroke: o ? "#ffffff" : Xn,
|
|
3649
3649
|
strokeWidth: Math.max(1.5, i * .3)
|
|
3650
3650
|
});
|
|
3651
3651
|
this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
|
|
@@ -3670,7 +3670,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3670
3670
|
y: r.y,
|
|
3671
3671
|
radius: 6,
|
|
3672
3672
|
fill: "#ffffff",
|
|
3673
|
-
stroke:
|
|
3673
|
+
stroke: Xn,
|
|
3674
3674
|
strokeWidth: 1.5
|
|
3675
3675
|
});
|
|
3676
3676
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -3693,8 +3693,8 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3693
3693
|
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 === N.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
3694
3694
|
}
|
|
3695
3695
|
repositionHandles(e) {
|
|
3696
|
-
|
|
3697
|
-
let r = this.imgToScreen(
|
|
3696
|
+
I.forEach((t, n) => {
|
|
3697
|
+
let r = this.imgToScreen(ae(t, e)), i = this.handleNodes[n];
|
|
3698
3698
|
i && this.layoutResizeHandle(i, r, 0);
|
|
3699
3699
|
}), this.setTransformerOutline(e);
|
|
3700
3700
|
}
|
|
@@ -3731,7 +3731,7 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3731
3731
|
let t = this.activeDrag;
|
|
3732
3732
|
if (!t) return;
|
|
3733
3733
|
this.applyCursor();
|
|
3734
|
-
let n =
|
|
3734
|
+
let n = Rn(this.shapes, t), { updates: r, box: i } = zn(t, e, n);
|
|
3735
3735
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
3736
3736
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
3737
3737
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
@@ -3758,18 +3758,18 @@ var Xn = 2, Zn = "#1e88e5", Qn = "#669def", $n = class {
|
|
|
3758
3758
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
3759
3759
|
return;
|
|
3760
3760
|
}
|
|
3761
|
-
let { updates: n } =
|
|
3761
|
+
let { updates: n } = zn(e, t, Rn(this.shapes, e));
|
|
3762
3762
|
this.commitTransformUpdates(n);
|
|
3763
3763
|
}
|
|
3764
|
-
},
|
|
3765
|
-
function
|
|
3766
|
-
if (!e) return
|
|
3764
|
+
}, $n = 2, er = 58879, tr = 6725103;
|
|
3765
|
+
function nr(e) {
|
|
3766
|
+
if (!e) return er;
|
|
3767
3767
|
let t = e.replace("#", "");
|
|
3768
3768
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
3769
3769
|
}
|
|
3770
3770
|
var rr = class {
|
|
3771
3771
|
constructor(e, t) {
|
|
3772
|
-
this.app = new T(), this.world = new D(), this.bgLayer = new D(), this.overlayLayer = new D(), this.guideOverlayLayer = new D(), this.regionOverlayLayer = new D(), this.dimOverlayLayer = new D(), this.shapeLayer = new D(), this.selLayer = new D(), this.previewLayer = new D(), this.handleLayer = new D(), this.filter = new E(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionDimMaskG = new O(), this.regionDimG = new O(), this.regionZoneMaskG = new O(), this.regionZoneG = new O(), this.regionOutlineG = new O(), this.baseCursor = "default", this.strokeSize =
|
|
3772
|
+
this.app = new T(), this.world = new D(), this.bgLayer = new D(), this.overlayLayer = new D(), this.guideOverlayLayer = new D(), this.regionOverlayLayer = new D(), this.dimOverlayLayer = new D(), this.shapeLayer = new D(), this.selLayer = new D(), this.previewLayer = new D(), this.handleLayer = new D(), this.filter = new E(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.overlayTextures = [], this.region = null, this.regionDimMaskG = new O(), this.regionDimG = new O(), this.regionZoneMaskG = new O(), this.regionZoneG = new O(), this.regionOutlineG = new O(), this.baseCursor = "default", this.strokeSize = $n, 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 O(), this.marqueeG = new O(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
3773
3773
|
}
|
|
3774
3774
|
ev(e) {
|
|
3775
3775
|
return {
|
|
@@ -3867,7 +3867,7 @@ var rr = class {
|
|
|
3867
3867
|
};
|
|
3868
3868
|
}
|
|
3869
3869
|
async setImage(e, t, n) {
|
|
3870
|
-
let r = ++this.imageLoadToken, i = await
|
|
3870
|
+
let r = ++this.imageLoadToken, i = await On(e);
|
|
3871
3871
|
if (this.destroyed) {
|
|
3872
3872
|
i && URL.revokeObjectURL(i);
|
|
3873
3873
|
return;
|
|
@@ -3879,8 +3879,8 @@ var rr = class {
|
|
|
3879
3879
|
this.imageWidth = t?.width ?? o.naturalWidth, this.imageHeight = t?.height ?? o.naturalHeight;
|
|
3880
3880
|
let e = n?.width ?? this.imageWidth, s = n?.height ?? this.imageHeight;
|
|
3881
3881
|
this.bgLayer.scale.set(e / o.naturalWidth, s / o.naturalHeight), this.clearImageTiles();
|
|
3882
|
-
for (let e of
|
|
3883
|
-
let t = M.from(
|
|
3882
|
+
for (let e of An(o.naturalWidth, o.naturalHeight)) {
|
|
3883
|
+
let t = M.from(jn(o, e));
|
|
3884
3884
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
3885
3885
|
let n = new j(t);
|
|
3886
3886
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
@@ -3942,7 +3942,7 @@ var rr = class {
|
|
|
3942
3942
|
}
|
|
3943
3943
|
setRegionOverlay(e) {
|
|
3944
3944
|
if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
|
|
3945
|
-
let t =
|
|
3945
|
+
let t = nr(e.dim.color);
|
|
3946
3946
|
for (let t of e.rects) this.regionDimMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215), this.regionZoneMaskG.rect(t.x, t.y, t.w, t.h).fill(16777215);
|
|
3947
3947
|
this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
3948
3948
|
color: t,
|
|
@@ -3963,7 +3963,7 @@ var rr = class {
|
|
|
3963
3963
|
}
|
|
3964
3964
|
applyViewport(e) {
|
|
3965
3965
|
let t = e.scale !== this.lastAppliedScale;
|
|
3966
|
-
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3966
|
+
this.lastAppliedScale = e.scale, this.world.scale.set(e.scale), this.world.position.set(e.x, e.y), this.world.visible = !0, t && this.restrokeShapes(), this.activeDrag ? this.dragTransform(this.lastDragImg ?? Bn(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
3967
3967
|
}
|
|
3968
3968
|
fit() {
|
|
3969
3969
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -4022,13 +4022,13 @@ var rr = class {
|
|
|
4022
4022
|
this.handleLayer.interactiveChildren = !e;
|
|
4023
4023
|
}
|
|
4024
4024
|
strokeW(e) {
|
|
4025
|
-
return (e ?
|
|
4025
|
+
return (e ? Ie(e, { strokeWidth: this.strokeSize }).strokeWidth : $n) / this.world.scale.x;
|
|
4026
4026
|
}
|
|
4027
4027
|
pointRadius(e) {
|
|
4028
|
-
return
|
|
4028
|
+
return Wn(e, this.strokeSize, this.world.scale.x);
|
|
4029
4029
|
}
|
|
4030
4030
|
dashForShape(e) {
|
|
4031
|
-
let t =
|
|
4031
|
+
let t = Ie(e, { strokeWidth: this.strokeSize }).dash;
|
|
4032
4032
|
if (!t?.length) return null;
|
|
4033
4033
|
let n = this.world.scale.x || 1;
|
|
4034
4034
|
return [t[0] / n, (t[1] ?? t[0]) / n];
|
|
@@ -4037,9 +4037,9 @@ var rr = class {
|
|
|
4037
4037
|
this.shapeLayer.removeChildren();
|
|
4038
4038
|
for (let e of this.nodes.values()) e.destroy();
|
|
4039
4039
|
this.nodes.clear();
|
|
4040
|
-
for (let e of
|
|
4040
|
+
for (let e of re(this.shapes).filter(P)) {
|
|
4041
4041
|
let t = new O();
|
|
4042
|
-
this.paintShape(t, e), t.eventMode =
|
|
4042
|
+
this.paintShape(t, e), t.eventMode = F(e) ? "static" : "none", t.cursor = void 0, F(e) && ne(e) && (t.on("pointerover", () => {
|
|
4043
4043
|
!this.activeDrag && this.transformEnabled && this.emitCursorHint("grab");
|
|
4044
4044
|
}), t.on("pointerout", () => {
|
|
4045
4045
|
this.activeDrag || this.emitCursorHint(null);
|
|
@@ -4050,15 +4050,15 @@ var rr = class {
|
|
|
4050
4050
|
}
|
|
4051
4051
|
paintShape(e, t) {
|
|
4052
4052
|
e.clear();
|
|
4053
|
-
let n =
|
|
4053
|
+
let n = Ie(t, { strokeWidth: this.strokeSize }), r = nr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4054
4054
|
if (t.type === N.POINT) {
|
|
4055
|
-
e.svg(
|
|
4055
|
+
e.svg(In(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4056
4056
|
let r = 1 / (this.world.scale.x || 1);
|
|
4057
4057
|
e.scale.set(r, r), e.alpha = a;
|
|
4058
4058
|
return;
|
|
4059
4059
|
}
|
|
4060
4060
|
if (n.fillVisible && t.type !== N.LINE) {
|
|
4061
|
-
let i = t.type === N.POLYGON ?
|
|
4061
|
+
let i = t.type === N.POLYGON ? Se(t.points) : null;
|
|
4062
4062
|
if (i && i.length > 1) for (let t of i) e.poly(t.flatMap((e) => [e.x, e.y]), !0), e.fill({
|
|
4063
4063
|
color: r,
|
|
4064
4064
|
alpha: n.fillAlpha * a
|
|
@@ -4074,7 +4074,7 @@ var rr = class {
|
|
|
4074
4074
|
if (o) {
|
|
4075
4075
|
t.style?.alternateColor && (this.path(e, t), e.stroke({
|
|
4076
4076
|
width: i,
|
|
4077
|
-
color:
|
|
4077
|
+
color: nr(t.style.alternateColor),
|
|
4078
4078
|
alpha: a
|
|
4079
4079
|
})), this.dashedStrokeShape(e, t, i, r, a, o);
|
|
4080
4080
|
return;
|
|
@@ -4093,11 +4093,11 @@ var rr = class {
|
|
|
4093
4093
|
});
|
|
4094
4094
|
}
|
|
4095
4095
|
shapesIntersecting(e) {
|
|
4096
|
-
return
|
|
4096
|
+
return Un(this.shapes, e);
|
|
4097
4097
|
}
|
|
4098
4098
|
shapesAt(e) {
|
|
4099
4099
|
return this.shapes.filter((t) => {
|
|
4100
|
-
let n =
|
|
4100
|
+
let n = L(t.points);
|
|
4101
4101
|
return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
|
|
4102
4102
|
}).map((e) => e.id);
|
|
4103
4103
|
}
|
|
@@ -4130,16 +4130,16 @@ var rr = class {
|
|
|
4130
4130
|
}, a = this.strokeW(i);
|
|
4131
4131
|
r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
|
|
4132
4132
|
width: a,
|
|
4133
|
-
color:
|
|
4133
|
+
color: nr(r.alternateColor)
|
|
4134
4134
|
}));
|
|
4135
4135
|
let o = this.dashForShape(i);
|
|
4136
4136
|
if (o) {
|
|
4137
|
-
this.dashedStrokeShape(this.previewG, i, a,
|
|
4137
|
+
this.dashedStrokeShape(this.previewG, i, a, nr(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
|
|
4138
4138
|
return;
|
|
4139
4139
|
}
|
|
4140
4140
|
this.path(this.previewG, i), this.previewG.stroke({
|
|
4141
4141
|
width: a,
|
|
4142
|
-
color:
|
|
4142
|
+
color: nr(r.color ?? "#00e5ff"),
|
|
4143
4143
|
alpha: r.opacity ?? 1
|
|
4144
4144
|
});
|
|
4145
4145
|
}
|
|
@@ -4161,12 +4161,12 @@ var rr = class {
|
|
|
4161
4161
|
}, c = this.strokeW(s);
|
|
4162
4162
|
n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
|
|
4163
4163
|
width: c,
|
|
4164
|
-
color:
|
|
4164
|
+
color: nr(n.alternateColor)
|
|
4165
4165
|
}));
|
|
4166
4166
|
let l = this.dashForShape(s);
|
|
4167
|
-
if (l ? this.dashedStrokeShape(this.previewG, s, c,
|
|
4167
|
+
if (l ? this.dashedStrokeShape(this.previewG, s, c, nr(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
|
|
4168
4168
|
width: c,
|
|
4169
|
-
color:
|
|
4169
|
+
color: nr(n.color ?? "#00e5ff"),
|
|
4170
4170
|
alpha: n.opacity ?? 1
|
|
4171
4171
|
})), !a) return;
|
|
4172
4172
|
let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
|
|
@@ -4180,15 +4180,15 @@ var rr = class {
|
|
|
4180
4180
|
}
|
|
4181
4181
|
previewScalarMask(e, t) {
|
|
4182
4182
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
4183
|
-
let n =
|
|
4183
|
+
let n = sn(e, t.length === 7 ? `${t}99` : t);
|
|
4184
4184
|
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = M.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new j(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;
|
|
4185
4185
|
}
|
|
4186
4186
|
previewMarquee(e, t) {
|
|
4187
4187
|
this.ensurePreview(), this.marqueeG.clear();
|
|
4188
|
-
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o =
|
|
4188
|
+
let n = Math.min(e.x, t.x), r = Math.min(e.y, t.y), i = Math.abs(t.x - e.x), a = Math.abs(t.y - e.y), o = nr(Ne);
|
|
4189
4189
|
this.marqueeG.rect(n, r, i, a).fill({
|
|
4190
4190
|
color: o,
|
|
4191
|
-
alpha:
|
|
4191
|
+
alpha: K
|
|
4192
4192
|
}).stroke({
|
|
4193
4193
|
width: 1 / this.world.scale.x,
|
|
4194
4194
|
color: o
|
|
@@ -4219,8 +4219,8 @@ var rr = class {
|
|
|
4219
4219
|
o.y
|
|
4220
4220
|
], !1).stroke({
|
|
4221
4221
|
width: i,
|
|
4222
|
-
color:
|
|
4223
|
-
}), this.strokeDashedPolyline(e, [n, o], !1, i,
|
|
4222
|
+
color: nr(r.underlayColor)
|
|
4223
|
+
}), this.strokeDashedPolyline(e, [n, o], !1, i, nr(r.color), r.opacity, a);
|
|
4224
4224
|
};
|
|
4225
4225
|
r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
|
|
4226
4226
|
}
|
|
@@ -4231,12 +4231,12 @@ var rr = class {
|
|
|
4231
4231
|
return;
|
|
4232
4232
|
}
|
|
4233
4233
|
if (n === N.RECTANGLE) {
|
|
4234
|
-
let t =
|
|
4234
|
+
let t = L(r);
|
|
4235
4235
|
e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
|
|
4236
4236
|
return;
|
|
4237
4237
|
}
|
|
4238
4238
|
if (n === N.ELLIPSE) {
|
|
4239
|
-
let t =
|
|
4239
|
+
let t = L(r);
|
|
4240
4240
|
e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
|
|
4241
4241
|
return;
|
|
4242
4242
|
}
|
|
@@ -4246,7 +4246,7 @@ var rr = class {
|
|
|
4246
4246
|
dashedStrokeShape(e, t, n, r, i, a) {
|
|
4247
4247
|
let { type: o, points: s } = t;
|
|
4248
4248
|
if (o === N.RECTANGLE) {
|
|
4249
|
-
let t =
|
|
4249
|
+
let t = L(s);
|
|
4250
4250
|
this.strokeDashedPolyline(e, [
|
|
4251
4251
|
{
|
|
4252
4252
|
x: t.minX,
|
|
@@ -4268,7 +4268,7 @@ var rr = class {
|
|
|
4268
4268
|
return;
|
|
4269
4269
|
}
|
|
4270
4270
|
if (o === N.ELLIPSE) {
|
|
4271
|
-
let t =
|
|
4271
|
+
let t = L(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) => {
|
|
4272
4272
|
let n = t / 96 * Math.PI * 2;
|
|
4273
4273
|
return {
|
|
4274
4274
|
x: o + Math.cos(n) * l,
|
|
@@ -4303,7 +4303,7 @@ var rr = class {
|
|
|
4303
4303
|
}
|
|
4304
4304
|
drawSelectionBorders() {
|
|
4305
4305
|
this.selLayer.position.set(0, 0);
|
|
4306
|
-
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) &&
|
|
4306
|
+
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && F(t)) : [];
|
|
4307
4307
|
if (this.selectionBorderGfx.length !== t.length) {
|
|
4308
4308
|
for (let e of this.selectionBorderGfx) e.destroy();
|
|
4309
4309
|
this.selectionBorderGfx = t.map(() => {
|
|
@@ -4316,23 +4316,23 @@ var rr = class {
|
|
|
4316
4316
|
let r = this.selectionBorderGfx[t];
|
|
4317
4317
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4318
4318
|
width: n,
|
|
4319
|
-
color:
|
|
4319
|
+
color: tr
|
|
4320
4320
|
});
|
|
4321
4321
|
});
|
|
4322
4322
|
}
|
|
4323
4323
|
updateSelectionBordersLive(e) {
|
|
4324
4324
|
let t = new Set(this.selected), n = 1.5 / this.world.scale.x, r = 0;
|
|
4325
4325
|
for (let i of this.shapes) {
|
|
4326
|
-
if (!t.has(i.id) || !
|
|
4326
|
+
if (!t.has(i.id) || !F(i)) continue;
|
|
4327
4327
|
let a = this.selectionBorderGfx[r++];
|
|
4328
4328
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4329
4329
|
width: n,
|
|
4330
|
-
color:
|
|
4330
|
+
color: tr
|
|
4331
4331
|
}));
|
|
4332
4332
|
}
|
|
4333
4333
|
}
|
|
4334
4334
|
selectionOutlinePoints(e, t) {
|
|
4335
|
-
return
|
|
4335
|
+
return Kn(e, t, this.pointRadius(e));
|
|
4336
4336
|
}
|
|
4337
4337
|
imgToScreen(e) {
|
|
4338
4338
|
let t = this.world.toGlobal({
|
|
@@ -4346,7 +4346,7 @@ var rr = class {
|
|
|
4346
4346
|
}
|
|
4347
4347
|
setTransformerOutline(e) {
|
|
4348
4348
|
let t = e.maxX - e.minX, n = e.maxY - e.minY;
|
|
4349
|
-
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(
|
|
4349
|
+
t <= 0 && n <= 0 || this.setTransformerOutlinePoints(z([{
|
|
4350
4350
|
x: e.minX,
|
|
4351
4351
|
y: e.minY
|
|
4352
4352
|
}, {
|
|
@@ -4361,10 +4361,10 @@ var rr = class {
|
|
|
4361
4361
|
}));
|
|
4362
4362
|
}
|
|
4363
4363
|
rotationHandleGap() {
|
|
4364
|
-
return
|
|
4364
|
+
return qn(this.viewport.scale);
|
|
4365
4365
|
}
|
|
4366
4366
|
rotationHandleScreenPoint(e) {
|
|
4367
|
-
return this.imgToScreen(
|
|
4367
|
+
return this.imgToScreen(he(e, this.rotationHandleGap()));
|
|
4368
4368
|
}
|
|
4369
4369
|
setRotationConnector(e) {
|
|
4370
4370
|
let t = this.imgToScreen(pe(e[0], e[1])), n = this.rotationHandleScreenPoint(e);
|
|
@@ -4377,7 +4377,7 @@ var rr = class {
|
|
|
4377
4377
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4378
4378
|
}
|
|
4379
4379
|
orientedHandleAngle(e) {
|
|
4380
|
-
return
|
|
4380
|
+
return Jn(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4381
4381
|
}
|
|
4382
4382
|
drawTransformer() {
|
|
4383
4383
|
if (this.activeDrag) return;
|
|
@@ -4385,25 +4385,25 @@ var rr = class {
|
|
|
4385
4385
|
for (let e of this.vertexNodes) e.destroy();
|
|
4386
4386
|
for (let e of this.midNodes) e.destroy();
|
|
4387
4387
|
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;
|
|
4388
|
-
let e =
|
|
4388
|
+
let e = $(this.shapes, this.selected);
|
|
4389
4389
|
if (e.length === 0 || e.length === 1 && e[0].type === N.POINT) return;
|
|
4390
|
-
let t = e.length === 1 && (e[0].type === N.POLYGON || e[0].type === N.LINE) && this.editingId === e[0].id ? e[0] : null, n =
|
|
4390
|
+
let t = e.length === 1 && (e[0].type === N.POLYGON || e[0].type === N.LINE) && this.editingId === e[0].id ? e[0] : null, n = L(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === N.ROTATED_RECTANGLE ? e[0] : null, i = r ? H(r.points) : I.map((e) => ae(e, n));
|
|
4391
4391
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
4392
4392
|
let a = r ? this.orientedHandleAngle(r.points) : 0;
|
|
4393
|
-
for (let e of t ? [] :
|
|
4394
|
-
let t = this.imgToScreen(i[
|
|
4393
|
+
for (let e of t ? [] : I) {
|
|
4394
|
+
let t = this.imgToScreen(i[I.indexOf(e)]), n = new O();
|
|
4395
4395
|
n.rect(-4, -4, 8, 8).fill({ color: 16777215 }).stroke({
|
|
4396
4396
|
width: 1,
|
|
4397
4397
|
color: 2001125
|
|
4398
4398
|
}), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
|
|
4399
|
-
let r =
|
|
4399
|
+
let r = gt(e, a);
|
|
4400
4400
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4401
4401
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4402
|
-
let n =
|
|
4402
|
+
let n = $(this.shapes, this.selected);
|
|
4403
4403
|
this.activeDrag = {
|
|
4404
4404
|
kind: "resize",
|
|
4405
4405
|
anchor: e,
|
|
4406
|
-
box:
|
|
4406
|
+
box: L(n.flatMap((e) => e.points)),
|
|
4407
4407
|
shapes: n.map((e) => ({
|
|
4408
4408
|
id: e.id,
|
|
4409
4409
|
points: e.points
|
|
@@ -4500,14 +4500,14 @@ var rr = class {
|
|
|
4500
4500
|
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 === N.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4501
4501
|
}
|
|
4502
4502
|
repositionHandlesForBox(e) {
|
|
4503
|
-
|
|
4504
|
-
let r = this.imgToScreen(
|
|
4503
|
+
I.forEach((t, n) => {
|
|
4504
|
+
let r = this.imgToScreen(ae(t, e)), i = this.handleNodes[n];
|
|
4505
4505
|
i && this.layoutResizeHandle(i, r, 0);
|
|
4506
4506
|
}), this.setTransformerOutline(e);
|
|
4507
4507
|
}
|
|
4508
4508
|
repositionOrientedHandles(e) {
|
|
4509
4509
|
let t = this.orientedHandleAngle(e);
|
|
4510
|
-
if (
|
|
4510
|
+
if (H(e).forEach((e, n) => {
|
|
4511
4511
|
let r = this.imgToScreen(e), i = this.handleNodes[n];
|
|
4512
4512
|
i && this.layoutResizeHandle(i, r, t);
|
|
4513
4513
|
}), this.setTransformerOutlinePoints(e), this.rotNode) {
|
|
@@ -4564,7 +4564,7 @@ var rr = class {
|
|
|
4564
4564
|
let t = this.activeDrag;
|
|
4565
4565
|
if (!t) return;
|
|
4566
4566
|
this.applyCursor();
|
|
4567
|
-
let n =
|
|
4567
|
+
let n = Rn(this.shapes, t), { updates: r, box: i } = zn(t, e, n);
|
|
4568
4568
|
if (t.kind === "move") {
|
|
4569
4569
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4570
4570
|
for (let e of t.shapes) {
|
|
@@ -4596,13 +4596,21 @@ var rr = class {
|
|
|
4596
4596
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4597
4597
|
return;
|
|
4598
4598
|
}
|
|
4599
|
-
let { updates: n } =
|
|
4599
|
+
let { updates: n } = zn(e, t, Rn(this.shapes, e));
|
|
4600
4600
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
4601
4601
|
}
|
|
4602
4602
|
};
|
|
4603
4603
|
//#endregion
|
|
4604
4604
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
4605
|
-
function ir({
|
|
4605
|
+
function ir({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
|
|
4606
|
+
if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
|
|
4607
|
+
let i = e !== t;
|
|
4608
|
+
return !i && n === r ? { kind: "none" } : {
|
|
4609
|
+
kind: "load",
|
|
4610
|
+
docChange: i
|
|
4611
|
+
};
|
|
4612
|
+
}
|
|
4613
|
+
function ar({ 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, maskCanvasRef: m, regionOverlayRef: h, dimmedRef: g, syncMinimap: _, setImage: v, setImageVisible: b, setReady: x, setImageStatus: S, onContextMenuRequest: C }) {
|
|
4606
4614
|
let w = y(i);
|
|
4607
4615
|
w.current = i;
|
|
4608
4616
|
let T = y(r);
|
|
@@ -4613,7 +4621,7 @@ function ir({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4613
4621
|
j.current = C, p(() => {
|
|
4614
4622
|
let r = t.current;
|
|
4615
4623
|
if (!r) return;
|
|
4616
|
-
let i = !1, a = null, p = null, y = A.current(), S = e === "konva" ? new
|
|
4624
|
+
let i = !1, a = null, p = null, y = A.current(), S = e === "konva" ? new Qn(r, y) : new rr(r, y);
|
|
4617
4625
|
return n.current = S, (async () => {
|
|
4618
4626
|
if (await S.init(), i) return;
|
|
4619
4627
|
if (S.setFilter(o.current.brightness, o.current.contrast), S.setStrokeSize(o.current.strokeSize), S.setImageSmoothing(o.current.imageSmoothing), S.setTransformEnabled(!s.current), O.current = !0, w.current) {
|
|
@@ -4644,7 +4652,7 @@ function ir({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4644
4652
|
}
|
|
4645
4653
|
S.zoomAt(t.clientX - n.left, t.clientY - n.top, e(t.deltaY, r));
|
|
4646
4654
|
}, S.dom.addEventListener("wheel", a, { passive: !1 }), p = (e) => {
|
|
4647
|
-
if (e.preventDefault(), c.current ===
|
|
4655
|
+
if (e.preventDefault(), c.current === W.ASSISTANT_POINT && e.altKey) return;
|
|
4648
4656
|
let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a = S.viewport;
|
|
4649
4657
|
j.current({
|
|
4650
4658
|
x: n,
|
|
@@ -4664,19 +4672,25 @@ function ir({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4664
4672
|
}, [e]), p(() => {
|
|
4665
4673
|
let e = n.current;
|
|
4666
4674
|
if (!e || !O.current) return;
|
|
4667
|
-
let t =
|
|
4675
|
+
let t = ir({
|
|
4676
|
+
currentDocId: D.current,
|
|
4677
|
+
documentId: r,
|
|
4678
|
+
loadedUrl: E.current,
|
|
4679
|
+
renderedImageUrl: i
|
|
4680
|
+
});
|
|
4681
|
+
if (t.kind === "none") return;
|
|
4682
|
+
let a = () => {
|
|
4668
4683
|
x(!1), b(!1), e.clearImage(), e.setShapes([], []), e.setOverlays(null, null, !1);
|
|
4669
4684
|
};
|
|
4670
|
-
if (
|
|
4671
|
-
|
|
4685
|
+
if (t.kind === "clear") {
|
|
4686
|
+
E.current = null, D.current = null, a();
|
|
4672
4687
|
return;
|
|
4673
4688
|
}
|
|
4674
|
-
if (!t && E.current === i) return;
|
|
4675
4689
|
let s = i;
|
|
4676
|
-
t && a();
|
|
4690
|
+
t.docChange && (D.current = null, a());
|
|
4677
4691
|
let c = !1;
|
|
4678
4692
|
return (async () => {
|
|
4679
|
-
await e.setImage(s, u.current, d.current), !(c || n.current !== e) && (E.current = s, t && (D.current = r, v({
|
|
4693
|
+
await e.setImage(s, u.current, d.current), !(c || n.current !== e) && (E.current = s, t.docChange && (D.current = r, v({
|
|
4680
4694
|
w: e.imageWidth,
|
|
4681
4695
|
h: e.imageHeight
|
|
4682
4696
|
}), b(!0), e.setShapes(l.current, f.current), e.setOverlays(o.current.showGuide ? m.current : null, o.current.showRegionMask ? h.current : null, g.current), o.current.keepZoomOnImageChange || e.fit(), _(), x(!0)));
|
|
@@ -4702,19 +4716,19 @@ function ir({ backend: e, hostRef: t, engineRef: n, imageUrl: r, renderedImageUr
|
|
|
4702
4716
|
}
|
|
4703
4717
|
//#endregion
|
|
4704
4718
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
4705
|
-
var
|
|
4706
|
-
function
|
|
4719
|
+
var or = .05, sr = 20;
|
|
4720
|
+
function cr(e) {
|
|
4707
4721
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
4708
4722
|
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);
|
|
4709
4723
|
}
|
|
4710
|
-
function
|
|
4724
|
+
function lr(e) {
|
|
4711
4725
|
let t = e.currentTarget.getBoundingClientRect();
|
|
4712
4726
|
return {
|
|
4713
4727
|
x: e.clientX - t.left,
|
|
4714
4728
|
y: e.clientY - t.top
|
|
4715
4729
|
};
|
|
4716
4730
|
}
|
|
4717
|
-
function
|
|
4731
|
+
function ur({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
4718
4732
|
let i = y(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 = f(() => {
|
|
4719
4733
|
let t = e.current;
|
|
4720
4734
|
if (!t) return null;
|
|
@@ -4752,7 +4766,7 @@ function lr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4752
4766
|
let n = e.current, r = d();
|
|
4753
4767
|
if (!n || !r) return;
|
|
4754
4768
|
t.preventDefault(), t.stopPropagation();
|
|
4755
|
-
let a =
|
|
4769
|
+
let a = lr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
|
|
4756
4770
|
offsetX: a.x - r.x,
|
|
4757
4771
|
offsetY: a.y - r.y
|
|
4758
4772
|
} : {
|
|
@@ -4769,7 +4783,7 @@ function lr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4769
4783
|
d
|
|
4770
4784
|
]), h = f((t) => {
|
|
4771
4785
|
let n = i.current, r = e.current;
|
|
4772
|
-
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), p(
|
|
4786
|
+
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), p(lr(t), r.viewport.scale, n));
|
|
4773
4787
|
}, [p, e]), g = f((e) => {
|
|
4774
4788
|
let t = i.current;
|
|
4775
4789
|
!t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
|
|
@@ -4777,8 +4791,8 @@ function lr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4777
4791
|
let r = e.current;
|
|
4778
4792
|
if (!r || !n) return;
|
|
4779
4793
|
t.preventDefault(), t.stopPropagation();
|
|
4780
|
-
let i =
|
|
4781
|
-
p(
|
|
4794
|
+
let i = cr(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(or, Math.min(sr, s));
|
|
4795
|
+
p(lr(t), c);
|
|
4782
4796
|
}, [
|
|
4783
4797
|
p,
|
|
4784
4798
|
e,
|
|
@@ -4815,14 +4829,14 @@ function lr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
4815
4829
|
}
|
|
4816
4830
|
//#endregion
|
|
4817
4831
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
4818
|
-
function
|
|
4832
|
+
function dr(e, t, n) {
|
|
4819
4833
|
if (!(!e || !n.length)) {
|
|
4820
4834
|
if (t.type === N.POINT) {
|
|
4821
4835
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
4822
4836
|
return;
|
|
4823
4837
|
}
|
|
4824
4838
|
if (t.type === N.RECTANGLE || t.type === N.ELLIPSE) {
|
|
4825
|
-
let r =
|
|
4839
|
+
let r = L(n);
|
|
4826
4840
|
if (t.type === N.ELLIPSE) {
|
|
4827
4841
|
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));
|
|
4828
4842
|
return;
|
|
@@ -4833,7 +4847,7 @@ function ur(e, t, n) {
|
|
|
4833
4847
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
4834
4848
|
}
|
|
4835
4849
|
}
|
|
4836
|
-
function
|
|
4850
|
+
function fr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
4837
4851
|
let s = y(/* @__PURE__ */ new Map());
|
|
4838
4852
|
return {
|
|
4839
4853
|
registerMinimapShape: f((e, t) => {
|
|
@@ -4842,13 +4856,13 @@ function dr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4842
4856
|
applyMinimapPreview: f((e) => {
|
|
4843
4857
|
let n = t.current.getShapes();
|
|
4844
4858
|
if (!e.length) {
|
|
4845
|
-
for (let e of n)
|
|
4859
|
+
for (let e of n) dr(s.current.get(e.id), e, e.points);
|
|
4846
4860
|
return;
|
|
4847
4861
|
}
|
|
4848
4862
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
4849
4863
|
for (let t of e) {
|
|
4850
4864
|
let e = r.get(t.id);
|
|
4851
|
-
e &&
|
|
4865
|
+
e && dr(s.current.get(e.id), e, t.points);
|
|
4852
4866
|
}
|
|
4853
4867
|
}, [t]),
|
|
4854
4868
|
syncMinimap: f(() => {
|
|
@@ -4877,15 +4891,15 @@ function dr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
4877
4891
|
}
|
|
4878
4892
|
//#endregion
|
|
4879
4893
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
4880
|
-
var
|
|
4881
|
-
function
|
|
4894
|
+
var pr = 12;
|
|
4895
|
+
function mr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
4882
4896
|
let s = y(0), c = y(!0), l = y(n), u = y(a), d = y(o);
|
|
4883
4897
|
l.current = n, u.current = a, d.current = o, p(() => (c.current = !0, () => {
|
|
4884
4898
|
c.current = !1;
|
|
4885
4899
|
}), []), p(() => {
|
|
4886
4900
|
s.current = 0;
|
|
4887
4901
|
}, [a]);
|
|
4888
|
-
let m = f(() => r(e.getShapes().filter((e) =>
|
|
4902
|
+
let m = f(() => r(e.getShapes().filter((e) => F(e)).map((e) => e.id)), [e, r]), h = f(() => r([]), [r]), g = f(() => e.getShapes().filter((e) => t.current.includes(e.id) && te(e)), [e, t]), _ = f(() => {
|
|
4889
4903
|
if (n || !t.current.length) return;
|
|
4890
4904
|
let i = g().map((e) => e.id);
|
|
4891
4905
|
i.length && (e.remove(i), r([]));
|
|
@@ -4897,7 +4911,7 @@ function pr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4897
4911
|
t
|
|
4898
4912
|
]), v = f(() => {
|
|
4899
4913
|
let e = g();
|
|
4900
|
-
e.length && (s.current = 0,
|
|
4914
|
+
e.length && (s.current = 0, ut(st(e, a, o)));
|
|
4901
4915
|
}, [
|
|
4902
4916
|
a,
|
|
4903
4917
|
o,
|
|
@@ -4909,15 +4923,15 @@ function pr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4909
4923
|
if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
|
|
4910
4924
|
let f, p, m = n.shapes.flatMap((e) => e.points);
|
|
4911
4925
|
if (t && m.length) {
|
|
4912
|
-
let e =
|
|
4926
|
+
let e = L(m);
|
|
4913
4927
|
f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
|
|
4914
4928
|
} else {
|
|
4915
|
-
let e = !!n.documentId && n.documentId !== a, t = pt(s.current, e,
|
|
4929
|
+
let e = !!n.documentId && n.documentId !== a, t = pt(s.current, e, pr);
|
|
4916
4930
|
f = t.offset, s.current = t.nextPasteCount, p = f;
|
|
4917
4931
|
}
|
|
4918
4932
|
let h = n.shapes.map((e) => ({
|
|
4919
4933
|
...e,
|
|
4920
|
-
id:
|
|
4934
|
+
id: ie(),
|
|
4921
4935
|
points: e.points.map((e) => ({
|
|
4922
4936
|
x: e.x + f,
|
|
4923
4937
|
y: e.y + p
|
|
@@ -4935,10 +4949,10 @@ function pr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4935
4949
|
if (n || !t.current.length) return;
|
|
4936
4950
|
let i = g().map((e) => ({
|
|
4937
4951
|
...e,
|
|
4938
|
-
id:
|
|
4952
|
+
id: ie(),
|
|
4939
4953
|
points: e.points.map((e) => ({
|
|
4940
|
-
x: e.x +
|
|
4941
|
-
y: e.y +
|
|
4954
|
+
x: e.x + pr,
|
|
4955
|
+
y: e.y + pr
|
|
4942
4956
|
}))
|
|
4943
4957
|
}));
|
|
4944
4958
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -4966,7 +4980,7 @@ function pr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4966
4980
|
g
|
|
4967
4981
|
]), T = f((r, i) => {
|
|
4968
4982
|
if (n || !t.current.length) return;
|
|
4969
|
-
let a = e.getShapes().filter((e) => t.current.includes(e.id) &&
|
|
4983
|
+
let a = e.getShapes().filter((e) => t.current.includes(e.id) && te(e));
|
|
4970
4984
|
a.length && e.update(a.map((e) => ({
|
|
4971
4985
|
...e,
|
|
4972
4986
|
points: e.points.map((e) => ({
|
|
@@ -4996,12 +5010,12 @@ function pr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
4996
5010
|
if (n) return;
|
|
4997
5011
|
let t = E();
|
|
4998
5012
|
if (t.length < 2 || i && !i(t)) return;
|
|
4999
|
-
let a =
|
|
5013
|
+
let a = an([], 1, rn(t));
|
|
5000
5014
|
if (!a) return;
|
|
5001
|
-
let o =
|
|
5015
|
+
let o = on(a, 1);
|
|
5002
5016
|
if (!o.length) return;
|
|
5003
5017
|
let s = t[0], c = o.map((e) => ({
|
|
5004
|
-
id:
|
|
5018
|
+
id: ie(),
|
|
5005
5019
|
type: N.POLYGON,
|
|
5006
5020
|
points: e,
|
|
5007
5021
|
style: s.style,
|
|
@@ -5019,12 +5033,12 @@ function pr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5019
5033
|
}
|
|
5020
5034
|
//#endregion
|
|
5021
5035
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
5022
|
-
function
|
|
5036
|
+
function hr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
5023
5037
|
let o = y(null), s = y(null), c = f(() => {
|
|
5024
5038
|
o.current?.(), o.current = null;
|
|
5025
5039
|
}, []), l = f((t, n = r) => {
|
|
5026
5040
|
let i = e.current;
|
|
5027
|
-
i && (c(), o.current =
|
|
5041
|
+
i && (c(), o.current = Vt(i.viewport, t, (e) => i.applyViewport(e), n));
|
|
5028
5042
|
}, [
|
|
5029
5043
|
c,
|
|
5030
5044
|
r,
|
|
@@ -5032,14 +5046,14 @@ function mr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5032
5046
|
]), u = f((t, n = r) => {
|
|
5033
5047
|
let i = e.current;
|
|
5034
5048
|
if (!i) return;
|
|
5035
|
-
let a =
|
|
5049
|
+
let a = zt(t, i.screenSize.w, i.screenSize.h);
|
|
5036
5050
|
a && l(a, n);
|
|
5037
5051
|
}, [
|
|
5038
5052
|
l,
|
|
5039
5053
|
r,
|
|
5040
5054
|
e
|
|
5041
5055
|
]), d = f((e, n = r) => {
|
|
5042
|
-
let i =
|
|
5056
|
+
let i = Rt(t.getShapes().filter((t) => e.includes(t.id)));
|
|
5043
5057
|
i && u(i, n);
|
|
5044
5058
|
}, [
|
|
5045
5059
|
t,
|
|
@@ -5050,7 +5064,7 @@ function mr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5050
5064
|
if (!r.length) return;
|
|
5051
5065
|
let i = e.current;
|
|
5052
5066
|
if (!i) return;
|
|
5053
|
-
let a =
|
|
5067
|
+
let a = Bt(L(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
5054
5068
|
a && l(a);
|
|
5055
5069
|
}, [
|
|
5056
5070
|
t,
|
|
@@ -5091,123 +5105,123 @@ function mr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5091
5105
|
}
|
|
5092
5106
|
//#endregion
|
|
5093
5107
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
5094
|
-
var
|
|
5108
|
+
var gr = 180, _r = "__draft_preview__", vr = new Set([
|
|
5095
5109
|
"copy",
|
|
5096
5110
|
"selectAll",
|
|
5097
5111
|
"clearSelection",
|
|
5098
5112
|
"zoomToSelection"
|
|
5099
5113
|
]);
|
|
5100
|
-
function
|
|
5114
|
+
function yr(e, t) {
|
|
5101
5115
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5102
5116
|
}
|
|
5103
|
-
function
|
|
5104
|
-
let
|
|
5117
|
+
function br({ document: t, clipboardScope: n, renderImageState: r, dimmed: i = !1, selectedIds: a, activeTool: o, draftStyle: s, draftMeta: c, readOnly: l, disableMarquee: u, locked: d, onLockedInteraction: v, onIdleEscape: x, overrideShapeInteraction: w, defaultViewSettings: T, viewSettings: E, onViewSettingsChange: D, showMinimap: O = !0, showViewSettings: k = !0, getContextMenuItems: A, strings: j, canMergeSelection: M, brushSize: ee = 20, zoomBound: ne, zoomAnimationDuration: re = 300, decorationShapes: I, regionMask: L, guideMask: ae, maskPalette: oe, overlayMarkers: R, renderOverlayMarker: se, onOverlayMarkerClick: z, renderImageOverlay: ce, getSelectionLabel: le, hideSelectionLabelDot: B, formatSelectionInfo: V, externalTools: ue, assistant: de, keymap: fe, handleRef: pe, backend: me = "pixi", onActiveToolChange: H, onSelectionChange: he, onEditingChange: ge, onShapesCreated: _e, onShapesUpdated: ve, onShapesDeleted: ye, onDrawSessionChange: be, onDraftShapeChange: xe, onViewportChange: Se, onShapesTransformPreview: U }) {
|
|
5118
|
+
let Te = y(null), G = y(null), Ee = y(null), De = y(null), ke = y(null), Ne = `${m()}-minimap`, [K, Pe] = b(null), [Fe, Ie] = b(!1), [q, Le] = b(!1), [Re, ze] = b(null), [Be, Ve] = b({
|
|
5105
5119
|
active: !1,
|
|
5106
5120
|
kind: "none",
|
|
5107
5121
|
canUndo: !1,
|
|
5108
5122
|
canRedo: !1
|
|
5109
|
-
}), [
|
|
5110
|
-
onShapesCreated:
|
|
5111
|
-
onShapesUpdated:
|
|
5112
|
-
onShapesDeleted:
|
|
5113
|
-
}), [
|
|
5123
|
+
}), [He, We] = b(!0), [Ge, Ke] = b(!1), qe = t?.id ?? "", Je = t?.imageUrl ?? "", Qe = t?.displayImageUrl, et = t?.coordinateSize, tt = t?.initialShapes, nt = t?.initialSelectedIds, rt = Qe ?? Je, [it, at] = b("loading"), J = _n({
|
|
5124
|
+
onShapesCreated: _e,
|
|
5125
|
+
onShapesUpdated: ve,
|
|
5126
|
+
onShapesDeleted: ye
|
|
5127
|
+
}), [ot, st] = b([]), Y = a ?? ot, lt = a !== void 0, ut = _(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), dt = y(ut);
|
|
5114
5128
|
g(() => {
|
|
5115
|
-
|
|
5116
|
-
}, [
|
|
5117
|
-
let
|
|
5118
|
-
|
|
5119
|
-
let [
|
|
5120
|
-
let e = Object.fromEntries(Object.entries(
|
|
5129
|
+
dt.current = ut;
|
|
5130
|
+
}, [ut]);
|
|
5131
|
+
let ft = y(Be);
|
|
5132
|
+
ft.current = Be;
|
|
5133
|
+
let [X, pt] = b(() => {
|
|
5134
|
+
let e = Object.fromEntries(Object.entries(T ?? {}).filter(([, e]) => e !== void 0));
|
|
5121
5135
|
return {
|
|
5122
|
-
...
|
|
5136
|
+
...we,
|
|
5123
5137
|
...e
|
|
5124
5138
|
};
|
|
5125
|
-
}),
|
|
5139
|
+
}), mt = f((e) => pt((t) => ({
|
|
5126
5140
|
...t,
|
|
5127
5141
|
...e
|
|
5128
|
-
})), []),
|
|
5142
|
+
})), []), Z = _(() => Ce(j), [j]);
|
|
5129
5143
|
p(() => {
|
|
5130
|
-
|
|
5131
|
-
let t = Object.entries(
|
|
5144
|
+
E && pt((e) => {
|
|
5145
|
+
let t = Object.entries(E).filter(([t, n]) => n !== void 0 && e[t] !== n);
|
|
5132
5146
|
return t.length ? {
|
|
5133
5147
|
...e,
|
|
5134
5148
|
...Object.fromEntries(t)
|
|
5135
5149
|
} : e;
|
|
5136
5150
|
});
|
|
5137
|
-
}, [
|
|
5138
|
-
let
|
|
5139
|
-
|
|
5140
|
-
let
|
|
5151
|
+
}, [E]);
|
|
5152
|
+
let ht = y(D);
|
|
5153
|
+
ht.current = D;
|
|
5154
|
+
let gt = y(!1);
|
|
5141
5155
|
p(() => {
|
|
5142
|
-
if (!
|
|
5143
|
-
|
|
5156
|
+
if (!gt.current) {
|
|
5157
|
+
gt.current = !0;
|
|
5144
5158
|
return;
|
|
5145
5159
|
}
|
|
5146
|
-
|
|
5147
|
-
}, [
|
|
5148
|
-
let
|
|
5149
|
-
|
|
5150
|
-
let
|
|
5151
|
-
|
|
5152
|
-
let
|
|
5153
|
-
|
|
5154
|
-
let
|
|
5155
|
-
|
|
5156
|
-
let
|
|
5157
|
-
|
|
5158
|
-
let
|
|
5159
|
-
|
|
5160
|
-
let
|
|
5160
|
+
ht.current?.(X);
|
|
5161
|
+
}, [X]);
|
|
5162
|
+
let _t = _(() => !ae || !oe ? null : xt(ae, oe), [ae, oe]), yt = _(() => _t?.toDataURL() ?? null, [_t]), bt = _(() => !K || !L ? null : Nt(L, K.w, K.h), [K, L]), St = y(_t);
|
|
5163
|
+
St.current = _t;
|
|
5164
|
+
let Ct = y(bt);
|
|
5165
|
+
Ct.current = bt;
|
|
5166
|
+
let wt = y(i);
|
|
5167
|
+
wt.current = i;
|
|
5168
|
+
let Tt = y(K);
|
|
5169
|
+
Tt.current = K;
|
|
5170
|
+
let Et = y(et);
|
|
5171
|
+
Et.current = et;
|
|
5172
|
+
let Dt = y(et?.imageSize);
|
|
5173
|
+
Dt.current = et?.imageSize;
|
|
5174
|
+
let Ot = y(Y);
|
|
5161
5175
|
g(() => {
|
|
5162
|
-
|
|
5163
|
-
}, [
|
|
5164
|
-
let
|
|
5165
|
-
|
|
5166
|
-
let
|
|
5167
|
-
|
|
5168
|
-
let
|
|
5169
|
-
|
|
5170
|
-
let
|
|
5171
|
-
|
|
5172
|
-
let
|
|
5173
|
-
|
|
5174
|
-
let
|
|
5175
|
-
|
|
5176
|
-
let
|
|
5177
|
-
|
|
5178
|
-
let
|
|
5179
|
-
|
|
5180
|
-
let
|
|
5181
|
-
|
|
5182
|
-
let
|
|
5183
|
-
|
|
5184
|
-
let
|
|
5185
|
-
|
|
5186
|
-
let
|
|
5187
|
-
let e =
|
|
5176
|
+
Ot.current = Y;
|
|
5177
|
+
}, [Y]);
|
|
5178
|
+
let kt = y(o);
|
|
5179
|
+
kt.current = o;
|
|
5180
|
+
let At = y(s);
|
|
5181
|
+
At.current = s;
|
|
5182
|
+
let jt = y(c);
|
|
5183
|
+
jt.current = c;
|
|
5184
|
+
let Mt = y(ee);
|
|
5185
|
+
Mt.current = ee;
|
|
5186
|
+
let Pt = y(X.simplifyStrength);
|
|
5187
|
+
Pt.current = X.simplifyStrength;
|
|
5188
|
+
let Q = !!l || !!d, Ft = y(Q);
|
|
5189
|
+
Ft.current = Q;
|
|
5190
|
+
let It = y(u);
|
|
5191
|
+
It.current = u;
|
|
5192
|
+
let Lt = y(d);
|
|
5193
|
+
Lt.current = d;
|
|
5194
|
+
let Rt = y(v);
|
|
5195
|
+
Rt.current = v;
|
|
5196
|
+
let zt = y(w);
|
|
5197
|
+
zt.current = w;
|
|
5198
|
+
let Bt = y(J);
|
|
5199
|
+
Bt.current = J;
|
|
5200
|
+
let Vt = y(!1), Wt = y(!1), Gt = y("idle"), Kt = y(null), qt = f(() => {
|
|
5201
|
+
let e = G.current;
|
|
5188
5202
|
if (!e) return;
|
|
5189
|
-
let t =
|
|
5190
|
-
e.setCursor(
|
|
5203
|
+
let t = kt.current, n = dt.current.get(t), r = ft.current;
|
|
5204
|
+
e.setCursor(vt({
|
|
5191
5205
|
tool: t,
|
|
5192
5206
|
externalToolCursor: n?.cursor,
|
|
5193
|
-
isSpacePressed:
|
|
5194
|
-
interactionMode:
|
|
5195
|
-
rendererCursorHint:
|
|
5207
|
+
isSpacePressed: Vt.current,
|
|
5208
|
+
interactionMode: Gt.current,
|
|
5209
|
+
rendererCursorHint: Kt.current,
|
|
5196
5210
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
5197
5211
|
}));
|
|
5198
|
-
}, []),
|
|
5199
|
-
|
|
5200
|
-
}, [
|
|
5201
|
-
|
|
5202
|
-
}, [
|
|
5203
|
-
let t = /* @__PURE__ */ new Set(), n = new Map(
|
|
5212
|
+
}, []), Jt = f((e) => {
|
|
5213
|
+
Gt.current !== e && (Gt.current = e, qt());
|
|
5214
|
+
}, [qt]), Yt = f((e) => {
|
|
5215
|
+
Kt.current !== e && (Kt.current = e, qt());
|
|
5216
|
+
}, [qt]), Xt = f((e) => {
|
|
5217
|
+
let t = /* @__PURE__ */ new Set(), n = new Map(Bt.current.getShapes().map((e) => [e.id, e]));
|
|
5204
5218
|
return e.filter((e) => {
|
|
5205
5219
|
if (t.has(e)) return !1;
|
|
5206
5220
|
t.add(e);
|
|
5207
5221
|
let r = n.get(e);
|
|
5208
5222
|
if (!r) return !1;
|
|
5209
|
-
let i =
|
|
5210
|
-
return
|
|
5223
|
+
let i = zt.current?.(r);
|
|
5224
|
+
return F(i ? {
|
|
5211
5225
|
...r,
|
|
5212
5226
|
interaction: {
|
|
5213
5227
|
...r.interaction,
|
|
@@ -5215,285 +5229,285 @@ function yr({ imageUrl: t, displayImageUrl: n, coordinateSize: r, clipboardScope
|
|
|
5215
5229
|
}
|
|
5216
5230
|
} : r);
|
|
5217
5231
|
});
|
|
5218
|
-
}, []),
|
|
5219
|
-
let t =
|
|
5220
|
-
|
|
5232
|
+
}, []), Zt = f((e) => {
|
|
5233
|
+
let t = Xt(e);
|
|
5234
|
+
yr(Ot.current, t) || (lt || st(t), G.current?.setSelection(t), he?.(t));
|
|
5221
5235
|
}, [
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
]),
|
|
5226
|
-
|
|
5227
|
-
let [
|
|
5228
|
-
|
|
5229
|
-
let
|
|
5230
|
-
|
|
5231
|
-
if (!
|
|
5232
|
-
let e =
|
|
5233
|
-
|
|
5236
|
+
Xt,
|
|
5237
|
+
he,
|
|
5238
|
+
lt
|
|
5239
|
+
]), Qt = y(Zt);
|
|
5240
|
+
Qt.current = Zt;
|
|
5241
|
+
let [$t, en] = b(null), tn = f((e) => en(e), []), nn = y(tn);
|
|
5242
|
+
nn.current = tn;
|
|
5243
|
+
let rn = y(null);
|
|
5244
|
+
rn.current = $t, p(() => {
|
|
5245
|
+
if (!lt) return;
|
|
5246
|
+
let e = Xt(a);
|
|
5247
|
+
yr(a, e) || he?.(e);
|
|
5234
5248
|
}, [
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5249
|
+
a,
|
|
5250
|
+
J.shapes,
|
|
5251
|
+
Xt,
|
|
5252
|
+
he,
|
|
5253
|
+
lt
|
|
5240
5254
|
]);
|
|
5241
|
-
let
|
|
5242
|
-
|
|
5243
|
-
let { registerMinimapShape:
|
|
5244
|
-
engineRef:
|
|
5245
|
-
docRef:
|
|
5246
|
-
overlayRef:
|
|
5247
|
-
zoomLabelRef:
|
|
5248
|
-
minimapRectRef:
|
|
5249
|
-
minimapSize:
|
|
5250
|
-
onViewportChangeRef:
|
|
5251
|
-
}),
|
|
5252
|
-
|
|
5253
|
-
let
|
|
5254
|
-
t ?
|
|
5255
|
-
}, []),
|
|
5255
|
+
let an = y(Se);
|
|
5256
|
+
an.current = Se;
|
|
5257
|
+
let { registerMinimapShape: on, applyMinimapPreview: sn, syncMinimap: cn } = fr({
|
|
5258
|
+
engineRef: G,
|
|
5259
|
+
docRef: Bt,
|
|
5260
|
+
overlayRef: De,
|
|
5261
|
+
zoomLabelRef: ke,
|
|
5262
|
+
minimapRectRef: Ee,
|
|
5263
|
+
minimapSize: gr,
|
|
5264
|
+
onViewportChangeRef: an
|
|
5265
|
+
}), ln = y(/* @__PURE__ */ new Map()), un = y(V);
|
|
5266
|
+
un.current = V;
|
|
5267
|
+
let dn = f((e, t) => {
|
|
5268
|
+
t ? ln.current.set(e, t) : ln.current.delete(e);
|
|
5269
|
+
}, []), fn = y(null), [pn, hn] = b(null), gn = f((e) => {
|
|
5256
5270
|
if (!e.length) return;
|
|
5257
|
-
let t = new Map(
|
|
5258
|
-
|
|
5271
|
+
let t = new Map(Bt.current.getShapes().map((e) => [e.id, e]));
|
|
5272
|
+
fn.current && t.set(fn.current.id, fn.current);
|
|
5259
5273
|
for (let { id: n, points: r } of e) {
|
|
5260
|
-
let e =
|
|
5274
|
+
let e = ln.current.get(n), i = t.get(n);
|
|
5261
5275
|
if (!e || !i) continue;
|
|
5262
|
-
let a =
|
|
5276
|
+
let a = Ye(e, r);
|
|
5263
5277
|
if (a) {
|
|
5264
|
-
let e =
|
|
5265
|
-
a.textContent =
|
|
5278
|
+
let e = Xe(i, r);
|
|
5279
|
+
a.textContent = un.current?.(e) ?? Ze(e);
|
|
5266
5280
|
}
|
|
5267
5281
|
}
|
|
5268
|
-
}, []),
|
|
5269
|
-
|
|
5282
|
+
}, []), vn = f((e) => {
|
|
5283
|
+
sn(e), gn(e), U?.(e);
|
|
5270
5284
|
}, [
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
]),
|
|
5275
|
-
if (
|
|
5285
|
+
sn,
|
|
5286
|
+
gn,
|
|
5287
|
+
U
|
|
5288
|
+
]), yn = f((e) => {
|
|
5289
|
+
if (xe?.(e ? {
|
|
5276
5290
|
...e,
|
|
5277
|
-
meta:
|
|
5278
|
-
} : null), !e || !
|
|
5279
|
-
|
|
5291
|
+
meta: jt.current
|
|
5292
|
+
} : null), !e || !At.current) {
|
|
5293
|
+
fn.current && (fn.current = null, hn(null));
|
|
5280
5294
|
return;
|
|
5281
5295
|
}
|
|
5282
5296
|
let t = {
|
|
5283
|
-
id:
|
|
5297
|
+
id: _r,
|
|
5284
5298
|
type: e.type,
|
|
5285
5299
|
points: e.points,
|
|
5286
|
-
style:
|
|
5287
|
-
meta:
|
|
5288
|
-
}, n =
|
|
5289
|
-
|
|
5290
|
-
id:
|
|
5300
|
+
style: At.current,
|
|
5301
|
+
meta: jt.current
|
|
5302
|
+
}, n = fn.current !== null;
|
|
5303
|
+
fn.current = t, n ? gn([{
|
|
5304
|
+
id: _r,
|
|
5291
5305
|
points: e.points
|
|
5292
|
-
}]) :
|
|
5293
|
-
}, [
|
|
5294
|
-
let n =
|
|
5295
|
-
if (!n ||
|
|
5296
|
-
let r =
|
|
5297
|
-
|
|
5306
|
+
}]) : hn(t);
|
|
5307
|
+
}, [gn, xe]), bn = f((e, t) => {
|
|
5308
|
+
let n = At.current;
|
|
5309
|
+
if (!n || Ft.current) return;
|
|
5310
|
+
let r = ie();
|
|
5311
|
+
Bt.current.create({
|
|
5298
5312
|
id: r,
|
|
5299
5313
|
type: e,
|
|
5300
5314
|
points: t,
|
|
5301
5315
|
style: n,
|
|
5302
|
-
meta:
|
|
5303
|
-
}),
|
|
5304
|
-
}, [
|
|
5305
|
-
yn.current = _n;
|
|
5306
|
-
let bn = hn({
|
|
5307
|
-
toolRef: Dt,
|
|
5308
|
-
selRef: Et,
|
|
5309
|
-
docRef: Rt,
|
|
5310
|
-
readOnlyRef: Mt,
|
|
5311
|
-
draftRef: Ot,
|
|
5312
|
-
brushSizeRef: At,
|
|
5313
|
-
simplifyEpsilonRef: jt,
|
|
5314
|
-
draftMeta: d,
|
|
5315
|
-
engineRef: W,
|
|
5316
|
-
onDrawSessionChange: f((e) => {
|
|
5317
|
-
Ke(e), H?.(e);
|
|
5318
|
-
}, [H]),
|
|
5319
|
-
onDraftShapeChange: Ee,
|
|
5320
|
-
changeSelection: Yt,
|
|
5321
|
-
createShape: _n
|
|
5322
|
-
}), xn = y(bn);
|
|
5316
|
+
meta: c
|
|
5317
|
+
}), Qt.current([r]);
|
|
5318
|
+
}, [c]), xn = y(bn);
|
|
5323
5319
|
xn.current = bn;
|
|
5324
|
-
let
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
docRef:
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
changeSelection:
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5320
|
+
let Sn = mn({
|
|
5321
|
+
toolRef: kt,
|
|
5322
|
+
selRef: Ot,
|
|
5323
|
+
docRef: Bt,
|
|
5324
|
+
readOnlyRef: Ft,
|
|
5325
|
+
draftRef: At,
|
|
5326
|
+
brushSizeRef: Mt,
|
|
5327
|
+
simplifyEpsilonRef: Pt,
|
|
5328
|
+
draftMeta: c,
|
|
5329
|
+
engineRef: G,
|
|
5330
|
+
onDrawSessionChange: f((e) => {
|
|
5331
|
+
Ve(e), be?.(e);
|
|
5332
|
+
}, [be]),
|
|
5333
|
+
onDraftShapeChange: xe,
|
|
5334
|
+
changeSelection: Zt,
|
|
5335
|
+
createShape: bn
|
|
5336
|
+
}), Cn = y(Sn);
|
|
5337
|
+
Cn.current = Sn;
|
|
5338
|
+
let { reset: wn, undoSession: Tn, redoSession: En, canUndoSession: On, canRedoSession: kn, hasDraftSession: An, hasDraftPoints: jn, commitDraftSession: Mn, setBrushScalarMode: Nn, getBrushScalarMode: Pn, hasBrushSession: Fn, commitBrush: In, cancelBrush: Ln, beginBrushEditFromSelection: Rn, deleteDraftSelectedPoints: zn, handleToolChange: Bn, handleBrushSelectionChange: Vn } = Sn, Hn = y(de);
|
|
5339
|
+
Hn.current = de;
|
|
5340
|
+
let $ = Ut({
|
|
5341
|
+
docRef: Bt,
|
|
5342
|
+
draftRef: At,
|
|
5343
|
+
draftMeta: c,
|
|
5344
|
+
changeSelection: Zt,
|
|
5345
|
+
assistantRef: Hn
|
|
5346
|
+
}), Un = y($);
|
|
5347
|
+
Un.current = $;
|
|
5348
|
+
let Wn = _(() => ct(qe), [qe]), { selectAll: Gn, clearSelection: Kn, deleteSelection: qn, copySelection: Jn, canPaste: Yn, paste: Xn, duplicate: Zn, bringToFront: Qn, sendToBack: $n, nudgeSelection: er, getMergeTargets: tr, mergeSelection: nr } = mr({
|
|
5349
|
+
doc: J,
|
|
5350
|
+
selRef: Ot,
|
|
5351
|
+
effectiveReadOnly: Q,
|
|
5352
|
+
changeSelection: Zt,
|
|
5353
|
+
canMergeSelection: M,
|
|
5354
|
+
clipboardDocumentId: Wn,
|
|
5355
|
+
clipboardScope: n ?? Wn
|
|
5356
|
+
}), { zoomToBounds: rr, zoomToShapes: ir, zoomToSelection: or, zoomAtCenter: sr } = hr({
|
|
5357
|
+
engineRef: G,
|
|
5358
|
+
doc: J,
|
|
5359
|
+
selRef: Ot,
|
|
5360
|
+
zoomAnimationDuration: re,
|
|
5361
|
+
zoomBound: ne,
|
|
5362
|
+
ready: q
|
|
5349
5363
|
});
|
|
5350
|
-
h(
|
|
5364
|
+
h(pe, () => ({
|
|
5351
5365
|
previewRegionMask: (e) => {
|
|
5352
|
-
let t =
|
|
5366
|
+
let t = Tt.current;
|
|
5353
5367
|
if (!t) return;
|
|
5354
|
-
let n = e ? Nt(e, t.w, t.h) :
|
|
5355
|
-
|
|
5368
|
+
let n = e ? Nt(e, t.w, t.h) : Ct.current;
|
|
5369
|
+
G.current?.setRegionOverlay(cr.current.showRegionMask ? n : null);
|
|
5356
5370
|
},
|
|
5357
5371
|
undo: () => {
|
|
5358
|
-
|
|
5372
|
+
Tn() || J.undo();
|
|
5359
5373
|
},
|
|
5360
5374
|
redo: () => {
|
|
5361
|
-
|
|
5375
|
+
En() || J.redo();
|
|
5362
5376
|
},
|
|
5363
|
-
canUndo: () =>
|
|
5364
|
-
canRedo: () =>
|
|
5365
|
-
undoSession:
|
|
5366
|
-
redoSession:
|
|
5367
|
-
canUndoSession:
|
|
5368
|
-
canRedoSession:
|
|
5369
|
-
hasDraftSession:
|
|
5370
|
-
cancelDraftSession:
|
|
5371
|
-
commitDraftSession:
|
|
5372
|
-
setSelection:
|
|
5377
|
+
canUndo: () => On() || J.canUndo(),
|
|
5378
|
+
canRedo: () => kn() || J.canRedo(),
|
|
5379
|
+
undoSession: Tn,
|
|
5380
|
+
redoSession: En,
|
|
5381
|
+
canUndoSession: On,
|
|
5382
|
+
canRedoSession: kn,
|
|
5383
|
+
hasDraftSession: An,
|
|
5384
|
+
cancelDraftSession: wn,
|
|
5385
|
+
commitDraftSession: Mn,
|
|
5386
|
+
setSelection: Zt,
|
|
5373
5387
|
createShapes: (e) => {
|
|
5374
|
-
e.length && (
|
|
5388
|
+
e.length && (J.create(e), Zt(e.map((e) => e.id)));
|
|
5375
5389
|
},
|
|
5376
|
-
updateShapes:
|
|
5377
|
-
deleteShapes:
|
|
5378
|
-
getShapes:
|
|
5379
|
-
selectAll:
|
|
5380
|
-
clearSelection:
|
|
5381
|
-
deleteSelection:
|
|
5382
|
-
copySelection:
|
|
5383
|
-
paste:
|
|
5384
|
-
duplicate:
|
|
5385
|
-
bringToFront:
|
|
5386
|
-
sendToBack:
|
|
5387
|
-
zoomFit: () =>
|
|
5388
|
-
zoom100: () =>
|
|
5390
|
+
updateShapes: J.update,
|
|
5391
|
+
deleteShapes: J.remove,
|
|
5392
|
+
getShapes: J.getShapes,
|
|
5393
|
+
selectAll: Gn,
|
|
5394
|
+
clearSelection: Kn,
|
|
5395
|
+
deleteSelection: qn,
|
|
5396
|
+
copySelection: Jn,
|
|
5397
|
+
paste: Xn,
|
|
5398
|
+
duplicate: Zn,
|
|
5399
|
+
bringToFront: Qn,
|
|
5400
|
+
sendToBack: $n,
|
|
5401
|
+
zoomFit: () => G.current?.fit(),
|
|
5402
|
+
zoom100: () => G.current?.zoom100(),
|
|
5389
5403
|
zoomIn: () => {
|
|
5390
|
-
let e =
|
|
5404
|
+
let e = G.current;
|
|
5391
5405
|
if (!e) return;
|
|
5392
5406
|
let { w: t, h: n } = e.screenSize;
|
|
5393
5407
|
e.zoomAt(t / 2, n / 2, 1.2);
|
|
5394
5408
|
},
|
|
5395
5409
|
zoomOut: () => {
|
|
5396
|
-
let e =
|
|
5410
|
+
let e = G.current;
|
|
5397
5411
|
if (!e) return;
|
|
5398
5412
|
let { w: t, h: n } = e.screenSize;
|
|
5399
5413
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5400
5414
|
},
|
|
5401
|
-
zoomToSelection:
|
|
5402
|
-
zoomToShapes:
|
|
5403
|
-
zoomToBounds:
|
|
5415
|
+
zoomToSelection: or,
|
|
5416
|
+
zoomToShapes: ir,
|
|
5417
|
+
zoomToBounds: rr,
|
|
5404
5418
|
brush: {
|
|
5405
|
-
setScalarMode:
|
|
5406
|
-
getScalarMode:
|
|
5407
|
-
hasSession:
|
|
5408
|
-
commit:
|
|
5409
|
-
cancel:
|
|
5410
|
-
beginEditFromSelection:
|
|
5419
|
+
setScalarMode: Nn,
|
|
5420
|
+
getScalarMode: Pn,
|
|
5421
|
+
hasSession: Fn,
|
|
5422
|
+
commit: In,
|
|
5423
|
+
cancel: Ln,
|
|
5424
|
+
beginEditFromSelection: Rn
|
|
5411
5425
|
}
|
|
5412
5426
|
}), [
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5427
|
+
J,
|
|
5428
|
+
Zt,
|
|
5429
|
+
Tn,
|
|
5430
|
+
En,
|
|
5431
|
+
Mn,
|
|
5416
5432
|
wn,
|
|
5417
|
-
|
|
5418
|
-
|
|
5419
|
-
Pn,
|
|
5420
|
-
Fn,
|
|
5421
|
-
Un,
|
|
5422
|
-
Wn,
|
|
5433
|
+
In,
|
|
5434
|
+
Ln,
|
|
5423
5435
|
Gn,
|
|
5424
5436
|
Kn,
|
|
5437
|
+
qn,
|
|
5425
5438
|
Jn,
|
|
5426
|
-
Yn,
|
|
5427
5439
|
Xn,
|
|
5428
5440
|
Zn,
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5441
|
+
Qn,
|
|
5442
|
+
$n,
|
|
5443
|
+
or,
|
|
5444
|
+
ir,
|
|
5445
|
+
rr,
|
|
5434
5446
|
Nn,
|
|
5435
|
-
|
|
5447
|
+
Pn,
|
|
5448
|
+
Fn,
|
|
5449
|
+
Rn
|
|
5436
5450
|
]);
|
|
5437
|
-
let
|
|
5438
|
-
|
|
5439
|
-
let
|
|
5440
|
-
engineRef:
|
|
5441
|
-
toolRef:
|
|
5442
|
-
externalToolMapRef:
|
|
5443
|
-
spaceRef:
|
|
5444
|
-
shiftRef:
|
|
5445
|
-
docRef:
|
|
5446
|
-
selRef:
|
|
5447
|
-
draftRef:
|
|
5448
|
-
readOnlyRef:
|
|
5449
|
-
disableMarqueeRef:
|
|
5450
|
-
lockedRef:
|
|
5451
|
-
onLockedInteraction: () =>
|
|
5452
|
-
createRef:
|
|
5453
|
-
selectRef:
|
|
5454
|
-
enterEditRef:
|
|
5455
|
-
editingIdRef:
|
|
5456
|
-
drawSessionRef:
|
|
5457
|
-
assistantRef:
|
|
5458
|
-
setCursorHint:
|
|
5459
|
-
setInteractionMode:
|
|
5460
|
-
syncMinimap:
|
|
5461
|
-
onTransformPreview:
|
|
5462
|
-
onDrawPreview:
|
|
5451
|
+
let cr = y(X);
|
|
5452
|
+
cr.current = X;
|
|
5453
|
+
let lr = f(() => Ht({
|
|
5454
|
+
engineRef: G,
|
|
5455
|
+
toolRef: kt,
|
|
5456
|
+
externalToolMapRef: dt,
|
|
5457
|
+
spaceRef: Vt,
|
|
5458
|
+
shiftRef: Wt,
|
|
5459
|
+
docRef: Bt,
|
|
5460
|
+
selRef: Ot,
|
|
5461
|
+
draftRef: At,
|
|
5462
|
+
readOnlyRef: Ft,
|
|
5463
|
+
disableMarqueeRef: It,
|
|
5464
|
+
lockedRef: Lt,
|
|
5465
|
+
onLockedInteraction: () => Rt.current?.(),
|
|
5466
|
+
createRef: xn,
|
|
5467
|
+
selectRef: Qt,
|
|
5468
|
+
enterEditRef: nn,
|
|
5469
|
+
editingIdRef: rn,
|
|
5470
|
+
drawSessionRef: Cn,
|
|
5471
|
+
assistantRef: Un,
|
|
5472
|
+
setCursorHint: Yt,
|
|
5473
|
+
setInteractionMode: Jt,
|
|
5474
|
+
syncMinimap: cn,
|
|
5475
|
+
onTransformPreview: vn,
|
|
5476
|
+
onDrawPreview: yn
|
|
5463
5477
|
}), [
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
]),
|
|
5470
|
-
|
|
5471
|
-
backend:
|
|
5472
|
-
hostRef:
|
|
5473
|
-
engineRef:
|
|
5474
|
-
|
|
5475
|
-
renderedImageUrl:
|
|
5476
|
-
makeCallbacks:
|
|
5477
|
-
viewRef:
|
|
5478
|
-
readOnlyRef:
|
|
5479
|
-
toolRef:
|
|
5480
|
-
renderShapesRef:
|
|
5481
|
-
coordinateSizeRef:
|
|
5482
|
-
imageSizeRef:
|
|
5483
|
-
selRef:
|
|
5484
|
-
maskCanvasRef:
|
|
5485
|
-
regionOverlayRef:
|
|
5486
|
-
dimmedRef:
|
|
5487
|
-
syncMinimap:
|
|
5488
|
-
setImage:
|
|
5489
|
-
setImageVisible:
|
|
5490
|
-
setReady:
|
|
5491
|
-
setImageStatus:
|
|
5492
|
-
onContextMenuRequest:
|
|
5478
|
+
Yt,
|
|
5479
|
+
Jt,
|
|
5480
|
+
cn,
|
|
5481
|
+
vn,
|
|
5482
|
+
yn
|
|
5483
|
+
]), dr = y([]);
|
|
5484
|
+
ar({
|
|
5485
|
+
backend: me,
|
|
5486
|
+
hostRef: Te,
|
|
5487
|
+
engineRef: G,
|
|
5488
|
+
documentId: qe,
|
|
5489
|
+
renderedImageUrl: rt,
|
|
5490
|
+
makeCallbacks: lr,
|
|
5491
|
+
viewRef: cr,
|
|
5492
|
+
readOnlyRef: Ft,
|
|
5493
|
+
toolRef: kt,
|
|
5494
|
+
renderShapesRef: dr,
|
|
5495
|
+
coordinateSizeRef: Et,
|
|
5496
|
+
imageSizeRef: Dt,
|
|
5497
|
+
selRef: Ot,
|
|
5498
|
+
maskCanvasRef: St,
|
|
5499
|
+
regionOverlayRef: Ct,
|
|
5500
|
+
dimmedRef: wt,
|
|
5501
|
+
syncMinimap: cn,
|
|
5502
|
+
setImage: Pe,
|
|
5503
|
+
setImageVisible: Ie,
|
|
5504
|
+
setReady: Le,
|
|
5505
|
+
setImageStatus: at,
|
|
5506
|
+
onContextMenuRequest: ze
|
|
5493
5507
|
});
|
|
5494
|
-
let
|
|
5495
|
-
let e =
|
|
5496
|
-
let t =
|
|
5508
|
+
let pr = _(() => {
|
|
5509
|
+
let e = w ? J.shapes.map((e) => {
|
|
5510
|
+
let t = w(e);
|
|
5497
5511
|
return t ? {
|
|
5498
5512
|
...e,
|
|
5499
5513
|
interaction: {
|
|
@@ -5501,8 +5515,8 @@ function yr({ imageUrl: t, displayImageUrl: n, coordinateSize: r, clipboardScope
|
|
|
5501
5515
|
...t
|
|
5502
5516
|
}
|
|
5503
5517
|
} : e;
|
|
5504
|
-
}) :
|
|
5505
|
-
return
|
|
5518
|
+
}) : J.shapes;
|
|
5519
|
+
return I?.length ? [...I.map((e) => ({
|
|
5506
5520
|
...e,
|
|
5507
5521
|
interaction: {
|
|
5508
5522
|
...e.interaction,
|
|
@@ -5513,389 +5527,393 @@ function yr({ imageUrl: t, displayImageUrl: n, coordinateSize: r, clipboardScope
|
|
|
5513
5527
|
}
|
|
5514
5528
|
})), ...e] : e;
|
|
5515
5529
|
}, [
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5530
|
+
J.shapes,
|
|
5531
|
+
w,
|
|
5532
|
+
I
|
|
5519
5533
|
]);
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
}, [
|
|
5523
|
-
|
|
5524
|
-
}, [
|
|
5525
|
-
|
|
5526
|
-
}, [
|
|
5527
|
-
let
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
}, [
|
|
5531
|
-
|
|
5532
|
-
}, [
|
|
5533
|
-
|
|
5534
|
-
}, [
|
|
5535
|
-
let e =
|
|
5536
|
-
e && (e.setFilter(
|
|
5534
|
+
dr.current = pr, p(() => {
|
|
5535
|
+
G.current?.setShapes(pr, Ot.current), cn();
|
|
5536
|
+
}, [pr, cn]), p(() => {
|
|
5537
|
+
G.current?.setSelection(Y);
|
|
5538
|
+
}, [Y]), p(() => {
|
|
5539
|
+
G.current?.setEditing($t);
|
|
5540
|
+
}, [$t, q]);
|
|
5541
|
+
let br = y(ge);
|
|
5542
|
+
br.current = ge, p(() => {
|
|
5543
|
+
br.current?.($t);
|
|
5544
|
+
}, [$t]), p(() => {
|
|
5545
|
+
en(null);
|
|
5546
|
+
}, [o]), p(() => {
|
|
5547
|
+
$t && (Y.length !== 1 || Y[0] !== $t) && en(null);
|
|
5548
|
+
}, [Y, $t]), p(() => {
|
|
5549
|
+
let e = G.current;
|
|
5550
|
+
e && (e.setFilter(X.brightness, X.contrast), e.setStrokeSize(X.strokeSize), e.setImageSmoothing(X.imageSmoothing), cn());
|
|
5537
5551
|
}, [
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5552
|
+
X.brightness,
|
|
5553
|
+
X.contrast,
|
|
5554
|
+
X.strokeSize,
|
|
5555
|
+
X.imageSmoothing,
|
|
5556
|
+
cn
|
|
5543
5557
|
]), g(() => {
|
|
5544
|
-
|
|
5558
|
+
q && G.current?.setOverlays(X.showGuide ? _t : null, X.showRegionMask ? bt : null, i);
|
|
5545
5559
|
}, [
|
|
5546
|
-
|
|
5547
|
-
ht,
|
|
5560
|
+
q,
|
|
5548
5561
|
_t,
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5562
|
+
bt,
|
|
5563
|
+
X.showGuide,
|
|
5564
|
+
X.showRegionMask,
|
|
5565
|
+
i
|
|
5552
5566
|
]), p(() => {
|
|
5553
|
-
!
|
|
5567
|
+
!q || !K || cn();
|
|
5554
5568
|
}, [
|
|
5569
|
+
q,
|
|
5555
5570
|
K,
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
on
|
|
5571
|
+
yt,
|
|
5572
|
+
X.showGuide,
|
|
5573
|
+
X.showRegionMask,
|
|
5574
|
+
L,
|
|
5575
|
+
cn
|
|
5562
5576
|
]), p(() => {
|
|
5563
|
-
|
|
5577
|
+
q && G.current?.setTransformEnabled(!Q && o !== W.BRUSH);
|
|
5564
5578
|
}, [
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5579
|
+
Q,
|
|
5580
|
+
q,
|
|
5581
|
+
o
|
|
5568
5582
|
]), p(() => {
|
|
5569
|
-
|
|
5570
|
-
}, [
|
|
5571
|
-
let
|
|
5583
|
+
Bn(o, dt.current.has(o));
|
|
5584
|
+
}, [o, Bn]);
|
|
5585
|
+
let xr = $.finalize;
|
|
5572
5586
|
p(() => {
|
|
5573
|
-
|
|
5574
|
-
}, [
|
|
5575
|
-
|
|
5587
|
+
xr();
|
|
5588
|
+
}, [o, xr]), p(() => {
|
|
5589
|
+
Gt.current = "idle", Kt.current = null, qt();
|
|
5576
5590
|
}, [
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5591
|
+
o,
|
|
5592
|
+
me,
|
|
5593
|
+
qt
|
|
5580
5594
|
]), p(() => {
|
|
5581
|
-
|
|
5595
|
+
Vn(Y, Q);
|
|
5582
5596
|
}, [
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5597
|
+
Y,
|
|
5598
|
+
o,
|
|
5599
|
+
Q,
|
|
5600
|
+
Vn
|
|
5587
5601
|
]), p(() => {
|
|
5588
|
-
|
|
5602
|
+
q && qt();
|
|
5589
5603
|
}, [
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5604
|
+
o,
|
|
5605
|
+
Be,
|
|
5606
|
+
ut,
|
|
5607
|
+
q,
|
|
5608
|
+
qt
|
|
5595
5609
|
]);
|
|
5596
|
-
let
|
|
5610
|
+
let Sr = y(nt);
|
|
5611
|
+
Sr.current = nt;
|
|
5612
|
+
let Cr = t !== null, wr = y(null);
|
|
5597
5613
|
p(() => {
|
|
5598
|
-
|
|
5614
|
+
let e = Cr ? qe : null;
|
|
5615
|
+
wr.current !== e && (wr.current = e, ze(null), en(null), Gt.current = "idle", Kt.current = null, J.reset(Cr ? tt ?? [] : []), Zt(Cr ? Sr.current ?? [] : []), wn(), xr(), qt());
|
|
5599
5616
|
}, [
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5617
|
+
Cr,
|
|
5618
|
+
qe,
|
|
5619
|
+
tt,
|
|
5620
|
+
J.reset,
|
|
5621
|
+
Zt,
|
|
5622
|
+
wn,
|
|
5623
|
+
xr,
|
|
5624
|
+
qt
|
|
5607
5625
|
]);
|
|
5608
|
-
let
|
|
5609
|
-
let e =
|
|
5610
|
-
if (!e ||
|
|
5611
|
-
let t =
|
|
5626
|
+
let Tr = f(() => {
|
|
5627
|
+
let e = rn.current;
|
|
5628
|
+
if (!e || Q) return !1;
|
|
5629
|
+
let t = G.current, n = new Set(t?.getVertexSelection() ?? []);
|
|
5612
5630
|
if (!n.size) return !1;
|
|
5613
|
-
let r =
|
|
5631
|
+
let r = Bt.current.getShapes().find((t) => t.id === e);
|
|
5614
5632
|
if (!r) return !1;
|
|
5615
5633
|
let i = r.points.filter((e, t) => !n.has(t)), a = r.type === N.LINE ? 2 : 3;
|
|
5616
|
-
return i.length < a ? !1 : (
|
|
5634
|
+
return i.length < a ? !1 : (Bt.current.update([{
|
|
5617
5635
|
...r,
|
|
5618
5636
|
points: i
|
|
5619
5637
|
}]), t?.setVertexSelection([]), !0);
|
|
5620
|
-
}, [
|
|
5621
|
-
|
|
5622
|
-
keymap:
|
|
5623
|
-
hostRef:
|
|
5638
|
+
}, [Q]);
|
|
5639
|
+
Dn({
|
|
5640
|
+
keymap: fe,
|
|
5641
|
+
hostRef: Te,
|
|
5624
5642
|
actions: {
|
|
5625
5643
|
undo: () => {
|
|
5626
|
-
|
|
5644
|
+
Q || Tn() || J.undo();
|
|
5627
5645
|
},
|
|
5628
5646
|
redo: () => {
|
|
5629
|
-
|
|
5647
|
+
Q || En() || J.redo();
|
|
5630
5648
|
},
|
|
5631
|
-
selectAll:
|
|
5632
|
-
copy:
|
|
5649
|
+
selectAll: Gn,
|
|
5650
|
+
copy: Jn,
|
|
5633
5651
|
cut: () => {
|
|
5634
|
-
|
|
5652
|
+
Jn(), qn();
|
|
5635
5653
|
},
|
|
5636
|
-
paste:
|
|
5637
|
-
duplicate:
|
|
5654
|
+
paste: Xn,
|
|
5655
|
+
duplicate: Zn,
|
|
5638
5656
|
delete: () => {
|
|
5639
|
-
|
|
5657
|
+
jn() && zn() || Tr() || qn();
|
|
5640
5658
|
},
|
|
5641
5659
|
cancel: () => {
|
|
5642
|
-
let e =
|
|
5660
|
+
let e = dt.current.get(kt.current);
|
|
5643
5661
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
5644
|
-
if (
|
|
5645
|
-
|
|
5662
|
+
if ($.isActive()) {
|
|
5663
|
+
$.cancel();
|
|
5646
5664
|
return;
|
|
5647
5665
|
}
|
|
5648
|
-
if (
|
|
5649
|
-
|
|
5666
|
+
if (An()) {
|
|
5667
|
+
wn();
|
|
5650
5668
|
return;
|
|
5651
5669
|
}
|
|
5652
|
-
if (
|
|
5653
|
-
|
|
5670
|
+
if ($t) {
|
|
5671
|
+
en(null);
|
|
5654
5672
|
return;
|
|
5655
5673
|
}
|
|
5656
|
-
if (
|
|
5657
|
-
|
|
5674
|
+
if (Ot.current.length) {
|
|
5675
|
+
Kn();
|
|
5658
5676
|
return;
|
|
5659
5677
|
}
|
|
5660
|
-
|
|
5678
|
+
x?.();
|
|
5661
5679
|
}
|
|
5662
5680
|
},
|
|
5663
5681
|
commitDraft: () => {
|
|
5664
|
-
if (
|
|
5665
|
-
|
|
5682
|
+
if ($.isActive()) {
|
|
5683
|
+
$.finalize();
|
|
5666
5684
|
return;
|
|
5667
5685
|
}
|
|
5668
|
-
if (
|
|
5669
|
-
|
|
5686
|
+
if (An()) {
|
|
5687
|
+
Mn();
|
|
5670
5688
|
return;
|
|
5671
5689
|
}
|
|
5672
|
-
if (
|
|
5673
|
-
if (
|
|
5674
|
-
|
|
5690
|
+
if (Q) return;
|
|
5691
|
+
if ($t) {
|
|
5692
|
+
en(null);
|
|
5675
5693
|
return;
|
|
5676
5694
|
}
|
|
5677
|
-
let e =
|
|
5695
|
+
let e = Ot.current;
|
|
5678
5696
|
if (e.length !== 1) return;
|
|
5679
|
-
let t =
|
|
5680
|
-
t && (t.type === N.POLYGON || t.type === N.LINE) && t.interaction?.editable !== !1 && !t.readOnly &&
|
|
5697
|
+
let t = Bt.current.getShapes().find((t) => t.id === e[0]);
|
|
5698
|
+
t && (t.type === N.POLYGON || t.type === N.LINE) && t.interaction?.editable !== !1 && !t.readOnly && en(e[0]);
|
|
5681
5699
|
},
|
|
5682
|
-
bringToFront:
|
|
5683
|
-
sendToBack:
|
|
5684
|
-
zoomIn: () =>
|
|
5685
|
-
zoomOut: () =>
|
|
5686
|
-
zoom100: () =>
|
|
5687
|
-
zoomFit: () =>
|
|
5688
|
-
toggleMinimap: () =>
|
|
5689
|
-
toggleCursorGuide: () =>
|
|
5700
|
+
bringToFront: Qn,
|
|
5701
|
+
sendToBack: $n,
|
|
5702
|
+
zoomIn: () => sr(1.2),
|
|
5703
|
+
zoomOut: () => sr(1 / 1.2),
|
|
5704
|
+
zoom100: () => G.current?.zoom100(),
|
|
5705
|
+
zoomFit: () => G.current?.fit(),
|
|
5706
|
+
toggleMinimap: () => We((e) => !e),
|
|
5707
|
+
toggleCursorGuide: () => pt((e) => ({
|
|
5690
5708
|
...e,
|
|
5691
5709
|
showCursorGuide: !e.showCursorGuide
|
|
5692
5710
|
})),
|
|
5693
|
-
togglePixelation: () =>
|
|
5711
|
+
togglePixelation: () => pt((e) => ({
|
|
5694
5712
|
...e,
|
|
5695
5713
|
imageSmoothing: !e.imageSmoothing
|
|
5696
5714
|
})),
|
|
5697
|
-
selectTool: () =>
|
|
5698
|
-
rectangleTool: () =>
|
|
5699
|
-
rotatedRectangleTool: () =>
|
|
5700
|
-
circleTool: () =>
|
|
5701
|
-
polygonTool: () =>
|
|
5702
|
-
pathTool: () =>
|
|
5703
|
-
brushTool: () =>
|
|
5704
|
-
pointTool: () =>
|
|
5715
|
+
selectTool: () => H?.(W.SELECT),
|
|
5716
|
+
rectangleTool: () => H?.(W.RECTANGLE),
|
|
5717
|
+
rotatedRectangleTool: () => H?.(W.ROTATED_RECTANGLE),
|
|
5718
|
+
circleTool: () => H?.(W.CIRCLE),
|
|
5719
|
+
polygonTool: () => H?.(W.POLYGON),
|
|
5720
|
+
pathTool: () => H?.(W.PATH),
|
|
5721
|
+
brushTool: () => H?.(W.BRUSH),
|
|
5722
|
+
pointTool: () => H?.(W.POINT)
|
|
5705
5723
|
},
|
|
5706
|
-
spaceRef:
|
|
5707
|
-
shiftRef:
|
|
5724
|
+
spaceRef: Vt,
|
|
5725
|
+
shiftRef: Wt,
|
|
5708
5726
|
onSpaceDown: () => {
|
|
5709
|
-
|
|
5727
|
+
G.current?.setPanMode(!0), qt();
|
|
5710
5728
|
},
|
|
5711
5729
|
onSpaceUp: () => {
|
|
5712
|
-
|
|
5730
|
+
G.current?.setPanMode(!1), Gt.current === "panning" ? Jt("idle") : qt();
|
|
5713
5731
|
},
|
|
5714
|
-
nudge:
|
|
5732
|
+
nudge: er
|
|
5715
5733
|
});
|
|
5716
|
-
let
|
|
5717
|
-
let e =
|
|
5734
|
+
let Er = _(() => pr.filter((e) => Y.includes(e.id) && P(e)), [pr, Y]), Dr = _(() => pn ? [...Er, pn] : Er, [Er, pn]), Or = Y.length > 0, kr = J.shapes.some((e) => Y.includes(e.id) && te(e)), Ar = !Q && Y.length === 1 && (() => {
|
|
5735
|
+
let e = J.shapes.find((e) => e.id === Y[0]);
|
|
5718
5736
|
return !!e && (e.type === N.POLYGON || e.type === N.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
5719
|
-
})(),
|
|
5720
|
-
let e =
|
|
5737
|
+
})(), jr = tr(), Mr = Q || jr.length < 2 || (M ? !M(jr) : !1), Nr = !!de && !Q, Pr = Nr && Y.length === 1 ? (() => {
|
|
5738
|
+
let e = J.shapes.find((e) => e.id === Y[0]);
|
|
5721
5739
|
return e && e.type === N.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
5722
|
-
})() : null,
|
|
5740
|
+
})() : null, Fr = [
|
|
5723
5741
|
{
|
|
5724
5742
|
id: "copy",
|
|
5725
|
-
label:
|
|
5743
|
+
label: Z.contextMenu.copy,
|
|
5726
5744
|
shortcut: "⌘C",
|
|
5727
|
-
disabled: !
|
|
5728
|
-
onClick:
|
|
5745
|
+
disabled: !kr,
|
|
5746
|
+
onClick: Jn
|
|
5729
5747
|
},
|
|
5730
5748
|
{
|
|
5731
5749
|
id: "paste",
|
|
5732
|
-
label:
|
|
5750
|
+
label: Z.contextMenu.paste,
|
|
5733
5751
|
shortcut: "⌘V",
|
|
5734
|
-
disabled:
|
|
5735
|
-
onClick: () =>
|
|
5752
|
+
disabled: Q || !Yn(),
|
|
5753
|
+
onClick: () => Xn(Re?.img)
|
|
5736
5754
|
},
|
|
5737
5755
|
{
|
|
5738
5756
|
id: "duplicate",
|
|
5739
|
-
label:
|
|
5757
|
+
label: Z.contextMenu.duplicate,
|
|
5740
5758
|
shortcut: "⌘D",
|
|
5741
|
-
disabled: !
|
|
5742
|
-
onClick:
|
|
5759
|
+
disabled: !kr || Q,
|
|
5760
|
+
onClick: Zn
|
|
5743
5761
|
},
|
|
5744
5762
|
{
|
|
5745
5763
|
id: "delete",
|
|
5746
|
-
label:
|
|
5764
|
+
label: Z.contextMenu.delete,
|
|
5747
5765
|
shortcut: "Del",
|
|
5748
5766
|
danger: !0,
|
|
5749
|
-
disabled: !
|
|
5750
|
-
onClick:
|
|
5767
|
+
disabled: !kr || Q,
|
|
5768
|
+
onClick: qn
|
|
5751
5769
|
},
|
|
5752
5770
|
{ separator: !0 },
|
|
5753
5771
|
{
|
|
5754
5772
|
id: "editVertices",
|
|
5755
|
-
label:
|
|
5773
|
+
label: Z.contextMenu.editVertices,
|
|
5756
5774
|
shortcut: "Enter",
|
|
5757
|
-
disabled: !
|
|
5758
|
-
onClick: () =>
|
|
5775
|
+
disabled: !Ar,
|
|
5776
|
+
onClick: () => en(Y[0])
|
|
5759
5777
|
},
|
|
5760
5778
|
{
|
|
5761
5779
|
id: "merge",
|
|
5762
|
-
label:
|
|
5763
|
-
disabled:
|
|
5764
|
-
onClick:
|
|
5780
|
+
label: Z.contextMenu.merge,
|
|
5781
|
+
disabled: Mr,
|
|
5782
|
+
onClick: nr
|
|
5765
5783
|
},
|
|
5766
|
-
...
|
|
5784
|
+
...Nr ? [{
|
|
5767
5785
|
id: "assistExpand",
|
|
5768
|
-
label:
|
|
5786
|
+
label: Z.contextMenu.assistExpand,
|
|
5769
5787
|
icon: /* @__PURE__ */ S(e, { size: 14 }),
|
|
5770
|
-
disabled: !
|
|
5788
|
+
disabled: !Pr,
|
|
5771
5789
|
onClick: () => {
|
|
5772
|
-
|
|
5790
|
+
Re && Pr && $.refineShape(Pr, Re.img, !0);
|
|
5773
5791
|
}
|
|
5774
5792
|
}, {
|
|
5775
5793
|
id: "assistExclude",
|
|
5776
|
-
label:
|
|
5794
|
+
label: Z.contextMenu.assistExclude,
|
|
5777
5795
|
icon: /* @__PURE__ */ S(e, { size: 14 }),
|
|
5778
|
-
disabled: !
|
|
5796
|
+
disabled: !Pr,
|
|
5779
5797
|
onClick: () => {
|
|
5780
|
-
|
|
5798
|
+
Re && Pr && $.refineShape(Pr, Re.img, !1);
|
|
5781
5799
|
}
|
|
5782
5800
|
}] : [],
|
|
5783
5801
|
{
|
|
5784
5802
|
id: "bringToFront",
|
|
5785
|
-
label:
|
|
5786
|
-
disabled: !
|
|
5787
|
-
onClick:
|
|
5803
|
+
label: Z.contextMenu.bringToFront,
|
|
5804
|
+
disabled: !kr || Q,
|
|
5805
|
+
onClick: Qn
|
|
5788
5806
|
},
|
|
5789
5807
|
{
|
|
5790
5808
|
id: "sendToBack",
|
|
5791
|
-
label:
|
|
5792
|
-
disabled: !
|
|
5793
|
-
onClick:
|
|
5809
|
+
label: Z.contextMenu.sendToBack,
|
|
5810
|
+
disabled: !kr || Q,
|
|
5811
|
+
onClick: $n
|
|
5794
5812
|
},
|
|
5795
5813
|
{ separator: !0 },
|
|
5796
5814
|
{
|
|
5797
5815
|
id: "undo",
|
|
5798
|
-
label:
|
|
5816
|
+
label: Z.contextMenu.undo,
|
|
5799
5817
|
shortcut: "⌘Z",
|
|
5800
|
-
disabled:
|
|
5818
|
+
disabled: Q || !On() && !J.canUndo(),
|
|
5801
5819
|
onClick: () => {
|
|
5802
|
-
|
|
5820
|
+
Tn() || J.undo();
|
|
5803
5821
|
}
|
|
5804
5822
|
},
|
|
5805
5823
|
{
|
|
5806
5824
|
id: "redo",
|
|
5807
|
-
label:
|
|
5825
|
+
label: Z.contextMenu.redo,
|
|
5808
5826
|
shortcut: "⇧⌘Z",
|
|
5809
|
-
disabled:
|
|
5827
|
+
disabled: Q || !kn() && !J.canRedo(),
|
|
5810
5828
|
onClick: () => {
|
|
5811
|
-
|
|
5829
|
+
En() || J.redo();
|
|
5812
5830
|
}
|
|
5813
5831
|
},
|
|
5814
5832
|
{ separator: !0 },
|
|
5815
5833
|
{
|
|
5816
5834
|
id: "selectAll",
|
|
5817
|
-
label:
|
|
5835
|
+
label: Z.contextMenu.selectAll,
|
|
5818
5836
|
shortcut: "⌘A",
|
|
5819
|
-
onClick:
|
|
5837
|
+
onClick: Gn
|
|
5820
5838
|
},
|
|
5821
5839
|
{
|
|
5822
5840
|
id: "clearSelection",
|
|
5823
|
-
label:
|
|
5824
|
-
disabled: !
|
|
5825
|
-
onClick:
|
|
5841
|
+
label: Z.contextMenu.clearSelection,
|
|
5842
|
+
disabled: !Or,
|
|
5843
|
+
onClick: Kn
|
|
5826
5844
|
},
|
|
5827
5845
|
{
|
|
5828
5846
|
id: "zoomToSelection",
|
|
5829
|
-
label:
|
|
5830
|
-
disabled: !
|
|
5831
|
-
onClick:
|
|
5847
|
+
label: Z.contextMenu.zoomToSelection,
|
|
5848
|
+
disabled: !Or,
|
|
5849
|
+
onClick: or
|
|
5832
5850
|
}
|
|
5833
|
-
],
|
|
5834
|
-
selectedIds:
|
|
5835
|
-
readOnly:
|
|
5836
|
-
}) :
|
|
5837
|
-
engineRef:
|
|
5838
|
-
image:
|
|
5839
|
-
wheelZoom:
|
|
5840
|
-
minimapSize:
|
|
5841
|
-
}),
|
|
5842
|
-
|
|
5843
|
-
}, []),
|
|
5844
|
-
|
|
5845
|
-
}, []),
|
|
5846
|
-
|
|
5847
|
-
}, []),
|
|
5848
|
-
|
|
5851
|
+
], Ir = l ? Fr.filter((e) => "separator" in e || !!e.id && vr.has(e.id)) : Fr, Lr = A ? A(Ir, {
|
|
5852
|
+
selectedIds: Y,
|
|
5853
|
+
readOnly: Q
|
|
5854
|
+
}) : Ir, Rr = ur({
|
|
5855
|
+
engineRef: G,
|
|
5856
|
+
image: K,
|
|
5857
|
+
wheelZoom: X.wheelZoom,
|
|
5858
|
+
minimapSize: gr
|
|
5859
|
+
}), zr = f(() => {
|
|
5860
|
+
G.current?.zoom100();
|
|
5861
|
+
}, []), Br = f(() => {
|
|
5862
|
+
We((e) => !e);
|
|
5863
|
+
}, []), Vr = f(() => {
|
|
5864
|
+
Ke((e) => !e);
|
|
5865
|
+
}, []), Hr = f(() => {
|
|
5866
|
+
Ke(!1);
|
|
5849
5867
|
}, []);
|
|
5850
5868
|
return /* @__PURE__ */ C("div", {
|
|
5851
5869
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
5852
5870
|
children: [
|
|
5853
5871
|
/* @__PURE__ */ S("div", {
|
|
5854
|
-
ref:
|
|
5872
|
+
ref: Te,
|
|
5855
5873
|
className: "aivex:h-full aivex:w-full",
|
|
5856
5874
|
style: {
|
|
5857
|
-
opacity: +!!
|
|
5858
|
-
transition:
|
|
5875
|
+
opacity: +!!Fe,
|
|
5876
|
+
transition: Fe ? "opacity 0.3s ease" : "none"
|
|
5859
5877
|
}
|
|
5860
5878
|
}),
|
|
5861
|
-
|
|
5862
|
-
status:
|
|
5863
|
-
render:
|
|
5864
|
-
loadingLabel:
|
|
5865
|
-
errorLabel:
|
|
5879
|
+
it !== "ready" && /* @__PURE__ */ S(Me, {
|
|
5880
|
+
status: it,
|
|
5881
|
+
render: r,
|
|
5882
|
+
loadingLabel: Z.imageLoading,
|
|
5883
|
+
errorLabel: Z.imageLoadError
|
|
5866
5884
|
}),
|
|
5867
|
-
|
|
5885
|
+
q && K && /* @__PURE__ */ S("div", {
|
|
5868
5886
|
className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
|
|
5869
5887
|
children: /* @__PURE__ */ C("div", {
|
|
5870
|
-
ref:
|
|
5888
|
+
ref: De,
|
|
5871
5889
|
style: {
|
|
5872
5890
|
position: "absolute",
|
|
5873
5891
|
top: 0,
|
|
5874
5892
|
left: 0,
|
|
5875
|
-
width:
|
|
5876
|
-
height:
|
|
5893
|
+
width: K.w,
|
|
5894
|
+
height: K.h,
|
|
5877
5895
|
transformOrigin: "0 0"
|
|
5878
5896
|
},
|
|
5879
5897
|
children: [
|
|
5880
|
-
!!
|
|
5898
|
+
!!R?.length && se && /* @__PURE__ */ S("div", {
|
|
5881
5899
|
style: {
|
|
5882
5900
|
position: "absolute",
|
|
5883
5901
|
left: 0,
|
|
5884
5902
|
top: 0,
|
|
5885
|
-
width:
|
|
5886
|
-
height:
|
|
5903
|
+
width: K.w,
|
|
5904
|
+
height: K.h,
|
|
5887
5905
|
pointerEvents: "none"
|
|
5888
5906
|
},
|
|
5889
|
-
children:
|
|
5907
|
+
children: R.map((e) => /* @__PURE__ */ S("div", {
|
|
5890
5908
|
role: e.disabled ? void 0 : "button",
|
|
5891
5909
|
tabIndex: e.disabled ? void 0 : 0,
|
|
5892
5910
|
"aria-pressed": e.selected || void 0,
|
|
5893
5911
|
onPointerDown: (e) => e.stopPropagation(),
|
|
5894
5912
|
onClick: (t) => {
|
|
5895
|
-
t.stopPropagation(), e.disabled ||
|
|
5913
|
+
t.stopPropagation(), e.disabled || z?.(e);
|
|
5896
5914
|
},
|
|
5897
5915
|
onKeyDown: (t) => {
|
|
5898
|
-
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(),
|
|
5916
|
+
e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), z?.(e));
|
|
5899
5917
|
},
|
|
5900
5918
|
style: {
|
|
5901
5919
|
position: "absolute",
|
|
@@ -5907,72 +5925,72 @@ function yr({ imageUrl: t, displayImageUrl: n, coordinateSize: r, clipboardScope
|
|
|
5907
5925
|
pointerEvents: e.disabled ? "none" : "auto",
|
|
5908
5926
|
cursor: e.disabled ? "default" : "pointer"
|
|
5909
5927
|
},
|
|
5910
|
-
children:
|
|
5928
|
+
children: se(e)
|
|
5911
5929
|
}, e.id))
|
|
5912
5930
|
}),
|
|
5913
|
-
|
|
5914
|
-
image:
|
|
5915
|
-
viewport:
|
|
5931
|
+
ce?.({
|
|
5932
|
+
image: K,
|
|
5933
|
+
viewport: G.current?.viewport ?? {
|
|
5916
5934
|
scale: 1,
|
|
5917
5935
|
x: 0,
|
|
5918
5936
|
y: 0
|
|
5919
5937
|
}
|
|
5920
5938
|
}),
|
|
5921
|
-
|
|
5922
|
-
shapes:
|
|
5923
|
-
getLabel:
|
|
5924
|
-
hideDot:
|
|
5925
|
-
formatInfo:
|
|
5926
|
-
register:
|
|
5939
|
+
Dr.length > 0 && /* @__PURE__ */ S($e, {
|
|
5940
|
+
shapes: Dr,
|
|
5941
|
+
getLabel: le,
|
|
5942
|
+
hideDot: B,
|
|
5943
|
+
formatInfo: V,
|
|
5944
|
+
register: dn
|
|
5927
5945
|
}),
|
|
5928
|
-
|
|
5929
|
-
image:
|
|
5930
|
-
points:
|
|
5931
|
-
boxes:
|
|
5932
|
-
status:
|
|
5946
|
+
de && ($.status === "loading" || $.boxes.length > 0) && /* @__PURE__ */ S(Oe, {
|
|
5947
|
+
image: K,
|
|
5948
|
+
points: $.points,
|
|
5949
|
+
boxes: $.boxes,
|
|
5950
|
+
status: $.status
|
|
5933
5951
|
})
|
|
5934
5952
|
]
|
|
5935
5953
|
})
|
|
5936
5954
|
}),
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
image:
|
|
5940
|
-
imageUrl:
|
|
5941
|
-
imageVisible:
|
|
5942
|
-
loading: !
|
|
5943
|
-
maskDataUrl:
|
|
5944
|
-
region:
|
|
5945
|
-
roiMaskId:
|
|
5946
|
-
shapes:
|
|
5947
|
-
view:
|
|
5948
|
-
onChangeView:
|
|
5949
|
-
nav:
|
|
5950
|
-
registerShape:
|
|
5951
|
-
rectRef:
|
|
5952
|
-
zoomLabelRef:
|
|
5953
|
-
onZoom100:
|
|
5954
|
-
open:
|
|
5955
|
-
onToggleOpen:
|
|
5956
|
-
labels:
|
|
5957
|
-
settingsLabels:
|
|
5958
|
-
showSettings:
|
|
5959
|
-
settingsOpen:
|
|
5960
|
-
onToggleSettings:
|
|
5961
|
-
onCloseSettings:
|
|
5955
|
+
q && X.showCursorGuide && /* @__PURE__ */ S(je, { color: "#1e88e5" }),
|
|
5956
|
+
K && O && /* @__PURE__ */ S(Ue, {
|
|
5957
|
+
image: K,
|
|
5958
|
+
imageUrl: rt,
|
|
5959
|
+
imageVisible: Fe,
|
|
5960
|
+
loading: !q,
|
|
5961
|
+
maskDataUrl: yt,
|
|
5962
|
+
region: bt,
|
|
5963
|
+
roiMaskId: Ne,
|
|
5964
|
+
shapes: pr,
|
|
5965
|
+
view: X,
|
|
5966
|
+
onChangeView: mt,
|
|
5967
|
+
nav: Rr,
|
|
5968
|
+
registerShape: on,
|
|
5969
|
+
rectRef: Ee,
|
|
5970
|
+
zoomLabelRef: ke,
|
|
5971
|
+
onZoom100: zr,
|
|
5972
|
+
open: He,
|
|
5973
|
+
onToggleOpen: Br,
|
|
5974
|
+
labels: Z.minimap,
|
|
5975
|
+
settingsLabels: Z.viewSettings,
|
|
5976
|
+
showSettings: k,
|
|
5977
|
+
settingsOpen: Ge,
|
|
5978
|
+
onToggleSettings: Vr,
|
|
5979
|
+
onCloseSettings: Hr
|
|
5962
5980
|
}),
|
|
5963
|
-
|
|
5964
|
-
x:
|
|
5965
|
-
y:
|
|
5966
|
-
items:
|
|
5967
|
-
onClose: () =>
|
|
5981
|
+
Re && /* @__PURE__ */ S(Ae, {
|
|
5982
|
+
x: Re.x,
|
|
5983
|
+
y: Re.y,
|
|
5984
|
+
items: Lr,
|
|
5985
|
+
onClose: () => ze(null)
|
|
5968
5986
|
})
|
|
5969
5987
|
]
|
|
5970
5988
|
});
|
|
5971
5989
|
}
|
|
5972
5990
|
//#endregion
|
|
5973
5991
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
5974
|
-
async function
|
|
5975
|
-
let t = await
|
|
5992
|
+
async function xr(e) {
|
|
5993
|
+
let t = await On(e);
|
|
5976
5994
|
return await new Promise((n, r) => {
|
|
5977
5995
|
let i = new Image();
|
|
5978
5996
|
t || (i.crossOrigin = "anonymous"), i.onload = () => n({
|
|
@@ -5983,16 +6001,16 @@ async function br(e) {
|
|
|
5983
6001
|
}, i.src = t ?? e;
|
|
5984
6002
|
});
|
|
5985
6003
|
}
|
|
5986
|
-
function
|
|
6004
|
+
function Sr(e, t, n) {
|
|
5987
6005
|
if (t.length !== 0) {
|
|
5988
6006
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
5989
6007
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
5990
6008
|
n && e.closePath();
|
|
5991
6009
|
}
|
|
5992
6010
|
}
|
|
5993
|
-
function
|
|
6011
|
+
function Cr(e, t, n, r) {
|
|
5994
6012
|
if (t.interaction?.visible === !1) return;
|
|
5995
|
-
let i =
|
|
6013
|
+
let i = Ie(t, {
|
|
5996
6014
|
strokeWidth: r,
|
|
5997
6015
|
pointRadius: 2
|
|
5998
6016
|
});
|
|
@@ -6007,10 +6025,10 @@ function Sr(e, t, n, r) {
|
|
|
6007
6025
|
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);
|
|
6008
6026
|
e.beginPath(), t.type === N.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6009
6027
|
}
|
|
6010
|
-
} else
|
|
6028
|
+
} else Sr(e, t.points, t.type !== N.LINE);
|
|
6011
6029
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill(), 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();
|
|
6012
6030
|
}
|
|
6013
|
-
function
|
|
6031
|
+
function wr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes: r = [], regionMask: i, guideMask: a, maskPalette: o, focusedShapeId: s, focusFit: c = "contain", zoomPadding: l = .3, strokeSize: u = 1, brightness: d = 1, contrast: f = 1, imageSmoothing: m = !0, lazy: h = !0, className: g, style: v, renderImageState: x }) {
|
|
6014
6032
|
let w = y(null), T = y(null), E = y(null), [D, O] = b(!h), [k, A] = b("loading"), [j, M] = b(0);
|
|
6015
6033
|
p(() => {
|
|
6016
6034
|
if (!h || D) return;
|
|
@@ -6031,7 +6049,7 @@ function Cr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6031
6049
|
return;
|
|
6032
6050
|
}
|
|
6033
6051
|
let t = !0;
|
|
6034
|
-
return A("loading"),
|
|
6052
|
+
return A("loading"), xr(e).then((e) => {
|
|
6035
6053
|
if (!t) {
|
|
6036
6054
|
e.revoke?.();
|
|
6037
6055
|
return;
|
|
@@ -6045,7 +6063,7 @@ function Cr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6045
6063
|
}, [e, D]), p(() => () => {
|
|
6046
6064
|
E.current?.revoke?.(), E.current = null;
|
|
6047
6065
|
}, []);
|
|
6048
|
-
let N = _(() => r.find((e) => e.id === s), [s, r]), P = _(() => a && o ?
|
|
6066
|
+
let N = _(() => r.find((e) => e.id === s), [s, r]), P = _(() => a && o ? xt(a, o) : null, [a, o]);
|
|
6049
6067
|
return p(() => {
|
|
6050
6068
|
if (k === "error") {
|
|
6051
6069
|
let e = T.current;
|
|
@@ -6064,24 +6082,24 @@ function Cr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6064
6082
|
if (!g || !_) return;
|
|
6065
6083
|
let v = Math.min(o / g, s / _), y = (o - g * v) / 2, b = (s - _ * v) / 2;
|
|
6066
6084
|
if (N && N.points.length > 0) {
|
|
6067
|
-
let e =
|
|
6085
|
+
let e = L(N.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * l;
|
|
6068
6086
|
v = Math.min(o / (t + r * 2), s / (n + r * 2)), c === "cover" && (v = Math.max(v, Math.max(o / g, s / _))), y = o / 2 - (e.minX + e.maxX) / 2 * v, b = s / 2 - (e.minY + e.maxY) / 2 * v, c === "cover" && (y = Math.min(0, Math.max(y, o - g * v)), b = Math.min(0, Math.max(b, s - _ * v)));
|
|
6069
6087
|
}
|
|
6070
6088
|
h.setTransform(p, 0, 0, p, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, b), h.scale(v, v), h.imageSmoothingEnabled = m, h.filter = `brightness(${d}) contrast(${f})`, h.drawImage(a.image, 0, 0, g, _), h.filter = "none", P && (h.save(), h.globalAlpha = .55, h.drawImage(P, 0, 0, g, _), h.restore());
|
|
6071
6089
|
let x = i ? Nt(i, g, _) : null;
|
|
6072
|
-
if (x && (
|
|
6090
|
+
if (x && (Ot(h, x, g, _), x.outlineStyles)) {
|
|
6073
6091
|
let e = (e, t) => {
|
|
6074
6092
|
if (h.lineWidth = t.width / v, t.underlayColor) {
|
|
6075
6093
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
6076
|
-
for (let [t, n] of e)
|
|
6094
|
+
for (let [t, n] of e) Sr(h, [t, n], !1), h.stroke();
|
|
6077
6095
|
}
|
|
6078
6096
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / v)), h.strokeStyle = t.color;
|
|
6079
|
-
for (let [t, n] of e)
|
|
6097
|
+
for (let [t, n] of e) Sr(h, [t, n], !1), h.stroke();
|
|
6080
6098
|
h.restore();
|
|
6081
6099
|
};
|
|
6082
6100
|
e(x.visibleOutline, x.outlineStyles.visible), e(x.occludedOutline, x.outlineStyles.occluded);
|
|
6083
6101
|
}
|
|
6084
|
-
for (let e of
|
|
6102
|
+
for (let e of re(r)) Cr(h, e, v, u);
|
|
6085
6103
|
h.restore();
|
|
6086
6104
|
}, [
|
|
6087
6105
|
d,
|
|
@@ -6121,6 +6139,6 @@ function Cr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6121
6139
|
});
|
|
6122
6140
|
}
|
|
6123
6141
|
//#endregion
|
|
6124
|
-
export {
|
|
6142
|
+
export { U as DEFAULT_EDITOR_STRINGS, we as DEFAULT_VIEW_SETTINGS, N as SHAPE_TYPE, br as ShapeEditor, br as default, wr as ShapeViewer, W as TOOL, ie as generateId };
|
|
6125
6143
|
|
|
6126
6144
|
//# sourceMappingURL=shape-editor.js.map
|