react-img-cutout 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,352 +1,451 @@
1
- import kt, { useState as L, useRef as B, useCallback as P, useMemo as F, useEffect as O, useContext as z, createContext as lt } from "react";
2
- var nt = { exports: {} }, G = {};
1
+ import Ct, { useState as O, useRef as N, useCallback as M, useMemo as V, useEffect as W, useContext as Y, createContext as lt } from "react";
2
+ var st = { exports: {} }, tt = {};
3
3
  var ut;
4
- function Et() {
5
- if (ut) return G;
4
+ function Mt() {
5
+ if (ut) return tt;
6
6
  ut = 1;
7
- var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
8
- function n(r, i, l) {
9
- var a = null;
10
- if (l !== void 0 && (a = "" + l), i.key !== void 0 && (a = "" + i.key), "key" in i) {
11
- l = {};
12
- for (var s in i)
13
- s !== "key" && (l[s] = i[s]);
14
- } else l = i;
15
- return i = l.ref, {
7
+ var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
8
+ function n(e, c, i) {
9
+ var s = null;
10
+ if (i !== void 0 && (s = "" + i), c.key !== void 0 && (s = "" + c.key), "key" in c) {
11
+ i = {};
12
+ for (var o in c)
13
+ o !== "key" && (i[o] = c[o]);
14
+ } else i = c;
15
+ return c = i.ref, {
16
16
  $$typeof: t,
17
- type: r,
18
- key: a,
19
- ref: i !== void 0 ? i : null,
20
- props: l
17
+ type: e,
18
+ key: s,
19
+ ref: c !== void 0 ? c : null,
20
+ props: i
21
21
  };
22
22
  }
23
- return G.Fragment = e, G.jsx = n, G.jsxs = n, G;
23
+ return tt.Fragment = r, tt.jsx = n, tt.jsxs = n, tt;
24
24
  }
25
- var J = {};
26
- var ft;
25
+ var et = {};
26
+ var ht;
27
27
  function It() {
28
- return ft || (ft = 1, process.env.NODE_ENV !== "production" && (function() {
29
- function t(o) {
30
- if (o == null) return null;
31
- if (typeof o == "function")
32
- return o.$$typeof === X ? null : o.displayName || o.name || null;
33
- if (typeof o == "string") return o;
34
- switch (o) {
35
- case f:
28
+ return ht || (ht = 1, process.env.NODE_ENV !== "production" && (function() {
29
+ function t(a) {
30
+ if (a == null) return null;
31
+ if (typeof a == "function")
32
+ return a.$$typeof === Q ? null : a.displayName || a.name || null;
33
+ if (typeof a == "string") return a;
34
+ switch (a) {
35
+ case d:
36
36
  return "Fragment";
37
- case h:
37
+ case f:
38
38
  return "Profiler";
39
- case b:
39
+ case h:
40
40
  return "StrictMode";
41
- case $:
41
+ case A:
42
42
  return "Suspense";
43
- case N:
43
+ case _:
44
44
  return "SuspenseList";
45
- case q:
45
+ case U:
46
46
  return "Activity";
47
47
  }
48
- if (typeof o == "object")
49
- switch (typeof o.tag == "number" && console.error(
48
+ if (typeof a == "object")
49
+ switch (typeof a.tag == "number" && console.error(
50
50
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
- ), o.$$typeof) {
52
- case v:
51
+ ), a.$$typeof) {
52
+ case y:
53
53
  return "Portal";
54
+ case k:
55
+ return a.displayName || "Context";
54
56
  case w:
55
- return o.displayName || "Context";
56
- case E:
57
- return (o._context.displayName || "Context") + ".Consumer";
58
- case x:
59
- var y = o.render;
60
- return o = o.displayName, o || (o = y.displayName || y.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
61
- case H:
62
- return y = o.displayName || null, y !== null ? y : t(o.type) || "Memo";
63
- case V:
64
- y = o._payload, o = o._init;
57
+ return (a._context.displayName || "Context") + ".Consumer";
58
+ case b:
59
+ var E = a.render;
60
+ return a = a.displayName, a || (a = E.displayName || E.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
61
+ case X:
62
+ return E = a.displayName || null, E !== null ? E : t(a.type) || "Memo";
63
+ case D:
64
+ E = a._payload, a = a._init;
65
65
  try {
66
- return t(o(y));
66
+ return t(a(E));
67
67
  } catch {
68
68
  }
69
69
  }
70
70
  return null;
71
71
  }
72
- function e(o) {
73
- return "" + o;
72
+ function r(a) {
73
+ return "" + a;
74
74
  }
75
- function n(o) {
75
+ function n(a) {
76
76
  try {
77
- e(o);
78
- var y = !1;
77
+ r(a);
78
+ var E = !1;
79
79
  } catch {
80
- y = !0;
80
+ E = !0;
81
81
  }
82
- if (y) {
83
- y = console;
84
- var A = y.error, S = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
85
- return A.call(
86
- y,
82
+ if (E) {
83
+ E = console;
84
+ var j = E.error, $ = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
85
+ return j.call(
86
+ E,
87
87
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
- S
89
- ), e(o);
88
+ $
89
+ ), r(a);
90
90
  }
91
91
  }
92
- function r(o) {
93
- if (o === f) return "<>";
94
- if (typeof o == "object" && o !== null && o.$$typeof === V)
92
+ function e(a) {
93
+ if (a === d) return "<>";
94
+ if (typeof a == "object" && a !== null && a.$$typeof === D)
95
95
  return "<...>";
96
96
  try {
97
- var y = t(o);
98
- return y ? "<" + y + ">" : "<...>";
97
+ var E = t(a);
98
+ return E ? "<" + E + ">" : "<...>";
99
99
  } catch {
100
100
  return "<...>";
101
101
  }
102
102
  }
103
- function i() {
104
- var o = j.A;
105
- return o === null ? null : o.getOwner();
103
+ function c() {
104
+ var a = B.A;
105
+ return a === null ? null : a.getOwner();
106
106
  }
107
- function l() {
107
+ function i() {
108
108
  return Error("react-stack-top-frame");
109
109
  }
110
- function a(o) {
111
- if (R.call(o, "key")) {
112
- var y = Object.getOwnPropertyDescriptor(o, "key").get;
113
- if (y && y.isReactWarning) return !1;
110
+ function s(a) {
111
+ if (q.call(a, "key")) {
112
+ var E = Object.getOwnPropertyDescriptor(a, "key").get;
113
+ if (E && E.isReactWarning) return !1;
114
114
  }
115
- return o.key !== void 0;
115
+ return a.key !== void 0;
116
116
  }
117
- function s(o, y) {
118
- function A() {
119
- M || (M = !0, console.error(
117
+ function o(a, E) {
118
+ function j() {
119
+ P || (P = !0, console.error(
120
120
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
121
- y
121
+ E
122
122
  ));
123
123
  }
124
- A.isReactWarning = !0, Object.defineProperty(o, "key", {
125
- get: A,
124
+ j.isReactWarning = !0, Object.defineProperty(a, "key", {
125
+ get: j,
126
126
  configurable: !0
127
127
  });
128
128
  }
129
- function u() {
130
- var o = t(this.type);
131
- return W[o] || (W[o] = !0, console.error(
129
+ function l() {
130
+ var a = t(this.type);
131
+ return I[a] || (I[a] = !0, console.error(
132
132
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
133
- )), o = this.props.ref, o !== void 0 ? o : null;
133
+ )), a = this.props.ref, a !== void 0 ? a : null;
134
134
  }
135
- function c(o, y, A, S, rt, st) {
136
- var T = A.ref;
137
- return o = {
138
- $$typeof: m,
139
- type: o,
140
- key: y,
141
- props: A,
142
- _owner: S
143
- }, (T !== void 0 ? T : null) !== null ? Object.defineProperty(o, "ref", {
135
+ function u(a, E, j, $, ot, it) {
136
+ var T = j.ref;
137
+ return a = {
138
+ $$typeof: g,
139
+ type: a,
140
+ key: E,
141
+ props: j,
142
+ _owner: $
143
+ }, (T !== void 0 ? T : null) !== null ? Object.defineProperty(a, "ref", {
144
144
  enumerable: !1,
145
- get: u
146
- }) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
145
+ get: l
146
+ }) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
147
147
  configurable: !1,
148
148
  enumerable: !1,
149
149
  writable: !0,
150
150
  value: 0
151
- }), Object.defineProperty(o, "_debugInfo", {
151
+ }), Object.defineProperty(a, "_debugInfo", {
152
152
  configurable: !1,
153
153
  enumerable: !1,
154
154
  writable: !0,
155
155
  value: null
156
- }), Object.defineProperty(o, "_debugStack", {
156
+ }), Object.defineProperty(a, "_debugStack", {
157
157
  configurable: !1,
158
158
  enumerable: !1,
159
159
  writable: !0,
160
- value: rt
161
- }), Object.defineProperty(o, "_debugTask", {
160
+ value: ot
161
+ }), Object.defineProperty(a, "_debugTask", {
162
162
  configurable: !1,
163
163
  enumerable: !1,
164
164
  writable: !0,
165
- value: st
166
- }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
165
+ value: it
166
+ }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
167
167
  }
168
- function d(o, y, A, S, rt, st) {
169
- var T = y.children;
168
+ function p(a, E, j, $, ot, it) {
169
+ var T = E.children;
170
170
  if (T !== void 0)
171
- if (S)
172
- if (C(T)) {
173
- for (S = 0; S < T.length; S++)
174
- k(T[S]);
171
+ if ($)
172
+ if (S(T)) {
173
+ for ($ = 0; $ < T.length; $++)
174
+ m(T[$]);
175
175
  Object.freeze && Object.freeze(T);
176
176
  } else
177
177
  console.error(
178
178
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
179
  );
180
- else k(T);
181
- if (R.call(y, "key")) {
182
- T = t(o);
183
- var U = Object.keys(y).filter(function(wt) {
184
- return wt !== "key";
180
+ else m(T);
181
+ if (q.call(E, "key")) {
182
+ T = t(a);
183
+ var K = Object.keys(E).filter(function(Et) {
184
+ return Et !== "key";
185
185
  });
186
- S = 0 < U.length ? "{key: someKey, " + U.join(": ..., ") + ": ...}" : "{key: someKey}", ct[T + S] || (U = 0 < U.length ? "{" + U.join(": ..., ") + ": ...}" : "{}", console.error(
186
+ $ = 0 < K.length ? "{key: someKey, " + K.join(": ..., ") + ": ...}" : "{key: someKey}", G[T + $] || (K = 0 < K.length ? "{" + K.join(": ..., ") + ": ...}" : "{}", console.error(
187
187
  `A props object containing a "key" prop is being spread into JSX:
188
188
  let props = %s;
189
189
  <%s {...props} />
190
190
  React keys must be passed directly to JSX without using spread:
191
191
  let props = %s;
192
192
  <%s key={someKey} {...props} />`,
193
- S,
193
+ $,
194
194
  T,
195
- U,
195
+ K,
196
196
  T
197
- ), ct[T + S] = !0);
197
+ ), G[T + $] = !0);
198
198
  }
199
- if (T = null, A !== void 0 && (n(A), T = "" + A), a(y) && (n(y.key), T = "" + y.key), "key" in y) {
200
- A = {};
201
- for (var it in y)
202
- it !== "key" && (A[it] = y[it]);
203
- } else A = y;
204
- return T && s(
205
- A,
206
- typeof o == "function" ? o.displayName || o.name || "Unknown" : o
207
- ), c(
208
- o,
199
+ if (T = null, j !== void 0 && (n(j), T = "" + j), s(E) && (n(E.key), T = "" + E.key), "key" in E) {
200
+ j = {};
201
+ for (var at in E)
202
+ at !== "key" && (j[at] = E[at]);
203
+ } else j = E;
204
+ return T && o(
205
+ j,
206
+ typeof a == "function" ? a.displayName || a.name || "Unknown" : a
207
+ ), u(
208
+ a,
209
209
  T,
210
- A,
211
- i(),
212
- rt,
213
- st
210
+ j,
211
+ c(),
212
+ ot,
213
+ it
214
214
  );
215
215
  }
216
- function k(o) {
217
- p(o) ? o._store && (o._store.validated = 1) : typeof o == "object" && o !== null && o.$$typeof === V && (o._payload.status === "fulfilled" ? p(o._payload.value) && o._payload.value._store && (o._payload.value._store.validated = 1) : o._store && (o._store.validated = 1));
216
+ function m(a) {
217
+ v(a) ? a._store && (a._store.validated = 1) : typeof a == "object" && a !== null && a.$$typeof === D && (a._payload.status === "fulfilled" ? v(a._payload.value) && a._payload.value._store && (a._payload.value._store.validated = 1) : a._store && (a._store.validated = 1));
218
218
  }
219
- function p(o) {
220
- return typeof o == "object" && o !== null && o.$$typeof === m;
219
+ function v(a) {
220
+ return typeof a == "object" && a !== null && a.$$typeof === g;
221
221
  }
222
- var g = kt, m = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), f = /* @__PURE__ */ Symbol.for("react.fragment"), b = /* @__PURE__ */ Symbol.for("react.strict_mode"), h = /* @__PURE__ */ Symbol.for("react.profiler"), E = /* @__PURE__ */ Symbol.for("react.consumer"), w = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), $ = /* @__PURE__ */ Symbol.for("react.suspense"), N = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), V = /* @__PURE__ */ Symbol.for("react.lazy"), q = /* @__PURE__ */ Symbol.for("react.activity"), X = /* @__PURE__ */ Symbol.for("react.client.reference"), j = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, C = Array.isArray, _ = console.createTask ? console.createTask : function() {
222
+ var x = Ct, g = /* @__PURE__ */ Symbol.for("react.transitional.element"), y = /* @__PURE__ */ Symbol.for("react.portal"), d = /* @__PURE__ */ Symbol.for("react.fragment"), h = /* @__PURE__ */ Symbol.for("react.strict_mode"), f = /* @__PURE__ */ Symbol.for("react.profiler"), w = /* @__PURE__ */ Symbol.for("react.consumer"), k = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), A = /* @__PURE__ */ Symbol.for("react.suspense"), _ = /* @__PURE__ */ Symbol.for("react.suspense_list"), X = /* @__PURE__ */ Symbol.for("react.memo"), D = /* @__PURE__ */ Symbol.for("react.lazy"), U = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), B = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, q = Object.prototype.hasOwnProperty, S = Array.isArray, R = console.createTask ? console.createTask : function() {
223
223
  return null;
224
224
  };
225
- g = {
226
- react_stack_bottom_frame: function(o) {
227
- return o();
225
+ x = {
226
+ react_stack_bottom_frame: function(a) {
227
+ return a();
228
228
  }
229
229
  };
230
- var M, W = {}, Y = g.react_stack_bottom_frame.bind(
231
- g,
232
- l
233
- )(), D = _(r(l)), ct = {};
234
- J.Fragment = f, J.jsx = function(o, y, A) {
235
- var S = 1e4 > j.recentlyCreatedOwnerStacks++;
236
- return d(
237
- o,
238
- y,
239
- A,
230
+ var P, I = {}, z = x.react_stack_bottom_frame.bind(
231
+ x,
232
+ i
233
+ )(), L = R(e(i)), G = {};
234
+ et.Fragment = d, et.jsx = function(a, E, j) {
235
+ var $ = 1e4 > B.recentlyCreatedOwnerStacks++;
236
+ return p(
237
+ a,
238
+ E,
239
+ j,
240
240
  !1,
241
- S ? Error("react-stack-top-frame") : Y,
242
- S ? _(r(o)) : D
241
+ $ ? Error("react-stack-top-frame") : z,
242
+ $ ? R(e(a)) : L
243
243
  );
244
- }, J.jsxs = function(o, y, A) {
245
- var S = 1e4 > j.recentlyCreatedOwnerStacks++;
246
- return d(
247
- o,
248
- y,
249
- A,
244
+ }, et.jsxs = function(a, E, j) {
245
+ var $ = 1e4 > B.recentlyCreatedOwnerStacks++;
246
+ return p(
247
+ a,
248
+ E,
249
+ j,
250
250
  !0,
251
- S ? Error("react-stack-top-frame") : Y,
252
- S ? _(r(o)) : D
251
+ $ ? Error("react-stack-top-frame") : z,
252
+ $ ? R(e(a)) : L
253
253
  );
254
254
  };
255
- })()), J;
255
+ })()), et;
256
256
  }
257
- var dt;
258
- function Ct() {
259
- return dt || (dt = 1, process.env.NODE_ENV === "production" ? nt.exports = Et() : nt.exports = It()), nt.exports;
257
+ var ft;
258
+ function Rt() {
259
+ return ft || (ft = 1, process.env.NODE_ENV === "production" ? st.exports = Mt() : st.exports = It()), st.exports;
260
260
  }
261
- var I = Ct();
262
- const At = 200;
263
- function Rt(t, e, n) {
264
- const r = n[0] - e[0], i = n[1] - e[1], l = r * r + i * i;
265
- if (l === 0) {
266
- const s = t[0] - e[0], u = t[1] - e[1];
267
- return Math.sqrt(s * s + u * u);
261
+ var C = Rt();
262
+ const At = 400;
263
+ function Pt(t, r, n) {
264
+ const e = n[0] - r[0], c = n[1] - r[1], i = e * e + c * c;
265
+ if (i === 0) {
266
+ const o = t[0] - r[0], l = t[1] - r[1];
267
+ return Math.sqrt(o * o + l * l);
268
268
  }
269
- return Math.abs(r * (e[1] - t[1]) - i * (e[0] - t[0])) / Math.sqrt(l);
269
+ return Math.abs(e * (r[1] - t[1]) - c * (r[0] - t[0])) / Math.sqrt(i);
270
270
  }
271
- function at(t, e) {
271
+ function ct(t, r) {
272
272
  if (t.length <= 2) return t;
273
- let n = 0, r = 0;
274
- const i = t[0], l = t[t.length - 1];
275
- for (let a = 1; a < t.length - 1; a++) {
276
- const s = Rt(t[a], i, l);
277
- s > n && (n = s, r = a);
273
+ let n = 0, e = 0;
274
+ const c = t[0], i = t[t.length - 1];
275
+ for (let s = 1; s < t.length - 1; s++) {
276
+ const o = Pt(t[s], c, i);
277
+ o > n && (n = o, e = s);
278
278
  }
279
- if (n > e) {
280
- const a = at(t.slice(0, r + 1), e), s = at(t.slice(r), e);
281
- return a.slice(0, -1).concat(s);
279
+ if (n > r) {
280
+ const s = ct(t.slice(0, e + 1), r), o = ct(t.slice(e), r);
281
+ return s.slice(0, -1).concat(o);
282
282
  }
283
- return [i, l];
283
+ return [c, i];
284
284
  }
285
- function _t(t, e, n) {
286
- let r = -1, i = -1;
287
- t: for (let g = 0; g < n; g++)
288
- for (let m = 0; m < e; m++)
289
- if (t[g * e + m]) {
290
- r = m, i = g;
291
- break t;
292
- }
293
- if (r < 0) return [];
294
- const l = [1, 1, 0, -1, -1, -1, 0, 1], a = [0, 1, 1, 1, 0, -1, -1, -1], s = [];
295
- let u = r, c = i, d = 5;
296
- const k = e * n * 4;
297
- let p = 0;
298
- do {
299
- s.push([u, c]);
300
- let g = !1;
301
- for (let m = 0; m < 8; m++) {
302
- const v = (d + m) % 8, f = u + l[v], b = c + a[v];
303
- if (f >= 0 && f < e && b >= 0 && b < n && t[b * e + f]) {
304
- u = f, c = b, d = ((v + 4) % 8 + 1) % 8, g = !0;
305
- break;
306
- }
285
+ function dt(t) {
286
+ let r = 0;
287
+ const n = t.length;
288
+ for (let e = 0; e < n; e++) {
289
+ const [c, i] = t[e], [s, o] = t[(e + 1) % n];
290
+ r += c * o - s * i;
291
+ }
292
+ return r * 0.5;
293
+ }
294
+ function St(t, r) {
295
+ if (t.length <= 3 || r <= 0) return t;
296
+ const n = t.concat([t[0]]), e = ct(n, r);
297
+ return e.length < 4 ? t : (e.pop(), e.length >= 3 ? e : t);
298
+ }
299
+ const jt = [
300
+ [],
301
+ // 0 (0000)
302
+ [[3, 0]],
303
+ // 1 (0001) TL
304
+ [[0, 1]],
305
+ // 2 (0010) TR
306
+ [[3, 1]],
307
+ // 3 (0011) TL TR
308
+ [[1, 2]],
309
+ // 4 (0100) BR
310
+ [[3, 0], [1, 2]],
311
+ // 5 (0101) TL BR (saddle)
312
+ [[0, 2]],
313
+ // 6 (0110) TR BR
314
+ [[3, 2]],
315
+ // 7 (0111) TL TR BR
316
+ [[2, 3]],
317
+ // 8 (1000) BL
318
+ [[2, 0]],
319
+ // 9 (1001) TL BL
320
+ [[0, 1], [2, 3]],
321
+ // 10 (1010) TR BL (saddle)
322
+ [[2, 1]],
323
+ // 11 (1011) TL TR BL
324
+ [[1, 3]],
325
+ // 12 (1100) BR BL
326
+ [[1, 0]],
327
+ // 13 (1101) TL BR BL
328
+ [[0, 3]],
329
+ // 14 (1110) TR BR BL
330
+ []
331
+ // 15 (1111)
332
+ ];
333
+ function _t(t, r, n, e) {
334
+ const c = [];
335
+ for (let i = 0; i < n - 1; i++)
336
+ for (let s = 0; s < r - 1; s++) {
337
+ const o = t[i * r + s], l = t[i * r + s + 1], u = t[(i + 1) * r + s + 1], p = t[(i + 1) * r + s];
338
+ let m = 0;
339
+ if (o >= e && (m |= 1), l >= e && (m |= 2), u >= e && (m |= 4), p >= e && (m |= 8), m === 0 || m === 15) continue;
340
+ const v = (x) => {
341
+ switch (x) {
342
+ case 0: {
343
+ const g = l - o, y = Math.abs(g) < 1e-10 ? 0.5 : Math.max(0, Math.min(1, (e - o) / g));
344
+ return [s + y, i];
345
+ }
346
+ case 1: {
347
+ const g = u - l, y = Math.abs(g) < 1e-10 ? 0.5 : Math.max(0, Math.min(1, (e - l) / g));
348
+ return [s + 1, i + y];
349
+ }
350
+ case 2: {
351
+ const g = u - p, y = Math.abs(g) < 1e-10 ? 0.5 : Math.max(0, Math.min(1, (e - p) / g));
352
+ return [s + y, i + 1];
353
+ }
354
+ case 3: {
355
+ const g = p - o, y = Math.abs(g) < 1e-10 ? 0.5 : Math.max(0, Math.min(1, (e - o) / g));
356
+ return [s, i + y];
357
+ }
358
+ default:
359
+ return [s + 0.5, i + 0.5];
360
+ }
361
+ };
362
+ for (const [x, g] of jt[m])
363
+ c.push([v(x), v(g)]);
307
364
  }
308
- if (!g || ++p > k) break;
309
- } while (u !== r || c !== i);
310
- return s;
365
+ return c;
311
366
  }
312
- function jt(t, e, n, r = 30, i = 3e-3) {
313
- if (e <= 0 || n <= 0 || t.length === 0) return [];
314
- const l = Math.min(1, At / Math.max(e, n)), a = Math.max(1, Math.round(e * l)), s = Math.max(1, Math.round(n * l)), u = new Uint8Array(a * s);
315
- for (let p = 0; p < s; p++) {
316
- const g = Math.min(n - 1, Math.floor(p / l));
317
- for (let m = 0; m < a; m++) {
318
- const v = Math.min(e - 1, Math.floor(m / l));
319
- u[p * a + m] = t[g * e + v] > r ? 1 : 0;
367
+ function $t(t) {
368
+ if (t.length === 0) return [];
369
+ const r = (i) => `${Math.round(i[0] * 1e4)},${Math.round(i[1] * 1e4)}`, n = /* @__PURE__ */ new Map();
370
+ for (let i = 0; i < t.length; i++)
371
+ for (const s of [0, 1]) {
372
+ const o = r(t[i][s]);
373
+ let l = n.get(o);
374
+ l || (l = [], n.set(o, l)), l.push({ idx: i, end: s });
320
375
  }
376
+ const e = new Uint8Array(t.length), c = [];
377
+ for (let i = 0; i < t.length; i++) {
378
+ if (e[i]) continue;
379
+ const s = [];
380
+ let o = i, l = 1, u = 0;
381
+ const p = t.length + 1;
382
+ for (; u++ < p && !e[o]; ) {
383
+ e[o] = 1;
384
+ const m = l === 1 ? 0 : 1;
385
+ s.push(t[o][m]);
386
+ const v = t[o][l], x = r(v), g = n.get(x);
387
+ if (!g) break;
388
+ const y = g.find((d) => !e[d.idx]);
389
+ if (!y) break;
390
+ o = y.idx, l = y.end === 0 ? 1 : 0;
391
+ }
392
+ s.length >= 3 && c.push(s);
393
+ }
394
+ return c;
395
+ }
396
+ function Tt(t, r, n, e = 30, c = 2e-3) {
397
+ if (r <= 0 || n <= 0 || t.length === 0) return [];
398
+ const i = Math.min(1, At / Math.max(r, n)), s = Math.max(1, Math.round(r * i)), o = Math.max(1, Math.round(n * i)), l = s + 2, u = o + 2, p = new Float32Array(l * u);
399
+ for (let h = 0; h < o; h++) {
400
+ const f = Math.min(n - 1, Math.floor(h / i));
401
+ for (let w = 0; w < s; w++) {
402
+ const k = Math.min(r - 1, Math.floor(w / i));
403
+ p[(h + 1) * l + (w + 1)] = t[f * r + k];
404
+ }
405
+ }
406
+ const m = _t(p, l, u, e), v = $t(m);
407
+ if (v.length === 0) return [];
408
+ let x = v[0], g = Math.abs(dt(x));
409
+ for (let h = 1; h < v.length; h++) {
410
+ const f = Math.abs(dt(v[h]));
411
+ f > g && (x = v[h], g = f);
321
412
  }
322
- const c = _t(u, a, s);
323
- if (c.length < 3) return [];
324
- const d = c.map(([p, g]) => [
325
- (p + 0.5) / a,
326
- (g + 0.5) / s
327
- ]), k = at(d, i);
328
- return k.length >= 3 ? k : d;
413
+ const y = x.map(([h, f]) => [
414
+ (h - 1) / s,
415
+ (f - 1) / o
416
+ ]), d = St(y, c);
417
+ return d.length >= 3 ? d : y;
329
418
  }
330
- function St(t, e) {
331
- const n = new Uint8Array(e);
332
- for (let r = 0; r < e; r++)
333
- n[r] = t[r * 4 + 3];
419
+ function Dt(t) {
420
+ const r = t.length;
421
+ if (r < 3) return "";
422
+ const n = [`M${t[0][0]},${t[0][1]}`];
423
+ for (let e = 0; e < r; e++) {
424
+ const c = t[(e - 1 + r) % r], i = t[e], s = t[(e + 1) % r], o = t[(e + 2) % r], l = i[0] + (s[0] - c[0]) / 6, u = i[1] + (s[1] - c[1]) / 6, p = s[0] - (o[0] - i[0]) / 6, m = s[1] - (o[1] - i[1]) / 6;
425
+ n.push(`C${l},${u} ${p},${m} ${s[0]},${s[1]}`);
426
+ }
427
+ return n.push("Z"), n.join("");
428
+ }
429
+ function Wt(t, r) {
430
+ const n = new Uint8Array(r);
431
+ for (let e = 0; e < r; e++)
432
+ n[e] = t[e * 4 + 3];
334
433
  return n;
335
434
  }
336
- function Tt(t, e, n, r) {
337
- if (e <= 0 || n <= 0) return { x: 0, y: 0, w: 1, h: 1 };
338
- let i = e, l = n, a = 0, s = 0, u = !1;
339
- for (let c = 0; c < n; c++)
340
- for (let d = 0; d < e; d++)
341
- t[c * e + d] > r && (d < i && (i = d), d > a && (a = d), c < l && (l = c), c > s && (s = c), u = !0);
342
- return u ? {
343
- x: i / e,
344
- y: l / n,
345
- w: (a - i + 1) / e,
346
- h: (s - l + 1) / n
435
+ function zt(t, r, n, e) {
436
+ if (r <= 0 || n <= 0) return { x: 0, y: 0, w: 1, h: 1 };
437
+ let c = r, i = n, s = 0, o = 0, l = !1;
438
+ for (let u = 0; u < n; u++)
439
+ for (let p = 0; p < r; p++)
440
+ t[u * r + p] > e && (p < c && (c = p), p > s && (s = p), u < i && (i = u), u > o && (o = u), l = !0);
441
+ return l ? {
442
+ x: c / r,
443
+ y: i / n,
444
+ w: (s - c + 1) / r,
445
+ h: (o - i + 1) / n
347
446
  } : { x: 0, y: 0, w: 1, h: 1 };
348
447
  }
349
- class Pt {
448
+ class Ot {
350
449
  id;
351
450
  bounds = { x: 0, y: 0, w: 1, h: 1 };
352
451
  contour = [];
@@ -359,8 +458,8 @@ class Pt {
359
458
  /** Source image dimensions (pixels) — needed to map normalized coords to pixel indices */
360
459
  width = 0;
361
460
  height = 0;
362
- constructor(e, n) {
363
- this.id = e.id, this.src = e.src, this.threshold = n;
461
+ constructor(r, n) {
462
+ this.id = r.id, this.src = r.src, this.threshold = n;
364
463
  }
365
464
  /**
366
465
  * Loads the cutout image and pre-computes the alpha buffer + bounding box.
@@ -377,20 +476,20 @@ class Pt {
377
476
  * empty alpha buffer, which means hitTest will always return false.
378
477
  */
379
478
  async prepare() {
380
- const e = new Image();
381
- e.crossOrigin = "anonymous", e.src = this.src, await new Promise((a) => {
382
- e.onload = () => a(), e.onerror = () => a();
479
+ const r = new Image();
480
+ r.crossOrigin = "anonymous", r.src = this.src, await new Promise((s) => {
481
+ r.onload = () => s(), r.onerror = () => s();
383
482
  });
384
- const n = e.naturalWidth, r = e.naturalHeight;
385
- if (n <= 0 || r <= 0) return;
386
- const i = document.createElement("canvas");
387
- i.width = n, i.height = r;
388
- const l = i.getContext("2d", { willReadFrequently: !0 });
389
- if (l)
483
+ const n = r.naturalWidth, e = r.naturalHeight;
484
+ if (n <= 0 || e <= 0) return;
485
+ const c = document.createElement("canvas");
486
+ c.width = n, c.height = e;
487
+ const i = c.getContext("2d", { willReadFrequently: !0 });
488
+ if (i)
390
489
  try {
391
- l.drawImage(e, 0, 0);
392
- const a = l.getImageData(0, 0, n, r);
393
- this.alpha = St(a.data, n * r), this.width = n, this.height = r, this.bounds = Tt(this.alpha, n, r, this.threshold), this.contour = jt(this.alpha, n, r, this.threshold);
490
+ i.drawImage(r, 0, 0);
491
+ const s = i.getImageData(0, 0, n, e);
492
+ this.alpha = Wt(s.data, n * e), this.width = n, this.height = e, this.bounds = zt(this.alpha, n, e, this.threshold), this.contour = Tt(this.alpha, n, e, this.threshold);
394
493
  } catch {
395
494
  this.alpha = new Uint8Array(0);
396
495
  }
@@ -410,50 +509,50 @@ class Pt {
410
509
  * @param nx - normalized x-coordinate (0-1, relative to the image width)
411
510
  * @param ny - normalized y-coordinate (0-1, relative to the image height)
412
511
  */
413
- hitTest(e, n) {
512
+ hitTest(r, n) {
414
513
  if (this.alpha.length === 0) return !1;
415
- const r = this.bounds;
416
- if (e < r.x || e > r.x + r.w || n < r.y || n > r.y + r.h) return !1;
417
- const i = Math.min(this.width - 1, Math.max(0, Math.floor(e * this.width))), l = Math.min(
514
+ const e = this.bounds;
515
+ if (r < e.x || r > e.x + e.w || n < e.y || n > e.y + e.h) return !1;
516
+ const c = Math.min(this.width - 1, Math.max(0, Math.floor(r * this.width))), i = Math.min(
418
517
  this.height - 1,
419
518
  Math.max(0, Math.floor(n * this.height))
420
519
  );
421
- return this.alpha[l * this.width + i] > this.threshold;
520
+ return this.alpha[i * this.width + c] > this.threshold;
422
521
  }
423
522
  }
424
- class Mt {
523
+ class Lt {
425
524
  id;
426
525
  bounds;
427
- constructor(e) {
428
- this.id = e.id, this.bounds = { ...e.bounds };
526
+ constructor(r) {
527
+ this.id = r.id, this.bounds = { ...r.bounds };
429
528
  }
430
- hitTest(e, n) {
431
- const r = this.bounds;
432
- return e >= r.x && e <= r.x + r.w && n >= r.y && n <= r.y + r.h;
529
+ hitTest(r, n) {
530
+ const e = this.bounds;
531
+ return r >= e.x && r <= e.x + e.w && n >= e.y && n <= e.y + e.h;
433
532
  }
434
533
  }
435
- function $t(t, e, n) {
436
- let r = !1;
437
- for (let i = 0, l = n.length - 1; i < n.length; l = i++) {
438
- const a = n[i][0], s = n[i][1], u = n[l][0], c = n[l][1];
439
- s > e != c > e && t < (u - a) * (e - s) / (c - s) + a && (r = !r);
534
+ function Yt(t, r, n) {
535
+ let e = !1;
536
+ for (let c = 0, i = n.length - 1; c < n.length; i = c++) {
537
+ const s = n[c][0], o = n[c][1], l = n[i][0], u = n[i][1];
538
+ o > r != u > r && t < (l - s) * (r - o) / (u - o) + s && (e = !e);
440
539
  }
441
- return r;
540
+ return e;
442
541
  }
443
- class Dt {
542
+ class Nt {
444
543
  id;
445
544
  bounds;
446
545
  points;
447
- constructor(e) {
448
- this.id = e.id, this.points = e.points;
449
- let n = 1 / 0, r = 1 / 0, i = -1 / 0, l = -1 / 0;
450
- for (const [a, s] of e.points)
451
- a < n && (n = a), a > i && (i = a), s < r && (r = s), s > l && (l = s);
546
+ constructor(r) {
547
+ this.id = r.id, this.points = r.points;
548
+ let n = 1 / 0, e = 1 / 0, c = -1 / 0, i = -1 / 0;
549
+ for (const [s, o] of r.points)
550
+ s < n && (n = s), s > c && (c = s), o < e && (e = o), o > i && (i = o);
452
551
  this.bounds = {
453
552
  x: n,
454
- y: r,
455
- w: i - n,
456
- h: l - r
553
+ y: e,
554
+ w: c - n,
555
+ h: i - e
457
556
  };
458
557
  }
459
558
  /**
@@ -468,22 +567,47 @@ class Dt {
468
567
  * @param nx - normalized x-coordinate (0-1, relative to the image width)
469
568
  * @param ny - normalized y-coordinate (0-1, relative to the image height)
470
569
  */
471
- hitTest(e, n) {
472
- const r = this.bounds;
473
- return e < r.x || e > r.x + r.w || n < r.y || n > r.y + r.h ? !1 : $t(e, n, this.points);
570
+ hitTest(r, n) {
571
+ const e = this.bounds;
572
+ return r < e.x || r > e.x + e.w || n < e.y || n > e.y + e.h ? !1 : Yt(r, n, this.points);
573
+ }
574
+ }
575
+ class Vt {
576
+ id;
577
+ bounds;
578
+ cx;
579
+ cy;
580
+ rx;
581
+ ry;
582
+ constructor(r, n = 1, e = 1) {
583
+ this.id = r.id, this.cx = r.center.x, this.cy = r.center.y;
584
+ const c = Math.max(1, n), i = Math.max(1, e), s = Math.min(c, i);
585
+ this.rx = r.radius * s / c, this.ry = r.radius * s / i, this.bounds = {
586
+ x: r.center.x - this.rx,
587
+ y: r.center.y - this.ry,
588
+ w: this.rx * 2,
589
+ h: this.ry * 2
590
+ };
591
+ }
592
+ hitTest(r, n) {
593
+ if (this.rx <= 0 || this.ry <= 0) return !1;
594
+ const e = (r - this.cx) / this.rx, c = (n - this.cy) / this.ry;
595
+ return e * e + c * c <= 1;
474
596
  }
475
597
  }
476
- function Wt(t, e) {
598
+ function Bt(t, r, n) {
477
599
  switch (t.type) {
478
600
  case "image":
479
- return new Pt(t, e);
601
+ return new Ot(t, r);
480
602
  case "bbox":
481
- return new Mt(t);
603
+ return new Lt(t);
482
604
  case "polygon":
483
- return new Dt(t);
605
+ return new Nt(t);
606
+ case "circle":
607
+ return new Vt(t, n?.viewportWidth, n?.viewportHeight);
484
608
  }
485
609
  }
486
- function Ot(t) {
610
+ function Ht(t) {
487
611
  switch (t.type) {
488
612
  case "image":
489
613
  return `${t.id}:image:${t.src}:${t.label ?? ""}`;
@@ -491,123 +615,142 @@ function Ot(t) {
491
615
  return `${t.id}:bbox:${t.bounds.x},${t.bounds.y},${t.bounds.w},${t.bounds.h}:${t.label ?? ""}`;
492
616
  case "polygon":
493
617
  return `${t.id}:polygon:${t.points.flat().join(",")}:${t.label ?? ""}`;
618
+ case "circle":
619
+ return `${t.id}:circle:${t.center.x},${t.center.y},${t.radius}:${t.label ?? ""}`;
494
620
  }
495
621
  }
496
- function Nt(t, e = !0, n = 30, r = 150) {
497
- const [i, l] = L(null), [a, s] = L(null), u = B(null), c = B([]), [d, k] = L({}), [p, g] = L({}), m = Math.min(255, Math.max(0, n)), v = B(null), f = P(() => {
498
- v.current === null && (v.current = setTimeout(() => {
499
- v.current = null, l(null);
500
- }, r));
501
- }, [r]), b = P(() => {
502
- v.current !== null && (clearTimeout(v.current), v.current = null);
503
- }, []), h = t.map(Ot).join("|"), E = F(() => t, [h]);
504
- O(() => {
505
- if (!e) {
506
- c.current = [];
622
+ function Ft(t, r = !0, n = 30, e = 150) {
623
+ const [c, i] = O(null), [s, o] = O(null), l = N(null), u = N([]), [p, m] = O({}), [v, x] = O({ width: 1, height: 1 }), [g, y] = O({}), d = Math.min(255, Math.max(0, n)), h = N(null), f = M(() => {
624
+ h.current === null && (h.current = setTimeout(() => {
625
+ h.current = null, i(null);
626
+ }, e));
627
+ }, [e]), w = M(() => {
628
+ h.current !== null && (clearTimeout(h.current), h.current = null);
629
+ }, []), k = t.map(Ht).join("|"), b = V(() => t, [k]);
630
+ W(() => {
631
+ const S = l.current;
632
+ if (!S) return;
633
+ const R = () => {
634
+ const I = S.getBoundingClientRect();
635
+ x({
636
+ width: Math.max(1, I.width),
637
+ height: Math.max(1, I.height)
638
+ });
639
+ };
640
+ R();
641
+ const P = new ResizeObserver(R);
642
+ return P.observe(S), () => P.disconnect();
643
+ }, []), W(() => {
644
+ if (!r) {
645
+ u.current = [];
507
646
  return;
508
647
  }
509
- let j = !1, R = [];
510
- async function C() {
511
- const _ = [], M = {}, W = {};
512
- for (const Y of E) {
513
- const D = Wt(Y, m);
514
- if (D.prepare && await D.prepare(), j) return;
515
- _.push(D), M[D.id] = D.bounds, D.contour && D.contour.length >= 3 && (W[D.id] = D.contour);
648
+ let S = !1, R = [];
649
+ async function P() {
650
+ const I = [], z = {}, L = {};
651
+ for (const G of b) {
652
+ const a = Bt(G, d, {
653
+ viewportWidth: v.width,
654
+ viewportHeight: v.height
655
+ });
656
+ if (a.prepare && await a.prepare(), S) return;
657
+ I.push(a), z[a.id] = a.bounds, a.contour && a.contour.length >= 3 && (L[a.id] = a.contour);
516
658
  }
517
- j || (R = _, c.current = _, k(M), g(W));
659
+ S || (R = I, u.current = I, m(z), y(L));
518
660
  }
519
- return C(), () => {
520
- j = !0;
521
- for (const _ of R)
522
- _.dispose?.();
661
+ return P(), () => {
662
+ S = !0;
663
+ for (const I of R)
664
+ I.dispose?.();
523
665
  };
524
- }, [E, e, m]);
525
- const w = P(
526
- (j, R) => {
527
- const C = c.current;
528
- for (let _ = C.length - 1; _ >= 0; _--)
529
- if (C[_].hitTest(j, R))
530
- return C[_].id;
666
+ }, [b, r, d, v.width, v.height]);
667
+ const A = M(
668
+ (S, R) => {
669
+ const P = u.current;
670
+ for (let I = P.length - 1; I >= 0; I--)
671
+ if (P[I].hitTest(S, R))
672
+ return P[I].id;
531
673
  return null;
532
674
  },
533
675
  []
534
- ), x = P(
535
- (j) => {
536
- const R = u.current;
676
+ ), _ = M(
677
+ (S) => {
678
+ const R = l.current;
537
679
  if (!R) return null;
538
- const C = R.getBoundingClientRect(), _ = (j.clientX - C.left) / C.width, M = (j.clientY - C.top) / C.height;
539
- return _ < 0 || _ > 1 || M < 0 || M > 1 ? null : { nx: _, ny: M };
680
+ const P = R.getBoundingClientRect(), I = (S.clientX - P.left) / P.width, z = (S.clientY - P.top) / P.height;
681
+ return I < 0 || I > 1 || z < 0 || z > 1 ? null : { nx: I, ny: z };
540
682
  },
541
683
  []
542
- ), $ = P(
543
- (j) => {
544
- if (!e) return;
545
- const R = x(j);
684
+ ), X = M(
685
+ (S) => {
686
+ if (!r) return;
687
+ const R = _(S);
546
688
  if (!R) {
547
689
  f();
548
690
  return;
549
691
  }
550
- const C = w(R.nx, R.ny);
551
- if (C === null) {
552
- if (j.target?.closest('[data-cutout-overlay="true"]')) {
553
- b();
692
+ const P = A(R.nx, R.ny);
693
+ if (P === null) {
694
+ if (S.target?.closest('[data-cutout-overlay="true"]')) {
695
+ w();
554
696
  return;
555
697
  }
556
698
  f();
557
699
  return;
558
700
  }
559
- b(), l(C);
701
+ w(), i(P);
560
702
  },
561
- [e, x, w, f, b]
562
- ), N = P(() => {
703
+ [r, _, A, f, w]
704
+ ), D = M(() => {
563
705
  f();
564
- }, [f]), H = P(
565
- (j) => {
566
- if (!e) return;
567
- const R = x(j);
706
+ }, [f]), U = M(
707
+ (S) => {
708
+ if (!r) return;
709
+ const R = _(S);
568
710
  if (!R) {
569
- s(null);
711
+ o(null);
570
712
  return;
571
713
  }
572
- const C = w(R.nx, R.ny);
573
- s(C === a || C === null ? null : C);
714
+ const P = A(R.nx, R.ny);
715
+ o(P === s || P === null ? null : P);
574
716
  },
575
- [e, x, w, a]
576
- ), V = a ?? i, q = e ? d : {}, X = e ? p : {};
577
- return O(() => () => {
578
- b();
579
- }, [b]), {
580
- hoveredId: i,
581
- selectedId: a,
582
- activeId: V,
583
- boundsMap: q,
584
- contourMap: X,
585
- containerRef: u,
717
+ [r, _, A, s]
718
+ ), Q = s ?? c, B = r ? p : {}, q = r ? g : {};
719
+ return W(() => () => {
720
+ w();
721
+ }, [w]), {
722
+ hoveredId: c,
723
+ selectedId: s,
724
+ activeId: Q,
725
+ viewportSize: v,
726
+ boundsMap: B,
727
+ contourMap: q,
728
+ containerRef: l,
586
729
  containerProps: {
587
- onPointerMove: $,
588
- onPointerLeave: N,
589
- onClick: H
730
+ onPointerMove: X,
731
+ onPointerLeave: D,
732
+ onClick: U
590
733
  }
591
734
  };
592
735
  }
593
- function vt(t, e) {
594
- return { name: t, css: e };
736
+ function bt(t, r) {
737
+ return { name: t, css: r };
595
738
  }
596
- const ht = /* @__PURE__ */ new Set();
597
- function Yt(t) {
739
+ const gt = /* @__PURE__ */ new Set();
740
+ function Xt(t) {
598
741
  if (!(!t.keyframes?.length || typeof document > "u"))
599
- for (const e of t.keyframes) {
600
- if (ht.has(e.name)) continue;
601
- ht.add(e.name);
742
+ for (const r of t.keyframes) {
743
+ if (gt.has(r.name)) continue;
744
+ gt.add(r.name);
602
745
  const n = document.createElement("style");
603
- n.setAttribute("data-ricut-kf", e.name), n.textContent = `@keyframes ${e.name} {
604
- ${e.css}
746
+ n.setAttribute("data-ricut-kf", r.name), n.textContent = `@keyframes ${r.name} {
747
+ ${r.css}
605
748
  }`, document.head.appendChild(n);
606
749
  }
607
750
  }
608
- const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
751
+ const rt = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ut = {
609
752
  name: "elevate",
610
- transition: Z,
753
+ transition: rt,
611
754
  mainImageHovered: {
612
755
  filter: "brightness(0.45) saturate(0.7)"
613
756
  },
@@ -632,7 +775,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
632
775
  geometryActive: {
633
776
  fill: "rgba(130, 190, 255, 0.2)",
634
777
  stroke: "rgba(130, 190, 255, 0.9)",
635
- strokeWidth: 2,
778
+ strokeWidth: 0,
636
779
  glow: "0 0 24px rgba(130, 190, 255, 0.5), 0 0 56px rgba(130, 190, 255, 0.2), 0 12px 40px rgba(0, 0, 0, 0.4)"
637
780
  },
638
781
  geometryInactive: {
@@ -645,9 +788,9 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
645
788
  stroke: "transparent",
646
789
  strokeWidth: 1
647
790
  }
648
- }, Lt = {
791
+ }, qt = {
649
792
  name: "glow",
650
- transition: Z,
793
+ transition: rt,
651
794
  mainImageHovered: {
652
795
  filter: "brightness(0.55) saturate(0.8)"
653
796
  },
@@ -672,7 +815,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
672
815
  geometryActive: {
673
816
  fill: "rgba(255, 200, 100, 0.15)",
674
817
  stroke: "rgba(255, 200, 100, 0.85)",
675
- strokeWidth: 2,
818
+ strokeWidth: 0,
676
819
  glow: "0 0 20px rgba(255, 200, 100, 0.5), 0 0 56px rgba(255, 200, 100, 0.2)"
677
820
  },
678
821
  geometryInactive: {
@@ -685,9 +828,9 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
685
828
  stroke: "transparent",
686
829
  strokeWidth: 1
687
830
  }
688
- }, Bt = {
831
+ }, Gt = {
689
832
  name: "lift",
690
- transition: Z,
833
+ transition: rt,
691
834
  mainImageHovered: {
692
835
  filter: "brightness(0.4)"
693
836
  },
@@ -712,7 +855,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
712
855
  geometryActive: {
713
856
  fill: "rgba(255, 255, 255, 0.1)",
714
857
  stroke: "rgba(255, 255, 255, 0.7)",
715
- strokeWidth: 2,
858
+ strokeWidth: 0,
716
859
  glow: "0 20px 56px rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 255, 255, 0.1)"
717
860
  },
718
861
  geometryInactive: {
@@ -725,7 +868,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
725
868
  stroke: "transparent",
726
869
  strokeWidth: 1
727
870
  }
728
- }, Ft = {
871
+ }, Kt = {
729
872
  name: "subtle",
730
873
  transition: "all 0.3s ease",
731
874
  mainImageHovered: {
@@ -752,7 +895,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
752
895
  geometryActive: {
753
896
  fill: "rgba(255, 255, 255, 0.08)",
754
897
  stroke: "rgba(255, 255, 255, 0.5)",
755
- strokeWidth: 1
898
+ strokeWidth: 0
756
899
  },
757
900
  geometryInactive: {
758
901
  fill: "transparent",
@@ -764,14 +907,14 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
764
907
  stroke: "transparent",
765
908
  strokeWidth: 1
766
909
  }
767
- }, gt = vt(
910
+ }, pt = bt(
768
911
  "_ricut-trace-stroke",
769
912
  `from { stroke-dashoffset: 0; }
770
913
  to { stroke-dashoffset: -1; }`
771
- ), zt = {
914
+ ), Jt = {
772
915
  name: "trace",
773
- transition: Z,
774
- keyframes: [gt],
916
+ transition: rt,
917
+ keyframes: [pt],
775
918
  mainImageHovered: {
776
919
  filter: "brightness(0.35) saturate(0.5)"
777
920
  },
@@ -796,9 +939,9 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
796
939
  geometryActive: {
797
940
  fill: "rgba(255, 255, 255, 0.03)",
798
941
  stroke: "rgba(255, 255, 255, 0.9)",
799
- strokeWidth: 2.5,
942
+ strokeWidth: 2,
800
943
  strokeDasharray: "0.15 0.85",
801
- animation: `${gt.name} 3s linear infinite`,
944
+ animation: `${pt.name} 3s linear infinite`,
802
945
  glow: "0 0 10px rgba(255, 255, 255, 0.25)"
803
946
  },
804
947
  geometryInactive: {
@@ -811,7 +954,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
811
954
  stroke: "transparent",
812
955
  strokeWidth: 1
813
956
  }
814
- }, pt = vt(
957
+ }, yt = bt(
815
958
  "_ricut-shimmer",
816
959
  `0%, 100% {
817
960
  filter: brightness(1.05) contrast(1.02)
@@ -828,10 +971,10 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
828
971
  drop-shadow(0 0 6px rgba(255, 255, 255, 0.12))
829
972
  drop-shadow(0 12px 32px rgba(0, 0, 0, 0.4));
830
973
  }`
831
- ), Ht = {
974
+ ), Zt = {
832
975
  name: "shimmer",
833
- transition: Z,
834
- keyframes: [pt],
976
+ transition: rt,
977
+ keyframes: [yt],
835
978
  mainImageHovered: {
836
979
  filter: "brightness(0.35) saturate(0.6)"
837
980
  },
@@ -844,7 +987,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
844
987
  we set it here so there's a graceful look before the first frame. */
845
988
  filter: "brightness(1.05) contrast(1.02) drop-shadow(0 0 6px rgba(255,255,255,0.12)) drop-shadow(0 12px 32px rgba(0,0,0,0.4))",
846
989
  opacity: 1,
847
- animation: `${pt.name} 2.4s ease-in-out infinite`
990
+ animation: `${yt.name} 2.4s ease-in-out infinite`
848
991
  },
849
992
  cutoutInactive: {
850
993
  transform: "scale(1)",
@@ -859,7 +1002,7 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
859
1002
  geometryActive: {
860
1003
  fill: "rgba(255, 255, 255, 0.1)",
861
1004
  stroke: "rgba(255, 255, 255, 0.7)",
862
- strokeWidth: 2,
1005
+ strokeWidth: 0,
863
1006
  glow: "0 0 14px rgba(255, 255, 255, 0.35), 0 12px 32px rgba(0, 0, 0, 0.4)"
864
1007
  },
865
1008
  geometryInactive: {
@@ -872,48 +1015,52 @@ const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
872
1015
  stroke: "transparent",
873
1016
  strokeWidth: 1
874
1017
  }
875
- }, K = {
876
- elevate: Vt,
877
- glow: Lt,
878
- lift: Bt,
879
- subtle: Ft,
880
- trace: zt,
881
- shimmer: Ht
882
- }, Q = lt(null), xt = lt(null);
883
- function ot() {
884
- const t = z(xt);
1018
+ }, J = {
1019
+ elevate: Ut,
1020
+ glow: qt,
1021
+ lift: Gt,
1022
+ subtle: Kt,
1023
+ trace: Jt,
1024
+ shimmer: Zt
1025
+ }, H = lt(null), kt = lt(null);
1026
+ function nt() {
1027
+ const t = Y(kt);
885
1028
  if (!t) throw new Error("Must be used inside <CutoutViewer>");
886
1029
  return t;
887
1030
  }
888
- const tt = lt(null);
889
- function ee() {
890
- const t = z(tt);
1031
+ const Z = lt(null);
1032
+ function de() {
1033
+ const t = Y(Z);
891
1034
  if (!t)
892
1035
  throw new Error("useCutout must be used inside <CutoutViewer.Cutout>");
893
1036
  return t;
894
1037
  }
895
- function Xt({ id: t, src: e, label: n, effect: r, children: i, renderLayer: l }) {
896
- const a = z(Q), s = ot();
897
- if (!a)
1038
+ function Qt({ id: t, src: r, label: n, effect: e, children: c, renderLayer: i }) {
1039
+ const s = Y(H), o = nt();
1040
+ if (!s)
898
1041
  throw new Error("<CutoutViewer.Cutout> must be used inside <CutoutViewer>");
899
- O(() => (a.registerCutout({ type: "image", id: t, src: e, label: n }), () => a.unregisterCutout(t)), [t, e, n, a]);
900
- const u = r ? typeof r == "string" ? K[r] ?? s.effect : r : s.effect, c = s.contourMap[t] ?? null, d = s.activeId === t, k = s.hoveredId === t, p = s.selectedId === t, g = { x: 0, y: 0, w: 1, h: 1 }, m = s.boundsMap[t] ?? g;
901
- let v, f;
902
- !s.enabled || !s.isAnyActive && !s.showAll ? (v = u.cutoutIdle, f = u.geometryIdle) : s.showAll || d ? (v = u.cutoutActive, f = u.geometryActive) : (v = u.cutoutInactive, f = u.geometryInactive);
903
- const b = F(
1042
+ W(() => (s.registerCutout({ type: "image", id: t, src: r, label: n }), () => s.unregisterCutout(t)), [t, r, n, s]);
1043
+ const l = e ? typeof e == "string" ? J[e] ?? o.effect : e : o.effect, u = o.contourMap[t] ?? null, p = V(() => {
1044
+ if (!u) return null;
1045
+ const w = o.viewportSize.width || 1, k = o.viewportSize.height || 1, b = u.map(([A, _]) => [A * w, _ * k]);
1046
+ return Dt(b);
1047
+ }, [u, o.viewportSize.width, o.viewportSize.height]), m = o.activeId === t, v = o.hoveredId === t, x = o.selectedId === t, g = { x: 0, y: 0, w: 1, h: 1 }, y = o.boundsMap[t] ?? g;
1048
+ let d, h;
1049
+ !o.enabled || !o.isAnyActive && !o.showAll ? (d = l.cutoutIdle, h = l.geometryIdle) : o.showAll || m ? (d = l.cutoutActive, h = l.geometryActive) : (d = l.cutoutInactive, h = l.geometryInactive);
1050
+ const f = V(
904
1051
  () => ({
905
1052
  id: t,
906
1053
  label: n,
907
- bounds: m,
908
- isActive: d,
909
- isHovered: k,
910
- isSelected: p,
911
- effect: u
1054
+ bounds: y,
1055
+ isActive: m,
1056
+ isHovered: v,
1057
+ isSelected: x,
1058
+ effect: l
912
1059
  }),
913
- [t, n, m, d, k, p, u]
1060
+ [t, n, y, m, v, x, l]
914
1061
  );
915
- return /* @__PURE__ */ I.jsxs(tt.Provider, { value: b, children: [
916
- /* @__PURE__ */ I.jsxs(
1062
+ return /* @__PURE__ */ C.jsxs(Z.Provider, { value: f, children: [
1063
+ /* @__PURE__ */ C.jsxs(
917
1064
  "div",
918
1065
  {
919
1066
  "data-cutout-id": t,
@@ -921,15 +1068,15 @@ function Xt({ id: t, src: e, label: n, effect: r, children: i, renderLayer: l })
921
1068
  pointerEvents: "none",
922
1069
  position: "absolute",
923
1070
  inset: 0,
924
- zIndex: d ? 20 : 10,
925
- transition: u.transition,
926
- ...v
1071
+ zIndex: m ? 20 : 10,
1072
+ transition: l.transition,
1073
+ ...d
927
1074
  },
928
1075
  children: [
929
- l ? l({ isActive: d, isHovered: k, isSelected: p, bounds: m, effect: u }) : /* @__PURE__ */ I.jsx(
1076
+ i ? i({ isActive: m, isHovered: v, isSelected: x, bounds: y, effect: l }) : /* @__PURE__ */ C.jsx(
930
1077
  "img",
931
1078
  {
932
- src: e,
1079
+ src: r,
933
1080
  alt: n || t,
934
1081
  draggable: !1,
935
1082
  style: {
@@ -940,10 +1087,10 @@ function Xt({ id: t, src: e, label: n, effect: r, children: i, renderLayer: l })
940
1087
  }
941
1088
  }
942
1089
  ),
943
- c && f && /* @__PURE__ */ I.jsx(
1090
+ p && h && /* @__PURE__ */ C.jsx(
944
1091
  "svg",
945
1092
  {
946
- viewBox: "0 0 1 1",
1093
+ viewBox: `0 0 ${o.viewportSize.width || 1} ${o.viewportSize.height || 1}`,
947
1094
  preserveAspectRatio: "none",
948
1095
  style: {
949
1096
  position: "absolute",
@@ -951,22 +1098,22 @@ function Xt({ id: t, src: e, label: n, effect: r, children: i, renderLayer: l })
951
1098
  width: "100%",
952
1099
  height: "100%",
953
1100
  overflow: "visible",
954
- filter: f.glow ? `drop-shadow(${f.glow.split(",")[0]?.trim() ?? ""})` : "none"
1101
+ filter: h.glow ? `drop-shadow(${h.glow.split(",")[0]?.trim() ?? ""})` : "none"
955
1102
  },
956
- children: /* @__PURE__ */ I.jsx(
957
- "polygon",
1103
+ children: /* @__PURE__ */ C.jsx(
1104
+ "path",
958
1105
  {
959
- points: c.map(([h, E]) => `${h},${E}`).join(" "),
960
- fill: f.fill,
961
- stroke: f.stroke,
962
- strokeWidth: (f.strokeWidth ?? 2) * 15e-4,
1106
+ d: p,
1107
+ fill: h.fill,
1108
+ stroke: h.stroke,
1109
+ strokeWidth: h.strokeWidth ?? 2,
963
1110
  strokeLinejoin: "round",
964
- strokeLinecap: f.strokeDasharray ? "round" : void 0,
965
- strokeDasharray: f.strokeDasharray,
966
- pathLength: f.strokeDasharray ? 1 : void 0,
1111
+ strokeLinecap: h.strokeDasharray ? "round" : void 0,
1112
+ strokeDasharray: h.strokeDasharray,
1113
+ pathLength: h.strokeDasharray ? 1 : void 0,
967
1114
  style: {
968
- transition: u.transition,
969
- animation: f.animation
1115
+ transition: l.transition,
1116
+ animation: h.animation
970
1117
  }
971
1118
  }
972
1119
  )
@@ -975,49 +1122,49 @@ function Xt({ id: t, src: e, label: n, effect: r, children: i, renderLayer: l })
975
1122
  ]
976
1123
  }
977
1124
  ),
978
- i
1125
+ c
979
1126
  ] });
980
1127
  }
981
1128
  function mt(t) {
982
- const { filter: e, ...n } = t;
1129
+ const { filter: r, ...n } = t;
983
1130
  return n;
984
1131
  }
985
- function Ut({
1132
+ function te({
986
1133
  id: t,
987
- bounds: e,
1134
+ bounds: r,
988
1135
  label: n,
989
- effect: r,
990
- children: i,
991
- renderLayer: l
1136
+ effect: e,
1137
+ children: c,
1138
+ renderLayer: i
992
1139
  }) {
993
- const a = z(Q), s = ot();
994
- if (!a)
1140
+ const s = Y(H), o = nt();
1141
+ if (!s)
995
1142
  throw new Error(
996
1143
  "<CutoutViewer.BBoxCutout> must be used inside <CutoutViewer>"
997
1144
  );
998
- const { x: u, y: c, w: d, h: k } = e;
999
- O(() => (a.registerCutout({ type: "bbox", id: t, bounds: { x: u, y: c, w: d, h: k }, label: n }), () => a.unregisterCutout(t)), [t, u, c, d, k, n, a]);
1000
- const p = r ? typeof r == "string" ? K[r] ?? s.effect : r : s.effect, g = s.activeId === t, m = s.hoveredId === t, v = s.selectedId === t, f = { x: 0, y: 0, w: 1, h: 1 }, b = s.boundsMap[t] ?? f;
1001
- let h, E;
1002
- !s.enabled || !s.isAnyActive && !s.showAll ? (E = { ...p.cutoutIdle, filter: "none", opacity: 0 }, h = p.geometryIdle) : s.showAll || g ? (E = mt(p.cutoutActive), h = p.geometryActive) : (E = mt(p.cutoutInactive), h = p.geometryInactive);
1003
- const x = h ?? {
1145
+ const { x: l, y: u, w: p, h: m } = r;
1146
+ W(() => (s.registerCutout({ type: "bbox", id: t, bounds: { x: l, y: u, w: p, h: m }, label: n }), () => s.unregisterCutout(t)), [t, l, u, p, m, n, s]);
1147
+ const v = e ? typeof e == "string" ? J[e] ?? o.effect : e : o.effect, x = o.activeId === t, g = o.hoveredId === t, y = o.selectedId === t, d = { x: 0, y: 0, w: 1, h: 1 }, h = o.boundsMap[t] ?? d;
1148
+ let f, w;
1149
+ !o.enabled || !o.isAnyActive && !o.showAll ? (w = { ...v.cutoutIdle, filter: "none", opacity: 0 }, f = v.geometryIdle) : o.showAll || x ? (w = mt(v.cutoutActive), f = v.geometryActive) : (w = mt(v.cutoutInactive), f = v.geometryInactive);
1150
+ const b = f ?? {
1004
1151
  fill: "rgba(37, 99, 235, 0.15)",
1005
1152
  stroke: "rgba(37, 99, 235, 0.6)",
1006
1153
  strokeWidth: 2
1007
- }, $ = F(
1154
+ }, A = V(
1008
1155
  () => ({
1009
1156
  id: t,
1010
1157
  label: n,
1011
- bounds: b,
1012
- isActive: g,
1013
- isHovered: m,
1014
- isSelected: v,
1015
- effect: p
1158
+ bounds: h,
1159
+ isActive: x,
1160
+ isHovered: g,
1161
+ isSelected: y,
1162
+ effect: v
1016
1163
  }),
1017
- [t, n, b, g, m, v, p]
1164
+ [t, n, h, x, g, y, v]
1018
1165
  );
1019
- return /* @__PURE__ */ I.jsxs(tt.Provider, { value: $, children: [
1020
- /* @__PURE__ */ I.jsx(
1166
+ return /* @__PURE__ */ C.jsxs(Z.Provider, { value: A, children: [
1167
+ /* @__PURE__ */ C.jsx(
1021
1168
  "div",
1022
1169
  {
1023
1170
  "data-cutout-id": t,
@@ -1025,11 +1172,11 @@ function Ut({
1025
1172
  pointerEvents: "none",
1026
1173
  position: "absolute",
1027
1174
  inset: 0,
1028
- zIndex: g ? 20 : 10,
1029
- transition: p.transition,
1030
- ...E
1175
+ zIndex: x ? 20 : 10,
1176
+ transition: v.transition,
1177
+ ...w
1031
1178
  },
1032
- children: l ? l({ isActive: g, isHovered: m, isSelected: v, bounds: b, effect: p }) : /* @__PURE__ */ I.jsx(
1179
+ children: i ? i({ isActive: x, isHovered: g, isSelected: y, bounds: h, effect: v }) : /* @__PURE__ */ C.jsx(
1033
1180
  "svg",
1034
1181
  {
1035
1182
  viewBox: "0 0 1 1",
@@ -1040,25 +1187,25 @@ function Ut({
1040
1187
  width: "100%",
1041
1188
  height: "100%",
1042
1189
  overflow: "visible",
1043
- filter: x.glow ? `drop-shadow(${x.glow.split(",")[0]?.trim() ?? ""})` : "none"
1190
+ filter: b.glow ? `drop-shadow(${b.glow.split(",")[0]?.trim() ?? ""})` : "none"
1044
1191
  },
1045
- children: /* @__PURE__ */ I.jsx(
1192
+ children: /* @__PURE__ */ C.jsx(
1046
1193
  "rect",
1047
1194
  {
1048
- x: b.x,
1049
- y: b.y,
1050
- width: b.w,
1051
- height: b.h,
1195
+ x: h.x,
1196
+ y: h.y,
1197
+ width: h.w,
1198
+ height: h.h,
1052
1199
  rx: 4e-3,
1053
- fill: x.fill,
1054
- stroke: x.stroke,
1055
- strokeWidth: (x.strokeWidth ?? 2) * 15e-4,
1056
- strokeLinecap: x.strokeDasharray ? "round" : void 0,
1057
- strokeDasharray: x.strokeDasharray,
1058
- pathLength: x.strokeDasharray ? 1 : void 0,
1200
+ fill: b.fill,
1201
+ stroke: b.stroke,
1202
+ strokeWidth: (b.strokeWidth ?? 2) * 15e-4,
1203
+ strokeLinecap: b.strokeDasharray ? "round" : void 0,
1204
+ strokeDasharray: b.strokeDasharray,
1205
+ pathLength: b.strokeDasharray ? 1 : void 0,
1059
1206
  style: {
1060
- transition: p.transition,
1061
- animation: x.animation
1207
+ transition: v.transition,
1208
+ animation: b.animation
1062
1209
  }
1063
1210
  }
1064
1211
  )
@@ -1066,49 +1213,49 @@ function Ut({
1066
1213
  )
1067
1214
  }
1068
1215
  ),
1069
- i
1216
+ c
1070
1217
  ] });
1071
1218
  }
1072
- function yt(t) {
1073
- const { filter: e, ...n } = t;
1219
+ function vt(t) {
1220
+ const { filter: r, ...n } = t;
1074
1221
  return n;
1075
1222
  }
1076
- function qt({
1223
+ function ee({
1077
1224
  id: t,
1078
- points: e,
1225
+ points: r,
1079
1226
  label: n,
1080
- effect: r,
1081
- children: i,
1082
- renderLayer: l
1227
+ effect: e,
1228
+ children: c,
1229
+ renderLayer: i
1083
1230
  }) {
1084
- const a = z(Q), s = ot();
1085
- if (!a)
1231
+ const s = Y(H), o = nt();
1232
+ if (!s)
1086
1233
  throw new Error(
1087
1234
  "<CutoutViewer.PolygonCutout> must be used inside <CutoutViewer>"
1088
1235
  );
1089
- const u = e.flat().join(",");
1090
- O(() => (a.registerCutout({ type: "polygon", id: t, points: e, label: n }), () => a.unregisterCutout(t)), [t, u, n, a]);
1091
- const c = r ? typeof r == "string" ? K[r] ?? s.effect : r : s.effect, d = s.activeId === t, k = s.hoveredId === t, p = s.selectedId === t, g = { x: 0, y: 0, w: 1, h: 1 }, m = s.boundsMap[t] ?? g;
1092
- let v, f;
1093
- !s.enabled || !s.isAnyActive && !s.showAll ? (f = { ...c.cutoutIdle, filter: "none", opacity: 0 }, v = c.geometryIdle) : s.showAll || d ? (f = yt(c.cutoutActive), v = c.geometryActive) : (f = yt(c.cutoutInactive), v = c.geometryInactive);
1094
- const h = v ?? {
1236
+ const l = r.flat().join(",");
1237
+ W(() => (s.registerCutout({ type: "polygon", id: t, points: r, label: n }), () => s.unregisterCutout(t)), [t, l, n, s]);
1238
+ const u = e ? typeof e == "string" ? J[e] ?? o.effect : e : o.effect, p = o.activeId === t, m = o.hoveredId === t, v = o.selectedId === t, x = { x: 0, y: 0, w: 1, h: 1 }, g = o.boundsMap[t] ?? x;
1239
+ let y, d;
1240
+ !o.enabled || !o.isAnyActive && !o.showAll ? (d = { ...u.cutoutIdle, filter: "none", opacity: 0 }, y = u.geometryIdle) : o.showAll || p ? (d = vt(u.cutoutActive), y = u.geometryActive) : (d = vt(u.cutoutInactive), y = u.geometryInactive);
1241
+ const f = y ?? {
1095
1242
  fill: "rgba(37, 99, 235, 0.15)",
1096
1243
  stroke: "rgba(37, 99, 235, 0.6)",
1097
1244
  strokeWidth: 2
1098
- }, E = F(
1245
+ }, w = V(
1099
1246
  () => ({
1100
1247
  id: t,
1101
1248
  label: n,
1102
- bounds: m,
1103
- isActive: d,
1104
- isHovered: k,
1105
- isSelected: p,
1106
- effect: c
1249
+ bounds: g,
1250
+ isActive: p,
1251
+ isHovered: m,
1252
+ isSelected: v,
1253
+ effect: u
1107
1254
  }),
1108
- [t, n, m, d, k, p, c]
1255
+ [t, n, g, p, m, v, u]
1109
1256
  );
1110
- return /* @__PURE__ */ I.jsxs(tt.Provider, { value: E, children: [
1111
- /* @__PURE__ */ I.jsx(
1257
+ return /* @__PURE__ */ C.jsxs(Z.Provider, { value: w, children: [
1258
+ /* @__PURE__ */ C.jsx(
1112
1259
  "div",
1113
1260
  {
1114
1261
  "data-cutout-id": t,
@@ -1116,11 +1263,11 @@ function qt({
1116
1263
  pointerEvents: "none",
1117
1264
  position: "absolute",
1118
1265
  inset: 0,
1119
- zIndex: d ? 20 : 10,
1120
- transition: c.transition,
1121
- ...f
1266
+ zIndex: p ? 20 : 10,
1267
+ transition: u.transition,
1268
+ ...d
1122
1269
  },
1123
- children: l ? l({ isActive: d, isHovered: k, isSelected: p, bounds: m, effect: c }) : /* @__PURE__ */ I.jsx(
1270
+ children: i ? i({ isActive: p, isHovered: m, isSelected: v, bounds: g, effect: u }) : /* @__PURE__ */ C.jsx(
1124
1271
  "svg",
1125
1272
  {
1126
1273
  viewBox: "0 0 1 1",
@@ -1131,22 +1278,113 @@ function qt({
1131
1278
  width: "100%",
1132
1279
  height: "100%",
1133
1280
  overflow: "visible",
1134
- filter: h.glow ? `drop-shadow(${h.glow.split(",")[0]?.trim() ?? ""})` : "none"
1281
+ filter: f.glow ? `drop-shadow(${f.glow.split(",")[0]?.trim() ?? ""})` : "none"
1135
1282
  },
1136
- children: /* @__PURE__ */ I.jsx(
1283
+ children: /* @__PURE__ */ C.jsx(
1137
1284
  "polygon",
1138
1285
  {
1139
- points: e.map(([w, x]) => `${w},${x}`).join(" "),
1140
- fill: h.fill,
1141
- stroke: h.stroke,
1142
- strokeWidth: (h.strokeWidth ?? 2) * 15e-4,
1286
+ points: r.map(([k, b]) => `${k},${b}`).join(" "),
1287
+ fill: f.fill,
1288
+ stroke: f.stroke,
1289
+ strokeWidth: (f.strokeWidth ?? 2) * 15e-4,
1143
1290
  strokeLinejoin: "round",
1144
- strokeLinecap: h.strokeDasharray ? "round" : void 0,
1145
- strokeDasharray: h.strokeDasharray,
1146
- pathLength: h.strokeDasharray ? 1 : void 0,
1291
+ strokeLinecap: f.strokeDasharray ? "round" : void 0,
1292
+ strokeDasharray: f.strokeDasharray,
1293
+ pathLength: f.strokeDasharray ? 1 : void 0,
1294
+ style: {
1295
+ transition: u.transition,
1296
+ animation: f.animation
1297
+ }
1298
+ }
1299
+ )
1300
+ }
1301
+ )
1302
+ }
1303
+ ),
1304
+ c
1305
+ ] });
1306
+ }
1307
+ function wt(t) {
1308
+ const { filter: r, ...n } = t;
1309
+ return n;
1310
+ }
1311
+ function re({
1312
+ id: t,
1313
+ center: r,
1314
+ radius: n,
1315
+ label: e,
1316
+ effect: c,
1317
+ children: i,
1318
+ renderLayer: s
1319
+ }) {
1320
+ const o = Y(H), l = nt();
1321
+ if (!o)
1322
+ throw new Error(
1323
+ "<CutoutViewer.CircleCutout> must be used inside <CutoutViewer>"
1324
+ );
1325
+ const { x: u, y: p } = r;
1326
+ W(() => (o.registerCutout({ type: "circle", id: t, center: { x: u, y: p }, radius: n, label: e }), () => o.unregisterCutout(t)), [t, u, p, n, e, o]);
1327
+ const m = c ? typeof c == "string" ? J[c] ?? l.effect : c : l.effect, v = l.activeId === t, x = l.hoveredId === t, g = l.selectedId === t, y = { x: 0, y: 0, w: 1, h: 1 }, d = l.boundsMap[t] ?? y, h = Math.max(1, l.viewportSize.width), f = Math.max(1, l.viewportSize.height), w = Math.min(h, f), k = n * w / h, b = n * w / f;
1328
+ let A, _;
1329
+ !l.enabled || !l.isAnyActive && !l.showAll ? (_ = { ...m.cutoutIdle, filter: "none", opacity: 0 }, A = m.geometryIdle) : l.showAll || v ? (_ = wt(m.cutoutActive), A = m.geometryActive) : (_ = wt(m.cutoutInactive), A = m.geometryInactive);
1330
+ const D = A ?? {
1331
+ fill: "rgba(37, 99, 235, 0.15)",
1332
+ stroke: "rgba(37, 99, 235, 0.6)",
1333
+ strokeWidth: 2
1334
+ }, U = V(
1335
+ () => ({
1336
+ id: t,
1337
+ label: e,
1338
+ bounds: d,
1339
+ isActive: v,
1340
+ isHovered: x,
1341
+ isSelected: g,
1342
+ effect: m
1343
+ }),
1344
+ [t, e, d, v, x, g, m]
1345
+ );
1346
+ return /* @__PURE__ */ C.jsxs(Z.Provider, { value: U, children: [
1347
+ /* @__PURE__ */ C.jsx(
1348
+ "div",
1349
+ {
1350
+ "data-cutout-id": t,
1351
+ style: {
1352
+ pointerEvents: "none",
1353
+ position: "absolute",
1354
+ inset: 0,
1355
+ zIndex: v ? 20 : 10,
1356
+ transition: m.transition,
1357
+ ..._
1358
+ },
1359
+ children: s ? s({ isActive: v, isHovered: x, isSelected: g, bounds: d, effect: m }) : /* @__PURE__ */ C.jsx(
1360
+ "svg",
1361
+ {
1362
+ viewBox: "0 0 1 1",
1363
+ preserveAspectRatio: "none",
1364
+ style: {
1365
+ position: "absolute",
1366
+ inset: 0,
1367
+ width: "100%",
1368
+ height: "100%",
1369
+ overflow: "visible",
1370
+ filter: D.glow ? `drop-shadow(${D.glow.split(",")[0]?.trim() ?? ""})` : "none"
1371
+ },
1372
+ children: /* @__PURE__ */ C.jsx(
1373
+ "ellipse",
1374
+ {
1375
+ cx: r.x,
1376
+ cy: r.y,
1377
+ rx: k,
1378
+ ry: b,
1379
+ fill: D.fill,
1380
+ stroke: D.stroke,
1381
+ strokeWidth: (D.strokeWidth ?? 2) * 15e-4,
1382
+ strokeLinecap: D.strokeDasharray ? "round" : void 0,
1383
+ strokeDasharray: D.strokeDasharray,
1384
+ pathLength: D.strokeDasharray ? 1 : void 0,
1147
1385
  style: {
1148
- transition: c.transition,
1149
- animation: h.animation
1386
+ transition: m.transition,
1387
+ animation: D.animation
1150
1388
  }
1151
1389
  }
1152
1390
  )
@@ -1157,163 +1395,163 @@ function qt({
1157
1395
  i
1158
1396
  ] });
1159
1397
  }
1160
- function Gt(t, e) {
1161
- const { x: n, y: r, w: i, h: l } = e;
1162
- let a, s;
1163
- t.includes("left") ? (a = `${n * 100}%`, s = "0") : t.includes("right") ? (a = `${(n + i) * 100}%`, s = "-100%") : (a = `${(n + i / 2) * 100}%`, s = "-50%");
1164
- let u, c;
1165
- return t.startsWith("top") ? (u = `${r * 100}%`, c = "-100%") : t.startsWith("bottom") ? (u = `${(r + l) * 100}%`, c = "0") : (u = `${(r + l / 2) * 100}%`, c = "-50%"), {
1398
+ function ne(t, r) {
1399
+ const { x: n, y: e, w: c, h: i } = r;
1400
+ let s, o;
1401
+ t.includes("left") ? (s = `${n * 100}%`, o = "0") : t.includes("right") ? (s = `${(n + c) * 100}%`, o = "-100%") : (s = `${(n + c / 2) * 100}%`, o = "-50%");
1402
+ let l, u;
1403
+ return t.startsWith("top") ? (l = `${e * 100}%`, u = "-100%") : t.startsWith("bottom") ? (l = `${(e + i) * 100}%`, u = "0") : (l = `${(e + i / 2) * 100}%`, u = "-50%"), {
1166
1404
  position: "absolute",
1167
- left: a,
1168
- top: u,
1169
- transform: `translate(${s}, ${c})`
1405
+ left: s,
1406
+ top: l,
1407
+ transform: `translate(${o}, ${u})`
1170
1408
  };
1171
1409
  }
1172
- function Jt({
1410
+ function oe({
1173
1411
  placement: t = "top-center",
1174
- children: e,
1412
+ children: r,
1175
1413
  className: n = "",
1176
- style: r
1414
+ style: e
1177
1415
  }) {
1178
- const i = z(tt), l = ot();
1179
- if (!i)
1416
+ const c = Y(Z), i = nt();
1417
+ if (!c)
1180
1418
  throw new Error(
1181
1419
  "<CutoutViewer.Overlay> must be used inside <CutoutViewer.Cutout>"
1182
1420
  );
1183
- const a = l.enabled && (l.showAll || i.isActive), s = Gt(t, i.bounds);
1184
- return /* @__PURE__ */ I.jsx(
1421
+ const s = i.enabled && (i.showAll || c.isActive), o = ne(t, c.bounds);
1422
+ return /* @__PURE__ */ C.jsx(
1185
1423
  "div",
1186
1424
  {
1187
1425
  "data-cutout-overlay": "true",
1188
1426
  className: n,
1189
1427
  style: {
1190
1428
  zIndex: 30,
1191
- transition: i.effect.transition,
1192
- opacity: a ? 1 : 0,
1193
- pointerEvents: a ? "auto" : "none",
1194
- ...s,
1195
- ...r
1429
+ transition: c.effect.transition,
1430
+ opacity: s ? 1 : 0,
1431
+ pointerEvents: s ? "auto" : "none",
1432
+ ...o,
1433
+ ...e
1196
1434
  },
1197
- children: e
1435
+ children: r
1198
1436
  }
1199
1437
  );
1200
1438
  }
1201
- function Kt({
1439
+ function se({
1202
1440
  onComplete: t,
1203
- minPoints: e = 3,
1441
+ minPoints: r = 3,
1204
1442
  closeThreshold: n = 0.03
1205
1443
  }) {
1206
- const [r, i] = L([]), [l, a] = L(null), s = B(null), u = P(
1207
- (h, E) => {
1208
- const w = s.current;
1209
- if (!w) return null;
1210
- const x = w.getBoundingClientRect(), $ = (h - x.left) / x.width, N = (E - x.top) / x.height;
1211
- return $ < 0 || $ > 1 || N < 0 || N > 1 ? null : [$, N];
1444
+ const [e, c] = O([]), [i, s] = O(null), o = N(null), l = M(
1445
+ (f, w) => {
1446
+ const k = o.current;
1447
+ if (!k) return null;
1448
+ const b = k.getBoundingClientRect(), A = (f - b.left) / b.width, _ = (w - b.top) / b.height;
1449
+ return A < 0 || A > 1 || _ < 0 || _ > 1 ? null : [A, _];
1212
1450
  },
1213
1451
  []
1214
- ), c = P(
1215
- (h, E) => {
1216
- if (E.length < e) return !1;
1217
- const w = h[0] - E[0][0], x = h[1] - E[0][1];
1218
- return Math.sqrt(w * w + x * x) < n;
1452
+ ), u = M(
1453
+ (f, w) => {
1454
+ if (w.length < r) return !1;
1455
+ const k = f[0] - w[0][0], b = f[1] - w[0][1];
1456
+ return Math.sqrt(k * k + b * b) < n;
1219
1457
  },
1220
- [e, n]
1221
- ), d = P(
1222
- (h) => {
1223
- h.length < e || (t(h), i([]), a(null));
1458
+ [r, n]
1459
+ ), p = M(
1460
+ (f) => {
1461
+ f.length < r || (t(f), c([]), s(null));
1224
1462
  },
1225
- [t, e]
1226
- ), k = P(() => {
1227
- i([]), a(null);
1228
- }, []), p = P(
1229
- (h) => {
1230
- a(u(h.clientX, h.clientY));
1463
+ [t, r]
1464
+ ), m = M(() => {
1465
+ c([]), s(null);
1466
+ }, []), v = M(
1467
+ (f) => {
1468
+ s(l(f.clientX, f.clientY));
1231
1469
  },
1232
- [u]
1233
- ), g = P(() => {
1234
- a(null);
1235
- }, []), m = P(
1236
- (h) => {
1237
- h.stopPropagation();
1238
- const E = u(h.clientX, h.clientY);
1239
- E && i((w) => c(E, w) ? (d(w), []) : [...w, E]);
1470
+ [l]
1471
+ ), x = M(() => {
1472
+ s(null);
1473
+ }, []), g = M(
1474
+ (f) => {
1475
+ f.stopPropagation();
1476
+ const w = l(f.clientX, f.clientY);
1477
+ w && c((k) => u(w, k) ? (p(k), []) : [...k, w]);
1240
1478
  },
1241
- [u, c, d]
1242
- ), v = P(
1243
- (h) => {
1244
- h.stopPropagation(), i((E) => {
1245
- const w = E.slice(0, -1);
1246
- return w.length >= e ? (d(w), []) : w;
1479
+ [l, u, p]
1480
+ ), y = M(
1481
+ (f) => {
1482
+ f.stopPropagation(), c((w) => {
1483
+ const k = w.slice(0, -1);
1484
+ return k.length >= r ? (p(k), []) : k;
1247
1485
  });
1248
1486
  },
1249
- [e, d]
1250
- ), f = P(
1251
- (h) => {
1252
- h.preventDefault(), i((E) => E.slice(0, -1));
1487
+ [r, p]
1488
+ ), d = M(
1489
+ (f) => {
1490
+ f.preventDefault(), c((w) => w.slice(0, -1));
1253
1491
  },
1254
1492
  []
1255
- ), b = l !== null && c(l, r);
1493
+ ), h = i !== null && u(i, e);
1256
1494
  return {
1257
- points: r,
1258
- previewPoint: l,
1259
- willClose: b,
1260
- reset: k,
1261
- containerRef: s,
1495
+ points: e,
1496
+ previewPoint: i,
1497
+ willClose: h,
1498
+ reset: m,
1499
+ containerRef: o,
1262
1500
  containerProps: {
1263
- onPointerMove: p,
1264
- onPointerLeave: g,
1265
- onClick: m,
1266
- onDoubleClick: v,
1267
- onContextMenu: f
1501
+ onPointerMove: v,
1502
+ onPointerLeave: x,
1503
+ onClick: g,
1504
+ onDoubleClick: y,
1505
+ onContextMenu: d
1268
1506
  }
1269
1507
  };
1270
1508
  }
1271
- function Zt({
1509
+ function ie({
1272
1510
  onComplete: t,
1273
- minPoints: e = 3,
1511
+ minPoints: r = 3,
1274
1512
  closeThreshold: n = 0.03,
1275
- strokeColor: r = "#3b82f6",
1276
- enabled: i = !0,
1277
- style: l,
1278
- className: a = ""
1513
+ strokeColor: e = "#3b82f6",
1514
+ enabled: c = !0,
1515
+ style: i,
1516
+ className: s = ""
1279
1517
  }) {
1280
- if (!z(Q))
1518
+ if (!Y(H))
1281
1519
  throw new Error(
1282
1520
  "<CutoutViewer.DrawPolygon> must be used inside <CutoutViewer>"
1283
1521
  );
1284
1522
  const {
1285
- points: u,
1286
- previewPoint: c,
1287
- willClose: d,
1288
- reset: k,
1289
- containerRef: p,
1290
- containerProps: g
1291
- } = Kt({ onComplete: t, minPoints: e, closeThreshold: n });
1292
- O(() => {
1293
- function f(b) {
1294
- b.key === "Escape" && k();
1523
+ points: l,
1524
+ previewPoint: u,
1525
+ willClose: p,
1526
+ reset: m,
1527
+ containerRef: v,
1528
+ containerProps: x
1529
+ } = se({ onComplete: t, minPoints: r, closeThreshold: n });
1530
+ W(() => {
1531
+ function d(h) {
1532
+ h.key === "Escape" && m();
1295
1533
  }
1296
- return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
1297
- }, [k]), O(() => {
1298
- i || k();
1299
- }, [i, k]);
1300
- const m = c ? [...u, c] : u, v = m.map(([f, b]) => `${f},${b}`).join(" ");
1301
- return /* @__PURE__ */ I.jsx(
1534
+ return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
1535
+ }, [m]), W(() => {
1536
+ c || m();
1537
+ }, [c, m]);
1538
+ const g = u ? [...l, u] : l, y = g.map(([d, h]) => `${d},${h}`).join(" ");
1539
+ return /* @__PURE__ */ C.jsx(
1302
1540
  "div",
1303
1541
  {
1304
- ref: p,
1542
+ ref: v,
1305
1543
  "data-draw-polygon": "true",
1306
- className: a,
1544
+ className: s,
1307
1545
  style: {
1308
1546
  position: "absolute",
1309
1547
  inset: 0,
1310
- cursor: i ? d ? "cell" : "crosshair" : "default",
1548
+ cursor: c ? p ? "cell" : "crosshair" : "default",
1311
1549
  zIndex: 30,
1312
- pointerEvents: i ? "auto" : "none",
1313
- ...l
1550
+ pointerEvents: c ? "auto" : "none",
1551
+ ...i
1314
1552
  },
1315
- ...i ? g : {},
1316
- children: u.length > 0 && /* @__PURE__ */ I.jsxs(
1553
+ ...c ? x : {},
1554
+ children: l.length > 0 && /* @__PURE__ */ C.jsxs(
1317
1555
  "svg",
1318
1556
  {
1319
1557
  viewBox: "0 0 1 1",
@@ -1327,61 +1565,61 @@ function Zt({
1327
1565
  pointerEvents: "none"
1328
1566
  },
1329
1567
  children: [
1330
- u.length >= 3 && /* @__PURE__ */ I.jsx(
1568
+ l.length >= 3 && /* @__PURE__ */ C.jsx(
1331
1569
  "polygon",
1332
1570
  {
1333
- points: u.map(([f, b]) => `${f},${b}`).join(" "),
1334
- fill: r,
1571
+ points: l.map(([d, h]) => `${d},${h}`).join(" "),
1572
+ fill: e,
1335
1573
  fillOpacity: 0.15,
1336
1574
  stroke: "none"
1337
1575
  }
1338
1576
  ),
1339
- m.length >= 2 && /* @__PURE__ */ I.jsx(
1577
+ g.length >= 2 && /* @__PURE__ */ C.jsx(
1340
1578
  "polyline",
1341
1579
  {
1342
- points: v,
1580
+ points: y,
1343
1581
  fill: "none",
1344
- stroke: r,
1582
+ stroke: e,
1345
1583
  strokeWidth: 3e-3,
1346
1584
  strokeLinecap: "round",
1347
1585
  strokeLinejoin: "round",
1348
- strokeDasharray: c ? "0.015 0.008" : void 0
1586
+ strokeDasharray: u ? "0.015 0.008" : void 0
1349
1587
  }
1350
1588
  ),
1351
- c && u.length >= 1 && /* @__PURE__ */ I.jsx(
1589
+ u && l.length >= 1 && /* @__PURE__ */ C.jsx(
1352
1590
  "line",
1353
1591
  {
1354
- x1: c[0],
1355
- y1: c[1],
1356
- x2: u[0][0],
1357
- y2: u[0][1],
1358
- stroke: r,
1592
+ x1: u[0],
1593
+ y1: u[1],
1594
+ x2: l[0][0],
1595
+ y2: l[0][1],
1596
+ stroke: e,
1359
1597
  strokeWidth: 2e-3,
1360
1598
  strokeDasharray: "0.015 0.008",
1361
1599
  strokeLinecap: "round",
1362
- opacity: d ? 0.9 : 0.35
1600
+ opacity: p ? 0.9 : 0.35
1363
1601
  }
1364
1602
  ),
1365
- u.map(([f, b], h) => /* @__PURE__ */ I.jsx(
1603
+ l.map(([d, h], f) => /* @__PURE__ */ C.jsx(
1366
1604
  "circle",
1367
1605
  {
1368
- cx: f,
1369
- cy: b,
1370
- r: h === 0 ? 0.012 : 7e-3,
1371
- fill: h === 0 && d ? r : "white",
1372
- stroke: r,
1606
+ cx: d,
1607
+ cy: h,
1608
+ r: f === 0 ? 0.012 : 7e-3,
1609
+ fill: f === 0 && p ? e : "white",
1610
+ stroke: e,
1373
1611
  strokeWidth: 2e-3
1374
1612
  },
1375
- h
1613
+ f
1376
1614
  )),
1377
- c && /* @__PURE__ */ I.jsx(
1615
+ u && /* @__PURE__ */ C.jsx(
1378
1616
  "circle",
1379
1617
  {
1380
- cx: c[0],
1381
- cy: c[1],
1618
+ cx: u[0],
1619
+ cy: u[1],
1382
1620
  r: 5e-3,
1383
- fill: d ? r : "white",
1384
- stroke: r,
1621
+ fill: p ? e : "white",
1622
+ stroke: e,
1385
1623
  strokeWidth: 2e-3,
1386
1624
  opacity: 0.8
1387
1625
  }
@@ -1392,7 +1630,298 @@ function Zt({
1392
1630
  }
1393
1631
  );
1394
1632
  }
1395
- function bt(t) {
1633
+ function ae({
1634
+ onComplete: t,
1635
+ minSize: r = 0.01
1636
+ }) {
1637
+ const [n, e] = O(null), [c, i] = O(null), s = N(null), o = M(
1638
+ (g, y) => {
1639
+ const d = s.current;
1640
+ if (!d) return null;
1641
+ const h = d.getBoundingClientRect(), f = (g - h.left) / h.width, w = (y - h.top) / h.height;
1642
+ return {
1643
+ x: Math.max(0, Math.min(1, f)),
1644
+ y: Math.max(0, Math.min(1, w))
1645
+ };
1646
+ },
1647
+ []
1648
+ ), l = M(
1649
+ (g, y) => {
1650
+ const d = Math.min(g.x, y.x), h = Math.min(g.y, y.y), f = Math.abs(y.x - g.x), w = Math.abs(y.y - g.y);
1651
+ return { x: d, y: h, w: f, h: w };
1652
+ },
1653
+ []
1654
+ ), u = M(() => {
1655
+ e(null), i(null);
1656
+ }, []);
1657
+ W(() => {
1658
+ function g(y) {
1659
+ y.key === "Escape" && u();
1660
+ }
1661
+ return document.addEventListener("keydown", g), () => document.removeEventListener("keydown", g);
1662
+ }, [u]);
1663
+ const p = M(
1664
+ (g) => {
1665
+ g.currentTarget.setPointerCapture(g.pointerId);
1666
+ const y = o(g.clientX, g.clientY);
1667
+ y && (e(y), i({ x: y.x, y: y.y, w: 0, h: 0 }));
1668
+ },
1669
+ [o]
1670
+ ), m = M(
1671
+ (g) => {
1672
+ if (!n) return;
1673
+ const y = o(g.clientX, g.clientY);
1674
+ y && i(l(n, y));
1675
+ },
1676
+ [n, o, l]
1677
+ ), v = M(
1678
+ (g) => {
1679
+ if (!n) return;
1680
+ const y = o(g.clientX, g.clientY);
1681
+ if (y) {
1682
+ const d = l(n, y);
1683
+ d.w >= r && d.h >= r && t(d);
1684
+ }
1685
+ e(null), i(null);
1686
+ },
1687
+ [n, o, l, r, t]
1688
+ ), x = M(() => {
1689
+ }, []);
1690
+ return {
1691
+ rect: c,
1692
+ isDragging: n !== null,
1693
+ reset: u,
1694
+ containerRef: s,
1695
+ containerProps: {
1696
+ onPointerDown: p,
1697
+ onPointerMove: m,
1698
+ onPointerUp: v,
1699
+ onPointerLeave: x
1700
+ }
1701
+ };
1702
+ }
1703
+ function ce({
1704
+ onComplete: t,
1705
+ minSize: r,
1706
+ strokeColor: n = "#3b82f6",
1707
+ enabled: e = !0,
1708
+ style: c,
1709
+ className: i = ""
1710
+ }) {
1711
+ if (!Y(H))
1712
+ throw new Error(
1713
+ "<CutoutViewer.DrawRectangle> must be used inside <CutoutViewer>"
1714
+ );
1715
+ const { rect: o, reset: l, containerRef: u, containerProps: p } = ae({
1716
+ onComplete: t,
1717
+ minSize: r
1718
+ });
1719
+ return W(() => {
1720
+ e || l();
1721
+ }, [e, l]), /* @__PURE__ */ C.jsx(
1722
+ "div",
1723
+ {
1724
+ ref: u,
1725
+ "data-draw-rectangle": "true",
1726
+ className: i,
1727
+ style: {
1728
+ position: "absolute",
1729
+ inset: 0,
1730
+ cursor: e ? "crosshair" : "default",
1731
+ zIndex: 30,
1732
+ pointerEvents: e ? "auto" : "none",
1733
+ ...c
1734
+ },
1735
+ ...e ? p : {},
1736
+ children: o && o.w > 0 && o.h > 0 && /* @__PURE__ */ C.jsx(
1737
+ "svg",
1738
+ {
1739
+ viewBox: "0 0 1 1",
1740
+ preserveAspectRatio: "none",
1741
+ style: {
1742
+ position: "absolute",
1743
+ inset: 0,
1744
+ width: "100%",
1745
+ height: "100%",
1746
+ overflow: "visible",
1747
+ pointerEvents: "none"
1748
+ },
1749
+ children: /* @__PURE__ */ C.jsx(
1750
+ "rect",
1751
+ {
1752
+ x: o.x,
1753
+ y: o.y,
1754
+ width: o.w,
1755
+ height: o.h,
1756
+ fill: n,
1757
+ fillOpacity: 0.15,
1758
+ stroke: n,
1759
+ strokeWidth: 3e-3,
1760
+ strokeLinecap: "round",
1761
+ strokeLinejoin: "round",
1762
+ strokeDasharray: "0.015 0.008"
1763
+ }
1764
+ )
1765
+ }
1766
+ )
1767
+ }
1768
+ );
1769
+ }
1770
+ function le({
1771
+ onComplete: t,
1772
+ minRadius: r = 0.01
1773
+ }) {
1774
+ const [n, e] = O(null), [c, i] = O(null), [s, o] = O({ width: 1, height: 1 }), l = N(null);
1775
+ W(() => {
1776
+ const d = l.current;
1777
+ if (!d) return;
1778
+ const h = () => {
1779
+ const w = d.getBoundingClientRect();
1780
+ o({
1781
+ width: Math.max(1, w.width),
1782
+ height: Math.max(1, w.height)
1783
+ });
1784
+ };
1785
+ h();
1786
+ const f = new ResizeObserver(h);
1787
+ return f.observe(d), () => f.disconnect();
1788
+ }, []);
1789
+ const u = M(
1790
+ (d, h) => {
1791
+ const f = l.current;
1792
+ if (!f) return null;
1793
+ const w = f.getBoundingClientRect(), k = (d - w.left) / w.width, b = (h - w.top) / w.height;
1794
+ return {
1795
+ x: Math.max(0, Math.min(1, k)),
1796
+ y: Math.max(0, Math.min(1, b))
1797
+ };
1798
+ },
1799
+ []
1800
+ ), p = M(
1801
+ (d, h) => {
1802
+ const f = (d.x - h.x) * s.width, w = (d.y - h.y) * s.height, k = Math.sqrt(f * f + w * w), b = Math.min(s.width, s.height);
1803
+ return k / b;
1804
+ },
1805
+ [s.height, s.width]
1806
+ ), m = M(() => {
1807
+ e(null), i(null);
1808
+ }, []);
1809
+ W(() => {
1810
+ function d(h) {
1811
+ h.key === "Escape" && m();
1812
+ }
1813
+ return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
1814
+ }, [m]);
1815
+ const v = M(
1816
+ (d) => {
1817
+ d.currentTarget.setPointerCapture(d.pointerId);
1818
+ const h = u(d.clientX, d.clientY);
1819
+ h && (e(h), i({ center: h, radius: 0 }));
1820
+ },
1821
+ [u]
1822
+ ), x = M(
1823
+ (d) => {
1824
+ if (!n) return;
1825
+ const h = u(d.clientX, d.clientY);
1826
+ if (!h) return;
1827
+ const f = p(h, n);
1828
+ i({ center: n, radius: f });
1829
+ },
1830
+ [n, u, p]
1831
+ ), g = M(
1832
+ (d) => {
1833
+ if (!n) return;
1834
+ const h = u(d.clientX, d.clientY);
1835
+ if (h) {
1836
+ const f = p(h, n);
1837
+ f >= r && t({ center: n, radius: f });
1838
+ }
1839
+ e(null), i(null);
1840
+ },
1841
+ [n, u, p, r, t]
1842
+ ), y = M(() => {
1843
+ }, []);
1844
+ return {
1845
+ circle: c,
1846
+ viewportSize: s,
1847
+ isDragging: n !== null,
1848
+ reset: m,
1849
+ containerRef: l,
1850
+ containerProps: {
1851
+ onPointerDown: v,
1852
+ onPointerMove: x,
1853
+ onPointerUp: g,
1854
+ onPointerLeave: y
1855
+ }
1856
+ };
1857
+ }
1858
+ function ue({
1859
+ onComplete: t,
1860
+ minRadius: r,
1861
+ strokeColor: n = "#3b82f6",
1862
+ enabled: e = !0,
1863
+ style: c,
1864
+ className: i = ""
1865
+ }) {
1866
+ if (!Y(H))
1867
+ throw new Error(
1868
+ "<CutoutViewer.DrawCircle> must be used inside <CutoutViewer>"
1869
+ );
1870
+ const { circle: o, viewportSize: l, reset: u, containerRef: p, containerProps: m } = le({
1871
+ onComplete: t,
1872
+ minRadius: r
1873
+ }), v = Math.max(1, l.width), x = Math.max(1, l.height), g = Math.min(v, x);
1874
+ return W(() => {
1875
+ e || u();
1876
+ }, [e, u]), /* @__PURE__ */ C.jsx(
1877
+ "div",
1878
+ {
1879
+ ref: p,
1880
+ "data-draw-circle": "true",
1881
+ className: i,
1882
+ style: {
1883
+ position: "absolute",
1884
+ inset: 0,
1885
+ cursor: e ? "crosshair" : "default",
1886
+ zIndex: 30,
1887
+ pointerEvents: e ? "auto" : "none",
1888
+ ...c
1889
+ },
1890
+ ...e ? m : {},
1891
+ children: o && o.radius > 0 && /* @__PURE__ */ C.jsx(
1892
+ "svg",
1893
+ {
1894
+ viewBox: "0 0 1 1",
1895
+ preserveAspectRatio: "none",
1896
+ style: {
1897
+ position: "absolute",
1898
+ inset: 0,
1899
+ width: "100%",
1900
+ height: "100%",
1901
+ overflow: "visible",
1902
+ pointerEvents: "none"
1903
+ },
1904
+ children: /* @__PURE__ */ C.jsx(
1905
+ "ellipse",
1906
+ {
1907
+ cx: o.center.x,
1908
+ cy: o.center.y,
1909
+ rx: o.radius * g / v,
1910
+ ry: o.radius * g / x,
1911
+ fill: n,
1912
+ fillOpacity: 0.15,
1913
+ stroke: n,
1914
+ strokeWidth: 3e-3,
1915
+ strokeLinecap: "round",
1916
+ strokeDasharray: "0.015 0.008"
1917
+ }
1918
+ )
1919
+ }
1920
+ )
1921
+ }
1922
+ );
1923
+ }
1924
+ function xt(t) {
1396
1925
  switch (t.type) {
1397
1926
  case "image":
1398
1927
  return `image:${t.src}:${t.label ?? ""}`;
@@ -1400,140 +1929,151 @@ function bt(t) {
1400
1929
  return `bbox:${t.bounds.x},${t.bounds.y},${t.bounds.w},${t.bounds.h}:${t.label ?? ""}`;
1401
1930
  case "polygon":
1402
1931
  return `polygon:${t.points.flat().join(",")}:${t.label ?? ""}`;
1932
+ case "circle":
1933
+ return `circle:${t.center.x},${t.center.y},${t.radius}:${t.label ?? ""}`;
1403
1934
  }
1404
1935
  }
1405
- function Qt({
1936
+ function he({
1406
1937
  mainImage: t,
1407
- mainImageAlt: e = "Main image",
1938
+ mainImageAlt: r = "Main image",
1408
1939
  effect: n = "elevate",
1409
- enabled: r = !0,
1410
- showAll: i = !1,
1411
- alphaThreshold: l = 30,
1412
- hoverLeaveDelay: a = 150,
1413
- children: s,
1414
- className: u = "",
1415
- style: c,
1416
- onHover: d,
1417
- onActiveChange: k,
1418
- onSelect: p
1940
+ enabled: e = !0,
1941
+ showAll: c = !1,
1942
+ alphaThreshold: i = 30,
1943
+ hoverLeaveDelay: s = 150,
1944
+ children: o,
1945
+ className: l = "",
1946
+ style: u,
1947
+ onHover: p,
1948
+ onActiveChange: m,
1949
+ onSelect: v
1419
1950
  }) {
1420
- const g = typeof n == "string" ? K[n] ?? K.elevate : n;
1421
- O(() => {
1422
- Yt(g);
1423
- }, [g]);
1424
- const [m, v] = L(() => /* @__PURE__ */ new Map()), f = P(
1425
- (M) => {
1426
- v((W) => {
1427
- const Y = W.get(M.id);
1428
- if (Y && bt(Y) === bt(M))
1429
- return W;
1430
- const D = new Map(W);
1431
- return D.set(M.id, M), D;
1951
+ const x = typeof n == "string" ? J[n] ?? J.elevate : n;
1952
+ W(() => {
1953
+ Xt(x);
1954
+ }, [x]);
1955
+ const [g, y] = O(() => /* @__PURE__ */ new Map()), d = M(
1956
+ (I) => {
1957
+ y((z) => {
1958
+ const L = z.get(I.id);
1959
+ if (L && xt(L) === xt(I))
1960
+ return z;
1961
+ const G = new Map(z);
1962
+ return G.set(I.id, I), G;
1432
1963
  });
1433
1964
  },
1434
1965
  []
1435
- ), b = P((M) => {
1436
- v((W) => {
1437
- if (!W.has(M)) return W;
1438
- const Y = new Map(W);
1439
- return Y.delete(M), Y;
1966
+ ), h = M((I) => {
1967
+ y((z) => {
1968
+ if (!z.has(I)) return z;
1969
+ const L = new Map(z);
1970
+ return L.delete(I), L;
1440
1971
  });
1441
- }, []), h = F(
1442
- () => ({ registerCutout: f, unregisterCutout: b }),
1443
- [f, b]
1444
- ), E = F(() => Array.from(m.values()), [m]), { activeId: w, selectedId: x, hoveredId: $, boundsMap: N, contourMap: H, containerRef: V, containerProps: q } = Nt(E, r, l, a), X = B(null), j = B(null), R = B(null);
1445
- O(() => {
1446
- $ !== X.current && (X.current = $, d?.($));
1447
- }, [$, d]), O(() => {
1448
- w !== j.current && (j.current = w, k?.(w));
1449
- }, [w, k]), O(() => {
1450
- x !== R.current && (R.current = x, p?.(x));
1451
- }, [x, p]);
1452
- const C = i || w !== null, _ = F(
1972
+ }, []), f = V(
1973
+ () => ({ registerCutout: d, unregisterCutout: h }),
1974
+ [d, h]
1975
+ ), w = V(() => Array.from(g.values()), [g]), { activeId: k, selectedId: b, hoveredId: A, viewportSize: _, boundsMap: X, contourMap: D, containerRef: U, containerProps: Q } = Ft(w, e, i, s), B = N(null), q = N(null), S = N(null);
1976
+ W(() => {
1977
+ A !== B.current && (B.current = A, p?.(A));
1978
+ }, [A, p]), W(() => {
1979
+ k !== q.current && (q.current = k, m?.(k));
1980
+ }, [k, m]), W(() => {
1981
+ b !== S.current && (S.current = b, v?.(b));
1982
+ }, [b, v]);
1983
+ const R = c || k !== null, P = V(
1453
1984
  () => ({
1454
- activeId: w,
1455
- selectedId: x,
1456
- hoveredId: $,
1457
- effect: g,
1458
- enabled: r,
1459
- showAll: i,
1460
- boundsMap: N,
1461
- contourMap: H,
1462
- isAnyActive: C
1985
+ activeId: k,
1986
+ selectedId: b,
1987
+ hoveredId: A,
1988
+ viewportSize: _,
1989
+ effect: x,
1990
+ enabled: e,
1991
+ showAll: c,
1992
+ boundsMap: X,
1993
+ contourMap: D,
1994
+ isAnyActive: R
1463
1995
  }),
1464
- [w, x, $, g, r, i, N, H, C]
1996
+ [k, b, A, _, x, e, c, X, D, R]
1465
1997
  );
1466
- return /* @__PURE__ */ I.jsx(Q.Provider, { value: h, children: /* @__PURE__ */ I.jsx(xt.Provider, { value: _, children: /* @__PURE__ */ I.jsxs(
1998
+ return /* @__PURE__ */ C.jsx(H.Provider, { value: f, children: /* @__PURE__ */ C.jsx(kt.Provider, { value: P, children: /* @__PURE__ */ C.jsxs(
1467
1999
  "div",
1468
2000
  {
1469
- ref: V,
1470
- className: u,
2001
+ ref: U,
2002
+ className: l,
1471
2003
  style: {
1472
2004
  position: "relative",
1473
2005
  width: "100%",
1474
2006
  overflow: "hidden",
1475
- cursor: C && r ? "pointer" : "default",
1476
- ...c
2007
+ cursor: R && e ? "pointer" : "default",
2008
+ ...u
1477
2009
  },
1478
- ...q,
2010
+ ...Q,
1479
2011
  children: [
1480
- /* @__PURE__ */ I.jsx(
2012
+ /* @__PURE__ */ C.jsx(
1481
2013
  "img",
1482
2014
  {
1483
2015
  src: t,
1484
- alt: e,
2016
+ alt: r,
1485
2017
  draggable: !1,
1486
2018
  style: {
1487
2019
  display: "block",
1488
2020
  width: "100%",
1489
2021
  height: "auto",
1490
2022
  userSelect: "none",
1491
- transition: g.transition,
1492
- ...C && r ? g.mainImageHovered : {}
2023
+ transition: x.transition,
2024
+ ...R && e ? x.mainImageHovered : {}
1493
2025
  }
1494
2026
  }
1495
2027
  ),
1496
- /* @__PURE__ */ I.jsx(
2028
+ /* @__PURE__ */ C.jsx(
1497
2029
  "div",
1498
2030
  {
1499
2031
  style: {
1500
2032
  pointerEvents: "none",
1501
2033
  position: "absolute",
1502
2034
  inset: 0,
1503
- transition: g.transition,
1504
- opacity: C && r ? 1 : 0,
1505
- ...g.vignetteStyle
2035
+ transition: x.transition,
2036
+ opacity: R && e ? 1 : 0,
2037
+ ...x.vignetteStyle
1506
2038
  }
1507
2039
  }
1508
2040
  ),
1509
- s
2041
+ o
1510
2042
  ]
1511
2043
  }
1512
2044
  ) }) });
1513
2045
  }
1514
- const et = Qt;
1515
- et.Cutout = Xt;
1516
- et.BBoxCutout = Ut;
1517
- et.PolygonCutout = qt;
1518
- et.Overlay = Jt;
1519
- et.DrawPolygon = Zt;
2046
+ const F = he;
2047
+ F.Cutout = Qt;
2048
+ F.BBoxCutout = te;
2049
+ F.PolygonCutout = ee;
2050
+ F.CircleCutout = re;
2051
+ F.Overlay = oe;
2052
+ F.DrawPolygon = ie;
2053
+ F.DrawRectangle = ce;
2054
+ F.DrawCircle = ue;
1520
2055
  export {
1521
- Jt as CutoutOverlay,
1522
- et as CutoutViewer,
1523
- Zt as DrawPolygon,
1524
- Pt as ImageHitTestStrategy,
1525
- Dt as PolygonHitTestStrategy,
1526
- Mt as RectHitTestStrategy,
1527
- Wt as createHitTestStrategy,
1528
- vt as defineKeyframes,
1529
- Vt as elevateEffect,
1530
- Lt as glowEffect,
1531
- K as hoverEffects,
1532
- Bt as liftEffect,
1533
- Ht as shimmerEffect,
1534
- Ft as subtleEffect,
1535
- zt as traceEffect,
1536
- ee as useCutout,
1537
- Nt as useCutoutHitTest,
1538
- Kt as useDrawPolygon
2056
+ Vt as CircleHitTestStrategy,
2057
+ oe as CutoutOverlay,
2058
+ F as CutoutViewer,
2059
+ ue as DrawCircle,
2060
+ ie as DrawPolygon,
2061
+ ce as DrawRectangle,
2062
+ Ot as ImageHitTestStrategy,
2063
+ Nt as PolygonHitTestStrategy,
2064
+ Lt as RectHitTestStrategy,
2065
+ Bt as createHitTestStrategy,
2066
+ bt as defineKeyframes,
2067
+ Ut as elevateEffect,
2068
+ qt as glowEffect,
2069
+ J as hoverEffects,
2070
+ Gt as liftEffect,
2071
+ Zt as shimmerEffect,
2072
+ Kt as subtleEffect,
2073
+ Jt as traceEffect,
2074
+ de as useCutout,
2075
+ Ft as useCutoutHitTest,
2076
+ le as useDrawCircle,
2077
+ se as useDrawPolygon,
2078
+ ae as useDrawRectangle
1539
2079
  };