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