@aivex/ui 1.2.0-dev.25 → 1.2.0-dev.27

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.
@@ -31,7 +31,7 @@ function ie(e) {
31
31
  function z(e) {
32
32
  return ie(e) && e.interaction?.draggable !== !1;
33
33
  }
34
- function ae(e) {
34
+ function B(e) {
35
35
  return e.map((e, t) => ({
36
36
  shape: e,
37
37
  index: t
@@ -40,10 +40,13 @@ function ae(e) {
40
40
  return n === r ? e.index - t.index : n - r;
41
41
  }).map((e) => e.shape);
42
42
  }
43
- function oe() {
43
+ function V(e, t, n) {
44
+ return Math.max(t, Math.min(n, e));
45
+ }
46
+ function ae() {
44
47
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `id_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
45
48
  }
46
- var B = [
49
+ var oe = [
47
50
  "tl",
48
51
  "t",
49
52
  "tr",
@@ -53,7 +56,7 @@ var B = [
53
56
  "bl",
54
57
  "l"
55
58
  ];
56
- function V(e) {
59
+ function H(e) {
57
60
  let t = e.map((e) => e.x), n = e.map((e) => e.y);
58
61
  return {
59
62
  minX: Math.min(...t),
@@ -62,14 +65,14 @@ function V(e) {
62
65
  maxY: Math.max(...n)
63
66
  };
64
67
  }
65
- function se(e, t) {
68
+ function U(e, t) {
66
69
  let n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2;
67
70
  return {
68
71
  x: e.includes("l") ? t.minX : e.includes("r") ? t.maxX : n,
69
72
  y: e.includes("t") ? t.minY : e.includes("b") ? t.maxY : r
70
73
  };
71
74
  }
72
- function H(e, t, n, r) {
75
+ function se(e, t, n, r) {
73
76
  let i = { ...t };
74
77
  return e.includes("l") && (i.minX = n), e.includes("r") && (i.maxX = n), e.includes("t") && (i.minY = r), e.includes("b") && (i.maxY = r), i;
75
78
  }
@@ -88,7 +91,7 @@ function le(e, t, n) {
88
91
  };
89
92
  }
90
93
  function ue(e) {
91
- let t = V(e);
94
+ let t = H(e);
92
95
  return [
93
96
  {
94
97
  x: t.minX,
@@ -220,7 +223,7 @@ function Se(e, t, n, r) {
220
223
  function Ce(e, t, n) {
221
224
  if (e.length < 4) return e;
222
225
  let r = e[0], i = _e(me(e[1], e[0])), a = _e(me(e[3], e[0])), o = he(me(e[1], r), i), s = he(me(e[3], r), a), c = me(n, r);
223
- return Se(H(t, {
226
+ return Se(se(t, {
224
227
  minX: 0,
225
228
  minY: 0,
226
229
  maxX: o,
@@ -238,7 +241,7 @@ function Te(e, t, n, r) {
238
241
  let i = (e, t, n) => Math.sign((t.x - e.x) * (n.y - e.y) - (t.y - e.y) * (n.x - e.x)), a = i(e, t, n), o = i(e, t, r), s = i(n, r, e), c = i(n, r, t);
239
242
  return a !== o && s !== c && !(a === 0 && o === 0);
240
243
  }
241
- function U(e, t = 256) {
244
+ function W(e, t = 256) {
242
245
  let n = e.length;
243
246
  if (n < 4 || n > t) return !1;
244
247
  for (let t = 0; t < n; t++) {
@@ -258,7 +261,7 @@ function Ee(e, t, n, r) {
258
261
  }
259
262
  function De(e, t = 256) {
260
263
  let n = e.length;
261
- if (n < 4 || n > t || !U(e, t)) return [e];
264
+ if (n < 4 || n > t || !W(e, t)) return [e];
262
265
  let r = Array.from({ length: n }, () => []), i = 0;
263
266
  for (let t = 0; t < n; t++) {
264
267
  let a = e[t], o = e[(t + 1) % n];
@@ -317,9 +320,85 @@ function De(e, t = 256) {
317
320
  }
318
321
  return l.length ? l : [e];
319
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);
327
+ }
328
+ function je(e, t, n) {
329
+ if (Oe(e, n) || Oe(t, n)) return !0;
330
+ let r = {
331
+ x: n.minX,
332
+ y: n.minY
333
+ }, i = {
334
+ x: n.maxX,
335
+ y: n.minY
336
+ }, a = {
337
+ x: n.maxX,
338
+ y: n.maxY
339
+ }, o = {
340
+ x: n.minX,
341
+ y: n.maxY
342
+ };
343
+ return Ae(e, t, r, i) || Ae(e, t, i, a) || Ae(e, t, a, o) || Ae(e, t, o, r);
344
+ }
345
+ function Me(e, t) {
346
+ let n = !1;
347
+ for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
348
+ let a = t[r], o = t[i];
349
+ a.y > e.y != o.y > e.y && e.x < (o.x - a.x) * (e.y - a.y) / (o.y - a.y) + a.x && (n = !n);
350
+ }
351
+ return n;
352
+ }
353
+ function K(e, t, n) {
354
+ if (e.some((e) => Oe(e, t))) return !0;
355
+ let r = n ? e.length : e.length - 1;
356
+ for (let n = 0; n < r; n += 1) if (je(e[n], e[(n + 1) % e.length], t)) return !0;
357
+ return !1;
358
+ }
359
+ function Ne(e, t) {
360
+ let n = e.points;
361
+ if (!n.length) return !1;
362
+ let r = H(n);
363
+ if (r.minX > t.maxX || r.maxX < t.minX || r.minY > t.maxY || r.maxY < t.minY) return !1;
364
+ switch (e.type) {
365
+ case L.POINT: return Oe(n[0], t);
366
+ case L.RECTANGLE: return !0;
367
+ case L.ELLIPSE: {
368
+ let e = (r.maxX - r.minX) / 2, n = (r.maxY - r.minY) / 2;
369
+ if (e <= 0 || n <= 0) return !0;
370
+ 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
+ return ((o - i) / e) ** 2 + ((s - a) / n) ** 2 <= 1;
372
+ }
373
+ case L.LINE: return K(n, t, !1);
374
+ case L.POLYGON:
375
+ case L.ROTATED_RECTANGLE: return K(n, t, !0) || n.length >= 3 && Me({
376
+ x: t.minX,
377
+ y: t.minY
378
+ }, n);
379
+ default: return !0;
380
+ }
381
+ }
382
+ function Pe(e) {
383
+ if (e.length <= 1) return e.map((e) => ({
384
+ outline: e,
385
+ holes: []
386
+ }));
387
+ let t = e.map((e) => ve(e[0], e[1] ?? e[0])), n = e.map((n, r) => e.reduce((e, n, i) => (r !== i && Me(t[r], n) && e.push(i), e), [])), r = /* @__PURE__ */ new Map();
388
+ return e.forEach((e, t) => {
389
+ n[t].length % 2 == 0 && r.set(t, {
390
+ outline: e,
391
+ holes: []
392
+ });
393
+ }), e.forEach((e, t) => {
394
+ if (n[t].length % 2 == 0) return;
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()];
398
+ }
320
399
  //#endregion
321
400
  //#region src/components/ShapeEditor/_model/strings.ts
322
- var W = {
401
+ var q = {
323
402
  contextMenu: {
324
403
  copy: "복사",
325
404
  paste: "붙여넣기",
@@ -380,31 +459,31 @@ var W = {
380
459
  unknown: "원인이 특정되지 않은 오류입니다. 아래 상세 정보와 함께 기술 지원에 문의하시기 바랍니다."
381
460
  }
382
461
  };
383
- function Oe(e) {
462
+ function Fe(e) {
384
463
  return e ? {
385
464
  contextMenu: {
386
- ...W.contextMenu,
465
+ ...q.contextMenu,
387
466
  ...e.contextMenu
388
467
  },
389
468
  viewSettings: {
390
- ...W.viewSettings,
469
+ ...q.viewSettings,
391
470
  ...e.viewSettings
392
471
  },
393
472
  minimap: {
394
- ...W.minimap,
473
+ ...q.minimap,
395
474
  ...e.minimap
396
475
  },
397
- imageLoading: e.imageLoading ?? W.imageLoading,
398
- imageLoadError: e.imageLoadError ?? W.imageLoadError,
476
+ imageLoading: e.imageLoading ?? q.imageLoading,
477
+ imageLoadError: e.imageLoadError ?? q.imageLoadError,
399
478
  imageErrorHints: {
400
- ...W.imageErrorHints,
479
+ ...q.imageErrorHints,
401
480
  ...e.imageErrorHints
402
481
  }
403
- } : W;
482
+ } : q;
404
483
  }
405
484
  //#endregion
406
485
  //#region src/components/ShapeEditor/_model/tools.ts
407
- var G = {
486
+ var J = {
408
487
  SELECT: "SELECT",
409
488
  POLYGON: "POLYGON",
410
489
  PATH: "PATH",
@@ -416,7 +495,7 @@ var G = {
416
495
  ASSISTANT_POLYGON: "ASSISTANT_POLYGON",
417
496
  ASSISTANT_RECT: "ASSISTANT_RECT",
418
497
  ASSISTANT_POINT: "ASSISTANT_POINT"
419
- }, ke = {
498
+ }, Ie = {
420
499
  brightness: 1,
421
500
  contrast: 1,
422
501
  showCursorGuide: !1,
@@ -428,9 +507,9 @@ var G = {
428
507
  keepZoomOnImageChange: !1,
429
508
  wheelZoom: !0,
430
509
  zoomSensitivity: 1
431
- }, Ae = "var(--editor-overlay-inverse-scale, 1)", K = "#377be2", je = "#e23c3c";
432
- function Me({ point: e }) {
433
- let t = e.positive ? K : je;
510
+ }, Le = "var(--editor-overlay-inverse-scale, 1)", Re = "#377be2", ze = "#e23c3c";
511
+ function Be({ point: e }) {
512
+ let t = e.positive ? Re : ze;
434
513
  return /* @__PURE__ */ v("div", {
435
514
  style: {
436
515
  position: "absolute",
@@ -451,13 +530,13 @@ function Me({ point: e }) {
451
530
  display: "flex",
452
531
  alignItems: "center",
453
532
  justifyContent: "center",
454
- transform: `scale(${Ae})`,
533
+ transform: `scale(${Le})`,
455
534
  transformOrigin: "center"
456
535
  },
457
536
  children: e.positive ? "+" : "−"
458
537
  });
459
538
  }
460
- function Ne({ image: e, points: t, boxes: n, status: r }) {
539
+ function Ve({ image: e, points: t, boxes: n, status: r }) {
461
540
  return /* @__PURE__ */ y("div", {
462
541
  style: {
463
542
  position: "absolute",
@@ -481,13 +560,13 @@ function Ne({ image: e, points: t, boxes: n, status: r }) {
481
560
  backgroundSize: "200% 100%",
482
561
  animation: "editorv2-assistant-shimmer 1.4s linear infinite"
483
562
  } }, `box-${t}-${e.x}-${e.y}-${e.width}-${e.height}`)),
484
- r === "loading" && t.map((e, t) => /* @__PURE__ */ v(Me, { point: e }, `pt-${t}-${e.x}-${e.y}`))
563
+ r === "loading" && t.map((e, t) => /* @__PURE__ */ v(Be, { point: e }, `pt-${t}-${e.x}-${e.y}`))
485
564
  ]
486
565
  });
487
566
  }
488
567
  //#endregion
489
568
  //#region src/components/ShapeEditor/_components/ContextMenu.tsx
490
- function Pe(e) {
569
+ function He(e) {
491
570
  let t = [];
492
571
  for (let n of e) if ("separator" in n) {
493
572
  if (!t.length || "separator" in t[t.length - 1]) continue;
@@ -496,8 +575,8 @@ function Pe(e) {
496
575
  for (; t.length && "separator" in t[t.length - 1];) t.pop();
497
576
  return t;
498
577
  }
499
- function Fe({ x: e, y: t, items: n, onClose: r }) {
500
- let i = Pe(n);
578
+ function Ue({ x: e, y: t, items: n, onClose: r }) {
579
+ let i = He(n);
501
580
  return /* @__PURE__ */ y(p, {
502
581
  open: !0,
503
582
  modal: !1,
@@ -548,7 +627,7 @@ function Fe({ x: e, y: t, items: n, onClose: r }) {
548
627
  }
549
628
  //#endregion
550
629
  //#region src/components/ShapeEditor/_components/CursorGuide.tsx
551
- function Ie({ color: e = "#1e88e5" }) {
630
+ function We({ color: e = "#1e88e5" }) {
552
631
  let t = O(null), n = O(null), r = O(null);
553
632
  return S(() => {
554
633
  let e = t.current, i = n.current, a = r.current;
@@ -598,7 +677,7 @@ function Ie({ color: e = "#1e88e5" }) {
598
677
  }
599
678
  //#endregion
600
679
  //#region src/components/ShapeEditor/_components/ImageStateOverlay.tsx
601
- function Le({ status: e, error: t, render: n, loadingLabel: r = W.imageLoading, errorLabel: i = W.imageLoadError, errorHints: a = W.imageErrorHints }) {
680
+ function Ge({ status: e, error: t, render: n, loadingLabel: r = q.imageLoading, errorLabel: i = q.imageLoadError, errorHints: a = q.imageErrorHints }) {
602
681
  let o = n?.(e, t) ?? null;
603
682
  return /* @__PURE__ */ v("div", {
604
683
  "data-track-id": e === "loading" ? "editor-image-loading-wrap" : "editor-image-error-wrap",
@@ -675,11 +754,11 @@ function Le({ status: e, error: t, render: n, loadingLabel: r = W.imageLoading,
675
754
  });
676
755
  }
677
756
  Math.PI / 12;
678
- var Re = "#00ff00", ze = "rgba(0, 255, 0, 0.1)", Be = "#669DEF", Ve = .1, He = [3, 3];
757
+ var Ke = "#00ff00", qe = "rgba(0, 255, 0, 0.1)", Je = "#669DEF", Ye = .1, Xe = [3, 3];
679
758
  //#endregion
680
759
  //#region src/components/ShapeEditor/_model/shapeRenderStyle.ts
681
- function Ue(e, t = {}) {
682
- 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 * He[0], r * He[1]] : void 0);
760
+ function Ze(e, t = {}) {
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 * Xe[0], r * Xe[1]] : void 0);
683
762
  return {
684
763
  color: n,
685
764
  strokeWidth: r,
@@ -690,7 +769,7 @@ function Ue(e, t = {}) {
690
769
  pointRadius: e.style?.pointRadius ?? t.pointRadius ?? 5
691
770
  };
692
771
  }
693
- function We(e, t) {
772
+ function Qe(e, t) {
694
773
  let n = Math.max(0, Math.min(1, t)), r = e.trim().replace("#", "");
695
774
  if (r.length === 3 || r.length === 6) {
696
775
  let e = r.length === 3 ? r.replace(/./g, (e) => e + e) : r, t = Number.parseInt(e, 16);
@@ -700,8 +779,8 @@ function We(e, t) {
700
779
  }
701
780
  //#endregion
702
781
  //#region src/components/ShapeEditor/_components/MinimapShape.tsx
703
- var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
704
- let { type: r, points: i } = e, a = Ue(e, { strokeWidth: t }), o = (t) => n?.(e.id, t), s = {
782
+ var $e = b(function({ shape: e, strokeSize: t, register: n }) {
783
+ let { type: r, points: i } = e, a = Ze(e, { strokeWidth: t }), o = (t) => n?.(e.id, t), s = {
705
784
  ref: o,
706
785
  stroke: a.color,
707
786
  strokeWidth: a.strokeWidth,
@@ -720,7 +799,7 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
720
799
  opacity: a.opacity
721
800
  });
722
801
  if (r === L.RECTANGLE || r === L.ELLIPSE) {
723
- let e = V(i);
802
+ let e = H(i);
724
803
  return r === L.ELLIPSE ? /* @__PURE__ */ v("ellipse", {
725
804
  cx: (e.minX + e.maxX) / 2,
726
805
  cy: (e.minY + e.maxY) / 2,
@@ -741,12 +820,13 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
741
820
  ...s
742
821
  }) : /* @__PURE__ */ v("polygon", {
743
822
  points: c,
823
+ fillRule: "evenodd",
744
824
  ...s
745
825
  });
746
826
  });
747
827
  //#endregion
748
828
  //#region src/components/ShapeEditor/_components/RegionOverlay.tsx
749
- function Ke({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth: a, strokeDasharray: o, style: s }) {
829
+ function et({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth: a, strokeDasharray: o, style: s }) {
750
830
  let c = [...t.visibleOutline, ...t.occludedOutline];
751
831
  return /* @__PURE__ */ y("svg", {
752
832
  width: r,
@@ -800,7 +880,7 @@ function Ke({ image: e, region: t, maskId: n, width: r, height: i, strokeWidth:
800
880
  }
801
881
  //#endregion
802
882
  //#region src/components/ShapeEditor/_components/SettingsPanel.tsx
803
- function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.viewSettings, openDown: f = !1, alignEnd: p = !1 }) {
883
+ function tt({ value: i, defaults: o, onChange: s, onClose: c, labels: d = q.viewSettings, openDown: f = !1, alignEnd: p = !1 }) {
804
884
  return S(() => {
805
885
  let e = (e) => {
806
886
  e.key === "Escape" && c();
@@ -819,7 +899,7 @@ function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
819
899
  /* @__PURE__ */ y("div", {
820
900
  className: "aivex:flex aivex:flex-col aivex:gap-md",
821
901
  children: [
822
- /* @__PURE__ */ v(Je, {
902
+ /* @__PURE__ */ v(nt, {
823
903
  icon: /* @__PURE__ */ v(r, { size: 16 }),
824
904
  label: d.brightness,
825
905
  value: i.brightness.toFixed(2),
@@ -831,7 +911,7 @@ function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
831
911
  onValueChange: ([e]) => s({ brightness: e })
832
912
  })
833
913
  }),
834
- /* @__PURE__ */ v(Je, {
914
+ /* @__PURE__ */ v(nt, {
835
915
  icon: /* @__PURE__ */ v(n, { size: 16 }),
836
916
  label: d.contrast,
837
917
  value: i.contrast.toFixed(2),
@@ -843,7 +923,7 @@ function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
843
923
  onValueChange: ([e]) => s({ contrast: e })
844
924
  })
845
925
  }),
846
- /* @__PURE__ */ v(Je, {
926
+ /* @__PURE__ */ v(nt, {
847
927
  icon: /* @__PURE__ */ v(t, { size: 16 }),
848
928
  label: d.strokeSize,
849
929
  value: String(i.strokeSize),
@@ -855,7 +935,7 @@ function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
855
935
  onValueChange: ([e]) => s({ strokeSize: e })
856
936
  })
857
937
  }),
858
- /* @__PURE__ */ v(Je, {
938
+ /* @__PURE__ */ v(nt, {
859
939
  icon: /* @__PURE__ */ v(e, { size: 16 }),
860
940
  label: d.simplifyStrength,
861
941
  value: String(i.simplifyStrength),
@@ -867,7 +947,7 @@ function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
867
947
  onValueChange: ([e]) => s({ simplifyStrength: e })
868
948
  })
869
949
  }),
870
- /* @__PURE__ */ v(Je, {
950
+ /* @__PURE__ */ v(nt, {
871
951
  icon: /* @__PURE__ */ v(l, { size: 16 }),
872
952
  label: d.zoomSensitivity,
873
953
  value: i.zoomSensitivity.toFixed(1),
@@ -882,32 +962,32 @@ function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
882
962
  /* @__PURE__ */ y("div", {
883
963
  className: "aivex:flex aivex:flex-col aivex:gap-xs",
884
964
  children: [
885
- /* @__PURE__ */ v(Ye, {
965
+ /* @__PURE__ */ v(rt, {
886
966
  label: d.pixelation,
887
967
  checked: !i.imageSmoothing,
888
968
  onChange: (e) => s({ imageSmoothing: !e })
889
969
  }),
890
- /* @__PURE__ */ v(Ye, {
970
+ /* @__PURE__ */ v(rt, {
891
971
  label: d.cursorGuide,
892
972
  checked: i.showCursorGuide,
893
973
  onChange: (e) => s({ showCursorGuide: e })
894
974
  }),
895
- /* @__PURE__ */ v(Ye, {
975
+ /* @__PURE__ */ v(rt, {
896
976
  label: d.guideMask,
897
977
  checked: i.showGuide,
898
978
  onChange: (e) => s({ showGuide: e })
899
979
  }),
900
- /* @__PURE__ */ v(Ye, {
980
+ /* @__PURE__ */ v(rt, {
901
981
  label: d.regionMask,
902
982
  checked: i.showRegionMask,
903
983
  onChange: (e) => s({ showRegionMask: e })
904
984
  }),
905
- /* @__PURE__ */ v(Ye, {
985
+ /* @__PURE__ */ v(rt, {
906
986
  label: d.keepZoomOnImageChange,
907
987
  checked: i.keepZoomOnImageChange,
908
988
  onChange: (e) => s({ keepZoomOnImageChange: e })
909
989
  }),
910
- /* @__PURE__ */ v(Ye, {
990
+ /* @__PURE__ */ v(rt, {
911
991
  label: d.wheelZoom,
912
992
  checked: i.wheelZoom,
913
993
  onChange: (e) => s({ wheelZoom: e })
@@ -930,7 +1010,7 @@ function qe({ value: i, defaults: o, onChange: s, onClose: c, labels: d = W.view
930
1010
  ]
931
1011
  });
932
1012
  }
933
- function Je({ icon: e, label: t, value: n, children: r }) {
1013
+ function nt({ icon: e, label: t, value: n, children: r }) {
934
1014
  return /* @__PURE__ */ y("div", {
935
1015
  className: "aivex:flex aivex:flex-col aivex:px-md aivex:py-2xs",
936
1016
  children: [/* @__PURE__ */ y("div", {
@@ -955,7 +1035,7 @@ function Je({ icon: e, label: t, value: n, children: r }) {
955
1035
  })]
956
1036
  });
957
1037
  }
958
- function Ye({ label: e, checked: t, onChange: n }) {
1038
+ function rt({ label: e, checked: t, onChange: n }) {
959
1039
  return /* @__PURE__ */ y("div", {
960
1040
  className: "aivex:flex aivex:items-center aivex:gap-md aivex:rounded-md aivex:px-md aivex:py-sm",
961
1041
  children: [/* @__PURE__ */ v("span", {
@@ -970,12 +1050,12 @@ function Ye({ label: e, checked: t, onChange: n }) {
970
1050
  }
971
1051
  //#endregion
972
1052
  //#region src/components/ShapeEditor/_components/Minimap.tsx
973
- var Xe = {
1053
+ var it = {
974
1054
  "bottom-left": "aivex:bottom-2 aivex:left-2",
975
1055
  "bottom-right": "aivex:bottom-2 aivex:right-2",
976
1056
  "top-left": "aivex:top-2 aivex:left-2",
977
1057
  "top-right": "aivex:top-2 aivex:right-2"
978
- }, Ze = 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 = W.minimap, settingsLabels: M }) {
1058
+ }, at = 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 }) {
979
1059
  let { offX: N, offY: P, dispW: F, dispH: ee, zoomCentered: te } = _, I = E.startsWith("top"), L = {
980
1060
  position: "absolute",
981
1061
  left: N,
@@ -1023,7 +1103,7 @@ var Xe = {
1023
1103
  pointerEvents: "none"
1024
1104
  }
1025
1105
  }),
1026
- m.showRegionMask && o && o.rects.length > 0 && /* @__PURE__ */ v(Ke, {
1106
+ m.showRegionMask && o && o.rects.length > 0 && /* @__PURE__ */ v(et, {
1027
1107
  image: e,
1028
1108
  region: o,
1029
1109
  maskId: l,
@@ -1049,7 +1129,7 @@ var Xe = {
1049
1129
  pointerEvents: "none"
1050
1130
  },
1051
1131
  "aria-hidden": !0,
1052
- children: ae(p).filter(ne).map((e) => /* @__PURE__ */ v(Ge, {
1132
+ children: B(p).filter(ne).map((e) => /* @__PURE__ */ v($e, {
1053
1133
  shape: e,
1054
1134
  strokeSize: m.strokeSize,
1055
1135
  register: b
@@ -1059,8 +1139,8 @@ var Xe = {
1059
1139
  ref: x,
1060
1140
  style: {
1061
1141
  position: "absolute",
1062
- border: `1px solid ${Re}`,
1063
- background: ze,
1142
+ border: `1px solid ${Ke}`,
1143
+ background: qe,
1064
1144
  boxSizing: "border-box",
1065
1145
  pointerEvents: "none"
1066
1146
  }
@@ -1109,7 +1189,7 @@ var Xe = {
1109
1189
  onPointerDown: (e) => e.stopPropagation(),
1110
1190
  className: O ? "aivex:text-text-brand" : void 0,
1111
1191
  children: /* @__PURE__ */ v(d, { size: 20 })
1112
- }), O && /* @__PURE__ */ v(qe, {
1192
+ }), O && /* @__PURE__ */ v(tt, {
1113
1193
  value: m,
1114
1194
  defaults: h,
1115
1195
  onChange: g,
@@ -1133,10 +1213,10 @@ var Xe = {
1133
1213
  ]
1134
1214
  });
1135
1215
  return /* @__PURE__ */ y("div", {
1136
- className: `aivex:absolute ${Xe[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)]`,
1216
+ className: `aivex:absolute ${it[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)]`,
1137
1217
  children: [I ? R : re, I ? re : R]
1138
1218
  });
1139
- }), Qe = "var(--editor-overlay-inverse-scale, 1)", $e = 6, et = {
1219
+ }), Y = "var(--editor-overlay-inverse-scale, 1)", ot = 6, st = {
1140
1220
  fontFamily: "Pretendard, sans-serif",
1141
1221
  fontSize: 12,
1142
1222
  fontWeight: 500,
@@ -1145,8 +1225,8 @@ var Xe = {
1145
1225
  textShadow: "0 0 4px #000, 0 0 4px #000",
1146
1226
  whiteSpace: "nowrap"
1147
1227
  };
1148
- function tt(e) {
1149
- let t = V(e);
1228
+ function X(e) {
1229
+ let t = H(e);
1150
1230
  return {
1151
1231
  x: t.minX,
1152
1232
  y: t.minY,
@@ -1154,25 +1234,25 @@ function tt(e) {
1154
1234
  height: t.maxY - t.minY
1155
1235
  };
1156
1236
  }
1157
- function nt(e) {
1158
- return `translate3d(${e.width}px, ${e.height}px, 0) scale(${Qe}) translate(-100%, ${$e}px)`;
1237
+ function ct(e) {
1238
+ return `translate3d(${e.width}px, ${e.height}px, 0) scale(${Y}) translate(-100%, ${ot}px)`;
1159
1239
  }
1160
- function rt(e, t) {
1161
- let n = tt(t);
1240
+ function lt(e, t) {
1241
+ let n = X(t);
1162
1242
  e.style.transform = `translate3d(${n.x}px, ${n.y}px, 0)`;
1163
1243
  let r = e.querySelector("[data-selinfo-dim]");
1164
- return r && (r.style.transform = nt(n)), r;
1244
+ return r && (r.style.transform = ct(n)), r;
1165
1245
  }
1166
- function it(e, t) {
1246
+ function ut(e, t) {
1167
1247
  return {
1168
1248
  shape: e,
1169
- ...tt(t)
1249
+ ...X(t)
1170
1250
  };
1171
1251
  }
1172
- function at(e) {
1252
+ function dt(e) {
1173
1253
  return `${Math.round(e.width)} x ${Math.round(e.height)} px`;
1174
1254
  }
1175
- function ot({ color: e, striped: t }) {
1255
+ function ft({ color: e, striped: t }) {
1176
1256
  return /* @__PURE__ */ v("span", { style: {
1177
1257
  display: "inline-block",
1178
1258
  width: 12,
@@ -1184,9 +1264,9 @@ function ot({ color: e, striped: t }) {
1184
1264
  } : { background: e }
1185
1265
  } });
1186
1266
  }
1187
- function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
1267
+ function pt({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
1188
1268
  return /* @__PURE__ */ v(_, { children: e.map((e) => {
1189
- let a = tt(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 = it(e, e.points), d = r ? r(u) : at(u);
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 = ut(e, e.points), d = r ? r(u) : dt(u);
1190
1270
  return /* @__PURE__ */ y("div", {
1191
1271
  ref: (t) => i(e.id, t),
1192
1272
  style: {
@@ -1205,11 +1285,11 @@ function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
1205
1285
  display: "flex",
1206
1286
  alignItems: "center",
1207
1287
  gap: 4,
1208
- transform: `scale(${Qe}) translateY(calc(-100% - ${$e}px))`,
1288
+ transform: `scale(${Y}) translateY(calc(-100% - ${ot}px))`,
1209
1289
  transformOrigin: "left top",
1210
- ...et
1290
+ ...st
1211
1291
  },
1212
- children: [!n && /* @__PURE__ */ v(ot, {
1292
+ children: [!n && /* @__PURE__ */ v(ft, {
1213
1293
  color: c,
1214
1294
  striped: l
1215
1295
  }), /* @__PURE__ */ v("span", { children: s })]
@@ -1219,10 +1299,10 @@ function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
1219
1299
  position: "absolute",
1220
1300
  left: 0,
1221
1301
  top: 0,
1222
- transform: nt(a),
1302
+ transform: ct(a),
1223
1303
  transformOrigin: "left top",
1224
1304
  willChange: "transform",
1225
- ...et
1305
+ ...st
1226
1306
  },
1227
1307
  children: d
1228
1308
  })]
@@ -1231,79 +1311,79 @@ function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
1231
1311
  }
1232
1312
  //#endregion
1233
1313
  //#region src/components/ShapeEditor/_model/clipboard.ts
1234
- var ct = "AIVEX_SHAPE_EDITOR:", lt = 1, ut = new Set(Object.values(L)), q = null, dt = "unavailable", ft = 0;
1235
- function J(e) {
1314
+ var mt = "AIVEX_SHAPE_EDITOR:", ht = 1, gt = new Set(Object.values(L)), _t = null, Z = "unavailable", vt = 0;
1315
+ function yt(e) {
1236
1316
  if (!e || typeof e != "object") return !1;
1237
1317
  let t = e;
1238
1318
  return Number.isFinite(t.x) && Number.isFinite(t.y);
1239
1319
  }
1240
- function pt(e) {
1320
+ function Q(e) {
1241
1321
  if (!e || typeof e != "object") return !1;
1242
1322
  let t = e;
1243
- return typeof t.type == "string" && ut.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(J);
1323
+ return typeof t.type == "string" && gt.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(yt);
1244
1324
  }
1245
- function mt(e, t, n) {
1325
+ function bt(e, t, n) {
1246
1326
  return {
1247
1327
  kind: "aivex-shape-editor",
1248
- version: lt,
1328
+ version: ht,
1249
1329
  scope: n,
1250
1330
  documentId: t,
1251
1331
  shapes: e
1252
1332
  };
1253
1333
  }
1254
- function ht(e) {
1334
+ function xt(e) {
1255
1335
  let t = 2166136261;
1256
1336
  for (let n = 0; n < e.length; n += 1) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
1257
1337
  return `fnv1a:${(t >>> 0).toString(36)}`;
1258
1338
  }
1259
- function gt(e) {
1260
- return `${ct}${JSON.stringify(e)}`;
1339
+ function St(e) {
1340
+ return `${mt}${JSON.stringify(e)}`;
1261
1341
  }
1262
- function _t(e) {
1263
- if (!e.startsWith(ct)) return null;
1342
+ function Ct(e) {
1343
+ if (!e.startsWith(mt)) return null;
1264
1344
  try {
1265
1345
  let t = JSON.parse(e.slice(19));
1266
- return t.kind !== "aivex-shape-editor" || t.version !== lt || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(pt) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
1346
+ return t.kind !== "aivex-shape-editor" || t.version !== ht || !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;
1267
1347
  } catch {
1268
1348
  return null;
1269
1349
  }
1270
1350
  }
1271
- function vt(e) {
1272
- q = e;
1273
- let t = ++ft;
1351
+ function wt(e) {
1352
+ _t = e;
1353
+ let t = ++vt;
1274
1354
  if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
1275
- dt = "unavailable";
1355
+ Z = "unavailable";
1276
1356
  return;
1277
1357
  }
1278
1358
  let n;
1279
1359
  try {
1280
- n = gt(e);
1360
+ n = St(e);
1281
1361
  } catch {
1282
- dt = "unavailable";
1362
+ Z = "unavailable";
1283
1363
  return;
1284
1364
  }
1285
- dt = "pending", navigator.clipboard.writeText(n).then(() => {
1286
- t === ft && (dt = "written");
1365
+ Z = "pending", navigator.clipboard.writeText(n).then(() => {
1366
+ t === vt && (Z = "written");
1287
1367
  }, () => {
1288
- t === ft && (dt = "unavailable");
1368
+ t === vt && (Z = "unavailable");
1289
1369
  });
1290
1370
  }
1291
- function yt(e, t) {
1371
+ function Tt(e, t) {
1292
1372
  return !!e && e.scope === t;
1293
1373
  }
1294
- function Y(e) {
1295
- return yt(q, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
1374
+ function Et(e) {
1375
+ return Tt(_t, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
1296
1376
  }
1297
- async function bt(e) {
1298
- let t = yt(q, e) ? q : null;
1299
- if (t && dt !== "written") return t;
1377
+ async function Dt(e) {
1378
+ let t = Tt(_t, e) ? _t : null;
1379
+ if (t && Z !== "written") return t;
1300
1380
  if (typeof navigator < "u" && navigator.clipboard?.readText) try {
1301
- let t = _t(await navigator.clipboard.readText());
1302
- return t?.scope === e ? (q = t, t) : null;
1381
+ let t = Ct(await navigator.clipboard.readText());
1382
+ return t?.scope === e ? (_t = t, t) : null;
1303
1383
  } catch {}
1304
1384
  return t;
1305
1385
  }
1306
- function xt(e, t, n) {
1386
+ function Ot(e, t, n) {
1307
1387
  return {
1308
1388
  offset: n * (t ? e : e + 1),
1309
1389
  nextPasteCount: e + 1
@@ -1311,18 +1391,18 @@ function xt(e, t, n) {
1311
1391
  }
1312
1392
  //#endregion
1313
1393
  //#region src/components/ShapeEditor/_model/cursors.ts
1314
- var X = new Set([
1315
- G.RECTANGLE,
1316
- G.ROTATED_RECTANGLE,
1317
- G.CIRCLE,
1318
- G.POLYGON,
1319
- G.PATH,
1320
- G.BRUSH,
1321
- G.POINT,
1322
- G.ASSISTANT_POLYGON,
1323
- G.ASSISTANT_RECT,
1324
- G.ASSISTANT_POINT
1325
- ]), St = {
1394
+ var kt = new Set([
1395
+ J.RECTANGLE,
1396
+ J.ROTATED_RECTANGLE,
1397
+ J.CIRCLE,
1398
+ J.POLYGON,
1399
+ J.PATH,
1400
+ J.BRUSH,
1401
+ J.POINT,
1402
+ J.ASSISTANT_POLYGON,
1403
+ J.ASSISTANT_RECT,
1404
+ J.ASSISTANT_POINT
1405
+ ]), At = {
1326
1406
  tl: -135,
1327
1407
  t: -90,
1328
1408
  tr: -45,
@@ -1331,21 +1411,25 @@ var X = new Set([
1331
1411
  b: 90,
1332
1412
  bl: 135,
1333
1413
  l: 180
1334
- }, Ct = [
1414
+ }, jt = [
1335
1415
  "ew-resize",
1336
1416
  "nwse-resize",
1337
1417
  "ns-resize",
1338
1418
  "nesw-resize"
1339
- ];
1340
- function wt(e, t = 0) {
1341
- let n = ((St[e] + t * 180 / Math.PI) % 180 + 180) % 180;
1342
- return Ct[Math.round(n / 45) % 4];
1419
+ ], Mt = "grab-unselected", Nt = new Set([
1420
+ J.RECTANGLE,
1421
+ J.ROTATED_RECTANGLE,
1422
+ J.CIRCLE
1423
+ ]);
1424
+ function Pt(e, t = 0) {
1425
+ let n = ((At[e] + t * 180 / Math.PI) % 180 + 180) % 180;
1426
+ return jt[Math.round(n / 45) % 4];
1343
1427
  }
1344
- function Tt({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
1345
- return n ? "grab" : t || (e === G.SELECT ? "default" : X.has(e) ? r ? "default" : "crosshair" : "default");
1428
+ function Ft({ tool: e, externalToolCursor: t, isSpacePressed: n, isPolygonDrawing: r }) {
1429
+ return n ? "grab" : t || (e === J.SELECT ? "default" : kt.has(e) ? r ? "default" : "crosshair" : "default");
1346
1430
  }
1347
- function Et({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
1348
- return r === "marquee" ? "default" : r === "moving" || r === "panning" || r === "vertexDragging" ? "grabbing" : r === "resizing" || r === "rotating" ? i ?? "grabbing" : r === "drawing" ? "crosshair" : n ? "grab" : t || (e === G.SELECT && i ? i : Tt({
1431
+ function It({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
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 : Nt.has(e) && i && i !== "grab-unselected" ? i : Ft({
1349
1433
  tool: e,
1350
1434
  externalToolCursor: t,
1351
1435
  isSpacePressed: n,
@@ -1354,7 +1438,7 @@ function Et({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode
1354
1438
  }
1355
1439
  //#endregion
1356
1440
  //#region src/components/ShapeEditor/_model/overlays.ts
1357
- var Dt = (e) => Math.min(255, Math.max(0, e)), Ot = (e) => {
1441
+ var Lt = (e) => Math.min(255, Math.max(0, e)), Rt = (e) => {
1358
1442
  let t = e.replace("#", "").trim();
1359
1443
  if (![
1360
1444
  3,
@@ -1368,13 +1452,13 @@ var Dt = (e) => Math.min(255, Math.max(0, e)), Ot = (e) => {
1368
1452
  c(o),
1369
1453
  c(s)
1370
1454
  ];
1371
- return l.some((e) => Number.isNaN(e)) ? null : l.map(Dt);
1372
- }, kt = (e, t) => {
1455
+ return l.some((e) => Number.isNaN(e)) ? null : l.map(Lt);
1456
+ }, zt = (e, t) => {
1373
1457
  let { width: n, height: r, indices: i, transparent: a } = e;
1374
1458
  if (!n || !r || i.length < n * r) return null;
1375
1459
  let o = {};
1376
1460
  for (let [e, n] of Object.entries(t)) {
1377
- let t = Ot(n);
1461
+ let t = Rt(n);
1378
1462
  t && (o[Number(e)] = t);
1379
1463
  }
1380
1464
  if (!Object.keys(o).length) return null;
@@ -1393,12 +1477,12 @@ var Dt = (e) => Math.min(255, Math.max(0, e)), Ot = (e) => {
1393
1477
  }
1394
1478
  return c.putImageData(new ImageData(l, n, r), 0, 0), s;
1395
1479
  };
1396
- function At(e, t) {
1480
+ function $(e, t) {
1397
1481
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
1398
1482
  for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
1399
1483
  e.closePath();
1400
1484
  }
1401
- var jt = (e) => [
1485
+ var Bt = (e) => [
1402
1486
  {
1403
1487
  x: e.x,
1404
1488
  y: e.y
@@ -1416,7 +1500,7 @@ var jt = (e) => [
1416
1500
  y: e.y + e.h
1417
1501
  }
1418
1502
  ];
1419
- function Mt(e, t) {
1503
+ function Vt(e, t) {
1420
1504
  let n = !1;
1421
1505
  for (let r = 0, i = t.length - 1; r < t.length; i = r, r += 1) {
1422
1506
  let a = t[r], o = t[i];
@@ -1427,7 +1511,7 @@ function Mt(e, t) {
1427
1511
  }
1428
1512
  return n;
1429
1513
  }
1430
- function Nt(e, t, n) {
1514
+ function Ht(e, t, n) {
1431
1515
  let r = [], i = t.x - e.x, a = t.y - e.y;
1432
1516
  for (let t = 0; t < n.length; t += 1) {
1433
1517
  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;
@@ -1437,15 +1521,15 @@ function Nt(e, t, n) {
1437
1521
  }
1438
1522
  return r;
1439
1523
  }
1440
- function Pt(e, t, n) {
1524
+ function Ut(e, t, n) {
1441
1525
  let r = .001, i = [], a = (e, t, n) => ({
1442
1526
  x: e.x + (t.x - e.x) * n,
1443
1527
  y: e.y + (t.y - e.y) * n
1444
1528
  });
1445
1529
  for (let o of e) if (!(o.length < 2)) for (let e = 0; e < o.length; e += 1) {
1446
1530
  let s = o[e], c = o[(e + 1) % o.length], l = [0, 1];
1447
- for (let e of t) e !== o && l.push(...Nt(s, c, e));
1448
- if (n) for (let e of n) l.push(...Nt(s, c, e));
1531
+ for (let e of t) e !== o && l.push(...Ht(s, c, e));
1532
+ if (n) for (let e of n) l.push(...Ht(s, c, e));
1449
1533
  let u = Math.hypot(c.x - s.x, c.y - s.y);
1450
1534
  if (!u) continue;
1451
1535
  let d = -(c.y - s.y) / u * r, f = (c.x - s.x) / u * r;
@@ -1459,13 +1543,13 @@ function Pt(e, t, n) {
1459
1543
  }, h = {
1460
1544
  x: p.x - d,
1461
1545
  y: p.y - f
1462
- }, g = Mt(m, o) ? m : h, _ = g === m ? h : m;
1463
- t.some((e) => e !== o && Mt(_, e)) || n && !n.some((e) => Mt(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
1546
+ }, g = Vt(m, o) ? m : h, _ = g === m ? h : m;
1547
+ t.some((e) => e !== o && Vt(_, e)) || n && !n.some((e) => Vt(g, e)) || i.push([a(s, c, r), a(s, c, u)]);
1464
1548
  }
1465
1549
  }
1466
1550
  return i;
1467
1551
  }
1468
- function Ft(e) {
1552
+ function Wt(e) {
1469
1553
  let t = [...new Set(e.flatMap((e) => [e.x, e.x + e.w]))].sort((e, t) => e - t), n = [];
1470
1554
  for (let r = 0; r + 1 < t.length; r += 1) {
1471
1555
  let i = t[r], a = t[r + 1];
@@ -1486,38 +1570,38 @@ function Ft(e) {
1486
1570
  }
1487
1571
  return n;
1488
1572
  }
1489
- function It(e, t, n, r) {
1573
+ function Gt(e, t, n, r) {
1490
1574
  e.save(), e.globalAlpha *= t.dim.opacity, e.fillStyle = t.dim.color, e.beginPath(), e.rect(0, 0, n, r);
1491
1575
  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();
1492
1576
  if (e.fill(), t.zones.length) {
1493
1577
  e.beginPath();
1494
1578
  for (let n of t.rects) e.rect(n.x, n.y, n.w, n.h);
1495
1579
  e.clip();
1496
- for (let n of t.zones) At(e, n.points), e.fill();
1580
+ for (let n of t.zones) $(e, n.points), e.fill();
1497
1581
  }
1498
1582
  e.restore();
1499
1583
  }
1500
- function Lt(e) {
1584
+ function Kt(e) {
1501
1585
  let t = [];
1502
1586
  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]]);
1503
1587
  return t;
1504
1588
  }
1505
- var Rt = {
1589
+ var qt = {
1506
1590
  color: "#000000",
1507
1591
  opacity: .5
1508
- }, zt = {
1592
+ }, Jt = {
1509
1593
  color: "#ffffff",
1510
1594
  opacity: 1,
1511
1595
  width: 2,
1512
1596
  dash: [6, 6],
1513
1597
  underlayColor: "#000000"
1514
- }, Bt = {
1598
+ }, Yt = {
1515
1599
  color: "#dc2626",
1516
1600
  opacity: .8,
1517
1601
  width: 2,
1518
1602
  dash: [6, 6],
1519
1603
  underlayColor: "#000000"
1520
- }, Vt = (e, t, n) => {
1604
+ }, Xt = (e, t, n) => {
1521
1605
  let r = e.occludedAreas?.filter((e) => e.points.length >= 3) ?? [];
1522
1606
  if (!t || !n || !e.visibleAreas.length && !r.length) return null;
1523
1607
  let i = e.visibleAreas, a = i.length ? i : [{
@@ -1525,8 +1609,8 @@ var Rt = {
1525
1609
  y: 0,
1526
1610
  w: t,
1527
1611
  h: n
1528
- }], o = Ft(a), s = {
1529
- ...Rt,
1612
+ }], o = Wt(a), s = {
1613
+ ...qt,
1530
1614
  ...e.dim
1531
1615
  }, c = e.outline;
1532
1616
  if (c === !1) return {
@@ -1540,36 +1624,36 @@ var Rt = {
1540
1624
  };
1541
1625
  let l = {
1542
1626
  visible: {
1543
- ...zt,
1627
+ ...Jt,
1544
1628
  ...c?.visibleStyle
1545
1629
  },
1546
1630
  occluded: {
1547
- ...Bt,
1631
+ ...Yt,
1548
1632
  ...c?.occludedStyle
1549
1633
  }
1550
- }, u = i.map(jt), d = a.map(jt), f = r.map((e) => e.points);
1634
+ }, u = i.map(Bt), d = a.map(Bt), f = r.map((e) => e.points);
1551
1635
  return c?.mode === "separate" ? {
1552
1636
  rects: a,
1553
1637
  zones: r,
1554
1638
  dimHoles: o,
1555
1639
  dim: s,
1556
- visibleOutline: Lt(u),
1557
- occludedOutline: Lt(f),
1640
+ visibleOutline: Kt(u),
1641
+ occludedOutline: Kt(f),
1558
1642
  outlineStyles: l
1559
1643
  } : {
1560
1644
  rects: a,
1561
1645
  zones: r,
1562
1646
  dimHoles: o,
1563
1647
  dim: s,
1564
- visibleOutline: [...Pt(u, [...u, ...f], null), ...Pt(f, f, d)],
1648
+ visibleOutline: [...Ut(u, [...u, ...f], null), ...Ut(f, f, d)],
1565
1649
  occludedOutline: [],
1566
1650
  outlineStyles: l
1567
1651
  };
1568
- }, Z = .3, Ht = .05;
1569
- function Ut(e) {
1652
+ }, Zt = .3, Qt = .05;
1653
+ function $t(e) {
1570
1654
  return 1 - (1 - e) ** 3;
1571
1655
  }
1572
- function Wt(e) {
1656
+ function en(e) {
1573
1657
  return {
1574
1658
  x: e.minX,
1575
1659
  y: e.minY,
@@ -1577,7 +1661,7 @@ function Wt(e) {
1577
1661
  height: Math.max(0, e.maxY - e.minY)
1578
1662
  };
1579
1663
  }
1580
- function Gt(e, t) {
1664
+ function tn(e, t) {
1581
1665
  if (!t.length) return null;
1582
1666
  if (e === L.POINT) {
1583
1667
  let e = t[0];
@@ -1588,7 +1672,7 @@ function Gt(e, t) {
1588
1672
  height: 16
1589
1673
  };
1590
1674
  }
1591
- let n = V(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
1675
+ let n = H(t), r = Math.max(1, n.maxX - n.minX), i = Math.max(1, n.maxY - n.minY);
1592
1676
  return {
1593
1677
  x: n.minX,
1594
1678
  y: n.minY,
@@ -1596,10 +1680,10 @@ function Gt(e, t) {
1596
1680
  height: i
1597
1681
  };
1598
1682
  }
1599
- function Kt(e) {
1683
+ function nn(e) {
1600
1684
  if (!e.length) return null;
1601
- let t = e.map((e) => Gt(e.type, e.points)).filter((e) => e !== null);
1602
- return t.length ? Wt(V(t.flatMap((e) => [{
1685
+ let t = e.map((e) => tn(e.type, e.points)).filter((e) => e !== null);
1686
+ return t.length ? en(H(t.flatMap((e) => [{
1603
1687
  x: e.x,
1604
1688
  y: e.y
1605
1689
  }, {
@@ -1607,8 +1691,8 @@ function Kt(e) {
1607
1691
  y: e.y + e.height
1608
1692
  }]))) : null;
1609
1693
  }
1610
- function qt(e, t, n, r = {}) {
1611
- let { containerRatio: i = Z, minScale: a = Ht, maxScale: o = 20 } = r;
1694
+ function rn(e, t, n, r = {}) {
1695
+ let { containerRatio: i = Zt, minScale: a = Qt, maxScale: o = 20 } = r;
1612
1696
  if (!t || !n || e.width <= 0 || e.height <= 0) return null;
1613
1697
  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;
1614
1698
  return {
@@ -1617,18 +1701,18 @@ function qt(e, t, n, r = {}) {
1617
1701
  y: n / 2 - u * c
1618
1702
  };
1619
1703
  }
1620
- function Jt(e, t, n, r = 80) {
1704
+ function an(e, t, n, r = 80) {
1621
1705
  if (!t || !n) return null;
1622
- let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(Ht, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
1706
+ let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(Qt, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
1623
1707
  return {
1624
1708
  scale: o,
1625
1709
  x: t / 2 - s * o,
1626
1710
  y: n / 2 - c * o
1627
1711
  };
1628
1712
  }
1629
- function Yt(e, t, n, r = 300) {
1713
+ function on(e, t, n, r = 300) {
1630
1714
  let i = Date.now(), a = 0, o = () => {
1631
- let s = Date.now() - i, c = Math.min(s / r, 1), l = Ut(c);
1715
+ let s = Date.now() - i, c = Math.min(s / r, 1), l = $t(c);
1632
1716
  n({
1633
1717
  scale: e.scale + (t.scale - e.scale) * l,
1634
1718
  x: e.x + (t.x - e.x) * l,
@@ -1639,11 +1723,11 @@ function Yt(e, t, n, r = 300) {
1639
1723
  }
1640
1724
  //#endregion
1641
1725
  //#region src/components/ShapeEditor/_state/createInteractionController.ts
1642
- function Xt(e) {
1643
- let { engineRef: t, toolRef: n, externalToolMapRef: r, spaceRef: i, shiftRef: a, docRef: o, selRef: s, draftRef: c, readOnlyRef: l, disableMarqueeRef: u, lockedRef: d, onLockedInteraction: f, createRef: p, selectRef: m, enterEditRef: h, editingIdRef: g, drawSessionRef: _, assistantRef: v, setCursorHint: y, setInteractionMode: b, syncMinimap: x, onTransformPreview: S, onDrawPreview: C } = e, w = () => _.current, T = () => v.current, E = null, D = null, O = null, k = null, A = null, j = null, M = "", N = null, P = null, F = (e) => e === G.RECTANGLE || e === G.ROTATED_RECTANGLE || e === G.CIRCLE, ee = (e) => e === G.ASSISTANT_POLYGON || e === G.ASSISTANT_RECT, te = (e) => e === G.POLYGON, I = (e, t) => {
1726
+ function sn(e) {
1727
+ 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) => {
1644
1728
  let n = !1;
1645
- D && !F(t) && !ee(t) && (D = null, e.clearPreview(), C(null), n = !0), (O === "path" && t !== G.PATH || O === "scalar" && t !== G.BRUSH) && (O = null, n = !0), k && !te(t) && (k = null, n = !0), A && t !== G.SELECT && (A = null, j = null, e.clearMarquee(), n = !0), N && t !== G.POINT && (N = null, n = !0), n && b("idle");
1646
- }, ne = () => r.current.get(n.current), re = (e, t, n, r) => ({
1729
+ 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");
1730
+ }, V = () => r.current.get(n.current), ae = (e, t, n, r) => ({
1647
1731
  point: t,
1648
1732
  targetId: r,
1649
1733
  event: n,
@@ -1651,66 +1735,81 @@ function Xt(e) {
1651
1735
  viewport: e.viewport
1652
1736
  });
1653
1737
  return {
1654
- onCursorHint: y,
1655
- onInteractionModeChange: b,
1738
+ onCursorHint: b,
1739
+ onInteractionModeChange: x,
1656
1740
  onPointerDown: (e, r, u) => {
1657
- let p = t.current;
1658
- if (!p) return;
1659
- let _ = n.current;
1660
- if (N = null, I(p, _), u.button === 1 || i.current) {
1661
- b("panning"), y(null), E = {
1741
+ let m = t.current;
1742
+ if (!m) return;
1743
+ let v = n.current;
1744
+ if (F = null, ie(m, v), u.button === 1 || i.current) {
1745
+ x("panning"), b(null), D = {
1662
1746
  px: u.global.x,
1663
1747
  py: u.global.y
1664
1748
  };
1665
1749
  return;
1666
1750
  }
1667
- if (u.button === 2 && !(_ === G.ASSISTANT_POINT && u.altKey)) {
1751
+ if (u.button === 2 && !(v === J.ASSISTANT_POINT && u.altKey)) {
1668
1752
  if (r && !s.current.includes(r)) {
1669
1753
  let e = o.current.getShapes().find((e) => e.id === r);
1670
- e && R(e) && m.current([r]);
1754
+ e && R(e) && h.current([r]);
1671
1755
  }
1672
1756
  return;
1673
1757
  }
1674
- let v = ne();
1675
- if (v) {
1676
- w().reset(), m.current([]), v.onPointerDown?.(re(p, e, u, r));
1758
+ let y = V();
1759
+ if (y) {
1760
+ T().reset(), h.current([]), y.onPointerDown?.(ae(m, e, u, r));
1677
1761
  return;
1678
1762
  }
1679
1763
  if (d.current) {
1680
1764
  f();
1681
1765
  return;
1682
1766
  }
1683
- if (_ === G.ASSISTANT_POINT) {
1684
- u.altKey ? T().addPoint(e, u.button !== 2) : T().newPolygon(e);
1767
+ if (te(v) && r && s.current.includes(r) && !l.current) {
1768
+ let t = o.current.getShapes().find((e) => e.id === r);
1769
+ if (t && z(t)) {
1770
+ m.beginMove(e, s.current);
1771
+ return;
1772
+ }
1773
+ }
1774
+ if (re(v) && !c.current) {
1775
+ p();
1776
+ return;
1777
+ }
1778
+ if (v === J.ASSISTANT_POINT) {
1779
+ u.altKey ? E().addPoint(e, u.button !== 2) : E().newPolygon(e);
1780
+ return;
1781
+ }
1782
+ if (I(v) && c.current) {
1783
+ O = e, x("drawing");
1685
1784
  return;
1686
1785
  }
1687
- if (ee(_) && c.current) {
1688
- D = e, b("drawing");
1786
+ if (v === J.SELECT && _.current) {
1787
+ M = a.current ? m.getVertexSelection() : [], N = r === _.current, j = e, P = "", x("marquee"), b(null);
1689
1788
  return;
1690
1789
  }
1691
- if (_ === G.SELECT && u.altKey) {
1692
- let t = ae(o.current.getShapes()).filter((t) => {
1790
+ if (v === J.SELECT && u.altKey) {
1791
+ let t = B(o.current.getShapes()).filter((t) => {
1693
1792
  if (!R(t)) return !1;
1694
- let n = V(t.points);
1793
+ let n = H(t.points);
1695
1794
  return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
1696
1795
  });
1697
1796
  if (t.length) {
1698
1797
  let e = [...t].reverse(), n = [e[(e.findIndex((e) => s.current.includes(e.id)) + 1) % e.length].id];
1699
- m.current(n);
1798
+ h.current(n);
1700
1799
  return;
1701
1800
  }
1702
1801
  }
1703
- if (r && _ === G.SELECT) {
1802
+ if (r && v === J.SELECT) {
1704
1803
  let t = o.current.getShapes().find((e) => e.id === r);
1705
1804
  if (!t || !R(t)) return;
1706
- let n = typeof performance < "u" ? performance.now() : 0, i = !!P && P.id === r && n - P.t < 300;
1707
- P = {
1805
+ let n = typeof performance < "u" ? performance.now() : 0, i = !!ee && ee.id === r && n - ee.t < 300;
1806
+ ee = {
1708
1807
  id: r,
1709
1808
  t: n
1710
1809
  };
1711
1810
  let c = (t.type === L.POLYGON || t.type === L.LINE) && !l.current && t.interaction?.editable !== !1 && !t.readOnly;
1712
1811
  if (i && c) {
1713
- m.current([r]), h.current(r);
1812
+ h.current([r]), g.current(r);
1714
1813
  return;
1715
1814
  }
1716
1815
  let u = s.current;
@@ -1718,176 +1817,180 @@ function Xt(e) {
1718
1817
  let e = new Set(u);
1719
1818
  e.has(r) ? e.delete(r) : e.add(r), u = [...e];
1720
1819
  } else u.includes(r) || (u = [r]);
1721
- m.current(u), !l.current && z(t) && p.beginMove(e, u);
1820
+ h.current(u), !l.current && z(t) && m.beginMove(e, u);
1722
1821
  return;
1723
1822
  }
1724
- if (F(_) && c.current) {
1725
- D = e, b("drawing");
1823
+ if (te(v) && c.current) {
1824
+ O = e, x("drawing");
1726
1825
  return;
1727
1826
  }
1728
- if (te(_) && c.current) {
1729
- if (!w().getDraftPointsSnapshot().length && s.current.length && m.current([]), w().tryClosePolygon(e, 12 / p.viewport.scale)) return;
1730
- let t = w().hitDraftPoint(e);
1827
+ if (ne(v) && c.current) {
1828
+ if (!T().getDraftPointsSnapshot().length && s.current.length && h.current([]), T().tryClosePolygon(e, 12 / m.viewport.scale)) return;
1829
+ let t = T().hitDraftPoint(e);
1731
1830
  if (t >= 0) {
1732
1831
  if (u.altKey) {
1733
- w().removeDraftPoint(t);
1832
+ T().removeDraftPoint(t);
1734
1833
  return;
1735
1834
  }
1736
- let n = w().selectDraftPointForDrag(t, u.shiftKey || u.ctrlKey || u.metaKey);
1835
+ let n = T().selectDraftPointForDrag(t, u.shiftKey || u.ctrlKey || u.metaKey);
1737
1836
  if (!n) return;
1738
- k = {
1837
+ A = {
1739
1838
  start: e,
1740
1839
  base: n.base,
1741
1840
  indices: n.indices,
1742
1841
  moved: !1
1743
- }, b("vertexDragging");
1842
+ }, x("vertexDragging");
1744
1843
  return;
1745
1844
  }
1746
- w().appendPolygonPoint(e);
1845
+ T().appendPolygonPoint(e);
1747
1846
  return;
1748
1847
  }
1749
- if (_ === G.PATH && c.current) {
1750
- s.current.length && m.current([]), O = "path", b("drawing"), w().beginStroke(e);
1848
+ if (v === J.PATH && c.current) {
1849
+ s.current.length && h.current([]), k = "path", x("drawing"), T().beginStroke(e);
1751
1850
  return;
1752
1851
  }
1753
- if (_ === G.BRUSH && c.current && !l.current) {
1754
- O = "scalar", b("drawing"), w().beginStroke(e);
1852
+ if (v === J.BRUSH && c.current && !l.current) {
1853
+ k = "scalar", x("drawing"), T().beginStroke(e);
1755
1854
  return;
1756
1855
  }
1757
- if (_ === G.POINT && c.current && u.button === 0) {
1758
- N = {
1856
+ if (v === J.POINT && c.current && u.button === 0) {
1857
+ F = {
1759
1858
  pointerId: u.pointerId,
1760
1859
  global: u.global,
1761
1860
  cancelled: !1
1762
1861
  };
1763
1862
  return;
1764
1863
  }
1765
- if (_ === G.SELECT) {
1766
- if (j = g.current ? a.current ? p.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
1864
+ if (v === J.SELECT) {
1865
+ if (M = null, N = !1, !a.current && !l.current && s.current.length >= 2) {
1767
1866
  let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && z(e));
1768
1867
  if (t.length) {
1769
- let n = V(t.flatMap((e) => e.points));
1868
+ let n = H(t.flatMap((e) => e.points));
1770
1869
  if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
1771
- p.beginMove(e, s.current);
1870
+ m.beginMove(e, s.current);
1772
1871
  return;
1773
1872
  }
1774
1873
  }
1775
1874
  }
1776
- A = e, M = "", b("marquee"), y(null);
1875
+ j = e, P = "", x("marquee"), b(null);
1777
1876
  }
1778
1877
  },
1779
1878
  onPointerMove: (e, r) => {
1780
1879
  let i = t.current;
1781
1880
  if (!i) return;
1782
- if (N && N.pointerId === r.pointerId && Math.hypot(r.global.x - N.global.x, r.global.y - N.global.y) > 4 && (N.cancelled = !0), E) {
1881
+ if (F && F.pointerId === r.pointerId && Math.hypot(r.global.x - F.global.x, r.global.y - F.global.y) > 4 && (F.cancelled = !0), D) {
1783
1882
  i.applyViewport({
1784
1883
  scale: i.viewport.scale,
1785
- x: i.viewport.x + (r.global.x - E.px),
1786
- y: i.viewport.y + (r.global.y - E.py)
1787
- }), E.px = r.global.x, E.py = r.global.y;
1884
+ x: i.viewport.x + (r.global.x - D.px),
1885
+ y: i.viewport.y + (r.global.y - D.py)
1886
+ }), D.px = r.global.x, D.py = r.global.y;
1788
1887
  return;
1789
1888
  }
1790
1889
  let s = n.current;
1791
- I(i, s);
1792
- let l = ne();
1890
+ ie(i, s);
1891
+ let l = V();
1793
1892
  if (l) {
1794
- l.onPointerMove?.(re(i, e, r));
1893
+ l.onPointerMove?.(ae(i, e, r));
1795
1894
  return;
1796
1895
  }
1797
- if (k) {
1798
- let t = e.x - k.start.x, n = e.y - k.start.y;
1799
- k.moved = k.moved || Math.hypot(t, n) > .5, w().moveDraftPoints(k.base, k.indices, t, n);
1896
+ if (A) {
1897
+ let t = e.x - A.start.x, n = e.y - A.start.y;
1898
+ A.moved = A.moved || Math.hypot(t, n) > .5, T().moveDraftPoints(A.base, A.indices, t, n);
1800
1899
  return;
1801
1900
  }
1802
- if (D && (F(s) || ee(s))) {
1803
- let t = a.current ? ce(D, e) : e;
1804
- i.previewBox(s === G.CIRCLE ? "ellipse" : "rect", D, t, {
1901
+ if (O && (te(s) || I(s))) {
1902
+ let t = a.current ? ce(O, e) : e;
1903
+ i.previewBox(s === J.CIRCLE ? "ellipse" : "rect", O, t, {
1805
1904
  ...c.current,
1806
1905
  color: c.current?.color ?? "#00e5ff"
1807
- }), F(s) && C({
1808
- type: s === G.CIRCLE ? L.ELLIPSE : L.RECTANGLE,
1809
- points: [D, t]
1906
+ }), te(s) && w({
1907
+ type: s === J.CIRCLE ? L.ELLIPSE : L.RECTANGLE,
1908
+ points: [O, t]
1810
1909
  });
1811
1910
  return;
1812
1911
  }
1813
- if (O) {
1814
- w().appendStrokePoint(e, 2 / i.viewport.scale);
1912
+ if (k) {
1913
+ T().appendStrokePoint(e, 2 / i.viewport.scale);
1815
1914
  return;
1816
1915
  }
1817
- if (te(s) && w().hasDraftPoints()) {
1818
- w().setDraftCursor(e);
1916
+ if (ne(s) && T().hasDraftPoints()) {
1917
+ T().setDraftCursor(e);
1819
1918
  return;
1820
1919
  }
1821
- if (A) {
1920
+ if (j) {
1822
1921
  if (u?.current) return;
1823
1922
  let t = {
1824
- minX: Math.min(A.x, e.x),
1825
- minY: Math.min(A.y, e.y),
1826
- maxX: Math.max(A.x, e.x),
1827
- maxY: Math.max(A.y, e.y)
1923
+ minX: Math.min(j.x, e.x),
1924
+ minY: Math.min(j.y, e.y),
1925
+ maxX: Math.max(j.x, e.x),
1926
+ maxY: Math.max(j.y, e.y)
1828
1927
  };
1829
- if (i.previewMarquee(A, e), j) {
1830
- let e = (o.current.getShapes().find((e) => e.id === g.current)?.points ?? []).flatMap((e, n) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY ? [n] : []), n = [...new Set([...j, ...e])].sort((e, t) => e - t), r = n.join(",");
1831
- r !== M && (M = r, i.setVertexSelection(n));
1928
+ if (i.previewMarquee(j, e), M) {
1929
+ let e = (o.current.getShapes().find((e) => e.id === _.current)?.points ?? []).flatMap((e, n) => e.x >= t.minX && e.x <= t.maxX && e.y >= t.minY && e.y <= t.maxY ? [n] : []), n = [...new Set([...M, ...e])].sort((e, t) => e - t), r = n.join(",");
1930
+ r !== P && (P = r, i.setVertexSelection(n));
1832
1931
  return;
1833
1932
  }
1834
1933
  let n = i.shapesIntersecting(t), r = n.join(",");
1835
- r !== M && (M = r, m.current(n));
1934
+ r !== P && (P = r, h.current(n));
1836
1935
  }
1837
1936
  },
1838
1937
  onPointerUp: (e, r) => {
1839
1938
  let i = t.current;
1840
1939
  if (!i) return;
1841
- let o = N;
1842
- if (N = null, E) {
1843
- E = null, b("idle");
1940
+ let o = F;
1941
+ if (F = null, D) {
1942
+ D = null, x("idle");
1844
1943
  return;
1845
1944
  }
1846
1945
  let l = n.current;
1847
- if (I(i, l), k) {
1848
- w().commitDraftPointDrag(k.moved), k = null, b("idle");
1946
+ if (ie(i, l), A) {
1947
+ T().commitDraftPointDrag(A.moved), A = null, x("idle");
1849
1948
  return;
1850
1949
  }
1851
- let u = ne();
1950
+ let u = V();
1852
1951
  if (u) {
1853
- u.onPointerUp?.(re(i, e, r));
1952
+ u.onPointerUp?.(ae(i, e, r));
1854
1953
  return;
1855
1954
  }
1856
1955
  let d = o ? Math.hypot(r.global.x - o.global.x, r.global.y - o.global.y) : Infinity;
1857
- if (l === G.POINT && c.current && o && !o.cancelled && o.pointerId === r.pointerId && r.insideCanvas && d <= 4) {
1858
- p.current(L.POINT, [e]);
1956
+ if (l === J.POINT && c.current && o && !o.cancelled && o.pointerId === r.pointerId && r.insideCanvas && d <= 4) {
1957
+ m.current(L.POINT, [e]);
1859
1958
  return;
1860
1959
  }
1861
- if (O) {
1862
- let e = O;
1863
- O = null, b("idle"), e === "path" ? w().completeFreehandStroke() : w().finishScalarStroke();
1960
+ if (k) {
1961
+ let e = k;
1962
+ k = null, x("idle"), e === "path" ? T().completeFreehandStroke() : T().finishScalarStroke();
1864
1963
  return;
1865
1964
  }
1866
- if (D && ee(l)) {
1867
- let t = D;
1868
- D = null, b("idle"), i.clearPreview();
1965
+ if (O && I(l)) {
1966
+ let t = O;
1967
+ O = null, x("idle"), i.clearPreview();
1869
1968
  let n = {
1870
1969
  x: Math.min(t.x, e.x),
1871
1970
  y: Math.min(t.y, e.y),
1872
1971
  width: Math.abs(e.x - t.x),
1873
1972
  height: Math.abs(e.y - t.y)
1874
1973
  };
1875
- n.width > 2 && n.height > 2 && T().beginBox(n, l === G.ASSISTANT_RECT ? "rect" : "polygon");
1974
+ n.width > 2 && n.height > 2 && E().beginBox(n, l === J.ASSISTANT_RECT ? "rect" : "polygon");
1876
1975
  return;
1877
1976
  }
1878
- if (D && F(l)) {
1879
- let t = a.current ? ce(D, e) : e, n = D;
1880
- D = null, b("idle"), i.clearPreview(), C(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (l === G.ROTATED_RECTANGLE ? p.current(L.ROTATED_RECTANGLE, ue([n, t])) : l === G.CIRCLE ? p.current(L.POLYGON, de(n, t)) : p.current(L.RECTANGLE, [n, t]));
1977
+ if (O && te(l)) {
1978
+ let t = a.current ? ce(O, e) : e, n = O;
1979
+ O = null, x("idle"), i.clearPreview(), w(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (l === J.ROTATED_RECTANGLE ? m.current(L.ROTATED_RECTANGLE, ue([n, t])) : l === J.CIRCLE ? m.current(L.POLYGON, de(n, t)) : m.current(L.RECTANGLE, [n, t]));
1881
1980
  return;
1882
1981
  }
1883
- if (A) {
1884
- let t = Math.abs(e.x - A.x) > 3 || Math.abs(e.y - A.y) > 3, n = j !== null;
1885
- if (A = null, j = null, i.clearMarquee(), b("idle"), n && t) return;
1886
- !t && s.current.length && m.current([]);
1982
+ if (j) {
1983
+ let t = Math.abs(e.x - j.x) > 3 || Math.abs(e.y - j.y) > 3, n = M !== null, r = N;
1984
+ if (j = null, M = null, N = !1, i.clearMarquee(), x("idle"), n && t) return;
1985
+ if (n && r) {
1986
+ i.setVertexSelection([]);
1987
+ return;
1988
+ }
1989
+ !t && s.current.length && h.current([]);
1887
1990
  }
1888
1991
  },
1889
- onViewportChange: x,
1890
- onTransformPreview: S,
1992
+ onViewportChange: S,
1993
+ onTransformPreview: C,
1891
1994
  onTransformCommit: (e) => {
1892
1995
  let t = o.current.getShapes(), n = e.map((e) => {
1893
1996
  let n = t.find((t) => t.id === e.id);
@@ -1902,7 +2005,7 @@ function Xt(e) {
1902
2005
  }
1903
2006
  //#endregion
1904
2007
  //#region src/components/ShapeEditor/_state/useAssistant.ts
1905
- function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
2008
+ function cn({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistantRef: i }) {
1906
2009
  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) => {
1907
2010
  d.current = e(d.current), u(d.current);
1908
2011
  }, []), b = x((e) => {
@@ -1911,16 +2014,16 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
1911
2014
  let a = i.current?.rectResult === "rotatedRect";
1912
2015
  return e.map((e) => {
1913
2016
  if (t === "rect" && a) return {
1914
- id: oe(),
2017
+ id: ae(),
1915
2018
  type: L.ROTATED_RECTANGLE,
1916
2019
  points: pe(e),
1917
2020
  style: r,
1918
2021
  meta: n
1919
2022
  };
1920
2023
  if (t === "rect") {
1921
- let t = V(e);
2024
+ let t = H(e);
1922
2025
  return {
1923
- id: oe(),
2026
+ id: ae(),
1924
2027
  type: L.RECTANGLE,
1925
2028
  points: [{
1926
2029
  x: t.minX,
@@ -1934,7 +2037,7 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
1934
2037
  };
1935
2038
  }
1936
2039
  return {
1937
- id: oe(),
2040
+ id: ae(),
1938
2041
  type: L.POLYGON,
1939
2042
  points: e,
1940
2043
  style: r,
@@ -2067,17 +2170,17 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
2067
2170
  }
2068
2171
  //#endregion
2069
2172
  //#region src/components/ShapeEditor/_model/brush.ts
2070
- function Qt(e, t, n) {
2173
+ function ln(e, t, n) {
2071
2174
  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);
2072
2175
  return i === 0 ? 0 : r * 2 / i;
2073
2176
  }
2074
- function $t(e, t = 1.5) {
2177
+ function un(e, t = 1.5) {
2075
2178
  if (e.length <= 2) return e;
2076
2179
  let n = (e, t) => {
2077
2180
  if (e.length < 3) return e;
2078
2181
  let r = 0, i = 0, a = e.length - 1;
2079
2182
  for (let t = 1; t < a; t++) {
2080
- let n = Qt(e[t], e[0], e[a]);
2183
+ let n = ln(e[t], e[0], e[a]);
2081
2184
  n > r && (i = t, r = n);
2082
2185
  }
2083
2186
  if (r > t) {
@@ -2090,8 +2193,8 @@ function $t(e, t = 1.5) {
2090
2193
  }
2091
2194
  //#endregion
2092
2195
  //#region src/components/ShapeEditor/_model/scalarMask.ts
2093
- var en = 4096, tn = 4;
2094
- function nn(e) {
2196
+ var dn = 4096, fn = 4;
2197
+ function pn(e) {
2095
2198
  let t = 0;
2096
2199
  for (let n = 0; n < e.length; n++) {
2097
2200
  let r = e[n], i = e[(n + 1) % e.length];
@@ -2099,17 +2202,17 @@ function nn(e) {
2099
2202
  }
2100
2203
  return Math.abs(t / 2);
2101
2204
  }
2102
- function rn(e, t, n) {
2205
+ function mn(e, t, n) {
2103
2206
  let r = new Uint8Array(t * n);
2104
2207
  for (let i = 0; i < t * n; i++) r[i] = e[i * 4 + 3] > 128 ? 255 : 0;
2105
2208
  return r;
2106
2209
  }
2107
- function an(e) {
2210
+ function hn(e) {
2108
2211
  let t = new Uint8ClampedArray(e.length * 4);
2109
2212
  for (let n = 0; n < e.length; n++) e[n] > 128 && (t[n * 4 + 3] = 255);
2110
2213
  return t;
2111
2214
  }
2112
- function on(e, t, n, r, i) {
2215
+ function gn(e, t, n, r, i) {
2113
2216
  let a = new Uint8Array(t * n), o = [[r, i]];
2114
2217
  for (; o.length;) {
2115
2218
  let [r, i] = o.pop(), s = i * t + r;
@@ -2117,8 +2220,8 @@ function on(e, t, n, r, i) {
2117
2220
  }
2118
2221
  return a;
2119
2222
  }
2120
- function sn(e, t, n) {
2121
- let r = rn(e, t, n), i = [];
2223
+ function _n(e, t, n) {
2224
+ let r = mn(e, t, n), i = [];
2122
2225
  for (;;) {
2123
2226
  let e = -1, a = -1;
2124
2227
  outer: for (let i = 0; i < n; i++) for (let n = 0; n < t; n++) if (r[i * t + n] > 128) {
@@ -2126,17 +2229,17 @@ function sn(e, t, n) {
2126
2229
  break outer;
2127
2230
  }
2128
2231
  if (e < 0) break;
2129
- let o = ln(an(on(r, t, n, e, a)), t, n);
2232
+ let o = yn(hn(gn(r, t, n, e, a)), t, n);
2130
2233
  o.length >= 3 && i.push(o);
2131
2234
  }
2132
2235
  return i;
2133
2236
  }
2134
- function cn(e, t, n, r, i) {
2237
+ function vn(e, t, n, r, i) {
2135
2238
  return r < 0 || i < 0 || r >= t || i >= n ? !1 : e[(i * t + r) * 4 + 3] > 128;
2136
2239
  }
2137
- function ln(e, t, n) {
2240
+ function yn(e, t, n) {
2138
2241
  let r = -1, i = -1;
2139
- outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (cn(e, t, n, o, a)) {
2242
+ outer: for (let a = 0; a < n; a++) for (let o = 0; o < t; o++) if (vn(e, t, n, o, a)) {
2140
2243
  r = o, i = a;
2141
2244
  break outer;
2142
2245
  }
@@ -2171,7 +2274,7 @@ function ln(e, t, n) {
2171
2274
  let r = !1;
2172
2275
  for (let i = 0; i < 8; i++) {
2173
2276
  let s = (u + i) % 8, d = c + a[s], f = l + o[s];
2174
- if (cn(e, t, n, d, f)) {
2277
+ if (vn(e, t, n, d, f)) {
2175
2278
  c = d, l = f, u = (s + 6) % 8, r = !0;
2176
2279
  break;
2177
2280
  }
@@ -2180,13 +2283,13 @@ function ln(e, t, n) {
2180
2283
  } while (c !== d.x || l !== d.y || s.length === 1);
2181
2284
  return s;
2182
2285
  }
2183
- function un(e, t) {
2286
+ function bn(e, t) {
2184
2287
  let n = [];
2185
2288
  for (let t of e) for (let e of t.points) n.push(e);
2186
2289
  for (let e of t) for (let t of e) n.push(t);
2187
2290
  return n;
2188
2291
  }
2189
- function dn(e) {
2292
+ function xn(e) {
2190
2293
  switch (e.type) {
2191
2294
  case L.RECTANGLE: return e.points.length < 2 ? null : ue(e.points);
2192
2295
  case L.POLYGON:
@@ -2205,14 +2308,14 @@ function dn(e) {
2205
2308
  default: return null;
2206
2309
  }
2207
2310
  }
2208
- function fn(e) {
2209
- return e.map(dn).filter((e) => !!e && e.length >= 3);
2311
+ function Sn(e) {
2312
+ return e.map(xn).filter((e) => !!e && e.length >= 3);
2210
2313
  }
2211
- function pn(e, t, n = []) {
2314
+ function Cn(e, t, n = []) {
2212
2315
  if (t <= 0 || !e.length && !n.length) return null;
2213
- let r = un(e, n);
2316
+ let r = bn(e, n);
2214
2317
  if (!r.length) return null;
2215
- let i = t + 4, a = V(r), o = Math.ceil(a.maxX - a.minX + i * 2), s = Math.ceil(a.maxY - a.minY + i * 2), c = Math.min(1, en / Math.max(o, s, 1));
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, dn / Math.max(o, s, 1));
2216
2319
  o = Math.max(1, Math.ceil(o * c)), s = Math.max(1, Math.ceil(s * c));
2217
2320
  let l = a.minX - i, u = a.minY - i, d = (e) => ({
2218
2321
  x: (e.x - l) * c,
@@ -2251,20 +2354,20 @@ function pn(e, t, n = []) {
2251
2354
  scale: c
2252
2355
  };
2253
2356
  }
2254
- function mn(e, t = 1.5) {
2255
- let { canvas: n, ox: r, oy: i, scale: a } = e, o = sn(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
2357
+ function wn(e, t = 1.5) {
2358
+ let { canvas: n, ox: r, oy: i, scale: a } = e, o = _n(n.getContext("2d").getImageData(0, 0, n.width, n.height).data, n.width, n.height);
2256
2359
  if (!o.length) return [];
2257
2360
  let s = (e) => ({
2258
2361
  x: e.x / a + r,
2259
2362
  y: e.y / a + i
2260
2363
  }), c = [];
2261
2364
  for (let e of o) {
2262
- let n = e.map(s), r = $t(n, t), i = r.length >= 3 ? r : n;
2263
- i.length >= 3 && nn(i) >= tn && c.push(i);
2365
+ let n = e.map(s), r = un(n, t), i = r.length >= 3 ? r : n;
2366
+ i.length >= 3 && pn(i) >= fn && c.push(i);
2264
2367
  }
2265
2368
  return c;
2266
2369
  }
2267
- function hn(e, t) {
2370
+ function Tn(e, t) {
2268
2371
  let { canvas: n } = e, r = document.createElement("canvas");
2269
2372
  r.width = n.width, r.height = n.height;
2270
2373
  let i = r.getContext("2d");
@@ -2272,30 +2375,30 @@ function hn(e, t) {
2272
2375
  }
2273
2376
  //#endregion
2274
2377
  //#region src/components/ShapeEditor/_state/drawSessionState.ts
2275
- function gn(e) {
2378
+ function En(e) {
2276
2379
  return e.map((e) => ({
2277
2380
  mode: e.mode,
2278
2381
  points: e.points.map((e) => ({ ...e }))
2279
2382
  }));
2280
2383
  }
2281
- function _n(e, t) {
2384
+ function Dn(e, t) {
2282
2385
  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));
2283
2386
  }
2284
- function vn(e) {
2387
+ function On(e) {
2285
2388
  return e.map((e) => ({ ...e }));
2286
2389
  }
2287
- function yn(e, t) {
2390
+ function kn(e, t) {
2288
2391
  return e.length === t.length && e.every((e, n) => e.x === t[n].x && e.y === t[n].y);
2289
2392
  }
2290
2393
  //#endregion
2291
2394
  //#region src/components/ShapeEditor/_state/useDrawSession.ts
2292
- var bn = 10;
2293
- function xn(e, t) {
2395
+ var An = 10;
2396
+ function jn(e, t) {
2294
2397
  if (e.active !== t.active || e.kind !== t.kind || e.canUndo !== t.canUndo || e.canRedo !== t.canRedo) return !1;
2295
2398
  let n = e.brush, r = t.brush;
2296
2399
  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]);
2297
2400
  }
2298
- function Sn({ 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 }) {
2401
+ function Mn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, brushSizeRef: a, simplifyEpsilonRef: o, draftMeta: s, engineRef: c, onDrawSessionChange: l, onDraftShapeChange: u, changeSelection: d, createShape: f }) {
2299
2402
  let p = O(l);
2300
2403
  p.current = l;
2301
2404
  let m = O(u);
@@ -2304,15 +2407,15 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2304
2407
  h.current = s;
2305
2408
  let g = O(f);
2306
2409
  g.current = f;
2307
- let _ = O(null), v = O([]), y = O(null), b = O(/* @__PURE__ */ new Set()), S = O([[]]), C = O(0), w = O(null), T = O([]), E = O([]), D = O([]), k = O([[]]), A = O(0), j = O("draw"), M = () => j.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === G.BRUSH && v.current.length > 0, P = () => {
2410
+ let _ = O(null), v = O([]), y = O(null), b = O(/* @__PURE__ */ new Set()), S = O([[]]), C = O(0), w = O(null), T = O([]), E = O([]), D = O([]), k = O([[]]), A = O(0), j = O("draw"), M = () => j.current === "erase" ? "erase" : "add", N = () => D.current.length > 0 || T.current.length > 0 || e.current === J.BRUSH && v.current.length > 0, P = () => {
2308
2411
  let t = e.current;
2309
- return t === G.BRUSH && N() ? "brush" : t === G.POLYGON && v.current.length > 0 ? "polygon" : t === G.PATH && v.current.length > 0 ? "path" : "none";
2412
+ return t === J.BRUSH && N() ? "brush" : t === J.POLYGON && v.current.length > 0 ? "polygon" : t === J.PATH && v.current.length > 0 ? "path" : "none";
2310
2413
  }, F = () => v.current.length > 0 || A.current > 0, ee = () => v.current.length === 0 && A.current < k.current.length - 1, te = () => C.current > 0, I = () => C.current < S.current.length - 1, ne = () => {
2311
2414
  let t = e.current;
2312
- return t === G.BRUSH ? F() : t === G.POLYGON || t === G.PATH ? te() : !1;
2415
+ return t === J.BRUSH ? F() : t === J.POLYGON || t === J.PATH ? te() : !1;
2313
2416
  }, re = () => {
2314
2417
  let t = e.current;
2315
- return t === G.BRUSH ? ee() : t === G.POLYGON || t === G.PATH ? I() : !1;
2418
+ return t === J.BRUSH ? ee() : t === J.POLYGON || t === J.PATH ? I() : !1;
2316
2419
  }, R = () => P() !== "none", z = x(() => {
2317
2420
  let e = P(), t = {
2318
2421
  active: e !== "none",
@@ -2325,14 +2428,14 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2325
2428
  editTargetIds: [...D.current]
2326
2429
  } : void 0
2327
2430
  }, n = _.current;
2328
- n && xn(n, t) || (_.current = t, p.current?.(t));
2329
- }, []), ae = x(() => {
2330
- k.current = [[]], A.current = 0;
2431
+ n && jn(n, t) || (_.current = t, p.current?.(t));
2331
2432
  }, []), B = x(() => {
2433
+ k.current = [[]], A.current = 0;
2434
+ }, []), V = x(() => {
2332
2435
  let t = c.current;
2333
2436
  if (!t) return;
2334
2437
  let n = e.current;
2335
- if (n === G.BRUSH) {
2438
+ if (n === J.BRUSH) {
2336
2439
  let e = [...T.current];
2337
2440
  if (v.current.length && e.push({
2338
2441
  points: v.current,
@@ -2341,7 +2444,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2341
2444
  t.clearPreview();
2342
2445
  return;
2343
2446
  }
2344
- let n = pn(e, a.current, E.current);
2447
+ let n = Cn(e, a.current, E.current);
2345
2448
  if (!n) {
2346
2449
  t.clearPreview();
2347
2450
  return;
@@ -2358,12 +2461,12 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2358
2461
  let o = {
2359
2462
  ...i.current,
2360
2463
  color: i.current?.color ?? "#00e5ff"
2361
- }, s = Array.from(b.current), l = n !== G.PATH;
2362
- if (t.previewPoly(r, y.current, o, !1, s, l), n === G.POLYGON || n === G.PATH) {
2464
+ }, s = Array.from(b.current), l = n !== J.PATH;
2465
+ if (t.previewPoly(r, y.current, o, !1, s, l), n === J.POLYGON || n === J.PATH) {
2363
2466
  let e = m.current;
2364
2467
  e && r !== w.current && (w.current = r, e({
2365
2468
  type: L.POLYGON,
2366
- points: vn(r),
2469
+ points: On(r),
2367
2470
  meta: h.current
2368
2471
  }));
2369
2472
  }
@@ -2372,97 +2475,97 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2372
2475
  i,
2373
2476
  c,
2374
2477
  e
2375
- ]), V = x((e) => {
2376
- let t = gn(e), n = k.current, r = A.current, i = n[r];
2377
- i && _n(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, z());
2378
- }, [z]), se = x((e) => {
2478
+ ]), oe = x((e) => {
2479
+ let t = En(e), n = k.current, r = A.current, i = n[r];
2480
+ i && Dn(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, z());
2481
+ }, [z]), H = x((e) => {
2379
2482
  let t = S.current, n = C.current, r = t[n];
2380
- r && yn(r, e) || (S.current = [...t.slice(0, n + 1), vn(e)], C.current += 1);
2381
- }, []), H = x(() => {
2382
- v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null, ae(), c.current?.clearPreview(), m.current?.(null), z();
2483
+ r && kn(r, e) || (S.current = [...t.slice(0, n + 1), On(e)], C.current += 1);
2484
+ }, []), U = x(() => {
2485
+ 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();
2383
2486
  }, [
2384
2487
  c,
2385
2488
  z,
2386
- ae
2387
- ]), ce = x((e, t) => {
2388
- v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && se(e), B(), z();
2489
+ B
2490
+ ]), se = x((e, t) => {
2491
+ v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && H(e), V(), z();
2389
2492
  }, [
2390
2493
  z,
2391
- se,
2392
- B
2393
- ]), le = x(() => vn(v.current), []), ue = x(() => v.current.length > 0, []), de = x((t, n) => {
2394
- if (e.current !== G.POLYGON) return !1;
2494
+ H,
2495
+ V
2496
+ ]), ce = x(() => On(v.current), []), le = x(() => v.current.length > 0, []), ue = x((t, n) => {
2497
+ if (e.current !== J.POLYGON) return !1;
2395
2498
  let r = v.current;
2396
2499
  if (r.length < 3) return !1;
2397
2500
  let i = r[0];
2398
- return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(L.POLYGON, r), H(), !0);
2399
- }, [H, e]), fe = x((e) => {
2501
+ return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(L.POLYGON, r), U(), !0);
2502
+ }, [U, e]), de = x((e) => {
2400
2503
  let t = v.current;
2401
- return e < 0 || e >= t.length ? !1 : (ce(t.filter((t, n) => n !== e), !0), !0);
2402
- }, [ce]), pe = x((e, t) => {
2504
+ return e < 0 || e >= t.length ? !1 : (se(t.filter((t, n) => n !== e), !0), !0);
2505
+ }, [se]), fe = x((e, t) => {
2403
2506
  let n = v.current;
2404
2507
  if (e < 0 || e >= n.length) return null;
2405
2508
  let r = new Set(b.current);
2406
- 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, B(), z(), {
2407
- base: vn(n),
2509
+ 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: On(n),
2408
2511
  indices: Array.from(r)
2409
2512
  };
2410
- }, [z, B]), me = x((e) => {
2411
- b.current = /* @__PURE__ */ new Set(), y.current = e, ce([...v.current, e], !0);
2412
- }, [ce]), he = x((e) => {
2413
- y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], B(), z();
2414
- }, [z, B]), ge = x((e, t) => {
2513
+ }, [z, V]), pe = x((e) => {
2514
+ b.current = /* @__PURE__ */ new Set(), y.current = e, se([...v.current, e], !0);
2515
+ }, [se]), me = x((e) => {
2516
+ y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], V(), z();
2517
+ }, [z, V]), he = x((e, t) => {
2415
2518
  let n = v.current[v.current.length - 1];
2416
- return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, B(), z(), !0);
2417
- }, [z, B]), _e = x((e, t, n, r) => {
2519
+ return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, V(), z(), !0);
2520
+ }, [z, V]), ge = x((e, t, n, r) => {
2418
2521
  let i = new Set(t);
2419
2522
  v.current = e.map((e, t) => i.has(t) ? {
2420
2523
  x: e.x + n,
2421
2524
  y: e.y + r
2422
- } : { ...e }), y.current = null, B(), z();
2423
- }, [z, B]), ve = x((e) => {
2424
- e && (se(v.current), B(), z());
2525
+ } : { ...e }), y.current = null, V(), z();
2526
+ }, [z, V]), _e = x((e) => {
2527
+ e && (H(v.current), V(), z());
2425
2528
  }, [
2426
2529
  z,
2427
- se,
2428
- B
2429
- ]), ye = x((e) => {
2430
- y.current = e ? { ...e } : null, B();
2431
- }, [B]), be = x(() => v.current.length > 0 ? (v.current = [], B(), z(), !0) : A.current <= 0 ? !1 : (--A.current, T.current = gn(k.current[A.current]), B(), z(), !0), [z, B]), xe = x(() => v.current.length > 0 || A.current >= k.current.length - 1 ? !1 : (A.current += 1, T.current = gn(k.current[A.current]), B(), z(), !0), [z, B]), Se = x(() => C.current <= 0 ? !1 : (--C.current, v.current = vn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), Ce = x(() => C.current >= S.current.length - 1 ? !1 : (C.current += 1, v.current = vn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), B(), z(), !0), [z, B]), we = x(() => {
2530
+ H,
2531
+ V
2532
+ ]), ve = x((e) => {
2533
+ 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 = En(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 = En(k.current[A.current]), V(), z(), !0), [z, V]), xe = x(() => C.current <= 0 ? !1 : (--C.current, v.current = On(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 = On(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), V(), z(), !0), [z, V]), Ce = x(() => {
2432
2535
  let t = e.current;
2433
- return t === G.BRUSH ? be() : t === G.POLYGON || t === G.PATH ? Se() : !1;
2536
+ return t === J.BRUSH ? ye() : t === J.POLYGON || t === J.PATH ? xe() : !1;
2434
2537
  }, [
2435
2538
  e,
2436
- be,
2437
- Se
2438
- ]), Te = x(() => {
2539
+ ye,
2540
+ xe
2541
+ ]), we = x(() => {
2439
2542
  let t = e.current;
2440
- return t === G.BRUSH ? xe() : t === G.POLYGON || t === G.PATH ? Ce() : !1;
2543
+ return t === J.BRUSH ? be() : t === J.POLYGON || t === J.PATH ? Se() : !1;
2441
2544
  }, [
2442
- xe,
2443
- Ce,
2545
+ be,
2546
+ Se,
2444
2547
  e
2445
- ]), U = x(() => {
2548
+ ]), Te = x(() => {
2446
2549
  let e = t.current;
2447
2550
  if (!e.length) return D.current.length > 0;
2448
- let r = n.current.getShapes().filter((t) => e.includes(t.id) && ie(t)), i = fn(r);
2551
+ let r = n.current.getShapes().filter((t) => e.includes(t.id) && ie(t)), i = Sn(r);
2449
2552
  return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
2450
- }, [n, t]), Ee = x(() => {
2553
+ }, [n, t]), W = x(() => {
2451
2554
  if (r.current) return !1;
2452
2555
  let e = [...T.current];
2453
2556
  v.current.length && e.push({
2454
- points: vn(v.current),
2557
+ points: On(v.current),
2455
2558
  mode: M()
2456
2559
  });
2457
2560
  let t = E.current, c = [...D.current];
2458
2561
  if (!e.length && !t.length) return !1;
2459
- let l = pn(e, a.current, t);
2460
- if (!l) return H(), !1;
2461
- let u = mn(l, o.current);
2562
+ let l = Cn(e, a.current, t);
2563
+ if (!l) return U(), !1;
2564
+ let u = wn(l, o.current);
2462
2565
  if (c.length) {
2463
2566
  let e = n.current.getShapes().filter((e) => c.includes(e.id));
2464
- if (!u.length) return n.current.remove(c), H(), d([]), !0;
2465
- u.sort((e, t) => nn(t) - nn(e));
2567
+ if (!u.length) return n.current.remove(c), U(), d([]), !0;
2568
+ u.sort((e, t) => pn(t) - pn(e));
2466
2569
  let t = [], r = [], i = [];
2467
2570
  for (let n = 0; n < u.length; n++) {
2468
2571
  let a = u[n];
@@ -2474,7 +2577,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2474
2577
  points: a
2475
2578
  }), i.push(r.id);
2476
2579
  } else {
2477
- let t = e[0], n = oe();
2580
+ let t = e[0], n = ae();
2478
2581
  r.push({
2479
2582
  ...t,
2480
2583
  id: n,
@@ -2484,19 +2587,19 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2484
2587
  }
2485
2588
  }
2486
2589
  let a = e.slice(u.length).map((e) => e.id);
2487
- return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), H(), d(i), !0;
2590
+ return t.length && n.current.update(t), r.length && n.current.create(r), a.length && n.current.remove(a), U(), d(i), !0;
2488
2591
  }
2489
- if (!u.length) return H(), !1;
2592
+ if (!u.length) return U(), !1;
2490
2593
  let f = i.current;
2491
2594
  if (!f) return !1;
2492
2595
  let p = u.map((e) => ({
2493
- id: oe(),
2596
+ id: ae(),
2494
2597
  type: L.POLYGON,
2495
2598
  points: e,
2496
2599
  style: f,
2497
2600
  meta: s
2498
2601
  }));
2499
- return n.current.create(p), d(p.map((e) => e.id)), H(), !0;
2602
+ return n.current.create(p), d(p.map((e) => e.id)), U(), !0;
2500
2603
  }, [
2501
2604
  a,
2502
2605
  d,
@@ -2504,46 +2607,46 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2504
2607
  s,
2505
2608
  i,
2506
2609
  r,
2507
- H
2508
- ]), De = x(() => {
2610
+ U
2611
+ ]), Ee = x(() => {
2509
2612
  let t = e.current;
2510
- if (t === G.BRUSH) return Ee();
2613
+ if (t === J.BRUSH) return W();
2511
2614
  let n = v.current;
2512
- return t === G.POLYGON && n.length >= 3 ? (g.current(L.POLYGON, n), H(), !0) : !1;
2615
+ return t === J.POLYGON && n.length >= 3 ? (g.current(L.POLYGON, n), U(), !0) : !1;
2513
2616
  }, [
2514
- Ee,
2515
- H,
2617
+ W,
2618
+ U,
2516
2619
  e
2517
- ]), W = x(() => {
2620
+ ]), De = x(() => {
2518
2621
  let t = v.current;
2519
- if (e.current === G.PATH && t.length >= 3) {
2520
- let e = $t(t, o.current);
2622
+ if (e.current === J.PATH && t.length >= 3) {
2623
+ let e = un(t, o.current);
2521
2624
  e.length >= 3 && g.current(L.POLYGON, e);
2522
2625
  }
2523
- H();
2524
- }, [H, e]), Oe = x((e) => {
2525
- j.current = e, z(), B();
2526
- }, [z, B]), ke = x(() => {
2527
- if (r.current || e.current !== G.BRUSH) return !1;
2528
- T.current = [], v.current = [], ae();
2529
- let t = U();
2530
- return z(), B(), t;
2626
+ U();
2627
+ }, [U, e]), Oe = x((e) => {
2628
+ j.current = e, z(), V();
2629
+ }, [z, V]), ke = x(() => {
2630
+ if (r.current || e.current !== J.BRUSH) return !1;
2631
+ T.current = [], v.current = [], B();
2632
+ let t = Te();
2633
+ return z(), V(), t;
2531
2634
  }, [
2532
2635
  z,
2533
2636
  r,
2637
+ V,
2534
2638
  B,
2535
- ae,
2536
- U,
2639
+ Te,
2537
2640
  e
2538
- ]), Ae = x(() => {
2641
+ ]), G = x(() => {
2539
2642
  let e = b.current;
2540
2643
  if (!e.size) return !1;
2541
2644
  let t = v.current.filter((t, n) => !e.has(n));
2542
- return b.current = /* @__PURE__ */ new Set(), ce(t, !0), !0;
2543
- }, [ce]), K = x((e) => {
2645
+ return b.current = /* @__PURE__ */ new Set(), se(t, !0), !0;
2646
+ }, [se]), Ae = x((e) => {
2544
2647
  let t = c.current, n = v.current;
2545
2648
  if (!t || !n.length) return -1;
2546
- let r = bn / (t.viewport.scale || 1);
2649
+ let r = An / (t.viewport.scale || 1);
2547
2650
  for (let t = n.length - 1; t >= 0; t--) {
2548
2651
  let i = n[t];
2549
2652
  if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
@@ -2551,106 +2654,106 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2551
2654
  return -1;
2552
2655
  }, [c]), je = x(() => {
2553
2656
  v.current.length >= 1 && (T.current.push({
2554
- points: vn(v.current),
2657
+ points: On(v.current),
2555
2658
  mode: M()
2556
- }), v.current = [], V(T.current)), B(), z();
2659
+ }), v.current = [], oe(T.current)), V(), z();
2557
2660
  }, [
2558
2661
  z,
2559
- V,
2560
- B
2662
+ oe,
2663
+ V
2561
2664
  ]);
2562
2665
  return {
2563
- reset: H,
2564
- undoSession: we,
2565
- redoSession: Te,
2666
+ reset: U,
2667
+ undoSession: Ce,
2668
+ redoSession: we,
2566
2669
  canUndoSession: ne,
2567
2670
  canRedoSession: re,
2568
2671
  hasDraftSession: R,
2569
- hasDraftPoints: ue,
2570
- commitDraftSession: De,
2571
- completeFreehandStroke: W,
2672
+ hasDraftPoints: le,
2673
+ commitDraftSession: Ee,
2674
+ completeFreehandStroke: De,
2572
2675
  setBrushScalarMode: Oe,
2573
2676
  getBrushScalarMode: () => j.current,
2574
2677
  hasBrushSession: N,
2575
- commitBrush: Ee,
2678
+ commitBrush: W,
2576
2679
  cancelBrush: x(() => {
2577
- e.current === G.BRUSH && H();
2578
- }, [H, e]),
2680
+ e.current === J.BRUSH && U();
2681
+ }, [U, e]),
2579
2682
  beginBrushEditFromSelection: ke,
2580
- deleteDraftSelectedPoints: Ae,
2581
- hitDraftPoint: K,
2582
- getDraftPointsSnapshot: le,
2583
- tryClosePolygon: de,
2584
- removeDraftPoint: fe,
2585
- selectDraftPointForDrag: pe,
2586
- appendPolygonPoint: me,
2587
- beginStroke: he,
2588
- appendStrokePoint: ge,
2589
- moveDraftPoints: _e,
2590
- commitDraftPointDrag: ve,
2591
- setDraftCursor: ye,
2683
+ deleteDraftSelectedPoints: G,
2684
+ hitDraftPoint: Ae,
2685
+ getDraftPointsSnapshot: ce,
2686
+ tryClosePolygon: ue,
2687
+ removeDraftPoint: de,
2688
+ selectDraftPointForDrag: fe,
2689
+ appendPolygonPoint: pe,
2690
+ beginStroke: me,
2691
+ appendStrokePoint: he,
2692
+ moveDraftPoints: ge,
2693
+ commitDraftPointDrag: _e,
2694
+ setDraftCursor: ve,
2592
2695
  finishScalarStroke: je,
2593
2696
  handleToolChange: x((e, t) => {
2594
2697
  if (t) {
2595
- H(), j.current = "draw";
2698
+ U(), j.current = "draw";
2596
2699
  return;
2597
2700
  }
2598
- if (e !== G.BRUSH) {
2599
- H(), j.current = "draw";
2701
+ if (e !== J.BRUSH) {
2702
+ U(), j.current = "draw";
2600
2703
  return;
2601
2704
  }
2602
- j.current = "draw", T.current = [], v.current = [], ae(), U(), z(), B();
2705
+ j.current = "draw", T.current = [], v.current = [], B(), Te(), z(), V();
2603
2706
  }, [
2604
2707
  z,
2708
+ V,
2709
+ U,
2605
2710
  B,
2606
- H,
2607
- ae,
2608
- U
2711
+ Te
2609
2712
  ]),
2610
2713
  handleBrushSelectionChange: x((t, n) => {
2611
- if (!(e.current !== G.BRUSH || n)) {
2714
+ if (!(e.current !== J.BRUSH || n)) {
2612
2715
  if (!t.length) {
2613
2716
  z();
2614
2717
  return;
2615
2718
  }
2616
- [...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], ae(), U(), z(), B()));
2719
+ [...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], B(), Te(), z(), V()));
2617
2720
  }
2618
2721
  }, [
2619
2722
  z,
2723
+ V,
2620
2724
  B,
2621
- ae,
2622
- U,
2725
+ Te,
2623
2726
  e
2624
2727
  ])
2625
2728
  };
2626
2729
  }
2627
2730
  //#endregion
2628
2731
  //#region src/components/ShapeEditor/_state/useEditorDocument.ts
2629
- function Cn(e, t) {
2732
+ function Nn(e, t) {
2630
2733
  return {
2631
2734
  shapes: t,
2632
2735
  past: [...e.past, e.shapes],
2633
2736
  future: []
2634
2737
  };
2635
2738
  }
2636
- function wn(e, t) {
2739
+ function Pn(e, t) {
2637
2740
  switch (t.type) {
2638
- case "CREATE": return Cn(e, [...e.shapes, ...t.shapes]);
2741
+ case "CREATE": return Nn(e, [...e.shapes, ...t.shapes]);
2639
2742
  case "UPDATE": {
2640
2743
  let n = new Map(t.shapes.map((e) => [e.id, e]));
2641
- return Cn(e, e.shapes.map((e) => n.get(e.id) ?? e));
2744
+ return Nn(e, e.shapes.map((e) => n.get(e.id) ?? e));
2642
2745
  }
2643
2746
  case "DELETE": {
2644
2747
  let n = new Set(t.ids);
2645
- return Cn(e, e.shapes.filter((e) => !n.has(e.id)));
2748
+ return Nn(e, e.shapes.filter((e) => !n.has(e.id)));
2646
2749
  }
2647
2750
  case "REPLACE": {
2648
2751
  let n = new Set(t.removeIds);
2649
- return Cn(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
2752
+ return Nn(e, [...e.shapes.filter((e) => !n.has(e.id)), ...t.shapes]);
2650
2753
  }
2651
2754
  case "REORDER": {
2652
2755
  let n = new Set(t.ids), r = e.shapes.filter((e) => n.has(e.id)), i = e.shapes.filter((e) => !n.has(e.id));
2653
- return r.length === 0 ? e : Cn(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
2756
+ return r.length === 0 ? e : Nn(e, t.edge === "front" ? [...i, ...r] : [...r, ...i]);
2654
2757
  }
2655
2758
  case "RESET": return {
2656
2759
  shapes: t.shapes,
@@ -2670,15 +2773,15 @@ function wn(e, t) {
2670
2773
  default: return e;
2671
2774
  }
2672
2775
  }
2673
- function Tn(e) {
2674
- let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = D(wn, {
2776
+ function Fn(e) {
2777
+ let { onShapesCreated: t, onShapesUpdated: n, onShapesDeleted: r } = e, [i, a] = D(Pn, {
2675
2778
  shapes: [],
2676
2779
  past: [],
2677
2780
  future: []
2678
2781
  }), o = O(i);
2679
2782
  o.current = i;
2680
2783
  let s = x((e) => {
2681
- o.current = wn(o.current, e), a(e);
2784
+ o.current = Pn(o.current, e), a(e);
2682
2785
  }, []), c = x((e, i) => {
2683
2786
  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));
2684
2787
  s.length && t?.(s);
@@ -2747,7 +2850,7 @@ function Tn(e) {
2747
2850
  }
2748
2851
  //#endregion
2749
2852
  //#region src/components/ShapeEditor/_model/keymap.ts
2750
- var En = {
2853
+ var In = {
2751
2854
  undo: ["mod+z"],
2752
2855
  redo: ["mod+shift+z"],
2753
2856
  selectAll: ["mod+a"],
@@ -2775,7 +2878,7 @@ var En = {
2775
2878
  pathTool: ["g"],
2776
2879
  brushTool: ["b"],
2777
2880
  pointTool: ["i"]
2778
- }, Dn = {
2881
+ }, Ln = {
2779
2882
  Equal: "=",
2780
2883
  Minus: "-",
2781
2884
  BracketLeft: "[",
@@ -2785,7 +2888,7 @@ var En = {
2785
2888
  Comma: ",",
2786
2889
  Slash: "/",
2787
2890
  Backquote: "`"
2788
- }, On = {
2891
+ }, Rn = {
2789
2892
  Escape: "escape",
2790
2893
  Enter: "enter",
2791
2894
  Backspace: "backspace",
@@ -2796,58 +2899,58 @@ var En = {
2796
2899
  ArrowLeft: "arrowleft",
2797
2900
  ArrowRight: "arrowright"
2798
2901
  };
2799
- function kn(e) {
2902
+ function zn(e) {
2800
2903
  let t = e.code, n = /^Key([A-Z])$/.exec(t);
2801
2904
  if (n) return n[1].toLowerCase();
2802
2905
  let r = /^Digit([0-9])$/.exec(t);
2803
- return r ? r[1] : Dn[t] ? Dn[t] : On[e.key] ? On[e.key] : null;
2906
+ return r ? r[1] : Ln[t] ? Ln[t] : Rn[e.key] ? Rn[e.key] : null;
2804
2907
  }
2805
- function An(e) {
2806
- let t = kn(e);
2908
+ function Bn(e) {
2909
+ let t = zn(e);
2807
2910
  if (!t) return null;
2808
2911
  let n = [];
2809
2912
  return (e.metaKey || e.ctrlKey) && n.push("mod"), e.shiftKey && n.push("shift"), e.altKey && n.push("alt"), n.push(t), n.join("+");
2810
2913
  }
2811
- function jn(e) {
2914
+ function Vn(e) {
2812
2915
  let t = /* @__PURE__ */ new Map();
2813
- for (let n of Object.keys(En)) {
2814
- let r = e?.[n], i = r === void 0 ? En[n] : r === null ? [] : Array.isArray(r) ? r : [r];
2916
+ for (let n of Object.keys(In)) {
2917
+ let r = e?.[n], i = r === void 0 ? In[n] : r === null ? [] : Array.isArray(r) ? r : [r];
2815
2918
  for (let e of i) t.set(e.toLowerCase(), n);
2816
2919
  }
2817
2920
  return t;
2818
2921
  }
2819
2922
  //#endregion
2820
2923
  //#region src/components/ShapeEditor/_state/useEditorHotkeys.ts
2821
- var Mn = {
2924
+ var Hn = {
2822
2925
  ArrowUp: [0, -1],
2823
2926
  ArrowDown: [0, 1],
2824
2927
  ArrowLeft: [-1, 0],
2825
2928
  ArrowRight: [1, 0]
2826
2929
  };
2827
- function Nn() {
2930
+ function Un() {
2828
2931
  let e = document.activeElement;
2829
2932
  return !!e && (e.tagName === "INPUT" || e.tagName === "TEXTAREA" || e.isContentEditable);
2830
2933
  }
2831
- function Pn(e, t) {
2934
+ function Wn(e, t) {
2832
2935
  if (!t || !(e instanceof Element)) return !1;
2833
2936
  let n = e.closest("[role=\"dialog\"],[aria-modal=\"true\"]");
2834
2937
  return !!n && !n.contains(t);
2835
2938
  }
2836
- function Fn(e) {
2837
- let { spaceRef: t, shiftRef: n } = e, r = E(() => jn(e.keymap), [e.keymap]), i = O(e);
2939
+ function Gn(e) {
2940
+ let { spaceRef: t, shiftRef: n } = e, r = E(() => Vn(e.keymap), [e.keymap]), i = O(e);
2838
2941
  i.current = e;
2839
2942
  let a = O(r);
2840
2943
  a.current = r, S(() => {
2841
2944
  let e = (e) => {
2842
- if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0), Nn() || Pn(e.target, i.current.hostRef.current)) return;
2843
- let r = Mn[e.key];
2945
+ if (e.code === "Space" && (t.current = !0, i.current.onSpaceDown()), e.key === "Shift" && (n.current = !0), Un() || Wn(e.target, i.current.hostRef.current)) return;
2946
+ let r = Hn[e.key];
2844
2947
  if (r) {
2845
2948
  e.preventDefault();
2846
2949
  let t = e.shiftKey ? 10 : 1;
2847
2950
  i.current.nudge(r[0] * t, r[1] * t);
2848
2951
  return;
2849
2952
  }
2850
- let o = An(e);
2953
+ let o = Bn(e);
2851
2954
  if (!o) return;
2852
2955
  let s = a.current.get(o);
2853
2956
  s && i.current.actions[s]?.() !== !1 && e.preventDefault();
@@ -2861,14 +2964,14 @@ function Fn(e) {
2861
2964
  }
2862
2965
  //#endregion
2863
2966
  //#region src/components/ShapeEditor/_model/imageLoad.ts
2864
- function In(e, t) {
2967
+ function Kn(e, t) {
2865
2968
  return new Promise((n) => {
2866
2969
  let r = new Image();
2867
2970
  t?.crossOrigin && (r.crossOrigin = "anonymous"), r.onload = () => n(r), r.onerror = () => n(null), r.src = e;
2868
2971
  });
2869
2972
  }
2870
- async function Ln(e) {
2871
- let t = await In(e, { crossOrigin: !0 });
2973
+ async function qn(e) {
2974
+ let t = await Kn(e, { crossOrigin: !0 });
2872
2975
  if (t) return t;
2873
2976
  try {
2874
2977
  let t = await fetch(e, {
@@ -2881,11 +2984,11 @@ async function Ln(e) {
2881
2984
  } catch {
2882
2985
  return null;
2883
2986
  }
2884
- return In(e, { crossOrigin: !0 });
2987
+ return Kn(e, { crossOrigin: !0 });
2885
2988
  }
2886
2989
  //#endregion
2887
2990
  //#region src/components/ShapeEditor/_model/imageDiagnosis.ts
2888
- function Rn(e) {
2991
+ function Jn(e) {
2889
2992
  return new Promise((t) => {
2890
2993
  let n = null, r = !1, i = () => {
2891
2994
  r || (r = !0, clearTimeout(o), document.removeEventListener("securitypolicyviolation", a), t(n));
@@ -2893,29 +2996,29 @@ function Rn(e) {
2893
2996
  let r = t.effectiveDirective ?? t.violatedDirective ?? "";
2894
2997
  r.includes("img-src") && (n = `CSP ${r} blocked ${t.blockedURI || e}`);
2895
2998
  }, o = setTimeout(i, 1e4);
2896
- document.addEventListener("securitypolicyviolation", a), In(e, { crossOrigin: !0 }).then(() => {
2999
+ document.addEventListener("securitypolicyviolation", a), Kn(e, { crossOrigin: !0 }).then(() => {
2897
3000
  setTimeout(i, 0);
2898
3001
  });
2899
3002
  });
2900
3003
  }
2901
- var zn = 3e4, Bn = 200, Vn = /* @__PURE__ */ new Map();
2902
- function Hn(e) {
2903
- let t = Vn.get(e), n = Date.now();
2904
- if (t && n - t.at < zn) return t.result;
2905
- let r = Un(e).catch((t) => (Vn.delete(e), {
3004
+ var Yn = 3e4, Xn = 200, Zn = /* @__PURE__ */ new Map();
3005
+ function Qn(e) {
3006
+ let t = Zn.get(e), n = Date.now();
3007
+ if (t && n - t.at < Yn) return t.result;
3008
+ let r = $n(e).catch((t) => (Zn.delete(e), {
2906
3009
  kind: "unknown",
2907
3010
  detail: t instanceof Error ? t.message : String(t)
2908
3011
  }));
2909
- if (Vn.set(e, {
3012
+ if (Zn.set(e, {
2910
3013
  at: n,
2911
3014
  result: r
2912
- }), Vn.size > Bn) {
2913
- let e = Vn.keys().next().value;
2914
- e !== void 0 && Vn.delete(e);
3015
+ }), Zn.size > Xn) {
3016
+ let e = Zn.keys().next().value;
3017
+ e !== void 0 && Zn.delete(e);
2915
3018
  }
2916
3019
  return r;
2917
3020
  }
2918
- async function Un(e) {
3021
+ async function $n(e) {
2919
3022
  let t = e;
2920
3023
  try {
2921
3024
  t = new URL(e, location.href).origin;
@@ -2958,7 +3061,7 @@ async function Un(e) {
2958
3061
  kind: "unexpected-content",
2959
3062
  detail: `HTTP ${r} (${t})${n.redirected ? " via redirect" : ""}`
2960
3063
  };
2961
- let i = await Rn(e);
3064
+ let i = await Jn(e);
2962
3065
  return i ? {
2963
3066
  kind: "csp-img",
2964
3067
  detail: i
@@ -2995,7 +3098,7 @@ async function Un(e) {
2995
3098
  detail: `HTTP ${r}`
2996
3099
  };
2997
3100
  }
2998
- function Wn() {
3101
+ function er() {
2999
3102
  try {
3000
3103
  let e = document.createElement("canvas");
3001
3104
  return !!(e.getContext("webgl2") ?? e.getContext("webgl"));
@@ -3003,12 +3106,12 @@ function Wn() {
3003
3106
  return !1;
3004
3107
  }
3005
3108
  }
3006
- function Gn(e) {
3109
+ function tr(e) {
3007
3110
  let t = e instanceof Error ? e.message : String(e);
3008
3111
  return /unsafe-eval/i.test(t) ? {
3009
3112
  kind: "csp-eval",
3010
3113
  detail: t
3011
- } : Wn() ? {
3114
+ } : er() ? {
3012
3115
  kind: "renderer-init",
3013
3116
  detail: t || "renderer init failed"
3014
3117
  } : {
@@ -3018,8 +3121,8 @@ function Gn(e) {
3018
3121
  }
3019
3122
  //#endregion
3020
3123
  //#region src/components/ShapeEditor/_model/imageTiles.ts
3021
- var Kn = 4e3;
3022
- function qn(e, t, n = Kn) {
3124
+ var nr = 4e3;
3125
+ function rr(e, t, n = nr) {
3023
3126
  if (e <= 0 || t <= 0) return [];
3024
3127
  let r = Math.ceil(e / n), i = Math.ceil(t / n);
3025
3128
  return Array.from({ length: i }, (a, o) => Array.from({ length: r }, (a, s) => {
@@ -3034,7 +3137,7 @@ function qn(e, t, n = Kn) {
3034
3137
  };
3035
3138
  })).flat();
3036
3139
  }
3037
- function Jn(e, t) {
3140
+ function ir(e, t) {
3038
3141
  let n = document.createElement("canvas");
3039
3142
  n.width = t.width, n.height = t.height;
3040
3143
  let r = n.getContext("2d");
@@ -3042,7 +3145,7 @@ function Jn(e, t) {
3042
3145
  }
3043
3146
  //#endregion
3044
3147
  //#region src/components/ShapeEditor/_model/konva.ts
3045
- function Yn(e, t, n) {
3148
+ function ar(e, t, n) {
3046
3149
  if (t === L.POINT) {
3047
3150
  e.setAttrs({
3048
3151
  x: n[0].x,
@@ -3061,7 +3164,7 @@ function Yn(e, t, n) {
3061
3164
  return;
3062
3165
  }
3063
3166
  if (t === L.ELLIPSE) {
3064
- let t = V(n);
3167
+ let t = H(n);
3065
3168
  e.setAttrs({
3066
3169
  x: (t.minX + t.maxX) / 2,
3067
3170
  y: (t.minY + t.maxY) / 2,
@@ -3078,19 +3181,19 @@ function Yn(e, t, n) {
3078
3181
  }
3079
3182
  //#endregion
3080
3183
  //#region src/components/ShapeEditor/_model/pinIcon.ts
3081
- var Q = "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", Xn = "#ffffff", Zn = 1.5;
3082
- function Qn(e) {
3083
- return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Q}" fill="${e}" stroke="${Xn}" stroke-width="${Zn}"/></svg>`;
3184
+ var or = "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", sr = "#ffffff", cr = 1.5;
3185
+ function lr(e) {
3186
+ return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${or}" fill="${e}" stroke="${sr}" stroke-width="${cr}"/></svg>`;
3084
3187
  }
3085
3188
  //#endregion
3086
3189
  //#region src/components/ShapeEditor/_renderers/transformSession.ts
3087
- var $n = Math.PI / 12;
3088
- function er(e, t) {
3190
+ var ur = Math.PI / 12;
3191
+ function dr(e, t) {
3089
3192
  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;
3090
3193
  }
3091
- function tr(e, t, n) {
3194
+ function fr(e, t, n) {
3092
3195
  if (e.kind === "resize") {
3093
- let r = n ? e.box : H(e.anchor, e.box, t.x, t.y);
3196
+ let r = n ? e.box : se(e.anchor, e.box, t.x, t.y);
3094
3197
  return {
3095
3198
  updates: e.shapes.map((i) => ({
3096
3199
  id: i.id,
@@ -3119,7 +3222,7 @@ function tr(e, t, n) {
3119
3222
  }
3120
3223
  if (e.kind === "rotate") {
3121
3224
  let n = Math.atan2(t.y - e.center.y, t.x - e.center.x) - e.startAngle;
3122
- return e.shiftKey && (n = Math.round(n / $n) * $n), {
3225
+ return e.shiftKey && (n = Math.round(n / ur) * ur), {
3123
3226
  updates: [{
3124
3227
  id: e.id,
3125
3228
  points: e.points.map((t) => le(t, e.center, n))
@@ -3136,16 +3239,16 @@ function tr(e, t, n) {
3136
3239
  id: e.id,
3137
3240
  points: a
3138
3241
  }],
3139
- box: V(a)
3242
+ box: H(a)
3140
3243
  };
3141
3244
  }
3142
- function nr(e, t) {
3245
+ function pr(e, t) {
3143
3246
  return t.kind === "move" || t.kind === "vertex" ? t.start : t.kind === "rotate" ? {
3144
3247
  x: t.center.x + Math.cos(t.startAngle),
3145
3248
  y: t.center.y + Math.sin(t.startAngle)
3146
- } : er(e, t) ? be(t.shapes[0].points)[B.indexOf(t.anchor)] : se(t.anchor, t.box);
3249
+ } : dr(e, t) ? be(t.shapes[0].points)[oe.indexOf(t.anchor)] : U(t.anchor, t.box);
3147
3250
  }
3148
- function rr(e, t, n) {
3251
+ function mr(e, t, n) {
3149
3252
  let r = e.filter((e) => t.includes(e.id) && z(e)).map((e) => ({
3150
3253
  id: e.id,
3151
3254
  points: e.points
@@ -3153,31 +3256,27 @@ function rr(e, t, n) {
3153
3256
  return r.length ? {
3154
3257
  kind: "move",
3155
3258
  start: n,
3156
- box: V(r.flatMap((e) => e.points)),
3259
+ box: H(r.flatMap((e) => e.points)),
3157
3260
  shapes: r
3158
3261
  } : null;
3159
3262
  }
3160
- function ir(e) {
3263
+ function hr(e) {
3161
3264
  return e.map((e) => ({
3162
3265
  ...e,
3163
3266
  points: e.points.map((e) => ({ ...e }))
3164
3267
  }));
3165
3268
  }
3166
- function ar(e, t) {
3269
+ function gr(e, t) {
3167
3270
  let n = new Set(t);
3168
3271
  return e.filter((e) => n.has(e.id) && ie(e));
3169
3272
  }
3170
- function or(e, t) {
3171
- return e.filter((e) => {
3172
- if (!R(e)) return !1;
3173
- let n = V(e.points);
3174
- return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
3175
- }).map((e) => e.id);
3273
+ function _r(e, t) {
3274
+ return e.filter((e) => R(e) && Ne(e, t)).map((e) => e.id);
3176
3275
  }
3177
- function sr(e, t, n) {
3178
- return (e ? Ue(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
3276
+ function vr(e, t, n) {
3277
+ return (e ? Ze(e, { strokeWidth: t }).pointRadius : 5) / (n || 1);
3179
3278
  }
3180
- function cr(e, t) {
3279
+ function yr(e, t) {
3181
3280
  return {
3182
3281
  minX: e.x - t,
3183
3282
  minY: e.y - t,
@@ -3185,9 +3284,9 @@ function cr(e, t) {
3185
3284
  maxY: e.y + t
3186
3285
  };
3187
3286
  }
3188
- function lr(e, t, n) {
3287
+ function br(e, t, n) {
3189
3288
  if (e.type === L.ROTATED_RECTANGLE) return t;
3190
- let r = e.type === L.POINT ? cr(t[0], n) : V(t);
3289
+ let r = e.type === L.POINT ? yr(t[0], n) : H(t);
3191
3290
  return ue([{
3192
3291
  x: r.minX,
3193
3292
  y: r.minY
@@ -3196,17 +3295,17 @@ function lr(e, t, n) {
3196
3295
  y: r.maxY
3197
3296
  }]);
3198
3297
  }
3199
- function ur(e) {
3298
+ function xr(e) {
3200
3299
  return 24 / (e || 1);
3201
3300
  }
3202
- function dr(e, t) {
3301
+ function Sr(e, t) {
3203
3302
  return Math.atan2(t.y - e.y, t.x - e.x);
3204
3303
  }
3205
3304
  //#endregion
3206
3305
  //#region src/components/ShapeEditor/_renderers/KonvaRenderer.ts
3207
- var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3306
+ var Cr = 2, wr = "#1e88e5", Tr = "#669def", Er = class {
3208
3307
  constructor(e, t) {
3209
- 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 = fr, 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 = {
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 = Cr, 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 = {
3210
3309
  x: 0,
3211
3310
  y: 0
3212
3311
  }, 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({
@@ -3297,9 +3396,15 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3297
3396
  this.stage.container().style.cursor = this.baseCursor;
3298
3397
  for (let e of this.stage.container().querySelectorAll("canvas")) e.style.cursor = this.baseCursor;
3299
3398
  }
3399
+ bindShapeCursor(e, t) {
3400
+ if (!z(t)) return this.bindCursor(e, "default");
3401
+ this.bindCursor(e, () => this.selected.includes(t.id) ? "grab" : Mt);
3402
+ }
3300
3403
  bindCursor(e, t) {
3301
3404
  let n = () => {
3302
- this.activeDrag || t === "pointer" && !this.transformEnabled || this.emitCursorHint(t);
3405
+ if (this.activeDrag) return;
3406
+ let e = typeof t == "function" ? t() : t;
3407
+ e === "pointer" && !this.transformEnabled || this.emitCursorHint(e);
3303
3408
  }, r = () => {
3304
3409
  this.activeDrag || this.emitCursorHint(null);
3305
3410
  };
@@ -3316,7 +3421,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3316
3421
  return this.world.getAbsoluteTransform().point(e);
3317
3422
  }
3318
3423
  async setImage(e, t, n) {
3319
- let r = ++this.imageLoadToken, i = await Ln(e);
3424
+ let r = ++this.imageLoadToken, i = await qn(e);
3320
3425
  if (r !== this.imageLoadToken) return !0;
3321
3426
  if (!i) return this.imageWidth ||= 800, this.imageHeight ||= 600, !1;
3322
3427
  this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
@@ -3325,7 +3430,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3325
3430
  x: a / i.naturalWidth,
3326
3431
  y: o / i.naturalHeight
3327
3432
  }), this.bgGroup.destroyChildren();
3328
- for (let e of qn(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new A.Image({
3433
+ for (let e of rr(i.naturalWidth, i.naturalHeight)) this.bgGroup.add(new A.Image({
3329
3434
  image: i,
3330
3435
  x: e.x,
3331
3436
  y: e.y,
@@ -3380,7 +3485,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3380
3485
  if (this.regionOverlayGroup.add(new A.Shape({
3381
3486
  listening: !1,
3382
3487
  sceneFunc: (r) => {
3383
- It(r._context, e, t, n);
3488
+ Gt(r._context, e, t, n);
3384
3489
  }
3385
3490
  })), e.outlineStyles) {
3386
3491
  let t = (e, t) => {
@@ -3436,7 +3541,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3436
3541
  let e = this.lastPreviewPoly;
3437
3542
  e && this.previewPoly(e.points, e.cursor, e.style, e.closed, e.selectedPointIndices, e.showVertices);
3438
3543
  }
3439
- this.activeDrag ? this.dragTransform(this.lastDragImg ?? nr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
3544
+ this.activeDrag ? this.dragTransform(this.lastDragImg ?? pr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.layer.batchDraw(), this.cb.onViewportChange?.();
3440
3545
  }
3441
3546
  fit() {
3442
3547
  if (!this.imageWidth || !this.imageHeight) return;
@@ -3465,10 +3570,10 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3465
3570
  });
3466
3571
  }
3467
3572
  setShapes(e, t) {
3468
- if (this.shapes = ir(e), this.selected = t, !this.activeDrag) {
3573
+ if (this.shapes = hr(e), this.selected = t, !this.activeDrag) {
3469
3574
  this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
3470
- for (let t of ae(e).filter(ne)) {
3471
- let e = this.makeNode(t), n = Ue(t, { strokeWidth: this.strokeSize });
3575
+ for (let t of B(e).filter(ne)) {
3576
+ let e = this.makeNode(t), n = Ze(t, { strokeWidth: this.strokeSize });
3472
3577
  if (t.style?.alternateColor && n.dash?.length && t.type !== L.POINT) {
3473
3578
  let n = e.clone({
3474
3579
  id: `${t.id}__alt`,
@@ -3499,7 +3604,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3499
3604
  t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
3500
3605
  }
3501
3606
  makeNode(e) {
3502
- let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i = R(e), a = {
3607
+ let { type: t, points: n } = e, r = Ze(e, { strokeWidth: this.strokeSize }), i = R(e), a = {
3503
3608
  id: e.id,
3504
3609
  stroke: r.color,
3505
3610
  strokeWidth: r.strokeWidth,
@@ -3507,11 +3612,11 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3507
3612
  opacity: r.opacity,
3508
3613
  strokeScaleEnabled: !1,
3509
3614
  listening: i
3510
- }, o = r.fillVisible ? We(r.color, r.fillAlpha) : void 0;
3615
+ }, o = r.fillVisible ? Qe(r.color, r.fillAlpha) : void 0;
3511
3616
  if (t === L.POINT) {
3512
3617
  let t = 1 / (this.world.scaleX() || 1), a = new A.Path({
3513
3618
  id: e.id,
3514
- data: Q,
3619
+ data: or,
3515
3620
  x: n[0].x,
3516
3621
  y: n[0].y,
3517
3622
  offsetX: 16 / 2,
@@ -3519,8 +3624,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3519
3624
  scaleX: t,
3520
3625
  scaleY: t,
3521
3626
  fill: r.color,
3522
- stroke: Xn,
3523
- strokeWidth: Zn,
3627
+ stroke: sr,
3628
+ strokeWidth: cr,
3524
3629
  strokeScaleEnabled: !1,
3525
3630
  shadowColor: "#000",
3526
3631
  shadowBlur: 2,
@@ -3529,10 +3634,10 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3529
3634
  opacity: r.opacity,
3530
3635
  listening: i
3531
3636
  });
3532
- return this.bindCursor(a, z(e) ? "grab" : "default"), a;
3637
+ return this.bindShapeCursor(a, e), a;
3533
3638
  }
3534
3639
  if (t === L.RECTANGLE) {
3535
- let t = V(n), r = new A.Rect({
3640
+ let t = H(n), r = new A.Rect({
3536
3641
  x: t.minX,
3537
3642
  y: t.minY,
3538
3643
  width: t.maxX - t.minX,
@@ -3540,10 +3645,10 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3540
3645
  fill: o,
3541
3646
  ...a
3542
3647
  });
3543
- return this.bindCursor(r, z(e) ? "grab" : "default"), r;
3648
+ return this.bindShapeCursor(r, e), r;
3544
3649
  }
3545
3650
  if (t === L.ELLIPSE) {
3546
- let t = V(n), r = new A.Ellipse({
3651
+ let t = H(n), r = new A.Ellipse({
3547
3652
  x: (t.minX + t.maxX) / 2,
3548
3653
  y: (t.minY + t.maxY) / 2,
3549
3654
  radiusX: (t.maxX - t.minX) / 2,
@@ -3551,27 +3656,28 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3551
3656
  fill: o,
3552
3657
  ...a
3553
3658
  });
3554
- return this.bindCursor(r, z(e) ? "grab" : "default"), r;
3659
+ return this.bindShapeCursor(r, e), r;
3555
3660
  }
3556
3661
  let s = n.flatMap((e) => [e.x, e.y]), c = t !== L.LINE, l = new A.Line({
3557
3662
  points: s,
3558
3663
  closed: c,
3559
3664
  fill: c ? o : void 0,
3665
+ fillRule: "evenodd",
3560
3666
  lineJoin: "round",
3561
3667
  ...a
3562
3668
  });
3563
- return this.bindCursor(l, z(e) ? "grab" : "default"), l;
3669
+ return this.bindShapeCursor(l, e), l;
3564
3670
  }
3565
3671
  liveUpdateShape(e, t) {
3566
3672
  let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
3567
3673
  if (n && r) {
3568
- Yn(n, r.type, t);
3674
+ ar(n, r.type, t);
3569
3675
  let i = this.altNodes.get(e);
3570
- i && Yn(i, r.type, t), r.type === L.POINT && n instanceof A.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
3676
+ i && ar(i, r.type, t), r.type === L.POINT && n instanceof A.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
3571
3677
  }
3572
3678
  }
3573
3679
  pointRadius(e) {
3574
- return sr(e, this.strokeSize, this.world.scaleX() || 1);
3680
+ return vr(e, this.strokeSize, this.world.scaleX() || 1);
3575
3681
  }
3576
3682
  scaledDash(e) {
3577
3683
  return e;
@@ -3587,11 +3693,11 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3587
3693
  });
3588
3694
  continue;
3589
3695
  }
3590
- n?.dash(this.scaledDash(Ue(t, { strokeWidth: this.strokeSize }).dash));
3696
+ n?.dash(this.scaledDash(Ze(t, { strokeWidth: this.strokeSize }).dash));
3591
3697
  }
3592
3698
  }
3593
3699
  shapesIntersecting(e) {
3594
- return or(this.shapes, e);
3700
+ return _r(this.shapes, e);
3595
3701
  }
3596
3702
  drawSelectionBorders() {
3597
3703
  let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && R(t)) : [];
@@ -3600,7 +3706,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3600
3706
  this.selectionBorders = t.map(() => {
3601
3707
  let e = new A.Line({
3602
3708
  closed: !0,
3603
- stroke: mr,
3709
+ stroke: Tr,
3604
3710
  strokeWidth: 1.5,
3605
3711
  strokeScaleEnabled: !1,
3606
3712
  listening: !1
@@ -3621,7 +3727,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3621
3727
  }
3622
3728
  }
3623
3729
  selectionOutlinePoints(e, t) {
3624
- return lr(e, t, this.pointRadius(e));
3730
+ return br(e, t, this.pointRadius(e));
3625
3731
  }
3626
3732
  clearPreview() {
3627
3733
  this.lastPreviewPoly = null, this.previewGroup.destroyChildren(), this.layer.batchDraw();
@@ -3684,8 +3790,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3684
3790
  x: n.x,
3685
3791
  y: n.y,
3686
3792
  radius: (r ? 6 : 5) / l,
3687
- fill: r ? pr : "#ffffff",
3688
- stroke: r ? "#ffffff" : pr,
3793
+ fill: r ? wr : "#ffffff",
3794
+ stroke: r ? "#ffffff" : wr,
3689
3795
  strokeWidth: 1.5,
3690
3796
  strokeScaleEnabled: !1,
3691
3797
  listening: !1
@@ -3695,7 +3801,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3695
3801
  }
3696
3802
  previewScalarMask(e, t) {
3697
3803
  this.previewGroup.destroyChildren();
3698
- let n = hn(e, t.length === 7 ? `${t}99` : t);
3804
+ let n = Tn(e, t.length === 7 ? `${t}99` : t);
3699
3805
  this.previewGroup.add(new A.Image({
3700
3806
  image: n,
3701
3807
  x: e.ox,
@@ -3707,8 +3813,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3707
3813
  }
3708
3814
  previewMarquee(e, t) {
3709
3815
  this.marquee || (this.marquee = new A.Rect({
3710
- fill: We(Be, Ve),
3711
- stroke: Be,
3816
+ fill: Qe(Je, Ye),
3817
+ stroke: Je,
3712
3818
  strokeWidth: 1,
3713
3819
  strokeScaleEnabled: !1,
3714
3820
  listening: !1,
@@ -3739,14 +3845,14 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3739
3845
  setTransformerOutlinePoints(e) {
3740
3846
  e.length < 2 || (this.transformerOutline || (this.transformerOutline = new A.Line({
3741
3847
  closed: !0,
3742
- stroke: pr,
3848
+ stroke: wr,
3743
3849
  strokeWidth: 1,
3744
3850
  strokeScaleEnabled: !1,
3745
3851
  listening: !1
3746
3852
  }), this.selGroup.add(this.transformerOutline)), this.transformerOutline.points(e.flatMap((e) => [e.x, e.y])));
3747
3853
  }
3748
3854
  rotationHandleGap() {
3749
- return ur(this.viewport.scale);
3855
+ return xr(this.viewport.scale);
3750
3856
  }
3751
3857
  rotationHandleScreenPoint(e) {
3752
3858
  return this.imgToScreen(xe(e, this.rotationHandleGap()));
@@ -3765,7 +3871,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3765
3871
  n.x,
3766
3872
  n.y
3767
3873
  ],
3768
- stroke: pr,
3874
+ stroke: wr,
3769
3875
  strokeWidth: 1,
3770
3876
  listening: !1
3771
3877
  }), this.handleGroup.add(this.rotLineNode));
@@ -3780,7 +3886,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3780
3886
  }), e.rotation(n * 180 / Math.PI);
3781
3887
  }
3782
3888
  orientedHandleAngle(e) {
3783
- return dr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
3889
+ return Sr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
3784
3890
  }
3785
3891
  repositionOrientedHandles(e) {
3786
3892
  let t = this.orientedHandleAngle(e);
@@ -3802,13 +3908,13 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3802
3908
  for (let e of this.vertexNodes) e.destroy();
3803
3909
  for (let e of this.midNodes) e.destroy();
3804
3910
  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;
3805
- let e = ar(this.shapes, this.selected);
3911
+ let e = gr(this.shapes, this.selected);
3806
3912
  if (!e.length || e.length === 1 && e[0].type === L.POINT) return;
3807
- let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
3913
+ 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));
3808
3914
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
3809
3915
  let a = r ? this.orientedHandleAngle(r.points) : 0;
3810
- for (let e of t ? [] : B) {
3811
- let t = this.imgToScreen(i[B.indexOf(e)]), n = new A.Rect({
3916
+ for (let e of t ? [] : oe) {
3917
+ let t = this.imgToScreen(i[oe.indexOf(e)]), n = new A.Rect({
3812
3918
  x: t.x,
3813
3919
  y: t.y,
3814
3920
  width: 8,
@@ -3817,16 +3923,16 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3817
3923
  offsetY: 4,
3818
3924
  rotation: a * 180 / Math.PI,
3819
3925
  fill: "#ffffff",
3820
- stroke: pr,
3926
+ stroke: wr,
3821
3927
  strokeWidth: 1
3822
- }), r = wt(e, a);
3928
+ }), r = Pt(e, a);
3823
3929
  this.bindCursor(n, r), n.on("mousedown", (t) => {
3824
3930
  t.cancelBubble = !0, this.emitCursorHint(r), this.emitInteractionMode("resizing");
3825
- let n = ar(this.shapes, this.selected);
3931
+ let n = gr(this.shapes, this.selected);
3826
3932
  this.activeDrag = {
3827
3933
  kind: "resize",
3828
3934
  anchor: e,
3829
- box: V(n.flatMap((e) => e.points)),
3935
+ box: H(n.flatMap((e) => e.points)),
3830
3936
  shapes: n.map((e) => ({
3831
3937
  id: e.id,
3832
3938
  points: e.points
@@ -3839,7 +3945,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3839
3945
  radius: i * .8,
3840
3946
  fill: "#ffffff",
3841
3947
  opacity: .6,
3842
- stroke: pr,
3948
+ stroke: wr,
3843
3949
  strokeWidth: 1,
3844
3950
  visible: !1,
3845
3951
  listening: !1
@@ -3899,8 +4005,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3899
4005
  x: a.x,
3900
4006
  y: a.y,
3901
4007
  radius: i,
3902
- fill: o ? pr : "#ffffff",
3903
- stroke: o ? "#ffffff" : pr,
4008
+ fill: o ? wr : "#ffffff",
4009
+ stroke: o ? "#ffffff" : wr,
3904
4010
  strokeWidth: Math.max(1.5, i * .3)
3905
4011
  });
3906
4012
  this.bindCursor(s, "pointer"), s.on("mousedown", (t) => {
@@ -3925,7 +4031,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3925
4031
  y: r.y,
3926
4032
  radius: 6,
3927
4033
  fill: "#ffffff",
3928
- stroke: pr,
4034
+ stroke: wr,
3929
4035
  strokeWidth: 1.5
3930
4036
  });
3931
4037
  this.bindCursor(i, "grab"), i.on("mousedown", (e) => {
@@ -3944,12 +4050,12 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3944
4050
  this.layer.batchDraw();
3945
4051
  }
3946
4052
  beginMove(e, t) {
3947
- let n = rr(this.shapes, t, e);
4053
+ let n = mr(this.shapes, t, e);
3948
4054
  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));
3949
4055
  }
3950
4056
  repositionHandles(e) {
3951
- B.forEach((t, n) => {
3952
- let r = this.imgToScreen(se(t, e)), i = this.handleNodes[n];
4057
+ oe.forEach((t, n) => {
4058
+ let r = this.imgToScreen(U(t, e)), i = this.handleNodes[n];
3953
4059
  i && this.layoutResizeHandle(i, r, 0);
3954
4060
  }), this.setTransformerOutline(e);
3955
4061
  }
@@ -3986,7 +4092,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3986
4092
  let t = this.activeDrag;
3987
4093
  if (!t) return;
3988
4094
  this.applyCursor();
3989
- let n = er(this.shapes, t), { updates: r, box: i } = tr(t, e, n);
4095
+ let n = dr(this.shapes, t), { updates: r, box: i } = fr(t, e, n);
3990
4096
  for (let e of r) this.liveUpdateShape(e.id, e.points);
3991
4097
  if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
3992
4098
  n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
@@ -4013,18 +4119,18 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
4013
4119
  this.cb.onTransformPreview?.([]), this.drawTransformer();
4014
4120
  return;
4015
4121
  }
4016
- let { updates: n } = tr(e, t, er(this.shapes, e));
4122
+ let { updates: n } = fr(e, t, dr(this.shapes, e));
4017
4123
  this.commitTransformUpdates(n);
4018
4124
  }
4019
- }, gr = 2, _r = 58879, vr = 6725103;
4020
- function $(e) {
4021
- if (!e) return _r;
4125
+ }, Dr = 2, Or = 58879, kr = 6725103;
4126
+ function Ar(e) {
4127
+ if (!e) return Or;
4022
4128
  let t = e.replace("#", "");
4023
4129
  return Number.parseInt(t.length === 3 ? t.replace(/./g, "$&$&") : t, 16);
4024
4130
  }
4025
- var yr = class {
4131
+ var jr = class {
4026
4132
  constructor(e, t) {
4027
- 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 = Kn, 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 = gr, 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;
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 = nr, 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 = Dr, 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;
4028
4134
  }
4029
4135
  ev(e) {
4030
4136
  return {
@@ -4054,7 +4160,7 @@ var yr = class {
4054
4160
  }
4055
4161
  this.host.appendChild(this.app.canvas);
4056
4162
  let e = this.app.renderer.gl, t = e?.getParameter(e.MAX_TEXTURE_SIZE);
4057
- typeof t == "number" && t > 1 && (this.tileSize = Math.min(Kn, 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({
4163
+ typeof t == "number" && t > 1 && (this.tileSize = Math.min(nr, 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({
4058
4164
  mask: this.regionDimMaskG,
4059
4165
  inverse: !0
4060
4166
  }), 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) => {
@@ -4132,14 +4238,14 @@ var yr = class {
4132
4238
  };
4133
4239
  }
4134
4240
  async setImage(e, t, n) {
4135
- let r = ++this.imageLoadToken, i = await Ln(e);
4241
+ let r = ++this.imageLoadToken, i = await qn(e);
4136
4242
  if (this.destroyed || r !== this.imageLoadToken) return !0;
4137
4243
  if (!i) return this.imageWidth ||= t?.width ?? 800, this.imageHeight ||= t?.height ?? 600, !1;
4138
4244
  this.imageWidth = t?.width ?? i.naturalWidth, this.imageHeight = t?.height ?? i.naturalHeight;
4139
4245
  let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
4140
4246
  this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
4141
- for (let e of qn(i.naturalWidth, i.naturalHeight, this.tileSize)) {
4142
- let t = I.from(Jn(i, e));
4247
+ for (let e of rr(i.naturalWidth, i.naturalHeight, this.tileSize)) {
4248
+ let t = I.from(ir(i, e));
4143
4249
  t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
4144
4250
  let n = new te(t);
4145
4251
  n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
@@ -4198,7 +4304,7 @@ var yr = class {
4198
4304
  }
4199
4305
  setRegionOverlay(e) {
4200
4306
  if (this.region = e, this.regionDimMaskG.clear(), this.regionDimG.clear(), this.regionZoneMaskG.clear(), this.regionZoneG.clear(), this.regionOutlineG.clear(), !e) return;
4201
- let t = $(e.dim.color);
4307
+ let t = Ar(e.dim.color);
4202
4308
  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);
4203
4309
  this.regionDimG.rect(0, 0, this.imageWidth, this.imageHeight).fill({
4204
4310
  color: t,
@@ -4219,7 +4325,7 @@ var yr = class {
4219
4325
  }
4220
4326
  applyViewport(e) {
4221
4327
  let t = e.scale !== this.lastAppliedScale;
4222
- 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 ?? nr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
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 ?? pr(this.shapes, this.activeDrag)) : this.drawTransformer(), this.cb.onViewportChange?.();
4223
4329
  }
4224
4330
  fit() {
4225
4331
  if (!this.imageWidth || !this.imageHeight) return;
@@ -4255,7 +4361,7 @@ var yr = class {
4255
4361
  });
4256
4362
  }
4257
4363
  setShapes(e, t) {
4258
- this.shapes = ir(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
4364
+ this.shapes = hr(e), this.selected = t, !this.activeDrag && (this.drawShapes(), this.drawSelectionBorders(), this.drawTransformer());
4259
4365
  }
4260
4366
  setSelection(e) {
4261
4367
  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());
@@ -4278,13 +4384,13 @@ var yr = class {
4278
4384
  this.handleLayer.interactiveChildren = !e;
4279
4385
  }
4280
4386
  strokeW(e) {
4281
- return (e ? Ue(e, { strokeWidth: this.strokeSize }).strokeWidth : gr) / this.world.scale.x;
4387
+ return (e ? Ze(e, { strokeWidth: this.strokeSize }).strokeWidth : Dr) / this.world.scale.x;
4282
4388
  }
4283
4389
  pointRadius(e) {
4284
- return sr(e, this.strokeSize, this.world.scale.x);
4390
+ return vr(e, this.strokeSize, this.world.scale.x);
4285
4391
  }
4286
4392
  dashForShape(e) {
4287
- let t = Ue(e, { strokeWidth: this.strokeSize }).dash;
4393
+ let t = Ze(e, { strokeWidth: this.strokeSize }).dash;
4288
4394
  if (!t?.length) return null;
4289
4395
  let n = this.world.scale.x || 1;
4290
4396
  return [t[0] / n, (t[1] ?? t[0]) / n];
@@ -4293,10 +4399,10 @@ var yr = class {
4293
4399
  this.shapeLayer.removeChildren();
4294
4400
  for (let e of this.nodes.values()) e.destroy();
4295
4401
  this.nodes.clear();
4296
- for (let e of ae(this.shapes).filter(ne)) {
4402
+ for (let e of B(this.shapes).filter(ne)) {
4297
4403
  let t = new P();
4298
4404
  this.paintShape(t, e), t.eventMode = R(e) ? "static" : "none", t.cursor = void 0, R(e) && z(e) && (t.on("pointerover", () => {
4299
- !this.activeDrag && this.transformEnabled && this.emitCursorHint("grab");
4405
+ this.activeDrag || !this.transformEnabled || this.emitCursorHint(this.selected.includes(e.id) ? "grab" : Mt);
4300
4406
  }), t.on("pointerout", () => {
4301
4407
  this.activeDrag || this.emitCursorHint(null);
4302
4408
  })), t.on("pointerdown", (t) => {
@@ -4306,19 +4412,22 @@ var yr = class {
4306
4412
  }
4307
4413
  paintShape(e, t) {
4308
4414
  e.clear();
4309
- let n = Ue(t, { strokeWidth: this.strokeSize }), r = $(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
4415
+ let n = Ze(t, { strokeWidth: this.strokeSize }), r = Ar(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
4310
4416
  if (t.type === L.POINT) {
4311
- e.svg(Qn(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
4417
+ e.svg(lr(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
4312
4418
  let r = 1 / (this.world.scale.x || 1);
4313
4419
  e.scale.set(r, r), e.alpha = a;
4314
4420
  return;
4315
4421
  }
4316
4422
  if (n.fillVisible && t.type !== L.LINE) {
4317
4423
  let i = t.type === L.POLYGON ? De(t.points) : null;
4318
- if (i && i.length > 1) for (let t of i) e.poly(t.flatMap((e) => [e.x, e.y]), !0), e.fill({
4319
- color: r,
4320
- alpha: n.fillAlpha * a
4321
- });
4424
+ if (i && i.length > 1) for (let t of Pe(i)) {
4425
+ e.poly(t.outline.flatMap((e) => [e.x, e.y]), !0), e.fill({
4426
+ color: r,
4427
+ alpha: n.fillAlpha * a
4428
+ });
4429
+ for (let n of t.holes) e.poly(n.flatMap((e) => [e.x, e.y]), !0), e.cut();
4430
+ }
4322
4431
  else this.path(e, t), e.fill({
4323
4432
  color: r,
4324
4433
  alpha: n.fillAlpha * a
@@ -4330,7 +4439,7 @@ var yr = class {
4330
4439
  if (o) {
4331
4440
  t.style?.alternateColor && (this.path(e, t), e.stroke({
4332
4441
  width: i,
4333
- color: $(t.style.alternateColor),
4442
+ color: Ar(t.style.alternateColor),
4334
4443
  alpha: a
4335
4444
  })), this.dashedStrokeShape(e, t, i, r, a, o);
4336
4445
  return;
@@ -4349,11 +4458,11 @@ var yr = class {
4349
4458
  });
4350
4459
  }
4351
4460
  shapesIntersecting(e) {
4352
- return or(this.shapes, e);
4461
+ return _r(this.shapes, e);
4353
4462
  }
4354
4463
  shapesAt(e) {
4355
4464
  return this.shapes.filter((t) => {
4356
- let n = V(t.points);
4465
+ let n = H(t.points);
4357
4466
  return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
4358
4467
  }).map((e) => e.id);
4359
4468
  }
@@ -4386,16 +4495,16 @@ var yr = class {
4386
4495
  }, a = this.strokeW(i);
4387
4496
  r.alternateColor && (this.path(this.previewG, i), this.previewG.stroke({
4388
4497
  width: a,
4389
- color: $(r.alternateColor)
4498
+ color: Ar(r.alternateColor)
4390
4499
  }));
4391
4500
  let o = this.dashForShape(i);
4392
4501
  if (o) {
4393
- this.dashedStrokeShape(this.previewG, i, a, $(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
4502
+ this.dashedStrokeShape(this.previewG, i, a, Ar(r.color ?? "#00e5ff"), r.opacity ?? 1, o);
4394
4503
  return;
4395
4504
  }
4396
4505
  this.path(this.previewG, i), this.previewG.stroke({
4397
4506
  width: a,
4398
- color: $(r.color ?? "#00e5ff"),
4507
+ color: Ar(r.color ?? "#00e5ff"),
4399
4508
  alpha: r.opacity ?? 1
4400
4509
  });
4401
4510
  }
@@ -4417,12 +4526,12 @@ var yr = class {
4417
4526
  }, c = this.strokeW(s);
4418
4527
  n.alternateColor && (this.path(this.previewG, s), this.previewG.stroke({
4419
4528
  width: c,
4420
- color: $(n.alternateColor)
4529
+ color: Ar(n.alternateColor)
4421
4530
  }));
4422
4531
  let l = this.dashForShape(s);
4423
- if (l ? this.dashedStrokeShape(this.previewG, s, c, $(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
4532
+ if (l ? this.dashedStrokeShape(this.previewG, s, c, Ar(n.color ?? "#00e5ff"), n.opacity ?? 1, l) : (this.path(this.previewG, s), this.previewG.stroke({
4424
4533
  width: c,
4425
- color: $(n.color ?? "#00e5ff"),
4534
+ color: Ar(n.color ?? "#00e5ff"),
4426
4535
  alpha: n.opacity ?? 1
4427
4536
  })), !a) return;
4428
4537
  let u = new Set(i), d = 5 / this.world.scale.x, f = 6 / this.world.scale.x;
@@ -4436,15 +4545,15 @@ var yr = class {
4436
4545
  }
4437
4546
  previewScalarMask(e, t) {
4438
4547
  this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
4439
- let n = hn(e, t.length === 7 ? `${t}99` : t);
4548
+ let n = Tn(e, t.length === 7 ? `${t}99` : t);
4440
4549
  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;
4441
4550
  }
4442
4551
  previewMarquee(e, t) {
4443
4552
  this.ensurePreview(), this.marqueeG.clear();
4444
- 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 = $(Be);
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 = Ar(Je);
4445
4554
  this.marqueeG.rect(n, r, i, a).fill({
4446
4555
  color: o,
4447
- alpha: Ve
4556
+ alpha: Ye
4448
4557
  }).stroke({
4449
4558
  width: 1 / this.world.scale.x,
4450
4559
  color: o
@@ -4475,8 +4584,8 @@ var yr = class {
4475
4584
  o.y
4476
4585
  ], !1).stroke({
4477
4586
  width: i,
4478
- color: $(r.underlayColor)
4479
- }), this.strokeDashedPolyline(e, [n, o], !1, i, $(r.color), r.opacity, a);
4587
+ color: Ar(r.underlayColor)
4588
+ }), this.strokeDashedPolyline(e, [n, o], !1, i, Ar(r.color), r.opacity, a);
4480
4589
  };
4481
4590
  r(this.region.visibleOutline, t.visible), r(this.region.occludedOutline, t.occluded);
4482
4591
  }
@@ -4487,12 +4596,12 @@ var yr = class {
4487
4596
  return;
4488
4597
  }
4489
4598
  if (n === L.RECTANGLE) {
4490
- let t = V(r);
4599
+ let t = H(r);
4491
4600
  e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
4492
4601
  return;
4493
4602
  }
4494
4603
  if (n === L.ELLIPSE) {
4495
- let t = V(r);
4604
+ let t = H(r);
4496
4605
  e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
4497
4606
  return;
4498
4607
  }
@@ -4502,7 +4611,7 @@ var yr = class {
4502
4611
  dashedStrokeShape(e, t, n, r, i, a) {
4503
4612
  let { type: o, points: s } = t;
4504
4613
  if (o === L.RECTANGLE) {
4505
- let t = V(s);
4614
+ let t = H(s);
4506
4615
  this.strokeDashedPolyline(e, [
4507
4616
  {
4508
4617
  x: t.minX,
@@ -4524,7 +4633,7 @@ var yr = class {
4524
4633
  return;
4525
4634
  }
4526
4635
  if (o === L.ELLIPSE) {
4527
- let t = V(s), o = (t.minX + t.maxX) / 2, c = (t.minY + t.maxY) / 2, l = (t.maxX - t.minX) / 2, u = (t.maxY - t.minY) / 2, d = Array.from({ length: 96 }, (e, t) => {
4636
+ let t = H(s), o = (t.minX + t.maxX) / 2, c = (t.minY + t.maxY) / 2, l = (t.maxX - t.minX) / 2, u = (t.maxY - t.minY) / 2, d = Array.from({ length: 96 }, (e, t) => {
4528
4637
  let n = t / 96 * Math.PI * 2;
4529
4638
  return {
4530
4639
  x: o + Math.cos(n) * l,
@@ -4588,7 +4697,7 @@ var yr = class {
4588
4697
  let r = this.selectionBorderGfx[t];
4589
4698
  r.clear(), r.poly(this.selectionOutlinePoints(e, e.points).flatMap((e) => [e.x, e.y]), !0).stroke({
4590
4699
  width: n,
4591
- color: vr
4700
+ color: kr
4592
4701
  });
4593
4702
  });
4594
4703
  }
@@ -4599,12 +4708,12 @@ var yr = class {
4599
4708
  let a = this.selectionBorderGfx[r++];
4600
4709
  a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
4601
4710
  width: n,
4602
- color: vr
4711
+ color: kr
4603
4712
  }));
4604
4713
  }
4605
4714
  }
4606
4715
  selectionOutlinePoints(e, t) {
4607
- return lr(e, t, this.pointRadius(e));
4716
+ return br(e, t, this.pointRadius(e));
4608
4717
  }
4609
4718
  imgToScreen(e) {
4610
4719
  let t = this.world.toGlobal({
@@ -4633,7 +4742,7 @@ var yr = class {
4633
4742
  }));
4634
4743
  }
4635
4744
  rotationHandleGap() {
4636
- return ur(this.viewport.scale);
4745
+ return xr(this.viewport.scale);
4637
4746
  }
4638
4747
  rotationHandleScreenPoint(e) {
4639
4748
  return this.imgToScreen(xe(e, this.rotationHandleGap()));
@@ -4649,7 +4758,7 @@ var yr = class {
4649
4758
  e.position.set(t.x, t.y), e.rotation = n;
4650
4759
  }
4651
4760
  orientedHandleAngle(e) {
4652
- return dr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
4761
+ return Sr(this.imgToScreen(e[0]), this.imgToScreen(e[1]));
4653
4762
  }
4654
4763
  drawTransformer() {
4655
4764
  if (this.activeDrag) return;
@@ -4657,25 +4766,25 @@ var yr = class {
4657
4766
  for (let e of this.vertexNodes) e.destroy();
4658
4767
  for (let e of this.midNodes) e.destroy();
4659
4768
  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;
4660
- let e = ar(this.shapes, this.selected);
4769
+ let e = gr(this.shapes, this.selected);
4661
4770
  if (e.length === 0 || e.length === 1 && e[0].type === L.POINT) return;
4662
- let t = e.length === 1 && (e[0].type === L.POLYGON || e[0].type === L.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === L.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
4771
+ 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));
4663
4772
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
4664
4773
  let a = r ? this.orientedHandleAngle(r.points) : 0;
4665
- for (let e of t ? [] : B) {
4666
- let t = this.imgToScreen(i[B.indexOf(e)]), n = new P();
4774
+ for (let e of t ? [] : oe) {
4775
+ let t = this.imgToScreen(i[oe.indexOf(e)]), n = new P();
4667
4776
  n.rect(-4, -4, 8, 8).fill({ color: 16777215 }).stroke({
4668
4777
  width: 1,
4669
4778
  color: 2001125
4670
4779
  }), this.layoutResizeHandle(n, t, a), n.eventMode = "static";
4671
- let r = wt(e, a);
4780
+ let r = Pt(e, a);
4672
4781
  this.bindCursor(n, r), n.on("pointerdown", (t) => {
4673
4782
  t.stopPropagation(), this.emitCursorHint(r), this.emitInteractionMode("resizing");
4674
- let n = ar(this.shapes, this.selected);
4783
+ let n = gr(this.shapes, this.selected);
4675
4784
  this.activeDrag = {
4676
4785
  kind: "resize",
4677
4786
  anchor: e,
4678
- box: V(n.flatMap((e) => e.points)),
4787
+ box: H(n.flatMap((e) => e.points)),
4679
4788
  shapes: n.map((e) => ({
4680
4789
  id: e.id,
4681
4790
  points: e.points
@@ -4768,12 +4877,12 @@ var yr = class {
4768
4877
  }
4769
4878
  }
4770
4879
  beginMove(e, t) {
4771
- let n = rr(this.shapes, t, e);
4880
+ let n = mr(this.shapes, t, e);
4772
4881
  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));
4773
4882
  }
4774
4883
  repositionHandlesForBox(e) {
4775
- B.forEach((t, n) => {
4776
- let r = this.imgToScreen(se(t, e)), i = this.handleNodes[n];
4884
+ oe.forEach((t, n) => {
4885
+ let r = this.imgToScreen(U(t, e)), i = this.handleNodes[n];
4777
4886
  i && this.layoutResizeHandle(i, r, 0);
4778
4887
  }), this.setTransformerOutline(e);
4779
4888
  }
@@ -4836,7 +4945,7 @@ var yr = class {
4836
4945
  let t = this.activeDrag;
4837
4946
  if (!t) return;
4838
4947
  this.applyCursor();
4839
- let n = er(this.shapes, t), { updates: r, box: i } = tr(t, e, n);
4948
+ let n = dr(this.shapes, t), { updates: r, box: i } = fr(t, e, n);
4840
4949
  if (t.kind === "move") {
4841
4950
  let n = e.x - t.start.x, r = e.y - t.start.y;
4842
4951
  for (let e of t.shapes) {
@@ -4868,13 +4977,13 @@ var yr = class {
4868
4977
  this.cb.onTransformPreview?.([]), this.drawTransformer();
4869
4978
  return;
4870
4979
  }
4871
- let { updates: n } = tr(e, t, er(this.shapes, e));
4980
+ let { updates: n } = fr(e, t, dr(this.shapes, e));
4872
4981
  e.kind === "move" && this.resetMoveOffsets(), this.commitTransformUpdates(n);
4873
4982
  }
4874
4983
  };
4875
4984
  //#endregion
4876
4985
  //#region src/components/ShapeEditor/_state/useEngineLifecycle.ts
4877
- function br({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
4986
+ function Mr({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r }) {
4878
4987
  if (!r) return e !== null || n !== null ? { kind: "clear" } : { kind: "none" };
4879
4988
  let i = e !== t;
4880
4989
  return !i && n === r ? { kind: "none" } : {
@@ -4882,7 +4991,7 @@ function br({ currentDocId: e, documentId: t, loadedUrl: n, renderedImageUrl: r
4882
4991
  docChange: i
4883
4992
  };
4884
4993
  }
4885
- function xr({ 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 }) {
4994
+ function Nr({ 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 }) {
4886
4995
  let C = O(i);
4887
4996
  C.current = i;
4888
4997
  let w = O(r);
@@ -4893,12 +5002,12 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
4893
5002
  j.current = x, S(() => {
4894
5003
  let r = t.current;
4895
5004
  if (!r) return;
4896
- let i = !1, a = null, x = null, S = A.current(), O = e === "konva" ? new hr(r, S) : new yr(r, S);
5005
+ let i = !1, a = null, x = null, S = A.current(), O = e === "konva" ? new Er(r, S) : new jr(r, S);
4897
5006
  return n.current = O, (async () => {
4898
5007
  try {
4899
5008
  await O.init();
4900
5009
  } catch (e) {
4901
- i || b("error", Gn(e));
5010
+ i || b("error", tr(e));
4902
5011
  return;
4903
5012
  }
4904
5013
  if (i) return;
@@ -4909,7 +5018,7 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
4909
5018
  try {
4910
5019
  n = await O.setImage(e, u.current, d.current);
4911
5020
  } catch (t) {
4912
- !i && C.current === e && b("error", Gn(t));
5021
+ !i && C.current === e && b("error", tr(t));
4913
5022
  }
4914
5023
  if (i) return;
4915
5024
  if (n !== null) {
@@ -4920,7 +5029,7 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
4920
5029
  let r = k.current;
4921
5030
  r?.viewport && (r.imageUrl === T.current || o.current.keepZoomOnImageChange) ? O.applyViewport(r.viewport) : O.fit(), g(), y(!0);
4922
5031
  let a = () => C.current === e;
4923
- n ? a() && b("ready") : Hn(e).then((e) => {
5032
+ n ? a() && b("ready") : Qn(e).then((e) => {
4924
5033
  !i && a() && b("error", e);
4925
5034
  });
4926
5035
  }
@@ -4944,7 +5053,7 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
4944
5053
  }
4945
5054
  O.zoomAt(t.clientX - n.left, t.clientY - n.top, e(t.deltaY, r));
4946
5055
  }, O.dom.addEventListener("wheel", a, { passive: !1 }), x = (e) => {
4947
- if (e.preventDefault(), c.current === G.ASSISTANT_POINT && e.altKey) return;
5056
+ if (e.preventDefault(), c.current === J.ASSISTANT_POINT && e.altKey) return;
4948
5057
  let t = r.getBoundingClientRect(), n = e.clientX - t.left, i = e.clientY - t.top, a = O.viewport;
4949
5058
  j.current({
4950
5059
  x: n,
@@ -4964,7 +5073,7 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
4964
5073
  }, [e]), S(() => {
4965
5074
  let e = n.current;
4966
5075
  if (!e || !D.current) return;
4967
- let t = br({
5076
+ let t = Mr({
4968
5077
  currentDocId: E.current,
4969
5078
  documentId: r,
4970
5079
  loadedUrl: T.current,
@@ -4987,7 +5096,7 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
4987
5096
  try {
4988
5097
  i = await e.setImage(s, u.current, d.current);
4989
5098
  } catch (t) {
4990
- !c && n.current === e && b("error", Gn(t));
5099
+ !c && n.current === e && b("error", tr(t));
4991
5100
  return;
4992
5101
  }
4993
5102
  if (c || n.current !== e) return;
@@ -4997,7 +5106,7 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
4997
5106
  b("ready");
4998
5107
  return;
4999
5108
  }
5000
- Hn(s).then((e) => {
5109
+ Qn(s).then((e) => {
5001
5110
  c || b("error", e);
5002
5111
  });
5003
5112
  };
@@ -5016,19 +5125,19 @@ function xr({ backend: e, hostRef: t, engineRef: n, documentId: r, renderedImage
5016
5125
  }
5017
5126
  //#endregion
5018
5127
  //#region src/components/ShapeEditor/_state/useMinimapNavigation.ts
5019
- var Sr = .05, Cr = 20;
5020
- function wr(e) {
5128
+ var Pr = .05, Fr = 20;
5129
+ function Ir(e) {
5021
5130
  let { deltaY: t, deltaX: n, deltaMode: r } = e;
5022
5131
  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);
5023
5132
  }
5024
- function Tr(e) {
5133
+ function Lr(e) {
5025
5134
  let t = e.currentTarget.getBoundingClientRect();
5026
5135
  return {
5027
5136
  x: e.clientX - t.left,
5028
5137
  y: e.clientY - t.top
5029
5138
  };
5030
5139
  }
5031
- function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5140
+ function Rr({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5032
5141
  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(() => {
5033
5142
  let t = e.current;
5034
5143
  if (!t) return null;
@@ -5066,7 +5175,7 @@ function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5066
5175
  let n = e.current, r = d();
5067
5176
  if (!n || !r) return;
5068
5177
  t.preventDefault(), t.stopPropagation();
5069
- let a = Tr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
5178
+ let a = Lr(t), o = a.x >= r.x && a.x <= r.x + r.width && a.y >= r.y && a.y <= r.y + r.height ? {
5070
5179
  offsetX: a.x - r.x,
5071
5180
  offsetY: a.y - r.y
5072
5181
  } : {
@@ -5083,7 +5192,7 @@ function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5083
5192
  d
5084
5193
  ]), m = x((t) => {
5085
5194
  let n = i.current, r = e.current;
5086
- !n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(Tr(t), r.viewport.scale, n));
5195
+ !n || !r || n.pointerId !== t.pointerId || (t.preventDefault(), t.stopPropagation(), f(Lr(t), r.viewport.scale, n));
5087
5196
  }, [f, e]), h = x((e) => {
5088
5197
  let t = i.current;
5089
5198
  !t || t.pointerId !== e.pointerId || (i.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId));
@@ -5091,8 +5200,8 @@ function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5091
5200
  let r = e.current;
5092
5201
  if (!r || !n) return;
5093
5202
  t.preventDefault(), t.stopPropagation();
5094
- let i = wr(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(Sr, Math.min(Cr, s));
5095
- f(Tr(t), c);
5203
+ let i = Ir(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(Pr, Math.min(Fr, s));
5204
+ f(Lr(t), c);
5096
5205
  }, [
5097
5206
  f,
5098
5207
  e,
@@ -5129,14 +5238,14 @@ function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5129
5238
  }
5130
5239
  //#endregion
5131
5240
  //#region src/components/ShapeEditor/_state/useMinimapSync.ts
5132
- function Dr(e, t, n) {
5241
+ function zr(e, t, n) {
5133
5242
  if (!(!e || !n.length)) {
5134
5243
  if (t.type === L.POINT) {
5135
5244
  e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
5136
5245
  return;
5137
5246
  }
5138
5247
  if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
5139
- let r = V(n);
5248
+ let r = H(n);
5140
5249
  if (t.type === L.ELLIPSE) {
5141
5250
  e.setAttribute("cx", String((r.minX + r.maxX) / 2)), e.setAttribute("cy", String((r.minY + r.maxY) / 2)), e.setAttribute("rx", String((r.maxX - r.minX) / 2)), e.setAttribute("ry", String((r.maxY - r.minY) / 2));
5142
5251
  return;
@@ -5147,7 +5256,7 @@ function Dr(e, t, n) {
5147
5256
  e.setAttribute("points", n.map((e) => `${e.x},${e.y}`).join(" "));
5148
5257
  }
5149
5258
  }
5150
- function Or({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
5259
+ function Br({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRectRef: i, minimapSize: a, onViewportChangeRef: o }) {
5151
5260
  let s = O(/* @__PURE__ */ new Map());
5152
5261
  return {
5153
5262
  registerMinimapShape: x((e, t) => {
@@ -5156,13 +5265,13 @@ function Or({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
5156
5265
  applyMinimapPreview: x((e) => {
5157
5266
  let n = t.current.getShapes();
5158
5267
  if (!e.length) {
5159
- for (let e of n) Dr(s.current.get(e.id), e, e.points);
5268
+ for (let e of n) zr(s.current.get(e.id), e, e.points);
5160
5269
  return;
5161
5270
  }
5162
5271
  let r = new Map(n.map((e) => [e.id, e]));
5163
5272
  for (let t of e) {
5164
5273
  let e = r.get(t.id);
5165
- e && Dr(s.current.get(e.id), e, t.points);
5274
+ e && zr(s.current.get(e.id), e, t.points);
5166
5275
  }
5167
5276
  }, [t]),
5168
5277
  syncMinimap: x(() => {
@@ -5191,8 +5300,8 @@ function Or({ engineRef: e, docRef: t, overlayRef: n, zoomLabelRef: r, minimapRe
5191
5300
  }
5192
5301
  //#endregion
5193
5302
  //#region src/components/ShapeEditor/_state/useSelectionActions.ts
5194
- var kr = 12;
5195
- function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
5303
+ var Vr = 12;
5304
+ function Hr({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMergeSelection: i, clipboardDocumentId: a, clipboardScope: o }) {
5196
5305
  let s = O(0), c = O(!0), l = O(n), u = O(a), d = O(o);
5197
5306
  l.current = n, u.current = a, d.current = o, S(() => (c.current = !0, () => {
5198
5307
  c.current = !1;
@@ -5211,27 +5320,27 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5211
5320
  t
5212
5321
  ]), g = x(() => {
5213
5322
  let e = m();
5214
- e.length && (s.current = 0, vt(mt(e, a, o)));
5323
+ e.length && (s.current = 0, wt(bt(e, a, o)));
5215
5324
  }, [
5216
5325
  a,
5217
5326
  o,
5218
5327
  m
5219
- ]), _ = x(() => Y(o), [o]), v = x((t) => {
5328
+ ]), _ = x(() => Et(o), [o]), v = x((t) => {
5220
5329
  if (n) return;
5221
5330
  let i = a;
5222
- bt(o).then((n) => {
5331
+ Dt(o).then((n) => {
5223
5332
  if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
5224
5333
  let f, p, m = n.shapes.flatMap((e) => e.points);
5225
5334
  if (t && m.length) {
5226
- let e = V(m);
5335
+ let e = H(m);
5227
5336
  f = t.x - (e.minX + e.maxX) / 2, p = t.y - (e.minY + e.maxY) / 2;
5228
5337
  } else {
5229
- let e = !!n.documentId && n.documentId !== a, t = xt(s.current, e, kr);
5338
+ let e = !!n.documentId && n.documentId !== a, t = Ot(s.current, e, Vr);
5230
5339
  f = t.offset, s.current = t.nextPasteCount, p = f;
5231
5340
  }
5232
5341
  let h = n.shapes.map((e) => ({
5233
5342
  ...e,
5234
- id: oe(),
5343
+ id: ae(),
5235
5344
  points: e.points.map((e) => ({
5236
5345
  x: e.x + f,
5237
5346
  y: e.y + p
@@ -5249,10 +5358,10 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5249
5358
  if (n || !t.current.length) return;
5250
5359
  let i = m().map((e) => ({
5251
5360
  ...e,
5252
- id: oe(),
5361
+ id: ae(),
5253
5362
  points: e.points.map((e) => ({
5254
- x: e.x + kr,
5255
- y: e.y + kr
5363
+ x: e.x + Vr,
5364
+ y: e.y + Vr
5256
5365
  }))
5257
5366
  }));
5258
5367
  i.length && (e.create(i), r(i.map((e) => e.id)));
@@ -5310,12 +5419,12 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5310
5419
  if (n) return;
5311
5420
  let t = T();
5312
5421
  if (t.length < 2 || i && !i(t)) return;
5313
- let a = pn([], 1, fn(t));
5422
+ let a = Cn([], 1, Sn(t));
5314
5423
  if (!a) return;
5315
- let o = mn(a, 1);
5424
+ let o = wn(a, 1);
5316
5425
  if (!o.length) return;
5317
5426
  let s = t[0], c = o.map((e) => ({
5318
- id: oe(),
5427
+ id: ae(),
5319
5428
  type: L.POLYGON,
5320
5429
  points: e,
5321
5430
  style: s.style,
@@ -5333,12 +5442,12 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5333
5442
  }
5334
5443
  //#endregion
5335
5444
  //#region src/components/ShapeEditor/_state/useViewportControls.ts
5336
- function jr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
5445
+ function Ur({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBound: i, ready: a }) {
5337
5446
  let o = O(null), s = O(null), c = x(() => {
5338
5447
  o.current?.(), o.current = null;
5339
5448
  }, []), l = x((t, n = r) => {
5340
5449
  let i = e.current;
5341
- i && (c(), o.current = Yt(i.viewport, t, (e) => i.applyViewport(e), n));
5450
+ i && (c(), o.current = on(i.viewport, t, (e) => i.applyViewport(e), n));
5342
5451
  }, [
5343
5452
  c,
5344
5453
  r,
@@ -5346,14 +5455,14 @@ function jr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
5346
5455
  ]), u = x((t, n = r) => {
5347
5456
  let i = e.current;
5348
5457
  if (!i) return;
5349
- let a = qt(t, i.screenSize.w, i.screenSize.h);
5458
+ let a = rn(t, i.screenSize.w, i.screenSize.h);
5350
5459
  a && l(a, n);
5351
5460
  }, [
5352
5461
  l,
5353
5462
  r,
5354
5463
  e
5355
5464
  ]), d = x((e, n = r) => {
5356
- let i = Kt(t.getShapes().filter((t) => e.includes(t.id)));
5465
+ let i = nn(t.getShapes().filter((t) => e.includes(t.id)));
5357
5466
  i && u(i, n);
5358
5467
  }, [
5359
5468
  t,
@@ -5364,7 +5473,7 @@ function jr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
5364
5473
  if (!r.length) return;
5365
5474
  let i = e.current;
5366
5475
  if (!i) return;
5367
- let a = Jt(V(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
5476
+ let a = an(H(r.flatMap((e) => e.points)), i.screenSize.w, i.screenSize.h, 80);
5368
5477
  a && l(a);
5369
5478
  }, [
5370
5479
  t,
@@ -5405,126 +5514,128 @@ function jr({ engineRef: e, doc: t, selRef: n, zoomAnimationDuration: r, zoomBou
5405
5514
  }
5406
5515
  //#endregion
5407
5516
  //#region src/components/ShapeEditor/ShapeEditor.tsx
5408
- var Mr = "__draft_preview__", Nr = new Set([
5517
+ var Wr = "__draft_preview__", Gr = new Set([
5409
5518
  "copy",
5410
5519
  "selectAll",
5411
5520
  "clearSelection",
5412
5521
  "zoomToSelection"
5413
5522
  ]);
5414
- function Pr(e, t) {
5523
+ function Kr(e, t) {
5415
5524
  return e.length === t.length && e.every((e, n) => e === t[n]);
5416
5525
  }
5417
- function Fr({ 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, onIdleEscape: p, overrideShapeInteraction: m, defaultViewSettings: h, viewSettings: g, onViewSettingsChange: _, showMinimap: b = !0, minimapPosition: D = "bottom-left", showViewSettings: A = !0, getContextMenuItems: j, strings: M, canMergeSelection: N, brushSize: P = 20, zoomBound: F, zoomAnimationDuration: ee = 300, decorationShapes: te, regionMask: I, guideMask: re, maskPalette: z, overlayMarkers: ae, renderOverlayMarker: B, onOverlayMarkerClick: V, renderImageOverlay: se, getSelectionLabel: H, 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 }) {
5418
- let Te = O(null), U = O(null), Ee = O(null), De = O(null), W = O(null), Ae = `${C()}-minimap`, [K, je] = k(null), [Me, Pe] = k(!1), [Re, ze] = k(!1), [Be, Ve] = k(null), [He, Ue] = k({
5526
+ function qr({ 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 }) {
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, q] = k(null), [Le, Re] = k({
5419
5528
  active: !1,
5420
5529
  kind: "none",
5421
5530
  canUndo: !1,
5422
5531
  canRedo: !1
5423
- }), [We, Ge] = k(!0), [Ke, qe] = k(!1), Je = e?.id ?? "", Ye = e?.imageUrl ?? "", Xe = e?.displayImageUrl, Qe = e?.coordinateSize, $e = e?.initialShapes, et = e?.initialSelectedIds, tt = Xe ?? Ye, [nt, ot] = k("loading"), [ct, lt] = k(null), ut = x((e, t) => {
5424
- ot(e), lt(e === "error" ? t ?? null : null);
5425
- }, []), q = Tn({
5532
+ }), [ze, Be] = k(!0), [He, Ke] = 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, rt] = k(null), it = x((e, t) => {
5533
+ tt(e), rt(e === "error" ? t ?? null : null);
5534
+ }, []), Y = Fn({
5426
5535
  onShapesCreated: ve,
5427
5536
  onShapesUpdated: ye,
5428
5537
  onShapesDeleted: be
5429
- }), [dt, ft] = k([]), J = i ?? dt, pt = i !== void 0, mt = E(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), gt = O(mt);
5538
+ }), [ot, st] = k([]), X = i ?? ot, ct = i !== void 0, ft = E(() => new Map((ue ?? []).map((e) => [e.id, e])), [ue]), mt = O(ft);
5430
5539
  T(() => {
5431
- gt.current = mt;
5432
- }, [mt]);
5433
- let _t = O(He);
5434
- _t.current = He;
5435
- let vt = E(() => {
5436
- let e = Object.fromEntries(Object.entries(h ?? {}).filter(([, e]) => e !== void 0));
5540
+ mt.current = ft;
5541
+ }, [ft]);
5542
+ let ht = O(Le);
5543
+ ht.current = Le;
5544
+ let gt = E(() => {
5545
+ let e = Object.fromEntries(Object.entries(g ?? {}).filter(([, e]) => e !== void 0));
5437
5546
  return {
5438
- ...ke,
5547
+ ...Ie,
5439
5548
  ...e
5440
5549
  };
5441
- }, [h]), yt = O(vt);
5442
- yt.current = vt;
5443
- let [Y, bt] = k(() => yt.current), xt = x((e) => bt((t) => ({
5550
+ }, [g]), _t = O(gt);
5551
+ _t.current = gt;
5552
+ let [Z, vt] = k(() => _t.current), yt = x((e) => vt((t) => ({
5444
5553
  ...t,
5445
5554
  ...e
5446
- })), []), X = E(() => Oe(M), [M]);
5555
+ })), []), Q = E(() => Fe(N), [N]);
5447
5556
  S(() => {
5448
- g && bt((e) => {
5449
- let t = Object.entries(g).filter(([t, n]) => n !== void 0 && e[t] !== n);
5557
+ _ && vt((e) => {
5558
+ let t = Object.entries(_).filter(([t, n]) => n !== void 0 && e[t] !== n);
5450
5559
  return t.length ? {
5451
5560
  ...e,
5452
5561
  ...Object.fromEntries(t)
5453
5562
  } : e;
5454
5563
  });
5455
- }, [g]);
5456
- let St = O(_);
5457
- St.current = _;
5458
- let Ct = O(!1);
5564
+ }, [_]);
5565
+ let bt = O(b);
5566
+ bt.current = b;
5567
+ let St = O(!1);
5459
5568
  S(() => {
5460
- if (!Ct.current) {
5461
- Ct.current = !0;
5569
+ if (!St.current) {
5570
+ St.current = !0;
5462
5571
  return;
5463
5572
  }
5464
- St.current?.(Y);
5465
- }, [Y]);
5466
- let wt = E(() => !re || !z ? null : kt(re, z), [re, z]), Tt = E(() => wt?.toDataURL() ?? null, [wt]), Dt = E(() => !K || !I ? null : Vt(I, K.w, K.h), [K, I]), Ot = O(wt);
5467
- Ot.current = wt;
5468
- let At = O(Dt);
5469
- At.current = Dt;
5470
- let jt = O(r);
5471
- jt.current = r;
5472
- let Mt = O(K);
5473
- Mt.current = K;
5474
- let Nt = O(Qe);
5475
- Nt.current = Qe;
5476
- let Pt = O(Qe?.imageSize);
5477
- Pt.current = Qe?.imageSize;
5478
- let Ft = O(J);
5573
+ bt.current?.(Z);
5574
+ }, [Z]);
5575
+ let Ct = E(() => !z || !B ? null : zt(z, B), [z, B]), wt = E(() => Ct?.toDataURL() ?? null, [Ct]), Tt = E(() => !G || !re ? null : Xt(re, G.w, G.h), [G, re]), Et = O(Ct);
5576
+ Et.current = Ct;
5577
+ let Dt = O(Tt);
5578
+ Dt.current = Tt;
5579
+ let Ot = O(r);
5580
+ Ot.current = r;
5581
+ let kt = O(G);
5582
+ kt.current = G;
5583
+ let At = O(Xe);
5584
+ At.current = Xe;
5585
+ let jt = O(Xe?.imageSize);
5586
+ jt.current = Xe?.imageSize;
5587
+ let Mt = O(X);
5479
5588
  T(() => {
5480
- Ft.current = J;
5481
- }, [J]);
5482
- let It = O(a);
5483
- It.current = a;
5484
- let Lt = O(s);
5485
- Lt.current = s;
5486
- let Rt = O(c);
5487
- Rt.current = c;
5488
- let zt = O(P);
5489
- zt.current = P;
5490
- let Bt = O(Y.simplifyStrength);
5491
- Bt.current = Y.simplifyStrength;
5492
- let Z = !!l || !!d, Ht = O(Z);
5493
- Ht.current = Z;
5494
- let Ut = O(u);
5495
- Ut.current = u;
5496
- let Wt = O(d);
5497
- Wt.current = d;
5498
- let Gt = O(f);
5499
- Gt.current = f;
5500
- let Kt = O(m);
5501
- Kt.current = m;
5502
- let qt = O(q);
5503
- qt.current = q;
5504
- let Jt = O(!1), Yt = O(!1), Qt = O("idle"), $t = O(null), en = x(() => {
5505
- let e = U.current;
5589
+ Mt.current = X;
5590
+ }, [X]);
5591
+ let Nt = O(a);
5592
+ Nt.current = a;
5593
+ let Pt = O(s);
5594
+ Pt.current = s;
5595
+ let Ft = O(c);
5596
+ Ft.current = c;
5597
+ let Lt = O(F);
5598
+ Lt.current = F;
5599
+ let Rt = O(Z.simplifyStrength);
5600
+ Rt.current = Z.simplifyStrength;
5601
+ let $ = !!l || !!d, Bt = O($);
5602
+ Bt.current = $;
5603
+ let Vt = O(u);
5604
+ Vt.current = u;
5605
+ let Ht = O(d);
5606
+ Ht.current = d;
5607
+ let Ut = O(f);
5608
+ Ut.current = f;
5609
+ let Wt = O(p);
5610
+ Wt.current = p;
5611
+ let Gt = O(h);
5612
+ Gt.current = h;
5613
+ let Kt = O(Y);
5614
+ Kt.current = Y;
5615
+ let qt = O(!1), Jt = O(!1), Yt = O("idle"), Zt = O(null), Qt = x(() => {
5616
+ let e = W.current;
5506
5617
  if (!e) return;
5507
- let t = It.current, n = gt.current.get(t), r = _t.current;
5508
- e.setCursor(Et({
5618
+ let t = Nt.current, n = mt.current.get(t), r = ht.current;
5619
+ e.setCursor(It({
5509
5620
  tool: t,
5510
5621
  externalToolCursor: n?.cursor,
5511
- isSpacePressed: Jt.current,
5512
- interactionMode: Qt.current,
5513
- rendererCursorHint: $t.current,
5622
+ isSpacePressed: qt.current,
5623
+ interactionMode: Yt.current,
5624
+ rendererCursorHint: Zt.current,
5514
5625
  isPolygonDrawing: r.kind === "polygon" && r.active
5515
5626
  }));
5516
- }, []), tn = x((e) => {
5517
- Qt.current !== e && (Qt.current = e, en());
5518
- }, [en]), nn = x((e) => {
5519
- $t.current !== e && ($t.current = e, en());
5520
- }, [en]), rn = x((e) => {
5521
- let t = /* @__PURE__ */ new Set(), n = new Map(qt.current.getShapes().map((e) => [e.id, e]));
5627
+ }, []), $t = x((e) => {
5628
+ Yt.current !== e && (Yt.current = e, Qt());
5629
+ }, [Qt]), en = x((e) => {
5630
+ Zt.current !== e && (Zt.current = e, Qt());
5631
+ }, [Qt]), tn = x((e) => {
5632
+ let t = /* @__PURE__ */ new Set(), n = new Map(Kt.current.getShapes().map((e) => [e.id, e]));
5522
5633
  return e.filter((e) => {
5523
5634
  if (t.has(e)) return !1;
5524
5635
  t.add(e);
5525
5636
  let r = n.get(e);
5526
5637
  if (!r) return !1;
5527
- let i = Kt.current?.(r);
5638
+ let i = Gt.current?.(r);
5528
5639
  return R(i ? {
5529
5640
  ...r,
5530
5641
  interaction: {
@@ -5533,36 +5644,36 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5533
5644
  }
5534
5645
  } : r);
5535
5646
  });
5536
- }, []), an = x((e) => {
5537
- let t = rn(e);
5538
- Pr(Ft.current, t) || (pt || ft(t), U.current?.setSelection(t), ge?.(t));
5647
+ }, []), nn = x((e) => {
5648
+ let t = tn(e);
5649
+ Kr(Mt.current, t) || (ct || st(t), W.current?.setSelection(t), ge?.(t));
5539
5650
  }, [
5540
- rn,
5651
+ tn,
5541
5652
  ge,
5542
- pt
5543
- ]), on = O(an);
5544
- on.current = an;
5545
- let [sn, cn] = k(null), ln = x((e) => cn(e), []), un = O(ln);
5653
+ ct
5654
+ ]), rn = O(nn);
5655
+ rn.current = nn;
5656
+ let [an, on] = k(null), ln = x((e) => on(e), []), un = O(ln);
5546
5657
  un.current = ln;
5547
5658
  let dn = O(null);
5548
- dn.current = sn, S(() => {
5549
- if (!pt) return;
5550
- let e = rn(i);
5551
- Pr(i, e) || ge?.(e);
5659
+ dn.current = an, S(() => {
5660
+ if (!ct) return;
5661
+ let e = tn(i);
5662
+ Kr(i, e) || ge?.(e);
5552
5663
  }, [
5553
5664
  i,
5554
- q.shapes,
5555
- rn,
5665
+ Y.shapes,
5666
+ tn,
5556
5667
  ge,
5557
- pt
5668
+ ct
5558
5669
  ]);
5559
5670
  let fn = O(Ce);
5560
5671
  fn.current = Ce;
5561
- let { registerMinimapShape: pn, applyMinimapPreview: mn, syncMinimap: hn } = Or({
5562
- engineRef: U,
5563
- docRef: qt,
5672
+ let { registerMinimapShape: pn, applyMinimapPreview: mn, syncMinimap: hn } = Br({
5673
+ engineRef: W,
5674
+ docRef: Kt,
5564
5675
  overlayRef: De,
5565
- zoomLabelRef: W,
5676
+ zoomLabelRef: Oe,
5566
5677
  minimapRectRef: Ee,
5567
5678
  minimapSize: 204,
5568
5679
  onViewportChangeRef: fn
@@ -5570,248 +5681,249 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5570
5681
  _n.current = le;
5571
5682
  let vn = x((e, t) => {
5572
5683
  t ? gn.current.set(e, t) : gn.current.delete(e);
5573
- }, []), yn = O(null), [bn, xn] = k(null), Cn = x((e) => {
5684
+ }, []), yn = O(null), [bn, xn] = k(null), Sn = x((e) => {
5574
5685
  if (!e.length) return;
5575
- let t = new Map(qt.current.getShapes().map((e) => [e.id, e]));
5686
+ let t = new Map(Kt.current.getShapes().map((e) => [e.id, e]));
5576
5687
  yn.current && t.set(yn.current.id, yn.current);
5577
5688
  for (let { id: n, points: r } of e) {
5578
5689
  let e = gn.current.get(n), i = t.get(n);
5579
5690
  if (!e || !i) continue;
5580
- let a = rt(e, r);
5691
+ let a = lt(e, r);
5581
5692
  if (a) {
5582
- let e = it(i, r);
5583
- a.textContent = _n.current?.(e) ?? at(e);
5693
+ let e = ut(i, r);
5694
+ a.textContent = _n.current?.(e) ?? dt(e);
5584
5695
  }
5585
5696
  }
5586
- }, []), wn = x((e) => {
5587
- mn(e), Cn(e), we?.(e);
5697
+ }, []), Cn = x((e) => {
5698
+ mn(e), Sn(e), we?.(e);
5588
5699
  }, [
5589
5700
  mn,
5590
- Cn,
5701
+ Sn,
5591
5702
  we
5592
- ]), En = x((e) => {
5703
+ ]), wn = x((e) => {
5593
5704
  if (Se?.(e ? {
5594
5705
  ...e,
5595
- meta: Rt.current
5596
- } : null), !e || !Lt.current) {
5706
+ meta: Ft.current
5707
+ } : null), !e || !Pt.current) {
5597
5708
  yn.current && (yn.current = null, xn(null));
5598
5709
  return;
5599
5710
  }
5600
5711
  let t = {
5601
- id: Mr,
5712
+ id: Wr,
5602
5713
  type: e.type,
5603
5714
  points: e.points,
5604
- style: Lt.current,
5605
- meta: Rt.current
5715
+ style: Pt.current,
5716
+ meta: Ft.current
5606
5717
  }, n = yn.current !== null;
5607
- yn.current = t, n ? Cn([{
5608
- id: Mr,
5718
+ yn.current = t, n ? Sn([{
5719
+ id: Wr,
5609
5720
  points: e.points
5610
5721
  }]) : xn(t);
5611
- }, [Cn, Se]), Dn = x((e, t) => {
5612
- let n = Lt.current;
5613
- if (!n || Ht.current) return;
5614
- let r = oe();
5615
- qt.current.create({
5722
+ }, [Sn, Se]), Tn = x((e, t) => {
5723
+ let n = Pt.current;
5724
+ if (!n || Bt.current) return;
5725
+ let r = ae();
5726
+ Kt.current.create({
5616
5727
  id: r,
5617
5728
  type: e,
5618
5729
  points: t,
5619
5730
  style: n,
5620
5731
  meta: c
5621
- }), on.current([r]);
5622
- }, [c]), On = O(Dn);
5623
- On.current = Dn;
5624
- let kn = Sn({
5625
- toolRef: It,
5626
- selRef: Ft,
5627
- docRef: qt,
5628
- readOnlyRef: Ht,
5629
- draftRef: Lt,
5630
- brushSizeRef: zt,
5631
- simplifyEpsilonRef: Bt,
5732
+ }), rn.current([r]);
5733
+ }, [c]), En = O(Tn);
5734
+ En.current = Tn;
5735
+ let Dn = Mn({
5736
+ toolRef: Nt,
5737
+ selRef: Mt,
5738
+ docRef: Kt,
5739
+ readOnlyRef: Bt,
5740
+ draftRef: Pt,
5741
+ brushSizeRef: Lt,
5742
+ simplifyEpsilonRef: Rt,
5632
5743
  draftMeta: c,
5633
- engineRef: U,
5744
+ engineRef: W,
5634
5745
  onDrawSessionChange: x((e) => {
5635
- Ue(e), xe?.(e);
5746
+ Re(e), xe?.(e);
5636
5747
  }, [xe]),
5637
5748
  onDraftShapeChange: Se,
5638
- changeSelection: an,
5639
- createShape: Dn
5640
- }), An = O(kn);
5641
- An.current = kn;
5642
- let { reset: jn, undoSession: Mn, redoSession: Nn, canUndoSession: Pn, canRedoSession: In, hasDraftSession: Ln, hasDraftPoints: Rn, commitDraftSession: zn, setBrushScalarMode: Bn, getBrushScalarMode: Vn, hasBrushSession: Hn, commitBrush: Un, cancelBrush: Wn, beginBrushEditFromSelection: Gn, deleteDraftSelectedPoints: Kn, handleToolChange: qn, handleBrushSelectionChange: Jn } = kn, Yn = O(de);
5749
+ changeSelection: nn,
5750
+ createShape: Tn
5751
+ }), On = O(Dn);
5752
+ On.current = Dn;
5753
+ let { reset: kn, undoSession: An, redoSession: jn, canUndoSession: Nn, canRedoSession: Pn, hasDraftSession: In, hasDraftPoints: Ln, commitDraftSession: Rn, setBrushScalarMode: zn, getBrushScalarMode: Bn, hasBrushSession: Vn, commitBrush: Hn, cancelBrush: Un, beginBrushEditFromSelection: Wn, deleteDraftSelectedPoints: Kn, handleToolChange: qn, handleBrushSelectionChange: Jn } = Dn, Yn = O(de);
5643
5754
  Yn.current = de;
5644
- let Q = Zt({
5645
- docRef: qt,
5646
- draftRef: Lt,
5755
+ let Xn = cn({
5756
+ docRef: Kt,
5757
+ draftRef: Pt,
5647
5758
  draftMeta: c,
5648
- changeSelection: an,
5759
+ changeSelection: nn,
5649
5760
  assistantRef: Yn
5650
- }), Xn = O(Q);
5651
- Xn.current = Q;
5652
- let Zn = E(() => ht(Je), [Je]), { selectAll: Qn, clearSelection: $n, deleteSelection: er, copySelection: tr, canPaste: nr, paste: rr, duplicate: ir, bringToFront: ar, sendToBack: or, nudgeSelection: sr, getMergeTargets: cr, mergeSelection: lr } = Ar({
5653
- doc: q,
5654
- selRef: Ft,
5655
- effectiveReadOnly: Z,
5656
- changeSelection: an,
5657
- canMergeSelection: N,
5658
- clipboardDocumentId: Zn,
5659
- clipboardScope: t ?? Zn
5660
- }), { zoomToBounds: ur, zoomToShapes: dr, zoomToSelection: fr, zoomAtCenter: pr } = jr({
5661
- engineRef: U,
5662
- doc: q,
5663
- selRef: Ft,
5664
- zoomAnimationDuration: ee,
5665
- zoomBound: F,
5666
- ready: Re
5761
+ }), Zn = O(Xn);
5762
+ Zn.current = Xn;
5763
+ let Qn = E(() => xt(qe), [qe]), { selectAll: $n, clearSelection: er, deleteSelection: tr, copySelection: nr, canPaste: rr, paste: ir, duplicate: ar, bringToFront: or, sendToBack: sr, nudgeSelection: cr, getMergeTargets: lr, mergeSelection: ur } = Hr({
5764
+ doc: Y,
5765
+ selRef: Mt,
5766
+ effectiveReadOnly: $,
5767
+ changeSelection: nn,
5768
+ canMergeSelection: P,
5769
+ clipboardDocumentId: Qn,
5770
+ clipboardScope: t ?? Qn
5771
+ }), { zoomToBounds: dr, zoomToShapes: fr, zoomToSelection: pr, zoomAtCenter: mr } = Ur({
5772
+ engineRef: W,
5773
+ doc: Y,
5774
+ selRef: Mt,
5775
+ zoomAnimationDuration: te,
5776
+ zoomBound: ee,
5777
+ ready: K
5667
5778
  });
5668
5779
  w(pe, () => ({
5669
5780
  previewRegionMask: (e) => {
5670
- let t = Mt.current;
5781
+ let t = kt.current;
5671
5782
  if (!t) return;
5672
- let n = e ? Vt(e, t.w, t.h) : At.current;
5673
- U.current?.setRegionOverlay(mr.current.showRegionMask ? n : null);
5783
+ let n = e ? Xt(e, t.w, t.h) : Dt.current;
5784
+ W.current?.setRegionOverlay(hr.current.showRegionMask ? n : null);
5674
5785
  },
5675
5786
  undo: () => {
5676
- Mn() || q.undo();
5787
+ An() || Y.undo();
5677
5788
  },
5678
5789
  redo: () => {
5679
- Nn() || q.redo();
5790
+ jn() || Y.redo();
5680
5791
  },
5681
- canUndo: () => Pn() || q.canUndo(),
5682
- canRedo: () => In() || q.canRedo(),
5683
- undoSession: Mn,
5684
- redoSession: Nn,
5685
- canUndoSession: Pn,
5686
- canRedoSession: In,
5687
- hasDraftSession: Ln,
5688
- cancelDraftSession: jn,
5689
- commitDraftSession: zn,
5690
- setSelection: an,
5792
+ canUndo: () => Nn() || Y.canUndo(),
5793
+ canRedo: () => Pn() || Y.canRedo(),
5794
+ undoSession: An,
5795
+ redoSession: jn,
5796
+ canUndoSession: Nn,
5797
+ canRedoSession: Pn,
5798
+ hasDraftSession: In,
5799
+ cancelDraftSession: kn,
5800
+ commitDraftSession: Rn,
5801
+ setSelection: nn,
5691
5802
  createShapes: (e) => {
5692
- e.length && (q.create(e), an(e.map((e) => e.id)));
5803
+ e.length && (Y.create(e), nn(e.map((e) => e.id)));
5693
5804
  },
5694
- updateShapes: q.update,
5695
- deleteShapes: q.remove,
5696
- getShapes: q.getShapes,
5697
- selectAll: Qn,
5698
- clearSelection: $n,
5699
- deleteSelection: er,
5700
- copySelection: tr,
5701
- paste: rr,
5702
- duplicate: ir,
5703
- bringToFront: ar,
5704
- sendToBack: or,
5705
- zoomFit: () => U.current?.fit(),
5706
- zoom100: () => U.current?.zoom100(),
5805
+ updateShapes: Y.update,
5806
+ deleteShapes: Y.remove,
5807
+ getShapes: Y.getShapes,
5808
+ selectAll: $n,
5809
+ clearSelection: er,
5810
+ deleteSelection: tr,
5811
+ copySelection: nr,
5812
+ paste: ir,
5813
+ duplicate: ar,
5814
+ bringToFront: or,
5815
+ sendToBack: sr,
5816
+ zoomFit: () => W.current?.fit(),
5817
+ zoom100: () => W.current?.zoom100(),
5707
5818
  zoomIn: () => {
5708
- let e = U.current;
5819
+ let e = W.current;
5709
5820
  if (!e) return;
5710
5821
  let { w: t, h: n } = e.screenSize;
5711
5822
  e.zoomAt(t / 2, n / 2, 1.2);
5712
5823
  },
5713
5824
  zoomOut: () => {
5714
- let e = U.current;
5825
+ let e = W.current;
5715
5826
  if (!e) return;
5716
5827
  let { w: t, h: n } = e.screenSize;
5717
5828
  e.zoomAt(t / 2, n / 2, 1 / 1.2);
5718
5829
  },
5719
- zoomToSelection: fr,
5720
- zoomToShapes: dr,
5721
- zoomToBounds: ur,
5830
+ zoomToSelection: pr,
5831
+ zoomToShapes: fr,
5832
+ zoomToBounds: dr,
5722
5833
  brush: {
5723
- setScalarMode: Bn,
5724
- getScalarMode: Vn,
5725
- hasSession: Hn,
5726
- commit: Un,
5727
- cancel: Wn,
5728
- beginEditFromSelection: Gn
5834
+ setScalarMode: zn,
5835
+ getScalarMode: Bn,
5836
+ hasSession: Vn,
5837
+ commit: Hn,
5838
+ cancel: Un,
5839
+ beginEditFromSelection: Wn
5729
5840
  }
5730
5841
  }), [
5731
- q,
5732
- an,
5733
- Mn,
5734
- Nn,
5735
- zn,
5842
+ Y,
5843
+ nn,
5844
+ An,
5736
5845
  jn,
5846
+ Rn,
5847
+ kn,
5848
+ Hn,
5737
5849
  Un,
5738
- Wn,
5739
- Qn,
5740
5850
  $n,
5741
5851
  er,
5742
5852
  tr,
5743
- rr,
5853
+ nr,
5744
5854
  ir,
5745
5855
  ar,
5746
5856
  or,
5857
+ sr,
5858
+ pr,
5747
5859
  fr,
5748
5860
  dr,
5749
- ur,
5861
+ zn,
5750
5862
  Bn,
5751
5863
  Vn,
5752
- Hn,
5753
- Gn
5864
+ Wn
5754
5865
  ]);
5755
- let mr = O(Y);
5756
- mr.current = Y;
5757
- let hr = x(() => Xt({
5758
- engineRef: U,
5759
- toolRef: It,
5760
- externalToolMapRef: gt,
5761
- spaceRef: Jt,
5762
- shiftRef: Yt,
5763
- docRef: qt,
5764
- selRef: Ft,
5765
- draftRef: Lt,
5766
- readOnlyRef: Ht,
5767
- disableMarqueeRef: Ut,
5768
- lockedRef: Wt,
5769
- onLockedInteraction: () => Gt.current?.(),
5770
- createRef: On,
5771
- selectRef: on,
5866
+ let hr = O(Z);
5867
+ hr.current = Z;
5868
+ let gr = x(() => sn({
5869
+ engineRef: W,
5870
+ toolRef: Nt,
5871
+ externalToolMapRef: mt,
5872
+ spaceRef: qt,
5873
+ shiftRef: Jt,
5874
+ docRef: Kt,
5875
+ selRef: Mt,
5876
+ draftRef: Pt,
5877
+ readOnlyRef: Bt,
5878
+ disableMarqueeRef: Vt,
5879
+ lockedRef: Ht,
5880
+ onLockedInteraction: () => Ut.current?.(),
5881
+ onDrawAttemptWithoutDraft: () => Wt.current?.(),
5882
+ createRef: En,
5883
+ selectRef: rn,
5772
5884
  enterEditRef: un,
5773
5885
  editingIdRef: dn,
5774
- drawSessionRef: An,
5775
- assistantRef: Xn,
5776
- setCursorHint: nn,
5777
- setInteractionMode: tn,
5886
+ drawSessionRef: On,
5887
+ assistantRef: Zn,
5888
+ setCursorHint: en,
5889
+ setInteractionMode: $t,
5778
5890
  syncMinimap: hn,
5779
- onTransformPreview: wn,
5780
- onDrawPreview: En
5891
+ onTransformPreview: Cn,
5892
+ onDrawPreview: wn
5781
5893
  }), [
5782
- nn,
5783
- tn,
5894
+ en,
5895
+ $t,
5784
5896
  hn,
5785
- wn,
5786
- En
5787
- ]), gr = O([]);
5788
- xr({
5897
+ Cn,
5898
+ wn
5899
+ ]), _r = O([]);
5900
+ Nr({
5789
5901
  backend: me,
5790
5902
  hostRef: Te,
5791
- engineRef: U,
5792
- documentId: Je,
5793
- renderedImageUrl: tt,
5794
- makeCallbacks: hr,
5795
- viewRef: mr,
5796
- readOnlyRef: Ht,
5797
- toolRef: It,
5798
- renderShapesRef: gr,
5799
- coordinateSizeRef: Nt,
5800
- imageSizeRef: Pt,
5801
- selRef: Ft,
5802
- maskCanvasRef: Ot,
5803
- regionOverlayRef: At,
5804
- dimmedRef: jt,
5903
+ engineRef: W,
5904
+ documentId: qe,
5905
+ renderedImageUrl: $e,
5906
+ makeCallbacks: gr,
5907
+ viewRef: hr,
5908
+ readOnlyRef: Bt,
5909
+ toolRef: Nt,
5910
+ renderShapesRef: _r,
5911
+ coordinateSizeRef: At,
5912
+ imageSizeRef: jt,
5913
+ selRef: Mt,
5914
+ maskCanvasRef: Et,
5915
+ regionOverlayRef: Dt,
5916
+ dimmedRef: Ot,
5805
5917
  syncMinimap: hn,
5806
- setImage: je,
5807
- setImageVisible: Pe,
5808
- setReady: ze,
5809
- setImageStatus: ut,
5810
- onContextMenuRequest: Ve
5918
+ setImage: Ae,
5919
+ setImageVisible: Me,
5920
+ setReady: Ne,
5921
+ setImageStatus: it,
5922
+ onContextMenuRequest: q
5811
5923
  });
5812
- let _r = E(() => {
5813
- let e = m ? q.shapes.map((e) => {
5814
- let t = m(e);
5924
+ let vr = E(() => {
5925
+ let e = h ? Y.shapes.map((e) => {
5926
+ let t = h(e);
5815
5927
  return t ? {
5816
5928
  ...e,
5817
5929
  interaction: {
@@ -5819,8 +5931,8 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5819
5931
  ...t
5820
5932
  }
5821
5933
  } : e;
5822
- }) : q.shapes;
5823
- return te?.length ? [...te.map((e) => ({
5934
+ }) : Y.shapes;
5935
+ return I?.length ? [...I.map((e) => ({
5824
5936
  ...e,
5825
5937
  interaction: {
5826
5938
  ...e.interaction,
@@ -5831,343 +5943,343 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5831
5943
  }
5832
5944
  })), ...e] : e;
5833
5945
  }, [
5834
- q.shapes,
5835
- m,
5836
- te
5946
+ Y.shapes,
5947
+ h,
5948
+ I
5837
5949
  ]);
5838
- gr.current = _r, S(() => {
5839
- U.current?.setShapes(_r, Ft.current), hn();
5840
- }, [_r, hn]), S(() => {
5841
- U.current?.setSelection(J);
5842
- }, [J]), S(() => {
5843
- U.current?.setEditing(sn);
5844
- }, [sn, Re]);
5845
- let vr = O(_e);
5846
- vr.current = _e, S(() => {
5847
- vr.current?.(sn);
5848
- }, [sn]), S(() => {
5849
- cn(null);
5950
+ _r.current = vr, S(() => {
5951
+ W.current?.setShapes(vr, Mt.current), hn();
5952
+ }, [vr, hn]), S(() => {
5953
+ W.current?.setSelection(X);
5954
+ }, [X]), S(() => {
5955
+ W.current?.setEditing(an);
5956
+ }, [an, K]);
5957
+ let yr = O(_e);
5958
+ yr.current = _e, S(() => {
5959
+ yr.current?.(an);
5960
+ }, [an]), S(() => {
5961
+ on(null);
5850
5962
  }, [a]), S(() => {
5851
- sn && (J.length !== 1 || J[0] !== sn) && cn(null);
5852
- }, [J, sn]), S(() => {
5853
- let e = U.current;
5854
- e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing), hn());
5963
+ an && (X.length !== 1 || X[0] !== an) && on(null);
5964
+ }, [X, an]), S(() => {
5965
+ let e = W.current;
5966
+ e && (e.setFilter(Z.brightness, Z.contrast), e.setRenderDefaults({ strokeWidth: Z.strokeSize }), e.setImageSmoothing(Z.imageSmoothing), hn());
5855
5967
  }, [
5856
- Y.brightness,
5857
- Y.contrast,
5858
- Y.strokeSize,
5859
- Y.imageSmoothing,
5968
+ Z.brightness,
5969
+ Z.contrast,
5970
+ Z.strokeSize,
5971
+ Z.imageSmoothing,
5860
5972
  hn
5861
5973
  ]), T(() => {
5862
- Re && U.current?.setOverlays(Y.showGuide ? wt : null, Y.showRegionMask ? Dt : null, r);
5974
+ K && W.current?.setOverlays(Z.showGuide ? Ct : null, Z.showRegionMask ? Tt : null, r);
5863
5975
  }, [
5864
- Re,
5865
- wt,
5866
- Dt,
5867
- Y.showGuide,
5868
- Y.showRegionMask,
5976
+ K,
5977
+ Ct,
5978
+ Tt,
5979
+ Z.showGuide,
5980
+ Z.showRegionMask,
5869
5981
  r
5870
5982
  ]), S(() => {
5871
- !Re || !K || hn();
5983
+ !K || !G || hn();
5872
5984
  }, [
5873
- Re,
5874
5985
  K,
5875
- Tt,
5876
- Y.showGuide,
5877
- Y.showRegionMask,
5878
- I,
5986
+ G,
5987
+ wt,
5988
+ Z.showGuide,
5989
+ Z.showRegionMask,
5990
+ re,
5879
5991
  hn
5880
5992
  ]), S(() => {
5881
- Re && U.current?.setTransformEnabled(!Z && a !== G.BRUSH);
5993
+ K && W.current?.setTransformEnabled(!$ && a !== J.BRUSH);
5882
5994
  }, [
5883
- Z,
5884
- Re,
5995
+ $,
5996
+ K,
5885
5997
  a
5886
5998
  ]), S(() => {
5887
- qn(a, gt.current.has(a));
5999
+ qn(a, mt.current.has(a));
5888
6000
  }, [a, qn]);
5889
- let $ = Q.finalize;
6001
+ let br = Xn.finalize;
5890
6002
  S(() => {
5891
- $();
5892
- }, [a, $]), S(() => {
5893
- Qt.current = "idle", $t.current = null, en();
6003
+ br();
6004
+ }, [a, br]), S(() => {
6005
+ Yt.current = "idle", Zt.current = null, Qt();
5894
6006
  }, [
5895
6007
  a,
5896
6008
  me,
5897
- en
6009
+ Qt
5898
6010
  ]), S(() => {
5899
- Jn(J, Z);
6011
+ Jn(X, $);
5900
6012
  }, [
5901
- J,
6013
+ X,
5902
6014
  a,
5903
- Z,
6015
+ $,
5904
6016
  Jn
5905
6017
  ]), S(() => {
5906
- Re && en();
6018
+ K && Qt();
5907
6019
  }, [
5908
6020
  a,
5909
- He,
5910
- mt,
5911
- Re,
5912
- en
6021
+ Le,
6022
+ ft,
6023
+ K,
6024
+ Qt
5913
6025
  ]);
5914
- let yr = O(et);
5915
- yr.current = et;
5916
- let br = e !== null, Sr = O(null);
6026
+ let xr = O(Qe);
6027
+ xr.current = Qe;
6028
+ let Sr = e !== null, Cr = O(null);
5917
6029
  S(() => {
5918
- let e = br ? Je : null;
5919
- Sr.current !== e && (Sr.current = e, Ve(null), cn(null), Qt.current = "idle", $t.current = null, q.reset(br ? $e ?? [] : []), an(br ? yr.current ?? [] : []), jn(), $(), en());
6030
+ let e = Sr ? qe : null;
6031
+ Cr.current !== e && (Cr.current = e, q(null), on(null), Yt.current = "idle", Zt.current = null, Y.reset(Sr ? Ze ?? [] : []), nn(Sr ? xr.current ?? [] : []), kn(), br(), Qt());
5920
6032
  }, [
6033
+ Sr,
6034
+ qe,
6035
+ Ze,
6036
+ Y.reset,
6037
+ nn,
6038
+ kn,
5921
6039
  br,
5922
- Je,
5923
- $e,
5924
- q.reset,
5925
- an,
5926
- jn,
5927
- $,
5928
- en
6040
+ Qt
5929
6041
  ]);
5930
- let Cr = x(() => {
6042
+ let wr = x(() => {
5931
6043
  let e = dn.current;
5932
- if (!e || Z) return !1;
5933
- let t = U.current, n = new Set(t?.getVertexSelection() ?? []);
6044
+ if (!e || $) return !1;
6045
+ let t = W.current, n = new Set(t?.getVertexSelection() ?? []);
5934
6046
  if (!n.size) return !1;
5935
- let r = qt.current.getShapes().find((t) => t.id === e);
6047
+ let r = Kt.current.getShapes().find((t) => t.id === e);
5936
6048
  if (!r) return !1;
5937
6049
  let i = r.points.filter((e, t) => !n.has(t)), a = r.type === L.LINE ? 2 : 3;
5938
- return i.length < a ? !1 : (qt.current.update([{
6050
+ return i.length < a ? !1 : (Kt.current.update([{
5939
6051
  ...r,
5940
6052
  points: i
5941
6053
  }]), t?.setVertexSelection([]), !0);
5942
- }, [Z]);
5943
- Fn({
6054
+ }, [$]);
6055
+ Gn({
5944
6056
  keymap: fe,
5945
6057
  hostRef: Te,
5946
6058
  actions: {
5947
6059
  undo: () => {
5948
- Z || Mn() || q.undo();
6060
+ $ || An() || Y.undo();
5949
6061
  },
5950
6062
  redo: () => {
5951
- Z || Nn() || q.redo();
6063
+ $ || jn() || Y.redo();
5952
6064
  },
5953
- selectAll: Qn,
5954
- copy: tr,
6065
+ selectAll: $n,
6066
+ copy: nr,
5955
6067
  cut: () => {
5956
- tr(), er();
6068
+ nr(), tr();
5957
6069
  },
5958
- paste: rr,
5959
- duplicate: ir,
6070
+ paste: ir,
6071
+ duplicate: ar,
5960
6072
  delete: () => {
5961
- Rn() && Kn() || Cr() || er();
6073
+ Ln() && Kn() || wr() || tr();
5962
6074
  },
5963
6075
  cancel: () => {
5964
- let e = gt.current.get(It.current);
6076
+ let e = mt.current.get(Nt.current);
5965
6077
  if (!(e?.onCancel && e.onCancel() !== !1)) {
5966
- if (Q.isActive()) {
5967
- Q.cancel();
6078
+ if (Xn.isActive()) {
6079
+ Xn.cancel();
5968
6080
  return;
5969
6081
  }
5970
- if (Ln()) {
5971
- jn();
6082
+ if (In()) {
6083
+ kn();
5972
6084
  return;
5973
6085
  }
5974
- if (sn) {
5975
- cn(null);
6086
+ if (an) {
6087
+ on(null);
5976
6088
  return;
5977
6089
  }
5978
- if (Ft.current.length) {
5979
- $n();
6090
+ if (Mt.current.length) {
6091
+ er();
5980
6092
  return;
5981
6093
  }
5982
- p?.();
6094
+ m?.();
5983
6095
  }
5984
6096
  },
5985
6097
  commitDraft: () => {
5986
- if (Q.isActive()) {
5987
- Q.finalize();
6098
+ if (Xn.isActive()) {
6099
+ Xn.finalize();
5988
6100
  return;
5989
6101
  }
5990
- if (Ln()) {
5991
- zn();
6102
+ if (In()) {
6103
+ Rn();
5992
6104
  return;
5993
6105
  }
5994
- if (Z) return;
5995
- if (sn) {
5996
- cn(null);
6106
+ if ($) return;
6107
+ if (an) {
6108
+ on(null);
5997
6109
  return;
5998
6110
  }
5999
- let e = Ft.current;
6111
+ let e = Mt.current;
6000
6112
  if (e.length !== 1) return;
6001
- let t = qt.current.getShapes().find((t) => t.id === e[0]);
6002
- t && (t.type === L.POLYGON || t.type === L.LINE) && t.interaction?.editable !== !1 && !t.readOnly && cn(e[0]);
6113
+ let t = Kt.current.getShapes().find((t) => t.id === e[0]);
6114
+ t && (t.type === L.POLYGON || t.type === L.LINE) && t.interaction?.editable !== !1 && !t.readOnly && on(e[0]);
6003
6115
  },
6004
- bringToFront: ar,
6005
- sendToBack: or,
6006
- zoomIn: () => pr(1.2),
6007
- zoomOut: () => pr(1 / 1.2),
6008
- zoom100: () => U.current?.zoom100(),
6009
- zoomFit: () => U.current?.fit(),
6010
- toggleMinimap: () => Ge((e) => !e),
6011
- toggleCursorGuide: () => bt((e) => ({
6116
+ bringToFront: or,
6117
+ sendToBack: sr,
6118
+ zoomIn: () => mr(1.2),
6119
+ zoomOut: () => mr(1 / 1.2),
6120
+ zoom100: () => W.current?.zoom100(),
6121
+ zoomFit: () => W.current?.fit(),
6122
+ toggleMinimap: () => Be((e) => !e),
6123
+ toggleCursorGuide: () => vt((e) => ({
6012
6124
  ...e,
6013
6125
  showCursorGuide: !e.showCursorGuide
6014
6126
  })),
6015
- togglePixelation: () => bt((e) => ({
6127
+ togglePixelation: () => vt((e) => ({
6016
6128
  ...e,
6017
6129
  imageSmoothing: !e.imageSmoothing
6018
6130
  })),
6019
- selectTool: () => he?.(G.SELECT),
6020
- rectangleTool: () => he?.(G.RECTANGLE),
6021
- rotatedRectangleTool: () => he?.(G.ROTATED_RECTANGLE),
6022
- circleTool: () => he?.(G.CIRCLE),
6023
- polygonTool: () => he?.(G.POLYGON),
6024
- pathTool: () => he?.(G.PATH),
6025
- brushTool: () => he?.(G.BRUSH),
6026
- pointTool: () => he?.(G.POINT)
6131
+ selectTool: () => he?.(J.SELECT),
6132
+ rectangleTool: () => he?.(J.RECTANGLE),
6133
+ rotatedRectangleTool: () => he?.(J.ROTATED_RECTANGLE),
6134
+ circleTool: () => he?.(J.CIRCLE),
6135
+ polygonTool: () => he?.(J.POLYGON),
6136
+ pathTool: () => he?.(J.PATH),
6137
+ brushTool: () => he?.(J.BRUSH),
6138
+ pointTool: () => he?.(J.POINT)
6027
6139
  },
6028
- spaceRef: Jt,
6029
- shiftRef: Yt,
6140
+ spaceRef: qt,
6141
+ shiftRef: Jt,
6030
6142
  onSpaceDown: () => {
6031
- U.current?.setPanMode(!0), en();
6143
+ W.current?.setPanMode(!0), Qt();
6032
6144
  },
6033
6145
  onSpaceUp: () => {
6034
- U.current?.setPanMode(!1), Qt.current === "panning" ? tn("idle") : en();
6146
+ W.current?.setPanMode(!1), Yt.current === "panning" ? $t("idle") : Qt();
6035
6147
  },
6036
- nudge: sr
6148
+ nudge: cr
6037
6149
  });
6038
- let wr = E(() => _r.filter((e) => J.includes(e.id) && ne(e)), [_r, J]), Tr = E(() => bn ? [...wr, bn] : wr, [wr, bn]), Dr = J.length > 0, kr = q.shapes.some((e) => J.includes(e.id) && ie(e)), Fr = !Z && J.length === 1 && (() => {
6039
- let e = q.shapes.find((e) => e.id === J[0]);
6150
+ let Tr = E(() => vr.filter((e) => X.includes(e.id) && ne(e)), [vr, X]), Er = E(() => bn ? [...Tr, bn] : Tr, [Tr, bn]), Dr = X.length > 0, Or = Y.shapes.some((e) => X.includes(e.id) && ie(e)), kr = !$ && X.length === 1 && (() => {
6151
+ let e = Y.shapes.find((e) => e.id === X[0]);
6040
6152
  return !!e && (e.type === L.POLYGON || e.type === L.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
6041
- })(), Ir = cr(), Lr = Z || Ir.length < 2 || (N ? !N(Ir) : !1), Rr = !!de && !Z, zr = Rr && J.length === 1 ? (() => {
6042
- let e = q.shapes.find((e) => e.id === J[0]);
6153
+ })(), Ar = lr(), jr = $ || Ar.length < 2 || (P ? !P(Ar) : !1), Mr = !!de && !$, Pr = Mr && X.length === 1 ? (() => {
6154
+ let e = Y.shapes.find((e) => e.id === X[0]);
6043
6155
  return e && e.type === L.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
6044
- })() : null, Br = [
6156
+ })() : null, Fr = [
6045
6157
  {
6046
6158
  id: "copy",
6047
- label: X.contextMenu.copy,
6159
+ label: Q.contextMenu.copy,
6048
6160
  shortcut: "⌘C",
6049
- disabled: !kr,
6050
- onClick: tr
6161
+ disabled: !Or,
6162
+ onClick: nr
6051
6163
  },
6052
6164
  {
6053
6165
  id: "paste",
6054
- label: X.contextMenu.paste,
6166
+ label: Q.contextMenu.paste,
6055
6167
  shortcut: "⌘V",
6056
- disabled: Z || !nr(),
6057
- onClick: () => rr(Be?.img)
6168
+ disabled: $ || !rr(),
6169
+ onClick: () => ir(Pe?.img)
6058
6170
  },
6059
6171
  {
6060
6172
  id: "duplicate",
6061
- label: X.contextMenu.duplicate,
6173
+ label: Q.contextMenu.duplicate,
6062
6174
  shortcut: "⌘D",
6063
- disabled: !kr || Z,
6064
- onClick: ir
6175
+ disabled: !Or || $,
6176
+ onClick: ar
6065
6177
  },
6066
6178
  {
6067
6179
  id: "delete",
6068
- label: X.contextMenu.delete,
6180
+ label: Q.contextMenu.delete,
6069
6181
  shortcut: "Del",
6070
6182
  danger: !0,
6071
- disabled: !kr || Z,
6072
- onClick: er
6183
+ disabled: !Or || $,
6184
+ onClick: tr
6073
6185
  },
6074
6186
  { separator: !0 },
6075
6187
  {
6076
6188
  id: "editVertices",
6077
- label: X.contextMenu.editVertices,
6189
+ label: Q.contextMenu.editVertices,
6078
6190
  shortcut: "Enter",
6079
- disabled: !Fr,
6080
- onClick: () => cn(J[0])
6191
+ disabled: !kr,
6192
+ onClick: () => on(X[0])
6081
6193
  },
6082
6194
  {
6083
6195
  id: "merge",
6084
- label: X.contextMenu.merge,
6085
- disabled: Lr,
6086
- onClick: lr
6196
+ label: Q.contextMenu.merge,
6197
+ disabled: jr,
6198
+ onClick: ur
6087
6199
  },
6088
- ...Rr ? [{
6200
+ ...Mr ? [{
6089
6201
  id: "assistExpand",
6090
- label: X.contextMenu.assistExpand,
6202
+ label: Q.contextMenu.assistExpand,
6091
6203
  icon: /* @__PURE__ */ v(o, { size: 14 }),
6092
- disabled: !zr,
6204
+ disabled: !Pr,
6093
6205
  onClick: () => {
6094
- Be && zr && Q.refineShape(zr, Be.img, !0);
6206
+ Pe && Pr && Xn.refineShape(Pr, Pe.img, !0);
6095
6207
  }
6096
6208
  }, {
6097
6209
  id: "assistExclude",
6098
- label: X.contextMenu.assistExclude,
6210
+ label: Q.contextMenu.assistExclude,
6099
6211
  icon: /* @__PURE__ */ v(o, { size: 14 }),
6100
- disabled: !zr,
6212
+ disabled: !Pr,
6101
6213
  onClick: () => {
6102
- Be && zr && Q.refineShape(zr, Be.img, !1);
6214
+ Pe && Pr && Xn.refineShape(Pr, Pe.img, !1);
6103
6215
  }
6104
6216
  }] : [],
6105
6217
  {
6106
6218
  id: "bringToFront",
6107
- label: X.contextMenu.bringToFront,
6108
- disabled: !kr || Z,
6109
- onClick: ar
6219
+ label: Q.contextMenu.bringToFront,
6220
+ disabled: !Or || $,
6221
+ onClick: or
6110
6222
  },
6111
6223
  {
6112
6224
  id: "sendToBack",
6113
- label: X.contextMenu.sendToBack,
6114
- disabled: !kr || Z,
6115
- onClick: or
6225
+ label: Q.contextMenu.sendToBack,
6226
+ disabled: !Or || $,
6227
+ onClick: sr
6116
6228
  },
6117
6229
  { separator: !0 },
6118
6230
  {
6119
6231
  id: "undo",
6120
- label: X.contextMenu.undo,
6232
+ label: Q.contextMenu.undo,
6121
6233
  shortcut: "⌘Z",
6122
- disabled: Z || !Pn() && !q.canUndo(),
6234
+ disabled: $ || !Nn() && !Y.canUndo(),
6123
6235
  onClick: () => {
6124
- Mn() || q.undo();
6236
+ An() || Y.undo();
6125
6237
  }
6126
6238
  },
6127
6239
  {
6128
6240
  id: "redo",
6129
- label: X.contextMenu.redo,
6241
+ label: Q.contextMenu.redo,
6130
6242
  shortcut: "⇧⌘Z",
6131
- disabled: Z || !In() && !q.canRedo(),
6243
+ disabled: $ || !Pn() && !Y.canRedo(),
6132
6244
  onClick: () => {
6133
- Nn() || q.redo();
6245
+ jn() || Y.redo();
6134
6246
  }
6135
6247
  },
6136
6248
  { separator: !0 },
6137
6249
  {
6138
6250
  id: "selectAll",
6139
- label: X.contextMenu.selectAll,
6251
+ label: Q.contextMenu.selectAll,
6140
6252
  shortcut: "⌘A",
6141
- onClick: Qn
6253
+ onClick: $n
6142
6254
  },
6143
6255
  {
6144
6256
  id: "clearSelection",
6145
- label: X.contextMenu.clearSelection,
6257
+ label: Q.contextMenu.clearSelection,
6146
6258
  disabled: !Dr,
6147
- onClick: $n
6259
+ onClick: er
6148
6260
  },
6149
6261
  {
6150
6262
  id: "zoomToSelection",
6151
- label: X.contextMenu.zoomToSelection,
6263
+ label: Q.contextMenu.zoomToSelection,
6152
6264
  disabled: !Dr,
6153
- onClick: fr
6265
+ onClick: pr
6154
6266
  }
6155
- ], Vr = l ? Br.filter((e) => "separator" in e || !!e.id && Nr.has(e.id)) : Br, Hr = j ? j(Vr, {
6156
- selectedIds: J,
6157
- readOnly: Z
6158
- }) : Vr, Ur = Er({
6159
- engineRef: U,
6160
- image: K,
6161
- wheelZoom: Y.wheelZoom,
6267
+ ], Ir = l ? Fr.filter((e) => "separator" in e || !!e.id && Gr.has(e.id)) : Fr, Lr = M ? M(Ir, {
6268
+ selectedIds: X,
6269
+ readOnly: $
6270
+ }) : Ir, zr = Rr({
6271
+ engineRef: W,
6272
+ image: G,
6273
+ wheelZoom: Z.wheelZoom,
6162
6274
  minimapSize: 204
6163
- }), Wr = x(() => {
6164
- U.current?.zoom100();
6165
- }, []), Gr = x(() => {
6166
- Ge((e) => !e);
6167
- }, []), Kr = x(() => {
6168
- qe((e) => !e);
6275
+ }), Vr = x(() => {
6276
+ W.current?.zoom100();
6169
6277
  }, []), qr = x(() => {
6170
- qe(!1);
6278
+ Be((e) => !e);
6279
+ }, []), Jr = x(() => {
6280
+ Ke((e) => !e);
6281
+ }, []), Yr = x(() => {
6282
+ Ke(!1);
6171
6283
  }, []);
6172
6284
  return /* @__PURE__ */ y("div", {
6173
6285
  className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
@@ -6176,19 +6288,19 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6176
6288
  ref: Te,
6177
6289
  className: "aivex:h-full aivex:w-full",
6178
6290
  style: {
6179
- opacity: +!!Me,
6180
- transition: Me ? "opacity 0.3s ease" : "none"
6291
+ opacity: +!!je,
6292
+ transition: je ? "opacity 0.3s ease" : "none"
6181
6293
  }
6182
6294
  }),
6183
- nt !== "ready" && /* @__PURE__ */ v(Le, {
6184
- status: nt,
6185
- error: ct,
6295
+ et !== "ready" && /* @__PURE__ */ v(Ge, {
6296
+ status: et,
6297
+ error: nt,
6186
6298
  render: n,
6187
- loadingLabel: X.imageLoading,
6188
- errorLabel: X.imageLoadError,
6189
- errorHints: X.imageErrorHints
6299
+ loadingLabel: Q.imageLoading,
6300
+ errorLabel: Q.imageLoadError,
6301
+ errorHints: Q.imageErrorHints
6190
6302
  }),
6191
- Re && K && /* @__PURE__ */ v("div", {
6303
+ K && G && /* @__PURE__ */ v("div", {
6192
6304
  className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
6193
6305
  children: /* @__PURE__ */ y("div", {
6194
6306
  ref: De,
@@ -6196,30 +6308,30 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6196
6308
  position: "absolute",
6197
6309
  top: 0,
6198
6310
  left: 0,
6199
- width: K.w,
6200
- height: K.h,
6311
+ width: G.w,
6312
+ height: G.h,
6201
6313
  transformOrigin: "0 0"
6202
6314
  },
6203
6315
  children: [
6204
- !!ae?.length && B && /* @__PURE__ */ v("div", {
6316
+ !!V?.length && oe && /* @__PURE__ */ v("div", {
6205
6317
  style: {
6206
6318
  position: "absolute",
6207
6319
  left: 0,
6208
6320
  top: 0,
6209
- width: K.w,
6210
- height: K.h,
6321
+ width: G.w,
6322
+ height: G.h,
6211
6323
  pointerEvents: "none"
6212
6324
  },
6213
- children: ae.map((e) => /* @__PURE__ */ v("div", {
6325
+ children: V.map((e) => /* @__PURE__ */ v("div", {
6214
6326
  role: e.disabled ? void 0 : "button",
6215
6327
  tabIndex: e.disabled ? void 0 : 0,
6216
6328
  "aria-pressed": e.selected || void 0,
6217
6329
  onPointerDown: (e) => e.stopPropagation(),
6218
6330
  onClick: (t) => {
6219
- t.stopPropagation(), e.disabled || V?.(e);
6331
+ t.stopPropagation(), e.disabled || H?.(e);
6220
6332
  },
6221
6333
  onKeyDown: (t) => {
6222
- e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), V?.(e));
6334
+ e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), H?.(e));
6223
6335
  },
6224
6336
  style: {
6225
6337
  position: "absolute",
@@ -6231,82 +6343,82 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6231
6343
  pointerEvents: e.disabled ? "none" : "auto",
6232
6344
  cursor: e.disabled ? "default" : "pointer"
6233
6345
  },
6234
- children: B(e)
6346
+ children: oe(e)
6235
6347
  }, e.id))
6236
6348
  }),
6237
- se?.({
6238
- image: K,
6239
- viewport: U.current?.viewport ?? {
6349
+ U?.({
6350
+ image: G,
6351
+ viewport: W.current?.viewport ?? {
6240
6352
  scale: 1,
6241
6353
  x: 0,
6242
6354
  y: 0
6243
6355
  }
6244
6356
  }),
6245
- Tr.length > 0 && /* @__PURE__ */ v(st, {
6246
- shapes: Tr,
6247
- getLabel: H,
6357
+ Er.length > 0 && /* @__PURE__ */ v(pt, {
6358
+ shapes: Er,
6359
+ getLabel: se,
6248
6360
  hideDot: ce,
6249
6361
  formatInfo: le,
6250
6362
  register: vn
6251
6363
  }),
6252
- de && (Q.status === "loading" || Q.boxes.length > 0) && /* @__PURE__ */ v(Ne, {
6253
- image: K,
6254
- points: Q.points,
6255
- boxes: Q.boxes,
6256
- status: Q.status
6364
+ de && (Xn.status === "loading" || Xn.boxes.length > 0) && /* @__PURE__ */ v(Ve, {
6365
+ image: G,
6366
+ points: Xn.points,
6367
+ boxes: Xn.boxes,
6368
+ status: Xn.status
6257
6369
  })
6258
6370
  ]
6259
6371
  })
6260
6372
  }),
6261
- Re && Y.showCursorGuide && /* @__PURE__ */ v(Ie, { color: "#1e88e5" }),
6262
- K && b && /* @__PURE__ */ v(Ze, {
6263
- image: K,
6264
- imageUrl: tt,
6265
- imageVisible: Me,
6266
- loading: !Re,
6267
- maskDataUrl: Tt,
6268
- region: Dt,
6269
- roiMaskId: Ae,
6270
- shapes: _r,
6271
- view: Y,
6272
- viewDefaults: vt,
6273
- onChangeView: xt,
6274
- nav: Ur,
6373
+ K && Z.showCursorGuide && /* @__PURE__ */ v(We, { color: "#1e88e5" }),
6374
+ G && D && /* @__PURE__ */ v(at, {
6375
+ image: G,
6376
+ imageUrl: $e,
6377
+ imageVisible: je,
6378
+ loading: !K,
6379
+ maskDataUrl: wt,
6380
+ region: Tt,
6381
+ roiMaskId: ke,
6382
+ shapes: vr,
6383
+ view: Z,
6384
+ viewDefaults: gt,
6385
+ onChangeView: yt,
6386
+ nav: zr,
6275
6387
  registerShape: pn,
6276
6388
  rectRef: Ee,
6277
- zoomLabelRef: W,
6278
- onZoom100: Wr,
6279
- open: We,
6280
- onToggleOpen: Gr,
6281
- position: D,
6282
- labels: X.minimap,
6283
- settingsLabels: X.viewSettings,
6284
- showSettings: A,
6285
- settingsOpen: Ke,
6286
- onToggleSettings: Kr,
6287
- onCloseSettings: qr
6389
+ zoomLabelRef: Oe,
6390
+ onZoom100: Vr,
6391
+ open: ze,
6392
+ onToggleOpen: qr,
6393
+ position: A,
6394
+ labels: Q.minimap,
6395
+ settingsLabels: Q.viewSettings,
6396
+ showSettings: j,
6397
+ settingsOpen: He,
6398
+ onToggleSettings: Jr,
6399
+ onCloseSettings: Yr
6288
6400
  }),
6289
- Be && /* @__PURE__ */ v(Fe, {
6290
- x: Be.x,
6291
- y: Be.y,
6292
- items: Hr,
6293
- onClose: () => Ve(null)
6401
+ Pe && /* @__PURE__ */ v(Ue, {
6402
+ x: Pe.x,
6403
+ y: Pe.y,
6404
+ items: Lr,
6405
+ onClose: () => q(null)
6294
6406
  })
6295
6407
  ]
6296
6408
  });
6297
6409
  }
6298
6410
  //#endregion
6299
6411
  //#region src/components/ShapeEditor/ShapeViewer.tsx
6300
- function Ir(e, t, n) {
6412
+ function Jr(e, t, n) {
6301
6413
  if (t.length !== 0) {
6302
6414
  e.beginPath(), e.moveTo(t[0].x, t[0].y);
6303
6415
  for (let n = 1; n < t.length; n += 1) e.lineTo(t[n].x, t[n].y);
6304
6416
  n && e.closePath();
6305
6417
  }
6306
6418
  }
6307
- function Lr(e, t, n, r) {
6419
+ function Yr(e, t, n, r) {
6308
6420
  if (t.interaction?.visible === !1) return;
6309
- let i = Ue(t, {
6421
+ let i = Ze(t, {
6310
6422
  strokeWidth: r,
6311
6423
  pointRadius: 2
6312
6424
  });
@@ -6321,10 +6433,10 @@ function Lr(e, t, n, r) {
6321
6433
  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);
6322
6434
  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);
6323
6435
  }
6324
- } else Ir(e, t.points, t.type !== L.LINE);
6325
- i.fillVisible && (e.save(), e.fillStyle = i.color, e.globalAlpha *= i.fillAlpha, e.fill(), e.restore()), t.style?.alternateColor && i.dash?.length && (e.setLineDash([]), e.strokeStyle = t.style.alternateColor, e.stroke()), e.setLineDash((i.dash ?? []).map((e) => e / n)), e.strokeStyle = i.color, e.stroke(), e.restore();
6436
+ } else Jr(e, t.points, t.type !== L.LINE);
6437
+ 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();
6326
6438
  }
6327
- function Rr({ 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: _ }) {
6439
+ function Xr({ 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: _ }) {
6328
6440
  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);
6329
6441
  S(() => {
6330
6442
  if (!m || w) return;
@@ -6345,14 +6457,14 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6345
6457
  return;
6346
6458
  }
6347
6459
  let t = !0;
6348
- return A("loading"), M(null), Ln(e).then(async (n) => {
6460
+ return A("loading"), M(null), qn(e).then(async (n) => {
6349
6461
  if (!t) return;
6350
6462
  if (n) {
6351
6463
  C.current = n, A("ready");
6352
6464
  return;
6353
6465
  }
6354
6466
  C.current = null, A("error");
6355
- let r = await Hn(e);
6467
+ let r = await Qn(e);
6356
6468
  t && M(r);
6357
6469
  }), () => {
6358
6470
  t = !1;
@@ -6360,7 +6472,7 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6360
6472
  }, [e, w]), S(() => () => {
6361
6473
  C.current = null;
6362
6474
  }, []);
6363
- let F = E(() => r.find((e) => e.id === s), [s, r]), ee = E(() => a && o ? kt(a, o) : null, [a, o]);
6475
+ let F = E(() => r.find((e) => e.id === s), [s, r]), ee = E(() => a && o ? zt(a, o) : null, [a, o]);
6364
6476
  return S(() => {
6365
6477
  if (D === "error") {
6366
6478
  let e = x.current;
@@ -6379,24 +6491,24 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6379
6491
  if (!g || !_) return;
6380
6492
  let v = Math.min(o / g, s / _), y = (o - g * v) / 2, S = (s - _ * v) / 2;
6381
6493
  if (F && F.points.length > 0) {
6382
- let e = V(F.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * l;
6494
+ let e = H(F.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * l;
6383
6495
  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)));
6384
6496
  }
6385
6497
  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());
6386
- let w = i ? Vt(i, g, _) : null;
6387
- if (w && (It(h, w, g, _), w.outlineStyles)) {
6498
+ let w = i ? Xt(i, g, _) : null;
6499
+ if (w && (Gt(h, w, g, _), w.outlineStyles)) {
6388
6500
  let e = (e, t) => {
6389
6501
  if (h.lineWidth = t.width / v, t.underlayColor) {
6390
6502
  h.setLineDash([]), h.strokeStyle = t.underlayColor;
6391
- for (let [t, n] of e) Ir(h, [t, n], !1), h.stroke();
6503
+ for (let [t, n] of e) Jr(h, [t, n], !1), h.stroke();
6392
6504
  }
6393
6505
  h.save(), h.globalAlpha *= t.opacity, h.setLineDash(t.dash.map((e) => e / v)), h.strokeStyle = t.color;
6394
- for (let [t, n] of e) Ir(h, [t, n], !1), h.stroke();
6506
+ for (let [t, n] of e) Jr(h, [t, n], !1), h.stroke();
6395
6507
  h.restore();
6396
6508
  };
6397
6509
  e(w.visibleOutline, w.outlineStyles.visible), e(w.occludedOutline, w.outlineStyles.occluded);
6398
6510
  }
6399
- for (let e of ae(r)) Lr(h, e, v, u);
6511
+ for (let e of B(r)) Yr(h, e, v, u);
6400
6512
  h.restore();
6401
6513
  }, [
6402
6514
  d,
@@ -6450,14 +6562,14 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6450
6562
  "aria-hidden": !0,
6451
6563
  children: "⚠"
6452
6564
  }),
6453
- /* @__PURE__ */ v("span", { children: W.imageLoadError }),
6565
+ /* @__PURE__ */ v("span", { children: q.imageLoadError }),
6454
6566
  j && /* @__PURE__ */ v("span", {
6455
6567
  style: {
6456
6568
  fontSize: 11,
6457
6569
  opacity: .7,
6458
6570
  wordBreak: "break-all"
6459
6571
  },
6460
- children: W.imageErrorHints[j.kind]
6572
+ children: q.imageErrorHints[j.kind]
6461
6573
  })
6462
6574
  ]
6463
6575
  }) : null)
@@ -6465,6 +6577,6 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6465
6577
  });
6466
6578
  }
6467
6579
  //#endregion
6468
- export { W as DEFAULT_EDITOR_STRINGS, ke as DEFAULT_VIEW_SETTINGS, L as SHAPE_TYPE, Fr as ShapeEditor, Fr as default, Rr as ShapeViewer, G as TOOL, oe as generateId };
6580
+ export { q as DEFAULT_EDITOR_STRINGS, Ie as DEFAULT_VIEW_SETTINGS, L as SHAPE_TYPE, qr as ShapeEditor, qr as default, Xr as ShapeViewer, J as TOOL, ae as generateId };
6469
6581
 
6470
6582
  //# sourceMappingURL=shape-editor.js.map