@aivex/ui 1.2.0-dev.58 → 1.2.0-dev.59

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.
Files changed (42) hide show
  1. package/dist/DESIGN.md +1 -1
  2. package/dist/components/ShapeEditor/ShapeEditor.cjs +1 -1
  3. package/dist/components/ShapeEditor/ShapeEditor.cjs.map +1 -1
  4. package/dist/components/ShapeEditor/ShapeEditor.js +406 -428
  5. package/dist/components/ShapeEditor/ShapeEditor.js.map +1 -1
  6. package/dist/components/ShapeEditor/_components/OverlayMarkers.cjs +2 -0
  7. package/dist/components/ShapeEditor/_components/OverlayMarkers.cjs.map +1 -0
  8. package/dist/components/ShapeEditor/_components/OverlayMarkers.d.cts +16 -0
  9. package/dist/components/ShapeEditor/_components/OverlayMarkers.d.ts +16 -0
  10. package/dist/components/ShapeEditor/_components/OverlayMarkers.js +41 -0
  11. package/dist/components/ShapeEditor/_components/OverlayMarkers.js.map +1 -0
  12. package/dist/components/ShapeEditor/_model/types/props.d.cts +3 -1
  13. package/dist/components/ShapeEditor/_model/types/props.d.ts +3 -1
  14. package/dist/components/ShapeEditor/_state/createInteractionController.cjs +1 -1
  15. package/dist/components/ShapeEditor/_state/createInteractionController.cjs.map +1 -1
  16. package/dist/components/ShapeEditor/_state/createInteractionController.js +4 -2
  17. package/dist/components/ShapeEditor/_state/createInteractionController.js.map +1 -1
  18. package/dist/components/ShapeEditor/_state/useAssistant.cjs +1 -1
  19. package/dist/components/ShapeEditor/_state/useAssistant.cjs.map +1 -1
  20. package/dist/components/ShapeEditor/_state/useAssistant.d.cts +1 -0
  21. package/dist/components/ShapeEditor/_state/useAssistant.d.ts +1 -0
  22. package/dist/components/ShapeEditor/_state/useAssistant.js +81 -74
  23. package/dist/components/ShapeEditor/_state/useAssistant.js.map +1 -1
  24. package/dist/components/ShapeEditor/_state/useDrawSession.cjs +1 -1
  25. package/dist/components/ShapeEditor/_state/useDrawSession.cjs.map +1 -1
  26. package/dist/components/ShapeEditor/_state/useDrawSession.d.cts +4 -1
  27. package/dist/components/ShapeEditor/_state/useDrawSession.d.ts +4 -1
  28. package/dist/components/ShapeEditor/_state/useDrawSession.js +184 -164
  29. package/dist/components/ShapeEditor/_state/useDrawSession.js.map +1 -1
  30. package/dist/components/ShapeEditor/_state/useEditorDocument.cjs +1 -1
  31. package/dist/components/ShapeEditor/_state/useEditorDocument.cjs.map +1 -1
  32. package/dist/components/ShapeEditor/_state/useEditorDocument.d.cts +7 -0
  33. package/dist/components/ShapeEditor/_state/useEditorDocument.d.ts +7 -0
  34. package/dist/components/ShapeEditor/_state/useEditorDocument.js +61 -31
  35. package/dist/components/ShapeEditor/_state/useEditorDocument.js.map +1 -1
  36. package/dist/components/ShapeEditor/_state/useSelectionModel.cjs +1 -1
  37. package/dist/components/ShapeEditor/_state/useSelectionModel.cjs.map +1 -1
  38. package/dist/components/ShapeEditor/_state/useSelectionModel.js +10 -3
  39. package/dist/components/ShapeEditor/_state/useSelectionModel.js.map +1 -1
  40. package/dist/llms-full.txt +4 -2
  41. package/dist/llms.txt +1 -1
  42. package/package.json +1 -1
@@ -2,28 +2,28 @@
2
2
  import { SHAPE_TYPE as e, generateId as t, isShapeEditable as n } from "../_model/geometry.js";
3
3
  import { TOOL as r } from "../_model/tools.js";
4
4
  import { simplifyPath as i } from "../_model/brush.js";
