@aivex/ui 1.2.0-dev.27 → 1.2.0-dev.28
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/ShapeViewer.d.ts +1 -1
- package/dist/components/ShapeEditor/_components/ImageStateOverlay.d.ts +4 -3
- package/dist/components/ShapeEditor/_model/geometry.d.ts +17 -24
- package/dist/components/ShapeEditor/_model/geometry.evenodd-audit.test.d.ts +1 -0
- package/dist/components/ShapeEditor/_model/props.d.ts +1 -1
- package/dist/components/ShapeEditor/_model/strings.d.ts +2 -0
- package/dist/components/ShapeEditor/_state/useEngineLifecycle.d.ts +1 -1
- package/dist/shape-editor.cjs +1 -1
- package/dist/shape-editor.cjs.map +1 -1
- package/dist/shape-editor.js +959 -903
- package/dist/shape-editor.js.map +1 -1
- package/package.json +1 -1
package/dist/shape-editor.js
CHANGED
|
@@ -237,20 +237,36 @@ function we(e, t, n) {
|
|
|
237
237
|
y: n.minY + (e.y - t.minY) / i * o
|
|
238
238
|
}));
|
|
239
239
|
}
|
|
240
|
-
function Te(e
|
|
241
|
-
let
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
240
|
+
function Te(e) {
|
|
241
|
+
let t = e.length, n = Array.from({ length: t }, (n, r) => {
|
|
242
|
+
let i = e[r], a = e[(r + 1) % t];
|
|
243
|
+
return {
|
|
244
|
+
i: r,
|
|
245
|
+
minX: Math.min(i.x, a.x),
|
|
246
|
+
maxX: Math.max(i.x, a.x),
|
|
247
|
+
minY: Math.min(i.y, a.y),
|
|
248
|
+
maxY: Math.max(i.y, a.y)
|
|
249
|
+
};
|
|
250
|
+
}).sort((e, t) => e.minX - t.minX), r = [];
|
|
251
|
+
for (let i = 0; i < t; i++) {
|
|
252
|
+
let a = n[i];
|
|
253
|
+
for (let o = i + 1; o < t && n[o].minX <= a.maxX; o++) {
|
|
254
|
+
let i = n[o];
|
|
255
|
+
if (i.minY > a.maxY || i.maxY < a.minY) continue;
|
|
256
|
+
let s = Math.min(a.i, i.i), c = Math.max(a.i, i.i);
|
|
257
|
+
if (c === s + 1 || s === 0 && c === t - 1) continue;
|
|
258
|
+
let l = W(e[s], e[(s + 1) % t], e[c], e[(c + 1) % t]);
|
|
259
|
+
l && r.push({
|
|
260
|
+
i: s,
|
|
261
|
+
j: c,
|
|
262
|
+
ti: l.ti,
|
|
263
|
+
tj: l.tj
|
|
264
|
+
});
|
|
265
|
+
}
|
|
250
266
|
}
|
|
251
|
-
return
|
|
267
|
+
return r;
|
|
252
268
|
}
|
|
253
|
-
function
|
|
269
|
+
function W(e, t, n, r) {
|
|
254
270
|
let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
|
|
255
271
|
if (!c) return null;
|
|
256
272
|
let l = ((n.x - e.x) * s - (n.y - e.y) * o) / c, u = ((n.x - e.x) * a - (n.y - e.y) * i) / c, d = 1e-9;
|
|
@@ -259,74 +275,13 @@ function Ee(e, t, n, r) {
|
|
|
259
275
|
tj: u
|
|
260
276
|
};
|
|
261
277
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
for (let t = 0; t < n; t++) {
|
|
267
|
-
let a = e[t], o = e[(t + 1) % n];
|
|
268
|
-
for (let s = t + 2; s < n; s++) {
|
|
269
|
-
if (t === 0 && s === n - 1) continue;
|
|
270
|
-
let c = Ee(a, o, e[s], e[(s + 1) % n]);
|
|
271
|
-
c && (r[t].push({
|
|
272
|
-
t: c.ti,
|
|
273
|
-
id: i
|
|
274
|
-
}), r[s].push({
|
|
275
|
-
t: c.tj,
|
|
276
|
-
id: i
|
|
277
|
-
}), i++);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (!i) return [e];
|
|
281
|
-
let a = [];
|
|
282
|
-
for (let t = 0; t < n; t++) {
|
|
283
|
-
let i = e[t], o = e[(t + 1) % n];
|
|
284
|
-
a.push({
|
|
285
|
-
p: i,
|
|
286
|
-
inter: -1
|
|
287
|
-
});
|
|
288
|
-
for (let e of r[t].sort((e, t) => e.t - t.t)) a.push({
|
|
289
|
-
p: {
|
|
290
|
-
x: i.x + (o.x - i.x) * e.t,
|
|
291
|
-
y: i.y + (o.y - i.y) * e.t
|
|
292
|
-
},
|
|
293
|
-
inter: e.id
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
let o = a.length, s = /* @__PURE__ */ new Map();
|
|
297
|
-
a.forEach((e, t) => {
|
|
298
|
-
if (e.inter >= 0) {
|
|
299
|
-
let n = s.get(e.inter) ?? [];
|
|
300
|
-
n.push(t), s.set(e.inter, n);
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
let c = Array(o).fill(!1), l = [];
|
|
304
|
-
for (let e = 0; e < o; e++) {
|
|
305
|
-
if (c[e] || a[e].inter >= 0) continue;
|
|
306
|
-
let t = [], n = e, r = 0;
|
|
307
|
-
for (; r++ <= o;) {
|
|
308
|
-
c[n] = !0, t.push(a[n].p);
|
|
309
|
-
let i = (n + 1) % o;
|
|
310
|
-
for (; a[i].inter >= 0 && !c[i] && r++ <= o;) {
|
|
311
|
-
t.push(a[i].p), c[i] = !0;
|
|
312
|
-
let e = s.get(a[i].inter), n = e && (e[0] === i ? e[1] : e[0]);
|
|
313
|
-
if (n === void 0) break;
|
|
314
|
-
i = (n + 1) % o;
|
|
315
|
-
}
|
|
316
|
-
if (i === e || c[i]) break;
|
|
317
|
-
n = i;
|
|
318
|
-
}
|
|
319
|
-
t.length >= 3 && l.push(t);
|
|
320
|
-
}
|
|
321
|
-
return l.length ? l : [e];
|
|
322
|
-
}
|
|
323
|
-
var Oe = (e, t) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY, ke = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), G = (e, t, n) => ke(e, t, n) === 0 && Math.min(e.x, t.x) <= n.x && n.x <= Math.max(e.x, t.x) && Math.min(e.y, t.y) <= n.y && n.y <= Math.max(e.y, t.y);
|
|
324
|
-
function Ae(e, t, n, r) {
|
|
325
|
-
let i = ke(n, r, e), a = ke(n, r, t), o = ke(e, t, n), s = ke(e, t, r);
|
|
326
|
-
return (i > 0 && a < 0 || i < 0 && a > 0) && (o > 0 && s < 0 || o < 0 && s > 0) ? !0 : G(n, r, e) || G(n, r, t) || G(e, t, n) || G(e, t, r);
|
|
278
|
+
var Ee = (e, t) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY, De = (e, t, n) => (t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x), Oe = (e, t, n) => De(e, t, n) === 0 && Math.min(e.x, t.x) <= n.x && n.x <= Math.max(e.x, t.x) && Math.min(e.y, t.y) <= n.y && n.y <= Math.max(e.y, t.y);
|
|
279
|
+
function ke(e, t, n, r) {
|
|
280
|
+
let i = De(n, r, e), a = De(n, r, t), o = De(e, t, n), s = De(e, t, r);
|
|
281
|
+
return (i > 0 && a < 0 || i < 0 && a > 0) && (o > 0 && s < 0 || o < 0 && s > 0) ? !0 : Oe(n, r, e) || Oe(n, r, t) || Oe(e, t, n) || Oe(e, t, r);
|
|
327
282
|
}
|
|
328
|
-
function
|
|
329
|
-
if (
|
|
283
|
+
function G(e, t, n) {
|
|
284
|
+
if (Ee(e, n) || Ee(t, n)) return !0;
|
|
330
285
|
let r = {
|
|
331
286
|
x: n.minX,
|
|
332
287
|
y: n.minY
|
|
@@ -340,9 +295,9 @@ function je(e, t, n) {
|
|
|
340
295
|
x: n.minX,
|
|
341
296
|
y: n.maxY
|
|
342
297
|
};
|
|
343
|
-
return
|
|
298
|
+
return ke(e, t, r, i) || ke(e, t, i, a) || ke(e, t, a, o) || ke(e, t, o, r);
|
|
344
299
|
}
|
|
345
|
-
function
|
|
300
|
+
function Ae(e, t) {
|
|
346
301
|
let n = !1;
|
|
347
302
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
348
303
|
let a = t[r], o = t[i];
|
|
@@ -350,19 +305,19 @@ function Me(e, t) {
|
|
|
350
305
|
}
|
|
351
306
|
return n;
|
|
352
307
|
}
|
|
353
|
-
function
|
|
354
|
-
if (e.some((e) =>
|
|
308
|
+
function je(e, t, n) {
|
|
309
|
+
if (e.some((e) => Ee(e, t))) return !0;
|
|
355
310
|
let r = n ? e.length : e.length - 1;
|
|
356
|
-
for (let n = 0; n < r; n += 1) if (
|
|
311
|
+
for (let n = 0; n < r; n += 1) if (G(e[n], e[(n + 1) % e.length], t)) return !0;
|
|
357
312
|
return !1;
|
|
358
313
|
}
|
|
359
|
-
function
|
|
314
|
+
function Me(e, t) {
|
|
360
315
|
let n = e.points;
|
|
361
316
|
if (!n.length) return !1;
|
|
362
317
|
let r = H(n);
|
|
363
318
|
if (r.minX > t.maxX || r.maxX < t.minX || r.minY > t.maxY || r.maxY < t.minY) return !1;
|
|
364
319
|
switch (e.type) {
|
|
365
|
-
case L.POINT: return
|
|
320
|
+
case L.POINT: return Ee(n[0], t);
|
|
366
321
|
case L.RECTANGLE: return !0;
|
|
367
322
|
case L.ELLIPSE: {
|
|
368
323
|
let e = (r.maxX - r.minX) / 2, n = (r.maxY - r.minY) / 2;
|
|
@@ -370,31 +325,110 @@ function Ne(e, t) {
|
|
|
370
325
|
let i = (r.minX + r.maxX) / 2, a = (r.minY + r.maxY) / 2, o = V(i, t.minX, t.maxX), s = V(a, t.minY, t.maxY);
|
|
371
326
|
return ((o - i) / e) ** 2 + ((s - a) / n) ** 2 <= 1;
|
|
372
327
|
}
|
|
373
|
-
case L.LINE: return
|
|
328
|
+
case L.LINE: return je(n, t, !1);
|
|
374
329
|
case L.POLYGON:
|
|
375
|
-
case L.ROTATED_RECTANGLE: return
|
|
330
|
+
case L.ROTATED_RECTANGLE: return je(n, t, !0) || n.length >= 3 && Ae({
|
|
376
331
|
x: t.minX,
|
|
377
332
|
y: t.minY
|
|
378
333
|
}, n);
|
|
379
334
|
default: return !0;
|
|
380
335
|
}
|
|
381
336
|
}
|
|
337
|
+
var K = (e) => {
|
|
338
|
+
let t = 0;
|
|
339
|
+
for (let n = 0, r = e.length - 1; n < e.length; r = n++) t += (e[r].x - e[n].x) * (e[r].y + e[n].y);
|
|
340
|
+
return t / 2;
|
|
341
|
+
};
|
|
342
|
+
function Ne(e, t, n, r) {
|
|
343
|
+
let i = 0, a = n.length;
|
|
344
|
+
for (let o = 0, s = a - 1; o < a; s = o++) {
|
|
345
|
+
let a = n[s], c = n[o], l = (a.x - e.x) * t.y - (a.y - e.y) * t.x, u = (c.x - e.x) * t.y - (c.y - e.y) * t.x;
|
|
346
|
+
if (l > 0 == u > 0) continue;
|
|
347
|
+
let d = (a.x - e.x) * t.x + (a.y - e.y) * t.y;
|
|
348
|
+
d + ((c.x - e.x) * t.x + (c.y - e.y) * t.y - d) * l / (l - u) > r && (i += l > 0 ? -1 : 1);
|
|
349
|
+
}
|
|
350
|
+
return i;
|
|
351
|
+
}
|
|
382
352
|
function Pe(e) {
|
|
383
|
-
|
|
353
|
+
let t = e[0], n = e[1], r = -(n.y - t.y), i = n.x - t.x;
|
|
354
|
+
K(e) < 0 && (r = -r, i = -i);
|
|
355
|
+
let a = Math.hypot(r, i);
|
|
356
|
+
return a ? {
|
|
357
|
+
x: r / a,
|
|
358
|
+
y: i / a
|
|
359
|
+
} : null;
|
|
360
|
+
}
|
|
361
|
+
function Fe(e, t = 4096) {
|
|
362
|
+
let n = [{
|
|
384
363
|
outline: e,
|
|
385
|
-
holes: []
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
364
|
+
holes: [],
|
|
365
|
+
layers: 1
|
|
366
|
+
}], r = e.length;
|
|
367
|
+
if (r < 4 || r > t) return n;
|
|
368
|
+
let i = Te(e);
|
|
369
|
+
if (!i.length) return n;
|
|
370
|
+
let a = Array.from({ length: r }, () => []);
|
|
371
|
+
for (let t of i) {
|
|
372
|
+
let n = e[t.i], i = e[(t.i + 1) % r], o = {
|
|
373
|
+
x: n.x + (i.x - n.x) * t.ti,
|
|
374
|
+
y: n.y + (i.y - n.y) * t.ti
|
|
375
|
+
};
|
|
376
|
+
a[t.i].push({
|
|
377
|
+
t: t.ti,
|
|
378
|
+
p: o
|
|
379
|
+
}), a[t.j].push({
|
|
380
|
+
t: t.tj,
|
|
381
|
+
p: o
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
let o = [];
|
|
385
|
+
for (let t = 0; t < r; t++) {
|
|
386
|
+
o.push(e[t]);
|
|
387
|
+
for (let e of a[t].sort((e, t) => e.t - t.t)) o.push(e.p);
|
|
388
|
+
}
|
|
389
|
+
let s = /* @__PURE__ */ new Map(), c = [], l = (e) => {
|
|
390
|
+
let t = s.get(e);
|
|
391
|
+
return t === void 0 && (t = c.length, s.set(e, t), c.push(e)), t;
|
|
392
|
+
}, u = o.length, d = [], f = [];
|
|
393
|
+
for (let e = 0; e < u; e++) {
|
|
394
|
+
let t = l(o[e]), n = l(o[(e + 1) % u]);
|
|
395
|
+
t !== n && (d.push(t, n), f.push(n, t));
|
|
396
|
+
}
|
|
397
|
+
let p = d.length;
|
|
398
|
+
if (!p) return n;
|
|
399
|
+
let m = Array.from({ length: c.length }, () => []);
|
|
400
|
+
for (let e = 0; e < p; e++) m[d[e]].push(e);
|
|
401
|
+
for (let e of m) e.sort((e, t) => Math.atan2(c[f[e]].y - c[d[e]].y, c[f[e]].x - c[d[e]].x) - Math.atan2(c[f[t]].y - c[d[t]].y, c[f[t]].x - c[d[t]].x));
|
|
402
|
+
let h = (e) => e % 2 == 0 ? e + 1 : e - 1, g = (e) => {
|
|
403
|
+
let t = m[f[e]];
|
|
404
|
+
return t[(t.indexOf(h(e)) - 1 + t.length) % t.length];
|
|
405
|
+
}, _ = Array(p).fill(!1), v = [];
|
|
406
|
+
for (let e = 0; e < p; e++) {
|
|
407
|
+
if (_[e]) continue;
|
|
408
|
+
let t = [], n = e, r = 0;
|
|
409
|
+
do
|
|
410
|
+
_[n] = !0, t.push(c[d[n]]), n = g(n);
|
|
411
|
+
while (n !== e && !_[n] && r++ <= p);
|
|
412
|
+
t.length >= 3 && v.push(t);
|
|
413
|
+
}
|
|
414
|
+
let y = v.map(K), b = Math.sign(y.reduce((e, t) => Math.abs(t) > Math.abs(e) ? t : e, 0)), x = v.map((e, t) => t).filter((e) => Math.sign(y[e]) === -b), S = /* @__PURE__ */ new Set();
|
|
415
|
+
for (let e of a) for (let t of e) S.add(t.p);
|
|
416
|
+
let C = (e) => {
|
|
417
|
+
let t = 0, n = /* @__PURE__ */ new Set();
|
|
418
|
+
for (let r of e) S.has(r) && !n.has(r) && (n.add(r), t++);
|
|
419
|
+
return t;
|
|
420
|
+
}, w = [];
|
|
421
|
+
for (let t of x) {
|
|
422
|
+
let n = Pe(v[t]);
|
|
423
|
+
if (!n) continue;
|
|
424
|
+
let r = v[t][0], i = v[t][1], a = 1e-9 * (Math.abs(r.x - i.x) + Math.abs(r.y - i.y) + 1), o = Math.abs(Ne(ve(r, i), n, e, a));
|
|
425
|
+
o % 2 == 0 && C(v[t]) === 1 || w.push({
|
|
426
|
+
outline: v[t],
|
|
427
|
+
holes: [],
|
|
428
|
+
layers: Math.max(1, o)
|
|
392
429
|
});
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
let i = n[t].filter((e) => n[e].length % 2 == 0).sort((e, t) => n[t].length - n[e].length);
|
|
396
|
-
(i.length ? r.get(i[0]) : void 0)?.holes.push(e);
|
|
397
|
-
}), [...r.values()];
|
|
430
|
+
}
|
|
431
|
+
return w.length ? w : n;
|
|
398
432
|
}
|
|
399
433
|
//#endregion
|
|
400
434
|
//#region src/components/ShapeEditor/_model/strings.ts
|
|
@@ -439,6 +473,7 @@ var q = {
|
|
|
439
473
|
toggleMinimap: "미니맵 접기/펼치기"
|
|
440
474
|
},
|
|
441
475
|
imageLoading: "이미지를 불러오는 중…",
|
|
476
|
+
imageMissing: "표시할 이미지가 없습니다",
|
|
442
477
|
imageLoadError: "이미지를 불러올 수 없습니다",
|
|
443
478
|
imageErrorHints: {
|
|
444
479
|
"mixed-content": "HTTPS 페이지에서 HTTP 이미지 요청은 혼합 콘텐츠 정책에 따라 차단됩니다. 이미지 스토리지의 HTTPS 전환이 필요합니다.",
|
|
@@ -459,7 +494,7 @@ var q = {
|
|
|
459
494
|
unknown: "원인이 특정되지 않은 오류입니다. 아래 상세 정보와 함께 기술 지원에 문의하시기 바랍니다."
|
|
460
495
|
}
|
|
461
496
|
};
|
|
462
|
-
function
|
|
497
|
+
function Ie(e) {
|
|
463
498
|
return e ? {
|
|
464
499
|
contextMenu: {
|
|
465
500
|
...q.contextMenu,
|
|
@@ -474,6 +509,7 @@ function Fe(e) {
|
|
|
474
509
|
...e.minimap
|
|
475
510
|
},
|
|
476
511
|
imageLoading: e.imageLoading ?? q.imageLoading,
|
|
512
|
+
imageMissing: e.imageMissing ?? q.imageMissing,
|
|
477
513
|
imageLoadError: e.imageLoadError ?? q.imageLoadError,
|
|
478
514
|
imageErrorHints: {
|
|
479
515
|
...q.imageErrorHints,
|
|
@@ -495,7 +531,7 @@ var J = {
|
|
|
495
531
|
ASSISTANT_POLYGON: "ASSISTANT_POLYGON",
|
|
496
532
|
ASSISTANT_RECT: "ASSISTANT_RECT",
|
|
497
533
|
ASSISTANT_POINT: "ASSISTANT_POINT"
|
|
498
|
-
},
|
|
534
|
+
}, Le = {
|
|
499
535
|
brightness: 1,
|
|
500
536
|
contrast: 1,
|
|
501
537
|
showCursorGuide: !1,
|
|
@@ -507,9 +543,9 @@ var J = {
|
|
|
507
543
|
keepZoomOnImageChange: !1,
|
|
508
544
|
wheelZoom: !0,
|
|
509
545
|
zoomSensitivity: 1
|
|
510
|
-
},
|
|
511
|
-
function
|
|
512
|
-
let t = e.positive ?
|
|
546
|
+
}, Re = "var(--editor-overlay-inverse-scale, 1)", ze = "#377be2", Be = "#e23c3c";
|
|
547
|
+
function Ve({ point: e }) {
|
|
548
|
+
let t = e.positive ? ze : Be;
|
|
513
549
|
return /* @__PURE__ */ v("div", {
|
|
514
550
|
style: {
|
|
515
551
|
position: "absolute",
|
|
@@ -530,13 +566,13 @@ function Be({ point: e }) {
|
|
|
530
566
|
display: "flex",
|
|
531
567
|
alignItems: "center",
|
|
532
568
|
justifyContent: "center",
|
|
533
|
-
transform: `scale(${
|
|
569
|
+
transform: `scale(${Re})`,
|
|
534
570
|
transformOrigin: "center"
|
|
535
571
|
},
|
|
536
572
|
children: e.positive ? "+" : "−"
|
|
537
573
|
});
|
|
538
574
|
}
|
|
539
|
-
function
|
|
575
|
+
function He({ image: e, points: t, boxes: n, status: r }) {
|
|
540
576
|
return /* @__PURE__ */ y("div", {
|
|
541
577
|
style: {
|
|
542
578
|
position: "absolute",
|
|
@@ -560,13 +596,13 @@ function Ve({ image: e, points: t, boxes: n, status: r }) {
|
|
|
560
596
|
backgroundSize: "200% 100%",
|
|
561
597
|
animation: "editorv2-assistant-shimmer 1.4s linear infinite"
|
|
562
598
|
} }, `box-${t}-${e.x}-${e.y}-${e.width}-${e.height}`)),
|
|
563
|
-
r === "loading" && t.map((e, t) => /* @__PURE__ */ v(
|
|
599
|
+
r === "loading" && t.map((e, t) => /* @__PURE__ */ v(Ve, { point: e }, `pt-${t}-${e.x}-${e.y}`))
|
|
564
600
|
]
|
|
565
601
|
});
|
|
566
602
|
}
|
|
567
603
|
//#endregion
|
|
568
604
|
//#region src/components/ShapeEditor/_components/ContextMenu.tsx
|
|
569
|
-
function
|
|
605
|
+
function Ue(e) {
|
|
570
606
|
let t = [];
|
|
571
607
|
for (let n of e) if ("separator" in n) {
|
|
572
608
|
if (!t.length || "separator" in t[t.length - 1]) continue;
|
|
@@ -575,8 +611,8 @@ function He(e) {
|
|
|
575
611
|
for (; t.length && "separator" in t[t.length - 1];) t.pop();
|
|
576
612
|
return t;
|
|
577
613
|
}
|
|
578
|
-
function
|
|
579
|
-
let i =
|
|
614
|
+
function We({ x: e, y: t, items: n, onClose: r }) {
|
|
615
|
+
let i = Ue(n);
|
|
580
616
|
return /* @__PURE__ */ y(p, {
|
|
581
617
|
open: !0,
|
|
582
618
|
modal: !1,
|
|
@@ -627,7 +663,7 @@ function Ue({ x: e, y: t, items: n, onClose: r }) {
|
|
|
627
663
|
}
|
|
628
664
|
//#endregion
|
|
629
665
|
//#region src/components/ShapeEditor/_components/CursorGuide.tsx
|
|
630
|
-
function
|
|
666
|
+
function Ge({ color: e = "#1e88e5" }) {
|
|
631
667
|
let t = O(null), n = O(null), r = O(null);
|
|
632
668
|
return S(() => {
|
|
633
669
|
let e = t.current, i = n.current, a = r.current;
|
|
@@ -677,10 +713,10 @@ function We({ color: e = "#1e88e5" }) {
|
|
|
677
713
|
}
|
|
678
714
|
//#endregion
|
|
679
715
|
//#region src/components/ShapeEditor/_components/ImageStateOverlay.tsx
|
|
680
|
-
function
|
|
681
|
-
let
|
|
716
|
+
function Ke({ status: e, error: t, render: n, loadingLabel: r = q.imageLoading, missingLabel: i = q.imageMissing, errorLabel: a = q.imageLoadError, errorHints: o = q.imageErrorHints }) {
|
|
717
|
+
let s = n?.(e, t) ?? null;
|
|
682
718
|
return /* @__PURE__ */ v("div", {
|
|
683
|
-
"data-track-id": e === "loading" ? "editor-image-loading-wrap" : "editor-image-error-wrap",
|
|
719
|
+
"data-track-id": e === "loading" ? "editor-image-loading-wrap" : e === "missing" ? "editor-image-missing-wrap" : "editor-image-error-wrap",
|
|
684
720
|
style: {
|
|
685
721
|
position: "absolute",
|
|
686
722
|
inset: 0,
|
|
@@ -693,7 +729,13 @@ function Ge({ status: e, error: t, render: n, loadingLabel: r = q.imageLoading,
|
|
|
693
729
|
fontFamily: "Pretendard, sans-serif",
|
|
694
730
|
pointerEvents: e === "error" ? "auto" : "none"
|
|
695
731
|
},
|
|
696
|
-
children:
|
|
732
|
+
children: s === null ? e === "missing" ? /* @__PURE__ */ v("div", {
|
|
733
|
+
style: {
|
|
734
|
+
fontSize: 13,
|
|
735
|
+
opacity: .75
|
|
736
|
+
},
|
|
737
|
+
children: i
|
|
738
|
+
}) : e === "loading" ? /* @__PURE__ */ y("div", {
|
|
697
739
|
style: {
|
|
698
740
|
display: "flex",
|
|
699
741
|
alignItems: "center",
|
|
@@ -729,7 +771,7 @@ function Ge({ status: e, error: t, render: n, loadingLabel: r = q.imageLoading,
|
|
|
729
771
|
}),
|
|
730
772
|
/* @__PURE__ */ v("div", {
|
|
731
773
|
style: { fontSize: 13 },
|
|
732
|
-
children:
|
|
774
|
+
children: a
|
|
733
775
|
}),
|
|
734
776
|
t && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("div", {
|
|
735
777
|
style: {
|
|
@@ -738,7 +780,7 @@ function Ge({ status: e, error: t, render: n, loadingLabel: r = q.imageLoading,
|
|
|
738
780
|
opacity: .8,
|
|
739
781
|
lineHeight: 1.5
|
|
740
782
|
},
|
|
741
|
-
children:
|
|
783
|
+
children: o[t.kind]
|
|
742
784
|
}), /* @__PURE__ */ v("div", {
|
|
743
785
|
style: {
|
|
744
786
|
fontSize: 11,
|
|
@@ -750,15 +792,15 @@ function Ge({ status: e, error: t, render: n, loadingLabel: r = q.imageLoading,
|
|
|
750
792
|
children: t.detail
|
|
751
793
|
})] })
|
|
752
794
|
]
|
|
753
|
-
}) :
|
|
795
|
+
}) : s
|
|
754
796
|
});
|
|
755
797
|
}
|
|
756
798
|
Math.PI / 12;
|
|
757
|
-
var
|
|
799
|
+
var qe = "#00ff00", Je = "rgba(0, 255, 0, 0.1)", Ye = "#669DEF", Xe = .1, Ze = [3, 3];
|
|
758
800
|
//#endregion
|
|
759
801
|
//#region src/components/ShapeEditor/_model/shapeRenderStyle.ts
|
|
760
|
-
function
|
|
761
|
-
let n = e.style?.color ?? "#00e5ff", r = e.style?.strokeWidth ?? t.strokeWidth ?? 2, i = e.style?.opacity ?? 1, a = e.style?.fillOpacity ?? .12549019607843137, o = e.style?.dash ?? (e.style?.dashed ? [r *
|
|
802
|
+
function Qe(e, t = {}) {
|
|
803
|
+
let n = e.style?.color ?? "#00e5ff", r = e.style?.strokeWidth ?? t.strokeWidth ?? 2, i = e.style?.opacity ?? 1, a = e.style?.fillOpacity ?? .12549019607843137, o = e.style?.dash ?? (e.style?.dashed ? [r * Ze[0], r * Ze[1]] : void 0);
|
|
762
804
|
return {
|
|
763
805
|
color: n,
|
|
764
806
|
strokeWidth: r,
|
|
@@ -769,7 +811,7 @@ function Ze(e, t = {}) {
|
|
|
769
811
|
pointRadius: e.style?.pointRadius ?? t.pointRadius ?? 5
|
|
770
812
|
};
|
|
771
813
|
}
|
|
772
|
-
function
|
|
814
|
+
function $e(e, t) {
|
|
773
815
|
let n = Math.max(0, Math.min(1, t)), r = e.trim().replace("#", "");
|
|
774
816
|
if (r.length === 3 || r.length === 6) {
|
|
775
817
|
let e = r.length === 3 ? r.replace(/./g, (e) => e + e) : r, t = Number.parseInt(e, 16);
|
|
@@ -779,8 +821,8 @@ function Qe(e, t) {
|
|
|
779
821
|
}
|
|
780
822
|
//#endregion
|
|
781
823
|
//#region src/components/ShapeEditor/_components/MinimapShape.tsx
|
|
782
|
-
var
|
|
783
|
-
let { type: r, points: i } = e, a =
|
|
824
|
+
var et = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
825
|
+
let { type: r, points: i } = e, a = Qe(e, { strokeWidth: t }), o = (t) => n?.(e.id, t), s = {
|
|
784
826
|
ref: o,
|
|
785
827
|
stroke: a.color,
|
|
786
828
|
strokeWidth: a.strokeWidth,
|
|
@@ -826,7 +868,7 @@ var $e = b(function({ shape: e, strokeSize: t, register: n }) {
|
|
|
826
868
|
});
|
|
827
869
|
//#endregion
|
|
828
870
|
//#region src/components/ShapeEditor/_components/RegionOverlay.tsx
|
|
829
|
-
function
|
|
871
|
+
function tt({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth: a, strokeDasharray: o, style: s }) {
|
|
830
872
|
let c = [...t.visibleOutline, ...t.occludedOutline];
|
|
831
873
|
return /* @__PURE__ */ y("svg", {
|
|
832
874
|
width: r,
|
|
@@ -880,7 +922,7 @@ function et({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth:
|
|
|
880
922
|
}
|
|
881
923
|
//#endregion
|
|
882
924
|
//#region src/components/ShapeEditor/_components/SettingsPanel.tsx
|
|
883
|
-
function
|
|
925
|
+
function nt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.viewSettings, openDown: f = !1, alignEnd: p = !1 }) {
|
|
884
926
|
return S(() => {
|
|
885
927
|
let e = (e) => {
|
|
886
928
|
e.key === "Escape" && c();
|
|
@@ -899,7 +941,7 @@ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.view
|
|
|
899
941
|
/* @__PURE__ */ y("div", {
|
|
900
942
|
className: "aivex:flex aivex:flex-col aivex:gap-md",
|
|
901
943
|
children: [
|
|
902
|
-
/* @__PURE__ */ v(
|
|
944
|
+
/* @__PURE__ */ v(rt, {
|
|
903
945
|
icon: /* @__PURE__ */ v(r, { size: 16 }),
|
|
904
946
|
label: d.brightness,
|
|
905
947
|
value: i.brightness.toFixed(2),
|
|
@@ -911,7 +953,7 @@ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.view
|
|
|
911
953
|
onValueChange: ([e]) => s({ brightness: e })
|
|
912
954
|
})
|
|
913
955
|
}),
|
|
914
|
-
/* @__PURE__ */ v(
|
|
956
|
+
/* @__PURE__ */ v(rt, {
|
|
915
957
|
icon: /* @__PURE__ */ v(n, { size: 16 }),
|
|
916
958
|
label: d.contrast,
|
|
917
959
|
value: i.contrast.toFixed(2),
|
|
@@ -923,7 +965,7 @@ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.view
|
|
|
923
965
|
onValueChange: ([e]) => s({ contrast: e })
|
|
924
966
|
})
|
|
925
967
|
}),
|
|
926
|
-
/* @__PURE__ */ v(
|
|
968
|
+
/* @__PURE__ */ v(rt, {
|
|
927
969
|
icon: /* @__PURE__ */ v(t, { size: 16 }),
|
|
928
970
|
label: d.strokeSize,
|
|
929
971
|
value: String(i.strokeSize),
|
|
@@ -935,7 +977,7 @@ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.view
|
|
|
935
977
|
onValueChange: ([e]) => s({ strokeSize: e })
|
|
936
978
|
})
|
|
937
979
|
}),
|
|
938
|
-
/* @__PURE__ */ v(
|
|
980
|
+
/* @__PURE__ */ v(rt, {
|
|
939
981
|
icon: /* @__PURE__ */ v(e, { size: 16 }),
|
|
940
982
|
label: d.simplifyStrength,
|
|
941
983
|
value: String(i.simplifyStrength),
|
|
@@ -947,7 +989,7 @@ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.view
|
|
|
947
989
|
onValueChange: ([e]) => s({ simplifyStrength: e })
|
|
948
990
|
})
|
|
949
991
|
}),
|
|
950
|
-
/* @__PURE__ */ v(
|
|
992
|
+
/* @__PURE__ */ v(rt, {
|
|
951
993
|
icon: /* @__PURE__ */ v(l, { size: 16 }),
|
|
952
994
|
label: d.zoomSensitivity,
|
|
953
995
|
value: i.zoomSensitivity.toFixed(1),
|
|
@@ -962,32 +1004,32 @@ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.view
|
|
|
962
1004
|
/* @__PURE__ */ y("div", {
|
|
963
1005
|
className: "aivex:flex aivex:flex-col aivex:gap-xs",
|
|
964
1006
|
children: [
|
|
965
|
-
/* @__PURE__ */ v(
|
|
1007
|
+
/* @__PURE__ */ v(it, {
|
|
966
1008
|
label: d.pixelation,
|
|
967
1009
|
checked: !i.imageSmoothing,
|
|
968
1010
|
onChange: (e) => s({ imageSmoothing: !e })
|
|
969
1011
|
}),
|
|
970
|
-
/* @__PURE__ */ v(
|
|
1012
|
+
/* @__PURE__ */ v(it, {
|
|
971
1013
|
label: d.cursorGuide,
|
|
972
1014
|
checked: i.showCursorGuide,
|
|
973
1015
|
onChange: (e) => s({ showCursorGuide: e })
|
|
974
1016
|
}),
|
|
975
|
-
/* @__PURE__ */ v(
|
|
1017
|
+
/* @__PURE__ */ v(it, {
|
|
976
1018
|
label: d.guideMask,
|
|
977
1019
|
checked: i.showGuide,
|
|
978
1020
|
onChange: (e) => s({ showGuide: e })
|
|
979
1021
|
}),
|
|
980
|
-
/* @__PURE__ */ v(
|
|
1022
|
+
/* @__PURE__ */ v(it, {
|
|
981
1023
|
label: d.regionMask,
|
|
982
1024
|
checked: i.showRegionMask,
|
|
983
1025
|
onChange: (e) => s({ showRegionMask: e })
|
|
984
1026
|
}),
|
|
985
|
-
/* @__PURE__ */ v(
|
|
1027
|
+
/* @__PURE__ */ v(it, {
|
|
986
1028
|
label: d.keepZoomOnImageChange,
|
|
987
1029
|
checked: i.keepZoomOnImageChange,
|
|
988
1030
|
onChange: (e) => s({ keepZoomOnImageChange: e })
|
|
989
1031
|
}),
|
|
990
|
-
/* @__PURE__ */ v(
|
|
1032
|
+
/* @__PURE__ */ v(it, {
|
|
991
1033
|
label: d.wheelZoom,
|
|
992
1034
|
checked: i.wheelZoom,
|
|
993
1035
|
onChange: (e) => s({ wheelZoom: e })
|
|
@@ -1010,7 +1052,7 @@ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.view
|
|
|
1010
1052
|
]
|
|
1011
1053
|
});
|
|
1012
1054
|
}
|
|
1013
|
-
function
|
|
1055
|
+
function rt({ icon: e, label: t, value: n, children: r }) {
|
|
1014
1056
|
return /* @__PURE__ */ y("div", {
|
|
1015
1057
|
className: "aivex:flex aivex:flex-col aivex:px-md aivex:py-2xs",
|
|
1016
1058
|
children: [/* @__PURE__ */ y("div", {
|
|
@@ -1035,7 +1077,7 @@ function nt({ icon: e, label: t, value: n, children: r }) {
|
|
|
1035
1077
|
})]
|
|
1036
1078
|
});
|
|
1037
1079
|
}
|
|
1038
|
-
function
|
|
1080
|
+
function it({ label: e, checked: t, onChange: n }) {
|
|
1039
1081
|
return /* @__PURE__ */ y("div", {
|
|
1040
1082
|
className: "aivex:flex aivex:items-center aivex:gap-md aivex:rounded-md aivex:px-md aivex:py-sm",
|
|
1041
1083
|
children: [/* @__PURE__ */ v("span", {
|
|
@@ -1050,12 +1092,12 @@ function rt({ label: e, checked: t, onChange: n }) {
|
|
|
1050
1092
|
}
|
|
1051
1093
|
//#endregion
|
|
1052
1094
|
//#region src/components/ShapeEditor/_components/Minimap.tsx
|
|
1053
|
-
var
|
|
1095
|
+
var at = {
|
|
1054
1096
|
"bottom-left": "aivex:bottom-2 aivex:left-2",
|
|
1055
1097
|
"bottom-right": "aivex:bottom-2 aivex:right-2",
|
|
1056
1098
|
"top-left": "aivex:top-2 aivex:left-2",
|
|
1057
1099
|
"top-right": "aivex:top-2 aivex:right-2"
|
|
1058
|
-
},
|
|
1100
|
+
}, ot = b(function({ image: e, imageUrl: t, imageVisible: n = !0, loading: r = !1, maskDataUrl: a, region: o, roiMaskId: l, shapes: p, view: m, viewDefaults: h, onChangeView: g, nav: _, registerShape: b, rectRef: x, zoomLabelRef: S, onZoom100: C, open: w, onToggleOpen: T, position: E = "bottom-left", showSettings: D = !0, settingsOpen: O, onToggleSettings: k, onCloseSettings: A, labels: j = q.minimap, settingsLabels: M }) {
|
|
1059
1101
|
let { offX: N, offY: P, dispW: F, dispH: ee, zoomCentered: te } = _, I = E.startsWith("top"), L = {
|
|
1060
1102
|
position: "absolute",
|
|
1061
1103
|
left: N,
|
|
@@ -1103,7 +1145,7 @@ var it = {
|
|
|
1103
1145
|
pointerEvents: "none"
|
|
1104
1146
|
}
|
|
1105
1147
|
}),
|
|
1106
|
-
m.showRegionMask && o && o.rects.length > 0 && /* @__PURE__ */ v(
|
|
1148
|
+
m.showRegionMask && o && o.rects.length > 0 && /* @__PURE__ */ v(tt, {
|
|
1107
1149
|
image: e,
|
|
1108
1150
|
region: o,
|
|
1109
1151
|
maskId: l,
|
|
@@ -1129,7 +1171,7 @@ var it = {
|
|
|
1129
1171
|
pointerEvents: "none"
|
|
1130
1172
|
},
|
|
1131
1173
|
"aria-hidden": !0,
|
|
1132
|
-
children: B(p).filter(ne).map((e) => /* @__PURE__ */ v(
|
|
1174
|
+
children: B(p).filter(ne).map((e) => /* @__PURE__ */ v(et, {
|
|
1133
1175
|
shape: e,
|
|
1134
1176
|
strokeSize: m.strokeSize,
|
|
1135
1177
|
register: b
|
|
@@ -1139,8 +1181,8 @@ var it = {
|
|
|
1139
1181
|
ref: x,
|
|
1140
1182
|
style: {
|
|
1141
1183
|
position: "absolute",
|
|
1142
|
-
border: `1px solid ${
|
|
1143
|
-
background:
|
|
1184
|
+
border: `1px solid ${qe}`,
|
|
1185
|
+
background: Je,
|
|
1144
1186
|
boxSizing: "border-box",
|
|
1145
1187
|
pointerEvents: "none"
|
|
1146
1188
|
}
|
|
@@ -1189,7 +1231,7 @@ var it = {
|
|
|
1189
1231
|
onPointerDown: (e) => e.stopPropagation(),
|
|
1190
1232
|
className: O ? "aivex:text-text-brand" : void 0,
|
|
1191
1233
|
children: /* @__PURE__ */ v(d, { size: 20 })
|
|
1192
|
-
}), O && /* @__PURE__ */ v(
|
|
1234
|
+
}), O && /* @__PURE__ */ v(nt, {
|
|
1193
1235
|
value: m,
|
|
1194
1236
|
defaults: h,
|
|
1195
1237
|
onChange: g,
|
|
@@ -1213,10 +1255,10 @@ var it = {
|
|
|
1213
1255
|
]
|
|
1214
1256
|
});
|
|
1215
1257
|
return /* @__PURE__ */ y("div", {
|
|
1216
|
-
className: `aivex:absolute ${
|
|
1258
|
+
className: `aivex:absolute ${at[E]} aivex:w-[220px] aivex:rounded-[12px] aivex:border aivex:border-border-subtle aivex:bg-bg-primary aivex:p-md aivex:shadow-[0_4px_12px_rgba(13,13,18,0.24)]`,
|
|
1217
1259
|
children: [I ? R : re, I ? re : R]
|
|
1218
1260
|
});
|
|
1219
|
-
}), Y = "var(--editor-overlay-inverse-scale, 1)",
|
|
1261
|
+
}), Y = "var(--editor-overlay-inverse-scale, 1)", st = 6, ct = {
|
|
1220
1262
|
fontFamily: "Pretendard, sans-serif",
|
|
1221
1263
|
fontSize: 12,
|
|
1222
1264
|
fontWeight: 500,
|
|
@@ -1234,25 +1276,25 @@ function X(e) {
|
|
|
1234
1276
|
height: t.maxY - t.minY
|
|
1235
1277
|
};
|
|
1236
1278
|
}
|
|
1237
|
-
function
|
|
1238
|
-
return `translate3d(${e.width}px, ${e.height}px, 0) scale(${Y}) translate(-100%, ${
|
|
1279
|
+
function lt(e) {
|
|
1280
|
+
return `translate3d(${e.width}px, ${e.height}px, 0) scale(${Y}) translate(-100%, ${st}px)`;
|
|
1239
1281
|
}
|
|
1240
|
-
function
|
|
1282
|
+
function ut(e, t) {
|
|
1241
1283
|
let n = X(t);
|
|
1242
1284
|
e.style.transform = `translate3d(${n.x}px, ${n.y}px, 0)`;
|
|
1243
1285
|
let r = e.querySelector("[data-selinfo-dim]");
|
|
1244
|
-
return r && (r.style.transform =
|
|
1286
|
+
return r && (r.style.transform = lt(n)), r;
|
|
1245
1287
|
}
|
|
1246
|
-
function
|
|
1288
|
+
function dt(e, t) {
|
|
1247
1289
|
return {
|
|
1248
1290
|
shape: e,
|
|
1249
1291
|
...X(t)
|
|
1250
1292
|
};
|
|
1251
1293
|
}
|
|
1252
|
-
function
|
|
1294
|
+
function ft(e) {
|
|
1253
1295
|
return `${Math.round(e.width)} x ${Math.round(e.height)} px`;
|
|
1254
1296
|
}
|
|
1255
|
-
function
|
|
1297
|
+
function pt({ color: e, striped: t }) {
|
|
1256
1298
|
return /* @__PURE__ */ v("span", { style: {
|
|
1257
1299
|
display: "inline-block",
|
|
1258
1300
|
width: 12,
|
|
@@ -1264,9 +1306,9 @@ function ft({ color: e, striped: t }) {
|
|
|
1264
1306
|
} : { background: e }
|
|
1265
1307
|
} });
|
|
1266
1308
|
}
|
|
1267
|
-
function
|
|
1309
|
+
function mt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
|
|
1268
1310
|
return /* @__PURE__ */ v(_, { children: e.map((e) => {
|
|
1269
|
-
let a = X(e.points), o = e.type === L.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u =
|
|
1311
|
+
let a = X(e.points), o = e.type === L.POINT, s = o ? void 0 : t?.(e), c = e.style?.color ?? "#00e5ff", l = !!e.style?.dashed || !!e.style?.dash, u = dt(e, e.points), d = r ? r(u) : ft(u);
|
|
1270
1312
|
return /* @__PURE__ */ y("div", {
|
|
1271
1313
|
ref: (t) => i(e.id, t),
|
|
1272
1314
|
style: {
|
|
@@ -1285,11 +1327,11 @@ function pt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1285
1327
|
display: "flex",
|
|
1286
1328
|
alignItems: "center",
|
|
1287
1329
|
gap: 4,
|
|
1288
|
-
transform: `scale(${Y}) translateY(calc(-100% - ${
|
|
1330
|
+
transform: `scale(${Y}) translateY(calc(-100% - ${st}px))`,
|
|
1289
1331
|
transformOrigin: "left top",
|
|
1290
|
-
...
|
|
1332
|
+
...ct
|
|
1291
1333
|
},
|
|
1292
|
-
children: [!n && /* @__PURE__ */ v(
|
|
1334
|
+
children: [!n && /* @__PURE__ */ v(pt, {
|
|
1293
1335
|
color: c,
|
|
1294
1336
|
striped: l
|
|
1295
1337
|
}), /* @__PURE__ */ v("span", { children: s })]
|
|
@@ -1299,10 +1341,10 @@ function pt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1299
1341
|
position: "absolute",
|
|
1300
1342
|
left: 0,
|
|
1301
1343
|
top: 0,
|
|
1302
|
-
transform:
|
|
1344
|
+
transform: lt(a),
|
|
1303
1345
|
transformOrigin: "left top",
|
|
1304
1346
|
willChange: "transform",
|
|
1305
|
-
...
|
|
1347
|
+
...ct
|
|
1306
1348
|
},
|
|
1307
1349
|
children: d
|
|
1308
1350
|
})]
|
|
@@ -1311,8 +1353,8 @@ function pt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
|
|
|
1311
1353
|
}
|
|
1312
1354
|
//#endregion
|
|
1313
1355
|
//#region src/components/ShapeEditor/_model/clipboard.ts
|
|
1314
|
-
var
|
|
1315
|
-
function
|
|
1356
|
+
var ht = "AIVEX_SHAPE_EDITOR:", gt = 1, _t = new Set(Object.values(L)), vt = null, Z = "unavailable", yt = 0;
|
|
1357
|
+
function bt(e) {
|
|
1316
1358
|
if (!e || typeof e != "object") return !1;
|
|
1317
1359
|
let t = e;
|
|
1318
1360
|
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
@@ -1320,70 +1362,70 @@ function yt(e) {
|
|
|
1320
1362
|
function Q(e) {
|
|
1321
1363
|
if (!e || typeof e != "object") return !1;
|
|
1322
1364
|
let t = e;
|
|
1323
|
-
return typeof t.type == "string" &&
|
|
1365
|
+
return typeof t.type == "string" && _t.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(bt);
|
|
1324
1366
|
}
|
|
1325
|
-
function
|
|
1367
|
+
function xt(e, t, n) {
|
|
1326
1368
|
return {
|
|
1327
1369
|
kind: "aivex-shape-editor",
|
|
1328
|
-
version:
|
|
1370
|
+
version: gt,
|
|
1329
1371
|
scope: n,
|
|
1330
1372
|
documentId: t,
|
|
1331
1373
|
shapes: e
|
|
1332
1374
|
};
|
|
1333
1375
|
}
|
|
1334
|
-
function
|
|
1376
|
+
function St(e) {
|
|
1335
1377
|
let t = 2166136261;
|
|
1336
1378
|
for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
1337
1379
|
return `fnv1a:${(t >>> 0).toString(36)}`;
|
|
1338
1380
|
}
|
|
1339
|
-
function St(e) {
|
|
1340
|
-
return `${mt}${JSON.stringify(e)}`;
|
|
1341
|
-
}
|
|
1342
1381
|
function Ct(e) {
|
|
1343
|
-
|
|
1382
|
+
return `${ht}${JSON.stringify(e)}`;
|
|
1383
|
+
}
|
|
1384
|
+
function wt(e) {
|
|
1385
|
+
if (!e.startsWith(ht)) return null;
|
|
1344
1386
|
try {
|
|
1345
1387
|
let t = JSON.parse(e.slice(19));
|
|
1346
|
-
return t.kind !== "aivex-shape-editor" || t.version !==
|
|
1388
|
+
return t.kind !== "aivex-shape-editor" || t.version !== gt || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(Q) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
|
|
1347
1389
|
} catch {
|
|
1348
1390
|
return null;
|
|
1349
1391
|
}
|
|
1350
1392
|
}
|
|
1351
|
-
function
|
|
1352
|
-
|
|
1353
|
-
let t = ++
|
|
1393
|
+
function Tt(e) {
|
|
1394
|
+
vt = e;
|
|
1395
|
+
let t = ++yt;
|
|
1354
1396
|
if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
|
|
1355
1397
|
Z = "unavailable";
|
|
1356
1398
|
return;
|
|
1357
1399
|
}
|
|
1358
1400
|
let n;
|
|
1359
1401
|
try {
|
|
1360
|
-
n =
|
|
1402
|
+
n = Ct(e);
|
|
1361
1403
|
} catch {
|
|
1362
1404
|
Z = "unavailable";
|
|
1363
1405
|
return;
|
|
1364
1406
|
}
|
|
1365
1407
|
Z = "pending", navigator.clipboard.writeText(n).then(() => {
|
|
1366
|
-
t ===
|
|
1408
|
+
t === yt && (Z = "written");
|
|
1367
1409
|
}, () => {
|
|
1368
|
-
t ===
|
|
1410
|
+
t === yt && (Z = "unavailable");
|
|
1369
1411
|
});
|
|
1370
1412
|
}
|
|
1371
|
-
function
|
|
1413
|
+
function Et(e, t) {
|
|
1372
1414
|
return !!e && e.scope === t;
|
|
1373
1415
|
}
|
|
1374
|
-
function
|
|
1375
|
-
return
|
|
1416
|
+
function Dt(e) {
|
|
1417
|
+
return Et(vt, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
|
|
1376
1418
|
}
|
|
1377
|
-
async function
|
|
1378
|
-
let t =
|
|
1419
|
+
async function Ot(e) {
|
|
1420
|
+
let t = Et(vt, e) ? vt : null;
|
|
1379
1421
|
if (t && Z !== "written") return t;
|
|
1380
1422
|
if (typeof navigator < "u" && navigator.clipboard?.readText) try {
|
|
1381
|
-
let t =
|
|
1382
|
-
return t?.scope === e ? (
|
|
1423
|
+
let t = wt(await navigator.clipboard.readText());
|
|
1424
|
+
return t?.scope === e ? (vt = t, t) : null;
|
|
1383
1425
|
} catch {}
|
|
1384
1426
|
return t;
|
|
1385
1427
|
}
|
|
1386
|
-
function
|
|
1428
|
+
function kt(e, t, n) {
|
|
1387
1429
|
return {
|
|
1388
1430
|
offset: n * (t ? e : e + 1),
|
|
1389
1431
|
nextPasteCount: e + 1
|
|
@@ -1391,7 +1433,7 @@ function Ot(e, t, n) {
|
|
|
1391
1433
|
}
|
|
1392
1434
|
//#endregion
|
|
1393
1435
|
//#region src/components/ShapeEditor/_model/cursors.ts
|
|
1394
|
-
var
|
|
1436
|
+
var At = new Set([
|
|
1395
1437
|
J.RECTANGLE,
|
|
1396
1438
|
J.ROTATED_RECTANGLE,
|
|
1397
1439
|
J.CIRCLE,
|
|
@@ -1402,7 +1444,7 @@ var kt = new Set([
|
|
|
1402
1444
|
J.ASSISTANT_POLYGON,
|
|
1403
1445
|
J.ASSISTANT_RECT,
|
|
1404
1446
|
J.ASSISTANT_POINT
|
|
1405
|
-
]),
|
|
1447
|
+
]), jt = {
|
|
1406
1448
|
tl: -135,
|
|
1407
1449
|
t: -90,
|
|
1408
1450
|
tr: -45,
|
|
@@ -1411,25 +1453,25 @@ var kt = new Set([
|
|
|
1411
1453
|
b: 90,
|
|
1412
1454
|
bl: 135,
|
|
1413
1455
|
l: 180
|
|
1414
|
-
},
|
|
1456
|
+
}, Mt = [
|
|
1415
1457
|
"ew-resize",
|
|
1416
1458
|
"nwse-resize",
|
|
1417
1459
|
"ns-resize",
|
|
1418
1460
|
"nesw-resize"
|
|
1419
|
-
],
|
|
1461
|
+
], Nt = "grab-unselected", Pt = new Set([
|
|
1420
1462
|
J.RECTANGLE,
|
|
1421
1463
|
J.ROTATED_RECTANGLE,
|
|
1422
1464
|
J.CIRCLE
|
|
1423
1465
|
]);
|
|
1424
|
-
function
|
|
1425
|
-
let n = ((
|
|
1426
|
-
return
|
|
1466
|
+
function Ft(e, t = 0) {
|
|
1467
|
+
let n = ((jt[e] + t * 180 / Math.PI) % 180 + 180) % 180;
|
|
1468
|
+
return Mt[Math.round(n / 45) % 4];
|
|
1427
1469
|
}
|
|
1428
|
-
function
|
|
1429
|
-
return n ? "grab" : t || (e === J.SELECT ? "default" :
|
|
1470
|
+
function It({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
|
|
1471
|
+
return n ? "grab" : t || (e === J.SELECT ? "default" : At.has(e) ? r ? "default" : "crosshair" : "default");
|
|
1430
1472
|
}
|
|
1431
|
-
function
|
|
1432
|
-
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === J.SELECT && i ? i === "grab-unselected" ? "grab" : i :
|
|
1473
|
+
function Lt({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
|
|
1474
|
+
return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === J.SELECT && i ? i === "grab-unselected" ? "grab" : i : Pt.has(e) && i && i !== "grab-unselected" ? i : It({
|
|
1433
1475
|
tool: e,
|
|
1434
1476
|
externalToolCursor: t,
|
|
1435
1477
|
isSpacePressed: n,
|
|
@@ -1438,7 +1480,7 @@ function It({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode
|
|
|
1438
1480
|
}
|
|
1439
1481
|
//#endregion
|
|
1440
1482
|
//#region src/components/ShapeEditor/_model/overlays.ts
|
|
1441
|
-
var
|
|
1483
|
+
var Rt = (e) => Math.min(255, Math.max(0, e)), zt = (e) => {
|
|
1442
1484
|
let t = e.replace("#", "").trim();
|
|
1443
1485
|
if (![
|
|
1444
1486
|
3,
|
|
@@ -1452,13 +1494,13 @@ var Lt = (e) => Math.min(255, Math.max(0, e)), Rt = (e) => {
|
|
|
1452
1494
|
c(o),
|
|
1453
1495
|
c(s)
|
|
1454
1496
|
];
|
|
1455
|
-
return l.some((e) => Number.isNaN(e)) ? null : l.map(
|
|
1456
|
-
},
|
|
1497
|
+
return l.some((e) => Number.isNaN(e)) ? null : l.map(Rt);
|
|
1498
|
+
}, Bt = (e, t) => {
|
|
1457
1499
|
let { width: n, height: r, indices: i, transparent: a } = e;
|
|
1458
1500
|
if (!n || !r || i.length < n * r) return null;
|
|
1459
1501
|
let o = {};
|
|
1460
1502
|
for (let [e, n] of Object.entries(t)) {
|
|
1461
|
-
let t =
|
|
1503
|
+
let t = zt(n);
|
|
1462
1504
|
t && (o[Number(e)] = t);
|
|
1463
1505
|
}
|
|
1464
1506
|
if (!Object.keys(o).length) return null;
|
|
@@ -1482,7 +1524,7 @@ function $(e, t) {
|
|
|
1482
1524
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
1483
1525
|
e.closePath();
|
|
1484
1526
|
}
|
|
1485
|
-
var
|
|
1527
|
+
var Vt = (e) => [
|
|
1486
1528
|
{
|
|
1487
1529
|
x: e.x,
|
|
1488
1530
|
y: e.y
|
|
@@ -1500,7 +1542,7 @@ var Bt = (e) => [
|
|
|
1500
1542
|
y: e.y + e.h
|
|
1501
1543
|
}
|
|
1502
1544
|
];
|
|
1503
|
-
function
|
|
1545
|
+
function Ht(e, t) {
|
|
1504
1546
|
let n = !1;
|
|
1505
1547
|
for (let r = 0, i = t.length - 1; r < t.length; i = r, r += 1) {
|
|
1506
1548
|
let a = t[r], o = t[i];
|
|
@@ -1511,7 +1553,7 @@ function Vt(e, t) {
|
|
|
1511
1553
|
}
|
|
1512
1554
|
return n;
|
|
1513
1555
|
}
|
|
1514
|
-
function
|
|
1556
|
+
function Ut(e, t, n) {
|
|
1515
1557
|
let r = [], i = t.x - e.x, a = t.y - e.y;
|
|
1516
1558
|
for (let t = 0; t < n.length; t += 1) {
|
|
1517
1559
|
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;
|
|
@@ -1521,15 +1563,15 @@ function Ht(e, t, n) {
|
|
|
1521
1563
|
}
|
|
1522
1564
|
return r;
|
|
1523
1565
|
}
|
|
1524
|
-
function
|
|
1566
|
+
function Wt(e, t, n) {
|
|
1525
1567
|
let r = .001, i = [], a = (e, t, n) => ({
|
|
1526
1568
|
x: e.x + (t.x - e.x) * n,
|
|
1527
1569
|
y: e.y + (t.y - e.y) * n
|
|
1528
1570
|
});
|
|
1529
1571
|
for (let o of e) if (!(o.length < 2)) for (let e = 0; e < o.length; e += 1) {
|
|
1530
1572
|
let s = o[e], c = o[(e + 1) % o.length], l = [0, 1];
|
|
1531
|
-
for (let e of t) e !== o && l.push(...
|
|
1532
|
-
if (n) for (let e of n) l.push(...
|
|
1573
|
+
for (let e of t) e !== o && l.push(...Ut(s, c, e));
|
|
1574
|
+
if (n) for (let e of n) l.push(...Ut(s, c, e));
|
|
1533
1575
|
let u = Math.hypot(c.x - s.x, c.y - s.y);
|
|
1534
1576
|
if (!u) continue;
|
|
1535
1577
|
let d = -(c.y - s.y) / u * r, f = (c.x - s.x) / u * r;
|
|
@@ -1543,13 +1585,13 @@ function Ut(e, t, n) {
|
|
|
1543
1585
|
}, h = {
|
|
1544
1586
|
x: p.x - d,
|
|
1545
1587
|
y: p.y - f
|
|
1546
|
-
}, g =
|
|
1547
|
-
t.some((e) => e !== o &&
|
|
1588
|
+
}, g = Ht(m, o) ? m : h, _ = g === m ? h : m;
|
|
1589
|
+
t.some((e) => e !== o && Ht(_, e)) || n && !n.some((e) => Ht(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
|
|
1548
1590
|
}
|
|
1549
1591
|
}
|
|
1550
1592
|
return i;
|
|
1551
1593
|
}
|
|
1552
|
-
function
|
|
1594
|
+
function Gt(e) {
|
|
1553
1595
|
let t = [...new Set(e.flatMap((e) => [e.x, e.x + e.w]))].sort((e, t) => e - t), n = [];
|
|
1554
1596
|
for (let r = 0; r + 1 < t.length; r += 1) {
|
|
1555
1597
|
let i = t[r], a = t[r + 1];
|
|
@@ -1570,7 +1612,7 @@ function Wt(e) {
|
|
|
1570
1612
|
}
|
|
1571
1613
|
return n;
|
|
1572
1614
|
}
|
|
1573
|
-
function
|
|
1615
|
+
function Kt(e, t, n, r) {
|
|
1574
1616
|
e.save(), e.globalAlpha *= t.dim.opacity, e.fillStyle = t.dim.color, e.beginPath(), e.rect(0, 0, n, r);
|
|
1575
1617
|
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();
|
|
1576
1618
|
if (e.fill(), t.zones.length) {
|
|
@@ -1581,27 +1623,27 @@ function Gt(e, t, n, r) {
|
|
|
1581
1623
|
}
|
|
1582
1624
|
e.restore();
|
|
1583
1625
|
}
|
|
1584
|
-
function
|
|
1626
|
+
function qt(e) {
|
|
1585
1627
|
let t = [];
|
|
1586
1628
|
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]]);
|
|
1587
1629
|
return t;
|
|
1588
1630
|
}
|
|
1589
|
-
var
|
|
1631
|
+
var Jt = {
|
|
1590
1632
|
color: "#000000",
|
|
1591
1633
|
opacity: .5
|
|
1592
|
-
},
|
|
1634
|
+
}, Yt = {
|
|
1593
1635
|
color: "#ffffff",
|
|
1594
1636
|
opacity: 1,
|
|
1595
1637
|
width: 2,
|
|
1596
1638
|
dash: [6, 6],
|
|
1597
1639
|
underlayColor: "#000000"
|
|
1598
|
-
},
|
|
1640
|
+
}, Xt = {
|
|
1599
1641
|
color: "#dc2626",
|
|
1600
1642
|
opacity: .8,
|
|
1601
1643
|
width: 2,
|
|
1602
1644
|
dash: [6, 6],
|
|
1603
1645
|
underlayColor: "#000000"
|
|
1604
|
-
},
|
|
1646
|
+
}, Zt = (e, t, n) => {
|
|
1605
1647
|
let r = e.occludedAreas?.filter((e) => e.points.length >= 3) ?? [];
|
|
1606
1648
|
if (!t || !n || !e.visibleAreas.length && !r.length) return null;
|
|
1607
1649
|
let i = e.visibleAreas, a = i.length ? i : [{
|
|
@@ -1609,8 +1651,8 @@ var qt = {
|
|
|
1609
1651
|
y: 0,
|
|
1610
1652
|
w: t,
|
|
1611
1653
|
h: n
|
|
1612
|
-
}], o =
|
|
1613
|
-
...
|
|
1654
|
+
}], o = Gt(a), s = {
|
|
1655
|
+
...Jt,
|
|
1614
1656
|
...e.dim
|
|
1615
1657
|
}, c = e.outline;
|
|
1616
1658
|
if (c === !1) return {
|
|
@@ -1624,36 +1666,36 @@ var qt = {
|
|
|
1624
1666
|
};
|
|
1625
1667
|
let l = {
|
|
1626
1668
|
visible: {
|
|
1627
|
-
...
|
|
1669
|
+
...Yt,
|
|
1628
1670
|
...c?.visibleStyle
|
|
1629
1671
|
},
|
|
1630
1672
|
occluded: {
|
|
1631
|
-
...
|
|
1673
|
+
...Xt,
|
|
1632
1674
|
...c?.occludedStyle
|
|
1633
1675
|
}
|
|
1634
|
-
}, u = i.map(
|
|
1676
|
+
}, u = i.map(Vt), d = a.map(Vt), f = r.map((e) => e.points);
|
|
1635
1677
|
return c?.mode === "separate" ? {
|
|
1636
1678
|
rects: a,
|
|
1637
1679
|
zones: r,
|
|
1638
1680
|
dimHoles: o,
|
|
1639
1681
|
dim: s,
|
|
1640
|
-
visibleOutline:
|
|
1641
|
-
occludedOutline:
|
|
1682
|
+
visibleOutline: qt(u),
|
|
1683
|
+
occludedOutline: qt(f),
|
|
1642
1684
|
outlineStyles: l
|
|
1643
1685
|
} : {
|
|
1644
1686
|
rects: a,
|
|
1645
1687
|
zones: r,
|
|
1646
1688
|
dimHoles: o,
|
|
1647
1689
|
dim: s,
|
|
1648
|
-
visibleOutline: [...
|
|
1690
|
+
visibleOutline: [...Wt(u, [...u, ...f], null), ...Wt(f, f, d)],
|
|
1649
1691
|
occludedOutline: [],
|
|
1650
1692
|
outlineStyles: l
|
|
1651
1693
|
};
|
|
1652
|
-
},
|
|
1653
|
-
function
|
|
1694
|
+
}, Qt = .3, $t = .05;
|
|
1695
|
+
function en(e) {
|
|
1654
1696
|
return 1 - (1 - e) ** 3;
|
|
1655
1697
|
}
|
|
1656
|
-
function
|
|
1698
|
+
function tn(e) {
|
|
1657
1699
|
return {
|
|
1658
1700
|
x: e.minX,
|
|
1659
1701
|
y: e.minY,
|
|
@@ -1661,7 +1703,7 @@ function en(e) {
|
|
|
1661
1703
|
height: Math.max(0, e.maxY - e.minY)
|
|
1662
1704
|
};
|
|
1663
1705
|
}
|
|
1664
|
-
function
|
|
1706
|
+
function nn(e, t) {
|
|
1665
1707
|
if (!t.length) return null;
|
|
1666
1708
|
if (e === L.POINT) {
|
|
1667
1709
|
let e = t[0];
|
|
@@ -1680,10 +1722,10 @@ function tn(e, t) {
|
|
|
1680
1722
|
height: i
|
|
1681
1723
|
};
|
|
1682
1724
|
}
|
|
1683
|
-
function
|
|
1725
|
+
function rn(e) {
|
|
1684
1726
|
if (!e.length) return null;
|
|
1685
|
-
let t = e.map((e) =>
|
|
1686
|
-
return t.length ?
|
|
1727
|
+
let t = e.map((e) => nn(e.type, e.points)).filter((e) => e !== null);
|
|
1728
|
+
return t.length ? tn(H(t.flatMap((e) => [{
|
|
1687
1729
|
x: e.x,
|
|
1688
1730
|
y: e.y
|
|
1689
1731
|
}, {
|
|
@@ -1691,8 +1733,8 @@ function nn(e) {
|
|
|
1691
1733
|
y: e.y + e.height
|
|
1692
1734
|
}]))) : null;
|
|
1693
1735
|
}
|
|
1694
|
-
function
|
|
1695
|
-
let { containerRatio: i =
|
|
1736
|
+
function an(e, t, n, r = {}) {
|
|
1737
|
+
let { containerRatio: i = Qt, minScale: a = $t, maxScale: o = 20 } = r;
|
|
1696
1738
|
if (!t || !n || e.width <= 0 || e.height <= 0) return null;
|
|
1697
1739
|
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;
|
|
1698
1740
|
return {
|
|
@@ -1701,18 +1743,18 @@ function rn(e, t, n, r = {}) {
|
|
|
1701
1743
|
y: n / 2 - u * c
|
|
1702
1744
|
};
|
|
1703
1745
|
}
|
|
1704
|
-
function
|
|
1746
|
+
function on(e, t, n, r = 80) {
|
|
1705
1747
|
if (!t || !n) return null;
|
|
1706
|
-
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(
|
|
1748
|
+
let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max($t, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
|
|
1707
1749
|
return {
|
|
1708
1750
|
scale: o,
|
|
1709
1751
|
x: t / 2 - s * o,
|
|
1710
1752
|
y: n / 2 - c * o
|
|
1711
1753
|
};
|
|
1712
1754
|
}
|
|
1713
|
-
function
|
|
1755
|
+
function sn(e, t, n, r = 300) {
|
|
1714
1756
|
let i = Date.now(), a = 0, o = () => {
|
|
1715
|
-
let s = Date.now() - i, c = Math.min(s / r, 1), l =
|
|
1757
|
+
let s = Date.now() - i, c = Math.min(s / r, 1), l = en(c);
|
|
1716
1758
|
n({
|
|
1717
1759
|
scale: e.scale + (t.scale - e.scale) * l,
|
|
1718
1760
|
x: e.x + (t.x - e.x) * l,
|
|
@@ -1723,7 +1765,7 @@ function on(e, t, n, r = 300) {
|
|
|
1723
1765
|
}
|
|
1724
1766
|
//#endregion
|
|
1725
1767
|
//#region src/components/ShapeEditor/_state/createInteractionController.ts
|
|
1726
|
-
function
|
|
1768
|
+
function cn(e) {
|
|
1727
1769
|
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, onDrawAttemptWithoutDraft: p, createRef: m, selectRef: h, enterEditRef: g, editingIdRef: _, drawSessionRef: v, assistantRef: y, setCursorHint: b, setInteractionMode: x, syncMinimap: S, onTransformPreview: C, onDrawPreview: w } = e, T = () => v.current, E = () => y.current, D = null, O = null, k = null, A = null, j = null, M = null, N = !1, P = "", F = null, ee = null, te = (e) => e === J.RECTANGLE || e === J.ROTATED_RECTANGLE || e === J.CIRCLE, I = (e) => e === J.ASSISTANT_POLYGON || e === J.ASSISTANT_RECT, ne = (e) => e === J.POLYGON, re = (e) => te(e) || I(e) || ne(e) || e === J.PATH || e === J.BRUSH || e === J.POINT, ie = (e, t) => {
|
|
1728
1770
|
let n = !1;
|
|
1729
1771
|
O && !te(t) && !I(t) && (O = null, e.clearPreview(), w(null), n = !0), (k === "path" && t !== J.PATH || k === "scalar" && t !== J.BRUSH) && (k = null, n = !0), A && !ne(t) && (A = null, n = !0), j && t !== J.SELECT && (j = null, M = null, N = !1, e.clearMarquee(), n = !0), F && t !== J.POINT && (F = null, n = !0), n && x("idle");
|
|
@@ -2005,7 +2047,7 @@ function sn(e) {
|
|
|
2005
2047
|
}
|
|
2006
2048
|
//#endregion
|
|
2007
2049
|
//#region src/components/ShapeEditor/_state/useAssistant.ts
|
|
2008
|
-
function
|
|
2050
|
+
function ln({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
|
|
2009
2051
|
let [a, o] = k("idle"), [s, c] = k([]), [l, u] = k([]), d = O([]), f = O([]), p = O([]), m = O("idle"), h = O(0), g = O(null), _ = O(null), v = O(0), y = x((e) => {
|
|
2010
2052
|
d.current = e(d.current), u(d.current);
|
|
2011
2053
|
}, []), b = x((e) => {
|
|
@@ -2170,17 +2212,17 @@ function cn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
|
|
|
2170
2212
|
}
|
|
2171
2213
|
//#endregion
|
|
2172
2214
|
//#region src/components/ShapeEditor/_model/brush.ts
|
|
2173
|
-
function
|
|
2215
|
+
function un(e, t, n) {
|
|
2174
2216
|
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);
|
|
2175
2217
|
return i === 0 ? 0 : r * 2 / i;
|
|
2176
2218
|
}
|
|
2177
|
-
function
|
|
2219
|
+
function dn(e, t = 1.5) {
|
|
2178
2220
|
if (e.length <= 2) return e;
|
|
2179
2221
|
let n = (e, t) => {
|
|
2180
2222
|
if (e.length < 3) return e;
|
|
2181
2223
|
let r = 0, i = 0, a = e.length - 1;
|
|
2182
2224
|
for (let t = 1; t < a; t++) {
|
|
2183
|
-
let n =
|
|
2225
|
+
let n = un(e[t], e[0], e[a]);
|
|
2184
2226
|
n > r && (i = t, r = n);
|
|
2185
2227
|
}
|
|
2186
2228
|
if (r > t) {
|
|
@@ -2193,8 +2235,8 @@ function un(e, t = 1.5) {
|
|
|
2193
2235
|
}
|
|
2194
2236
|
//#endregion
|
|
2195
2237
|
//#region src/components/ShapeEditor/_model/scalarMask.ts
|
|
2196
|
-
var
|
|
2197
|
-
function
|
|
2238
|
+
var fn = 4096, pn = 4;
|
|
2239
|
+
function mn(e) {
|
|
2198
2240
|
let t = 0;
|
|
2199
2241
|
for (let n = 0; n < e.length; n++) {
|
|
2200
2242
|
let r = e[n], i = e[(n + 1) % e.length];
|
|
@@ -2202,17 +2244,17 @@ function pn(e) {
|
|
|
2202
2244
|
}
|
|
2203
2245
|
return Math.abs(t / 2);
|
|
2204
2246
|
}
|
|
2205
|
-
function
|
|
2247
|
+
function hn(e, t, n) {
|
|
2206
2248
|
let r = new Uint8Array(t * n);
|
|
2207
2249
|
for (let i = 0; i < t * n; i++) r[i] = e[i * 4 + 3] > 128 ? 255 : 0;
|
|
2208
2250
|
return r;
|
|
2209
2251
|
}
|
|
2210
|
-
function
|
|
2252
|
+
function gn(e) {
|
|
2211
2253
|
let t = new Uint8ClampedArray(e.length * 4);
|
|
2212
2254
|
for (let n = 0; n < e.length; n++) e[n] > 128 && (t[n * 4 + 3] = 255);
|
|
2213
2255
|
return t;
|
|
2214
2256
|
}
|
|
2215
|
-
function
|
|
2257
|
+
function _n(e, t, n, r, i) {
|
|
2216
2258
|
let a = new Uint8Array(t * n), o = [[r, i]];
|
|
2217
2259
|
for (; o.length;) {
|
|
2218
2260
|
let [r, i] = o.pop(), s = i * t + r;
|
|
@@ -2220,8 +2262,8 @@ function gn(e, t, n, r, i) {
|
|
|
2220
2262
|
}
|
|
2221
2263
|
return a;
|
|
2222
2264
|
}
|
|
2223
|
-
function
|
|
2224
|
-
let r =
|
|
2265
|
+
function vn(e, t, n) {
|
|
2266
|
+
let r = hn(e, t, n), i = [];
|
|
2225
2267
|
for (;;) {
|
|
2226
2268
|
let e = -1, a = -1;
|
|
2227
2269
|
outer: for (let i = 0; i < n; i++) for (let n = 0; n < t; n++) if (r[i * t + n] > 128) {
|
|
@@ -2229,17 +2271,17 @@ function _n(e, t, n) {
|
|
|
2229
2271
|
break outer;
|
|
2230
2272
|
}
|
|
2231
2273
|
if (e < 0) break;
|
|
2232
|
-
let o =
|
|
2274
|
+
let o = bn(gn(_n(r, t, n, e, a)), t, n);
|
|
2233
2275
|
o.length >= 3 && i.push(o);
|
|
2234
2276
|
}
|
|
2235
2277
|
return i;
|
|
2236
2278
|
}
|
|
2237
|
-
function
|
|
2279
|
+
function yn(e, t, n, r, i) {
|
|
2238
2280
|
return r < 0 || i < 0 || r >= t || i >= n ? !1 : e[(i * t + r) * 4 + 3] > 128;
|
|
2239
2281
|
}
|
|
2240
|
-
function
|
|
2282
|
+
function bn(e, t, n) {
|
|
2241
2283
|
let r = -1, i = -1;
|
|
2242
|
-
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (
|
|
2284
|
+
outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (yn(e, t, n, o, a)) {
|
|
2243
2285
|
r = o, i = a;
|
|
2244
2286
|
break outer;
|
|
2245
2287
|
}
|
|
@@ -2274,7 +2316,7 @@ function yn(e, t, n) {
|
|
|
2274
2316
|
let r = !1;
|
|
2275
2317
|
for (let i = 0; i < 8; i++) {
|
|
2276
2318
|
let s = (u + i) % 8, d = c + a[s], f = l + o[s];
|
|
2277
|
-
if (
|
|
2319
|
+
if (yn(e, t, n, d, f)) {
|
|
2278
2320
|
c = d, l = f, u = (s + 6) % 8, r = !0;
|
|
2279
2321
|
break;
|
|
2280
2322
|
}
|
|
@@ -2283,13 +2325,13 @@ function yn(e, t, n) {
|
|
|
2283
2325
|
} while (c !== d.x || l !== d.y || s.length === 1);
|
|
2284
2326
|
return s;
|
|
2285
2327
|
}
|
|
2286
|
-
function
|
|
2328
|
+
function xn(e, t) {
|
|
2287
2329
|
let n = [];
|
|
2288
2330
|
for (let t of e) for (let e of t.points) n.push(e);
|
|
2289
2331
|
for (let e of t) for (let t of e) n.push(t);
|
|
2290
2332
|
return n;
|
|
2291
2333
|
}
|
|
2292
|
-
function
|
|
2334
|
+
function Sn(e) {
|
|
2293
2335
|
switch (e.type) {
|
|
2294
2336
|
case L.RECTANGLE: return e.points.length < 2 ? null : ue(e.points);
|
|
2295
2337
|
case L.POLYGON:
|
|
@@ -2308,14 +2350,14 @@ function xn(e) {
|
|
|
2308
2350
|
default: return null;
|
|
2309
2351
|
}
|
|
2310
2352
|
}
|
|
2311
|
-
function
|
|
2312
|
-
return e.map(
|
|
2353
|
+
function Cn(e) {
|
|
2354
|
+
return e.map(Sn).filter((e) => !!e && e.length >= 3);
|
|
2313
2355
|
}
|
|
2314
|
-
function
|
|
2356
|
+
function wn(e, t, n = []) {
|
|
2315
2357
|
if (t <= 0 || !e.length && !n.length) return null;
|
|
2316
|
-
let r =
|
|
2358
|
+
let r = xn(e, n);
|
|
2317
2359
|
if (!r.length) return null;
|
|
2318
|
-
let i = t + 4, a = H(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1,
|
|
2360
|
+
let i = t + 4, a = H(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, fn / Math.max(o, s, 1));
|
|
2319
2361
|
o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
|
|
2320
2362
|
let l = a.minX - i, u = a.minY - i, d = (e) => ({
|
|
2321
2363
|
x: (e.x - l) * c,
|
|
@@ -2354,20 +2396,20 @@ function Cn(e, t, n = []) {
|
|
|
2354
2396
|
scale: c
|
|
2355
2397
|
};
|
|
2356
2398
|
}
|
|
2357
|
-
function
|
|
2358
|
-
let { canvas: n, ox: r, oy: i, scale: a } = e, o =
|
|
2399
|
+
function Tn(e, t = 1.5) {
|
|
2400
|
+
let { canvas: n, ox: r, oy: i, scale: a } = e, o = vn(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
|
|
2359
2401
|
if (!o.length) return [];
|
|
2360
2402
|
let s = (e) => ({
|
|
2361
2403
|
x: e.x / a + r,
|
|
2362
2404
|
y: e.y / a + i
|
|
2363
2405
|
}), c = [];
|
|
2364
2406
|
for (let e of o) {
|
|
2365
|
-
let n = e.map(s), r =
|
|
2366
|
-
i.length >= 3 &&
|
|
2407
|
+
let n = e.map(s), r = dn(n, t), i = r.length >= 3 ? r : n;
|
|
2408
|
+
i.length >= 3 && mn(i) >= pn && c.push(i);
|
|
2367
2409
|
}
|
|
2368
2410
|
return c;
|
|
2369
2411
|
}
|
|
2370
|
-
function
|
|
2412
|
+
function En(e, t) {
|
|
2371
2413
|
let { canvas: n } = e, r = document.createElement("canvas");
|
|
2372
2414
|
r.width = n.width, r.height = n.height;
|
|
2373
2415
|
let i = r.getContext("2d");
|
|
@@ -2375,30 +2417,30 @@ function Tn(e, t) {
|
|
|
2375
2417
|
}
|
|
2376
2418
|
//#endregion
|
|
2377
2419
|
//#region src/components/ShapeEditor/_state/drawSessionState.ts
|
|
2378
|
-
function
|
|
2420
|
+
function Dn(e) {
|
|
2379
2421
|
return e.map((e) => ({
|
|
2380
2422
|
mode: e.mode,
|
|
2381
2423
|
points: e.points.map((e) => ({ ...e }))
|
|
2382
2424
|
}));
|
|
2383
2425
|
}
|
|
2384
|
-
function
|
|
2426
|
+
function On(e, t) {
|
|
2385
2427
|
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));
|
|
2386
2428
|
}
|
|
2387
|
-
function
|
|
2429
|
+
function kn(e) {
|
|
2388
2430
|
return e.map((e) => ({ ...e }));
|
|
2389
2431
|
}
|
|
2390
|
-
function
|
|
2432
|
+
function An(e, t) {
|
|
2391
2433
|
return e.length === t.length && e.every((e, n) => e.x === t[n].x && e.y === t[n].y);
|
|
2392
2434
|
}
|
|
2393
2435
|
//#endregion
|
|
2394
2436
|
//#region src/components/ShapeEditor/_state/useDrawSession.ts
|
|
2395
|
-
var
|
|
2396
|
-
function
|
|
2437
|
+
var jn = 10;
|
|
2438
|
+
function Mn(e, t) {
|
|
2397
2439
|
if (e.active !== t.active || e.kind !== t.kind || e.canUndo !== t.canUndo || e.canRedo !== t.canRedo) return !1;
|
|
2398
2440
|
let n = e.brush, r = t.brush;
|
|
2399
2441
|
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]);
|
|
2400
2442
|
}
|
|
2401
|
-
function
|
|
2443
|
+
function Nn({ 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: f }) {
|
|
2402
2444
|
let p = O(l);
|
|
2403
2445
|
p.current = l;
|
|
2404
2446
|
let m = O(u);
|
|
@@ -2428,7 +2470,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2428
2470
|
editTargetIds: [...D.current]
|
|
2429
2471
|
} : void 0
|
|
2430
2472
|
}, n = _.current;
|
|
2431
|
-
n &&
|
|
2473
|
+
n && Mn(n, t) || (_.current = t, p.current?.(t));
|
|
2432
2474
|
}, []), B = x(() => {
|
|
2433
2475
|
k.current = [[]], A.current = 0;
|
|
2434
2476
|
}, []), V = x(() => {
|
|
@@ -2444,7 +2486,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2444
2486
|
t.clearPreview();
|
|
2445
2487
|
return;
|
|
2446
2488
|
}
|
|
2447
|
-
let n =
|
|
2489
|
+
let n = wn(e, a.current, E.current);
|
|
2448
2490
|
if (!n) {
|
|
2449
2491
|
t.clearPreview();
|
|
2450
2492
|
return;
|
|
@@ -2466,7 +2508,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2466
2508
|
let e = m.current;
|
|
2467
2509
|
e && r !== w.current && (w.current = r, e({
|
|
2468
2510
|
type: L.POLYGON,
|
|
2469
|
-
points:
|
|
2511
|
+
points: kn(r),
|
|
2470
2512
|
meta: h.current
|
|
2471
2513
|
}));
|
|
2472
2514
|
}
|
|
@@ -2476,11 +2518,11 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2476
2518
|
c,
|
|
2477
2519
|
e
|
|
2478
2520
|
]), oe = x((e) => {
|
|
2479
|
-
let t =
|
|
2480
|
-
i &&
|
|
2521
|
+
let t = Dn(e), n = k.current, r = A.current, i = n[r];
|
|
2522
|
+
i && On(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, z());
|
|
2481
2523
|
}, [z]), H = x((e) => {
|
|
2482
2524
|
let t = S.current, n = C.current, r = t[n];
|
|
2483
|
-
r &&
|
|
2525
|
+
r && An(r, e) || (S.current = [...t.slice(0, n + 1), kn(e)], C.current += 1);
|
|
2484
2526
|
}, []), U = x(() => {
|
|
2485
2527
|
v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null, B(), c.current?.clearPreview(), m.current?.(null), z();
|
|
2486
2528
|
}, [
|
|
@@ -2493,7 +2535,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2493
2535
|
z,
|
|
2494
2536
|
H,
|
|
2495
2537
|
V
|
|
2496
|
-
]), ce = x(() =>
|
|
2538
|
+
]), ce = x(() => kn(v.current), []), le = x(() => v.current.length > 0, []), ue = x((t, n) => {
|
|
2497
2539
|
if (e.current !== J.POLYGON) return !1;
|
|
2498
2540
|
let r = v.current;
|
|
2499
2541
|
if (r.length < 3) return !1;
|
|
@@ -2507,7 +2549,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2507
2549
|
if (e < 0 || e >= n.length) return null;
|
|
2508
2550
|
let r = new Set(b.current);
|
|
2509
2551
|
return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), b.current = r, y.current = null, V(), z(), {
|
|
2510
|
-
base:
|
|
2552
|
+
base: kn(n),
|
|
2511
2553
|
indices: Array.from(r)
|
|
2512
2554
|
};
|
|
2513
2555
|
}, [z, V]), pe = x((e) => {
|
|
@@ -2531,7 +2573,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2531
2573
|
V
|
|
2532
2574
|
]), ve = x((e) => {
|
|
2533
2575
|
y.current = e ? { ...e } : null, V();
|
|
2534
|
-
}, [V]), ye = x(() => v.current.length > 0 ? (v.current = [], V(), z(), !0) : A.current <= 0 ? !1 : (--A.current, T.current =
|
|
2576
|
+
}, [V]), ye = x(() => v.current.length > 0 ? (v.current = [], V(), z(), !0) : A.current <= 0 ? !1 : (--A.current, T.current = Dn(k.current[A.current]), V(), z(), !0), [z, V]), be = x(() => v.current.length > 0 || A.current >= k.current.length - 1 ? !1 : (A.current += 1, T.current = Dn(k.current[A.current]), V(), z(), !0), [z, V]), xe = x(() => C.current <= 0 ? !1 : (--C.current, v.current = kn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), V(), z(), !0), [z, V]), Se = x(() => C.current >= S.current.length - 1 ? !1 : (C.current += 1, v.current = kn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), V(), z(), !0), [z, V]), Ce = x(() => {
|
|
2535
2577
|
let t = e.current;
|
|
2536
2578
|
return t === J.BRUSH ? ye() : t === J.POLYGON || t === J.PATH ? xe() : !1;
|
|
2537
2579
|
}, [
|
|
@@ -2548,24 +2590,24 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2548
2590
|
]), Te = x(() => {
|
|
2549
2591
|
let e = t.current;
|
|
2550
2592
|
if (!e.length) return D.current.length > 0;
|
|
2551
|
-
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ie(t)), i =
|
|
2593
|
+
let r = n.current.getShapes().filter((t) => e.includes(t.id) && ie(t)), i = Cn(r);
|
|
2552
2594
|
return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
|
|
2553
2595
|
}, [n, t]), W = x(() => {
|
|
2554
2596
|
if (r.current) return !1;
|
|
2555
2597
|
let e = [...T.current];
|
|
2556
2598
|
v.current.length && e.push({
|
|
2557
|
-
points:
|
|
2599
|
+
points: kn(v.current),
|
|
2558
2600
|
mode: M()
|
|
2559
2601
|
});
|
|
2560
2602
|
let t = E.current, c = [...D.current];
|
|
2561
2603
|
if (!e.length && !t.length) return !1;
|
|
2562
|
-
let l =
|
|
2604
|
+
let l = wn(e, a.current, t);
|
|
2563
2605
|
if (!l) return U(), !1;
|
|
2564
|
-
let u =
|
|
2606
|
+
let u = Tn(l, o.current);
|
|
2565
2607
|
if (c.length) {
|
|
2566
2608
|
let e = n.current.getShapes().filter((e) => c.includes(e.id));
|
|
2567
2609
|
if (!u.length) return n.current.remove(c), U(), d([]), !0;
|
|
2568
|
-
u.sort((e, t) =>
|
|
2610
|
+
u.sort((e, t) => mn(t) - mn(e));
|
|
2569
2611
|
let t = [], r = [], i = [];
|
|
2570
2612
|
for (let n = 0; n < u.length; n++) {
|
|
2571
2613
|
let a = u[n];
|
|
@@ -2620,7 +2662,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2620
2662
|
]), De = x(() => {
|
|
2621
2663
|
let t = v.current;
|
|
2622
2664
|
if (e.current === J.PATH && t.length >= 3) {
|
|
2623
|
-
let e =
|
|
2665
|
+
let e = dn(t, o.current);
|
|
2624
2666
|
e.length >= 3 && g.current(L.POLYGON, e);
|
|
2625
2667
|
}
|
|
2626
2668
|
U();
|
|
@@ -2646,7 +2688,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2646
2688
|
}, [se]), Ae = x((e) => {
|
|
2647
2689
|
let t = c.current, n = v.current;
|
|
2648
2690
|
if (!t || !n.length) return -1;
|
|
2649
|
-
let r =
|
|
2691
|
+
let r = jn / (t.viewport.scale || 1);
|
|
2650
2692
|
for (let t = n.length - 1; t >= 0; t--) {
|
|
2651
2693
|
let i = n[t];
|
|
2652
2694
|
if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
|
|
@@ -2654,7 +2696,7 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2654
2696
|
return -1;
|
|
2655
2697
|
}, [c]), je = x(() => {
|
|
2656
2698
|
v.current.length >= 1 && (T.current.push({
|
|
2657
|
-
points:
|
|
2699
|
+
points: kn(v.current),
|
|
2658
2700
|
mode: M()
|
|
2659
2701
|
}), v.current = [], oe(T.current)), V(), z();
|
|
2660
2702
|
}, [
|
|
@@ -2729,31 +2771,31 @@ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
|
|
|
2729
2771
|
}
|
|
2730
2772
|
//#endregion
|
|
2731
2773
|
//#region src/components/ShapeEditor/_state/useEditorDocument.ts
|
|
2732
|
-
function
|
|
2774
|
+
function Pn(e, t) {
|
|
2733
2775
|
return {
|
|
2734
2776
|
shapes: t,
|
|
2735
2777
|
past: [...e.past, e.shapes],
|
|
2736
2778
|
future: []
|
|
2737
2779
|
};
|
|
2738
2780
|
}
|
|
2739
|
-
function
|
|
2781
|
+
function Fn(e, t) {
|
|
2740
2782
|
switch (t.type) {
|
|
2741
|
-
case "CREATE": return
|
|
2783
|
+
case "CREATE": return Pn(e, [...e.shapes, ...t.shapes]);
|
|
2742
2784
|
case "UPDATE": {
|
|
2743
2785
|
let n = new Map(t.shapes.map((e) => [e.id, e]));
|
|
2744
|
-
return
|
|
2786
|
+
return Pn(e, e.shapes.map((e) => n.get(e.id) ?? e));
|
|
2745
2787
|
}
|
|
2746
2788
|
case "DELETE": {
|
|
2747
2789
|
let n = new Set(t.ids);
|
|
2748
|
-
return
|
|
2790
|
+
return Pn(e, e.shapes.filter((e) => !n.has(e.id)));
|
|
2749
2791
|
}
|
|
2750
2792
|
case "REPLACE": {
|
|
2751
2793
|
let n = new Set(t.removeIds);
|
|
2752
|
-
return
|
|
2794
|
+
return Pn(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
|
|
2753
2795
|
}
|
|
2754
2796
|
case "REORDER": {
|
|
2755
2797
|
let n = new Set(t.ids), r = e.shapes.filter((e) => n.has(e.id)), i = e.shapes.filter((e) => !n.has(e.id));
|
|
2756
|
-
return r.length === 0 ? e :
|
|
2798
|
+
return r.length === 0 ? e : Pn(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
|
|
2757
2799
|
}
|
|
2758
2800
|
case "RESET": return {
|
|
2759
2801
|
shapes: t.shapes,
|
|
@@ -2773,15 +2815,15 @@ function Pn(e, t) {
|
|
|
2773
2815
|
default: return e;
|
|
2774
2816
|
}
|
|
2775
2817
|
}
|
|
2776
|
-
function
|
|
2777
|
-
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = D(
|
|
2818
|
+
function In(e) {
|
|
2819
|
+
let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = D(Fn, {
|
|
2778
2820
|
shapes: [],
|
|
2779
2821
|
past: [],
|
|
2780
2822
|
future: []
|
|
2781
2823
|
}), o = O(i);
|
|
2782
2824
|
o.current = i;
|
|
2783
2825
|
let s = x((e) => {
|
|
2784
|
-
o.current =
|
|
2826
|
+
o.current = Fn(o.current, e), a(e);
|
|
2785
2827
|
}, []), c = x((e, i) => {
|
|
2786
2828
|
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));
|
|
2787
2829
|
s.length && t?.(s);
|
|
@@ -2850,7 +2892,7 @@ function Fn(e) {
|
|
|
2850
2892
|
}
|
|
2851
2893
|
//#endregion
|
|
2852
2894
|
//#region src/components/ShapeEditor/_model/keymap.ts
|
|
2853
|
-
var
|
|
2895
|
+
var Ln = {
|
|
2854
2896
|
undo: ["mod+z"],
|
|
2855
2897
|
redo: ["mod+shift+z"],
|
|
2856
2898
|
selectAll: ["mod+a"],
|
|
@@ -2878,7 +2920,7 @@ var In = {
|
|
|
2878
2920
|
pathTool: ["g"],
|
|
2879
2921
|
brushTool: ["b"],
|
|
2880
2922
|
pointTool: ["i"]
|
|
2881
|
-
},
|
|
2923
|
+
}, Rn = {
|
|
2882
2924
|
Equal: "=",
|
|
2883
2925
|
Minus: "-",
|
|
2884
2926
|
BracketLeft: "[",
|
|
@@ -2888,7 +2930,7 @@ var In = {
|
|
|
2888
2930
|
Comma: ",",
|
|
2889
2931
|
Slash: "/",
|
|
2890
2932
|
Backquote: "`"
|
|
2891
|
-
},
|
|
2933
|
+
}, zn = {
|
|
2892
2934
|
Escape: "escape",
|
|
2893
2935
|
Enter: "enter",
|
|
2894
2936
|
Backspace: "backspace",
|
|
@@ -2899,58 +2941,58 @@ var In = {
|
|
|
2899
2941
|
ArrowLeft: "arrowleft",
|
|
2900
2942
|
ArrowRight: "arrowright"
|
|
2901
2943
|
};
|
|
2902
|
-
function
|
|
2944
|
+
function Bn(e) {
|
|
2903
2945
|
let t = e.code, n = /^Key([A-Z])$/.exec(t);
|
|
2904
2946
|
if (n) return n[1].toLowerCase();
|
|
2905
2947
|
let r = /^Digit([0-9])$/.exec(t);
|
|
2906
|
-
return r ? r[1] :
|
|
2948
|
+
return r ? r[1] : Rn[t] ? Rn[t] : zn[e.key] ? zn[e.key] : null;
|
|
2907
2949
|
}
|
|
2908
|
-
function
|
|
2909
|
-
let t =
|
|
2950
|
+
function Vn(e) {
|
|
2951
|
+
let t = Bn(e);
|
|
2910
2952
|
if (!t) return null;
|
|
2911
2953
|
let n = [];
|
|
2912
2954
|
return (e.metaKey || e.ctrlKey) && n.push("mod"), e.shiftKey && n.push("shift"), e.altKey && n.push("alt"), n.push(t), n.join("+");
|
|
2913
2955
|
}
|
|
2914
|
-
function
|
|
2956
|
+
function Hn(e) {
|
|
2915
2957
|
let t = /* @__PURE__ */ new Map();
|
|
2916
|
-
for (let n of Object.keys(
|
|
2917
|
-
let r = e?.[n], i = r === void 0 ?
|
|
2958
|
+
for (let n of Object.keys(Ln)) {
|
|
2959
|
+
let r = e?.[n], i = r === void 0 ? Ln[n] : r === null ? [] : Array.isArray(r) ? r : [r];
|
|
2918
2960
|
for (let e of i) t.set(e.toLowerCase(), n);
|
|
2919
2961
|
}
|
|
2920
2962
|
return t;
|
|
2921
2963
|
}
|
|
2922
2964
|
//#endregion
|
|
2923
2965
|
//#region src/components/ShapeEditor/_state/useEditorHotkeys.ts
|
|
2924
|
-
var
|
|
2966
|
+
var Un = {
|
|
2925
2967
|
ArrowUp: [0, -1],
|
|
2926
2968
|
ArrowDown: [0, 1],
|
|
2927
2969
|
ArrowLeft: [-1, 0],
|
|
2928
2970
|
ArrowRight: [1, 0]
|
|
2929
2971
|
};
|
|
2930
|
-
function
|
|
2972
|
+
function Wn() {
|
|
2931
2973
|
let e = document.activeElement;
|
|
2932
2974
|
return !!e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable);
|
|
2933
2975
|
}
|
|
2934
|
-
function
|
|
2976
|
+
function Gn(e, t) {
|
|
2935
2977
|
if (!t || !(e instanceof Element)) return !1;
|
|
2936
2978
|
let n = e.closest("[role=\"dialog\"],[aria-modal=\"true\"]");
|
|
2937
2979
|
return !!n && !n.contains(t);
|
|
2938
2980
|
}
|
|
2939
|
-
function
|
|
2940
|
-
let { spaceRef: t, shiftRef: n } = e, r = E(() =>
|
|
2981
|
+
function Kn(e) {
|
|
2982
|
+
let { spaceRef: t, shiftRef: n } = e, r = E(() => Hn(e.keymap), [e.keymap]), i = O(e);
|
|
2941
2983
|
i.current = e;
|
|
2942
2984
|
let a = O(r);
|
|
2943
2985
|
a.current = r, S(() => {
|
|
2944
2986
|
let e = (e) => {
|
|
2945
|
-
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0),
|
|
2946
|
-
let r =
|
|
2987
|
+
if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0), Wn() || Gn(e.target, i.current.hostRef.current)) return;
|
|
2988
|
+
let r = Un[e.key];
|
|
2947
2989
|
if (r) {
|
|
2948
2990
|
e.preventDefault();
|
|
2949
2991
|
let t = e.shiftKey ? 10 : 1;
|
|
2950
2992
|
i.current.nudge(r[0] * t, r[1] * t);
|
|
2951
2993
|
return;
|
|
2952
2994
|
}
|
|
2953
|
-
let o =
|
|
2995
|
+
let o = Vn(e);
|
|
2954
2996
|
if (!o) return;
|
|
2955
2997
|
let s = a.current.get(o);
|
|
2956
2998
|
s && i.current.actions[s]?.() !== !1 && e.preventDefault();
|
|
@@ -2964,14 +3006,14 @@ function Gn(e) {
|
|
|
2964
3006
|
}
|
|
2965
3007
|
//#endregion
|
|
2966
3008
|
//#region src/components/ShapeEditor/_model/imageLoad.ts
|
|
2967
|
-
function
|
|
3009
|
+
function qn(e, t) {
|
|
2968
3010
|
return new Promise((n) => {
|
|
2969
3011
|
let r = new Image();
|
|
2970
3012
|
t?.crossOrigin && (r.crossOrigin = "anonymous"), r.onload = () => n(r), r.onerror = () => n(null), r.src = e;
|
|
2971
3013
|
});
|
|
2972
3014
|
}
|
|
2973
|
-
async function
|
|
2974
|
-
let t = await
|
|
3015
|
+
async function Jn(e) {
|
|
3016
|
+
let t = await qn(e, { crossOrigin: !0 });
|
|
2975
3017
|
if (t) return t;
|
|
2976
3018
|
try {
|
|
2977
3019
|
let t = await fetch(e, {
|
|
@@ -2984,11 +3026,11 @@ async function qn(e) {
|
|
|
2984
3026
|
} catch {
|
|
2985
3027
|
return null;
|
|
2986
3028
|
}
|
|
2987
|
-
return
|
|
3029
|
+
return qn(e, { crossOrigin: !0 });
|
|
2988
3030
|
}
|
|
2989
3031
|
//#endregion
|
|
2990
3032
|
//#region src/components/ShapeEditor/_model/imageDiagnosis.ts
|
|
2991
|
-
function
|
|
3033
|
+
function Yn(e) {
|
|
2992
3034
|
return new Promise((t) => {
|
|
2993
3035
|
let n = null, r = !1, i = () => {
|
|
2994
3036
|
r || (r = !0, clearTimeout(o), document.removeEventListener("securitypolicyviolation", a), t(n));
|
|
@@ -2996,29 +3038,29 @@ function Jn(e) {
|
|
|
2996
3038
|
let r = t.effectiveDirective ?? t.violatedDirective ?? "";
|
|
2997
3039
|
r.includes("img-src") && (n = `CSP ${r} blocked ${t.blockedURI || e}`);
|
|
2998
3040
|
}, o = setTimeout(i, 1e4);
|
|
2999
|
-
document.addEventListener("securitypolicyviolation", a),
|
|
3041
|
+
document.addEventListener("securitypolicyviolation", a), qn(e, { crossOrigin: !0 }).then(() => {
|
|
3000
3042
|
setTimeout(i, 0);
|
|
3001
3043
|
});
|
|
3002
3044
|
});
|
|
3003
3045
|
}
|
|
3004
|
-
var
|
|
3005
|
-
function
|
|
3006
|
-
let t =
|
|
3007
|
-
if (t && n - t.at <
|
|
3008
|
-
let r =
|
|
3046
|
+
var Xn = 3e4, Zn = 200, Qn = /* @__PURE__ */ new Map();
|
|
3047
|
+
function $n(e) {
|
|
3048
|
+
let t = Qn.get(e), n = Date.now();
|
|
3049
|
+
if (t && n - t.at < Xn) return t.result;
|
|
3050
|
+
let r = er(e).catch((t) => (Qn.delete(e), {
|
|
3009
3051
|
kind: "unknown",
|
|
3010
3052
|
detail: t instanceof Error ? t.message : String(t)
|
|
3011
3053
|
}));
|
|
3012
|
-
if (
|
|
3054
|
+
if (Qn.set(e, {
|
|
3013
3055
|
at: n,
|
|
3014
3056
|
result: r
|
|
3015
|
-
}),
|
|
3016
|
-
let e =
|
|
3017
|
-
e !== void 0 &&
|
|
3057
|
+
}), Qn.size > Zn) {
|
|
3058
|
+
let e = Qn.keys().next().value;
|
|
3059
|
+
e !== void 0 && Qn.delete(e);
|
|
3018
3060
|
}
|
|
3019
3061
|
return r;
|
|
3020
3062
|
}
|
|
3021
|
-
async function
|
|
3063
|
+
async function er(e) {
|
|
3022
3064
|
let t = e;
|
|
3023
3065
|
try {
|
|
3024
3066
|
t = new URL(e, location.href).origin;
|
|
@@ -3061,7 +3103,7 @@ async function $n(e) {
|
|
|
3061
3103
|
kind: "unexpected-content",
|
|
3062
3104
|
detail: `HTTP ${r} (${t})${n.redirected ? " via redirect" : ""}`
|
|
3063
3105
|
};
|
|
3064
|
-
let i = await
|
|
3106
|
+
let i = await Yn(e);
|
|
3065
3107
|
return i ? {
|
|
3066
3108
|
kind: "csp-img",
|
|
3067
3109
|
detail: i
|
|
@@ -3098,7 +3140,7 @@ async function $n(e) {
|
|
|
3098
3140
|
detail: `HTTP ${r}`
|
|
3099
3141
|
};
|
|
3100
3142
|
}
|
|
3101
|
-
function
|
|
3143
|
+
function tr() {
|
|
3102
3144
|
try {
|
|
3103
3145
|
let e = document.createElement("canvas");
|
|
3104
3146
|
return !!(e.getContext("webgl2") ?? e.getContext("webgl"));
|
|
@@ -3106,12 +3148,12 @@ function er() {
|
|
|
3106
3148
|
return !1;
|
|
3107
3149
|
}
|
|
3108
3150
|
}
|
|
3109
|
-
function
|
|
3151
|
+
function nr(e) {
|
|
3110
3152
|
let t = e instanceof Error ? e.message : String(e);
|
|
3111
3153
|
return /unsafe-eval/i.test(t) ? {
|
|
3112
3154
|
kind: "csp-eval",
|
|
3113
3155
|
detail: t
|
|
3114
|
-
} :
|
|
3156
|
+
} : tr() ? {
|
|
3115
3157
|
kind: "renderer-init",
|
|
3116
3158
|
detail: t || "renderer init failed"
|
|
3117
3159
|
} : {
|
|
@@ -3121,8 +3163,8 @@ function tr(e) {
|
|
|
3121
3163
|
}
|
|
3122
3164
|
//#endregion
|
|
3123
3165
|
//#region src/components/ShapeEditor/_model/imageTiles.ts
|
|
3124
|
-
var
|
|
3125
|
-
function
|
|
3166
|
+
var rr = 4e3;
|
|
3167
|
+
function ir(e, t, n = rr) {
|
|
3126
3168
|
if (e <= 0 || t <= 0) return [];
|
|
3127
3169
|
let r = Math.ceil(e / n), i = Math.ceil(t / n);
|
|
3128
3170
|
return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
|
|
@@ -3137,7 +3179,7 @@ function rr(e, t, n = nr) {
|
|
|
3137
3179
|
};
|
|
3138
3180
|
})).flat();
|
|
3139
3181
|
}
|
|
3140
|
-
function
|
|
3182
|
+
function ar(e, t) {
|
|
3141
3183
|
let n = document.createElement("canvas");
|
|
3142
3184
|
n.width = t.width, n.height = t.height;
|
|
3143
3185
|
let r = n.getContext("2d");
|
|
@@ -3145,7 +3187,7 @@ function ir(e, t) {
|
|
|
3145
3187
|
}
|
|
3146
3188
|
//#endregion
|
|
3147
3189
|
//#region src/components/ShapeEditor/_model/konva.ts
|
|
3148
|
-
function
|
|
3190
|
+
function or(e, t, n) {
|
|
3149
3191
|
if (t === L.POINT) {
|
|
3150
3192
|
e.setAttrs({
|
|
3151
3193
|
x: n[0].x,
|
|
@@ -3181,17 +3223,17 @@ function ar(e, t, n) {
|
|
|
3181
3223
|
}
|
|
3182
3224
|
//#endregion
|
|
3183
3225
|
//#region src/components/ShapeEditor/_model/pinIcon.ts
|
|
3184
|
-
var
|
|
3185
|
-
function
|
|
3186
|
-
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${
|
|
3226
|
+
var sr = "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", cr = "#ffffff", lr = 1.5;
|
|
3227
|
+
function ur(e) {
|
|
3228
|
+
return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${sr}" fill="${e}" stroke="${cr}" stroke-width="${lr}"/></svg>`;
|
|
3187
3229
|
}
|
|
3188
3230
|
//#endregion
|
|
3189
3231
|
//#region src/components/ShapeEditor/_renderers/transformSession.ts
|
|
3190
|
-
var
|
|
3191
|
-
function
|
|
3232
|
+
var dr = Math.PI / 12;
|
|
3233
|
+
function fr(e, t) {
|
|
3192
3234
|
return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === L.ROTATED_RECTANGLE;
|
|
3193
3235
|
}
|
|
3194
|
-
function
|
|
3236
|
+
function pr(e, t, n) {
|
|
3195
3237
|
if (e.kind === "resize") {
|
|
3196
3238
|
let r = n ? e.box : se(e.anchor, e.box, t.x, t.y);
|
|
3197
3239
|
return {
|
|
@@ -3222,7 +3264,7 @@ function fr(e, t, n) {
|
|
|
3222
3264
|
}
|
|
3223
3265
|
if (e.kind === "rotate") {
|
|
3224
3266
|
let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
|
|
3225
|
-
return e.shiftKey && (n = Math.round(n /
|
|
3267
|
+
return e.shiftKey && (n = Math.round(n / dr) * dr), {
|
|
3226
3268
|
updates: [{
|
|
3227
3269
|
id: e.id,
|
|
3228
3270
|
points: e.points.map((t) => le(t, e.center, n))
|
|
@@ -3242,13 +3284,13 @@ function fr(e, t, n) {
|
|
|
3242
3284
|
box: H(a)
|
|
3243
3285
|
};
|
|
3244
3286
|
}
|
|
3245
|
-
function
|
|
3287
|
+
function mr(e, t) {
|
|
3246
3288
|
return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
|
|
3247
3289
|
x: t.center.x + Math.cos(t.startAngle),
|
|
3248
3290
|
y: t.center.y + Math.sin(t.startAngle)
|
|
3249
|
-
} :
|
|
3291
|
+
} : fr(e, t) ? be(t.shapes[0].points)[oe.indexOf(t.anchor)] : U(t.anchor, t.box);
|
|
3250
3292
|
}
|
|
3251
|
-
function
|
|
3293
|
+
function hr(e, t, n) {
|
|
3252
3294
|
let r = e.filter((e) => t.includes(e.id) && z(e)).map((e) => ({
|
|
3253
3295
|
id: e.id,
|
|
3254
3296
|
points: e.points
|
|
@@ -3260,23 +3302,23 @@ function mr(e, t, n) {
|
|
|
3260
3302
|
shapes: r
|
|
3261
3303
|
} : null;
|
|
3262
3304
|
}
|
|
3263
|
-
function
|
|
3305
|
+
function gr(e) {
|
|
3264
3306
|
return e.map((e) => ({
|
|
3265
3307
|
...e,
|
|
3266
3308
|
points: e.points.map((e) => ({ ...e }))
|
|
3267
3309
|
}));
|
|
3268
3310
|
}
|
|
3269
|
-
function
|
|
3311
|
+
function _r(e, t) {
|
|
3270
3312
|
let n = new Set(t);
|
|
3271
3313
|
return e.filter((e) => n.has(e.id) && ie(e));
|
|
3272
3314
|
}
|
|
3273
|
-
function
|
|
3274
|
-
return e.filter((e) => R(e) &&
|
|
3315
|
+
function vr(e, t) {
|
|
3316
|
+
return e.filter((e) => R(e) && Me(e, t)).map((e) => e.id);
|
|
3275
3317
|
}
|
|
3276
|
-
function
|
|
3277
|
-
return (e ?
|
|
3318
|
+
function yr(e, t, n) {
|
|
3319
|
+
return (e ? Qe(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
|
|
3278
3320
|
}
|
|
3279
|
-
function
|
|
3321
|
+
function br(e, t) {
|
|
3280
3322
|
return {
|
|
3281
3323
|
minX: e.x - t,
|
|
3282
3324
|
minY: e.y - t,
|
|
@@ -3284,9 +3326,9 @@ function yr(e, t) {
|
|
|
3284
3326
|
maxY: e.y + t
|
|
3285
3327
|
};
|
|
3286
3328
|
}
|
|
3287
|
-
function
|
|
3329
|
+
function xr(e, t, n) {
|
|
3288
3330
|
if (e.type === L.ROTATED_RECTANGLE) return t;
|
|
3289
|
-
let r = e.type === L.POINT ?
|
|
3331
|
+
let r = e.type === L.POINT ? br(t[0], n) : H(t);
|
|
3290
3332
|
return ue([{
|
|
3291
3333
|
x: r.minX,
|
|
3292
3334
|
y: r.minY
|
|
@@ -3295,17 +3337,17 @@ function br(e, t, n) {
|
|
|
3295
3337
|
y: r.maxY
|
|
3296
3338
|
}]);
|
|
3297
3339
|
}
|
|
3298
|
-
function
|
|
3340
|
+
function Sr(e) {
|
|
3299
3341
|
return 24 / (e || 1);
|
|
3300
3342
|
}
|
|
3301
|
-
function
|
|
3343
|
+
function Cr(e, t) {
|
|
3302
3344
|
return Math.atan2(t.y - e.y, t.x - e.x);
|
|
3303
3345
|
}
|
|
3304
3346
|
//#endregion
|
|
3305
3347
|
//#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
|
|
3306
|
-
var
|
|
3348
|
+
var wr = 2, Tr = "#1e88e5", Er = "#669def", Dr = class {
|
|
3307
3349
|
constructor(e, t) {
|
|
3308
|
-
this.layer = new A.Layer(), this.world = new A.Group(), this.bgGroup = new A.Group(), this.overlayGroup = new A.Group({ listening: !1 }), this.guideOverlayGroup = new A.Group({ listening: !1 }), this.regionOverlayGroup = new A.Group({ listening: !1 }), this.dimOverlayGroup = new A.Group({ listening: !1 }), this.shapeGroup = new A.Group(), this.selGroup = new A.Group(), this.previewGroup = new A.Group(), this.handleGroup = new A.Group(), this.baseCursor = "default", this.strokeSize =
|
|
3350
|
+
this.layer = new A.Layer(), this.world = new A.Group(), this.bgGroup = new A.Group(), this.overlayGroup = new A.Group({ listening: !1 }), this.guideOverlayGroup = new A.Group({ listening: !1 }), this.regionOverlayGroup = new A.Group({ listening: !1 }), this.dimOverlayGroup = new A.Group({ listening: !1 }), this.shapeGroup = new A.Group(), this.selGroup = new A.Group(), this.previewGroup = new A.Group(), this.handleGroup = new A.Group(), this.baseCursor = "default", this.strokeSize = wr, 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 = {
|
|
3309
3351
|
x: 0,
|
|
3310
3352
|
y: 0
|
|
3311
3353
|
}, 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 A.Stage({
|
|
@@ -3398,7 +3440,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3398
3440
|
}
|
|
3399
3441
|
bindShapeCursor(e, t) {
|
|
3400
3442
|
if (!z(t)) return this.bindCursor(e, "default");
|
|
3401
|
-
this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" :
|
|
3443
|
+
this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" : Nt);
|
|
3402
3444
|
}
|
|
3403
3445
|
bindCursor(e, t) {
|
|
3404
3446
|
let n = () => {
|
|
@@ -3421,7 +3463,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3421
3463
|
return this.world.getAbsoluteTransform().point(e);
|
|
3422
3464
|
}
|
|
3423
3465
|
async setImage(e, t, n) {
|
|
3424
|
-
let r = ++this.imageLoadToken, i = await
|
|
3466
|
+
let r = ++this.imageLoadToken, i = await Jn(e);
|
|
3425
3467
|
if (r !== this.imageLoadToken) return !0;
|
|
3426
3468
|
if (!i) return this.imageWidth ||= 800, this.imageHeight ||= 600, !1;
|
|
3427
3469
|
this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
|
|
@@ -3430,7 +3472,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3430
3472
|
x: a / i.naturalWidth,
|
|
3431
3473
|
y: o / i.naturalHeight
|
|
3432
3474
|
}), this.bgGroup.destroyChildren();
|
|
3433
|
-
for (let e of
|
|
3475
|
+
for (let e of ir(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new A.Image({
|
|
3434
3476
|
image: i,
|
|
3435
3477
|
x: e.x,
|
|
3436
3478
|
y: e.y,
|
|
@@ -3485,7 +3527,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3485
3527
|
if (this.regionOverlayGroup.add(new A.Shape({
|
|
3486
3528
|
listening: !1,
|
|
3487
3529
|
sceneFunc: (r) => {
|
|
3488
|
-
|
|
3530
|
+
Kt(r._context, e, t, n);
|
|
3489
3531
|
}
|
|
3490
3532
|
})), e.outlineStyles) {
|
|
3491
3533
|
let t = (e, t) => {
|
|
@@ -3541,7 +3583,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3541
3583
|
let e = this.lastPreviewPoly;
|
|
3542
3584
|
e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
|
|
3543
3585
|
}
|
|
3544
|
-
this.activeDrag ? this.dragTransform(this.lastDragImg ??
|
|
3586
|
+
this.activeDrag ? this.dragTransform(this.lastDragImg ?? mr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
|
|
3545
3587
|
}
|
|
3546
3588
|
fit() {
|
|
3547
3589
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -3570,10 +3612,10 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3570
3612
|
});
|
|
3571
3613
|
}
|
|
3572
3614
|
setShapes(e, t) {
|
|
3573
|
-
if (this.shapes =
|
|
3615
|
+
if (this.shapes = gr(e), this.selected = t, !this.activeDrag) {
|
|
3574
3616
|
this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
|
|
3575
3617
|
for (let t of B(e).filter(ne)) {
|
|
3576
|
-
let e = this.makeNode(t), n =
|
|
3618
|
+
let e = this.makeNode(t), n = Qe(t, { strokeWidth: this.strokeSize });
|
|
3577
3619
|
if (t.style?.alternateColor && n.dash?.length && t.type !== L.POINT) {
|
|
3578
3620
|
let n = e.clone({
|
|
3579
3621
|
id: `${t.id}__alt`,
|
|
@@ -3604,7 +3646,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3604
3646
|
t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
|
|
3605
3647
|
}
|
|
3606
3648
|
makeNode(e) {
|
|
3607
|
-
let { type: t, points: n } = e, r =
|
|
3649
|
+
let { type: t, points: n } = e, r = Qe(e, { strokeWidth: this.strokeSize }), i = R(e), a = {
|
|
3608
3650
|
id: e.id,
|
|
3609
3651
|
stroke: r.color,
|
|
3610
3652
|
strokeWidth: r.strokeWidth,
|
|
@@ -3612,11 +3654,11 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3612
3654
|
opacity: r.opacity,
|
|
3613
3655
|
strokeScaleEnabled: !1,
|
|
3614
3656
|
listening: i
|
|
3615
|
-
}, o = r.fillVisible ?
|
|
3657
|
+
}, o = r.fillVisible ? $e(r.color, r.fillAlpha) : void 0;
|
|
3616
3658
|
if (t === L.POINT) {
|
|
3617
3659
|
let t = 1 / (this.world.scaleX() || 1), a = new A.Path({
|
|
3618
3660
|
id: e.id,
|
|
3619
|
-
data:
|
|
3661
|
+
data: sr,
|
|
3620
3662
|
x: n[0].x,
|
|
3621
3663
|
y: n[0].y,
|
|
3622
3664
|
offsetX: 16 / 2,
|
|
@@ -3624,8 +3666,8 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3624
3666
|
scaleX: t,
|
|
3625
3667
|
scaleY: t,
|
|
3626
3668
|
fill: r.color,
|
|
3627
|
-
stroke:
|
|
3628
|
-
strokeWidth:
|
|
3669
|
+
stroke: cr,
|
|
3670
|
+
strokeWidth: lr,
|
|
3629
3671
|
strokeScaleEnabled: !1,
|
|
3630
3672
|
shadowColor: "#000",
|
|
3631
3673
|
shadowBlur: 2,
|
|
@@ -3671,13 +3713,13 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3671
3713
|
liveUpdateShape(e, t) {
|
|
3672
3714
|
let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
|
|
3673
3715
|
if (n && r) {
|
|
3674
|
-
|
|
3716
|
+
or(n, r.type, t);
|
|
3675
3717
|
let i = this.altNodes.get(e);
|
|
3676
|
-
i &&
|
|
3718
|
+
i && or(i, r.type, t), r.type === L.POINT && n instanceof A.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
|
|
3677
3719
|
}
|
|
3678
3720
|
}
|
|
3679
3721
|
pointRadius(e) {
|
|
3680
|
-
return
|
|
3722
|
+
return yr(e, this.strokeSize, this.world.scaleX() || 1);
|
|
3681
3723
|
}
|
|
3682
3724
|
scaledDash(e) {
|
|
3683
3725
|
return e;
|
|
@@ -3693,11 +3735,11 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3693
3735
|
});
|
|
3694
3736
|
continue;
|
|
3695
3737
|
}
|
|
3696
|
-
n?.dash(this.scaledDash(
|
|
3738
|
+
n?.dash(this.scaledDash(Qe(t, { strokeWidth: this.strokeSize }).dash));
|
|
3697
3739
|
}
|
|
3698
3740
|
}
|
|
3699
3741
|
shapesIntersecting(e) {
|
|
3700
|
-
return
|
|
3742
|
+
return vr(this.shapes, e);
|
|
3701
3743
|
}
|
|
3702
3744
|
drawSelectionBorders() {
|
|
3703
3745
|
let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && R(t)) : [];
|
|
@@ -3706,7 +3748,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3706
3748
|
this.selectionBorders = t.map(() => {
|
|
3707
3749
|
let e = new A.Line({
|
|
3708
3750
|
closed: !0,
|
|
3709
|
-
stroke:
|
|
3751
|
+
stroke: Er,
|
|
3710
3752
|
strokeWidth: 1.5,
|
|
3711
3753
|
strokeScaleEnabled: !1,
|
|
3712
3754
|
listening: !1
|
|
@@ -3727,7 +3769,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3727
3769
|
}
|
|
3728
3770
|
}
|
|
3729
3771
|
selectionOutlinePoints(e, t) {
|
|
3730
|
-
return
|
|
3772
|
+
return xr(e, t, this.pointRadius(e));
|
|
3731
3773
|
}
|
|
3732
3774
|
clearPreview() {
|
|
3733
3775
|
this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
|
|
@@ -3790,8 +3832,8 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3790
3832
|
x: n.x,
|
|
3791
3833
|
y: n.y,
|
|
3792
3834
|
radius: (r ? 6 : 5) / l,
|
|
3793
|
-
fill: r ?
|
|
3794
|
-
stroke: r ? "#ffffff" :
|
|
3835
|
+
fill: r ? Tr : "#ffffff",
|
|
3836
|
+
stroke: r ? "#ffffff" : Tr,
|
|
3795
3837
|
strokeWidth: 1.5,
|
|
3796
3838
|
strokeScaleEnabled: !1,
|
|
3797
3839
|
listening: !1
|
|
@@ -3801,7 +3843,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3801
3843
|
}
|
|
3802
3844
|
previewScalarMask(e, t) {
|
|
3803
3845
|
this.previewGroup.destroyChildren();
|
|
3804
|
-
let n =
|
|
3846
|
+
let n = En(e, t.length === 7 ? `${t}99` : t);
|
|
3805
3847
|
this.previewGroup.add(new A.Image({
|
|
3806
3848
|
image: n,
|
|
3807
3849
|
x: e.ox,
|
|
@@ -3813,8 +3855,8 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3813
3855
|
}
|
|
3814
3856
|
previewMarquee(e, t) {
|
|
3815
3857
|
this.marquee || (this.marquee = new A.Rect({
|
|
3816
|
-
fill:
|
|
3817
|
-
stroke:
|
|
3858
|
+
fill: $e(Ye, Xe),
|
|
3859
|
+
stroke: Ye,
|
|
3818
3860
|
strokeWidth: 1,
|
|
3819
3861
|
strokeScaleEnabled: !1,
|
|
3820
3862
|
listening: !1,
|
|
@@ -3845,14 +3887,14 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3845
3887
|
setTransformerOutlinePoints(e) {
|
|
3846
3888
|
e.length < 2 || (this.transformerOutline || (this.transformerOutline = new A.Line({
|
|
3847
3889
|
closed: !0,
|
|
3848
|
-
stroke:
|
|
3890
|
+
stroke: Tr,
|
|
3849
3891
|
strokeWidth: 1,
|
|
3850
3892
|
strokeScaleEnabled: !1,
|
|
3851
3893
|
listening: !1
|
|
3852
3894
|
}), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
|
|
3853
3895
|
}
|
|
3854
3896
|
rotationHandleGap() {
|
|
3855
|
-
return
|
|
3897
|
+
return Sr(this.viewport.scale);
|
|
3856
3898
|
}
|
|
3857
3899
|
rotationHandleScreenPoint(e) {
|
|
3858
3900
|
return this.imgToScreen(xe(e, this.rotationHandleGap()));
|
|
@@ -3871,7 +3913,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3871
3913
|
n.x,
|
|
3872
3914
|
n.y
|
|
3873
3915
|
],
|
|
3874
|
-
stroke:
|
|
3916
|
+
stroke: Tr,
|
|
3875
3917
|
strokeWidth: 1,
|
|
3876
3918
|
listening: !1
|
|
3877
3919
|
}), this.handleGroup.add(this.rotLineNode));
|
|
@@ -3886,7 +3928,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3886
3928
|
}), e.rotation(n * 180 / Math.PI);
|
|
3887
3929
|
}
|
|
3888
3930
|
orientedHandleAngle(e) {
|
|
3889
|
-
return
|
|
3931
|
+
return Cr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
3890
3932
|
}
|
|
3891
3933
|
repositionOrientedHandles(e) {
|
|
3892
3934
|
let t = this.orientedHandleAngle(e);
|
|
@@ -3908,7 +3950,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3908
3950
|
for (let e of this.vertexNodes) e.destroy();
|
|
3909
3951
|
for (let e of this.midNodes) e.destroy();
|
|
3910
3952
|
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;
|
|
3911
|
-
let e =
|
|
3953
|
+
let e = _r(this.shapes, this.selected);
|
|
3912
3954
|
if (!e.length || e.length === 1 && e[0].type === L.POINT) return;
|
|
3913
3955
|
let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = H(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : oe.map((e) => U(e, n));
|
|
3914
3956
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -3923,12 +3965,12 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3923
3965
|
offsetY: 4,
|
|
3924
3966
|
rotation: a * 180 / Math.PI,
|
|
3925
3967
|
fill: "#ffffff",
|
|
3926
|
-
stroke:
|
|
3968
|
+
stroke: Tr,
|
|
3927
3969
|
strokeWidth: 1
|
|
3928
|
-
}), r =
|
|
3970
|
+
}), r = Ft(e, a);
|
|
3929
3971
|
this.bindCursor(n, r), n.on("mousedown", (t) => {
|
|
3930
3972
|
t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
3931
|
-
let n =
|
|
3973
|
+
let n = _r(this.shapes, this.selected);
|
|
3932
3974
|
this.activeDrag = {
|
|
3933
3975
|
kind: "resize",
|
|
3934
3976
|
anchor: e,
|
|
@@ -3945,7 +3987,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
3945
3987
|
radius: i * .8,
|
|
3946
3988
|
fill: "#ffffff",
|
|
3947
3989
|
opacity: .6,
|
|
3948
|
-
stroke:
|
|
3990
|
+
stroke: Tr,
|
|
3949
3991
|
strokeWidth: 1,
|
|
3950
3992
|
visible: !1,
|
|
3951
3993
|
listening: !1
|
|
@@ -4005,8 +4047,8 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
4005
4047
|
x: a.x,
|
|
4006
4048
|
y: a.y,
|
|
4007
4049
|
radius: i,
|
|
4008
|
-
fill: o ?
|
|
4009
|
-
stroke: o ? "#ffffff" :
|
|
4050
|
+
fill: o ? Tr : "#ffffff",
|
|
4051
|
+
stroke: o ? "#ffffff" : Tr,
|
|
4010
4052
|
strokeWidth: Math.max(1.5, i * .3)
|
|
4011
4053
|
});
|
|
4012
4054
|
this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
|
|
@@ -4031,7 +4073,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
4031
4073
|
y: r.y,
|
|
4032
4074
|
radius: 6,
|
|
4033
4075
|
fill: "#ffffff",
|
|
4034
|
-
stroke:
|
|
4076
|
+
stroke: Tr,
|
|
4035
4077
|
strokeWidth: 1.5
|
|
4036
4078
|
});
|
|
4037
4079
|
this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
|
|
@@ -4050,7 +4092,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
4050
4092
|
this.layer.batchDraw();
|
|
4051
4093
|
}
|
|
4052
4094
|
beginMove(e, t) {
|
|
4053
|
-
let n =
|
|
4095
|
+
let n = hr(this.shapes, t, e);
|
|
4054
4096
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4055
4097
|
}
|
|
4056
4098
|
repositionHandles(e) {
|
|
@@ -4092,7 +4134,7 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
4092
4134
|
let t = this.activeDrag;
|
|
4093
4135
|
if (!t) return;
|
|
4094
4136
|
this.applyCursor();
|
|
4095
|
-
let n =
|
|
4137
|
+
let n = fr(this.shapes, t), { updates: r, box: i } = pr(t, e, n);
|
|
4096
4138
|
for (let e of r) this.liveUpdateShape(e.id, e.points);
|
|
4097
4139
|
if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
|
|
4098
4140
|
n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
|
|
@@ -4119,18 +4161,18 @@ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
|
|
|
4119
4161
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4120
4162
|
return;
|
|
4121
4163
|
}
|
|
4122
|
-
let { updates: n } =
|
|
4164
|
+
let { updates: n } = pr(e, t, fr(this.shapes, e));
|
|
4123
4165
|
this.commitTransformUpdates(n);
|
|
4124
4166
|
}
|
|
4125
|
-
},
|
|
4126
|
-
function
|
|
4127
|
-
if (!e) return
|
|
4167
|
+
}, Or = 2, kr = 58879, Ar = 6725103;
|
|
4168
|
+
function jr(e) {
|
|
4169
|
+
if (!e) return kr;
|
|
4128
4170
|
let t = e.replace("#", "");
|
|
4129
4171
|
return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
|
|
4130
4172
|
}
|
|
4131
|
-
var
|
|
4173
|
+
var Mr = class {
|
|
4132
4174
|
constructor(e, t) {
|
|
4133
|
-
this.app = new j(), this.world = new N(), this.bgLayer = new N(), this.overlayLayer = new N(), this.guideOverlayLayer = new N(), this.regionOverlayLayer = new N(), this.dimOverlayLayer = new N(), this.shapeLayer = new N(), this.selLayer = new N(), this.previewLayer = new N(), this.handleLayer = new N(), this.filter = new M(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize =
|
|
4175
|
+
this.app = new j(), this.world = new N(), this.bgLayer = new N(), this.overlayLayer = new N(), this.guideOverlayLayer = new N(), this.regionOverlayLayer = new N(), this.dimOverlayLayer = new N(), this.shapeLayer = new N(), this.selLayer = new N(), this.previewLayer = new N(), this.handleLayer = new N(), this.filter = new M(), this.imageWidth = 0, this.imageHeight = 0, this.imageTileTextures = [], this.imageLoadToken = 0, this.tileSize = rr, this.overlayTextures = [], this.region = null, this.regionDimMaskG = new P(), this.regionDimG = new P(), this.regionZoneMaskG = new P(), this.regionZoneG = new P(), this.regionOutlineG = new P(), this.baseCursor = "default", this.strokeSize = Or, 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 P(), this.marqueeG = new P(), this.previewMaskSprite = null, this.previewMaskTexture = null, this.previewReady = !1, this.lastPreview = null, this.host = e, this.cb = t;
|
|
4134
4176
|
}
|
|
4135
4177
|
ev(e) {
|
|
4136
4178
|
return {
|
|
@@ -4160,7 +4202,7 @@ var jr = class {
|
|
|
4160
4202
|
}
|
|
4161
4203
|
this.host.appendChild(this.app.canvas);
|
|
4162
4204
|
let e = this.app.renderer.gl, t = e?.getParameter(e.MAX_TEXTURE_SIZE);
|
|
4163
|
-
typeof t == "number" && t > 1 && (this.tileSize = Math.min(
|
|
4205
|
+
typeof t == "number" && t > 1 && (this.tileSize = Math.min(rr, t - 1)), this.applyCursor(), this.overlayLayer.addChild(this.guideOverlayLayer, this.regionOverlayLayer, this.dimOverlayLayer), this.regionOverlayLayer.addChild(this.regionDimMaskG, this.regionDimG, this.regionZoneMaskG, this.regionZoneG, this.regionOutlineG), this.regionDimG.setMask({
|
|
4164
4206
|
mask: this.regionDimMaskG,
|
|
4165
4207
|
inverse: !0
|
|
4166
4208
|
}), this.regionZoneG.setMask({ mask: this.regionZoneMaskG }), this.world.addChild(this.bgLayer, this.overlayLayer, this.shapeLayer, this.selLayer, this.previewLayer), this.app.stage.addChild(this.world, this.handleLayer), this.world.visible = !1, this.app.stage.eventMode = "static", this.syncHitArea(), this.app.stage.on("pointerdown", (e) => {
|
|
@@ -4238,14 +4280,14 @@ var jr = class {
|
|
|
4238
4280
|
};
|
|
4239
4281
|
}
|
|
4240
4282
|
async setImage(e, t, n) {
|
|
4241
|
-
let r = ++this.imageLoadToken, i = await
|
|
4283
|
+
let r = ++this.imageLoadToken, i = await Jn(e);
|
|
4242
4284
|
if (this.destroyed || r !== this.imageLoadToken) return !0;
|
|
4243
4285
|
if (!i) return this.imageWidth ||= t?.width ?? 800, this.imageHeight ||= t?.height ?? 600, !1;
|
|
4244
4286
|
this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
|
|
4245
4287
|
let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
|
|
4246
4288
|
this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
|
|
4247
|
-
for (let e of
|
|
4248
|
-
let t = I.from(
|
|
4289
|
+
for (let e of ir(i.naturalWidth, i.naturalHeight, this.tileSize)) {
|
|
4290
|
+
let t = I.from(ar(i, e));
|
|
4249
4291
|
t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
|
|
4250
4292
|
let n = new te(t);
|
|
4251
4293
|
n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
|
|
@@ -4304,7 +4346,7 @@ var jr = class {
|
|
|
4304
4346
|
}
|
|
4305
4347
|
setRegionOverlay(e) {
|
|
4306
4348
|
if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
|
|
4307
|
-
let t =
|
|
4349
|
+
let t = jr(e.dim.color);
|
|
4308
4350
|
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);
|
|
4309
4351
|
this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
|
|
4310
4352
|
color: t,
|
|
@@ -4325,7 +4367,7 @@ var jr = class {
|
|
|
4325
4367
|
}
|
|
4326
4368
|
applyViewport(e) {
|
|
4327
4369
|
let t = e.scale !== this.lastAppliedScale;
|
|
4328
|
-
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 ??
|
|
4370
|
+
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 ?? mr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
|
|
4329
4371
|
}
|
|
4330
4372
|
fit() {
|
|
4331
4373
|
if (!this.imageWidth || !this.imageHeight) return;
|
|
@@ -4361,7 +4403,7 @@ var jr = class {
|
|
|
4361
4403
|
});
|
|
4362
4404
|
}
|
|
4363
4405
|
setShapes(e, t) {
|
|
4364
|
-
this.shapes =
|
|
4406
|
+
this.shapes = gr(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
|
|
4365
4407
|
}
|
|
4366
4408
|
setSelection(e) {
|
|
4367
4409
|
this.selected = e, (e.length !== 1 || e[0] !== this.vertexPolygonId) && (this.vertexPolygonId = null, this.selectedVertices.clear()), this.editingId && (e.length !== 1 || e[0] !== this.editingId) && (this.editingId = null), !this.activeDrag && (this.drawSelectionBorders(), this.drawTransformer());
|
|
@@ -4384,13 +4426,13 @@ var jr = class {
|
|
|
4384
4426
|
this.handleLayer.interactiveChildren = !e;
|
|
4385
4427
|
}
|
|
4386
4428
|
strokeW(e) {
|
|
4387
|
-
return (e ?
|
|
4429
|
+
return (e ? Qe(e, { strokeWidth: this.strokeSize }).strokeWidth : Or) / this.world.scale.x;
|
|
4388
4430
|
}
|
|
4389
4431
|
pointRadius(e) {
|
|
4390
|
-
return
|
|
4432
|
+
return yr(e, this.strokeSize, this.world.scale.x);
|
|
4391
4433
|
}
|
|
4392
4434
|
dashForShape(e) {
|
|
4393
|
-
let t =
|
|
4435
|
+
let t = Qe(e, { strokeWidth: this.strokeSize }).dash;
|
|
4394
4436
|
if (!t?.length) return null;
|
|
4395
4437
|
let n = this.world.scale.x || 1;
|
|
4396
4438
|
return [t[0] / n, (t[1] ?? t[0]) / n];
|
|
@@ -4402,7 +4444,7 @@ var jr = class {
|
|
|
4402
4444
|
for (let e of B(this.shapes).filter(ne)) {
|
|
4403
4445
|
let t = new P();
|
|
4404
4446
|
this.paintShape(t, e), t.eventMode = R(e) ? "static" : "none", t.cursor = void 0, R(e) && z(e) && (t.on("pointerover", () => {
|
|
4405
|
-
this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" :
|
|
4447
|
+
this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" : Nt);
|
|
4406
4448
|
}), t.on("pointerout", () => {
|
|
4407
4449
|
this.activeDrag || this.emitCursorHint(null);
|
|
4408
4450
|
})), t.on("pointerdown", (t) => {
|
|
@@ -4412,16 +4454,16 @@ var jr = class {
|
|
|
4412
4454
|
}
|
|
4413
4455
|
paintShape(e, t) {
|
|
4414
4456
|
e.clear();
|
|
4415
|
-
let n =
|
|
4457
|
+
let n = Qe(t, { strokeWidth: this.strokeSize }), r = jr(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
|
|
4416
4458
|
if (t.type === L.POINT) {
|
|
4417
|
-
e.svg(
|
|
4459
|
+
e.svg(ur(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
|
|
4418
4460
|
let r = 1 / (this.world.scale.x || 1);
|
|
4419
4461
|
e.scale.set(r, r), e.alpha = a;
|
|
4420
4462
|
return;
|
|
4421
4463
|
}
|
|
4422
4464
|
if (n.fillVisible && t.type !== L.LINE) {
|
|
4423
|
-
let i = t.type === L.POLYGON ?
|
|
4424
|
-
if (i && i.length > 1) for (let t of
|
|
4465
|
+
let i = t.type === L.POLYGON ? Fe(t.points) : null;
|
|
4466
|
+
if (i && (i.length > 1 || i[0].holes.length > 0)) for (let t of i) for (let i = 0; i < Math.min(t.layers, 4); i++) {
|
|
4425
4467
|
e.poly(t.outline.flatMap((e) => [e.x, e.y]), !0), e.fill({
|
|
4426
4468
|
color: r,
|
|
4427
4469
|
alpha: n.fillAlpha * a
|
|
@@ -4439,7 +4481,7 @@ var jr = class {
|
|
|
4439
4481
|
if (o) {
|
|
4440
4482
|
t.style?.alternateColor && (this.path(e, t), e.stroke({
|
|
4441
4483
|
width: i,
|
|
4442
|
-
color:
|
|
4484
|
+
color: jr(t.style.alternateColor),
|
|
4443
4485
|
alpha: a
|
|
4444
4486
|
})), this.dashedStrokeShape(e, t, i, r, a, o);
|
|
4445
4487
|
return;
|
|
@@ -4458,7 +4500,7 @@ var jr = class {
|
|
|
4458
4500
|
});
|
|
4459
4501
|
}
|
|
4460
4502
|
shapesIntersecting(e) {
|
|
4461
|
-
return
|
|
4503
|
+
return vr(this.shapes, e);
|
|
4462
4504
|
}
|
|
4463
4505
|
shapesAt(e) {
|
|
4464
4506
|
return this.shapes.filter((t) => {
|
|
@@ -4495,16 +4537,16 @@ var jr = class {
|
|
|
4495
4537
|
}, a = this.strokeW(i);
|
|
4496
4538
|
r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
|
|
4497
4539
|
width: a,
|
|
4498
|
-
color:
|
|
4540
|
+
color: jr(r.alternateColor)
|
|
4499
4541
|
}));
|
|
4500
4542
|
let o = this.dashForShape(i);
|
|
4501
4543
|
if (o) {
|
|
4502
|
-
this.dashedStrokeShape(this.previewG, i, a,
|
|
4544
|
+
this.dashedStrokeShape(this.previewG, i, a, jr(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
|
|
4503
4545
|
return;
|
|
4504
4546
|
}
|
|
4505
4547
|
this.path(this.previewG, i), this.previewG.stroke({
|
|
4506
4548
|
width: a,
|
|
4507
|
-
color:
|
|
4549
|
+
color: jr(r.color ?? "#00e5ff"),
|
|
4508
4550
|
alpha: r.opacity ?? 1
|
|
4509
4551
|
});
|
|
4510
4552
|
}
|
|
@@ -4526,12 +4568,12 @@ var jr = class {
|
|
|
4526
4568
|
}, c = this.strokeW(s);
|
|
4527
4569
|
n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
|
|
4528
4570
|
width: c,
|
|
4529
|
-
color:
|
|
4571
|
+
color: jr(n.alternateColor)
|
|
4530
4572
|
}));
|
|
4531
4573
|
let l = this.dashForShape(s);
|
|
4532
|
-
if (l ? this.dashedStrokeShape(this.previewG, s, c,
|
|
4574
|
+
if (l ? this.dashedStrokeShape(this.previewG, s, c, jr(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
|
|
4533
4575
|
width: c,
|
|
4534
|
-
color:
|
|
4576
|
+
color: jr(n.color ?? "#00e5ff"),
|
|
4535
4577
|
alpha: n.opacity ?? 1
|
|
4536
4578
|
})), !a) return;
|
|
4537
4579
|
let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
|
|
@@ -4545,15 +4587,15 @@ var jr = class {
|
|
|
4545
4587
|
}
|
|
4546
4588
|
previewScalarMask(e, t) {
|
|
4547
4589
|
this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
|
|
4548
|
-
let n =
|
|
4590
|
+
let n = En(e, t.length === 7 ? `${t}99` : t);
|
|
4549
4591
|
this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = I.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new te(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;
|
|
4550
4592
|
}
|
|
4551
4593
|
previewMarquee(e, t) {
|
|
4552
4594
|
this.ensurePreview(), this.marqueeG.clear();
|
|
4553
|
-
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 =
|
|
4595
|
+
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 = jr(Ye);
|
|
4554
4596
|
this.marqueeG.rect(n, r, i, a).fill({
|
|
4555
4597
|
color: o,
|
|
4556
|
-
alpha:
|
|
4598
|
+
alpha: Xe
|
|
4557
4599
|
}).stroke({
|
|
4558
4600
|
width: 1 / this.world.scale.x,
|
|
4559
4601
|
color: o
|
|
@@ -4584,8 +4626,8 @@ var jr = class {
|
|
|
4584
4626
|
o.y
|
|
4585
4627
|
], !1).stroke({
|
|
4586
4628
|
width: i,
|
|
4587
|
-
color:
|
|
4588
|
-
}), this.strokeDashedPolyline(e, [n, o], !1, i,
|
|
4629
|
+
color: jr(r.underlayColor)
|
|
4630
|
+
}), this.strokeDashedPolyline(e, [n, o], !1, i, jr(r.color), r.opacity, a);
|
|
4589
4631
|
};
|
|
4590
4632
|
r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
|
|
4591
4633
|
}
|
|
@@ -4697,7 +4739,7 @@ var jr = class {
|
|
|
4697
4739
|
let r = this.selectionBorderGfx[t];
|
|
4698
4740
|
r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4699
4741
|
width: n,
|
|
4700
|
-
color:
|
|
4742
|
+
color: Ar
|
|
4701
4743
|
});
|
|
4702
4744
|
});
|
|
4703
4745
|
}
|
|
@@ -4708,12 +4750,12 @@ var jr = class {
|
|
|
4708
4750
|
let a = this.selectionBorderGfx[r++];
|
|
4709
4751
|
a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
|
|
4710
4752
|
width: n,
|
|
4711
|
-
color:
|
|
4753
|
+
color: Ar
|
|
4712
4754
|
}));
|
|
4713
4755
|
}
|
|
4714
4756
|
}
|
|
4715
4757
|
selectionOutlinePoints(e, t) {
|
|
4716
|
-
return
|
|
4758
|
+
return xr(e, t, this.pointRadius(e));
|
|
4717
4759
|
}
|
|
4718
4760
|
imgToScreen(e) {
|
|
4719
4761
|
let t = this.world.toGlobal({
|
|
@@ -4742,7 +4784,7 @@ var jr = class {
|
|
|
4742
4784
|
}));
|
|
4743
4785
|
}
|
|
4744
4786
|
rotationHandleGap() {
|
|
4745
|
-
return
|
|
4787
|
+
return Sr(this.viewport.scale);
|
|
4746
4788
|
}
|
|
4747
4789
|
rotationHandleScreenPoint(e) {
|
|
4748
4790
|
return this.imgToScreen(xe(e, this.rotationHandleGap()));
|
|
@@ -4758,7 +4800,7 @@ var jr = class {
|
|
|
4758
4800
|
e.position.set(t.x, t.y), e.rotation = n;
|
|
4759
4801
|
}
|
|
4760
4802
|
orientedHandleAngle(e) {
|
|
4761
|
-
return
|
|
4803
|
+
return Cr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
|
|
4762
4804
|
}
|
|
4763
4805
|
drawTransformer() {
|
|
4764
4806
|
if (this.activeDrag) return;
|
|
@@ -4766,7 +4808,7 @@ var jr = class {
|
|
|
4766
4808
|
for (let e of this.vertexNodes) e.destroy();
|
|
4767
4809
|
for (let e of this.midNodes) e.destroy();
|
|
4768
4810
|
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;
|
|
4769
|
-
let e =
|
|
4811
|
+
let e = _r(this.shapes, this.selected);
|
|
4770
4812
|
if (e.length === 0 || e.length === 1 && e[0].type === L.POINT) return;
|
|
4771
4813
|
let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = H(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : oe.map((e) => U(e, n));
|
|
4772
4814
|
r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
|
|
@@ -4777,10 +4819,10 @@ var jr = class {
|
|
|
4777
4819
|
width: 1,
|
|
4778
4820
|
color: 2001125
|
|
4779
4821
|
}), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
|
|
4780
|
-
let r =
|
|
4822
|
+
let r = Ft(e, a);
|
|
4781
4823
|
this.bindCursor(n, r), n.on("pointerdown", (t) => {
|
|
4782
4824
|
t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
|
|
4783
|
-
let n =
|
|
4825
|
+
let n = _r(this.shapes, this.selected);
|
|
4784
4826
|
this.activeDrag = {
|
|
4785
4827
|
kind: "resize",
|
|
4786
4828
|
anchor: e,
|
|
@@ -4877,7 +4919,7 @@ var jr = class {
|
|
|
4877
4919
|
}
|
|
4878
4920
|
}
|
|
4879
4921
|
beginMove(e, t) {
|
|
4880
|
-
let n =
|
|
4922
|
+
let n = hr(this.shapes, t, e);
|
|
4881
4923
|
n && (this.transformEnabled && !this.handleNodes.length && this.drawTransformer(), this.activeDrag = n, this.lastDragImg = null, this.emitCursorHint("grabbing"), this.emitInteractionMode("moving"), (n.shapes.length === 1 ? this.shapes.find((e) => e.id === n.shapes[0].id) : null)?.type === L.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
|
|
4882
4924
|
}
|
|
4883
4925
|
repositionHandlesForBox(e) {
|
|
@@ -4945,7 +4987,7 @@ var jr = class {
|
|
|
4945
4987
|
let t = this.activeDrag;
|
|
4946
4988
|
if (!t) return;
|
|
4947
4989
|
this.applyCursor();
|
|
4948
|
-
let n =
|
|
4990
|
+
let n = fr(this.shapes, t), { updates: r, box: i } = pr(t, e, n);
|
|
4949
4991
|
if (t.kind === "move") {
|
|
4950
4992
|
let n = e.x - t.start.x, r = e.y - t.start.y;
|
|
4951
4993
|
for (let e of t.shapes) {
|
|
@@ -4977,13 +5019,13 @@ var jr = class {
|
|
|
4977
5019
|
this.cb.onTransformPreview?.([]), this.drawTransformer();
|
|
4978
5020
|
return;
|
|
4979
5021
|
}
|
|
4980
|
-
let { updates: n } =
|
|
5022
|
+
let { updates: n } = pr(e, t, fr(this.shapes, e));
|
|
4981
5023
|
e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
|
|
4982
5024
|
}
|
|
4983
5025
|
};
|
|
4984
5026
|
//#endregion
|
|
4985
5027
|
//#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
|
|
4986
|
-
function
|
|
5028
|
+
function Nr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
|
|
4987
5029
|
if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
|
|
4988
5030
|
let i = e !== t;
|
|
4989
5031
|
return !i && n === r ? { kind: "none" } : {
|
|
@@ -4991,7 +5033,7 @@ function Mr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
|
|
|
4991
5033
|
docChange: i
|
|
4992
5034
|
};
|
|
4993
5035
|
}
|
|
4994
|
-
function
|
|
5036
|
+
function Pr({ 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: p, regionOverlayRef: m, dimmedRef: h, syncMinimap: g, setImage: _, setImageVisible: v, setReady: y, setImageStatus: b, onContextMenuRequest: x }) {
|
|
4995
5037
|
let C = O(i);
|
|
4996
5038
|
C.current = i;
|
|
4997
5039
|
let w = O(r);
|
|
@@ -5002,12 +5044,12 @@ function Nr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5002
5044
|
j.current = x, S(() => {
|
|
5003
5045
|
let r = t.current;
|
|
5004
5046
|
if (!r) return;
|
|
5005
|
-
let i = !1, a = null, x = null, S = A.current(), O = e === "konva" ? new
|
|
5047
|
+
let i = !1, a = null, x = null, S = A.current(), O = e === "konva" ? new Dr(r, S) : new Mr(r, S);
|
|
5006
5048
|
return n.current = O, (async () => {
|
|
5007
5049
|
try {
|
|
5008
5050
|
await O.init();
|
|
5009
5051
|
} catch (e) {
|
|
5010
|
-
i || b("error",
|
|
5052
|
+
i || b("error", nr(e));
|
|
5011
5053
|
return;
|
|
5012
5054
|
}
|
|
5013
5055
|
if (i) return;
|
|
@@ -5018,7 +5060,7 @@ function Nr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5018
5060
|
try {
|
|
5019
5061
|
n = await O.setImage(e, u.current, d.current);
|
|
5020
5062
|
} catch (t) {
|
|
5021
|
-
!i && C.current === e && b("error",
|
|
5063
|
+
!i && C.current === e && b("error", nr(t));
|
|
5022
5064
|
}
|
|
5023
5065
|
if (i) return;
|
|
5024
5066
|
if (n !== null) {
|
|
@@ -5029,7 +5071,7 @@ function Nr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5029
5071
|
let r = k.current;
|
|
5030
5072
|
r?.viewport && (r.imageUrl === T.current || o.current.keepZoomOnImageChange) ? O.applyViewport(r.viewport) : O.fit(), g(), y(!0);
|
|
5031
5073
|
let a = () => C.current === e;
|
|
5032
|
-
n ? a() && b("ready") :
|
|
5074
|
+
n ? a() && b("ready") : $n(e).then((e) => {
|
|
5033
5075
|
!i && a() && b("error", e);
|
|
5034
5076
|
});
|
|
5035
5077
|
}
|
|
@@ -5073,7 +5115,7 @@ function Nr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5073
5115
|
}, [e]), S(() => {
|
|
5074
5116
|
let e = n.current;
|
|
5075
5117
|
if (!e || !D.current) return;
|
|
5076
|
-
let t =
|
|
5118
|
+
let t = Nr({
|
|
5077
5119
|
currentDocId: E.current,
|
|
5078
5120
|
documentId: r,
|
|
5079
5121
|
loadedUrl: T.current,
|
|
@@ -5096,7 +5138,7 @@ function Nr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5096
5138
|
try {
|
|
5097
5139
|
i = await e.setImage(s, u.current, d.current);
|
|
5098
5140
|
} catch (t) {
|
|
5099
|
-
!c && n.current === e && b("error",
|
|
5141
|
+
!c && n.current === e && b("error", nr(t));
|
|
5100
5142
|
return;
|
|
5101
5143
|
}
|
|
5102
5144
|
if (c || n.current !== e) return;
|
|
@@ -5106,7 +5148,7 @@ function Nr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5106
5148
|
b("ready");
|
|
5107
5149
|
return;
|
|
5108
5150
|
}
|
|
5109
|
-
|
|
5151
|
+
$n(s).then((e) => {
|
|
5110
5152
|
c || b("error", e);
|
|
5111
5153
|
});
|
|
5112
5154
|
};
|
|
@@ -5125,19 +5167,19 @@ function Nr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
|
|
|
5125
5167
|
}
|
|
5126
5168
|
//#endregion
|
|
5127
5169
|
//#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
|
|
5128
|
-
var
|
|
5129
|
-
function
|
|
5170
|
+
var Fr = .05, Ir = 20;
|
|
5171
|
+
function Lr(e) {
|
|
5130
5172
|
let { deltaY: t, deltaX: n, deltaMode: r } = e;
|
|
5131
5173
|
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);
|
|
5132
5174
|
}
|
|
5133
|
-
function
|
|
5175
|
+
function Rr(e) {
|
|
5134
5176
|
let t = e.currentTarget.getBoundingClientRect();
|
|
5135
5177
|
return {
|
|
5136
5178
|
x: e.clientX - t.left,
|
|
5137
5179
|
y: e.clientY - t.top
|
|
5138
5180
|
};
|
|
5139
5181
|
}
|
|
5140
|
-
function
|
|
5182
|
+
function zr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
5141
5183
|
let i = O(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 = x(() => {
|
|
5142
5184
|
let t = e.current;
|
|
5143
5185
|
if (!t) return null;
|
|
@@ -5175,7 +5217,7 @@ function Rr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5175
5217
|
let n = e.current, r = d();
|
|
5176
5218
|
if (!n || !r) return;
|
|
5177
5219
|
t.preventDefault(), t.stopPropagation();
|
|
5178
|
-
let a =
|
|
5220
|
+
let a = Rr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
|
|
5179
5221
|
offsetX: a.x - r.x,
|
|
5180
5222
|
offsetY: a.y - r.y
|
|
5181
5223
|
} : {
|
|
@@ -5192,7 +5234,7 @@ function Rr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5192
5234
|
d
|
|
5193
5235
|
]), m = x((t) => {
|
|
5194
5236
|
let n = i.current, r = e.current;
|
|
5195
|
-
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(
|
|
5237
|
+
!n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(Rr(t), r.viewport.scale, n));
|
|
5196
5238
|
}, [f, e]), h = x((e) => {
|
|
5197
5239
|
let t = i.current;
|
|
5198
5240
|
!t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
|
|
@@ -5200,8 +5242,8 @@ function Rr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5200
5242
|
let r = e.current;
|
|
5201
5243
|
if (!r || !n) return;
|
|
5202
5244
|
t.preventDefault(), t.stopPropagation();
|
|
5203
|
-
let i =
|
|
5204
|
-
f(
|
|
5245
|
+
let i = Lr(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(Fr, Math.min(Ir, s));
|
|
5246
|
+
f(Rr(t), c);
|
|
5205
5247
|
}, [
|
|
5206
5248
|
f,
|
|
5207
5249
|
e,
|
|
@@ -5238,7 +5280,7 @@ function Rr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
|
|
|
5238
5280
|
}
|
|
5239
5281
|
//#endregion
|
|
5240
5282
|
//#region src/components/ShapeEditor/_state/useMinimapSync.ts
|
|
5241
|
-
function
|
|
5283
|
+
function Br(e, t, n) {
|
|
5242
5284
|
if (!(!e || !n.length)) {
|
|
5243
5285
|
if (t.type === L.POINT) {
|
|
5244
5286
|
e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
|
|
@@ -5256,7 +5298,7 @@ function zr(e, t, n) {
|
|
|
5256
5298
|
e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
|
|
5257
5299
|
}
|
|
5258
5300
|
}
|
|
5259
|
-
function
|
|
5301
|
+
function Vr({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
|
|
5260
5302
|
let s = O(/* @__PURE__ */ new Map());
|
|
5261
5303
|
return {
|
|
5262
5304
|
registerMinimapShape: x((e, t) => {
|
|
@@ -5265,13 +5307,13 @@ function Br({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
5265
5307
|
applyMinimapPreview: x((e) => {
|
|
5266
5308
|
let n = t.current.getShapes();
|
|
5267
5309
|
if (!e.length) {
|
|
5268
|
-
for (let e of n)
|
|
5310
|
+
for (let e of n) Br(s.current.get(e.id), e, e.points);
|
|
5269
5311
|
return;
|
|
5270
5312
|
}
|
|
5271
5313
|
let r = new Map(n.map((e) => [e.id, e]));
|
|
5272
5314
|
for (let t of e) {
|
|
5273
5315
|
let e = r.get(t.id);
|
|
5274
|
-
e &&
|
|
5316
|
+
e && Br(s.current.get(e.id), e, t.points);
|
|
5275
5317
|
}
|
|
5276
5318
|
}, [t]),
|
|
5277
5319
|
syncMinimap: x(() => {
|
|
@@ -5300,8 +5342,8 @@ function Br({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
|
|
|
5300
5342
|
}
|
|
5301
5343
|
//#endregion
|
|
5302
5344
|
//#region src/components/ShapeEditor/_state/useSelectionActions.ts
|
|
5303
|
-
var
|
|
5304
|
-
function
|
|
5345
|
+
var Hr = 12;
|
|
5346
|
+
function Ur({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
|
|
5305
5347
|
let s = O(0), c = O(!0), l = O(n), u = O(a), d = O(o);
|
|
5306
5348
|
l.current = n, u.current = a, d.current = o, S(() => (c.current = !0, () => {
|
|
5307
5349
|
c.current = !1;
|
|
@@ -5320,22 +5362,22 @@ function Hr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5320
5362
|
t
|
|
5321
5363
|
]), g = x(() => {
|
|
5322
5364
|
let e = m();
|
|
5323
|
-
e.length && (s.current = 0,
|
|
5365
|
+
e.length && (s.current = 0, Tt(xt(e, a, o)));
|
|
5324
5366
|
}, [
|
|
5325
5367
|
a,
|
|
5326
5368
|
o,
|
|
5327
5369
|
m
|
|
5328
|
-
]), _ = x(() =>
|
|
5370
|
+
]), _ = x(() => Dt(o), [o]), v = x((t) => {
|
|
5329
5371
|
if (n) return;
|
|
5330
5372
|
let i = a;
|
|
5331
|
-
|
|
5373
|
+
Ot(o).then((n) => {
|
|
5332
5374
|
if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
|
|
5333
5375
|
let f, p, m = n.shapes.flatMap((e) => e.points);
|
|
5334
5376
|
if (t && m.length) {
|
|
5335
5377
|
let e = H(m);
|
|
5336
5378
|
f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
|
|
5337
5379
|
} else {
|
|
5338
|
-
let e = !!n.documentId && n.documentId !== a, t =
|
|
5380
|
+
let e = !!n.documentId && n.documentId !== a, t = kt(s.current, e, Hr);
|
|
5339
5381
|
f = t.offset, s.current = t.nextPasteCount, p = f;
|
|
5340
5382
|
}
|
|
5341
5383
|
let h = n.shapes.map((e) => ({
|
|
@@ -5360,8 +5402,8 @@ function Hr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5360
5402
|
...e,
|
|
5361
5403
|
id: ae(),
|
|
5362
5404
|
points: e.points.map((e) => ({
|
|
5363
|
-
x: e.x +
|
|
5364
|
-
y: e.y +
|
|
5405
|
+
x: e.x + Hr,
|
|
5406
|
+
y: e.y + Hr
|
|
5365
5407
|
}))
|
|
5366
5408
|
}));
|
|
5367
5409
|
i.length && (e.create(i), r(i.map((e) => e.id)));
|
|
@@ -5419,9 +5461,9 @@ function Hr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5419
5461
|
if (n) return;
|
|
5420
5462
|
let t = T();
|
|
5421
5463
|
if (t.length < 2 || i && !i(t)) return;
|
|
5422
|
-
let a =
|
|
5464
|
+
let a = wn([], 1, Cn(t));
|
|
5423
5465
|
if (!a) return;
|
|
5424
|
-
let o =
|
|
5466
|
+
let o = Tn(a, 1);
|
|
5425
5467
|
if (!o.length) return;
|
|
5426
5468
|
let s = t[0], c = o.map((e) => ({
|
|
5427
5469
|
id: ae(),
|
|
@@ -5442,12 +5484,12 @@ function Hr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
|
|
|
5442
5484
|
}
|
|
5443
5485
|
//#endregion
|
|
5444
5486
|
//#region src/components/ShapeEditor/_state/useViewportControls.ts
|
|
5445
|
-
function
|
|
5487
|
+
function Wr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
|
|
5446
5488
|
let o = O(null), s = O(null), c = x(() => {
|
|
5447
5489
|
o.current?.(), o.current = null;
|
|
5448
5490
|
}, []), l = x((t, n = r) => {
|
|
5449
5491
|
let i = e.current;
|
|
5450
|
-
i && (c(), o.current =
|
|
5492
|
+
i && (c(), o.current = sn(i.viewport, t, (e) => i.applyViewport(e), n));
|
|
5451
5493
|
}, [
|
|
5452
5494
|
c,
|
|
5453
5495
|
r,
|
|
@@ -5455,14 +5497,14 @@ function Ur({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5455
5497
|
]), u = x((t, n = r) => {
|
|
5456
5498
|
let i = e.current;
|
|
5457
5499
|
if (!i) return;
|
|
5458
|
-
let a =
|
|
5500
|
+
let a = an(t, i.screenSize.w, i.screenSize.h);
|
|
5459
5501
|
a && l(a, n);
|
|
5460
5502
|
}, [
|
|
5461
5503
|
l,
|
|
5462
5504
|
r,
|
|
5463
5505
|
e
|
|
5464
5506
|
]), d = x((e, n = r) => {
|
|
5465
|
-
let i =
|
|
5507
|
+
let i = rn(t.getShapes().filter((t) => e.includes(t.id)));
|
|
5466
5508
|
i && u(i, n);
|
|
5467
5509
|
}, [
|
|
5468
5510
|
t,
|
|
@@ -5473,7 +5515,7 @@ function Ur({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5473
5515
|
if (!r.length) return;
|
|
5474
5516
|
let i = e.current;
|
|
5475
5517
|
if (!i) return;
|
|
5476
|
-
let a =
|
|
5518
|
+
let a = on(H(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
|
|
5477
5519
|
a && l(a);
|
|
5478
5520
|
}, [
|
|
5479
5521
|
t,
|
|
@@ -5514,47 +5556,47 @@ function Ur({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
|
|
|
5514
5556
|
}
|
|
5515
5557
|
//#endregion
|
|
5516
5558
|
//#region src/components/ShapeEditor/ShapeEditor.tsx
|
|
5517
|
-
var
|
|
5559
|
+
var Gr = "__draft_preview__", Kr = new Set([
|
|
5518
5560
|
"copy",
|
|
5519
5561
|
"selectAll",
|
|
5520
5562
|
"clearSelection",
|
|
5521
5563
|
"zoomToSelection"
|
|
5522
5564
|
]);
|
|
5523
|
-
function
|
|
5565
|
+
function qr(e, t) {
|
|
5524
5566
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
5525
5567
|
}
|
|
5526
|
-
function
|
|
5527
|
-
let Te = O(null), W = O(null), Ee = O(null), De = O(null), Oe = O(null), ke = `${C()}-minimap`, [G, Ae] = k(null), [je, Me] = k(!1), [K, Ne] = k(!1), [Pe,
|
|
5568
|
+
function Jr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !1, selectedIds: i, activeTool: a, draftStyle: s, draftMeta: c, readOnly: l, disableMarquee: u, locked: d, onLockedInteraction: f, onDrawAttemptWithoutDraft: p, onIdleEscape: m, overrideShapeInteraction: h, defaultViewSettings: g, viewSettings: _, onViewSettingsChange: b, showMinimap: D = !0, minimapPosition: A = "bottom-left", showViewSettings: j = !0, getContextMenuItems: M, strings: N, canMergeSelection: P, brushSize: F = 20, zoomBound: ee, zoomAnimationDuration: te = 300, decorationShapes: I, regionMask: re, guideMask: z, maskPalette: B, overlayMarkers: V, renderOverlayMarker: oe, onOverlayMarkerClick: H, renderImageOverlay: U, getSelectionLabel: se, hideSelectionLabelDot: ce, formatSelectionInfo: le, externalTools: ue, assistant: de, keymap: fe, handleRef: pe, backend: me = "pixi", onActiveToolChange: he, onSelectionChange: ge, onEditingChange: _e, onShapesCreated: ve, onShapesUpdated: ye, onShapesDeleted: be, onDrawSessionChange: xe, onDraftShapeChange: Se, onViewportChange: Ce, onShapesTransformPreview: we }) {
|
|
5569
|
+
let Te = O(null), W = O(null), Ee = O(null), De = O(null), Oe = O(null), ke = `${C()}-minimap`, [G, Ae] = k(null), [je, Me] = k(!1), [K, Ne] = k(!1), [Pe, Fe] = k(null), [q, Re] = k({
|
|
5528
5570
|
active: !1,
|
|
5529
5571
|
kind: "none",
|
|
5530
5572
|
canUndo: !1,
|
|
5531
5573
|
canRedo: !1
|
|
5532
|
-
}), [ze, Be] = k(!0), [
|
|
5533
|
-
tt(e),
|
|
5534
|
-
}, []), Y =
|
|
5574
|
+
}), [ze, Be] = k(!0), [Ve, Ue] = k(!1), qe = e?.id ?? "", Je = e?.imageUrl ?? "", Ye = e?.displayImageUrl, Xe = e?.coordinateSize, Ze = e?.initialShapes, Qe = e?.initialSelectedIds, $e = Ye ?? Je, [et, tt] = k("loading"), nt = et === "loading" && e !== null && !$e ? "missing" : et, [rt, it] = k(null), at = x((e, t) => {
|
|
5575
|
+
tt(e), it(e === "error" ? t ?? null : null);
|
|
5576
|
+
}, []), Y = In({
|
|
5535
5577
|
onShapesCreated: ve,
|
|
5536
5578
|
onShapesUpdated: ye,
|
|
5537
5579
|
onShapesDeleted: be
|
|
5538
|
-
}), [
|
|
5580
|
+
}), [st, ct] = k([]), X = i ?? st, lt = i !== void 0, pt = E(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), ht = O(pt);
|
|
5539
5581
|
T(() => {
|
|
5540
|
-
|
|
5541
|
-
}, [
|
|
5542
|
-
let
|
|
5543
|
-
|
|
5544
|
-
let
|
|
5582
|
+
ht.current = pt;
|
|
5583
|
+
}, [pt]);
|
|
5584
|
+
let gt = O(q);
|
|
5585
|
+
gt.current = q;
|
|
5586
|
+
let _t = E(() => {
|
|
5545
5587
|
let e = Object.fromEntries(Object.entries(g ?? {}).filter(([, e]) => e !== void 0));
|
|
5546
5588
|
return {
|
|
5547
|
-
...
|
|
5589
|
+
...Le,
|
|
5548
5590
|
...e
|
|
5549
5591
|
};
|
|
5550
|
-
}, [g]),
|
|
5551
|
-
|
|
5552
|
-
let [Z,
|
|
5592
|
+
}, [g]), vt = O(_t);
|
|
5593
|
+
vt.current = _t;
|
|
5594
|
+
let [Z, yt] = k(() => vt.current), bt = x((e) => yt((t) => ({
|
|
5553
5595
|
...t,
|
|
5554
5596
|
...e
|
|
5555
|
-
})), []), Q = E(() =>
|
|
5597
|
+
})), []), Q = E(() => Ie(N), [N]);
|
|
5556
5598
|
S(() => {
|
|
5557
|
-
_ &&
|
|
5599
|
+
_ && yt((e) => {
|
|
5558
5600
|
let t = Object.entries(_).filter(([t, n]) => n !== void 0 && e[t] !== n);
|
|
5559
5601
|
return t.length ? {
|
|
5560
5602
|
...e,
|
|
@@ -5562,80 +5604,80 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5562
5604
|
} : e;
|
|
5563
5605
|
});
|
|
5564
5606
|
}, [_]);
|
|
5565
|
-
let
|
|
5566
|
-
|
|
5567
|
-
let
|
|
5607
|
+
let xt = O(b);
|
|
5608
|
+
xt.current = b;
|
|
5609
|
+
let Ct = O(!1);
|
|
5568
5610
|
S(() => {
|
|
5569
|
-
if (!
|
|
5570
|
-
|
|
5611
|
+
if (!Ct.current) {
|
|
5612
|
+
Ct.current = !0;
|
|
5571
5613
|
return;
|
|
5572
5614
|
}
|
|
5573
|
-
|
|
5615
|
+
xt.current?.(Z);
|
|
5574
5616
|
}, [Z]);
|
|
5575
|
-
let
|
|
5576
|
-
|
|
5577
|
-
let
|
|
5578
|
-
|
|
5579
|
-
let
|
|
5580
|
-
|
|
5581
|
-
let
|
|
5582
|
-
|
|
5583
|
-
let
|
|
5584
|
-
|
|
5585
|
-
let
|
|
5586
|
-
|
|
5587
|
-
let
|
|
5617
|
+
let wt = E(() => !z || !B ? null : Bt(z, B), [z, B]), Tt = E(() => wt?.toDataURL() ?? null, [wt]), Et = E(() => !G || !re ? null : Zt(re, G.w, G.h), [G, re]), Dt = O(wt);
|
|
5618
|
+
Dt.current = wt;
|
|
5619
|
+
let Ot = O(Et);
|
|
5620
|
+
Ot.current = Et;
|
|
5621
|
+
let kt = O(r);
|
|
5622
|
+
kt.current = r;
|
|
5623
|
+
let At = O(G);
|
|
5624
|
+
At.current = G;
|
|
5625
|
+
let jt = O(Xe);
|
|
5626
|
+
jt.current = Xe;
|
|
5627
|
+
let Mt = O(Xe?.imageSize);
|
|
5628
|
+
Mt.current = Xe?.imageSize;
|
|
5629
|
+
let Nt = O(X);
|
|
5588
5630
|
T(() => {
|
|
5589
|
-
|
|
5631
|
+
Nt.current = X;
|
|
5590
5632
|
}, [X]);
|
|
5591
|
-
let
|
|
5592
|
-
|
|
5593
|
-
let
|
|
5594
|
-
|
|
5595
|
-
let
|
|
5596
|
-
|
|
5597
|
-
let
|
|
5598
|
-
|
|
5599
|
-
let
|
|
5600
|
-
|
|
5601
|
-
let $ = !!l || !!d,
|
|
5602
|
-
|
|
5603
|
-
let
|
|
5604
|
-
|
|
5605
|
-
let
|
|
5606
|
-
|
|
5607
|
-
let
|
|
5608
|
-
|
|
5609
|
-
let
|
|
5610
|
-
|
|
5611
|
-
let
|
|
5612
|
-
|
|
5613
|
-
let
|
|
5614
|
-
|
|
5615
|
-
let
|
|
5633
|
+
let Pt = O(a);
|
|
5634
|
+
Pt.current = a;
|
|
5635
|
+
let Ft = O(s);
|
|
5636
|
+
Ft.current = s;
|
|
5637
|
+
let It = O(c);
|
|
5638
|
+
It.current = c;
|
|
5639
|
+
let Rt = O(F);
|
|
5640
|
+
Rt.current = F;
|
|
5641
|
+
let zt = O(Z.simplifyStrength);
|
|
5642
|
+
zt.current = Z.simplifyStrength;
|
|
5643
|
+
let $ = !!l || !!d, Vt = O($);
|
|
5644
|
+
Vt.current = $;
|
|
5645
|
+
let Ht = O(u);
|
|
5646
|
+
Ht.current = u;
|
|
5647
|
+
let Ut = O(d);
|
|
5648
|
+
Ut.current = d;
|
|
5649
|
+
let Wt = O(f);
|
|
5650
|
+
Wt.current = f;
|
|
5651
|
+
let Gt = O(p);
|
|
5652
|
+
Gt.current = p;
|
|
5653
|
+
let Kt = O(h);
|
|
5654
|
+
Kt.current = h;
|
|
5655
|
+
let qt = O(Y);
|
|
5656
|
+
qt.current = Y;
|
|
5657
|
+
let Jt = O(!1), Yt = O(!1), Xt = O("idle"), Qt = O(null), $t = x(() => {
|
|
5616
5658
|
let e = W.current;
|
|
5617
5659
|
if (!e) return;
|
|
5618
|
-
let t =
|
|
5619
|
-
e.setCursor(
|
|
5660
|
+
let t = Pt.current, n = ht.current.get(t), r = gt.current;
|
|
5661
|
+
e.setCursor(Lt({
|
|
5620
5662
|
tool: t,
|
|
5621
5663
|
externalToolCursor: n?.cursor,
|
|
5622
|
-
isSpacePressed:
|
|
5623
|
-
interactionMode:
|
|
5624
|
-
rendererCursorHint:
|
|
5664
|
+
isSpacePressed: Jt.current,
|
|
5665
|
+
interactionMode: Xt.current,
|
|
5666
|
+
rendererCursorHint: Qt.current,
|
|
5625
5667
|
isPolygonDrawing: r.kind === "polygon" && r.active
|
|
5626
5668
|
}));
|
|
5627
|
-
}, []),
|
|
5628
|
-
|
|
5629
|
-
}, [
|
|
5630
|
-
|
|
5631
|
-
}, [
|
|
5632
|
-
let t = /* @__PURE__ */ new Set(), n = new Map(
|
|
5669
|
+
}, []), en = x((e) => {
|
|
5670
|
+
Xt.current !== e && (Xt.current = e, $t());
|
|
5671
|
+
}, [$t]), tn = x((e) => {
|
|
5672
|
+
Qt.current !== e && (Qt.current = e, $t());
|
|
5673
|
+
}, [$t]), nn = x((e) => {
|
|
5674
|
+
let t = /* @__PURE__ */ new Set(), n = new Map(qt.current.getShapes().map((e) => [e.id, e]));
|
|
5633
5675
|
return e.filter((e) => {
|
|
5634
5676
|
if (t.has(e)) return !1;
|
|
5635
5677
|
t.add(e);
|
|
5636
5678
|
let r = n.get(e);
|
|
5637
5679
|
if (!r) return !1;
|
|
5638
|
-
let i =
|
|
5680
|
+
let i = Kt.current?.(r);
|
|
5639
5681
|
return R(i ? {
|
|
5640
5682
|
...r,
|
|
5641
5683
|
interaction: {
|
|
@@ -5644,175 +5686,175 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5644
5686
|
}
|
|
5645
5687
|
} : r);
|
|
5646
5688
|
});
|
|
5647
|
-
}, []),
|
|
5648
|
-
let t =
|
|
5649
|
-
|
|
5689
|
+
}, []), rn = x((e) => {
|
|
5690
|
+
let t = nn(e);
|
|
5691
|
+
qr(Nt.current, t) || (lt || ct(t), W.current?.setSelection(t), ge?.(t));
|
|
5650
5692
|
}, [
|
|
5651
|
-
|
|
5693
|
+
nn,
|
|
5652
5694
|
ge,
|
|
5653
|
-
|
|
5654
|
-
]),
|
|
5655
|
-
|
|
5656
|
-
let [
|
|
5657
|
-
|
|
5658
|
-
let
|
|
5659
|
-
|
|
5660
|
-
if (!
|
|
5661
|
-
let e =
|
|
5662
|
-
|
|
5695
|
+
lt
|
|
5696
|
+
]), an = O(rn);
|
|
5697
|
+
an.current = rn;
|
|
5698
|
+
let [on, sn] = k(null), un = x((e) => sn(e), []), dn = O(un);
|
|
5699
|
+
dn.current = un;
|
|
5700
|
+
let fn = O(null);
|
|
5701
|
+
fn.current = on, S(() => {
|
|
5702
|
+
if (!lt) return;
|
|
5703
|
+
let e = nn(i);
|
|
5704
|
+
qr(i, e) || ge?.(e);
|
|
5663
5705
|
}, [
|
|
5664
5706
|
i,
|
|
5665
5707
|
Y.shapes,
|
|
5666
|
-
|
|
5708
|
+
nn,
|
|
5667
5709
|
ge,
|
|
5668
|
-
|
|
5710
|
+
lt
|
|
5669
5711
|
]);
|
|
5670
|
-
let
|
|
5671
|
-
|
|
5672
|
-
let { registerMinimapShape:
|
|
5712
|
+
let pn = O(Ce);
|
|
5713
|
+
pn.current = Ce;
|
|
5714
|
+
let { registerMinimapShape: mn, applyMinimapPreview: hn, syncMinimap: gn } = Vr({
|
|
5673
5715
|
engineRef: W,
|
|
5674
|
-
docRef:
|
|
5716
|
+
docRef: qt,
|
|
5675
5717
|
overlayRef: De,
|
|
5676
5718
|
zoomLabelRef: Oe,
|
|
5677
5719
|
minimapRectRef: Ee,
|
|
5678
5720
|
minimapSize: 204,
|
|
5679
|
-
onViewportChangeRef:
|
|
5680
|
-
}),
|
|
5681
|
-
|
|
5682
|
-
let
|
|
5683
|
-
t ?
|
|
5684
|
-
}, []),
|
|
5721
|
+
onViewportChangeRef: pn
|
|
5722
|
+
}), _n = O(/* @__PURE__ */ new Map()), vn = O(le);
|
|
5723
|
+
vn.current = le;
|
|
5724
|
+
let yn = x((e, t) => {
|
|
5725
|
+
t ? _n.current.set(e, t) : _n.current.delete(e);
|
|
5726
|
+
}, []), bn = O(null), [xn, Sn] = k(null), Cn = x((e) => {
|
|
5685
5727
|
if (!e.length) return;
|
|
5686
|
-
let t = new Map(
|
|
5687
|
-
|
|
5728
|
+
let t = new Map(qt.current.getShapes().map((e) => [e.id, e]));
|
|
5729
|
+
bn.current && t.set(bn.current.id, bn.current);
|
|
5688
5730
|
for (let { id: n, points: r } of e) {
|
|
5689
|
-
let e =
|
|
5731
|
+
let e = _n.current.get(n), i = t.get(n);
|
|
5690
5732
|
if (!e || !i) continue;
|
|
5691
|
-
let a =
|
|
5733
|
+
let a = ut(e, r);
|
|
5692
5734
|
if (a) {
|
|
5693
|
-
let e =
|
|
5694
|
-
a.textContent =
|
|
5735
|
+
let e = dt(i, r);
|
|
5736
|
+
a.textContent = vn.current?.(e) ?? ft(e);
|
|
5695
5737
|
}
|
|
5696
5738
|
}
|
|
5697
|
-
}, []),
|
|
5698
|
-
|
|
5739
|
+
}, []), wn = x((e) => {
|
|
5740
|
+
hn(e), Cn(e), we?.(e);
|
|
5699
5741
|
}, [
|
|
5700
|
-
|
|
5701
|
-
|
|
5742
|
+
hn,
|
|
5743
|
+
Cn,
|
|
5702
5744
|
we
|
|
5703
|
-
]),
|
|
5745
|
+
]), Tn = x((e) => {
|
|
5704
5746
|
if (Se?.(e ? {
|
|
5705
5747
|
...e,
|
|
5706
|
-
meta:
|
|
5707
|
-
} : null), !e || !
|
|
5708
|
-
|
|
5748
|
+
meta: It.current
|
|
5749
|
+
} : null), !e || !Ft.current) {
|
|
5750
|
+
bn.current && (bn.current = null, Sn(null));
|
|
5709
5751
|
return;
|
|
5710
5752
|
}
|
|
5711
5753
|
let t = {
|
|
5712
|
-
id:
|
|
5754
|
+
id: Gr,
|
|
5713
5755
|
type: e.type,
|
|
5714
5756
|
points: e.points,
|
|
5715
|
-
style:
|
|
5716
|
-
meta:
|
|
5717
|
-
}, n =
|
|
5718
|
-
|
|
5719
|
-
id:
|
|
5757
|
+
style: Ft.current,
|
|
5758
|
+
meta: It.current
|
|
5759
|
+
}, n = bn.current !== null;
|
|
5760
|
+
bn.current = t, n ? Cn([{
|
|
5761
|
+
id: Gr,
|
|
5720
5762
|
points: e.points
|
|
5721
|
-
}]) :
|
|
5722
|
-
}, [
|
|
5723
|
-
let n =
|
|
5724
|
-
if (!n ||
|
|
5763
|
+
}]) : Sn(t);
|
|
5764
|
+
}, [Cn, Se]), En = x((e, t) => {
|
|
5765
|
+
let n = Ft.current;
|
|
5766
|
+
if (!n || Vt.current) return;
|
|
5725
5767
|
let r = ae();
|
|
5726
|
-
|
|
5768
|
+
qt.current.create({
|
|
5727
5769
|
id: r,
|
|
5728
5770
|
type: e,
|
|
5729
5771
|
points: t,
|
|
5730
5772
|
style: n,
|
|
5731
5773
|
meta: c
|
|
5732
|
-
}),
|
|
5733
|
-
}, [c]),
|
|
5734
|
-
|
|
5735
|
-
let
|
|
5736
|
-
toolRef:
|
|
5737
|
-
selRef:
|
|
5738
|
-
docRef:
|
|
5739
|
-
readOnlyRef:
|
|
5740
|
-
draftRef:
|
|
5741
|
-
brushSizeRef:
|
|
5742
|
-
simplifyEpsilonRef:
|
|
5774
|
+
}), an.current([r]);
|
|
5775
|
+
}, [c]), Dn = O(En);
|
|
5776
|
+
Dn.current = En;
|
|
5777
|
+
let On = Nn({
|
|
5778
|
+
toolRef: Pt,
|
|
5779
|
+
selRef: Nt,
|
|
5780
|
+
docRef: qt,
|
|
5781
|
+
readOnlyRef: Vt,
|
|
5782
|
+
draftRef: Ft,
|
|
5783
|
+
brushSizeRef: Rt,
|
|
5784
|
+
simplifyEpsilonRef: zt,
|
|
5743
5785
|
draftMeta: c,
|
|
5744
5786
|
engineRef: W,
|
|
5745
5787
|
onDrawSessionChange: x((e) => {
|
|
5746
5788
|
Re(e), xe?.(e);
|
|
5747
5789
|
}, [xe]),
|
|
5748
5790
|
onDraftShapeChange: Se,
|
|
5749
|
-
changeSelection:
|
|
5750
|
-
createShape:
|
|
5751
|
-
}),
|
|
5752
|
-
|
|
5753
|
-
let { reset:
|
|
5754
|
-
|
|
5755
|
-
let
|
|
5756
|
-
docRef:
|
|
5757
|
-
draftRef:
|
|
5791
|
+
changeSelection: rn,
|
|
5792
|
+
createShape: En
|
|
5793
|
+
}), kn = O(On);
|
|
5794
|
+
kn.current = On;
|
|
5795
|
+
let { reset: An, undoSession: jn, redoSession: Mn, canUndoSession: Pn, canRedoSession: Fn, hasDraftSession: Ln, hasDraftPoints: Rn, commitDraftSession: zn, setBrushScalarMode: Bn, getBrushScalarMode: Vn, hasBrushSession: Hn, commitBrush: Un, cancelBrush: Wn, beginBrushEditFromSelection: Gn, deleteDraftSelectedPoints: qn, handleToolChange: Jn, handleBrushSelectionChange: Yn } = On, Xn = O(de);
|
|
5796
|
+
Xn.current = de;
|
|
5797
|
+
let Zn = ln({
|
|
5798
|
+
docRef: qt,
|
|
5799
|
+
draftRef: Ft,
|
|
5758
5800
|
draftMeta: c,
|
|
5759
|
-
changeSelection:
|
|
5760
|
-
assistantRef:
|
|
5761
|
-
}),
|
|
5762
|
-
|
|
5763
|
-
let
|
|
5801
|
+
changeSelection: rn,
|
|
5802
|
+
assistantRef: Xn
|
|
5803
|
+
}), Qn = O(Zn);
|
|
5804
|
+
Qn.current = Zn;
|
|
5805
|
+
let $n = E(() => St(qe), [qe]), { selectAll: er, clearSelection: tr, deleteSelection: nr, copySelection: rr, canPaste: ir, paste: ar, duplicate: or, bringToFront: sr, sendToBack: cr, nudgeSelection: lr, getMergeTargets: ur, mergeSelection: dr } = Ur({
|
|
5764
5806
|
doc: Y,
|
|
5765
|
-
selRef:
|
|
5807
|
+
selRef: Nt,
|
|
5766
5808
|
effectiveReadOnly: $,
|
|
5767
|
-
changeSelection:
|
|
5809
|
+
changeSelection: rn,
|
|
5768
5810
|
canMergeSelection: P,
|
|
5769
|
-
clipboardDocumentId:
|
|
5770
|
-
clipboardScope: t ??
|
|
5771
|
-
}), { zoomToBounds:
|
|
5811
|
+
clipboardDocumentId: $n,
|
|
5812
|
+
clipboardScope: t ?? $n
|
|
5813
|
+
}), { zoomToBounds: fr, zoomToShapes: pr, zoomToSelection: mr, zoomAtCenter: hr } = Wr({
|
|
5772
5814
|
engineRef: W,
|
|
5773
5815
|
doc: Y,
|
|
5774
|
-
selRef:
|
|
5816
|
+
selRef: Nt,
|
|
5775
5817
|
zoomAnimationDuration: te,
|
|
5776
5818
|
zoomBound: ee,
|
|
5777
5819
|
ready: K
|
|
5778
5820
|
});
|
|
5779
5821
|
w(pe, () => ({
|
|
5780
5822
|
previewRegionMask: (e) => {
|
|
5781
|
-
let t =
|
|
5823
|
+
let t = At.current;
|
|
5782
5824
|
if (!t) return;
|
|
5783
|
-
let n = e ?
|
|
5784
|
-
W.current?.setRegionOverlay(
|
|
5825
|
+
let n = e ? Zt(e, t.w, t.h) : Ot.current;
|
|
5826
|
+
W.current?.setRegionOverlay(gr.current.showRegionMask ? n : null);
|
|
5785
5827
|
},
|
|
5786
5828
|
undo: () => {
|
|
5787
|
-
|
|
5829
|
+
jn() || Y.undo();
|
|
5788
5830
|
},
|
|
5789
5831
|
redo: () => {
|
|
5790
|
-
|
|
5832
|
+
Mn() || Y.redo();
|
|
5791
5833
|
},
|
|
5792
|
-
canUndo: () =>
|
|
5793
|
-
canRedo: () =>
|
|
5794
|
-
undoSession:
|
|
5795
|
-
redoSession:
|
|
5796
|
-
canUndoSession:
|
|
5797
|
-
canRedoSession:
|
|
5798
|
-
hasDraftSession:
|
|
5799
|
-
cancelDraftSession:
|
|
5800
|
-
commitDraftSession:
|
|
5801
|
-
setSelection:
|
|
5834
|
+
canUndo: () => Pn() || Y.canUndo(),
|
|
5835
|
+
canRedo: () => Fn() || Y.canRedo(),
|
|
5836
|
+
undoSession: jn,
|
|
5837
|
+
redoSession: Mn,
|
|
5838
|
+
canUndoSession: Pn,
|
|
5839
|
+
canRedoSession: Fn,
|
|
5840
|
+
hasDraftSession: Ln,
|
|
5841
|
+
cancelDraftSession: An,
|
|
5842
|
+
commitDraftSession: zn,
|
|
5843
|
+
setSelection: rn,
|
|
5802
5844
|
createShapes: (e) => {
|
|
5803
|
-
e.length && (Y.create(e),
|
|
5845
|
+
e.length && (Y.create(e), rn(e.map((e) => e.id)));
|
|
5804
5846
|
},
|
|
5805
5847
|
updateShapes: Y.update,
|
|
5806
5848
|
deleteShapes: Y.remove,
|
|
5807
5849
|
getShapes: Y.getShapes,
|
|
5808
|
-
selectAll:
|
|
5809
|
-
clearSelection:
|
|
5810
|
-
deleteSelection:
|
|
5811
|
-
copySelection:
|
|
5812
|
-
paste:
|
|
5813
|
-
duplicate:
|
|
5814
|
-
bringToFront:
|
|
5815
|
-
sendToBack:
|
|
5850
|
+
selectAll: er,
|
|
5851
|
+
clearSelection: tr,
|
|
5852
|
+
deleteSelection: nr,
|
|
5853
|
+
copySelection: rr,
|
|
5854
|
+
paste: ar,
|
|
5855
|
+
duplicate: or,
|
|
5856
|
+
bringToFront: sr,
|
|
5857
|
+
sendToBack: cr,
|
|
5816
5858
|
zoomFit: () => W.current?.fit(),
|
|
5817
5859
|
zoom100: () => W.current?.zoom100(),
|
|
5818
5860
|
zoomIn: () => {
|
|
@@ -5827,101 +5869,101 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5827
5869
|
let { w: t, h: n } = e.screenSize;
|
|
5828
5870
|
e.zoomAt(t / 2, n / 2, 1 / 1.2);
|
|
5829
5871
|
},
|
|
5830
|
-
zoomToSelection:
|
|
5831
|
-
zoomToShapes:
|
|
5832
|
-
zoomToBounds:
|
|
5872
|
+
zoomToSelection: mr,
|
|
5873
|
+
zoomToShapes: pr,
|
|
5874
|
+
zoomToBounds: fr,
|
|
5833
5875
|
brush: {
|
|
5834
|
-
setScalarMode:
|
|
5835
|
-
getScalarMode:
|
|
5836
|
-
hasSession:
|
|
5837
|
-
commit:
|
|
5838
|
-
cancel:
|
|
5839
|
-
beginEditFromSelection:
|
|
5876
|
+
setScalarMode: Bn,
|
|
5877
|
+
getScalarMode: Vn,
|
|
5878
|
+
hasSession: Hn,
|
|
5879
|
+
commit: Un,
|
|
5880
|
+
cancel: Wn,
|
|
5881
|
+
beginEditFromSelection: Gn
|
|
5840
5882
|
}
|
|
5841
5883
|
}), [
|
|
5842
5884
|
Y,
|
|
5843
|
-
|
|
5844
|
-
An,
|
|
5885
|
+
rn,
|
|
5845
5886
|
jn,
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5887
|
+
Mn,
|
|
5888
|
+
zn,
|
|
5889
|
+
An,
|
|
5849
5890
|
Un,
|
|
5850
|
-
|
|
5891
|
+
Wn,
|
|
5851
5892
|
er,
|
|
5852
5893
|
tr,
|
|
5853
5894
|
nr,
|
|
5854
|
-
|
|
5895
|
+
rr,
|
|
5855
5896
|
ar,
|
|
5856
5897
|
or,
|
|
5857
5898
|
sr,
|
|
5899
|
+
cr,
|
|
5900
|
+
mr,
|
|
5858
5901
|
pr,
|
|
5859
5902
|
fr,
|
|
5860
|
-
dr,
|
|
5861
|
-
zn,
|
|
5862
5903
|
Bn,
|
|
5863
5904
|
Vn,
|
|
5864
|
-
|
|
5905
|
+
Hn,
|
|
5906
|
+
Gn
|
|
5865
5907
|
]);
|
|
5866
|
-
let
|
|
5867
|
-
|
|
5868
|
-
let
|
|
5908
|
+
let gr = O(Z);
|
|
5909
|
+
gr.current = Z;
|
|
5910
|
+
let _r = x(() => cn({
|
|
5869
5911
|
engineRef: W,
|
|
5870
|
-
toolRef:
|
|
5871
|
-
externalToolMapRef:
|
|
5872
|
-
spaceRef:
|
|
5873
|
-
shiftRef:
|
|
5874
|
-
docRef:
|
|
5875
|
-
selRef:
|
|
5876
|
-
draftRef:
|
|
5877
|
-
readOnlyRef:
|
|
5878
|
-
disableMarqueeRef:
|
|
5879
|
-
lockedRef:
|
|
5880
|
-
onLockedInteraction: () =>
|
|
5881
|
-
onDrawAttemptWithoutDraft: () =>
|
|
5882
|
-
createRef:
|
|
5883
|
-
selectRef:
|
|
5884
|
-
enterEditRef:
|
|
5885
|
-
editingIdRef:
|
|
5886
|
-
drawSessionRef:
|
|
5887
|
-
assistantRef:
|
|
5888
|
-
setCursorHint:
|
|
5889
|
-
setInteractionMode:
|
|
5890
|
-
syncMinimap:
|
|
5891
|
-
onTransformPreview:
|
|
5892
|
-
onDrawPreview:
|
|
5912
|
+
toolRef: Pt,
|
|
5913
|
+
externalToolMapRef: ht,
|
|
5914
|
+
spaceRef: Jt,
|
|
5915
|
+
shiftRef: Yt,
|
|
5916
|
+
docRef: qt,
|
|
5917
|
+
selRef: Nt,
|
|
5918
|
+
draftRef: Ft,
|
|
5919
|
+
readOnlyRef: Vt,
|
|
5920
|
+
disableMarqueeRef: Ht,
|
|
5921
|
+
lockedRef: Ut,
|
|
5922
|
+
onLockedInteraction: () => Wt.current?.(),
|
|
5923
|
+
onDrawAttemptWithoutDraft: () => Gt.current?.(),
|
|
5924
|
+
createRef: Dn,
|
|
5925
|
+
selectRef: an,
|
|
5926
|
+
enterEditRef: dn,
|
|
5927
|
+
editingIdRef: fn,
|
|
5928
|
+
drawSessionRef: kn,
|
|
5929
|
+
assistantRef: Qn,
|
|
5930
|
+
setCursorHint: tn,
|
|
5931
|
+
setInteractionMode: en,
|
|
5932
|
+
syncMinimap: gn,
|
|
5933
|
+
onTransformPreview: wn,
|
|
5934
|
+
onDrawPreview: Tn
|
|
5893
5935
|
}), [
|
|
5936
|
+
tn,
|
|
5894
5937
|
en,
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
Nr({
|
|
5938
|
+
gn,
|
|
5939
|
+
wn,
|
|
5940
|
+
Tn
|
|
5941
|
+
]), vr = O([]);
|
|
5942
|
+
Pr({
|
|
5901
5943
|
backend: me,
|
|
5902
5944
|
hostRef: Te,
|
|
5903
5945
|
engineRef: W,
|
|
5904
5946
|
documentId: qe,
|
|
5905
5947
|
renderedImageUrl: $e,
|
|
5906
|
-
makeCallbacks:
|
|
5907
|
-
viewRef:
|
|
5908
|
-
readOnlyRef:
|
|
5909
|
-
toolRef:
|
|
5910
|
-
renderShapesRef:
|
|
5911
|
-
coordinateSizeRef:
|
|
5912
|
-
imageSizeRef:
|
|
5913
|
-
selRef:
|
|
5914
|
-
maskCanvasRef:
|
|
5915
|
-
regionOverlayRef:
|
|
5916
|
-
dimmedRef:
|
|
5917
|
-
syncMinimap:
|
|
5948
|
+
makeCallbacks: _r,
|
|
5949
|
+
viewRef: gr,
|
|
5950
|
+
readOnlyRef: Vt,
|
|
5951
|
+
toolRef: Pt,
|
|
5952
|
+
renderShapesRef: vr,
|
|
5953
|
+
coordinateSizeRef: jt,
|
|
5954
|
+
imageSizeRef: Mt,
|
|
5955
|
+
selRef: Nt,
|
|
5956
|
+
maskCanvasRef: Dt,
|
|
5957
|
+
regionOverlayRef: Ot,
|
|
5958
|
+
dimmedRef: kt,
|
|
5959
|
+
syncMinimap: gn,
|
|
5918
5960
|
setImage: Ae,
|
|
5919
5961
|
setImageVisible: Me,
|
|
5920
5962
|
setReady: Ne,
|
|
5921
|
-
setImageStatus:
|
|
5922
|
-
onContextMenuRequest:
|
|
5963
|
+
setImageStatus: at,
|
|
5964
|
+
onContextMenuRequest: Fe
|
|
5923
5965
|
});
|
|
5924
|
-
let
|
|
5966
|
+
let yr = E(() => {
|
|
5925
5967
|
let e = h ? Y.shapes.map((e) => {
|
|
5926
5968
|
let t = h(e);
|
|
5927
5969
|
return t ? {
|
|
@@ -5947,48 +5989,48 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5947
5989
|
h,
|
|
5948
5990
|
I
|
|
5949
5991
|
]);
|
|
5950
|
-
|
|
5951
|
-
W.current?.setShapes(
|
|
5952
|
-
}, [
|
|
5992
|
+
vr.current = yr, S(() => {
|
|
5993
|
+
W.current?.setShapes(yr, Nt.current), gn();
|
|
5994
|
+
}, [yr, gn]), S(() => {
|
|
5953
5995
|
W.current?.setSelection(X);
|
|
5954
5996
|
}, [X]), S(() => {
|
|
5955
|
-
W.current?.setEditing(
|
|
5956
|
-
}, [
|
|
5957
|
-
let
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
}, [
|
|
5961
|
-
|
|
5997
|
+
W.current?.setEditing(on);
|
|
5998
|
+
}, [on, K]);
|
|
5999
|
+
let br = O(_e);
|
|
6000
|
+
br.current = _e, S(() => {
|
|
6001
|
+
br.current?.(on);
|
|
6002
|
+
}, [on]), S(() => {
|
|
6003
|
+
sn(null);
|
|
5962
6004
|
}, [a]), S(() => {
|
|
5963
|
-
|
|
5964
|
-
}, [X,
|
|
6005
|
+
on && (X.length !== 1 || X[0] !== on) && sn(null);
|
|
6006
|
+
}, [X, on]), S(() => {
|
|
5965
6007
|
let e = W.current;
|
|
5966
|
-
e && (e.setFilter(Z.brightness, Z.contrast), e.setRenderDefaults({ strokeWidth: Z.strokeSize }), e.setImageSmoothing(Z.imageSmoothing),
|
|
6008
|
+
e && (e.setFilter(Z.brightness, Z.contrast), e.setRenderDefaults({ strokeWidth: Z.strokeSize }), e.setImageSmoothing(Z.imageSmoothing), gn());
|
|
5967
6009
|
}, [
|
|
5968
6010
|
Z.brightness,
|
|
5969
6011
|
Z.contrast,
|
|
5970
6012
|
Z.strokeSize,
|
|
5971
6013
|
Z.imageSmoothing,
|
|
5972
|
-
|
|
6014
|
+
gn
|
|
5973
6015
|
]), T(() => {
|
|
5974
|
-
K && W.current?.setOverlays(Z.showGuide ?
|
|
6016
|
+
K && W.current?.setOverlays(Z.showGuide ? wt : null, Z.showRegionMask ? Et : null, r);
|
|
5975
6017
|
}, [
|
|
5976
6018
|
K,
|
|
5977
|
-
|
|
5978
|
-
|
|
6019
|
+
wt,
|
|
6020
|
+
Et,
|
|
5979
6021
|
Z.showGuide,
|
|
5980
6022
|
Z.showRegionMask,
|
|
5981
6023
|
r
|
|
5982
6024
|
]), S(() => {
|
|
5983
|
-
!K || !G ||
|
|
6025
|
+
!K || !G || gn();
|
|
5984
6026
|
}, [
|
|
5985
6027
|
K,
|
|
5986
6028
|
G,
|
|
5987
|
-
|
|
6029
|
+
Tt,
|
|
5988
6030
|
Z.showGuide,
|
|
5989
6031
|
Z.showRegionMask,
|
|
5990
6032
|
re,
|
|
5991
|
-
|
|
6033
|
+
gn
|
|
5992
6034
|
]), S(() => {
|
|
5993
6035
|
K && W.current?.setTransformEnabled(!$ && a !== J.BRUSH);
|
|
5994
6036
|
}, [
|
|
@@ -5996,135 +6038,135 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
5996
6038
|
K,
|
|
5997
6039
|
a
|
|
5998
6040
|
]), S(() => {
|
|
5999
|
-
|
|
6000
|
-
}, [a,
|
|
6001
|
-
let
|
|
6041
|
+
Jn(a, ht.current.has(a));
|
|
6042
|
+
}, [a, Jn]);
|
|
6043
|
+
let xr = Zn.finalize;
|
|
6002
6044
|
S(() => {
|
|
6003
|
-
|
|
6004
|
-
}, [a,
|
|
6005
|
-
|
|
6045
|
+
xr();
|
|
6046
|
+
}, [a, xr]), S(() => {
|
|
6047
|
+
Xt.current = "idle", Qt.current = null, $t();
|
|
6006
6048
|
}, [
|
|
6007
6049
|
a,
|
|
6008
6050
|
me,
|
|
6009
|
-
|
|
6051
|
+
$t
|
|
6010
6052
|
]), S(() => {
|
|
6011
|
-
|
|
6053
|
+
Yn(X, $);
|
|
6012
6054
|
}, [
|
|
6013
6055
|
X,
|
|
6014
6056
|
a,
|
|
6015
6057
|
$,
|
|
6016
|
-
|
|
6058
|
+
Yn
|
|
6017
6059
|
]), S(() => {
|
|
6018
|
-
K &&
|
|
6060
|
+
K && $t();
|
|
6019
6061
|
}, [
|
|
6020
6062
|
a,
|
|
6021
|
-
|
|
6022
|
-
|
|
6063
|
+
q,
|
|
6064
|
+
pt,
|
|
6023
6065
|
K,
|
|
6024
|
-
|
|
6066
|
+
$t
|
|
6025
6067
|
]);
|
|
6026
|
-
let
|
|
6027
|
-
|
|
6028
|
-
let
|
|
6068
|
+
let Sr = O(Qe);
|
|
6069
|
+
Sr.current = Qe;
|
|
6070
|
+
let Cr = e !== null, wr = O(null);
|
|
6029
6071
|
S(() => {
|
|
6030
|
-
let e =
|
|
6031
|
-
|
|
6072
|
+
let e = Cr ? qe : null;
|
|
6073
|
+
wr.current !== e && (wr.current = e, Fe(null), sn(null), Xt.current = "idle", Qt.current = null, Y.reset(Cr ? Ze ?? [] : []), rn(Cr ? Sr.current ?? [] : []), An(), xr(), $t());
|
|
6032
6074
|
}, [
|
|
6033
|
-
|
|
6075
|
+
Cr,
|
|
6034
6076
|
qe,
|
|
6035
6077
|
Ze,
|
|
6036
6078
|
Y.reset,
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6079
|
+
rn,
|
|
6080
|
+
An,
|
|
6081
|
+
xr,
|
|
6082
|
+
$t
|
|
6041
6083
|
]);
|
|
6042
|
-
let
|
|
6043
|
-
let e =
|
|
6084
|
+
let Tr = x(() => {
|
|
6085
|
+
let e = fn.current;
|
|
6044
6086
|
if (!e || $) return !1;
|
|
6045
6087
|
let t = W.current, n = new Set(t?.getVertexSelection() ?? []);
|
|
6046
6088
|
if (!n.size) return !1;
|
|
6047
|
-
let r =
|
|
6089
|
+
let r = qt.current.getShapes().find((t) => t.id === e);
|
|
6048
6090
|
if (!r) return !1;
|
|
6049
6091
|
let i = r.points.filter((e, t) => !n.has(t)), a = r.type === L.LINE ? 2 : 3;
|
|
6050
|
-
return i.length < a ? !1 : (
|
|
6092
|
+
return i.length < a ? !1 : (qt.current.update([{
|
|
6051
6093
|
...r,
|
|
6052
6094
|
points: i
|
|
6053
6095
|
}]), t?.setVertexSelection([]), !0);
|
|
6054
6096
|
}, [$]);
|
|
6055
|
-
|
|
6097
|
+
Kn({
|
|
6056
6098
|
keymap: fe,
|
|
6057
6099
|
hostRef: Te,
|
|
6058
6100
|
actions: {
|
|
6059
6101
|
undo: () => {
|
|
6060
|
-
$ ||
|
|
6102
|
+
$ || jn() || Y.undo();
|
|
6061
6103
|
},
|
|
6062
6104
|
redo: () => {
|
|
6063
|
-
$ ||
|
|
6105
|
+
$ || Mn() || Y.redo();
|
|
6064
6106
|
},
|
|
6065
|
-
selectAll:
|
|
6066
|
-
copy:
|
|
6107
|
+
selectAll: er,
|
|
6108
|
+
copy: rr,
|
|
6067
6109
|
cut: () => {
|
|
6068
|
-
|
|
6110
|
+
rr(), nr();
|
|
6069
6111
|
},
|
|
6070
|
-
paste:
|
|
6071
|
-
duplicate:
|
|
6112
|
+
paste: ar,
|
|
6113
|
+
duplicate: or,
|
|
6072
6114
|
delete: () => {
|
|
6073
|
-
|
|
6115
|
+
Rn() && qn() || Tr() || nr();
|
|
6074
6116
|
},
|
|
6075
6117
|
cancel: () => {
|
|
6076
|
-
let e =
|
|
6118
|
+
let e = ht.current.get(Pt.current);
|
|
6077
6119
|
if (!(e?.onCancel && e.onCancel() !== !1)) {
|
|
6078
|
-
if (
|
|
6079
|
-
|
|
6120
|
+
if (Zn.isActive()) {
|
|
6121
|
+
Zn.cancel();
|
|
6080
6122
|
return;
|
|
6081
6123
|
}
|
|
6082
|
-
if (
|
|
6083
|
-
|
|
6124
|
+
if (Ln()) {
|
|
6125
|
+
An();
|
|
6084
6126
|
return;
|
|
6085
6127
|
}
|
|
6086
|
-
if (
|
|
6087
|
-
|
|
6128
|
+
if (on) {
|
|
6129
|
+
sn(null);
|
|
6088
6130
|
return;
|
|
6089
6131
|
}
|
|
6090
|
-
if (
|
|
6091
|
-
|
|
6132
|
+
if (Nt.current.length) {
|
|
6133
|
+
tr();
|
|
6092
6134
|
return;
|
|
6093
6135
|
}
|
|
6094
6136
|
m?.();
|
|
6095
6137
|
}
|
|
6096
6138
|
},
|
|
6097
6139
|
commitDraft: () => {
|
|
6098
|
-
if (
|
|
6099
|
-
|
|
6140
|
+
if (Zn.isActive()) {
|
|
6141
|
+
Zn.finalize();
|
|
6100
6142
|
return;
|
|
6101
6143
|
}
|
|
6102
|
-
if (
|
|
6103
|
-
|
|
6144
|
+
if (Ln()) {
|
|
6145
|
+
zn();
|
|
6104
6146
|
return;
|
|
6105
6147
|
}
|
|
6106
6148
|
if ($) return;
|
|
6107
|
-
if (
|
|
6108
|
-
|
|
6149
|
+
if (on) {
|
|
6150
|
+
sn(null);
|
|
6109
6151
|
return;
|
|
6110
6152
|
}
|
|
6111
|
-
let e =
|
|
6153
|
+
let e = Nt.current;
|
|
6112
6154
|
if (e.length !== 1) return;
|
|
6113
|
-
let t =
|
|
6114
|
-
t && (t.type === L.POLYGON || t.type === L.LINE) && t.interaction?.editable !== !1 && !t.readOnly &&
|
|
6155
|
+
let t = qt.current.getShapes().find((t) => t.id === e[0]);
|
|
6156
|
+
t && (t.type === L.POLYGON || t.type === L.LINE) && t.interaction?.editable !== !1 && !t.readOnly && sn(e[0]);
|
|
6115
6157
|
},
|
|
6116
|
-
bringToFront:
|
|
6117
|
-
sendToBack:
|
|
6118
|
-
zoomIn: () =>
|
|
6119
|
-
zoomOut: () =>
|
|
6158
|
+
bringToFront: sr,
|
|
6159
|
+
sendToBack: cr,
|
|
6160
|
+
zoomIn: () => hr(1.2),
|
|
6161
|
+
zoomOut: () => hr(1 / 1.2),
|
|
6120
6162
|
zoom100: () => W.current?.zoom100(),
|
|
6121
6163
|
zoomFit: () => W.current?.fit(),
|
|
6122
6164
|
toggleMinimap: () => Be((e) => !e),
|
|
6123
|
-
toggleCursorGuide: () =>
|
|
6165
|
+
toggleCursorGuide: () => yt((e) => ({
|
|
6124
6166
|
...e,
|
|
6125
6167
|
showCursorGuide: !e.showCursorGuide
|
|
6126
6168
|
})),
|
|
6127
|
-
togglePixelation: () =>
|
|
6169
|
+
togglePixelation: () => yt((e) => ({
|
|
6128
6170
|
...e,
|
|
6129
6171
|
imageSmoothing: !e.imageSmoothing
|
|
6130
6172
|
})),
|
|
@@ -6137,112 +6179,112 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6137
6179
|
brushTool: () => he?.(J.BRUSH),
|
|
6138
6180
|
pointTool: () => he?.(J.POINT)
|
|
6139
6181
|
},
|
|
6140
|
-
spaceRef:
|
|
6141
|
-
shiftRef:
|
|
6182
|
+
spaceRef: Jt,
|
|
6183
|
+
shiftRef: Yt,
|
|
6142
6184
|
onSpaceDown: () => {
|
|
6143
|
-
W.current?.setPanMode(!0),
|
|
6185
|
+
W.current?.setPanMode(!0), $t();
|
|
6144
6186
|
},
|
|
6145
6187
|
onSpaceUp: () => {
|
|
6146
|
-
W.current?.setPanMode(!1),
|
|
6188
|
+
W.current?.setPanMode(!1), Xt.current === "panning" ? en("idle") : $t();
|
|
6147
6189
|
},
|
|
6148
|
-
nudge:
|
|
6190
|
+
nudge: lr
|
|
6149
6191
|
});
|
|
6150
|
-
let
|
|
6192
|
+
let Er = E(() => yr.filter((e) => X.includes(e.id) && ne(e)), [yr, X]), Dr = E(() => xn ? [...Er, xn] : Er, [Er, xn]), Or = X.length > 0, kr = Y.shapes.some((e) => X.includes(e.id) && ie(e)), Ar = !$ && X.length === 1 && (() => {
|
|
6151
6193
|
let e = Y.shapes.find((e) => e.id === X[0]);
|
|
6152
6194
|
return !!e && (e.type === L.POLYGON || e.type === L.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
|
|
6153
|
-
})(),
|
|
6195
|
+
})(), jr = ur(), Mr = $ || jr.length < 2 || (P ? !P(jr) : !1), Nr = !!de && !$, Fr = Nr && X.length === 1 ? (() => {
|
|
6154
6196
|
let e = Y.shapes.find((e) => e.id === X[0]);
|
|
6155
6197
|
return e && e.type === L.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
|
|
6156
|
-
})() : null,
|
|
6198
|
+
})() : null, Ir = [
|
|
6157
6199
|
{
|
|
6158
6200
|
id: "copy",
|
|
6159
6201
|
label: Q.contextMenu.copy,
|
|
6160
6202
|
shortcut: "⌘C",
|
|
6161
|
-
disabled: !
|
|
6162
|
-
onClick:
|
|
6203
|
+
disabled: !kr,
|
|
6204
|
+
onClick: rr
|
|
6163
6205
|
},
|
|
6164
6206
|
{
|
|
6165
6207
|
id: "paste",
|
|
6166
6208
|
label: Q.contextMenu.paste,
|
|
6167
6209
|
shortcut: "⌘V",
|
|
6168
|
-
disabled: $ || !
|
|
6169
|
-
onClick: () =>
|
|
6210
|
+
disabled: $ || !ir(),
|
|
6211
|
+
onClick: () => ar(Pe?.img)
|
|
6170
6212
|
},
|
|
6171
6213
|
{
|
|
6172
6214
|
id: "duplicate",
|
|
6173
6215
|
label: Q.contextMenu.duplicate,
|
|
6174
6216
|
shortcut: "⌘D",
|
|
6175
|
-
disabled: !
|
|
6176
|
-
onClick:
|
|
6217
|
+
disabled: !kr || $,
|
|
6218
|
+
onClick: or
|
|
6177
6219
|
},
|
|
6178
6220
|
{
|
|
6179
6221
|
id: "delete",
|
|
6180
6222
|
label: Q.contextMenu.delete,
|
|
6181
6223
|
shortcut: "Del",
|
|
6182
6224
|
danger: !0,
|
|
6183
|
-
disabled: !
|
|
6184
|
-
onClick:
|
|
6225
|
+
disabled: !kr || $,
|
|
6226
|
+
onClick: nr
|
|
6185
6227
|
},
|
|
6186
6228
|
{ separator: !0 },
|
|
6187
6229
|
{
|
|
6188
6230
|
id: "editVertices",
|
|
6189
6231
|
label: Q.contextMenu.editVertices,
|
|
6190
6232
|
shortcut: "Enter",
|
|
6191
|
-
disabled: !
|
|
6192
|
-
onClick: () =>
|
|
6233
|
+
disabled: !Ar,
|
|
6234
|
+
onClick: () => sn(X[0])
|
|
6193
6235
|
},
|
|
6194
6236
|
{
|
|
6195
6237
|
id: "merge",
|
|
6196
6238
|
label: Q.contextMenu.merge,
|
|
6197
|
-
disabled:
|
|
6198
|
-
onClick:
|
|
6239
|
+
disabled: Mr,
|
|
6240
|
+
onClick: dr
|
|
6199
6241
|
},
|
|
6200
|
-
...
|
|
6242
|
+
...Nr ? [{
|
|
6201
6243
|
id: "assistExpand",
|
|
6202
6244
|
label: Q.contextMenu.assistExpand,
|
|
6203
6245
|
icon: /* @__PURE__ */ v(o, { size: 14 }),
|
|
6204
|
-
disabled: !
|
|
6246
|
+
disabled: !Fr,
|
|
6205
6247
|
onClick: () => {
|
|
6206
|
-
Pe &&
|
|
6248
|
+
Pe && Fr && Zn.refineShape(Fr, Pe.img, !0);
|
|
6207
6249
|
}
|
|
6208
6250
|
}, {
|
|
6209
6251
|
id: "assistExclude",
|
|
6210
6252
|
label: Q.contextMenu.assistExclude,
|
|
6211
6253
|
icon: /* @__PURE__ */ v(o, { size: 14 }),
|
|
6212
|
-
disabled: !
|
|
6254
|
+
disabled: !Fr,
|
|
6213
6255
|
onClick: () => {
|
|
6214
|
-
Pe &&
|
|
6256
|
+
Pe && Fr && Zn.refineShape(Fr, Pe.img, !1);
|
|
6215
6257
|
}
|
|
6216
6258
|
}] : [],
|
|
6217
6259
|
{
|
|
6218
6260
|
id: "bringToFront",
|
|
6219
6261
|
label: Q.contextMenu.bringToFront,
|
|
6220
|
-
disabled: !
|
|
6221
|
-
onClick:
|
|
6262
|
+
disabled: !kr || $,
|
|
6263
|
+
onClick: sr
|
|
6222
6264
|
},
|
|
6223
6265
|
{
|
|
6224
6266
|
id: "sendToBack",
|
|
6225
6267
|
label: Q.contextMenu.sendToBack,
|
|
6226
|
-
disabled: !
|
|
6227
|
-
onClick:
|
|
6268
|
+
disabled: !kr || $,
|
|
6269
|
+
onClick: cr
|
|
6228
6270
|
},
|
|
6229
6271
|
{ separator: !0 },
|
|
6230
6272
|
{
|
|
6231
6273
|
id: "undo",
|
|
6232
6274
|
label: Q.contextMenu.undo,
|
|
6233
6275
|
shortcut: "⌘Z",
|
|
6234
|
-
disabled: $ || !
|
|
6276
|
+
disabled: $ || !Pn() && !Y.canUndo(),
|
|
6235
6277
|
onClick: () => {
|
|
6236
|
-
|
|
6278
|
+
jn() || Y.undo();
|
|
6237
6279
|
}
|
|
6238
6280
|
},
|
|
6239
6281
|
{
|
|
6240
6282
|
id: "redo",
|
|
6241
6283
|
label: Q.contextMenu.redo,
|
|
6242
6284
|
shortcut: "⇧⌘Z",
|
|
6243
|
-
disabled: $ || !
|
|
6285
|
+
disabled: $ || !Fn() && !Y.canRedo(),
|
|
6244
6286
|
onClick: () => {
|
|
6245
|
-
|
|
6287
|
+
Mn() || Y.redo();
|
|
6246
6288
|
}
|
|
6247
6289
|
},
|
|
6248
6290
|
{ separator: !0 },
|
|
@@ -6250,36 +6292,36 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6250
6292
|
id: "selectAll",
|
|
6251
6293
|
label: Q.contextMenu.selectAll,
|
|
6252
6294
|
shortcut: "⌘A",
|
|
6253
|
-
onClick:
|
|
6295
|
+
onClick: er
|
|
6254
6296
|
},
|
|
6255
6297
|
{
|
|
6256
6298
|
id: "clearSelection",
|
|
6257
6299
|
label: Q.contextMenu.clearSelection,
|
|
6258
|
-
disabled: !
|
|
6259
|
-
onClick:
|
|
6300
|
+
disabled: !Or,
|
|
6301
|
+
onClick: tr
|
|
6260
6302
|
},
|
|
6261
6303
|
{
|
|
6262
6304
|
id: "zoomToSelection",
|
|
6263
6305
|
label: Q.contextMenu.zoomToSelection,
|
|
6264
|
-
disabled: !
|
|
6265
|
-
onClick:
|
|
6306
|
+
disabled: !Or,
|
|
6307
|
+
onClick: mr
|
|
6266
6308
|
}
|
|
6267
|
-
],
|
|
6309
|
+
], Lr = l ? Ir.filter((e) => "separator" in e || !!e.id && Kr.has(e.id)) : Ir, Rr = M ? M(Lr, {
|
|
6268
6310
|
selectedIds: X,
|
|
6269
6311
|
readOnly: $
|
|
6270
|
-
}) :
|
|
6312
|
+
}) : Lr, Br = zr({
|
|
6271
6313
|
engineRef: W,
|
|
6272
6314
|
image: G,
|
|
6273
6315
|
wheelZoom: Z.wheelZoom,
|
|
6274
6316
|
minimapSize: 204
|
|
6275
|
-
}),
|
|
6317
|
+
}), Hr = x(() => {
|
|
6276
6318
|
W.current?.zoom100();
|
|
6277
|
-
}, []), qr = x(() => {
|
|
6278
|
-
Be((e) => !e);
|
|
6279
6319
|
}, []), Jr = x(() => {
|
|
6280
|
-
|
|
6320
|
+
Be((e) => !e);
|
|
6281
6321
|
}, []), Yr = x(() => {
|
|
6282
|
-
|
|
6322
|
+
Ue((e) => !e);
|
|
6323
|
+
}, []), Xr = x(() => {
|
|
6324
|
+
Ue(!1);
|
|
6283
6325
|
}, []);
|
|
6284
6326
|
return /* @__PURE__ */ y("div", {
|
|
6285
6327
|
className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
|
|
@@ -6292,11 +6334,12 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6292
6334
|
transition: je ? "opacity 0.3s ease" : "none"
|
|
6293
6335
|
}
|
|
6294
6336
|
}),
|
|
6295
|
-
|
|
6296
|
-
status:
|
|
6297
|
-
error:
|
|
6337
|
+
nt !== "ready" && /* @__PURE__ */ v(Ke, {
|
|
6338
|
+
status: nt,
|
|
6339
|
+
error: rt,
|
|
6298
6340
|
render: n,
|
|
6299
6341
|
loadingLabel: Q.imageLoading,
|
|
6342
|
+
missingLabel: Q.imageMissing,
|
|
6300
6343
|
errorLabel: Q.imageLoadError,
|
|
6301
6344
|
errorHints: Q.imageErrorHints
|
|
6302
6345
|
}),
|
|
@@ -6354,71 +6397,71 @@ function qr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
|
|
|
6354
6397
|
y: 0
|
|
6355
6398
|
}
|
|
6356
6399
|
}),
|
|
6357
|
-
|
|
6358
|
-
shapes:
|
|
6400
|
+
Dr.length > 0 && /* @__PURE__ */ v(mt, {
|
|
6401
|
+
shapes: Dr,
|
|
6359
6402
|
getLabel: se,
|
|
6360
6403
|
hideDot: ce,
|
|
6361
6404
|
formatInfo: le,
|
|
6362
|
-
register:
|
|
6405
|
+
register: yn
|
|
6363
6406
|
}),
|
|
6364
|
-
de && (
|
|
6407
|
+
de && (Zn.status === "loading" || Zn.boxes.length > 0) && /* @__PURE__ */ v(He, {
|
|
6365
6408
|
image: G,
|
|
6366
|
-
points:
|
|
6367
|
-
boxes:
|
|
6368
|
-
status:
|
|
6409
|
+
points: Zn.points,
|
|
6410
|
+
boxes: Zn.boxes,
|
|
6411
|
+
status: Zn.status
|
|
6369
6412
|
})
|
|
6370
6413
|
]
|
|
6371
6414
|
})
|
|
6372
6415
|
}),
|
|
6373
|
-
K && Z.showCursorGuide && /* @__PURE__ */ v(
|
|
6374
|
-
G && D && /* @__PURE__ */ v(
|
|
6416
|
+
K && Z.showCursorGuide && /* @__PURE__ */ v(Ge, { color: "#1e88e5" }),
|
|
6417
|
+
G && D && /* @__PURE__ */ v(ot, {
|
|
6375
6418
|
image: G,
|
|
6376
6419
|
imageUrl: $e,
|
|
6377
6420
|
imageVisible: je,
|
|
6378
6421
|
loading: !K,
|
|
6379
|
-
maskDataUrl:
|
|
6380
|
-
region:
|
|
6422
|
+
maskDataUrl: Tt,
|
|
6423
|
+
region: Et,
|
|
6381
6424
|
roiMaskId: ke,
|
|
6382
|
-
shapes:
|
|
6425
|
+
shapes: yr,
|
|
6383
6426
|
view: Z,
|
|
6384
|
-
viewDefaults:
|
|
6385
|
-
onChangeView:
|
|
6386
|
-
nav:
|
|
6387
|
-
registerShape:
|
|
6427
|
+
viewDefaults: _t,
|
|
6428
|
+
onChangeView: bt,
|
|
6429
|
+
nav: Br,
|
|
6430
|
+
registerShape: mn,
|
|
6388
6431
|
rectRef: Ee,
|
|
6389
6432
|
zoomLabelRef: Oe,
|
|
6390
|
-
onZoom100:
|
|
6433
|
+
onZoom100: Hr,
|
|
6391
6434
|
open: ze,
|
|
6392
|
-
onToggleOpen:
|
|
6435
|
+
onToggleOpen: Jr,
|
|
6393
6436
|
position: A,
|
|
6394
6437
|
labels: Q.minimap,
|
|
6395
6438
|
settingsLabels: Q.viewSettings,
|
|
6396
6439
|
showSettings: j,
|
|
6397
|
-
settingsOpen:
|
|
6398
|
-
onToggleSettings:
|
|
6399
|
-
onCloseSettings:
|
|
6440
|
+
settingsOpen: Ve,
|
|
6441
|
+
onToggleSettings: Yr,
|
|
6442
|
+
onCloseSettings: Xr
|
|
6400
6443
|
}),
|
|
6401
|
-
Pe && /* @__PURE__ */ v(
|
|
6444
|
+
Pe && /* @__PURE__ */ v(We, {
|
|
6402
6445
|
x: Pe.x,
|
|
6403
6446
|
y: Pe.y,
|
|
6404
|
-
items:
|
|
6405
|
-
onClose: () =>
|
|
6447
|
+
items: Rr,
|
|
6448
|
+
onClose: () => Fe(null)
|
|
6406
6449
|
})
|
|
6407
6450
|
]
|
|
6408
6451
|
});
|
|
6409
6452
|
}
|
|
6410
6453
|
//#endregion
|
|
6411
6454
|
//#region src/components/ShapeEditor/ShapeViewer.tsx
|
|
6412
|
-
function
|
|
6455
|
+
function Yr(e, t, n) {
|
|
6413
6456
|
if (t.length !== 0) {
|
|
6414
6457
|
e.beginPath(), e.moveTo(t[0].x, t[0].y);
|
|
6415
6458
|
for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
|
|
6416
6459
|
n && e.closePath();
|
|
6417
6460
|
}
|
|
6418
6461
|
}
|
|
6419
|
-
function
|
|
6462
|
+
function Xr(e, t, n, r) {
|
|
6420
6463
|
if (t.interaction?.visible === !1) return;
|
|
6421
|
-
let i =
|
|
6464
|
+
let i = Qe(t, {
|
|
6422
6465
|
strokeWidth: r,
|
|
6423
6466
|
pointRadius: 2
|
|
6424
6467
|
});
|
|
@@ -6433,10 +6476,10 @@ function Yr(e, t, n, r) {
|
|
|
6433
6476
|
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);
|
|
6434
6477
|
e.beginPath(), t.type === L.ELLIPSE ? e.ellipse(i + o / 2, a + s / 2, o / 2, s / 2, 0, 0, Math.PI * 2) : e.rect(i, a, o, s);
|
|
6435
6478
|
}
|
|
6436
|
-
} else
|
|
6479
|
+
} else Yr(e, t.points, t.type !== L.LINE);
|
|
6437
6480
|
i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill("evenodd"), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
|
|
6438
6481
|
}
|
|
6439
|
-
function
|
|
6482
|
+
function Zr({ 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: p = !0, lazy: m = !0, className: h, style: g, renderImageState: _ }) {
|
|
6440
6483
|
let b = O(null), x = O(null), C = O(null), [w, T] = k(!m), [D, A] = k("loading"), [j, M] = k(null), [N, P] = k(0);
|
|
6441
6484
|
S(() => {
|
|
6442
6485
|
if (!m || w) return;
|
|
@@ -6453,18 +6496,18 @@ function Xr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6453
6496
|
return t.observe(e), () => t.disconnect();
|
|
6454
6497
|
}, []), S(() => {
|
|
6455
6498
|
if (!w || !e) {
|
|
6456
|
-
A(e ? "loading" : "
|
|
6499
|
+
A(e ? "loading" : "missing"), M(null);
|
|
6457
6500
|
return;
|
|
6458
6501
|
}
|
|
6459
6502
|
let t = !0;
|
|
6460
|
-
return A("loading"), M(null),
|
|
6503
|
+
return A("loading"), M(null), Jn(e).then(async (n) => {
|
|
6461
6504
|
if (!t) return;
|
|
6462
6505
|
if (n) {
|
|
6463
6506
|
C.current = n, A("ready");
|
|
6464
6507
|
return;
|
|
6465
6508
|
}
|
|
6466
6509
|
C.current = null, A("error");
|
|
6467
|
-
let r = await
|
|
6510
|
+
let r = await $n(e);
|
|
6468
6511
|
t && M(r);
|
|
6469
6512
|
}), () => {
|
|
6470
6513
|
t = !1;
|
|
@@ -6472,7 +6515,7 @@ function Xr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6472
6515
|
}, [e, w]), S(() => () => {
|
|
6473
6516
|
C.current = null;
|
|
6474
6517
|
}, []);
|
|
6475
|
-
let F = E(() => r.find((e) => e.id === s), [s, r]), ee = E(() => a && o ?
|
|
6518
|
+
let F = E(() => r.find((e) => e.id === s), [s, r]), ee = E(() => a && o ? Bt(a, o) : null, [a, o]);
|
|
6476
6519
|
return S(() => {
|
|
6477
6520
|
if (D === "error") {
|
|
6478
6521
|
let e = x.current;
|
|
@@ -6495,20 +6538,20 @@ function Xr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6495
6538
|
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, S = s / 2 - (e.minY + e.maxY) / 2 * v, c === "cover" && (y = Math.min(0, Math.max(y, o - g * v)), S = Math.min(0, Math.max(S, s - _ * v)));
|
|
6496
6539
|
}
|
|
6497
6540
|
h.setTransform(m, 0, 0, m, 0, 0), h.clearRect(0, 0, o, s), h.save(), h.translate(y, S), h.scale(v, v), h.imageSmoothingEnabled = p, h.filter = `brightness(${d}) contrast(${f})`, h.drawImage(a, 0, 0, g, _), h.filter = "none", ee && (h.save(), h.globalAlpha = .55, h.drawImage(ee, 0, 0, g, _), h.restore());
|
|
6498
|
-
let w = i ?
|
|
6499
|
-
if (w && (
|
|
6541
|
+
let w = i ? Zt(i, g, _) : null;
|
|
6542
|
+
if (w && (Kt(h, w, g, _), w.outlineStyles)) {
|
|
6500
6543
|
let e = (e, t) => {
|
|
6501
6544
|
if (h.lineWidth = t.width / v, t.underlayColor) {
|
|
6502
6545
|
h.setLineDash([]), h.strokeStyle = t.underlayColor;
|
|
6503
|
-
for (let [t, n] of e)
|
|
6546
|
+
for (let [t, n] of e) Yr(h, [t, n], !1), h.stroke();
|
|
6504
6547
|
}
|
|
6505
6548
|
h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / v)), h.strokeStyle = t.color;
|
|
6506
|
-
for (let [t, n] of e)
|
|
6549
|
+
for (let [t, n] of e) Yr(h, [t, n], !1), h.stroke();
|
|
6507
6550
|
h.restore();
|
|
6508
6551
|
};
|
|
6509
6552
|
e(w.visibleOutline, w.outlineStyles.visible), e(w.occludedOutline, w.outlineStyles.occluded);
|
|
6510
6553
|
}
|
|
6511
|
-
for (let e of B(r))
|
|
6554
|
+
for (let e of B(r)) Xr(h, e, v, u);
|
|
6512
6555
|
h.restore();
|
|
6513
6556
|
}, [
|
|
6514
6557
|
d,
|
|
@@ -6543,7 +6586,20 @@ function Xr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6543
6586
|
position: "absolute",
|
|
6544
6587
|
inset: 0
|
|
6545
6588
|
},
|
|
6546
|
-
children: _?.(D
|
|
6589
|
+
children: _?.(D, j) ?? (D === "missing" ? /* @__PURE__ */ v("div", {
|
|
6590
|
+
style: {
|
|
6591
|
+
display: "flex",
|
|
6592
|
+
alignItems: "center",
|
|
6593
|
+
justifyContent: "center",
|
|
6594
|
+
height: "100%",
|
|
6595
|
+
padding: 8,
|
|
6596
|
+
textAlign: "center",
|
|
6597
|
+
color: "rgba(255,255,255,0.7)",
|
|
6598
|
+
background: "rgba(13,13,18,0.85)",
|
|
6599
|
+
fontSize: 12
|
|
6600
|
+
},
|
|
6601
|
+
children: q.imageMissing
|
|
6602
|
+
}) : D === "error" ? /* @__PURE__ */ y("div", {
|
|
6547
6603
|
style: {
|
|
6548
6604
|
display: "flex",
|
|
6549
6605
|
flexDirection: "column",
|
|
@@ -6577,6 +6633,6 @@ function Xr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
|
|
|
6577
6633
|
});
|
|
6578
6634
|
}
|
|
6579
6635
|
//#endregion
|
|
6580
|
-
export { q as DEFAULT_EDITOR_STRINGS,
|
|
6636
|
+
export { q as DEFAULT_EDITOR_STRINGS, Le as DEFAULT_VIEW_SETTINGS, L as SHAPE_TYPE, Jr as ShapeEditor, Jr as default, Zr as ShapeViewer, J as TOOL, ae as generateId };
|
|
6581
6637
|
|
|
6582
6638
|
//# sourceMappingURL=shape-editor.js.map
|