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

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.
@@ -6,9 +6,9 @@ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
6
6
  import { memo as b, useCallback as x, useEffect as S, useId as C, useImperativeHandle as w, useLayoutEffect as T, useMemo as E, useReducer as D, useRef as O, useState as k } from "react";
7
7
  import A from "konva";
8
8
  import "pixi.js/unsafe-eval";
9
- import { Application as j, ColorMatrixFilter as M, Container as N, Graphics as P, Polygon as F, Rectangle as ee, Sprite as te, Texture as I } from "pixi.js";
9
+ import { Application as j, ColorMatrixFilter as M, Container as N, Graphics as P, Polygon as ee, Rectangle as te, Sprite as ne, Texture as F } from "pixi.js";
10
10
  //#region src/components/ShapeEditor/_model/geometry.ts
11
- var L = {
11
+ var I = {
12
12
  POINT: "POINT",
13
13
  RECTANGLE: "RECTANGLE",
14
14
  ROTATED_RECTANGLE: "ROTATED_RECTANGLE",
@@ -16,22 +16,22 @@ var L = {
16
16
  ELLIPSE: "ELLIPSE",
17
17
  LINE: "LINE"
18
18
  };
19
- function ne(e) {
20
- return e.interaction?.visible !== !1;
21
- }
22
19
  function re(e) {
23
- return ne(e) && e.interaction?.hitTestDisabled !== !0;
24
- }
25
- function R(e) {
26
- return re(e) && e.interaction?.selectable !== !1;
20
+ return e.interaction?.visible !== !1;
27
21
  }
28
22
  function ie(e) {
29
- return R(e) && !e.readOnly && e.interaction?.editable !== !1;
23
+ return re(e) && e.interaction?.hitTestDisabled !== !0;
30
24
  }
31
- function z(e) {
32
- return ie(e) && e.interaction?.draggable !== !1;
25
+ function L(e) {
26
+ return ie(e) && e.interaction?.selectable !== !1;
33
27
  }
34
28
  function ae(e) {
29
+ return L(e) && !e.readOnly && e.interaction?.editable !== !1;
30
+ }
31
+ function R(e) {
32
+ return ae(e) && e.interaction?.draggable !== !1;
33
+ }
34
+ function z(e) {
35
35
  return e.map((e, t) => ({
36
36
  shape: e,
37
37
  index: t
@@ -238,7 +238,7 @@ function Te(e, t, n, r) {
238
238
  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
239
  return a !== o && s !== c && !(a === 0 && o === 0);
240
240
  }
241
- function U(e, t = 256) {
241
+ function Ee(e, t = 256) {
242
242
  let n = e.length;
243
243
  if (n < 4 || n > t) return !1;
244
244
  for (let t = 0; t < n; t++) {
@@ -247,7 +247,7 @@ function U(e, t = 256) {
247
247
  }
248
248
  return !1;
249
249
  }
250
- function Ee(e, t, n, r) {
250
+ function U(e, t, n, r) {
251
251
  let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
252
252
  if (!c) return null;
253
253
  let l = ((n.x - e.x) * s - (n.y - e.y) * o) / c, u = ((n.x - e.x) * a - (n.y - e.y) * i) / c, d = 1e-9;
@@ -258,13 +258,13 @@ function Ee(e, t, n, r) {
258
258
  }
259
259
  function De(e, t = 256) {
260
260
  let n = e.length;
261
- if (n < 4 || n > t || !U(e, t)) return [e];
261
+ if (n < 4 || n > t || !Ee(e, t)) return [e];
262
262
  let r = Array.from({ length: n }, () => []), i = 0;
263
263
  for (let t = 0; t < n; t++) {
264
264
  let a = e[t], o = e[(t + 1) % n];
265
265
  for (let s = t + 2; s < n; s++) {
266
266
  if (t === 0 && s === n - 1) continue;
267
- let c = Ee(a, o, e[s], e[(s + 1) % n]);
267
+ let c = U(a, o, e[s], e[(s + 1) % n]);
268
268
  c && (r[t].push({
269
269
  t: c.ti,
270
270
  id: i
@@ -428,9 +428,9 @@ var G = {
428
428
  keepZoomOnImageChange: !1,
429
429
  wheelZoom: !0,
430
430
  zoomSensitivity: 1
431
- }, Ae = "var(--editor-overlay-inverse-scale, 1)", K = "#377be2", je = "#e23c3c";
431
+ }, Ae = "var(--editor-overlay-inverse-scale, 1)", je = "#377be2", K = "#e23c3c";
432
432
  function Me({ point: e }) {
433
- let t = e.positive ? K : je;
433
+ let t = e.positive ? je : K;
434
434
  return /* @__PURE__ */ v("div", {
435
435
  style: {
436
436
  position: "absolute",
@@ -707,11 +707,11 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
707
707
  strokeWidth: a.strokeWidth,
708
708
  strokeDasharray: a.dash?.join(" "),
709
709
  opacity: a.opacity,
710
- fill: a.fillVisible && r !== L.LINE ? a.color : "none",
710
+ fill: a.fillVisible && r !== I.LINE ? a.color : "none",
711
711
  fillOpacity: a.fillAlpha,
712
712
  vectorEffect: "non-scaling-stroke"
713
713
  };
714
- if (r === L.POINT) return /* @__PURE__ */ v("circle", {
714
+ if (r === I.POINT) return /* @__PURE__ */ v("circle", {
715
715
  ref: o,
716
716
  cx: i[0].x,
717
717
  cy: i[0].y,
@@ -719,9 +719,9 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
719
719
  fill: a.color,
720
720
  opacity: a.opacity
721
721
  });
722
- if (r === L.RECTANGLE || r === L.ELLIPSE) {
722
+ if (r === I.RECTANGLE || r === I.ELLIPSE) {
723
723
  let e = V(i);
724
- return r === L.ELLIPSE ? /* @__PURE__ */ v("ellipse", {
724
+ return r === I.ELLIPSE ? /* @__PURE__ */ v("ellipse", {
725
725
  cx: (e.minX + e.maxX) / 2,
726
726
  cy: (e.minY + e.maxY) / 2,
727
727
  rx: (e.maxX - e.minX) / 2,
@@ -736,7 +736,7 @@ var Ge = b(function({ shape: e, strokeSize: t, register: n }) {
736
736
  });
737
737
  }
738
738
  let c = i.map((e) => `${e.x},${e.y}`).join(" ");
739
- return r === L.LINE ? /* @__PURE__ */ v("polyline", {
739
+ return r === I.LINE ? /* @__PURE__ */ v("polyline", {
740
740
  points: c,
741
741
  ...s
742
742
  }) : /* @__PURE__ */ v("polygon", {
@@ -976,14 +976,14 @@ var Xe = {
976
976
  "top-left": "aivex:top-2 aivex:left-2",
977
977
  "top-right": "aivex:top-2 aivex:right-2"
978
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 }) {
979
- let { offX: N, offY: P, dispW: F, dispH: ee, zoomCentered: te } = _, I = E.startsWith("top"), L = {
979
+ let { offX: N, offY: P, dispW: ee, dispH: te, zoomCentered: ne } = _, F = E.startsWith("top"), I = {
980
980
  position: "absolute",
981
981
  left: N,
982
982
  top: P,
983
- width: F,
984
- height: ee
985
- }, re = /* @__PURE__ */ v("div", {
986
- className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${I ? "aivex:mt-md" : "aivex:mb-md"} aivex:opacity-100` : "aivex:opacity-0"}`,
983
+ width: ee,
984
+ height: te
985
+ }, ie = /* @__PURE__ */ v("div", {
986
+ className: `aivex:overflow-hidden aivex:rounded-sm aivex:transition-all aivex:duration-200 aivex:ease-in-out ${w ? `${F ? "aivex:mt-md" : "aivex:mb-md"} aivex:opacity-100` : "aivex:opacity-0"}`,
987
987
  style: { maxHeight: w ? 204 : 0 },
988
988
  children: /* @__PURE__ */ v("div", {
989
989
  style: {
@@ -1010,14 +1010,14 @@ var Xe = {
1010
1010
  alt: "",
1011
1011
  crossOrigin: "anonymous",
1012
1012
  draggable: !1,
1013
- style: L
1013
+ style: I
1014
1014
  }),
1015
1015
  a && m.showGuide && /* @__PURE__ */ v("img", {
1016
1016
  src: a,
1017
1017
  alt: "",
1018
1018
  draggable: !1,
1019
1019
  style: {
1020
- ...L,
1020
+ ...I,
1021
1021
  opacity: .55,
1022
1022
  imageRendering: "pixelated",
1023
1023
  pointerEvents: "none"
@@ -1027,8 +1027,8 @@ var Xe = {
1027
1027
  image: e,
1028
1028
  region: o,
1029
1029
  maskId: l,
1030
- width: F,
1031
- height: ee,
1030
+ width: ee,
1031
+ height: te,
1032
1032
  strokeWidth: 1,
1033
1033
  strokeDasharray: "4 4",
1034
1034
  style: {
@@ -1040,8 +1040,8 @@ var Xe = {
1040
1040
  }),
1041
1041
  /* @__PURE__ */ v("svg", {
1042
1042
  viewBox: `0 0 ${e.w} ${e.h}`,
1043
- width: F,
1044
- height: ee,
1043
+ width: ee,
1044
+ height: te,
1045
1045
  style: {
1046
1046
  position: "absolute",
1047
1047
  left: N,
@@ -1049,7 +1049,7 @@ var Xe = {
1049
1049
  pointerEvents: "none"
1050
1050
  },
1051
1051
  "aria-hidden": !0,
1052
- children: ae(p).filter(ne).map((e) => /* @__PURE__ */ v(Ge, {
1052
+ children: z(p).filter(re).map((e) => /* @__PURE__ */ v(Ge, {
1053
1053
  shape: e,
1054
1054
  strokeSize: m.strokeSize,
1055
1055
  register: b
@@ -1068,14 +1068,14 @@ var Xe = {
1068
1068
  ]
1069
1069
  })
1070
1070
  })
1071
- }), R = /* @__PURE__ */ y("div", {
1071
+ }), L = /* @__PURE__ */ y("div", {
1072
1072
  className: "aivex:relative aivex:flex aivex:items-center aivex:gap-xs",
1073
1073
  children: [
1074
1074
  /* @__PURE__ */ v(u, {
1075
1075
  variant: "ghost",
1076
1076
  size: "icon-md",
1077
1077
  "aria-label": j.zoomOut,
1078
- onClick: () => te(1 / 1.2),
1078
+ onClick: () => ne(1 / 1.2),
1079
1079
  disabled: r,
1080
1080
  children: /* @__PURE__ */ v(f, { size: 20 })
1081
1081
  }),
@@ -1095,7 +1095,7 @@ var Xe = {
1095
1095
  variant: "ghost",
1096
1096
  size: "icon-md",
1097
1097
  "aria-label": j.zoomIn,
1098
- onClick: () => te(1.2),
1098
+ onClick: () => ne(1.2),
1099
1099
  disabled: r,
1100
1100
  children: /* @__PURE__ */ v(i, { size: 20 })
1101
1101
  }),
@@ -1115,7 +1115,7 @@ var Xe = {
1115
1115
  onChange: g,
1116
1116
  onClose: A,
1117
1117
  labels: M,
1118
- openDown: I,
1118
+ openDown: F,
1119
1119
  alignEnd: E.endsWith("right")
1120
1120
  })]
1121
1121
  }),
@@ -1127,14 +1127,14 @@ var Xe = {
1127
1127
  onClick: T,
1128
1128
  children: w ? /* @__PURE__ */ v(c, {
1129
1129
  size: 20,
1130
- className: I ? "aivex:rotate-180" : void 0
1130
+ className: F ? "aivex:rotate-180" : void 0
1131
1131
  }) : /* @__PURE__ */ v(s, { size: 20 })
1132
1132
  })
1133
1133
  ]
1134
1134
  });
1135
1135
  return /* @__PURE__ */ y("div", {
1136
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)]`,
1137
- children: [I ? R : re, I ? re : R]
1137
+ children: [F ? L : ie, F ? ie : L]
1138
1138
  });
1139
1139
  }), Qe = "var(--editor-overlay-inverse-scale, 1)", $e = 6, et = {
1140
1140
  fontFamily: "Pretendard, sans-serif",
@@ -1186,7 +1186,7 @@ function ot({ color: e, striped: t }) {
1186
1186
  }
1187
1187
  function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i }) {
1188
1188
  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);
1189
+ let a = tt(e.points), o = e.type === I.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);
1190
1190
  return /* @__PURE__ */ y("div", {
1191
1191
  ref: (t) => i(e.id, t),
1192
1192
  style: {
@@ -1231,16 +1231,16 @@ function st({ shapes: e, getLabel: t, hideDot: n, formatInfo: r, register: i })
1231
1231
  }
1232
1232
  //#endregion
1233
1233
  //#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) {
1234
+ var ct = "AIVEX_SHAPE_EDITOR:", lt = 1, ut = new Set(Object.values(I)), dt = null, q = "unavailable", ft = 0;
1235
+ function pt(e) {
1236
1236
  if (!e || typeof e != "object") return !1;
1237
1237
  let t = e;
1238
1238
  return Number.isFinite(t.x) && Number.isFinite(t.y);
1239
1239
  }
1240
- function pt(e) {
1240
+ function J(e) {
1241
1241
  if (!e || typeof e != "object") return !1;
1242
1242
  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);
1243
+ return typeof t.type == "string" && ut.has(t.type) && Array.isArray(t.points) && t.points.length > 0 && t.points.every(pt);
1244
1244
  }
1245
1245
  function mt(e, t, n) {
1246
1246
  return {
@@ -1263,43 +1263,43 @@ function _t(e) {
1263
1263
  if (!e.startsWith(ct)) return null;
1264
1264
  try {
1265
1265
  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;
1266
+ return t.kind !== "aivex-shape-editor" || t.version !== lt || !Array.isArray(t.shapes) || t.shapes.length === 0 || !t.shapes.every(J) || t.scope !== void 0 && typeof t.scope != "string" || t.documentId !== void 0 && typeof t.documentId != "string" ? null : t;
1267
1267
  } catch {
1268
1268
  return null;
1269
1269
  }
1270
1270
  }
1271
1271
  function vt(e) {
1272
- q = e;
1272
+ dt = e;
1273
1273
  let t = ++ft;
1274
1274
  if (typeof navigator > "u" || !navigator.clipboard?.writeText) {
1275
- dt = "unavailable";
1275
+ q = "unavailable";
1276
1276
  return;
1277
1277
  }
1278
1278
  let n;
1279
1279
  try {
1280
1280
  n = gt(e);
1281
1281
  } catch {
1282
- dt = "unavailable";
1282
+ q = "unavailable";
1283
1283
  return;
1284
1284
  }
1285
- dt = "pending", navigator.clipboard.writeText(n).then(() => {
1286
- t === ft && (dt = "written");
1285
+ q = "pending", navigator.clipboard.writeText(n).then(() => {
1286
+ t === ft && (q = "written");
1287
1287
  }, () => {
1288
- t === ft && (dt = "unavailable");
1288
+ t === ft && (q = "unavailable");
1289
1289
  });
1290
1290
  }
1291
1291
  function yt(e, t) {
1292
1292
  return !!e && e.scope === t;
1293
1293
  }
1294
- function Y(e) {
1295
- return yt(q, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
1294
+ function bt(e) {
1295
+ return yt(dt, e) || typeof navigator < "u" && typeof navigator.clipboard?.readText == "function";
1296
1296
  }
1297
- async function bt(e) {
1298
- let t = yt(q, e) ? q : null;
1299
- if (t && dt !== "written") return t;
1297
+ async function Y(e) {
1298
+ let t = yt(dt, e) ? dt : null;
1299
+ if (t && q !== "written") return t;
1300
1300
  if (typeof navigator < "u" && navigator.clipboard?.readText) try {
1301
1301
  let t = _t(await navigator.clipboard.readText());
1302
- return t?.scope === e ? (q = t, t) : null;
1302
+ return t?.scope === e ? (dt = t, t) : null;
1303
1303
  } catch {}
1304
1304
  return t;
1305
1305
  }
@@ -1311,7 +1311,7 @@ function xt(e, t, n) {
1311
1311
  }
1312
1312
  //#endregion
1313
1313
  //#region src/components/ShapeEditor/_model/cursors.ts
1314
- var X = new Set([
1314
+ var St = new Set([
1315
1315
  G.RECTANGLE,
1316
1316
  G.ROTATED_RECTANGLE,
1317
1317
  G.CIRCLE,
@@ -1322,7 +1322,7 @@ var X = new Set([
1322
1322
  G.ASSISTANT_POLYGON,
1323
1323
  G.ASSISTANT_RECT,
1324
1324
  G.ASSISTANT_POINT
1325
- ]), St = {
1325
+ ]), X = {
1326
1326
  tl: -135,
1327
1327
  t: -90,
1328
1328
  tr: -45,
@@ -1338,11 +1338,11 @@ var X = new Set([
1338
1338
  "nesw-resize"
1339
1339
  ];
1340
1340
  function wt(e, t = 0) {
1341
- let n = ((St[e] + t * 180 / Math.PI) % 180 + 180) % 180;
1341
+ let n = ((X[e] + t * 180 / Math.PI) % 180 + 180) % 180;
1342
1342
  return Ct[Math.round(n / 45) % 4];
1343
1343
  }
1344
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");
1345
+ return n ? "grab" : t || (e === G.SELECT ? "default" : St.has(e) ? r ? "default" : "crosshair" : "default");
1346
1346
  }
1347
1347
  function Et({ tool: e, externalToolCursor: t, isSpacePressed: n, interactionMode: r, rendererCursorHint: i, isPolygonDrawing: a }) {
1348
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({
@@ -1565,7 +1565,7 @@ var Rt = {
1565
1565
  occludedOutline: [],
1566
1566
  outlineStyles: l
1567
1567
  };
1568
- }, Z = .3, Ht = .05;
1568
+ }, Ht = .3, Z = .05;
1569
1569
  function Ut(e) {
1570
1570
  return 1 - (1 - e) ** 3;
1571
1571
  }
@@ -1579,7 +1579,7 @@ function Wt(e) {
1579
1579
  }
1580
1580
  function Gt(e, t) {
1581
1581
  if (!t.length) return null;
1582
- if (e === L.POINT) {
1582
+ if (e === I.POINT) {
1583
1583
  let e = t[0];
1584
1584
  return {
1585
1585
  x: e.x - 8,
@@ -1608,7 +1608,7 @@ function Kt(e) {
1608
1608
  }]))) : null;
1609
1609
  }
1610
1610
  function qt(e, t, n, r = {}) {
1611
- let { containerRatio: i = Z, minScale: a = Ht, maxScale: o = 20 } = r;
1611
+ let { containerRatio: i = Ht, minScale: a = Z, maxScale: o = 20 } = r;
1612
1612
  if (!t || !n || e.width <= 0 || e.height <= 0) return null;
1613
1613
  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
1614
  return {
@@ -1619,7 +1619,7 @@ function qt(e, t, n, r = {}) {
1619
1619
  }
1620
1620
  function Jt(e, t, n, r = 80) {
1621
1621
  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;
1622
+ let i = Math.max(1, e.maxX - e.minX), a = Math.max(1, e.maxY - e.minY), o = Math.max(Z, Math.min(20, Math.min((t - r) / i, (n - r) / a))), s = (e.minX + e.maxX) / 2, c = (e.minY + e.maxY) / 2;
1623
1623
  return {
1624
1624
  scale: o,
1625
1625
  x: t / 2 - s * o,
@@ -1640,10 +1640,10 @@ function Yt(e, t, n, r = 300) {
1640
1640
  //#endregion
1641
1641
  //#region src/components/ShapeEditor/_state/createInteractionController.ts
1642
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) => {
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, 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 = "", P = null, ee = null, te = (e) => e === G.RECTANGLE || e === G.ROTATED_RECTANGLE || e === G.CIRCLE, ne = (e) => e === G.ASSISTANT_POLYGON || e === G.ASSISTANT_RECT, F = (e) => e === G.POLYGON, re = (e) => te(e) || ne(e) || F(e) || e === G.PATH || e === G.BRUSH || e === G.POINT, ie = (e, t) => {
1644
1644
  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) => ({
1645
+ O && !te(t) && !ne(t) && (O = null, e.clearPreview(), w(null), n = !0), (k === "path" && t !== G.PATH || k === "scalar" && t !== G.BRUSH) && (k = null, n = !0), A && !F(t) && (A = null, n = !0), j && t !== G.SELECT && (j = null, M = null, e.clearMarquee(), n = !0), P && t !== G.POINT && (P = null, n = !0), n && x("idle");
1646
+ }, ae = () => r.current.get(n.current), oe = (e, t, n, r) => ({
1647
1647
  point: t,
1648
1648
  targetId: r,
1649
1649
  event: n,
@@ -1651,66 +1651,70 @@ function Xt(e) {
1651
1651
  viewport: e.viewport
1652
1652
  });
1653
1653
  return {
1654
- onCursorHint: y,
1655
- onInteractionModeChange: b,
1654
+ onCursorHint: b,
1655
+ onInteractionModeChange: x,
1656
1656
  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 = {
1657
+ let m = t.current;
1658
+ if (!m) return;
1659
+ let v = n.current;
1660
+ if (P = null, ie(m, v), u.button === 1 || i.current) {
1661
+ x("panning"), b(null), D = {
1662
1662
  px: u.global.x,
1663
1663
  py: u.global.y
1664
1664
  };
1665
1665
  return;
1666
1666
  }
1667
- if (u.button === 2 && !(_ === G.ASSISTANT_POINT && u.altKey)) {
1667
+ if (u.button === 2 && !(v === G.ASSISTANT_POINT && u.altKey)) {
1668
1668
  if (r && !s.current.includes(r)) {
1669
1669
  let e = o.current.getShapes().find((e) => e.id === r);
1670
- e && R(e) && m.current([r]);
1670
+ e && L(e) && h.current([r]);
1671
1671
  }
1672
1672
  return;
1673
1673
  }
1674
- let v = ne();
1675
- if (v) {
1676
- w().reset(), m.current([]), v.onPointerDown?.(re(p, e, u, r));
1674
+ let y = ae();
1675
+ if (y) {
1676
+ T().reset(), h.current([]), y.onPointerDown?.(oe(m, e, u, r));
1677
1677
  return;
1678
1678
  }
1679
1679
  if (d.current) {
1680
1680
  f();
1681
1681
  return;
1682
1682
  }
1683
- if (_ === G.ASSISTANT_POINT) {
1684
- u.altKey ? T().addPoint(e, u.button !== 2) : T().newPolygon(e);
1683
+ if (re(v) && !c.current) {
1684
+ p();
1685
1685
  return;
1686
1686
  }
1687
- if (ee(_) && c.current) {
1688
- D = e, b("drawing");
1687
+ if (v === G.ASSISTANT_POINT) {
1688
+ u.altKey ? E().addPoint(e, u.button !== 2) : E().newPolygon(e);
1689
1689
  return;
1690
1690
  }
1691
- if (_ === G.SELECT && u.altKey) {
1692
- let t = ae(o.current.getShapes()).filter((t) => {
1693
- if (!R(t)) return !1;
1691
+ if (ne(v) && c.current) {
1692
+ O = e, x("drawing");
1693
+ return;
1694
+ }
1695
+ if (v === G.SELECT && u.altKey) {
1696
+ let t = z(o.current.getShapes()).filter((t) => {
1697
+ if (!L(t)) return !1;
1694
1698
  let n = V(t.points);
1695
1699
  return e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY;
1696
1700
  });
1697
1701
  if (t.length) {
1698
1702
  let e = [...t].reverse(), n = [e[(e.findIndex((e) => s.current.includes(e.id)) + 1) % e.length].id];
1699
- m.current(n);
1703
+ h.current(n);
1700
1704
  return;
1701
1705
  }
1702
1706
  }
1703
- if (r && _ === G.SELECT) {
1707
+ if (r && v === G.SELECT) {
1704
1708
  let t = o.current.getShapes().find((e) => e.id === r);
1705
- 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 = {
1709
+ if (!t || !L(t)) return;
1710
+ let n = typeof performance < "u" ? performance.now() : 0, i = !!ee && ee.id === r && n - ee.t < 300;
1711
+ ee = {
1708
1712
  id: r,
1709
1713
  t: n
1710
1714
  };
1711
- let c = (t.type === L.POLYGON || t.type === L.LINE) && !l.current && t.interaction?.editable !== !1 && !t.readOnly;
1715
+ let c = (t.type === I.POLYGON || t.type === I.LINE) && !l.current && t.interaction?.editable !== !1 && !t.readOnly;
1712
1716
  if (i && c) {
1713
- m.current([r]), h.current(r);
1717
+ h.current([r]), g.current(r);
1714
1718
  return;
1715
1719
  }
1716
1720
  let u = s.current;
@@ -1718,176 +1722,176 @@ function Xt(e) {
1718
1722
  let e = new Set(u);
1719
1723
  e.has(r) ? e.delete(r) : e.add(r), u = [...e];
1720
1724
  } else u.includes(r) || (u = [r]);
1721
- m.current(u), !l.current && z(t) && p.beginMove(e, u);
1725
+ h.current(u), !l.current && R(t) && m.beginMove(e, u);
1722
1726
  return;
1723
1727
  }
1724
- if (F(_) && c.current) {
1725
- D = e, b("drawing");
1728
+ if (te(v) && c.current) {
1729
+ O = e, x("drawing");
1726
1730
  return;
1727
1731
  }
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);
1732
+ if (F(v) && c.current) {
1733
+ if (!T().getDraftPointsSnapshot().length && s.current.length && h.current([]), T().tryClosePolygon(e, 12 / m.viewport.scale)) return;
1734
+ let t = T().hitDraftPoint(e);
1731
1735
  if (t >= 0) {
1732
1736
  if (u.altKey) {
1733
- w().removeDraftPoint(t);
1737
+ T().removeDraftPoint(t);
1734
1738
  return;
1735
1739
  }
1736
- let n = w().selectDraftPointForDrag(t, u.shiftKey || u.ctrlKey || u.metaKey);
1740
+ let n = T().selectDraftPointForDrag(t, u.shiftKey || u.ctrlKey || u.metaKey);
1737
1741
  if (!n) return;
1738
- k = {
1742
+ A = {
1739
1743
  start: e,
1740
1744
  base: n.base,
1741
1745
  indices: n.indices,
1742
1746
  moved: !1
1743
- }, b("vertexDragging");
1747
+ }, x("vertexDragging");
1744
1748
  return;
1745
1749
  }
1746
- w().appendPolygonPoint(e);
1750
+ T().appendPolygonPoint(e);
1747
1751
  return;
1748
1752
  }
1749
- if (_ === G.PATH && c.current) {
1750
- s.current.length && m.current([]), O = "path", b("drawing"), w().beginStroke(e);
1753
+ if (v === G.PATH && c.current) {
1754
+ s.current.length && h.current([]), k = "path", x("drawing"), T().beginStroke(e);
1751
1755
  return;
1752
1756
  }
1753
- if (_ === G.BRUSH && c.current && !l.current) {
1754
- O = "scalar", b("drawing"), w().beginStroke(e);
1757
+ if (v === G.BRUSH && c.current && !l.current) {
1758
+ k = "scalar", x("drawing"), T().beginStroke(e);
1755
1759
  return;
1756
1760
  }
1757
- if (_ === G.POINT && c.current && u.button === 0) {
1758
- N = {
1761
+ if (v === G.POINT && c.current && u.button === 0) {
1762
+ P = {
1759
1763
  pointerId: u.pointerId,
1760
1764
  global: u.global,
1761
1765
  cancelled: !1
1762
1766
  };
1763
1767
  return;
1764
1768
  }
1765
- if (_ === G.SELECT) {
1766
- if (j = g.current ? a.current ? p.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
1767
- let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && z(e));
1769
+ if (v === G.SELECT) {
1770
+ if (M = _.current ? a.current ? m.getVertexSelection() : [] : null, !a.current && !l.current && s.current.length >= 2) {
1771
+ let t = o.current.getShapes().filter((e) => s.current.includes(e.id) && R(e));
1768
1772
  if (t.length) {
1769
1773
  let n = V(t.flatMap((e) => e.points));
1770
1774
  if (e.x >= n.minX && e.x <= n.maxX && e.y >= n.minY && e.y <= n.maxY) {
1771
- p.beginMove(e, s.current);
1775
+ m.beginMove(e, s.current);
1772
1776
  return;
1773
1777
  }
1774
1778
  }
1775
1779
  }
1776
- A = e, M = "", b("marquee"), y(null);
1780
+ j = e, N = "", x("marquee"), b(null);
1777
1781
  }
1778
1782
  },
1779
1783
  onPointerMove: (e, r) => {
1780
1784
  let i = t.current;
1781
1785
  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) {
1786
+ if (P && P.pointerId === r.pointerId && Math.hypot(r.global.x - P.global.x, r.global.y - P.global.y) > 4 && (P.cancelled = !0), D) {
1783
1787
  i.applyViewport({
1784
1788
  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;
1789
+ x: i.viewport.x + (r.global.x - D.px),
1790
+ y: i.viewport.y + (r.global.y - D.py)
1791
+ }), D.px = r.global.x, D.py = r.global.y;
1788
1792
  return;
1789
1793
  }
1790
1794
  let s = n.current;
1791
- I(i, s);
1792
- let l = ne();
1795
+ ie(i, s);
1796
+ let l = ae();
1793
1797
  if (l) {
1794
- l.onPointerMove?.(re(i, e, r));
1798
+ l.onPointerMove?.(oe(i, e, r));
1795
1799
  return;
1796
1800
  }
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);
1801
+ if (A) {
1802
+ let t = e.x - A.start.x, n = e.y - A.start.y;
1803
+ A.moved = A.moved || Math.hypot(t, n) > .5, T().moveDraftPoints(A.base, A.indices, t, n);
1800
1804
  return;
1801
1805
  }
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, {
1806
+ if (O && (te(s) || ne(s))) {
1807
+ let t = a.current ? ce(O, e) : e;
1808
+ i.previewBox(s === G.CIRCLE ? "ellipse" : "rect", O, t, {
1805
1809
  ...c.current,
1806
1810
  color: c.current?.color ?? "#00e5ff"
1807
- }), F(s) && C({
1808
- type: s === G.CIRCLE ? L.ELLIPSE : L.RECTANGLE,
1809
- points: [D, t]
1811
+ }), te(s) && w({
1812
+ type: s === G.CIRCLE ? I.ELLIPSE : I.RECTANGLE,
1813
+ points: [O, t]
1810
1814
  });
1811
1815
  return;
1812
1816
  }
1813
- if (O) {
1814
- w().appendStrokePoint(e, 2 / i.viewport.scale);
1817
+ if (k) {
1818
+ T().appendStrokePoint(e, 2 / i.viewport.scale);
1815
1819
  return;
1816
1820
  }
1817
- if (te(s) && w().hasDraftPoints()) {
1818
- w().setDraftCursor(e);
1821
+ if (F(s) && T().hasDraftPoints()) {
1822
+ T().setDraftCursor(e);
1819
1823
  return;
1820
1824
  }
1821
- if (A) {
1825
+ if (j) {
1822
1826
  if (u?.current) return;
1823
1827
  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)
1828
+ minX: Math.min(j.x, e.x),
1829
+ minY: Math.min(j.y, e.y),
1830
+ maxX: Math.max(j.x, e.x),
1831
+ maxY: Math.max(j.y, e.y)
1828
1832
  };
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));
1833
+ if (i.previewMarquee(j, e), M) {
1834
+ 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(",");
1835
+ r !== N && (N = r, i.setVertexSelection(n));
1832
1836
  return;
1833
1837
  }
1834
1838
  let n = i.shapesIntersecting(t), r = n.join(",");
1835
- r !== M && (M = r, m.current(n));
1839
+ r !== N && (N = r, h.current(n));
1836
1840
  }
1837
1841
  },
1838
1842
  onPointerUp: (e, r) => {
1839
1843
  let i = t.current;
1840
1844
  if (!i) return;
1841
- let o = N;
1842
- if (N = null, E) {
1843
- E = null, b("idle");
1845
+ let o = P;
1846
+ if (P = null, D) {
1847
+ D = null, x("idle");
1844
1848
  return;
1845
1849
  }
1846
1850
  let l = n.current;
1847
- if (I(i, l), k) {
1848
- w().commitDraftPointDrag(k.moved), k = null, b("idle");
1851
+ if (ie(i, l), A) {
1852
+ T().commitDraftPointDrag(A.moved), A = null, x("idle");
1849
1853
  return;
1850
1854
  }
1851
- let u = ne();
1855
+ let u = ae();
1852
1856
  if (u) {
1853
- u.onPointerUp?.(re(i, e, r));
1857
+ u.onPointerUp?.(oe(i, e, r));
1854
1858
  return;
1855
1859
  }
1856
1860
  let d = o ? Math.hypot(r.global.x - o.global.x, r.global.y - o.global.y) : Infinity;
1857
1861
  if (l === G.POINT && c.current && o && !o.cancelled && o.pointerId === r.pointerId && r.insideCanvas && d <= 4) {
1858
- p.current(L.POINT, [e]);
1862
+ m.current(I.POINT, [e]);
1859
1863
  return;
1860
1864
  }
1861
- if (O) {
1862
- let e = O;
1863
- O = null, b("idle"), e === "path" ? w().completeFreehandStroke() : w().finishScalarStroke();
1865
+ if (k) {
1866
+ let e = k;
1867
+ k = null, x("idle"), e === "path" ? T().completeFreehandStroke() : T().finishScalarStroke();
1864
1868
  return;
1865
1869
  }
1866
- if (D && ee(l)) {
1867
- let t = D;
1868
- D = null, b("idle"), i.clearPreview();
1870
+ if (O && ne(l)) {
1871
+ let t = O;
1872
+ O = null, x("idle"), i.clearPreview();
1869
1873
  let n = {
1870
1874
  x: Math.min(t.x, e.x),
1871
1875
  y: Math.min(t.y, e.y),
1872
1876
  width: Math.abs(e.x - t.x),
1873
1877
  height: Math.abs(e.y - t.y)
1874
1878
  };
1875
- n.width > 2 && n.height > 2 && T().beginBox(n, l === G.ASSISTANT_RECT ? "rect" : "polygon");
1879
+ n.width > 2 && n.height > 2 && E().beginBox(n, l === G.ASSISTANT_RECT ? "rect" : "polygon");
1876
1880
  return;
1877
1881
  }
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]));
1882
+ if (O && te(l)) {
1883
+ let t = a.current ? ce(O, e) : e, n = O;
1884
+ O = null, x("idle"), i.clearPreview(), w(null), Math.abs(t.x - n.x) > 2 && Math.abs(t.y - n.y) > 2 && (l === G.ROTATED_RECTANGLE ? m.current(I.ROTATED_RECTANGLE, ue([n, t])) : l === G.CIRCLE ? m.current(I.POLYGON, de(n, t)) : m.current(I.RECTANGLE, [n, t]));
1881
1885
  return;
1882
1886
  }
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([]);
1887
+ if (j) {
1888
+ let t = Math.abs(e.x - j.x) > 3 || Math.abs(e.y - j.y) > 3, n = M !== null;
1889
+ if (j = null, M = null, i.clearMarquee(), x("idle"), n && t) return;
1890
+ !t && s.current.length && h.current([]);
1887
1891
  }
1888
1892
  },
1889
- onViewportChange: x,
1890
- onTransformPreview: S,
1893
+ onViewportChange: S,
1894
+ onTransformPreview: C,
1891
1895
  onTransformCommit: (e) => {
1892
1896
  let t = o.current.getShapes(), n = e.map((e) => {
1893
1897
  let n = t.find((t) => t.id === e.id);
@@ -1912,7 +1916,7 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
1912
1916
  return e.map((e) => {
1913
1917
  if (t === "rect" && a) return {
1914
1918
  id: oe(),
1915
- type: L.ROTATED_RECTANGLE,
1919
+ type: I.ROTATED_RECTANGLE,
1916
1920
  points: pe(e),
1917
1921
  style: r,
1918
1922
  meta: n
@@ -1921,7 +1925,7 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
1921
1925
  let t = V(e);
1922
1926
  return {
1923
1927
  id: oe(),
1924
- type: L.RECTANGLE,
1928
+ type: I.RECTANGLE,
1925
1929
  points: [{
1926
1930
  x: t.minX,
1927
1931
  y: t.minY
@@ -1935,7 +1939,7 @@ function Zt({ docRef: e, draftRef: t, draftMeta: n, changeSelection: r, assistan
1935
1939
  }
1936
1940
  return {
1937
1941
  id: oe(),
1938
- type: L.POLYGON,
1942
+ type: I.POLYGON,
1939
1943
  points: e,
1940
1944
  style: r,
1941
1945
  meta: n
@@ -2188,11 +2192,11 @@ function un(e, t) {
2188
2192
  }
2189
2193
  function dn(e) {
2190
2194
  switch (e.type) {
2191
- case L.RECTANGLE: return e.points.length < 2 ? null : ue(e.points);
2192
- case L.POLYGON:
2193
- case L.ROTATED_RECTANGLE:
2194
- case L.ELLIPSE: return e.points.length >= 3 ? e.points : null;
2195
- case L.POINT: {
2195
+ case I.RECTANGLE: return e.points.length < 2 ? null : ue(e.points);
2196
+ case I.POLYGON:
2197
+ case I.ROTATED_RECTANGLE:
2198
+ case I.ELLIPSE: return e.points.length >= 3 ? e.points : null;
2199
+ case I.POINT: {
2196
2200
  let t = e.points[0];
2197
2201
  return t ? de({
2198
2202
  x: t.x - 6,
@@ -2307,18 +2311,18 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2307
2311
  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 = () => {
2308
2312
  let t = e.current;
2309
2313
  return t === G.BRUSH && N() ? "brush" : t === G.POLYGON && v.current.length > 0 ? "polygon" : t === G.PATH && v.current.length > 0 ? "path" : "none";
2310
- }, 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 = () => {
2314
+ }, ee = () => v.current.length > 0 || A.current > 0, te = () => v.current.length === 0 && A.current < k.current.length - 1, ne = () => C.current > 0, F = () => C.current < S.current.length - 1, re = () => {
2311
2315
  let t = e.current;
2312
- return t === G.BRUSH ? F() : t === G.POLYGON || t === G.PATH ? te() : !1;
2313
- }, re = () => {
2316
+ return t === G.BRUSH ? ee() : t === G.POLYGON || t === G.PATH ? ne() : !1;
2317
+ }, ie = () => {
2314
2318
  let t = e.current;
2315
- return t === G.BRUSH ? ee() : t === G.POLYGON || t === G.PATH ? I() : !1;
2316
- }, R = () => P() !== "none", z = x(() => {
2319
+ return t === G.BRUSH ? te() : t === G.POLYGON || t === G.PATH ? F() : !1;
2320
+ }, L = () => P() !== "none", R = x(() => {
2317
2321
  let e = P(), t = {
2318
2322
  active: e !== "none",
2319
2323
  kind: e,
2320
- canUndo: ne(),
2321
- canRedo: re(),
2324
+ canUndo: re(),
2325
+ canRedo: ie(),
2322
2326
  brush: e === "brush" ? {
2323
2327
  mode: j.current,
2324
2328
  editing: D.current.length > 0,
@@ -2326,7 +2330,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2326
2330
  } : void 0
2327
2331
  }, n = _.current;
2328
2332
  n && xn(n, t) || (_.current = t, p.current?.(t));
2329
- }, []), ae = x(() => {
2333
+ }, []), z = x(() => {
2330
2334
  k.current = [[]], A.current = 0;
2331
2335
  }, []), B = x(() => {
2332
2336
  let t = c.current;
@@ -2362,7 +2366,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2362
2366
  if (t.previewPoly(r, y.current, o, !1, s, l), n === G.POLYGON || n === G.PATH) {
2363
2367
  let e = m.current;
2364
2368
  e && r !== w.current && (w.current = r, e({
2365
- type: L.POLYGON,
2369
+ type: I.POLYGON,
2366
2370
  points: vn(r),
2367
2371
  meta: h.current
2368
2372
  }));
@@ -2374,20 +2378,20 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2374
2378
  e
2375
2379
  ]), V = x((e) => {
2376
2380
  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) => {
2381
+ i && _n(i, t) || (k.current = [...n.slice(0, r + 1), t], A.current += 1, R());
2382
+ }, [R]), se = x((e) => {
2379
2383
  let t = S.current, n = C.current, r = t[n];
2380
2384
  r && yn(r, e) || (S.current = [...t.slice(0, n + 1), vn(e)], C.current += 1);
2381
2385
  }, []), 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();
2386
+ v.current = [], T.current = [], E.current = [], D.current = [], y.current = null, b.current = /* @__PURE__ */ new Set(), S.current = [[]], C.current = 0, w.current = null, z(), c.current?.clearPreview(), m.current?.(null), R();
2383
2387
  }, [
2384
2388
  c,
2385
- z,
2386
- ae
2389
+ R,
2390
+ z
2387
2391
  ]), 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();
2392
+ v.current = e, b.current = new Set(Array.from(b.current).filter((t) => t >= 0 && t < e.length)), t && se(e), B(), R();
2389
2393
  }, [
2390
- z,
2394
+ R,
2391
2395
  se,
2392
2396
  B
2393
2397
  ]), le = x(() => vn(v.current), []), ue = x(() => v.current.length > 0, []), de = x((t, n) => {
@@ -2395,7 +2399,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2395
2399
  let r = v.current;
2396
2400
  if (r.length < 3) return !1;
2397
2401
  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);
2402
+ return Math.hypot(t.x - i.x, t.y - i.y) > n ? !1 : (g.current(I.POLYGON, r), H(), !0);
2399
2403
  }, [H, e]), fe = x((e) => {
2400
2404
  let t = v.current;
2401
2405
  return e < 0 || e >= t.length ? !1 : (ce(t.filter((t, n) => n !== e), !0), !0);
@@ -2403,32 +2407,32 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2403
2407
  let n = v.current;
2404
2408
  if (e < 0 || e >= n.length) return null;
2405
2409
  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(), {
2410
+ 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(), R(), {
2407
2411
  base: vn(n),
2408
2412
  indices: Array.from(r)
2409
2413
  };
2410
- }, [z, B]), me = x((e) => {
2414
+ }, [R, B]), me = x((e) => {
2411
2415
  b.current = /* @__PURE__ */ new Set(), y.current = e, ce([...v.current, e], !0);
2412
2416
  }, [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) => {
2417
+ y.current = null, b.current = /* @__PURE__ */ new Set(), v.current = [{ ...e }], B(), R();
2418
+ }, [R, B]), ge = x((e, t) => {
2415
2419
  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) => {
2420
+ return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (v.current = [...v.current, { ...e }], y.current = null, B(), R(), !0);
2421
+ }, [R, B]), _e = x((e, t, n, r) => {
2418
2422
  let i = new Set(t);
2419
2423
  v.current = e.map((e, t) => i.has(t) ? {
2420
2424
  x: e.x + n,
2421
2425
  y: e.y + r
2422
- } : { ...e }), y.current = null, B(), z();
2423
- }, [z, B]), ve = x((e) => {
2424
- e && (se(v.current), B(), z());
2426
+ } : { ...e }), y.current = null, B(), R();
2427
+ }, [R, B]), ve = x((e) => {
2428
+ e && (se(v.current), B(), R());
2425
2429
  }, [
2426
- z,
2430
+ R,
2427
2431
  se,
2428
2432
  B
2429
2433
  ]), ye = x((e) => {
2430
2434
  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(() => {
2435
+ }, [B]), be = x(() => v.current.length > 0 ? (v.current = [], B(), R(), !0) : A.current <= 0 ? !1 : (--A.current, T.current = gn(k.current[A.current]), B(), R(), !0), [R, 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(), R(), !0), [R, B]), Se = x(() => C.current <= 0 ? !1 : (--C.current, v.current = vn(S.current[C.current]), b.current = /* @__PURE__ */ new Set(), B(), R(), !0), [R, 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(), R(), !0), [R, B]), we = x(() => {
2432
2436
  let t = e.current;
2433
2437
  return t === G.BRUSH ? be() : t === G.POLYGON || t === G.PATH ? Se() : !1;
2434
2438
  }, [
@@ -2442,12 +2446,12 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2442
2446
  xe,
2443
2447
  Ce,
2444
2448
  e
2445
- ]), U = x(() => {
2449
+ ]), Ee = x(() => {
2446
2450
  let e = t.current;
2447
2451
  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);
2452
+ let r = n.current.getShapes().filter((t) => e.includes(t.id) && ae(t)), i = fn(r);
2449
2453
  return i.length ? (D.current = r.map((e) => e.id), E.current = i, !0) : (D.current = [], E.current = [], !1);
2450
- }, [n, t]), Ee = x(() => {
2454
+ }, [n, t]), U = x(() => {
2451
2455
  if (r.current) return !1;
2452
2456
  let e = [...T.current];
2453
2457
  v.current.length && e.push({
@@ -2470,7 +2474,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2470
2474
  let r = e[n];
2471
2475
  t.push({
2472
2476
  ...r,
2473
- type: L.POLYGON,
2477
+ type: I.POLYGON,
2474
2478
  points: a
2475
2479
  }), i.push(r.id);
2476
2480
  } else {
@@ -2478,7 +2482,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2478
2482
  r.push({
2479
2483
  ...t,
2480
2484
  id: n,
2481
- type: L.POLYGON,
2485
+ type: I.POLYGON,
2482
2486
  points: a
2483
2487
  }), i.push(n);
2484
2488
  }
@@ -2491,7 +2495,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2491
2495
  if (!f) return !1;
2492
2496
  let p = u.map((e) => ({
2493
2497
  id: oe(),
2494
- type: L.POLYGON,
2498
+ type: I.POLYGON,
2495
2499
  points: e,
2496
2500
  style: f,
2497
2501
  meta: s
@@ -2507,40 +2511,40 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2507
2511
  H
2508
2512
  ]), De = x(() => {
2509
2513
  let t = e.current;
2510
- if (t === G.BRUSH) return Ee();
2514
+ if (t === G.BRUSH) return U();
2511
2515
  let n = v.current;
2512
- return t === G.POLYGON && n.length >= 3 ? (g.current(L.POLYGON, n), H(), !0) : !1;
2516
+ return t === G.POLYGON && n.length >= 3 ? (g.current(I.POLYGON, n), H(), !0) : !1;
2513
2517
  }, [
2514
- Ee,
2518
+ U,
2515
2519
  H,
2516
2520
  e
2517
2521
  ]), W = x(() => {
2518
2522
  let t = v.current;
2519
2523
  if (e.current === G.PATH && t.length >= 3) {
2520
2524
  let e = $t(t, o.current);
2521
- e.length >= 3 && g.current(L.POLYGON, e);
2525
+ e.length >= 3 && g.current(I.POLYGON, e);
2522
2526
  }
2523
2527
  H();
2524
2528
  }, [H, e]), Oe = x((e) => {
2525
- j.current = e, z(), B();
2526
- }, [z, B]), ke = x(() => {
2529
+ j.current = e, R(), B();
2530
+ }, [R, B]), ke = x(() => {
2527
2531
  if (r.current || e.current !== G.BRUSH) return !1;
2528
- T.current = [], v.current = [], ae();
2529
- let t = U();
2530
- return z(), B(), t;
2532
+ T.current = [], v.current = [], z();
2533
+ let t = Ee();
2534
+ return R(), B(), t;
2531
2535
  }, [
2532
- z,
2536
+ R,
2533
2537
  r,
2534
2538
  B,
2535
- ae,
2536
- U,
2539
+ z,
2540
+ Ee,
2537
2541
  e
2538
2542
  ]), Ae = x(() => {
2539
2543
  let e = b.current;
2540
2544
  if (!e.size) return !1;
2541
2545
  let t = v.current.filter((t, n) => !e.has(n));
2542
2546
  return b.current = /* @__PURE__ */ new Set(), ce(t, !0), !0;
2543
- }, [ce]), K = x((e) => {
2547
+ }, [ce]), je = x((e) => {
2544
2548
  let t = c.current, n = v.current;
2545
2549
  if (!t || !n.length) return -1;
2546
2550
  let r = bn / (t.viewport.scale || 1);
@@ -2549,13 +2553,13 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2549
2553
  if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
2550
2554
  }
2551
2555
  return -1;
2552
- }, [c]), je = x(() => {
2556
+ }, [c]), K = x(() => {
2553
2557
  v.current.length >= 1 && (T.current.push({
2554
2558
  points: vn(v.current),
2555
2559
  mode: M()
2556
- }), v.current = [], V(T.current)), B(), z();
2560
+ }), v.current = [], V(T.current)), B(), R();
2557
2561
  }, [
2558
- z,
2562
+ R,
2559
2563
  V,
2560
2564
  B
2561
2565
  ]);
@@ -2563,22 +2567,22 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2563
2567
  reset: H,
2564
2568
  undoSession: we,
2565
2569
  redoSession: Te,
2566
- canUndoSession: ne,
2567
- canRedoSession: re,
2568
- hasDraftSession: R,
2570
+ canUndoSession: re,
2571
+ canRedoSession: ie,
2572
+ hasDraftSession: L,
2569
2573
  hasDraftPoints: ue,
2570
2574
  commitDraftSession: De,
2571
2575
  completeFreehandStroke: W,
2572
2576
  setBrushScalarMode: Oe,
2573
2577
  getBrushScalarMode: () => j.current,
2574
2578
  hasBrushSession: N,
2575
- commitBrush: Ee,
2579
+ commitBrush: U,
2576
2580
  cancelBrush: x(() => {
2577
2581
  e.current === G.BRUSH && H();
2578
2582
  }, [H, e]),
2579
2583
  beginBrushEditFromSelection: ke,
2580
2584
  deleteDraftSelectedPoints: Ae,
2581
- hitDraftPoint: K,
2585
+ hitDraftPoint: je,
2582
2586
  getDraftPointsSnapshot: le,
2583
2587
  tryClosePolygon: de,
2584
2588
  removeDraftPoint: fe,
@@ -2589,7 +2593,7 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2589
2593
  moveDraftPoints: _e,
2590
2594
  commitDraftPointDrag: ve,
2591
2595
  setDraftCursor: ye,
2592
- finishScalarStroke: je,
2596
+ finishScalarStroke: K,
2593
2597
  handleToolChange: x((e, t) => {
2594
2598
  if (t) {
2595
2599
  H(), j.current = "draw";
@@ -2599,27 +2603,27 @@ function Sn({ toolRef: e, selRef: t, docRef: n, readOnlyRef: r, draftRef: i, bru
2599
2603
  H(), j.current = "draw";
2600
2604
  return;
2601
2605
  }
2602
- j.current = "draw", T.current = [], v.current = [], ae(), U(), z(), B();
2606
+ j.current = "draw", T.current = [], v.current = [], z(), Ee(), R(), B();
2603
2607
  }, [
2604
- z,
2608
+ R,
2605
2609
  B,
2606
2610
  H,
2607
- ae,
2608
- U
2611
+ z,
2612
+ Ee
2609
2613
  ]),
2610
2614
  handleBrushSelectionChange: x((t, n) => {
2611
2615
  if (!(e.current !== G.BRUSH || n)) {
2612
2616
  if (!t.length) {
2613
- z();
2617
+ R();
2614
2618
  return;
2615
2619
  }
2616
- [...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], ae(), U(), z(), B()));
2620
+ [...t].sort().join(",") !== [...D.current].sort().join(",") && (T.current.length || v.current.length || (T.current = [], v.current = [], z(), Ee(), R(), B()));
2617
2621
  }
2618
2622
  }, [
2619
- z,
2623
+ R,
2620
2624
  B,
2621
- ae,
2622
- U,
2625
+ z,
2626
+ Ee,
2623
2627
  e
2624
2628
  ])
2625
2629
  };
@@ -3043,14 +3047,14 @@ function Jn(e, t) {
3043
3047
  //#endregion
3044
3048
  //#region src/components/ShapeEditor/_model/konva.ts
3045
3049
  function Yn(e, t, n) {
3046
- if (t === L.POINT) {
3050
+ if (t === I.POINT) {
3047
3051
  e.setAttrs({
3048
3052
  x: n[0].x,
3049
3053
  y: n[0].y
3050
3054
  });
3051
3055
  return;
3052
3056
  }
3053
- if (t === L.RECTANGLE) {
3057
+ if (t === I.RECTANGLE) {
3054
3058
  let [t, r] = n;
3055
3059
  e.setAttrs({
3056
3060
  x: Math.min(t.x, r.x),
@@ -3060,7 +3064,7 @@ function Yn(e, t, n) {
3060
3064
  });
3061
3065
  return;
3062
3066
  }
3063
- if (t === L.ELLIPSE) {
3067
+ if (t === I.ELLIPSE) {
3064
3068
  let t = V(n);
3065
3069
  e.setAttrs({
3066
3070
  x: (t.minX + t.maxX) / 2,
@@ -3078,15 +3082,15 @@ function Yn(e, t, n) {
3078
3082
  }
3079
3083
  //#endregion
3080
3084
  //#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;
3085
+ var Xn = "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", Zn = "#ffffff", Q = 1.5;
3082
3086
  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>`;
3087
+ return `<svg width="16" height="22" viewBox="0 0 16 22" xmlns="http://www.w3.org/2000/svg"><path d="${Xn}" fill="${e}" stroke="${Zn}" stroke-width="${Q}"/></svg>`;
3084
3088
  }
3085
3089
  //#endregion
3086
3090
  //#region src/components/ShapeEditor/_renderers/transformSession.ts
3087
3091
  var $n = Math.PI / 12;
3088
3092
  function er(e, t) {
3089
- 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;
3093
+ return t.kind !== "resize" && t.kind !== "move" || t.shapes.length !== 1 ? !1 : e.find((e) => e.id === t.shapes[0].id)?.type === I.ROTATED_RECTANGLE;
3090
3094
  }
3091
3095
  function tr(e, t, n) {
3092
3096
  if (e.kind === "resize") {
@@ -3146,7 +3150,7 @@ function nr(e, t) {
3146
3150
  } : er(e, t) ? be(t.shapes[0].points)[B.indexOf(t.anchor)] : se(t.anchor, t.box);
3147
3151
  }
3148
3152
  function rr(e, t, n) {
3149
- let r = e.filter((e) => t.includes(e.id) && z(e)).map((e) => ({
3153
+ let r = e.filter((e) => t.includes(e.id) && R(e)).map((e) => ({
3150
3154
  id: e.id,
3151
3155
  points: e.points
3152
3156
  }));
@@ -3165,11 +3169,11 @@ function ir(e) {
3165
3169
  }
3166
3170
  function ar(e, t) {
3167
3171
  let n = new Set(t);
3168
- return e.filter((e) => n.has(e.id) && ie(e));
3172
+ return e.filter((e) => n.has(e.id) && ae(e));
3169
3173
  }
3170
3174
  function or(e, t) {
3171
3175
  return e.filter((e) => {
3172
- if (!R(e)) return !1;
3176
+ if (!L(e)) return !1;
3173
3177
  let n = V(e.points);
3174
3178
  return n.minX <= t.maxX && n.maxX >= t.minX && n.minY <= t.maxY && n.maxY >= t.minY;
3175
3179
  }).map((e) => e.id);
@@ -3186,8 +3190,8 @@ function cr(e, t) {
3186
3190
  };
3187
3191
  }
3188
3192
  function lr(e, t, n) {
3189
- if (e.type === L.ROTATED_RECTANGLE) return t;
3190
- let r = e.type === L.POINT ? cr(t[0], n) : V(t);
3193
+ if (e.type === I.ROTATED_RECTANGLE) return t;
3194
+ let r = e.type === I.POINT ? cr(t[0], n) : V(t);
3191
3195
  return ue([{
3192
3196
  x: r.minX,
3193
3197
  y: r.minY
@@ -3467,9 +3471,9 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3467
3471
  setShapes(e, t) {
3468
3472
  if (this.shapes = ir(e), this.selected = t, !this.activeDrag) {
3469
3473
  this.shapeGroup.destroyChildren(), this.nodes.clear(), this.altNodes.clear();
3470
- for (let t of ae(e).filter(ne)) {
3474
+ for (let t of z(e).filter(re)) {
3471
3475
  let e = this.makeNode(t), n = Ue(t, { strokeWidth: this.strokeSize });
3472
- if (t.style?.alternateColor && n.dash?.length && t.type !== L.POINT) {
3476
+ if (t.style?.alternateColor && n.dash?.length && t.type !== I.POINT) {
3473
3477
  let n = e.clone({
3474
3478
  id: `${t.id}__alt`,
3475
3479
  stroke: t.style.alternateColor,
@@ -3499,7 +3503,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3499
3503
  t.size === this.selectedVertices.size && [...t].every((e) => this.selectedVertices.has(e)) || (this.selectedVertices = t, this.activeDrag || (this.drawTransformer(), this.layer.batchDraw()));
3500
3504
  }
3501
3505
  makeNode(e) {
3502
- let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i = R(e), a = {
3506
+ let { type: t, points: n } = e, r = Ue(e, { strokeWidth: this.strokeSize }), i = L(e), a = {
3503
3507
  id: e.id,
3504
3508
  stroke: r.color,
3505
3509
  strokeWidth: r.strokeWidth,
@@ -3508,10 +3512,10 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3508
3512
  strokeScaleEnabled: !1,
3509
3513
  listening: i
3510
3514
  }, o = r.fillVisible ? We(r.color, r.fillAlpha) : void 0;
3511
- if (t === L.POINT) {
3515
+ if (t === I.POINT) {
3512
3516
  let t = 1 / (this.world.scaleX() || 1), a = new A.Path({
3513
3517
  id: e.id,
3514
- data: Q,
3518
+ data: Xn,
3515
3519
  x: n[0].x,
3516
3520
  y: n[0].y,
3517
3521
  offsetX: 16 / 2,
@@ -3519,8 +3523,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3519
3523
  scaleX: t,
3520
3524
  scaleY: t,
3521
3525
  fill: r.color,
3522
- stroke: Xn,
3523
- strokeWidth: Zn,
3526
+ stroke: Zn,
3527
+ strokeWidth: Q,
3524
3528
  strokeScaleEnabled: !1,
3525
3529
  shadowColor: "#000",
3526
3530
  shadowBlur: 2,
@@ -3529,9 +3533,9 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3529
3533
  opacity: r.opacity,
3530
3534
  listening: i
3531
3535
  });
3532
- return this.bindCursor(a, z(e) ? "grab" : "default"), a;
3536
+ return this.bindCursor(a, R(e) ? "grab" : "default"), a;
3533
3537
  }
3534
- if (t === L.RECTANGLE) {
3538
+ if (t === I.RECTANGLE) {
3535
3539
  let t = V(n), r = new A.Rect({
3536
3540
  x: t.minX,
3537
3541
  y: t.minY,
@@ -3540,9 +3544,9 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3540
3544
  fill: o,
3541
3545
  ...a
3542
3546
  });
3543
- return this.bindCursor(r, z(e) ? "grab" : "default"), r;
3547
+ return this.bindCursor(r, R(e) ? "grab" : "default"), r;
3544
3548
  }
3545
- if (t === L.ELLIPSE) {
3549
+ if (t === I.ELLIPSE) {
3546
3550
  let t = V(n), r = new A.Ellipse({
3547
3551
  x: (t.minX + t.maxX) / 2,
3548
3552
  y: (t.minY + t.maxY) / 2,
@@ -3551,23 +3555,23 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3551
3555
  fill: o,
3552
3556
  ...a
3553
3557
  });
3554
- return this.bindCursor(r, z(e) ? "grab" : "default"), r;
3558
+ return this.bindCursor(r, R(e) ? "grab" : "default"), r;
3555
3559
  }
3556
- let s = n.flatMap((e) => [e.x, e.y]), c = t !== L.LINE, l = new A.Line({
3560
+ let s = n.flatMap((e) => [e.x, e.y]), c = t !== I.LINE, l = new A.Line({
3557
3561
  points: s,
3558
3562
  closed: c,
3559
3563
  fill: c ? o : void 0,
3560
3564
  lineJoin: "round",
3561
3565
  ...a
3562
3566
  });
3563
- return this.bindCursor(l, z(e) ? "grab" : "default"), l;
3567
+ return this.bindCursor(l, R(e) ? "grab" : "default"), l;
3564
3568
  }
3565
3569
  liveUpdateShape(e, t) {
3566
3570
  let n = this.nodes.get(e), r = this.shapes.find((t) => t.id === e);
3567
3571
  if (n && r) {
3568
3572
  Yn(n, r.type, t);
3569
3573
  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();
3574
+ i && Yn(i, r.type, t), r.type === I.POINT && n instanceof A.Circle && n.radius(this.pointRadius(r)), this.layer.batchDraw();
3571
3575
  }
3572
3576
  }
3573
3577
  pointRadius(e) {
@@ -3580,7 +3584,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3580
3584
  let e = 1 / (this.world.scaleX() || 1);
3581
3585
  for (let t of this.shapes) {
3582
3586
  let n = this.nodes.get(t.id);
3583
- if (t.type === L.POINT) {
3587
+ if (t.type === I.POINT) {
3584
3588
  n?.scale({
3585
3589
  x: e,
3586
3590
  y: e
@@ -3594,7 +3598,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3594
3598
  return or(this.shapes, e);
3595
3599
  }
3596
3600
  drawSelectionBorders() {
3597
- let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && R(t)) : [];
3601
+ let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && L(t)) : [];
3598
3602
  if (this.selectionBorders.length !== t.length) {
3599
3603
  for (let e of this.selectionBorders) e.destroy();
3600
3604
  this.selectionBorders = t.map(() => {
@@ -3615,7 +3619,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3615
3619
  updateSelectionBordersLive(e) {
3616
3620
  let t = new Set(this.selected), n = 0;
3617
3621
  for (let r of this.shapes) {
3618
- if (!t.has(r.id) || !R(r)) continue;
3622
+ if (!t.has(r.id) || !L(r)) continue;
3619
3623
  let i = this.selectionOutlinePoints(r, e(r)), a = this.selectionBorders[n++];
3620
3624
  a && a.points(i.flatMap((e) => [e.x, e.y]));
3621
3625
  }
@@ -3803,8 +3807,8 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3803
3807
  for (let e of this.midNodes) e.destroy();
3804
3808
  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
3809
  let e = ar(this.shapes, this.selected);
3806
- 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));
3810
+ if (!e.length || e.length === 1 && e[0].type === I.POINT) return;
3811
+ let t = e.length === 1 && (e[0].type === I.POLYGON || e[0].type === I.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === I.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
3808
3812
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
3809
3813
  let a = r ? this.orientedHandleAngle(r.points) : 0;
3810
3814
  for (let e of t ? [] : B) {
@@ -3835,7 +3839,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3835
3839
  }), this.handleGroup.add(n), this.handleNodes.push(n);
3836
3840
  }
3837
3841
  if (t) {
3838
- let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new A.Circle({
3842
+ let e = t, n = e.points, r = e.type === I.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new A.Circle({
3839
3843
  radius: i * .8,
3840
3844
  fill: "#ffffff",
3841
3845
  opacity: .6,
@@ -3919,7 +3923,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3919
3923
  }), this.handleGroup.add(s), this.vertexNodes.push(s);
3920
3924
  });
3921
3925
  }
3922
- if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
3926
+ if (e.length === 1 && e[0].type === I.ROTATED_RECTANGLE) {
3923
3927
  let t = e[0], n = ye(t.points), r = this.rotationHandleScreenPoint(t.points), i = new A.Circle({
3924
3928
  x: r.x,
3925
3929
  y: r.y,
@@ -3945,7 +3949,7 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3945
3949
  }
3946
3950
  beginMove(e, t) {
3947
3951
  let n = rr(this.shapes, t, e);
3948
- 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));
3952
+ 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 === I.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
3949
3953
  }
3950
3954
  repositionHandles(e) {
3951
3955
  B.forEach((t, n) => {
@@ -3990,16 +3994,16 @@ var fr = 2, pr = "#1e88e5", mr = "#669def", hr = class {
3990
3994
  for (let e of r) this.liveUpdateShape(e.id, e.points);
3991
3995
  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
3996
  n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandles(i);
3993
- let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
3994
- (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
3997
+ let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === I.POLYGON || e?.type === I.LINE;
3998
+ (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
3995
3999
  } else if (t.kind === "rotate") {
3996
4000
  this.repositionOrientedHandles(r[0].points);
3997
4001
  let e = this.shapes.find((e) => e.id === t.id);
3998
- e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
4002
+ e && (e.type === I.POLYGON || e.type === I.LINE) && this.repositionPolygonHandles(r[0].points, e.type === I.POLYGON);
3999
4003
  } else {
4000
4004
  i && this.repositionHandles(i);
4001
4005
  let e = this.shapes.find((e) => e.id === t.id);
4002
- this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
4006
+ this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
4003
4007
  }
4004
4008
  this.layer.batchDraw();
4005
4009
  }
@@ -4084,7 +4088,7 @@ var yr = class {
4084
4088
  }
4085
4089
  syncHitArea() {
4086
4090
  let { w: e, h: t } = this.screenSize;
4087
- this.app.stage.hitArea = new ee(0, 0, e, t);
4091
+ this.app.stage.hitArea = new te(0, 0, e, t);
4088
4092
  }
4089
4093
  destroy() {
4090
4094
  this.destroyed = !0, this.clearImageTiles();
@@ -4139,9 +4143,9 @@ var yr = class {
4139
4143
  let a = n?.width ?? this.imageWidth, o = n?.height ?? this.imageHeight;
4140
4144
  this.bgLayer.scale.set(a / i.naturalWidth, o / i.naturalHeight), this.clearImageTiles();
4141
4145
  for (let e of qn(i.naturalWidth, i.naturalHeight, this.tileSize)) {
4142
- let t = I.from(Jn(i, e));
4146
+ let t = F.from(Jn(i, e));
4143
4147
  t.source.scaleMode = this.imageSmoothing ? "linear" : "nearest", this.imageTileTextures.push(t);
4144
- let n = new te(t);
4148
+ let n = new ne(t);
4145
4149
  n.x = e.x, n.y = e.y, n.width = e.width, n.height = e.height, this.bgLayer.addChild(n);
4146
4150
  }
4147
4151
  return this.applySpriteFilter(), !0;
@@ -4184,9 +4188,9 @@ var yr = class {
4184
4188
  for (let e of this.guideOverlayLayer.removeChildren()) e.destroy();
4185
4189
  for (let e of this.overlayTextures) e.destroy(!0);
4186
4190
  if (this.overlayTextures = [], e) {
4187
- let t = I.from(e);
4191
+ let t = F.from(e);
4188
4192
  t.source.scaleMode = "nearest", this.overlayTextures.push(t);
4189
- let n = new te(t);
4193
+ let n = new ne(t);
4190
4194
  n.alpha = .55, this.guideOverlayLayer.addChild(n);
4191
4195
  }
4192
4196
  this.setRegionOverlay(t);
@@ -4293,9 +4297,9 @@ var yr = class {
4293
4297
  this.shapeLayer.removeChildren();
4294
4298
  for (let e of this.nodes.values()) e.destroy();
4295
4299
  this.nodes.clear();
4296
- for (let e of ae(this.shapes).filter(ne)) {
4300
+ for (let e of z(this.shapes).filter(re)) {
4297
4301
  let t = new P();
4298
- this.paintShape(t, e), t.eventMode = R(e) ? "static" : "none", t.cursor = void 0, R(e) && z(e) && (t.on("pointerover", () => {
4302
+ this.paintShape(t, e), t.eventMode = L(e) ? "static" : "none", t.cursor = void 0, L(e) && R(e) && (t.on("pointerover", () => {
4299
4303
  !this.activeDrag && this.transformEnabled && this.emitCursorHint("grab");
4300
4304
  }), t.on("pointerout", () => {
4301
4305
  this.activeDrag || this.emitCursorHint(null);
@@ -4307,14 +4311,14 @@ var yr = class {
4307
4311
  paintShape(e, t) {
4308
4312
  e.clear();
4309
4313
  let n = Ue(t, { strokeWidth: this.strokeSize }), r = $(n.color), i = this.strokeW(t), a = n.opacity, o = this.dashForShape(t);
4310
- if (t.type === L.POINT) {
4314
+ if (t.type === I.POINT) {
4311
4315
  e.svg(Qn(n.color)), e.position.set(t.points[0].x, t.points[0].y), e.pivot.set(16 / 2, 22);
4312
4316
  let r = 1 / (this.world.scale.x || 1);
4313
4317
  e.scale.set(r, r), e.alpha = a;
4314
4318
  return;
4315
4319
  }
4316
- if (n.fillVisible && t.type !== L.LINE) {
4317
- let i = t.type === L.POLYGON ? De(t.points) : null;
4320
+ if (n.fillVisible && t.type !== I.LINE) {
4321
+ let i = t.type === I.POLYGON ? De(t.points) : null;
4318
4322
  if (i && i.length > 1) for (let t of i) e.poly(t.flatMap((e) => [e.x, e.y]), !0), e.fill({
4319
4323
  color: r,
4320
4324
  alpha: n.fillAlpha * a
@@ -4323,7 +4327,7 @@ var yr = class {
4323
4327
  color: r,
4324
4328
  alpha: n.fillAlpha * a
4325
4329
  });
4326
- } else t.type !== L.LINE && (this.path(e, t), e.fill({
4330
+ } else t.type !== I.LINE && (this.path(e, t), e.fill({
4327
4331
  color: r,
4328
4332
  alpha: 0
4329
4333
  }));
@@ -4380,7 +4384,7 @@ var yr = class {
4380
4384
  }, this.ensurePreview(), this.previewG.clear();
4381
4385
  let i = {
4382
4386
  id: "__preview__",
4383
- type: e === "ellipse" ? L.ELLIPSE : L.RECTANGLE,
4387
+ type: e === "ellipse" ? I.ELLIPSE : I.RECTANGLE,
4384
4388
  points: [t, n],
4385
4389
  style: r
4386
4390
  }, a = this.strokeW(i);
@@ -4411,7 +4415,7 @@ var yr = class {
4411
4415
  }, this.ensurePreview(), this.previewG.clear(), !e.length) return;
4412
4416
  let o = t ? [...e, t] : e, s = {
4413
4417
  id: "__preview__",
4414
- type: r ? L.POLYGON : L.LINE,
4418
+ type: r ? I.POLYGON : I.LINE,
4415
4419
  points: o,
4416
4420
  style: n
4417
4421
  }, c = this.strokeW(s);
@@ -4437,7 +4441,7 @@ var yr = class {
4437
4441
  previewScalarMask(e, t) {
4438
4442
  this.lastPreview = null, this.ensurePreview(), this.previewG.clear();
4439
4443
  let n = hn(e, t.length === 7 ? `${t}99` : t);
4440
- 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;
4444
+ this.previewMaskTexture && this.previewMaskTexture.destroy(!0), this.previewMaskTexture = F.from(n), this.previewMaskSprite ? (this.previewMaskSprite.texture = this.previewMaskTexture, this.previewMaskSprite.visible = !0) : (this.previewMaskSprite = new ne(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
4445
  }
4442
4446
  previewMarquee(e, t) {
4443
4447
  this.ensurePreview(), this.marqueeG.clear();
@@ -4482,26 +4486,26 @@ var yr = class {
4482
4486
  }
4483
4487
  path(e, t) {
4484
4488
  let { type: n, points: r } = t;
4485
- if (n === L.POINT) {
4489
+ if (n === I.POINT) {
4486
4490
  e.circle(r[0].x, r[0].y, this.pointRadius(t));
4487
4491
  return;
4488
4492
  }
4489
- if (n === L.RECTANGLE) {
4493
+ if (n === I.RECTANGLE) {
4490
4494
  let t = V(r);
4491
4495
  e.rect(t.minX, t.minY, t.maxX - t.minX, t.maxY - t.minY);
4492
4496
  return;
4493
4497
  }
4494
- if (n === L.ELLIPSE) {
4498
+ if (n === I.ELLIPSE) {
4495
4499
  let t = V(r);
4496
4500
  e.ellipse((t.minX + t.maxX) / 2, (t.minY + t.maxY) / 2, (t.maxX - t.minX) / 2, (t.maxY - t.minY) / 2);
4497
4501
  return;
4498
4502
  }
4499
4503
  let i = r.flatMap((e) => [e.x, e.y]);
4500
- e.poly(i, n !== L.LINE);
4504
+ e.poly(i, n !== I.LINE);
4501
4505
  }
4502
4506
  dashedStrokeShape(e, t, n, r, i, a) {
4503
4507
  let { type: o, points: s } = t;
4504
- if (o === L.RECTANGLE) {
4508
+ if (o === I.RECTANGLE) {
4505
4509
  let t = V(s);
4506
4510
  this.strokeDashedPolyline(e, [
4507
4511
  {
@@ -4523,7 +4527,7 @@ var yr = class {
4523
4527
  ], !0, n, r, i, a);
4524
4528
  return;
4525
4529
  }
4526
- if (o === L.ELLIPSE) {
4530
+ if (o === I.ELLIPSE) {
4527
4531
  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) => {
4528
4532
  let n = t / 96 * Math.PI * 2;
4529
4533
  return {
@@ -4534,7 +4538,7 @@ var yr = class {
4534
4538
  this.strokeDashedPolyline(e, d, !0, n, r, i, a);
4535
4539
  return;
4536
4540
  }
4537
- this.strokeDashedPolyline(e, s, o !== L.LINE, n, r, i, a);
4541
+ this.strokeDashedPolyline(e, s, o !== I.LINE, n, r, i, a);
4538
4542
  }
4539
4543
  strokeDashedPolyline(e, t, n, r, i, a, o) {
4540
4544
  if (t.length < 2) return;
@@ -4575,7 +4579,7 @@ var yr = class {
4575
4579
  }
4576
4580
  drawSelectionBorders() {
4577
4581
  this.selLayer.position.set(0, 0);
4578
- let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && R(t)) : [];
4582
+ let e = new Set(this.selected), t = this.selected.length ? this.shapes.filter((t) => e.has(t.id) && L(t)) : [];
4579
4583
  if (this.selectionBorderGfx.length !== t.length) {
4580
4584
  for (let e of this.selectionBorderGfx) e.destroy();
4581
4585
  this.selectionBorderGfx = t.map(() => {
@@ -4595,7 +4599,7 @@ var yr = class {
4595
4599
  updateSelectionBordersLive(e) {
4596
4600
  let t = new Set(this.selected), n = 1.5 / this.world.scale.x, r = 0;
4597
4601
  for (let i of this.shapes) {
4598
- if (!t.has(i.id) || !R(i)) continue;
4602
+ if (!t.has(i.id) || !L(i)) continue;
4599
4603
  let a = this.selectionBorderGfx[r++];
4600
4604
  a && (a.clear(), a.poly(this.selectionOutlinePoints(i, e(i)).flatMap((e) => [e.x, e.y]), !0).stroke({
4601
4605
  width: n,
@@ -4658,8 +4662,8 @@ var yr = class {
4658
4662
  for (let e of this.midNodes) e.destroy();
4659
4663
  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
4664
  let e = ar(this.shapes, this.selected);
4661
- 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));
4665
+ if (e.length === 0 || e.length === 1 && e[0].type === I.POINT) return;
4666
+ let t = e.length === 1 && (e[0].type === I.POLYGON || e[0].type === I.LINE) && this.editingId === e[0].id ? e[0] : null, n = V(e.flatMap((e) => e.points)), r = e.length === 1 && e[0].type === I.ROTATED_RECTANGLE ? e[0] : null, i = r ? be(r.points) : B.map((e) => se(e, n));
4663
4667
  r ? this.setTransformerOutlinePoints(r.points) : this.setTransformerOutline(n), r && this.setRotationConnector(r.points);
4664
4668
  let a = r ? this.orientedHandleAngle(r.points) : 0;
4665
4669
  for (let e of t ? [] : B) {
@@ -4684,7 +4688,7 @@ var yr = class {
4684
4688
  }), this.handleLayer.addChild(n), this.handleNodes.push(n);
4685
4689
  }
4686
4690
  if (t) {
4687
- let e = t, n = e.points, r = e.type === L.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new P();
4691
+ let e = t, n = e.points, r = e.type === I.POLYGON ? n.length : n.length - 1, i = this.vertexHandleRadius(), a = new P();
4688
4692
  a.circle(0, 0, i * .8).fill({
4689
4693
  color: 16777215,
4690
4694
  alpha: .6
@@ -4748,7 +4752,7 @@ var yr = class {
4748
4752
  }), this.handleLayer.addChild(s), this.vertexNodes.push(s);
4749
4753
  });
4750
4754
  }
4751
- if (e.length === 1 && e[0].type === L.ROTATED_RECTANGLE) {
4755
+ if (e.length === 1 && e[0].type === I.ROTATED_RECTANGLE) {
4752
4756
  let t = e[0], n = ye(t.points), r = this.rotationHandleScreenPoint(t.points), i = new P();
4753
4757
  i.circle(0, 0, 6).fill({ color: 16777215 }).stroke({
4754
4758
  width: 1.5,
@@ -4769,7 +4773,7 @@ var yr = class {
4769
4773
  }
4770
4774
  beginMove(e, t) {
4771
4775
  let n = rr(this.shapes, t, e);
4772
- 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));
4776
+ 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 === I.ROTATED_RECTANGLE ? this.setTransformerOutlinePoints(n.shapes[0].points) : this.setTransformerOutline(n.box), this.updateSelectionBordersLive((e) => e.points));
4773
4777
  }
4774
4778
  repositionHandlesForBox(e) {
4775
4779
  B.forEach((t, n) => {
@@ -4802,7 +4806,7 @@ var yr = class {
4802
4806
  }
4803
4807
  edgeHitQuad(e, t) {
4804
4808
  let n = Math.max(7, this.vertexHandleRadius() + 2), r = this.imgToScreen(e), i = this.imgToScreen(t), a = i.x - r.x, o = i.y - r.y, s = Math.hypot(a, o) || 1, c = -o / s * n, l = a / s * n;
4805
- return new F([
4809
+ return new ee([
4806
4810
  r.x + c,
4807
4811
  r.y + l,
4808
4812
  i.x + c,
@@ -4814,7 +4818,7 @@ var yr = class {
4814
4818
  ]);
4815
4819
  }
4816
4820
  resetMoveOffsets() {
4817
- for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !== L.POINT && t.position.set(0, 0);
4821
+ for (let [e, t] of this.nodes) this.shapes.find((t) => t.id === e)?.type !== I.POINT && t.position.set(0, 0);
4818
4822
  this.selLayer.position.set(0, 0);
4819
4823
  }
4820
4824
  commitTransformUpdates(e) {
@@ -4841,21 +4845,21 @@ var yr = class {
4841
4845
  let n = e.x - t.start.x, r = e.y - t.start.y;
4842
4846
  for (let e of t.shapes) {
4843
4847
  let t = this.nodes.get(e.id);
4844
- t && (this.shapes.find((t) => t.id === e.id)?.type === L.POINT ? t.position.set(e.points[0].x + n, e.points[0].y + r) : t.position.set(n, r));
4848
+ t && (this.shapes.find((t) => t.id === e.id)?.type === I.POINT ? t.position.set(e.points[0].x + n, e.points[0].y + r) : t.position.set(n, r));
4845
4849
  }
4846
4850
  } else for (let e of r) this.liveUpdateShape(e.id, e.points);
4847
4851
  if (this.cb.onTransformPreview?.(r), this.updateSelectionBordersLive((e) => r.find((t) => t.id === e.id)?.points ?? e.points), t.kind === "resize" || t.kind === "move") {
4848
4852
  n ? this.repositionOrientedHandles(r[0].points) : i && this.repositionHandlesForBox(i);
4849
- let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === L.POLYGON || e?.type === L.LINE;
4850
- (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
4853
+ let e = t.shapes.length === 1 ? this.shapes.find((e) => e.id === t.shapes[0].id) : null, a = e?.type === I.POLYGON || e?.type === I.LINE;
4854
+ (t.kind === "resize" ? a : this.vertexNodes.length > 0 && t.shapes.length === 1) && this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
4851
4855
  } else if (t.kind === "rotate") {
4852
4856
  this.repositionOrientedHandles(r[0].points);
4853
4857
  let e = this.shapes.find((e) => e.id === t.id);
4854
- e && (e.type === L.POLYGON || e.type === L.LINE) && this.repositionPolygonHandles(r[0].points, e.type === L.POLYGON);
4858
+ e && (e.type === I.POLYGON || e.type === I.LINE) && this.repositionPolygonHandles(r[0].points, e.type === I.POLYGON);
4855
4859
  } else {
4856
4860
  i && this.repositionHandlesForBox(i);
4857
4861
  let e = this.shapes.find((e) => e.id === t.id);
4858
- this.repositionPolygonHandles(r[0].points, e?.type === L.POLYGON);
4862
+ this.repositionPolygonHandles(r[0].points, e?.type === I.POLYGON);
4859
4863
  }
4860
4864
  }
4861
4865
  endTransform() {
@@ -5131,13 +5135,13 @@ function Er({ engineRef: e, image: t, wheelZoom: n, minimapSize: r }) {
5131
5135
  //#region src/components/ShapeEditor/_state/useMinimapSync.ts
5132
5136
  function Dr(e, t, n) {
5133
5137
  if (!(!e || !n.length)) {
5134
- if (t.type === L.POINT) {
5138
+ if (t.type === I.POINT) {
5135
5139
  e.setAttribute("cx", String(n[0].x)), e.setAttribute("cy", String(n[0].y));
5136
5140
  return;
5137
5141
  }
5138
- if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
5142
+ if (t.type === I.RECTANGLE || t.type === I.ELLIPSE) {
5139
5143
  let r = V(n);
5140
- if (t.type === L.ELLIPSE) {
5144
+ if (t.type === I.ELLIPSE) {
5141
5145
  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
5146
  return;
5143
5147
  }
@@ -5199,7 +5203,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5199
5203
  }), []), S(() => {
5200
5204
  s.current = 0;
5201
5205
  }, [a]);
5202
- let f = x(() => r(e.getShapes().filter((e) => R(e)).map((e) => e.id)), [e, r]), p = x(() => r([]), [r]), m = x(() => e.getShapes().filter((e) => t.current.includes(e.id) && ie(e)), [e, t]), h = x(() => {
5206
+ let f = x(() => r(e.getShapes().filter((e) => L(e)).map((e) => e.id)), [e, r]), p = x(() => r([]), [r]), m = x(() => e.getShapes().filter((e) => t.current.includes(e.id) && ae(e)), [e, t]), h = x(() => {
5203
5207
  if (n || !t.current.length) return;
5204
5208
  let i = m().map((e) => e.id);
5205
5209
  i.length && (e.remove(i), r([]));
@@ -5216,10 +5220,10 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5216
5220
  a,
5217
5221
  o,
5218
5222
  m
5219
- ]), _ = x(() => Y(o), [o]), v = x((t) => {
5223
+ ]), _ = x(() => bt(o), [o]), v = x((t) => {
5220
5224
  if (n) return;
5221
5225
  let i = a;
5222
- bt(o).then((n) => {
5226
+ Y(o).then((n) => {
5223
5227
  if (!c.current || l.current || u.current !== i || d.current !== o || !n?.shapes.length) return;
5224
5228
  let f, p, m = n.shapes.flatMap((e) => e.points);
5225
5229
  if (t && m.length) {
@@ -5280,7 +5284,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5280
5284
  m
5281
5285
  ]), w = x((r, i) => {
5282
5286
  if (n || !t.current.length) return;
5283
- let a = e.getShapes().filter((e) => t.current.includes(e.id) && ie(e));
5287
+ let a = e.getShapes().filter((e) => t.current.includes(e.id) && ae(e));
5284
5288
  a.length && e.update(a.map((e) => ({
5285
5289
  ...e,
5286
5290
  points: e.points.map((e) => ({
@@ -5292,7 +5296,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5292
5296
  e,
5293
5297
  n,
5294
5298
  t
5295
- ]), T = x(() => m().filter((e) => e.type === L.POLYGON || e.type === L.RECTANGLE || e.type === L.ROTATED_RECTANGLE || e.type === L.ELLIPSE), [m]);
5299
+ ]), T = x(() => m().filter((e) => e.type === I.POLYGON || e.type === I.RECTANGLE || e.type === I.ROTATED_RECTANGLE || e.type === I.ELLIPSE), [m]);
5296
5300
  return {
5297
5301
  selectAll: f,
5298
5302
  clearSelection: p,
@@ -5316,7 +5320,7 @@ function Ar({ doc: e, selRef: t, effectiveReadOnly: n, changeSelection: r, canMe
5316
5320
  if (!o.length) return;
5317
5321
  let s = t[0], c = o.map((e) => ({
5318
5322
  id: oe(),
5319
- type: L.POLYGON,
5323
+ type: I.POLYGON,
5320
5324
  points: e,
5321
5325
  style: s.style,
5322
5326
  meta: s.meta
@@ -5414,118 +5418,120 @@ var Mr = "__draft_preview__", Nr = new Set([
5414
5418
  function Pr(e, t) {
5415
5419
  return e.length === t.length && e.every((e, n) => e === t[n]);
5416
5420
  }
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({
5421
+ 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, 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: ee = 20, zoomBound: te, zoomAnimationDuration: ne = 300, decorationShapes: F, regionMask: ie, guideMask: R, maskPalette: z, overlayMarkers: B, renderOverlayMarker: V, onOverlayMarkerClick: se, renderImageOverlay: H, getSelectionLabel: ce, hideSelectionLabelDot: le, formatSelectionInfo: ue, externalTools: de, assistant: fe, keymap: pe, handleRef: me, backend: he = "pixi", onActiveToolChange: ge, onSelectionChange: _e, onEditingChange: ve, onShapesCreated: ye, onShapesUpdated: be, onShapesDeleted: xe, onDrawSessionChange: Se, onDraftShapeChange: Ce, onViewportChange: we, onShapesTransformPreview: Te }) {
5422
+ let Ee = O(null), U = O(null), De = O(null), W = O(null), Ae = O(null), je = `${C()}-minimap`, [K, Me] = k(null), [Pe, Re] = k(!1), [ze, Be] = k(!1), [Ve, He] = k(null), [Ue, We] = k({
5419
5423
  active: !1,
5420
5424
  kind: "none",
5421
5425
  canUndo: !1,
5422
5426
  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);
5427
+ }), [Ge, Ke] = k(!0), [qe, Je] = k(!1), Ye = e?.id ?? "", Xe = e?.imageUrl ?? "", Qe = e?.displayImageUrl, $e = e?.coordinateSize, et = e?.initialShapes, tt = e?.initialSelectedIds, nt = Qe ?? Xe, [ot, ct] = k("loading"), [lt, ut] = k(null), dt = x((e, t) => {
5428
+ ct(e), ut(e === "error" ? t ?? null : null);
5425
5429
  }, []), q = Tn({
5426
- onShapesCreated: ve,
5427
- onShapesUpdated: ye,
5428
- 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);
5430
+ onShapesCreated: ye,
5431
+ onShapesUpdated: be,
5432
+ onShapesDeleted: xe
5433
+ }), [ft, pt] = k([]), J = i ?? ft, mt = i !== void 0, gt = E(() => new Map((de ?? []).map((e) => [e.id, e])), [de]), _t = O(gt);
5430
5434
  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));
5435
+ _t.current = gt;
5436
+ }, [gt]);
5437
+ let vt = O(Ue);
5438
+ vt.current = Ue;
5439
+ let yt = E(() => {
5440
+ let e = Object.fromEntries(Object.entries(g ?? {}).filter(([, e]) => e !== void 0));
5437
5441
  return {
5438
5442
  ...ke,
5439
5443
  ...e
5440
5444
  };
5441
- }, [h]), yt = O(vt);
5442
- yt.current = vt;
5443
- let [Y, bt] = k(() => yt.current), xt = x((e) => bt((t) => ({
5445
+ }, [g]), bt = O(yt);
5446
+ bt.current = yt;
5447
+ let [Y, xt] = k(() => bt.current), St = x((e) => xt((t) => ({
5444
5448
  ...t,
5445
5449
  ...e
5446
- })), []), X = E(() => Oe(M), [M]);
5450
+ })), []), X = E(() => Oe(N), [N]);
5447
5451
  S(() => {
5448
- g && bt((e) => {
5449
- let t = Object.entries(g).filter(([t, n]) => n !== void 0 && e[t] !== n);
5452
+ _ && xt((e) => {
5453
+ let t = Object.entries(_).filter(([t, n]) => n !== void 0 && e[t] !== n);
5450
5454
  return t.length ? {
5451
5455
  ...e,
5452
5456
  ...Object.fromEntries(t)
5453
5457
  } : e;
5454
5458
  });
5455
- }, [g]);
5456
- let St = O(_);
5457
- St.current = _;
5458
- let Ct = O(!1);
5459
+ }, [_]);
5460
+ let Ct = O(b);
5461
+ Ct.current = b;
5462
+ let wt = O(!1);
5459
5463
  S(() => {
5460
- if (!Ct.current) {
5461
- Ct.current = !0;
5464
+ if (!wt.current) {
5465
+ wt.current = !0;
5462
5466
  return;
5463
5467
  }
5464
- St.current?.(Y);
5468
+ Ct.current?.(Y);
5465
5469
  }, [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);
5470
+ let Tt = E(() => !R || !z ? null : kt(R, z), [R, z]), Dt = E(() => Tt?.toDataURL() ?? null, [Tt]), Ot = E(() => !K || !ie ? null : Vt(ie, K.w, K.h), [K, ie]), At = O(Tt);
5471
+ At.current = Tt;
5472
+ let jt = O(Ot);
5473
+ jt.current = Ot;
5474
+ let Mt = O(r);
5475
+ Mt.current = r;
5476
+ let Nt = O(K);
5477
+ Nt.current = K;
5478
+ let Pt = O($e);
5479
+ Pt.current = $e;
5480
+ let Ft = O($e?.imageSize);
5481
+ Ft.current = $e?.imageSize;
5482
+ let It = O(J);
5479
5483
  T(() => {
5480
- Ft.current = J;
5484
+ It.current = J;
5481
5485
  }, [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(() => {
5486
+ let Lt = O(a);
5487
+ Lt.current = a;
5488
+ let Rt = O(s);
5489
+ Rt.current = s;
5490
+ let zt = O(c);
5491
+ zt.current = c;
5492
+ let Bt = O(ee);
5493
+ Bt.current = ee;
5494
+ let Ht = O(Y.simplifyStrength);
5495
+ Ht.current = Y.simplifyStrength;
5496
+ let Z = !!l || !!d, Ut = O(Z);
5497
+ Ut.current = Z;
5498
+ let Wt = O(u);
5499
+ Wt.current = u;
5500
+ let Gt = O(d);
5501
+ Gt.current = d;
5502
+ let Kt = O(f);
5503
+ Kt.current = f;
5504
+ let qt = O(p);
5505
+ qt.current = p;
5506
+ let Jt = O(h);
5507
+ Jt.current = h;
5508
+ let Yt = O(q);
5509
+ Yt.current = q;
5510
+ let Qt = O(!1), $t = O(!1), en = O("idle"), tn = O(null), nn = x(() => {
5505
5511
  let e = U.current;
5506
5512
  if (!e) return;
5507
- let t = It.current, n = gt.current.get(t), r = _t.current;
5513
+ let t = Lt.current, n = _t.current.get(t), r = vt.current;
5508
5514
  e.setCursor(Et({
5509
5515
  tool: t,
5510
5516
  externalToolCursor: n?.cursor,
5511
- isSpacePressed: Jt.current,
5512
- interactionMode: Qt.current,
5513
- rendererCursorHint: $t.current,
5517
+ isSpacePressed: Qt.current,
5518
+ interactionMode: en.current,
5519
+ rendererCursorHint: tn.current,
5514
5520
  isPolygonDrawing: r.kind === "polygon" && r.active
5515
5521
  }));
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]));
5522
+ }, []), rn = x((e) => {
5523
+ en.current !== e && (en.current = e, nn());
5524
+ }, [nn]), an = x((e) => {
5525
+ tn.current !== e && (tn.current = e, nn());
5526
+ }, [nn]), on = x((e) => {
5527
+ let t = /* @__PURE__ */ new Set(), n = new Map(Yt.current.getShapes().map((e) => [e.id, e]));
5522
5528
  return e.filter((e) => {
5523
5529
  if (t.has(e)) return !1;
5524
5530
  t.add(e);
5525
5531
  let r = n.get(e);
5526
5532
  if (!r) return !1;
5527
- let i = Kt.current?.(r);
5528
- return R(i ? {
5533
+ let i = Jt.current?.(r);
5534
+ return L(i ? {
5529
5535
  ...r,
5530
5536
  interaction: {
5531
5537
  ...r.interaction,
@@ -5533,175 +5539,175 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5533
5539
  }
5534
5540
  } : r);
5535
5541
  });
5536
- }, []), an = x((e) => {
5537
- let t = rn(e);
5538
- Pr(Ft.current, t) || (pt || ft(t), U.current?.setSelection(t), ge?.(t));
5542
+ }, []), sn = x((e) => {
5543
+ let t = on(e);
5544
+ Pr(It.current, t) || (mt || pt(t), U.current?.setSelection(t), _e?.(t));
5539
5545
  }, [
5540
- rn,
5541
- 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);
5546
- un.current = ln;
5547
- let dn = O(null);
5548
- dn.current = sn, S(() => {
5549
- if (!pt) return;
5550
- let e = rn(i);
5551
- Pr(i, e) || ge?.(e);
5546
+ on,
5547
+ _e,
5548
+ mt
5549
+ ]), cn = O(sn);
5550
+ cn.current = sn;
5551
+ let [ln, un] = k(null), dn = x((e) => un(e), []), fn = O(dn);
5552
+ fn.current = dn;
5553
+ let pn = O(null);
5554
+ pn.current = ln, S(() => {
5555
+ if (!mt) return;
5556
+ let e = on(i);
5557
+ Pr(i, e) || _e?.(e);
5552
5558
  }, [
5553
5559
  i,
5554
5560
  q.shapes,
5555
- rn,
5556
- ge,
5557
- pt
5561
+ on,
5562
+ _e,
5563
+ mt
5558
5564
  ]);
5559
- let fn = O(Ce);
5560
- fn.current = Ce;
5561
- let { registerMinimapShape: pn, applyMinimapPreview: mn, syncMinimap: hn } = Or({
5565
+ let mn = O(we);
5566
+ mn.current = we;
5567
+ let { registerMinimapShape: hn, applyMinimapPreview: gn, syncMinimap: _n } = Or({
5562
5568
  engineRef: U,
5563
- docRef: qt,
5564
- overlayRef: De,
5565
- zoomLabelRef: W,
5566
- minimapRectRef: Ee,
5569
+ docRef: Yt,
5570
+ overlayRef: W,
5571
+ zoomLabelRef: Ae,
5572
+ minimapRectRef: De,
5567
5573
  minimapSize: 204,
5568
- onViewportChangeRef: fn
5569
- }), gn = O(/* @__PURE__ */ new Map()), _n = O(le);
5570
- _n.current = le;
5571
- let vn = x((e, t) => {
5572
- t ? gn.current.set(e, t) : gn.current.delete(e);
5573
- }, []), yn = O(null), [bn, xn] = k(null), Cn = x((e) => {
5574
+ onViewportChangeRef: mn
5575
+ }), vn = O(/* @__PURE__ */ new Map()), yn = O(ue);
5576
+ yn.current = ue;
5577
+ let bn = x((e, t) => {
5578
+ t ? vn.current.set(e, t) : vn.current.delete(e);
5579
+ }, []), xn = O(null), [Cn, wn] = k(null), En = x((e) => {
5574
5580
  if (!e.length) return;
5575
- let t = new Map(qt.current.getShapes().map((e) => [e.id, e]));
5576
- yn.current && t.set(yn.current.id, yn.current);
5581
+ let t = new Map(Yt.current.getShapes().map((e) => [e.id, e]));
5582
+ xn.current && t.set(xn.current.id, xn.current);
5577
5583
  for (let { id: n, points: r } of e) {
5578
- let e = gn.current.get(n), i = t.get(n);
5584
+ let e = vn.current.get(n), i = t.get(n);
5579
5585
  if (!e || !i) continue;
5580
5586
  let a = rt(e, r);
5581
5587
  if (a) {
5582
5588
  let e = it(i, r);
5583
- a.textContent = _n.current?.(e) ?? at(e);
5589
+ a.textContent = yn.current?.(e) ?? at(e);
5584
5590
  }
5585
5591
  }
5586
- }, []), wn = x((e) => {
5587
- mn(e), Cn(e), we?.(e);
5592
+ }, []), Dn = x((e) => {
5593
+ gn(e), En(e), Te?.(e);
5588
5594
  }, [
5589
- mn,
5590
- Cn,
5591
- we
5592
- ]), En = x((e) => {
5593
- if (Se?.(e ? {
5595
+ gn,
5596
+ En,
5597
+ Te
5598
+ ]), On = x((e) => {
5599
+ if (Ce?.(e ? {
5594
5600
  ...e,
5595
- meta: Rt.current
5596
- } : null), !e || !Lt.current) {
5597
- yn.current && (yn.current = null, xn(null));
5601
+ meta: zt.current
5602
+ } : null), !e || !Rt.current) {
5603
+ xn.current && (xn.current = null, wn(null));
5598
5604
  return;
5599
5605
  }
5600
5606
  let t = {
5601
5607
  id: Mr,
5602
5608
  type: e.type,
5603
5609
  points: e.points,
5604
- style: Lt.current,
5605
- meta: Rt.current
5606
- }, n = yn.current !== null;
5607
- yn.current = t, n ? Cn([{
5610
+ style: Rt.current,
5611
+ meta: zt.current
5612
+ }, n = xn.current !== null;
5613
+ xn.current = t, n ? En([{
5608
5614
  id: Mr,
5609
5615
  points: e.points
5610
- }]) : xn(t);
5611
- }, [Cn, Se]), Dn = x((e, t) => {
5612
- let n = Lt.current;
5613
- if (!n || Ht.current) return;
5616
+ }]) : wn(t);
5617
+ }, [En, Ce]), kn = x((e, t) => {
5618
+ let n = Rt.current;
5619
+ if (!n || Ut.current) return;
5614
5620
  let r = oe();
5615
- qt.current.create({
5621
+ Yt.current.create({
5616
5622
  id: r,
5617
5623
  type: e,
5618
5624
  points: t,
5619
5625
  style: n,
5620
5626
  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,
5627
+ }), cn.current([r]);
5628
+ }, [c]), An = O(kn);
5629
+ An.current = kn;
5630
+ let jn = Sn({
5631
+ toolRef: Lt,
5632
+ selRef: It,
5633
+ docRef: Yt,
5634
+ readOnlyRef: Ut,
5635
+ draftRef: Rt,
5636
+ brushSizeRef: Bt,
5637
+ simplifyEpsilonRef: Ht,
5632
5638
  draftMeta: c,
5633
5639
  engineRef: U,
5634
5640
  onDrawSessionChange: x((e) => {
5635
- Ue(e), xe?.(e);
5636
- }, [xe]),
5637
- 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);
5643
- Yn.current = de;
5641
+ We(e), Se?.(e);
5642
+ }, [Se]),
5643
+ onDraftShapeChange: Ce,
5644
+ changeSelection: sn,
5645
+ createShape: kn
5646
+ }), Mn = O(jn);
5647
+ Mn.current = jn;
5648
+ let { reset: Nn, undoSession: Pn, redoSession: In, canUndoSession: Ln, canRedoSession: Rn, hasDraftSession: zn, hasDraftPoints: Bn, commitDraftSession: Vn, setBrushScalarMode: Hn, getBrushScalarMode: Un, hasBrushSession: Wn, commitBrush: Gn, cancelBrush: Kn, beginBrushEditFromSelection: qn, deleteDraftSelectedPoints: Jn, handleToolChange: Yn, handleBrushSelectionChange: Xn } = jn, Zn = O(fe);
5649
+ Zn.current = fe;
5644
5650
  let Q = Zt({
5645
- docRef: qt,
5646
- draftRef: Lt,
5651
+ docRef: Yt,
5652
+ draftRef: Rt,
5647
5653
  draftMeta: c,
5648
- changeSelection: an,
5649
- 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({
5654
+ changeSelection: sn,
5655
+ assistantRef: Zn
5656
+ }), Qn = O(Q);
5657
+ Qn.current = Q;
5658
+ let $n = E(() => ht(Ye), [Ye]), { selectAll: er, clearSelection: tr, deleteSelection: nr, copySelection: rr, canPaste: ir, paste: ar, duplicate: or, bringToFront: sr, sendToBack: cr, nudgeSelection: lr, getMergeTargets: ur, mergeSelection: dr } = Ar({
5653
5659
  doc: q,
5654
- selRef: Ft,
5660
+ selRef: It,
5655
5661
  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({
5662
+ changeSelection: sn,
5663
+ canMergeSelection: P,
5664
+ clipboardDocumentId: $n,
5665
+ clipboardScope: t ?? $n
5666
+ }), { zoomToBounds: fr, zoomToShapes: pr, zoomToSelection: mr, zoomAtCenter: hr } = jr({
5661
5667
  engineRef: U,
5662
5668
  doc: q,
5663
- selRef: Ft,
5664
- zoomAnimationDuration: ee,
5665
- zoomBound: F,
5666
- ready: Re
5669
+ selRef: It,
5670
+ zoomAnimationDuration: ne,
5671
+ zoomBound: te,
5672
+ ready: ze
5667
5673
  });
5668
- w(pe, () => ({
5674
+ w(me, () => ({
5669
5675
  previewRegionMask: (e) => {
5670
- let t = Mt.current;
5676
+ let t = Nt.current;
5671
5677
  if (!t) return;
5672
- let n = e ? Vt(e, t.w, t.h) : At.current;
5673
- U.current?.setRegionOverlay(mr.current.showRegionMask ? n : null);
5678
+ let n = e ? Vt(e, t.w, t.h) : jt.current;
5679
+ U.current?.setRegionOverlay(gr.current.showRegionMask ? n : null);
5674
5680
  },
5675
5681
  undo: () => {
5676
- Mn() || q.undo();
5682
+ Pn() || q.undo();
5677
5683
  },
5678
5684
  redo: () => {
5679
- Nn() || q.redo();
5685
+ In() || q.redo();
5680
5686
  },
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,
5687
+ canUndo: () => Ln() || q.canUndo(),
5688
+ canRedo: () => Rn() || q.canRedo(),
5689
+ undoSession: Pn,
5690
+ redoSession: In,
5691
+ canUndoSession: Ln,
5692
+ canRedoSession: Rn,
5693
+ hasDraftSession: zn,
5694
+ cancelDraftSession: Nn,
5695
+ commitDraftSession: Vn,
5696
+ setSelection: sn,
5691
5697
  createShapes: (e) => {
5692
- e.length && (q.create(e), an(e.map((e) => e.id)));
5698
+ e.length && (q.create(e), sn(e.map((e) => e.id)));
5693
5699
  },
5694
5700
  updateShapes: q.update,
5695
5701
  deleteShapes: q.remove,
5696
5702
  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,
5703
+ selectAll: er,
5704
+ clearSelection: tr,
5705
+ deleteSelection: nr,
5706
+ copySelection: rr,
5707
+ paste: ar,
5708
+ duplicate: or,
5709
+ bringToFront: sr,
5710
+ sendToBack: cr,
5705
5711
  zoomFit: () => U.current?.fit(),
5706
5712
  zoom100: () => U.current?.zoom100(),
5707
5713
  zoomIn: () => {
@@ -5716,102 +5722,103 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5716
5722
  let { w: t, h: n } = e.screenSize;
5717
5723
  e.zoomAt(t / 2, n / 2, 1 / 1.2);
5718
5724
  },
5719
- zoomToSelection: fr,
5720
- zoomToShapes: dr,
5721
- zoomToBounds: ur,
5725
+ zoomToSelection: mr,
5726
+ zoomToShapes: pr,
5727
+ zoomToBounds: fr,
5722
5728
  brush: {
5723
- setScalarMode: Bn,
5724
- getScalarMode: Vn,
5725
- hasSession: Hn,
5726
- commit: Un,
5727
- cancel: Wn,
5728
- beginEditFromSelection: Gn
5729
+ setScalarMode: Hn,
5730
+ getScalarMode: Un,
5731
+ hasSession: Wn,
5732
+ commit: Gn,
5733
+ cancel: Kn,
5734
+ beginEditFromSelection: qn
5729
5735
  }
5730
5736
  }), [
5731
5737
  q,
5732
- an,
5733
- Mn,
5738
+ sn,
5739
+ Pn,
5740
+ In,
5741
+ Vn,
5734
5742
  Nn,
5735
- zn,
5736
- jn,
5737
- Un,
5738
- Wn,
5739
- Qn,
5740
- $n,
5743
+ Gn,
5744
+ Kn,
5741
5745
  er,
5742
5746
  tr,
5747
+ nr,
5743
5748
  rr,
5744
- ir,
5745
5749
  ar,
5746
5750
  or,
5751
+ sr,
5752
+ cr,
5753
+ mr,
5754
+ pr,
5747
5755
  fr,
5748
- dr,
5749
- ur,
5750
- Bn,
5751
- Vn,
5752
5756
  Hn,
5753
- Gn
5757
+ Un,
5758
+ Wn,
5759
+ qn
5754
5760
  ]);
5755
- let mr = O(Y);
5756
- mr.current = Y;
5757
- let hr = x(() => Xt({
5761
+ let gr = O(Y);
5762
+ gr.current = Y;
5763
+ let _r = x(() => Xt({
5758
5764
  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,
5772
- enterEditRef: un,
5773
- editingIdRef: dn,
5774
- drawSessionRef: An,
5775
- assistantRef: Xn,
5776
- setCursorHint: nn,
5777
- setInteractionMode: tn,
5778
- syncMinimap: hn,
5779
- onTransformPreview: wn,
5780
- onDrawPreview: En
5765
+ toolRef: Lt,
5766
+ externalToolMapRef: _t,
5767
+ spaceRef: Qt,
5768
+ shiftRef: $t,
5769
+ docRef: Yt,
5770
+ selRef: It,
5771
+ draftRef: Rt,
5772
+ readOnlyRef: Ut,
5773
+ disableMarqueeRef: Wt,
5774
+ lockedRef: Gt,
5775
+ onLockedInteraction: () => Kt.current?.(),
5776
+ onDrawAttemptWithoutDraft: () => qt.current?.(),
5777
+ createRef: An,
5778
+ selectRef: cn,
5779
+ enterEditRef: fn,
5780
+ editingIdRef: pn,
5781
+ drawSessionRef: Mn,
5782
+ assistantRef: Qn,
5783
+ setCursorHint: an,
5784
+ setInteractionMode: rn,
5785
+ syncMinimap: _n,
5786
+ onTransformPreview: Dn,
5787
+ onDrawPreview: On
5781
5788
  }), [
5782
- nn,
5783
- tn,
5784
- hn,
5785
- wn,
5786
- En
5787
- ]), gr = O([]);
5789
+ an,
5790
+ rn,
5791
+ _n,
5792
+ Dn,
5793
+ On
5794
+ ]), vr = O([]);
5788
5795
  xr({
5789
- backend: me,
5790
- hostRef: Te,
5796
+ backend: he,
5797
+ hostRef: Ee,
5791
5798
  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,
5805
- syncMinimap: hn,
5806
- setImage: je,
5807
- setImageVisible: Pe,
5808
- setReady: ze,
5809
- setImageStatus: ut,
5810
- onContextMenuRequest: Ve
5799
+ documentId: Ye,
5800
+ renderedImageUrl: nt,
5801
+ makeCallbacks: _r,
5802
+ viewRef: gr,
5803
+ readOnlyRef: Ut,
5804
+ toolRef: Lt,
5805
+ renderShapesRef: vr,
5806
+ coordinateSizeRef: Pt,
5807
+ imageSizeRef: Ft,
5808
+ selRef: It,
5809
+ maskCanvasRef: At,
5810
+ regionOverlayRef: jt,
5811
+ dimmedRef: Mt,
5812
+ syncMinimap: _n,
5813
+ setImage: Me,
5814
+ setImageVisible: Re,
5815
+ setReady: Be,
5816
+ setImageStatus: dt,
5817
+ onContextMenuRequest: He
5811
5818
  });
5812
- let _r = E(() => {
5813
- let e = m ? q.shapes.map((e) => {
5814
- let t = m(e);
5819
+ let $ = E(() => {
5820
+ let e = h ? q.shapes.map((e) => {
5821
+ let t = h(e);
5815
5822
  return t ? {
5816
5823
  ...e,
5817
5824
  interaction: {
@@ -5820,7 +5827,7 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5820
5827
  }
5821
5828
  } : e;
5822
5829
  }) : q.shapes;
5823
- return te?.length ? [...te.map((e) => ({
5830
+ return F?.length ? [...F.map((e) => ({
5824
5831
  ...e,
5825
5832
  interaction: {
5826
5833
  ...e.interaction,
@@ -5832,154 +5839,154 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5832
5839
  })), ...e] : e;
5833
5840
  }, [
5834
5841
  q.shapes,
5835
- m,
5836
- te
5842
+ h,
5843
+ F
5837
5844
  ]);
5838
- gr.current = _r, S(() => {
5839
- U.current?.setShapes(_r, Ft.current), hn();
5840
- }, [_r, hn]), S(() => {
5845
+ vr.current = $, S(() => {
5846
+ U.current?.setShapes($, It.current), _n();
5847
+ }, [$, _n]), S(() => {
5841
5848
  U.current?.setSelection(J);
5842
5849
  }, [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);
5850
+ U.current?.setEditing(ln);
5851
+ }, [ln, ze]);
5852
+ let yr = O(ve);
5853
+ yr.current = ve, S(() => {
5854
+ yr.current?.(ln);
5855
+ }, [ln]), S(() => {
5856
+ un(null);
5850
5857
  }, [a]), S(() => {
5851
- sn && (J.length !== 1 || J[0] !== sn) && cn(null);
5852
- }, [J, sn]), S(() => {
5858
+ ln && (J.length !== 1 || J[0] !== ln) && un(null);
5859
+ }, [J, ln]), S(() => {
5853
5860
  let e = U.current;
5854
- e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing), hn());
5861
+ e && (e.setFilter(Y.brightness, Y.contrast), e.setRenderDefaults({ strokeWidth: Y.strokeSize }), e.setImageSmoothing(Y.imageSmoothing), _n());
5855
5862
  }, [
5856
5863
  Y.brightness,
5857
5864
  Y.contrast,
5858
5865
  Y.strokeSize,
5859
5866
  Y.imageSmoothing,
5860
- hn
5867
+ _n
5861
5868
  ]), T(() => {
5862
- Re && U.current?.setOverlays(Y.showGuide ? wt : null, Y.showRegionMask ? Dt : null, r);
5869
+ ze && U.current?.setOverlays(Y.showGuide ? Tt : null, Y.showRegionMask ? Ot : null, r);
5863
5870
  }, [
5864
- Re,
5865
- wt,
5866
- Dt,
5871
+ ze,
5872
+ Tt,
5873
+ Ot,
5867
5874
  Y.showGuide,
5868
5875
  Y.showRegionMask,
5869
5876
  r
5870
5877
  ]), S(() => {
5871
- !Re || !K || hn();
5878
+ !ze || !K || _n();
5872
5879
  }, [
5873
- Re,
5880
+ ze,
5874
5881
  K,
5875
- Tt,
5882
+ Dt,
5876
5883
  Y.showGuide,
5877
5884
  Y.showRegionMask,
5878
- I,
5879
- hn
5885
+ ie,
5886
+ _n
5880
5887
  ]), S(() => {
5881
- Re && U.current?.setTransformEnabled(!Z && a !== G.BRUSH);
5888
+ ze && U.current?.setTransformEnabled(!Z && a !== G.BRUSH);
5882
5889
  }, [
5883
5890
  Z,
5884
- Re,
5891
+ ze,
5885
5892
  a
5886
5893
  ]), S(() => {
5887
- qn(a, gt.current.has(a));
5888
- }, [a, qn]);
5889
- let $ = Q.finalize;
5894
+ Yn(a, _t.current.has(a));
5895
+ }, [a, Yn]);
5896
+ let br = Q.finalize;
5890
5897
  S(() => {
5891
- $();
5892
- }, [a, $]), S(() => {
5893
- Qt.current = "idle", $t.current = null, en();
5898
+ br();
5899
+ }, [a, br]), S(() => {
5900
+ en.current = "idle", tn.current = null, nn();
5894
5901
  }, [
5895
5902
  a,
5896
- me,
5897
- en
5903
+ he,
5904
+ nn
5898
5905
  ]), S(() => {
5899
- Jn(J, Z);
5906
+ Xn(J, Z);
5900
5907
  }, [
5901
5908
  J,
5902
5909
  a,
5903
5910
  Z,
5904
- Jn
5911
+ Xn
5905
5912
  ]), S(() => {
5906
- Re && en();
5913
+ ze && nn();
5907
5914
  }, [
5908
5915
  a,
5909
- He,
5910
- mt,
5911
- Re,
5912
- en
5916
+ Ue,
5917
+ gt,
5918
+ ze,
5919
+ nn
5913
5920
  ]);
5914
- let yr = O(et);
5915
- yr.current = et;
5916
- let br = e !== null, Sr = O(null);
5921
+ let Sr = O(tt);
5922
+ Sr.current = tt;
5923
+ let Cr = e !== null, wr = O(null);
5917
5924
  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());
5925
+ let e = Cr ? Ye : null;
5926
+ wr.current !== e && (wr.current = e, He(null), un(null), en.current = "idle", tn.current = null, q.reset(Cr ? et ?? [] : []), sn(Cr ? Sr.current ?? [] : []), Nn(), br(), nn());
5920
5927
  }, [
5921
- br,
5922
- Je,
5923
- $e,
5928
+ Cr,
5929
+ Ye,
5930
+ et,
5924
5931
  q.reset,
5925
- an,
5926
- jn,
5927
- $,
5928
- en
5932
+ sn,
5933
+ Nn,
5934
+ br,
5935
+ nn
5929
5936
  ]);
5930
- let Cr = x(() => {
5931
- let e = dn.current;
5937
+ let Tr = x(() => {
5938
+ let e = pn.current;
5932
5939
  if (!e || Z) return !1;
5933
5940
  let t = U.current, n = new Set(t?.getVertexSelection() ?? []);
5934
5941
  if (!n.size) return !1;
5935
- let r = qt.current.getShapes().find((t) => t.id === e);
5942
+ let r = Yt.current.getShapes().find((t) => t.id === e);
5936
5943
  if (!r) return !1;
5937
- 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([{
5944
+ let i = r.points.filter((e, t) => !n.has(t)), a = r.type === I.LINE ? 2 : 3;
5945
+ return i.length < a ? !1 : (Yt.current.update([{
5939
5946
  ...r,
5940
5947
  points: i
5941
5948
  }]), t?.setVertexSelection([]), !0);
5942
5949
  }, [Z]);
5943
5950
  Fn({
5944
- keymap: fe,
5945
- hostRef: Te,
5951
+ keymap: pe,
5952
+ hostRef: Ee,
5946
5953
  actions: {
5947
5954
  undo: () => {
5948
- Z || Mn() || q.undo();
5955
+ Z || Pn() || q.undo();
5949
5956
  },
5950
5957
  redo: () => {
5951
- Z || Nn() || q.redo();
5958
+ Z || In() || q.redo();
5952
5959
  },
5953
- selectAll: Qn,
5954
- copy: tr,
5960
+ selectAll: er,
5961
+ copy: rr,
5955
5962
  cut: () => {
5956
- tr(), er();
5963
+ rr(), nr();
5957
5964
  },
5958
- paste: rr,
5959
- duplicate: ir,
5965
+ paste: ar,
5966
+ duplicate: or,
5960
5967
  delete: () => {
5961
- Rn() && Kn() || Cr() || er();
5968
+ Bn() && Jn() || Tr() || nr();
5962
5969
  },
5963
5970
  cancel: () => {
5964
- let e = gt.current.get(It.current);
5971
+ let e = _t.current.get(Lt.current);
5965
5972
  if (!(e?.onCancel && e.onCancel() !== !1)) {
5966
5973
  if (Q.isActive()) {
5967
5974
  Q.cancel();
5968
5975
  return;
5969
5976
  }
5970
- if (Ln()) {
5971
- jn();
5977
+ if (zn()) {
5978
+ Nn();
5972
5979
  return;
5973
5980
  }
5974
- if (sn) {
5975
- cn(null);
5981
+ if (ln) {
5982
+ un(null);
5976
5983
  return;
5977
5984
  }
5978
- if (Ft.current.length) {
5979
- $n();
5985
+ if (It.current.length) {
5986
+ tr();
5980
5987
  return;
5981
5988
  }
5982
- p?.();
5989
+ m?.();
5983
5990
  }
5984
5991
  },
5985
5992
  commitDraft: () => {
@@ -5987,150 +5994,150 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
5987
5994
  Q.finalize();
5988
5995
  return;
5989
5996
  }
5990
- if (Ln()) {
5991
- zn();
5997
+ if (zn()) {
5998
+ Vn();
5992
5999
  return;
5993
6000
  }
5994
6001
  if (Z) return;
5995
- if (sn) {
5996
- cn(null);
6002
+ if (ln) {
6003
+ un(null);
5997
6004
  return;
5998
6005
  }
5999
- let e = Ft.current;
6006
+ let e = It.current;
6000
6007
  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]);
6008
+ let t = Yt.current.getShapes().find((t) => t.id === e[0]);
6009
+ t && (t.type === I.POLYGON || t.type === I.LINE) && t.interaction?.editable !== !1 && !t.readOnly && un(e[0]);
6003
6010
  },
6004
- bringToFront: ar,
6005
- sendToBack: or,
6006
- zoomIn: () => pr(1.2),
6007
- zoomOut: () => pr(1 / 1.2),
6011
+ bringToFront: sr,
6012
+ sendToBack: cr,
6013
+ zoomIn: () => hr(1.2),
6014
+ zoomOut: () => hr(1 / 1.2),
6008
6015
  zoom100: () => U.current?.zoom100(),
6009
6016
  zoomFit: () => U.current?.fit(),
6010
- toggleMinimap: () => Ge((e) => !e),
6011
- toggleCursorGuide: () => bt((e) => ({
6017
+ toggleMinimap: () => Ke((e) => !e),
6018
+ toggleCursorGuide: () => xt((e) => ({
6012
6019
  ...e,
6013
6020
  showCursorGuide: !e.showCursorGuide
6014
6021
  })),
6015
- togglePixelation: () => bt((e) => ({
6022
+ togglePixelation: () => xt((e) => ({
6016
6023
  ...e,
6017
6024
  imageSmoothing: !e.imageSmoothing
6018
6025
  })),
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)
6026
+ selectTool: () => ge?.(G.SELECT),
6027
+ rectangleTool: () => ge?.(G.RECTANGLE),
6028
+ rotatedRectangleTool: () => ge?.(G.ROTATED_RECTANGLE),
6029
+ circleTool: () => ge?.(G.CIRCLE),
6030
+ polygonTool: () => ge?.(G.POLYGON),
6031
+ pathTool: () => ge?.(G.PATH),
6032
+ brushTool: () => ge?.(G.BRUSH),
6033
+ pointTool: () => ge?.(G.POINT)
6027
6034
  },
6028
- spaceRef: Jt,
6029
- shiftRef: Yt,
6035
+ spaceRef: Qt,
6036
+ shiftRef: $t,
6030
6037
  onSpaceDown: () => {
6031
- U.current?.setPanMode(!0), en();
6038
+ U.current?.setPanMode(!0), nn();
6032
6039
  },
6033
6040
  onSpaceUp: () => {
6034
- U.current?.setPanMode(!1), Qt.current === "panning" ? tn("idle") : en();
6041
+ U.current?.setPanMode(!1), en.current === "panning" ? rn("idle") : nn();
6035
6042
  },
6036
- nudge: sr
6043
+ nudge: lr
6037
6044
  });
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 && (() => {
6045
+ let Dr = E(() => $.filter((e) => J.includes(e.id) && re(e)), [$, J]), kr = E(() => Cn ? [...Dr, Cn] : Dr, [Dr, Cn]), Fr = J.length > 0, Ir = q.shapes.some((e) => J.includes(e.id) && ae(e)), Lr = !Z && J.length === 1 && (() => {
6039
6046
  let e = q.shapes.find((e) => e.id === J[0]);
6040
- 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 ? (() => {
6047
+ return !!e && (e.type === I.POLYGON || e.type === I.LINE) && e.interaction?.editable !== !1 && !e.readOnly;
6048
+ })(), Rr = ur(), zr = Z || Rr.length < 2 || (P ? !P(Rr) : !1), Br = !!fe && !Z, Vr = Br && J.length === 1 ? (() => {
6042
6049
  let e = q.shapes.find((e) => e.id === J[0]);
6043
- return e && e.type === L.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
6044
- })() : null, Br = [
6050
+ return e && e.type === I.POLYGON && e.interaction?.editable !== !1 && !e.readOnly ? e : null;
6051
+ })() : null, Hr = [
6045
6052
  {
6046
6053
  id: "copy",
6047
6054
  label: X.contextMenu.copy,
6048
6055
  shortcut: "⌘C",
6049
- disabled: !kr,
6050
- onClick: tr
6056
+ disabled: !Ir,
6057
+ onClick: rr
6051
6058
  },
6052
6059
  {
6053
6060
  id: "paste",
6054
6061
  label: X.contextMenu.paste,
6055
6062
  shortcut: "⌘V",
6056
- disabled: Z || !nr(),
6057
- onClick: () => rr(Be?.img)
6063
+ disabled: Z || !ir(),
6064
+ onClick: () => ar(Ve?.img)
6058
6065
  },
6059
6066
  {
6060
6067
  id: "duplicate",
6061
6068
  label: X.contextMenu.duplicate,
6062
6069
  shortcut: "⌘D",
6063
- disabled: !kr || Z,
6064
- onClick: ir
6070
+ disabled: !Ir || Z,
6071
+ onClick: or
6065
6072
  },
6066
6073
  {
6067
6074
  id: "delete",
6068
6075
  label: X.contextMenu.delete,
6069
6076
  shortcut: "Del",
6070
6077
  danger: !0,
6071
- disabled: !kr || Z,
6072
- onClick: er
6078
+ disabled: !Ir || Z,
6079
+ onClick: nr
6073
6080
  },
6074
6081
  { separator: !0 },
6075
6082
  {
6076
6083
  id: "editVertices",
6077
6084
  label: X.contextMenu.editVertices,
6078
6085
  shortcut: "Enter",
6079
- disabled: !Fr,
6080
- onClick: () => cn(J[0])
6086
+ disabled: !Lr,
6087
+ onClick: () => un(J[0])
6081
6088
  },
6082
6089
  {
6083
6090
  id: "merge",
6084
6091
  label: X.contextMenu.merge,
6085
- disabled: Lr,
6086
- onClick: lr
6092
+ disabled: zr,
6093
+ onClick: dr
6087
6094
  },
6088
- ...Rr ? [{
6095
+ ...Br ? [{
6089
6096
  id: "assistExpand",
6090
6097
  label: X.contextMenu.assistExpand,
6091
6098
  icon: /* @__PURE__ */ v(o, { size: 14 }),
6092
- disabled: !zr,
6099
+ disabled: !Vr,
6093
6100
  onClick: () => {
6094
- Be && zr && Q.refineShape(zr, Be.img, !0);
6101
+ Ve && Vr && Q.refineShape(Vr, Ve.img, !0);
6095
6102
  }
6096
6103
  }, {
6097
6104
  id: "assistExclude",
6098
6105
  label: X.contextMenu.assistExclude,
6099
6106
  icon: /* @__PURE__ */ v(o, { size: 14 }),
6100
- disabled: !zr,
6107
+ disabled: !Vr,
6101
6108
  onClick: () => {
6102
- Be && zr && Q.refineShape(zr, Be.img, !1);
6109
+ Ve && Vr && Q.refineShape(Vr, Ve.img, !1);
6103
6110
  }
6104
6111
  }] : [],
6105
6112
  {
6106
6113
  id: "bringToFront",
6107
6114
  label: X.contextMenu.bringToFront,
6108
- disabled: !kr || Z,
6109
- onClick: ar
6115
+ disabled: !Ir || Z,
6116
+ onClick: sr
6110
6117
  },
6111
6118
  {
6112
6119
  id: "sendToBack",
6113
6120
  label: X.contextMenu.sendToBack,
6114
- disabled: !kr || Z,
6115
- onClick: or
6121
+ disabled: !Ir || Z,
6122
+ onClick: cr
6116
6123
  },
6117
6124
  { separator: !0 },
6118
6125
  {
6119
6126
  id: "undo",
6120
6127
  label: X.contextMenu.undo,
6121
6128
  shortcut: "⌘Z",
6122
- disabled: Z || !Pn() && !q.canUndo(),
6129
+ disabled: Z || !Ln() && !q.canUndo(),
6123
6130
  onClick: () => {
6124
- Mn() || q.undo();
6131
+ Pn() || q.undo();
6125
6132
  }
6126
6133
  },
6127
6134
  {
6128
6135
  id: "redo",
6129
6136
  label: X.contextMenu.redo,
6130
6137
  shortcut: "⇧⌘Z",
6131
- disabled: Z || !In() && !q.canRedo(),
6138
+ disabled: Z || !Rn() && !q.canRedo(),
6132
6139
  onClick: () => {
6133
- Nn() || q.redo();
6140
+ In() || q.redo();
6134
6141
  }
6135
6142
  },
6136
6143
  { separator: !0 },
@@ -6138,60 +6145,60 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6138
6145
  id: "selectAll",
6139
6146
  label: X.contextMenu.selectAll,
6140
6147
  shortcut: "⌘A",
6141
- onClick: Qn
6148
+ onClick: er
6142
6149
  },
6143
6150
  {
6144
6151
  id: "clearSelection",
6145
6152
  label: X.contextMenu.clearSelection,
6146
- disabled: !Dr,
6147
- onClick: $n
6153
+ disabled: !Fr,
6154
+ onClick: tr
6148
6155
  },
6149
6156
  {
6150
6157
  id: "zoomToSelection",
6151
6158
  label: X.contextMenu.zoomToSelection,
6152
- disabled: !Dr,
6153
- onClick: fr
6159
+ disabled: !Fr,
6160
+ onClick: mr
6154
6161
  }
6155
- ], Vr = l ? Br.filter((e) => "separator" in e || !!e.id && Nr.has(e.id)) : Br, Hr = j ? j(Vr, {
6162
+ ], Ur = l ? Hr.filter((e) => "separator" in e || !!e.id && Nr.has(e.id)) : Hr, Wr = M ? M(Ur, {
6156
6163
  selectedIds: J,
6157
6164
  readOnly: Z
6158
- }) : Vr, Ur = Er({
6165
+ }) : Ur, Gr = Er({
6159
6166
  engineRef: U,
6160
6167
  image: K,
6161
6168
  wheelZoom: Y.wheelZoom,
6162
6169
  minimapSize: 204
6163
- }), Wr = x(() => {
6170
+ }), Kr = x(() => {
6164
6171
  U.current?.zoom100();
6165
- }, []), Gr = x(() => {
6166
- Ge((e) => !e);
6167
- }, []), Kr = x(() => {
6168
- qe((e) => !e);
6169
6172
  }, []), qr = x(() => {
6170
- qe(!1);
6173
+ Ke((e) => !e);
6174
+ }, []), Jr = x(() => {
6175
+ Je((e) => !e);
6176
+ }, []), Yr = x(() => {
6177
+ Je(!1);
6171
6178
  }, []);
6172
6179
  return /* @__PURE__ */ y("div", {
6173
6180
  className: "aivex:relative aivex:h-full aivex:w-full aivex:overflow-hidden aivex:bg-black",
6174
6181
  children: [
6175
6182
  /* @__PURE__ */ v("div", {
6176
- ref: Te,
6183
+ ref: Ee,
6177
6184
  className: "aivex:h-full aivex:w-full",
6178
6185
  style: {
6179
- opacity: +!!Me,
6180
- transition: Me ? "opacity 0.3s ease" : "none"
6186
+ opacity: +!!Pe,
6187
+ transition: Pe ? "opacity 0.3s ease" : "none"
6181
6188
  }
6182
6189
  }),
6183
- nt !== "ready" && /* @__PURE__ */ v(Le, {
6184
- status: nt,
6185
- error: ct,
6190
+ ot !== "ready" && /* @__PURE__ */ v(Le, {
6191
+ status: ot,
6192
+ error: lt,
6186
6193
  render: n,
6187
6194
  loadingLabel: X.imageLoading,
6188
6195
  errorLabel: X.imageLoadError,
6189
6196
  errorHints: X.imageErrorHints
6190
6197
  }),
6191
- Re && K && /* @__PURE__ */ v("div", {
6198
+ ze && K && /* @__PURE__ */ v("div", {
6192
6199
  className: "aivex:pointer-events-none aivex:absolute aivex:inset-0 aivex:overflow-hidden",
6193
6200
  children: /* @__PURE__ */ y("div", {
6194
- ref: De,
6201
+ ref: W,
6195
6202
  style: {
6196
6203
  position: "absolute",
6197
6204
  top: 0,
@@ -6201,7 +6208,7 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6201
6208
  transformOrigin: "0 0"
6202
6209
  },
6203
6210
  children: [
6204
- !!ae?.length && B && /* @__PURE__ */ v("div", {
6211
+ !!B?.length && V && /* @__PURE__ */ v("div", {
6205
6212
  style: {
6206
6213
  position: "absolute",
6207
6214
  left: 0,
@@ -6210,16 +6217,16 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6210
6217
  height: K.h,
6211
6218
  pointerEvents: "none"
6212
6219
  },
6213
- children: ae.map((e) => /* @__PURE__ */ v("div", {
6220
+ children: B.map((e) => /* @__PURE__ */ v("div", {
6214
6221
  role: e.disabled ? void 0 : "button",
6215
6222
  tabIndex: e.disabled ? void 0 : 0,
6216
6223
  "aria-pressed": e.selected || void 0,
6217
6224
  onPointerDown: (e) => e.stopPropagation(),
6218
6225
  onClick: (t) => {
6219
- t.stopPropagation(), e.disabled || V?.(e);
6226
+ t.stopPropagation(), e.disabled || se?.(e);
6220
6227
  },
6221
6228
  onKeyDown: (t) => {
6222
- e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), V?.(e));
6229
+ e.disabled || t.key !== "Enter" && t.key !== " " || (t.preventDefault(), t.stopPropagation(), se?.(e));
6223
6230
  },
6224
6231
  style: {
6225
6232
  position: "absolute",
@@ -6231,10 +6238,10 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6231
6238
  pointerEvents: e.disabled ? "none" : "auto",
6232
6239
  cursor: e.disabled ? "default" : "pointer"
6233
6240
  },
6234
- children: B(e)
6241
+ children: V(e)
6235
6242
  }, e.id))
6236
6243
  }),
6237
- se?.({
6244
+ H?.({
6238
6245
  image: K,
6239
6246
  viewport: U.current?.viewport ?? {
6240
6247
  scale: 1,
@@ -6242,14 +6249,14 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6242
6249
  y: 0
6243
6250
  }
6244
6251
  }),
6245
- Tr.length > 0 && /* @__PURE__ */ v(st, {
6246
- shapes: Tr,
6247
- getLabel: H,
6248
- hideDot: ce,
6249
- formatInfo: le,
6250
- register: vn
6252
+ kr.length > 0 && /* @__PURE__ */ v(st, {
6253
+ shapes: kr,
6254
+ getLabel: ce,
6255
+ hideDot: le,
6256
+ formatInfo: ue,
6257
+ register: bn
6251
6258
  }),
6252
- de && (Q.status === "loading" || Q.boxes.length > 0) && /* @__PURE__ */ v(Ne, {
6259
+ fe && (Q.status === "loading" || Q.boxes.length > 0) && /* @__PURE__ */ v(Ne, {
6253
6260
  image: K,
6254
6261
  points: Q.points,
6255
6262
  boxes: Q.boxes,
@@ -6258,39 +6265,39 @@ function Fr({ document: e, clipboardScope: t, renderImageState: n, dimmed: r = !
6258
6265
  ]
6259
6266
  })
6260
6267
  }),
6261
- Re && Y.showCursorGuide && /* @__PURE__ */ v(Ie, { color: "#1e88e5" }),
6262
- K && b && /* @__PURE__ */ v(Ze, {
6268
+ ze && Y.showCursorGuide && /* @__PURE__ */ v(Ie, { color: "#1e88e5" }),
6269
+ K && D && /* @__PURE__ */ v(Ze, {
6263
6270
  image: K,
6264
- imageUrl: tt,
6265
- imageVisible: Me,
6266
- loading: !Re,
6267
- maskDataUrl: Tt,
6268
- region: Dt,
6269
- roiMaskId: Ae,
6270
- shapes: _r,
6271
+ imageUrl: nt,
6272
+ imageVisible: Pe,
6273
+ loading: !ze,
6274
+ maskDataUrl: Dt,
6275
+ region: Ot,
6276
+ roiMaskId: je,
6277
+ shapes: $,
6271
6278
  view: Y,
6272
- viewDefaults: vt,
6273
- onChangeView: xt,
6274
- nav: Ur,
6275
- registerShape: pn,
6276
- rectRef: Ee,
6277
- zoomLabelRef: W,
6278
- onZoom100: Wr,
6279
- open: We,
6280
- onToggleOpen: Gr,
6281
- position: D,
6279
+ viewDefaults: yt,
6280
+ onChangeView: St,
6281
+ nav: Gr,
6282
+ registerShape: hn,
6283
+ rectRef: De,
6284
+ zoomLabelRef: Ae,
6285
+ onZoom100: Kr,
6286
+ open: Ge,
6287
+ onToggleOpen: qr,
6288
+ position: A,
6282
6289
  labels: X.minimap,
6283
6290
  settingsLabels: X.viewSettings,
6284
- showSettings: A,
6285
- settingsOpen: Ke,
6286
- onToggleSettings: Kr,
6287
- onCloseSettings: qr
6291
+ showSettings: j,
6292
+ settingsOpen: qe,
6293
+ onToggleSettings: Jr,
6294
+ onCloseSettings: Yr
6288
6295
  }),
6289
- Be && /* @__PURE__ */ v(Fe, {
6290
- x: Be.x,
6291
- y: Be.y,
6292
- items: Hr,
6293
- onClose: () => Ve(null)
6296
+ Ve && /* @__PURE__ */ v(Fe, {
6297
+ x: Ve.x,
6298
+ y: Ve.y,
6299
+ items: Wr,
6300
+ onClose: () => He(null)
6294
6301
  })
6295
6302
  ]
6296
6303
  });
@@ -6310,18 +6317,18 @@ function Lr(e, t, n, r) {
6310
6317
  strokeWidth: r,
6311
6318
  pointRadius: 2
6312
6319
  });
6313
- if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type === L.POINT) {
6320
+ if (e.save(), e.globalAlpha = i.opacity, e.lineWidth = i.strokeWidth / n, e.lineJoin = "round", e.lineCap = "round", t.type === I.POINT) {
6314
6321
  let r = t.points[0];
6315
6322
  r && (e.fillStyle = i.color, e.beginPath(), e.arc(r.x, r.y, i.pointRadius / n, 0, Math.PI * 2), e.fill()), e.restore();
6316
6323
  return;
6317
6324
  }
6318
- if (t.type === L.RECTANGLE || t.type === L.ELLIPSE) {
6325
+ if (t.type === I.RECTANGLE || t.type === I.ELLIPSE) {
6319
6326
  let [n, r] = t.points;
6320
6327
  if (n && r) {
6321
6328
  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
- 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);
6329
+ e.beginPath(), t.type === I.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
6330
  }
6324
- } else Ir(e, t.points, t.type !== L.LINE);
6331
+ } else Ir(e, t.points, t.type !== I.LINE);
6325
6332
  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();
6326
6333
  }
6327
6334
  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: _ }) {
@@ -6360,7 +6367,7 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6360
6367
  }, [e, w]), S(() => () => {
6361
6368
  C.current = null;
6362
6369
  }, []);
6363
- let F = E(() => r.find((e) => e.id === s), [s, r]), ee = E(() => a && o ? kt(a, o) : null, [a, o]);
6370
+ let ee = E(() => r.find((e) => e.id === s), [s, r]), te = E(() => a && o ? kt(a, o) : null, [a, o]);
6364
6371
  return S(() => {
6365
6372
  if (D === "error") {
6366
6373
  let e = x.current;
@@ -6378,11 +6385,11 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6378
6385
  let g = n?.width ?? a.naturalWidth, _ = n?.height ?? a.naturalHeight;
6379
6386
  if (!g || !_) return;
6380
6387
  let v = Math.min(o / g, s / _), y = (o - g * v) / 2, S = (s - _ * v) / 2;
6381
- 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;
6388
+ if (ee && ee.points.length > 0) {
6389
+ let e = V(ee.points), t = Math.max(e.maxX - e.minX, 50), n = Math.max(e.maxY - e.minY, 50), r = Math.min(t, n) * l;
6383
6390
  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
6391
  }
6385
- 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());
6392
+ 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", te && (h.save(), h.globalAlpha = .55, h.drawImage(te, 0, 0, g, _), h.restore());
6386
6393
  let w = i ? Vt(i, g, _) : null;
6387
6394
  if (w && (It(h, w, g, _), w.outlineStyles)) {
6388
6395
  let e = (e, t) => {
@@ -6396,16 +6403,16 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6396
6403
  };
6397
6404
  e(w.visibleOutline, w.outlineStyles.visible), e(w.occludedOutline, w.outlineStyles.occluded);
6398
6405
  }
6399
- for (let e of ae(r)) Lr(h, e, v, u);
6406
+ for (let e of z(r)) Lr(h, e, v, u);
6400
6407
  h.restore();
6401
6408
  }, [
6402
6409
  d,
6403
6410
  f,
6404
6411
  n,
6405
- F,
6412
+ ee,
6406
6413
  c,
6407
6414
  p,
6408
- ee,
6415
+ te,
6409
6416
  i,
6410
6417
  r,
6411
6418
  N,
@@ -6465,6 +6472,6 @@ function Rr({ imageUrl: e, alt: t = "Shape preview", coordinateSize: n, shapes:
6465
6472
  });
6466
6473
  }
6467
6474
  //#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 };
6475
+ export { W as DEFAULT_EDITOR_STRINGS, ke as DEFAULT_VIEW_SETTINGS, I as SHAPE_TYPE, Fr as ShapeEditor, Fr as default, Rr as ShapeViewer, G as TOOL, oe as generateId };
6469
6476
 
6470
6477
  //# sourceMappingURL=shape-editor.js.map