5
- import { buildScalarMaskRaster as a, polygonArea as o, scalarMaskToPolygons as s, shapesToFilledPolygons as c } from "../_model/scalarMask.js";
6
- import { clonePoints as l, cloneScalarStrokes as u, pointsEqual as d, scalarStrokesEqual as f } from "./drawSessionState.js";
7
- import { useLatestRef as p } from "./useLatestRef.js";
8
- import { useCallback as m, useRef as h } from "react";
5
+ import { buildScalarMaskRaster as a, polygonArea as o, scalarMaskToPolygons as ee, shapesToFilledPolygons as s } from "../_model/scalarMask.js";
6
+ import { clonePoints as c, cloneScalarStrokes as l, pointsEqual as u, scalarStrokesEqual as d } from "./drawSessionState.js";
7
+ import { useLatestRef as f } from "./useLatestRef.js";
8
+ import { useCallback as p, useRef as m } from "react";
9
9
  //#region src/components/ShapeEditor/_state/useDrawSession.ts
10
- var ee = 10;
11
- function te(e, t) {
10
+ var te = 10;
11
+ function ne(e, t) {
12
12
  if (e.active !== t.active || e.kind !== t.kind || e.canUndo !== t.canUndo || e.canRedo !== t.canRedo) return !1;
13
13
  let n = e.brush, r = t.brush;
14
14
  return !n || !r ? n === r : n.mode === r.mode && n.editing === r.editing && n.editTargetIds.length === r.editTargetIds.length && n.editTargetIds.every((e, t) => e === r.editTargetIds[t]);
15
15
  }
16
- function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brushSizeRef: x, simplifyEpsilonRef: S, draftMeta: C, engineRef: w, onDrawSessionChange: ne, onDraftShapeChange: re, changeSelection: T, createShape: ie }) {
17
- let ae = p(ne), E = p(re), oe = p(C), D = p(ie), se = h(null), O = h([]), k = h(null), A = h(/* @__PURE__ */ new Set()), j = h([[]]), M = h(0), N = h(null), P = h([]), F = h([]), I = h([]), L = h([[]]), R = h(0), z = h("draw"), B = m(() => z.current === "erase" ? "erase" : "add", []), V = m(() => I.current.length > 0 || P.current.length > 0 || g.current === r.BRUSH && O.current.length > 0, [g]), H = m(() => {
18
- let e = g.current;
16
+ function h({ toolRef: h, selRef: g, docRef: _, readOnlyRef: v, draftRef: y, brushSizeRef: b, simplifyEpsilonRef: x, draftMeta: S, engineRef: C, onDrawSessionChange: re, onDraftShapeChange: ie, changeSelection: w, createShape: ae, onDrawAttemptWithoutDraft: oe }) {
17
+ let se = f(re), T = f(ie), ce = f(S), E = f(ae), le = f(oe), D = p(() => y.current ? !0 : (le.current?.(), !1), [y]), ue = m(null), O = m([]), k = m(null), A = m(/* @__PURE__ */ new Set()), j = m([[]]), M = m(0), N = m(null), P = m([]), F = m([]), I = m([]), L = m([[]]), R = m(0), z = m("draw"), B = p(() => z.current === "erase" ? "erase" : "add", []), V = p(() => I.current.length > 0 || P.current.length > 0 || h.current === r.BRUSH && O.current.length > 0, [h]), H = p(() => {
18
+ let e = h.current;
19
19
  return e === r.BRUSH && V() ? "brush" : e === r.POLYGON && O.current.length > 0 ? "polygon" : e === r.PATH && O.current.length > 0 ? "path" : "none";
20
- }, [V, g]), U = m(() => {
21
- let e = g.current;
20
+ }, [V, h]), U = p(() => {
21
+ let e = h.current;
22
22
  return e === r.BRUSH ? O.current.length > 0 || R.current > 0 : e === r.POLYGON || e === r.PATH ? M.current > 0 : !1;
23
- }, [g]), W = m(() => {
24
- let e = g.current;
23
+ }, [h]), W = p(() => {
24
+ let e = h.current;
25
25
  return e === r.BRUSH ? O.current.length === 0 && R.current < L.current.length - 1 : e === r.POLYGON || e === r.PATH ? M.current < j.current.length - 1 : !1;
26
- }, [g]), ce = m(() => H() !== "none", [H]), le = m(() => z.current, []), G = m(() => {
26
+ }, [h]), de = p(() => H() !== "none", [H]), fe = p(() => z.current, []), G = p(() => {
27
27
  let e = H(), t = {
28
28
  active: e !== "none",
29
29
  kind: e,
@@ -34,18 +34,18 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
34
34
  editing: I.current.length > 0,
35
35
  editTargetIds: [...I.current]
36
36
  } : void 0
37
- }, n = se.current;
38
- n && te(n, t) || (se.current = t, ae.current?.(t));
37
+ }, n = ue.current;
38
+ n && ne(n, t) || (ue.current = t, se.current?.(t));
39
39
  }, [
40
40
  W,
41
41
  U,
42
42
  H
43
- ]), K = m(() => {
43
+ ]), K = p(() => {
44
44
  L.current = [[]], R.current = 0;
45
- }, []), q = m(() => {
46
- let t = w.current;
45
+ }, []), q = p(() => {
46
+ let t = C.current;
47
47
  if (!t) return;
48
- let n = g.current;
48
+ let n = h.current;
49
49
  if (n === r.BRUSH) {
50
50
  let e = [...P.current];
51
51
  if (O.current.length && e.push({
@@ -55,264 +55,284 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
55
55
  t.clearPreview();
56
56
  return;
57
57
  }
58
- let n = a(e, x.current, F.current);
58
+ let n = a(e, b.current, F.current);
59
59
  if (!n) {
60
60
  t.clearPreview();
61
61
  return;
62
62
  }
63
- let r = b.current?.color ?? "#00e5ff";
63
+ let r = y.current?.color ?? "#00e5ff";
64
64
  t.previewScalarMask(n, r);
65
65
  return;
66
66
  }
67
67
  let i = O.current;
68
68
  if (!i.length) {
69
- t.clearPreview(), N.current && (N.current = null, E.current?.(null));
69
+ t.clearPreview(), N.current && (N.current = null, T.current?.(null));
70
70
  return;
71
71
  }
72
72
  let o = {
73
- ...b.current,
74
- color: b.current?.color ?? "#00e5ff"
75
- }, s = Array.from(A.current), c = n !== r.PATH;
76
- if (t.previewPoly(i, k.current, o, !1, s, c), n === r.POLYGON || n === r.PATH) {
77
- let t = E.current;
73
+ ...y.current,
74
+ color: y.current?.color ?? "#00e5ff"
75
+ }, ee = Array.from(A.current), s = n !== r.PATH;
76
+ if (t.previewPoly(i, k.current, o, !1, ee, s), n === r.POLYGON || n === r.PATH) {
77
+ let t = T.current;
78
78
  t && i !== N.current && (N.current = i, t({
79
79
  type: e.POLYGON,
80
- points: l(i),
81
- meta: oe.current
80
+ points: c(i),
81
+ meta: ce.current
82
82
  }));
83
83
  }
84
84
  }, [
85
- x,
86
- B,
87
85
  b,
88
- w,
89
- g
90
- ]), ue = m((e) => {
91
- let t = u(e), n = L.current, r = R.current, i = n[r];
92
- i && f(i, t) || (L.current = [...n.slice(0, r + 1), t], R.current += 1, G());
93
- }, [G]), J = m((e) => {
86
+ B,
87
+ y,
88
+ C,
89
+ h
90
+ ]), pe = p((e) => {
91
+ let t = l(e), n = L.current, r = R.current, i = n[r];
92
+ i && d(i, t) || (L.current = [...n.slice(0, r + 1), t], R.current += 1, G());
93
+ }, [G]), J = p((e) => {
94
94
  let t = j.current, n = M.current, r = t[n];
95
- r && d(r, e) || (j.current = [...t.slice(0, n + 1), l(e)], M.current += 1);
96
- }, []), Y = m(() => {
97
- O.current = [], P.current = [], F.current = [], I.current = [], k.current = null, A.current = /* @__PURE__ */ new Set(), j.current = [[]], M.current = 0, N.current = null, K(), w.current?.clearPreview(), E.current?.(null), G();
95
+ r && u(r, e) || (j.current = [...t.slice(0, n + 1), c(e)], M.current += 1);
96
+ }, []), Y = p(() => {
97
+ O.current = [], P.current = [], F.current = [], I.current = [], k.current = null, A.current = /* @__PURE__ */ new Set(), j.current = [[]], M.current = 0, N.current = null, K(), C.current?.clearPreview(), T.current?.(null), G();
98
98
  }, [
99
- w,
99
+ C,
100
100
  G,
101
101
  K
102
- ]), X = m((e, t) => {
102
+ ]), X = p((e, t) => {
103
103
  O.current = e, A.current = new Set(Array.from(A.current).filter((t) => t >= 0 && t < e.length)), t && J(e), q(), G();
104
104
  }, [
105
105
  G,
106
106
  J,
107
107
  q
108
- ]), de = m(() => l(O.current), []), fe = m(() => O.current.length > 0, []), pe = m((t, n) => {
109
- if (g.current !== r.POLYGON) return !1;
108
+ ]), me = p(() => c(O.current), []), he = p(() => O.current.length > 0, []), ge = p((t, n) => {
109
+ if (h.current !== r.POLYGON) return !1;
110
110
  let i = O.current;
111
111
  if (i.length < 3) return !1;
112
112
  let a = i[0];
113
- return Math.hypot(t.x - a.x, t.y - a.y) > n ? !1 : (D.current(e.POLYGON, i), Y(), !0);
114
- }, [Y, g]), me = m((e) => {
113
+ return Math.hypot(t.x - a.x, t.y - a.y) > n ? !1 : D() ? (E.current(e.POLYGON, i), Y(), !0) : !0;
114
+ }, [
115
+ D,
116
+ Y,
117
+ h
118
+ ]), _e = p((e) => {
115
119
  let t = O.current;
116
120
  return e < 0 || e >= t.length ? !1 : (X(t.filter((t, n) => n !== e), !0), !0);
117
- }, [X]), he = m((e, t) => {
121
+ }, [X]), ve = p((e, t) => {
118
122
  let n = O.current;
119
123
  if (e < 0 || e >= n.length) return null;
120
124
  let r = new Set(A.current);
121
125
  return t ? r.has(e) ? r.delete(e) : r.add(e) : r.has(e) || (r.clear(), r.add(e)), A.current = r, k.current = null, q(), G(), {
122
- base: l(n),
126
+ base: c(n),
123
127
  indices: Array.from(r)
124
128
  };
125
- }, [G, q]), ge = m((e) => {
129
+ }, [G, q]), ye = p((e) => {
126
130
  A.current = /* @__PURE__ */ new Set(), k.current = e, X([...O.current, e], !0);
127
- }, [X]), _e = m((e) => {
131
+ }, [X]), be = p((e) => {
128
132
  k.current = null, A.current = /* @__PURE__ */ new Set(), O.current = [{ ...e }], q(), G();
129
- }, [G, q]), ve = m((e, t) => {
133
+ }, [G, q]), xe = p((e, t) => {
130
134
  let n = O.current[O.current.length - 1];
131
135
  return n && Math.hypot(e.x - n.x, e.y - n.y) < t ? !1 : (O.current = [...O.current, { ...e }], k.current = null, q(), G(), !0);
132
- }, [G, q]), ye = m((e, t, n, r) => {
136
+ }, [G, q]), Se = p((e, t, n, r) => {
133
137
  let i = new Set(t);
134
138
  O.current = e.map((e, t) => i.has(t) ? {
135
139
  x: e.x + n,
136
140
  y: e.y + r
137
141
  } : { ...e }), k.current = null, q(), G();
138
- }, [G, q]), be = m((e) => {
142
+ }, [G, q]), Ce = p((e) => {
139
143
  e && (J(O.current), q(), G());
140
144
  }, [
141
145
  G,
142
146
  J,
143
147
  q
144
- ]), xe = m((e) => {
148
+ ]), we = p((e) => {
145
149
  k.current = e ? { ...e } : null, q();
146
- }, [q]), Se = m(() => O.current.length > 0 ? (O.current = [], q(), G(), !0) : R.current <= 0 ? !1 : (--R.current, P.current = u(L.current[R.current]), q(), G(), !0), [G, q]), Ce = m(() => O.current.length > 0 || R.current >= L.current.length - 1 ? !1 : (R.current += 1, P.current = u(L.current[R.current]), q(), G(), !0), [G, q]), we = m(() => M.current <= 0 ? !1 : (--M.current, O.current = l(j.current[M.current]), A.current = /* @__PURE__ */ new Set(), q(), G(), !0), [G, q]), Z = m(() => M.current >= j.current.length - 1 ? !1 : (M.current += 1, O.current = l(j.current[M.current]), A.current = /* @__PURE__ */ new Set(), q(), G(), !0), [G, q]), Te = m(() => {
147
- let e = g.current;
148
- return e === r.BRUSH ? Se() : e === r.POLYGON || e === r.PATH ? we() : !1;
150
+ }, [q]), Te = p(() => O.current.length > 0 ? (O.current = [], q(), G(), !0) : R.current <= 0 ? !1 : (--R.current, P.current = l(L.current[R.current]), q(), G(), !0), [G, q]), Ee = p(() => O.current.length > 0 || R.current >= L.current.length - 1 ? !1 : (R.current += 1, P.current = l(L.current[R.current]), q(), G(), !0), [G, q]), Z = p(() => M.current <= 0 ? !1 : (--M.current, O.current = c(j.current[M.current]), A.current = /* @__PURE__ */ new Set(), q(), G(), !0), [G, q]), De = p(() => M.current >= j.current.length - 1 ? !1 : (M.current += 1, O.current = c(j.current[M.current]), A.current = /* @__PURE__ */ new Set(), q(), G(), !0), [G, q]), Oe = p(() => {
151
+ let e = h.current;
152
+ return e === r.BRUSH ? Te() : e === r.POLYGON || e === r.PATH ? Z() : !1;
149
153
  }, [
150
- g,
151
- Se,
152
- we
153
- ]), Ee = m(() => {
154
- let e = g.current;
155
- return e === r.BRUSH ? Ce() : e === r.POLYGON || e === r.PATH ? Z() : !1;
154
+ h,
155
+ Te,
156
+ Z
157
+ ]), ke = p(() => {
158
+ let e = h.current;
159
+ return e === r.BRUSH ? Ee() : e === r.POLYGON || e === r.PATH ? De() : !1;
156
160
  }, [
157
- Ce,
158
- Z,
159
- g
160
- ]), Q = m(() => {
161
- let e = _.current;
161
+ Ee,
162
+ De,
163
+ h
164
+ ]), Q = p(() => {
165
+ let e = g.current;
162
166
  if (!e.length) return I.current.length > 0;
163
- let t = v.current.getShapes().filter((t) => e.includes(t.id) && n(t)), r = c(t);
167
+ let t = _.current.getShapes().filter((t) => e.includes(t.id) && n(t)), r = s(t);
164
168
  return r.length ? (I.current = t.map((e) => e.id), F.current = r, !0) : (I.current = [], F.current = [], !1);
165
- }, [v, _]), $ = m(() => {
166
- if (y.current) return !1;
167
- let n = [...P.current];
168
- O.current.length && n.push({
169
- points: l(O.current),
169
+ }, [_, g]), Ae = p(() => {
170
+ let e = I.current;
171
+ if (!e.length) return;
172
+ let t = _.current.getShapes().filter((t) => e.includes(t.id) && n(t)), i = t.length ? s(t) : [];
173
+ I.current = i.length ? t.map((e) => e.id) : [], F.current = i, h.current === r.BRUSH && q(), G();
174
+ }, [
175
+ _,
176
+ G,
177
+ q,
178
+ h
179
+ ]), $ = p(() => {
180
+ if (v.current) return !1;
181
+ let r = [...P.current];
182
+ O.current.length && r.push({
183
+ points: c(O.current),
170
184
  mode: B()
171
185
  });
172
- let r = F.current, i = [...I.current];
173
- if (!n.length && !r.length) return !1;
174
- let c = a(n, x.current, r);
175
- if (!c) return Y(), !1;
176
- let u = s(c, S.current);
177
- if (i.length) {
178
- let n = v.current.getShapes().filter((e) => i.includes(e.id));
179
- if (!u.length) return v.current.remove(i), Y(), T([]), !0;
180
- u.sort((e, t) => o(t) - o(e));
181
- let r = [], a = [], s = [];
182
- for (let i = 0; i < u.length; i++) {
183
- let o = u[i];
184
- if (i < n.length) {
185
- let t = n[i];
186
- r.push({
186
+ let i = I.current, l = i.length ? _.current.getShapes().filter((e) => i.includes(e.id) && n(e)) : [], u = l.length ? s(l) : [];
187
+ if (!r.length && !u.length) return i.length && Y(), !1;
188
+ let d = a(r, b.current, u);
189
+ if (!d) return Y(), !1;
190
+ let f = ee(d, x.current);
191
+ if (l.length) {
192
+ if (!f.length) return _.current.remove(l.map((e) => e.id)), Y(), w([]), !0;
193
+ f.sort((e, t) => o(t) - o(e));
194
+ let n = [], r = [], i = [];
195
+ for (let a = 0; a < f.length; a++) {
196
+ let o = f[a];
197
+ if (a < l.length) {
198
+ let t = l[a];
199
+ n.push({
187
200
  ...t,
188
201
  type: e.POLYGON,
189
202
  points: o
190
- }), s.push(t.id);
203
+ }), i.push(t.id);
191
204
  } else {
192
- let r = n[0], i = t();
193
- a.push({
194
- ...r,
195
- id: i,
205
+ let n = l[0], a = t();
206
+ r.push({
207
+ ...n,
208
+ id: a,
196
209
  type: e.POLYGON,
197
210
  points: o
198
- }), s.push(i);
211
+ }), i.push(a);
199
212
  }
200
213
  }
201
- let c = n.slice(u.length).map((e) => e.id);
202
- return r.length && v.current.update(r), a.length && v.current.create(a), c.length && v.current.remove(c), Y(), T(s), !0;
214
+ let a = l.slice(f.length).map((e) => e.id);
215
+ return _.current.commit({
216
+ update: n,
217
+ create: r,
218
+ remove: a
219
+ }), Y(), w(i), !0;
203
220
  }
204
- if (!u.length) return Y(), !1;
205
- let d = b.current;
206
- if (!d) return !1;
207
- let f = u.map((n) => ({
221
+ if (!f.length) return Y(), !1;
222
+ let p = y.current;
223
+ if (!p) return le.current?.(), !1;
224
+ let m = f.map((n) => ({
208
225
  id: t(),
209
226
  type: e.POLYGON,
210
227
  points: n,
211
- style: d,
212
- meta: C
228
+ style: p,
229
+ meta: S
213
230
  }));
214
- return v.current.create(f), T(f.map((e) => e.id)), Y(), !0;
231
+ return _.current.create(m), w(m.map((e) => e.id)), Y(), !0;
215
232
  }, [
216
- x,
217
- B,
218
- T,
219
- v,
220
- C,
221
233
  b,
234
+ B,
235
+ w,
236
+ _,
237
+ S,
222
238
  y,
239
+ v,
223
240
  Y,
224
- S
225
- ]), De = m(() => {
226
- let t = g.current;
241
+ x
242
+ ]), je = p(() => {
243
+ let t = h.current;
227
244
  if (t === r.BRUSH) return $();
228
245
  let n = O.current;
229
- return t === r.POLYGON && n.length >= 3 ? (D.current(e.POLYGON, n), Y(), !0) : !1;
246
+ return t === r.POLYGON && n.length >= 3 && D() ? (E.current(e.POLYGON, n), Y(), !0) : !1;
230
247
  }, [
231
248
  $,
249
+ D,
232
250
  Y,
233
- g
234
- ]), Oe = m(() => {
251
+ h
252
+ ]), Me = p(() => {
235
253
  let t = O.current;
236
- if (g.current === r.PATH && t.length >= 3) {
237
- let n = i(t, S.current);
238
- n.length >= 3 && D.current(e.POLYGON, n);
254
+ if (h.current === r.PATH && t.length >= 3) {
255
+ let n = i(t, x.current);
256
+ n.length >= 3 && D() && E.current(e.POLYGON, n);
239
257
  }
240
258
  Y();
241
259
  }, [
260
+ D,
242
261
  Y,
243
- S,
244
- g
245
- ]), ke = m((e) => {
262
+ x,
263
+ h
264
+ ]), Ne = p((e) => {
246
265
  z.current = e, G(), q();
247
- }, [G, q]), Ae = m(() => {
248
- if (y.current || g.current !== r.BRUSH) return !1;
266
+ }, [G, q]), Pe = p(() => {
267
+ if (v.current || h.current !== r.BRUSH) return !1;
249
268
  P.current = [], O.current = [], K();
250
269
  let e = Q();
251
270
  return G(), q(), e;
252
271
  }, [
253
272
  G,
254
- y,
273
+ v,
255
274
  q,
256
275
  K,
257
276
  Q,
258
- g
259
- ]), je = m(() => {
277
+ h
278
+ ]), Fe = p(() => {
260
279
  let e = A.current;
261
280
  if (!e.size) return !1;
262
281
  let t = O.current.filter((t, n) => !e.has(n));
263
282
  return A.current = /* @__PURE__ */ new Set(), X(t, !0), !0;
264
- }, [X]), Me = m((e) => {
265
- let t = w.current, n = O.current;
283
+ }, [X]), Ie = p((e) => {
284
+ let t = C.current, n = O.current;
266
285
  if (!t || !n.length) return -1;
267
- let r = ee / (t.viewport.scale || 1);
286
+ let r = te / (t.viewport.scale || 1);
268
287
  for (let t = n.length - 1; t >= 0; t--) {
269
288
  let i = n[t];
270
289
  if (Math.hypot(e.x - i.x, e.y - i.y) <= r) return t;
271
290
  }
272
291
  return -1;
273
- }, [w]), Ne = m(() => {
292
+ }, [C]), Le = p(() => {
274
293
  O.current.length >= 1 && (P.current.push({
275
- points: l(O.current),
294
+ points: c(O.current),
276
295
  mode: B()
277
- }), O.current = [], ue(P.current)), q(), G();
296
+ }), O.current = [], pe(P.current)), q(), G();
278
297
  }, [
279
298
  B,
280
299
  G,
281
- ue,
300
+ pe,
282
301
  q
283
302
  ]);
284
303
  return {
285
304
  reset: Y,
286
- undoSession: Te,
287
- redoSession: Ee,
305
+ undoSession: Oe,
306
+ redoSession: ke,
288
307
  canUndoSession: U,
289
308
  canRedoSession: W,
290
- hasDraftSession: ce,
291
- hasDraftPoints: fe,
292
- commitDraftSession: De,
293
- completeFreehandStroke: Oe,
294
- setBrushScalarMode: ke,
295
- getBrushScalarMode: le,
309
+ hasDraftSession: de,
310
+ hasDraftPoints: he,
311
+ commitDraftSession: je,
312
+ completeFreehandStroke: Me,
313
+ setBrushScalarMode: Ne,
314
+ getBrushScalarMode: fe,
296
315
  hasBrushSession: V,
297
316
  commitBrush: $,
298
- cancelBrush: m(() => {
299
- g.current === r.BRUSH && Y();
300
- }, [Y, g]),
301
- beginBrushEditFromSelection: Ae,
302
- deleteDraftSelectedPoints: je,
303
- hitDraftPoint: Me,
304
- getDraftPointsSnapshot: de,
305
- tryClosePolygon: pe,
306
- removeDraftPoint: me,
307
- selectDraftPointForDrag: he,
308
- appendPolygonPoint: ge,
309
- beginStroke: _e,
310
- appendStrokePoint: ve,
311
- moveDraftPoints: ye,
312
- commitDraftPointDrag: be,
313
- setDraftCursor: xe,
314
- finishScalarStroke: Ne,
315
- handleToolChange: m((e, t) => {
317
+ syncBrushTargets: Ae,
318
+ cancelBrush: p(() => {
319
+ h.current === r.BRUSH && Y();
320
+ }, [Y, h]),
321
+ beginBrushEditFromSelection: Pe,
322
+ deleteDraftSelectedPoints: Fe,
323
+ hitDraftPoint: Ie,
324
+ getDraftPointsSnapshot: me,
325
+ tryClosePolygon: ge,
326
+ removeDraftPoint: _e,
327
+ selectDraftPointForDrag: ve,
328
+ appendPolygonPoint: ye,
329
+ beginStroke: be,
330
+ appendStrokePoint: xe,
331
+ moveDraftPoints: Se,
332
+ commitDraftPointDrag: Ce,
333
+ setDraftCursor: we,
334
+ finishScalarStroke: Le,
335
+ handleToolChange: p((e, t) => {
316
336
  if (t) {
317
337
  Y(), z.current = "draw";
318
338
  return;
@@ -329,8 +349,8 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
329
349
  K,
330
350
  Q
331
351
  ]),
332
- handleBrushSelectionChange: m((e, t) => {
333
- if (!(g.current !== r.BRUSH || t)) {
352
+ handleBrushSelectionChange: p((e, t) => {
353
+ if (!(h.current !== r.BRUSH || t)) {
334
354
  if (!e.length) {
335
355
  G();
336
356
  return;
@@ -342,11 +362,11 @@ function g({ toolRef: g, selRef: _, docRef: v, readOnlyRef: y, draftRef: b, brus
342
362
  q,
343
363
  K,
344
364
  Q,
345
- g
365
+ h
346
366
  ])
347
367
  };
348
368
  }
349
369
  //#endregion
350
- export { g as useDrawSession };
370
+ export { h as useDrawSession };
351
371
 
352
372
  //# sourceMappingURL=useDrawSession.js.map