react-img-cutout 1.0.0 → 1.1.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 +67 -3
- package/dist/components/cutout-viewer/cutout-viewer.d.ts +2 -0
- package/dist/components/cutout-viewer/drawing/draw-polygon.d.ts +58 -0
- package/dist/components/cutout-viewer/drawing/use-draw-polygon.d.ts +56 -0
- package/dist/components/cutout-viewer/index.d.ts +4 -0
- package/dist/index.cjs +6 -6
- package/dist/index.js +643 -446
- package/package.json +1 -1
- package/dist/demo-images/main.png +0 -0
- package/dist/demo-images/man.png +0 -0
- package/dist/demo-images/woman.png +0 -0
package/dist/index.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import kt, { useState as
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
import kt, { useState as F, useRef as V, useCallback as P, useMemo as B, useEffect as O, useContext as H, createContext as it } from "react";
|
|
2
|
+
var rt = { exports: {} }, G = {};
|
|
3
|
+
var ut;
|
|
4
4
|
function Et() {
|
|
5
|
-
if (
|
|
6
|
-
|
|
5
|
+
if (ut) return G;
|
|
6
|
+
ut = 1;
|
|
7
7
|
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
-
function o(n,
|
|
9
|
-
var
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
for (var s in
|
|
13
|
-
s !== "key" && (
|
|
14
|
-
} else
|
|
15
|
-
return
|
|
8
|
+
function o(n, i, c) {
|
|
9
|
+
var a = null;
|
|
10
|
+
if (c !== void 0 && (a = "" + c), i.key !== void 0 && (a = "" + i.key), "key" in i) {
|
|
11
|
+
c = {};
|
|
12
|
+
for (var s in i)
|
|
13
|
+
s !== "key" && (c[s] = i[s]);
|
|
14
|
+
} else c = i;
|
|
15
|
+
return i = c.ref, {
|
|
16
16
|
$$typeof: t,
|
|
17
17
|
type: n,
|
|
18
|
-
key:
|
|
19
|
-
ref:
|
|
20
|
-
props:
|
|
18
|
+
key: a,
|
|
19
|
+
ref: i !== void 0 ? i : null,
|
|
20
|
+
props: c
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
return G.Fragment = r, G.jsx = o, G.jsxs = o, G;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
25
|
+
var q = {};
|
|
26
26
|
var ft;
|
|
27
27
|
function It() {
|
|
28
28
|
return ft || (ft = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
29
|
function t(e) {
|
|
30
30
|
if (e == null) return null;
|
|
31
31
|
if (typeof e == "function")
|
|
32
|
-
return e.$$typeof ===
|
|
32
|
+
return e.$$typeof === R ? null : e.displayName || e.name || null;
|
|
33
33
|
if (typeof e == "string") return e;
|
|
34
34
|
switch (e) {
|
|
35
|
-
case
|
|
35
|
+
case x:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case
|
|
37
|
+
case u:
|
|
38
38
|
return "Profiler";
|
|
39
|
-
case
|
|
39
|
+
case w:
|
|
40
40
|
return "StrictMode";
|
|
41
41
|
case M:
|
|
42
42
|
return "Suspense";
|
|
43
|
-
case
|
|
43
|
+
case D:
|
|
44
44
|
return "SuspenseList";
|
|
45
|
-
case
|
|
45
|
+
case _:
|
|
46
46
|
return "Activity";
|
|
47
47
|
}
|
|
48
48
|
if (typeof e == "object")
|
|
49
49
|
switch (typeof e.tag == "number" && console.error(
|
|
50
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
51
|
), e.$$typeof) {
|
|
52
|
-
case
|
|
52
|
+
case E:
|
|
53
53
|
return "Portal";
|
|
54
|
-
case
|
|
54
|
+
case v:
|
|
55
55
|
return e.displayName || "Context";
|
|
56
|
-
case j:
|
|
57
|
-
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
56
|
case b:
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case m:
|
|
59
|
+
var p = e.render;
|
|
60
|
+
return e = e.displayName, e || (e = p.displayName || p.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
61
|
case z:
|
|
62
|
-
return
|
|
63
|
-
case
|
|
64
|
-
|
|
62
|
+
return p = e.displayName || null, p !== null ? p : t(e.type) || "Memo";
|
|
63
|
+
case j:
|
|
64
|
+
p = e._payload, e = e._init;
|
|
65
65
|
try {
|
|
66
|
-
return t(e(
|
|
66
|
+
return t(e(p));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -75,74 +75,74 @@ function It() {
|
|
|
75
75
|
function o(e) {
|
|
76
76
|
try {
|
|
77
77
|
r(e);
|
|
78
|
-
var
|
|
78
|
+
var p = !1;
|
|
79
79
|
} catch {
|
|
80
|
-
|
|
80
|
+
p = !0;
|
|
81
81
|
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
return
|
|
86
|
-
|
|
82
|
+
if (p) {
|
|
83
|
+
p = console;
|
|
84
|
+
var C = p.error, T = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
85
|
+
return C.call(
|
|
86
|
+
p,
|
|
87
87
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
-
|
|
88
|
+
T
|
|
89
89
|
), r(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function n(e) {
|
|
93
|
-
if (e ===
|
|
94
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
93
|
+
if (e === x) return "<>";
|
|
94
|
+
if (typeof e == "object" && e !== null && e.$$typeof === j)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var
|
|
98
|
-
return
|
|
97
|
+
var p = t(e);
|
|
98
|
+
return p ? "<" + p + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
var e =
|
|
103
|
+
function i() {
|
|
104
|
+
var e = A.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function c() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (
|
|
112
|
-
var
|
|
113
|
-
if (
|
|
110
|
+
function a(e) {
|
|
111
|
+
if (W.call(e, "key")) {
|
|
112
|
+
var p = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
|
+
if (p && p.isReactWarning) return !1;
|
|
114
114
|
}
|
|
115
115
|
return e.key !== void 0;
|
|
116
116
|
}
|
|
117
|
-
function s(e,
|
|
118
|
-
function
|
|
119
|
-
|
|
117
|
+
function s(e, p) {
|
|
118
|
+
function C() {
|
|
119
|
+
N || (N = !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
|
+
p
|
|
122
122
|
));
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
get:
|
|
124
|
+
C.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
125
|
+
get: C,
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function f() {
|
|
130
130
|
var e = t(this.type);
|
|
131
131
|
return Y[e] || (Y[e] = !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
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
var
|
|
135
|
+
function l(e, p, C, T, et, ot) {
|
|
136
|
+
var S = C.ref;
|
|
137
137
|
return e = {
|
|
138
|
-
$$typeof:
|
|
138
|
+
$$typeof: y,
|
|
139
139
|
type: e,
|
|
140
|
-
key:
|
|
141
|
-
props:
|
|
142
|
-
_owner:
|
|
143
|
-
}, (
|
|
140
|
+
key: p,
|
|
141
|
+
props: C,
|
|
142
|
+
_owner: T
|
|
143
|
+
}, (S !== void 0 ? S : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
|
-
get:
|
|
145
|
+
get: f
|
|
146
146
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
147
|
configurable: !1,
|
|
148
148
|
enumerable: !1,
|
|
@@ -157,128 +157,128 @@ function It() {
|
|
|
157
157
|
configurable: !1,
|
|
158
158
|
enumerable: !1,
|
|
159
159
|
writable: !0,
|
|
160
|
-
value:
|
|
160
|
+
value: et
|
|
161
161
|
}), Object.defineProperty(e, "_debugTask", {
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
165
|
+
value: ot
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
var
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
for (
|
|
174
|
-
|
|
175
|
-
Object.freeze && Object.freeze(
|
|
168
|
+
function d(e, p, C, T, et, ot) {
|
|
169
|
+
var S = p.children;
|
|
170
|
+
if (S !== void 0)
|
|
171
|
+
if (T)
|
|
172
|
+
if (U(S)) {
|
|
173
|
+
for (T = 0; T < S.length; T++)
|
|
174
|
+
k(S[T]);
|
|
175
|
+
Object.freeze && Object.freeze(S);
|
|
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
|
-
|
|
183
|
-
var
|
|
180
|
+
else k(S);
|
|
181
|
+
if (W.call(p, "key")) {
|
|
182
|
+
S = t(e);
|
|
183
|
+
var L = Object.keys(p).filter(function(wt) {
|
|
184
184
|
return wt !== "key";
|
|
185
185
|
});
|
|
186
|
-
|
|
186
|
+
T = 0 < L.length ? "{key: someKey, " + L.join(": ..., ") + ": ...}" : "{key: someKey}", ct[S + T] || (L = 0 < L.length ? "{" + L.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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
),
|
|
193
|
+
T,
|
|
194
|
+
S,
|
|
195
|
+
L,
|
|
196
|
+
S
|
|
197
|
+
), ct[S + T] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
for (var st in
|
|
202
|
-
st !== "key" && (
|
|
203
|
-
} else
|
|
204
|
-
return
|
|
205
|
-
|
|
199
|
+
if (S = null, C !== void 0 && (o(C), S = "" + C), a(p) && (o(p.key), S = "" + p.key), "key" in p) {
|
|
200
|
+
C = {};
|
|
201
|
+
for (var st in p)
|
|
202
|
+
st !== "key" && (C[st] = p[st]);
|
|
203
|
+
} else C = p;
|
|
204
|
+
return S && s(
|
|
205
|
+
C,
|
|
206
206
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
|
-
),
|
|
207
|
+
), l(
|
|
208
208
|
e,
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
209
|
+
S,
|
|
210
|
+
C,
|
|
211
|
+
i(),
|
|
212
|
+
et,
|
|
213
|
+
ot
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
216
|
+
function k(e) {
|
|
217
|
+
g(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === j && (e._payload.status === "fulfilled" ? g(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
219
|
+
function g(e) {
|
|
220
|
+
return typeof e == "object" && e !== null && e.$$typeof === y;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var h = kt, y = /* @__PURE__ */ Symbol.for("react.transitional.element"), E = /* @__PURE__ */ Symbol.for("react.portal"), x = /* @__PURE__ */ Symbol.for("react.fragment"), w = /* @__PURE__ */ Symbol.for("react.strict_mode"), u = /* @__PURE__ */ Symbol.for("react.profiler"), b = /* @__PURE__ */ Symbol.for("react.consumer"), v = /* @__PURE__ */ Symbol.for("react.context"), m = /* @__PURE__ */ Symbol.for("react.forward_ref"), M = /* @__PURE__ */ Symbol.for("react.suspense"), D = /* @__PURE__ */ Symbol.for("react.suspense_list"), z = /* @__PURE__ */ Symbol.for("react.memo"), j = /* @__PURE__ */ Symbol.for("react.lazy"), _ = /* @__PURE__ */ Symbol.for("react.activity"), R = /* @__PURE__ */ Symbol.for("react.client.reference"), A = h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, W = Object.prototype.hasOwnProperty, U = Array.isArray, $ = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
h = {
|
|
226
226
|
react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)(), lt =
|
|
234
|
-
|
|
235
|
-
var
|
|
236
|
-
return
|
|
230
|
+
var N, Y = {}, X = h.react_stack_bottom_frame.bind(
|
|
231
|
+
h,
|
|
232
|
+
c
|
|
233
|
+
)(), lt = $(n(c)), ct = {};
|
|
234
|
+
q.Fragment = x, q.jsx = function(e, p, C) {
|
|
235
|
+
var T = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return d(
|
|
237
237
|
e,
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
p,
|
|
239
|
+
C,
|
|
240
240
|
!1,
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
T ? Error("react-stack-top-frame") : X,
|
|
242
|
+
T ? $(n(e)) : lt
|
|
243
243
|
);
|
|
244
|
-
},
|
|
245
|
-
var
|
|
246
|
-
return
|
|
244
|
+
}, q.jsxs = function(e, p, C) {
|
|
245
|
+
var T = 1e4 > A.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return d(
|
|
247
247
|
e,
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
p,
|
|
249
|
+
C,
|
|
250
250
|
!0,
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
T ? Error("react-stack-top-frame") : X,
|
|
252
|
+
T ? $(n(e)) : lt
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
|
-
})()),
|
|
255
|
+
})()), q;
|
|
256
256
|
}
|
|
257
257
|
var dt;
|
|
258
|
-
function
|
|
259
|
-
return dt || (dt = 1, process.env.NODE_ENV === "production" ?
|
|
258
|
+
function Rt() {
|
|
259
|
+
return dt || (dt = 1, process.env.NODE_ENV === "production" ? rt.exports = Et() : rt.exports = It()), rt.exports;
|
|
260
260
|
}
|
|
261
|
-
var
|
|
262
|
-
function
|
|
261
|
+
var I = Rt();
|
|
262
|
+
function At(t, r) {
|
|
263
263
|
const o = new Uint8Array(r);
|
|
264
264
|
for (let n = 0; n < r; n++)
|
|
265
265
|
o[n] = t[n * 4 + 3];
|
|
266
266
|
return o;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function Ct(t, r, o, n) {
|
|
269
269
|
if (r <= 0 || o <= 0) return { x: 0, y: 0, w: 1, h: 1 };
|
|
270
|
-
let
|
|
271
|
-
for (let
|
|
272
|
-
for (let
|
|
273
|
-
t[
|
|
274
|
-
return
|
|
275
|
-
x:
|
|
276
|
-
y:
|
|
277
|
-
w: (
|
|
278
|
-
h: (s -
|
|
270
|
+
let i = r, c = o, a = 0, s = 0, f = !1;
|
|
271
|
+
for (let l = 0; l < o; l++)
|
|
272
|
+
for (let d = 0; d < r; d++)
|
|
273
|
+
t[l * r + d] > n && (d < i && (i = d), d > a && (a = d), l < c && (c = l), l > s && (s = l), f = !0);
|
|
274
|
+
return f ? {
|
|
275
|
+
x: i / r,
|
|
276
|
+
y: c / o,
|
|
277
|
+
w: (a - i + 1) / r,
|
|
278
|
+
h: (s - c + 1) / o
|
|
279
279
|
} : { x: 0, y: 0, w: 1, h: 1 };
|
|
280
280
|
}
|
|
281
|
-
class
|
|
281
|
+
class _t {
|
|
282
282
|
id;
|
|
283
283
|
bounds = { x: 0, y: 0, w: 1, h: 1 };
|
|
284
284
|
/** URL of the cutout mask image */
|
|
@@ -309,19 +309,19 @@ class Ct {
|
|
|
309
309
|
*/
|
|
310
310
|
async prepare() {
|
|
311
311
|
const r = new Image();
|
|
312
|
-
r.crossOrigin = "anonymous", r.src = this.src, await new Promise((
|
|
313
|
-
r.onload = () =>
|
|
312
|
+
r.crossOrigin = "anonymous", r.src = this.src, await new Promise((a) => {
|
|
313
|
+
r.onload = () => a(), r.onerror = () => a();
|
|
314
314
|
});
|
|
315
315
|
const o = r.naturalWidth, n = r.naturalHeight;
|
|
316
316
|
if (o <= 0 || n <= 0) return;
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
317
|
+
const i = document.createElement("canvas");
|
|
318
|
+
i.width = o, i.height = n;
|
|
319
|
+
const c = i.getContext("2d", { willReadFrequently: !0 });
|
|
320
|
+
if (c)
|
|
321
321
|
try {
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
this.alpha =
|
|
322
|
+
c.drawImage(r, 0, 0);
|
|
323
|
+
const a = c.getImageData(0, 0, o, n);
|
|
324
|
+
this.alpha = At(a.data, o * n), this.width = o, this.height = n, this.bounds = Ct(this.alpha, o, n, this.threshold);
|
|
325
325
|
} catch {
|
|
326
326
|
this.alpha = new Uint8Array(0);
|
|
327
327
|
}
|
|
@@ -345,14 +345,14 @@ class Ct {
|
|
|
345
345
|
if (this.alpha.length === 0) return !1;
|
|
346
346
|
const n = this.bounds;
|
|
347
347
|
if (r < n.x || r > n.x + n.w || o < n.y || o > n.y + n.h) return !1;
|
|
348
|
-
const
|
|
348
|
+
const i = Math.min(this.width - 1, Math.max(0, Math.floor(r * this.width))), c = Math.min(
|
|
349
349
|
this.height - 1,
|
|
350
350
|
Math.max(0, Math.floor(o * this.height))
|
|
351
351
|
);
|
|
352
|
-
return this.alpha[
|
|
352
|
+
return this.alpha[c * this.width + i] > this.threshold;
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
|
-
class
|
|
355
|
+
class jt {
|
|
356
356
|
id;
|
|
357
357
|
bounds;
|
|
358
358
|
constructor(r) {
|
|
@@ -363,28 +363,28 @@ class Tt {
|
|
|
363
363
|
return r >= n.x && r <= n.x + n.w && o >= n.y && o <= n.y + n.h;
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
function
|
|
366
|
+
function Tt(t, r, o) {
|
|
367
367
|
let n = !1;
|
|
368
|
-
for (let
|
|
369
|
-
const
|
|
370
|
-
s > r !=
|
|
368
|
+
for (let i = 0, c = o.length - 1; i < o.length; c = i++) {
|
|
369
|
+
const a = o[i][0], s = o[i][1], f = o[c][0], l = o[c][1];
|
|
370
|
+
s > r != l > r && t < (f - a) * (r - s) / (l - s) + a && (n = !n);
|
|
371
371
|
}
|
|
372
372
|
return n;
|
|
373
373
|
}
|
|
374
|
-
class
|
|
374
|
+
class St {
|
|
375
375
|
id;
|
|
376
376
|
bounds;
|
|
377
377
|
points;
|
|
378
378
|
constructor(r) {
|
|
379
379
|
this.id = r.id, this.points = r.points;
|
|
380
|
-
let o = 1 / 0, n = 1 / 0,
|
|
381
|
-
for (const [
|
|
382
|
-
|
|
380
|
+
let o = 1 / 0, n = 1 / 0, i = -1 / 0, c = -1 / 0;
|
|
381
|
+
for (const [a, s] of r.points)
|
|
382
|
+
a < o && (o = a), a > i && (i = a), s < n && (n = s), s > c && (c = s);
|
|
383
383
|
this.bounds = {
|
|
384
384
|
x: o,
|
|
385
385
|
y: n,
|
|
386
|
-
w:
|
|
387
|
-
h:
|
|
386
|
+
w: i - o,
|
|
387
|
+
h: c - n
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
@@ -401,20 +401,20 @@ class jt {
|
|
|
401
401
|
*/
|
|
402
402
|
hitTest(r, o) {
|
|
403
403
|
const n = this.bounds;
|
|
404
|
-
return r < n.x || r > n.x + n.w || o < n.y || o > n.y + n.h ? !1 :
|
|
404
|
+
return r < n.x || r > n.x + n.w || o < n.y || o > n.y + n.h ? !1 : Tt(r, o, this.points);
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function Pt(t, r) {
|
|
408
408
|
switch (t.type) {
|
|
409
409
|
case "image":
|
|
410
|
-
return new
|
|
410
|
+
return new _t(t, r);
|
|
411
411
|
case "bbox":
|
|
412
|
-
return new Tt(t);
|
|
413
|
-
case "polygon":
|
|
414
412
|
return new jt(t);
|
|
413
|
+
case "polygon":
|
|
414
|
+
return new St(t);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function $t(t) {
|
|
418
418
|
switch (t.type) {
|
|
419
419
|
case "image":
|
|
420
420
|
return `${t.id}:image:${t.src}:${t.label ?? ""}`;
|
|
@@ -425,102 +425,102 @@ function Pt(t) {
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
function Mt(t, r = !0, o = 30, n = 150) {
|
|
428
|
-
const [
|
|
429
|
-
|
|
430
|
-
|
|
428
|
+
const [i, c] = F(null), [a, s] = F(null), f = V(null), l = V([]), [d, k] = F({}), g = Math.min(255, Math.max(0, o)), h = V(null), y = P(() => {
|
|
429
|
+
h.current === null && (h.current = setTimeout(() => {
|
|
430
|
+
h.current = null, c(null);
|
|
431
431
|
}, n));
|
|
432
|
-
}, [n]),
|
|
433
|
-
|
|
434
|
-
}, []),
|
|
435
|
-
|
|
432
|
+
}, [n]), E = P(() => {
|
|
433
|
+
h.current !== null && (clearTimeout(h.current), h.current = null);
|
|
434
|
+
}, []), x = t.map($t).join("|"), w = B(() => t, [x]);
|
|
435
|
+
O(() => {
|
|
436
436
|
if (!r) {
|
|
437
|
-
|
|
437
|
+
l.current = [];
|
|
438
438
|
return;
|
|
439
439
|
}
|
|
440
|
-
let
|
|
441
|
-
async function
|
|
442
|
-
const
|
|
443
|
-
for (const
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
|
|
440
|
+
let j = !1, _ = [];
|
|
441
|
+
async function R() {
|
|
442
|
+
const A = [], W = {};
|
|
443
|
+
for (const U of w) {
|
|
444
|
+
const $ = Pt(U, g);
|
|
445
|
+
if ($.prepare && await $.prepare(), j) return;
|
|
446
|
+
A.push($), W[$.id] = $.bounds;
|
|
447
447
|
}
|
|
448
|
-
|
|
448
|
+
j || (_ = A, l.current = A, k(W));
|
|
449
449
|
}
|
|
450
|
-
return
|
|
451
|
-
|
|
452
|
-
for (const
|
|
453
|
-
|
|
450
|
+
return R(), () => {
|
|
451
|
+
j = !0;
|
|
452
|
+
for (const A of _)
|
|
453
|
+
A.dispose?.();
|
|
454
454
|
};
|
|
455
|
-
}, [
|
|
456
|
-
const
|
|
457
|
-
(
|
|
458
|
-
const
|
|
459
|
-
for (let
|
|
460
|
-
if (
|
|
461
|
-
return
|
|
455
|
+
}, [w, r, g]);
|
|
456
|
+
const u = P(
|
|
457
|
+
(j, _) => {
|
|
458
|
+
const R = l.current;
|
|
459
|
+
for (let A = R.length - 1; A >= 0; A--)
|
|
460
|
+
if (R[A].hitTest(j, _))
|
|
461
|
+
return R[A].id;
|
|
462
462
|
return null;
|
|
463
463
|
},
|
|
464
464
|
[]
|
|
465
|
-
),
|
|
466
|
-
(
|
|
467
|
-
const
|
|
468
|
-
if (!
|
|
469
|
-
const
|
|
470
|
-
return
|
|
465
|
+
), b = P(
|
|
466
|
+
(j) => {
|
|
467
|
+
const _ = f.current;
|
|
468
|
+
if (!_) return null;
|
|
469
|
+
const R = _.getBoundingClientRect(), A = (j.clientX - R.left) / R.width, W = (j.clientY - R.top) / R.height;
|
|
470
|
+
return A < 0 || A > 1 || W < 0 || W > 1 ? null : { nx: A, ny: W };
|
|
471
471
|
},
|
|
472
472
|
[]
|
|
473
|
-
),
|
|
474
|
-
(
|
|
473
|
+
), v = P(
|
|
474
|
+
(j) => {
|
|
475
475
|
if (!r) return;
|
|
476
|
-
const
|
|
477
|
-
if (!
|
|
478
|
-
|
|
476
|
+
const _ = b(j);
|
|
477
|
+
if (!_) {
|
|
478
|
+
y();
|
|
479
479
|
return;
|
|
480
480
|
}
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
if (
|
|
484
|
-
|
|
481
|
+
const R = u(_.nx, _.ny);
|
|
482
|
+
if (R === null) {
|
|
483
|
+
if (j.target?.closest('[data-cutout-overlay="true"]')) {
|
|
484
|
+
E();
|
|
485
485
|
return;
|
|
486
486
|
}
|
|
487
|
-
|
|
487
|
+
y();
|
|
488
488
|
return;
|
|
489
489
|
}
|
|
490
|
-
|
|
490
|
+
E(), c(R);
|
|
491
491
|
},
|
|
492
|
-
[r,
|
|
493
|
-
),
|
|
494
|
-
|
|
495
|
-
}, [
|
|
496
|
-
(
|
|
492
|
+
[r, b, u, y, E]
|
|
493
|
+
), m = P(() => {
|
|
494
|
+
y();
|
|
495
|
+
}, [y]), M = P(
|
|
496
|
+
(j) => {
|
|
497
497
|
if (!r) return;
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
498
|
+
const _ = b(j);
|
|
499
|
+
if (!_) {
|
|
500
500
|
s(null);
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
|
-
const
|
|
504
|
-
s(
|
|
503
|
+
const R = u(_.nx, _.ny);
|
|
504
|
+
s(R === a || R === null ? null : R);
|
|
505
505
|
},
|
|
506
|
-
[r,
|
|
507
|
-
),
|
|
508
|
-
return
|
|
509
|
-
|
|
510
|
-
}, [
|
|
511
|
-
hoveredId:
|
|
512
|
-
selectedId:
|
|
513
|
-
activeId:
|
|
506
|
+
[r, b, u, a]
|
|
507
|
+
), D = a ?? i, z = r ? d : {};
|
|
508
|
+
return O(() => () => {
|
|
509
|
+
E();
|
|
510
|
+
}, [E]), {
|
|
511
|
+
hoveredId: i,
|
|
512
|
+
selectedId: a,
|
|
513
|
+
activeId: D,
|
|
514
514
|
boundsMap: z,
|
|
515
|
-
containerRef:
|
|
515
|
+
containerRef: f,
|
|
516
516
|
containerProps: {
|
|
517
|
-
onPointerMove:
|
|
518
|
-
onPointerLeave:
|
|
517
|
+
onPointerMove: v,
|
|
518
|
+
onPointerLeave: m,
|
|
519
519
|
onClick: M
|
|
520
520
|
}
|
|
521
521
|
};
|
|
522
522
|
}
|
|
523
|
-
function
|
|
523
|
+
function at(t, r) {
|
|
524
524
|
return { name: t, css: r };
|
|
525
525
|
}
|
|
526
526
|
const pt = /* @__PURE__ */ new Set();
|
|
@@ -535,9 +535,9 @@ ${r.css}
|
|
|
535
535
|
}`, document.head.appendChild(o);
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
|
-
const
|
|
538
|
+
const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
539
539
|
name: "elevate",
|
|
540
|
-
transition:
|
|
540
|
+
transition: K,
|
|
541
541
|
mainImageHovered: {
|
|
542
542
|
filter: "brightness(0.45) saturate(0.7)"
|
|
543
543
|
},
|
|
@@ -575,9 +575,9 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
575
575
|
stroke: "transparent",
|
|
576
576
|
strokeWidth: 1
|
|
577
577
|
}
|
|
578
|
-
},
|
|
578
|
+
}, Dt = {
|
|
579
579
|
name: "glow",
|
|
580
|
-
transition:
|
|
580
|
+
transition: K,
|
|
581
581
|
mainImageHovered: {
|
|
582
582
|
filter: "brightness(0.55) saturate(0.8)"
|
|
583
583
|
},
|
|
@@ -615,9 +615,9 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
615
615
|
stroke: "transparent",
|
|
616
616
|
strokeWidth: 1
|
|
617
617
|
}
|
|
618
|
-
},
|
|
618
|
+
}, Nt = {
|
|
619
619
|
name: "lift",
|
|
620
|
-
transition:
|
|
620
|
+
transition: K,
|
|
621
621
|
mainImageHovered: {
|
|
622
622
|
filter: "brightness(0.4)"
|
|
623
623
|
},
|
|
@@ -655,7 +655,7 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
655
655
|
stroke: "transparent",
|
|
656
656
|
strokeWidth: 1
|
|
657
657
|
}
|
|
658
|
-
},
|
|
658
|
+
}, Yt = {
|
|
659
659
|
name: "subtle",
|
|
660
660
|
transition: "all 0.3s ease",
|
|
661
661
|
mainImageHovered: {
|
|
@@ -694,11 +694,11 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
694
694
|
stroke: "transparent",
|
|
695
695
|
strokeWidth: 1
|
|
696
696
|
}
|
|
697
|
-
}, ht =
|
|
697
|
+
}, ht = at(
|
|
698
698
|
"_ricut-trace-stroke",
|
|
699
699
|
`from { stroke-dashoffset: 0; }
|
|
700
700
|
to { stroke-dashoffset: -1; }`
|
|
701
|
-
), gt =
|
|
701
|
+
), gt = at(
|
|
702
702
|
"_ricut-trace-glow",
|
|
703
703
|
`0% { filter: drop-shadow(-3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
|
|
704
704
|
25% { filter: drop-shadow(3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
|
|
@@ -707,7 +707,7 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
707
707
|
100% { filter: drop-shadow(-3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }`
|
|
708
708
|
), Vt = {
|
|
709
709
|
name: "trace",
|
|
710
|
-
transition:
|
|
710
|
+
transition: K,
|
|
711
711
|
keyframes: [ht, gt],
|
|
712
712
|
mainImageHovered: {
|
|
713
713
|
filter: "brightness(0.35) saturate(0.5)"
|
|
@@ -749,7 +749,7 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
749
749
|
stroke: "transparent",
|
|
750
750
|
strokeWidth: 1
|
|
751
751
|
}
|
|
752
|
-
}, mt =
|
|
752
|
+
}, mt = at(
|
|
753
753
|
"_ricut-shimmer",
|
|
754
754
|
`0%, 100% {
|
|
755
755
|
filter: brightness(1.05) contrast(1.02)
|
|
@@ -766,9 +766,9 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
766
766
|
drop-shadow(0 0 6px rgba(255, 255, 255, 0.12))
|
|
767
767
|
drop-shadow(0 12px 32px rgba(0, 0, 0, 0.4));
|
|
768
768
|
}`
|
|
769
|
-
),
|
|
769
|
+
), Bt = {
|
|
770
770
|
name: "shimmer",
|
|
771
|
-
transition:
|
|
771
|
+
transition: K,
|
|
772
772
|
keyframes: [mt],
|
|
773
773
|
mainImageHovered: {
|
|
774
774
|
filter: "brightness(0.35) saturate(0.6)"
|
|
@@ -810,48 +810,48 @@ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
810
810
|
stroke: "transparent",
|
|
811
811
|
strokeWidth: 1
|
|
812
812
|
}
|
|
813
|
-
},
|
|
813
|
+
}, J = {
|
|
814
814
|
elevate: Ot,
|
|
815
|
-
glow:
|
|
816
|
-
lift:
|
|
817
|
-
subtle:
|
|
815
|
+
glow: Dt,
|
|
816
|
+
lift: Nt,
|
|
817
|
+
subtle: Yt,
|
|
818
818
|
trace: Vt,
|
|
819
|
-
shimmer:
|
|
820
|
-
},
|
|
821
|
-
function
|
|
822
|
-
const t =
|
|
819
|
+
shimmer: Bt
|
|
820
|
+
}, Z = it(null), xt = it(null);
|
|
821
|
+
function nt() {
|
|
822
|
+
const t = H(xt);
|
|
823
823
|
if (!t) throw new Error("Must be used inside <CutoutViewer>");
|
|
824
824
|
return t;
|
|
825
825
|
}
|
|
826
|
-
const
|
|
827
|
-
function
|
|
828
|
-
const t =
|
|
826
|
+
const Q = it(null);
|
|
827
|
+
function Kt() {
|
|
828
|
+
const t = H(Q);
|
|
829
829
|
if (!t)
|
|
830
830
|
throw new Error("useCutout must be used inside <CutoutViewer.Cutout>");
|
|
831
831
|
return t;
|
|
832
832
|
}
|
|
833
|
-
function
|
|
834
|
-
const
|
|
835
|
-
if (!
|
|
833
|
+
function Ht({ id: t, src: r, label: o, effect: n, children: i, renderLayer: c }) {
|
|
834
|
+
const a = H(Z), s = nt();
|
|
835
|
+
if (!a)
|
|
836
836
|
throw new Error("<CutoutViewer.Cutout> must be used inside <CutoutViewer>");
|
|
837
|
-
|
|
838
|
-
const
|
|
839
|
-
let
|
|
840
|
-
!s.enabled || !s.isAnyActive && !s.showAll ?
|
|
841
|
-
const
|
|
837
|
+
O(() => (a.registerCutout({ type: "image", id: t, src: r, label: o }), () => a.unregisterCutout(t)), [t, r, o, a]);
|
|
838
|
+
const f = n ? typeof n == "string" ? J[n] ?? s.effect : n : s.effect, l = s.activeId === t, d = s.hoveredId === t, k = s.selectedId === t, g = { x: 0, y: 0, w: 1, h: 1 }, h = s.boundsMap[t] ?? g;
|
|
839
|
+
let y;
|
|
840
|
+
!s.enabled || !s.isAnyActive && !s.showAll ? y = f.cutoutIdle : s.showAll || l ? y = f.cutoutActive : y = f.cutoutInactive;
|
|
841
|
+
const E = B(
|
|
842
842
|
() => ({
|
|
843
843
|
id: t,
|
|
844
844
|
label: o,
|
|
845
|
-
bounds:
|
|
846
|
-
isActive:
|
|
847
|
-
isHovered:
|
|
848
|
-
isSelected:
|
|
849
|
-
effect:
|
|
845
|
+
bounds: h,
|
|
846
|
+
isActive: l,
|
|
847
|
+
isHovered: d,
|
|
848
|
+
isSelected: k,
|
|
849
|
+
effect: f
|
|
850
850
|
}),
|
|
851
|
-
[t, o,
|
|
851
|
+
[t, o, h, l, d, k, f]
|
|
852
852
|
);
|
|
853
|
-
return /* @__PURE__ */
|
|
854
|
-
/* @__PURE__ */
|
|
853
|
+
return /* @__PURE__ */ I.jsxs(Q.Provider, { value: E, children: [
|
|
854
|
+
/* @__PURE__ */ I.jsx(
|
|
855
855
|
"div",
|
|
856
856
|
{
|
|
857
857
|
"data-cutout-id": t,
|
|
@@ -859,11 +859,11 @@ function Bt({ id: t, src: r, label: o, effect: n, children: a, renderLayer: l })
|
|
|
859
859
|
pointerEvents: "none",
|
|
860
860
|
position: "absolute",
|
|
861
861
|
inset: 0,
|
|
862
|
-
zIndex:
|
|
863
|
-
transition:
|
|
864
|
-
...
|
|
862
|
+
zIndex: l ? 20 : 10,
|
|
863
|
+
transition: f.transition,
|
|
864
|
+
...y
|
|
865
865
|
},
|
|
866
|
-
children:
|
|
866
|
+
children: c ? c({ isActive: l, isHovered: d, isSelected: k, bounds: h, effect: f }) : /* @__PURE__ */ I.jsx(
|
|
867
867
|
"img",
|
|
868
868
|
{
|
|
869
869
|
src: r,
|
|
@@ -879,49 +879,49 @@ function Bt({ id: t, src: r, label: o, effect: n, children: a, renderLayer: l })
|
|
|
879
879
|
)
|
|
880
880
|
}
|
|
881
881
|
),
|
|
882
|
-
|
|
882
|
+
i
|
|
883
883
|
] });
|
|
884
884
|
}
|
|
885
|
-
function
|
|
885
|
+
function yt(t) {
|
|
886
886
|
const { filter: r, ...o } = t;
|
|
887
887
|
return o;
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function Lt({
|
|
890
890
|
id: t,
|
|
891
891
|
bounds: r,
|
|
892
892
|
label: o,
|
|
893
893
|
effect: n,
|
|
894
|
-
children:
|
|
895
|
-
renderLayer:
|
|
894
|
+
children: i,
|
|
895
|
+
renderLayer: c
|
|
896
896
|
}) {
|
|
897
|
-
const
|
|
898
|
-
if (!
|
|
897
|
+
const a = H(Z), s = nt();
|
|
898
|
+
if (!a)
|
|
899
899
|
throw new Error(
|
|
900
900
|
"<CutoutViewer.BBoxCutout> must be used inside <CutoutViewer>"
|
|
901
901
|
);
|
|
902
|
-
const { x:
|
|
903
|
-
|
|
904
|
-
const
|
|
905
|
-
let
|
|
906
|
-
!s.enabled || !s.isAnyActive && !s.showAll ? (
|
|
907
|
-
const
|
|
902
|
+
const { x: f, y: l, w: d, h: k } = r;
|
|
903
|
+
O(() => (a.registerCutout({ type: "bbox", id: t, bounds: { x: f, y: l, w: d, h: k }, label: o }), () => a.unregisterCutout(t)), [t, f, l, d, k, o, a]);
|
|
904
|
+
const g = n ? typeof n == "string" ? J[n] ?? s.effect : n : s.effect, h = s.activeId === t, y = s.hoveredId === t, E = s.selectedId === t, x = { x: 0, y: 0, w: 1, h: 1 }, w = s.boundsMap[t] ?? x;
|
|
905
|
+
let u, b;
|
|
906
|
+
!s.enabled || !s.isAnyActive && !s.showAll ? (b = { ...g.cutoutIdle, filter: "none", opacity: 0 }, u = g.geometryIdle) : s.showAll || h ? (b = yt(g.cutoutActive), u = g.geometryActive) : (b = yt(g.cutoutInactive), u = g.geometryInactive);
|
|
907
|
+
const m = u ?? {
|
|
908
908
|
fill: "rgba(37, 99, 235, 0.15)",
|
|
909
909
|
stroke: "rgba(37, 99, 235, 0.6)",
|
|
910
910
|
strokeWidth: 2
|
|
911
|
-
}, M =
|
|
911
|
+
}, M = B(
|
|
912
912
|
() => ({
|
|
913
913
|
id: t,
|
|
914
914
|
label: o,
|
|
915
|
-
bounds:
|
|
916
|
-
isActive:
|
|
917
|
-
isHovered:
|
|
918
|
-
isSelected:
|
|
919
|
-
effect:
|
|
915
|
+
bounds: w,
|
|
916
|
+
isActive: h,
|
|
917
|
+
isHovered: y,
|
|
918
|
+
isSelected: E,
|
|
919
|
+
effect: g
|
|
920
920
|
}),
|
|
921
|
-
[t, o,
|
|
921
|
+
[t, o, w, h, y, E, g]
|
|
922
922
|
);
|
|
923
|
-
return /* @__PURE__ */
|
|
924
|
-
/* @__PURE__ */
|
|
923
|
+
return /* @__PURE__ */ I.jsxs(Q.Provider, { value: M, children: [
|
|
924
|
+
/* @__PURE__ */ I.jsx(
|
|
925
925
|
"div",
|
|
926
926
|
{
|
|
927
927
|
"data-cutout-id": t,
|
|
@@ -929,11 +929,11 @@ function Ft({
|
|
|
929
929
|
pointerEvents: "none",
|
|
930
930
|
position: "absolute",
|
|
931
931
|
inset: 0,
|
|
932
|
-
zIndex:
|
|
933
|
-
transition:
|
|
934
|
-
...
|
|
932
|
+
zIndex: h ? 20 : 10,
|
|
933
|
+
transition: g.transition,
|
|
934
|
+
...b
|
|
935
935
|
},
|
|
936
|
-
children:
|
|
936
|
+
children: c ? c({ isActive: h, isHovered: y, isSelected: E, bounds: w, effect: g }) : /* @__PURE__ */ I.jsx(
|
|
937
937
|
"svg",
|
|
938
938
|
{
|
|
939
939
|
viewBox: "0 0 1 1",
|
|
@@ -944,25 +944,25 @@ function Ft({
|
|
|
944
944
|
width: "100%",
|
|
945
945
|
height: "100%",
|
|
946
946
|
overflow: "visible",
|
|
947
|
-
filter:
|
|
947
|
+
filter: m.glow ? `drop-shadow(${m.glow.split(",")[0]?.trim() ?? ""})` : "none"
|
|
948
948
|
},
|
|
949
|
-
children: /* @__PURE__ */
|
|
949
|
+
children: /* @__PURE__ */ I.jsx(
|
|
950
950
|
"rect",
|
|
951
951
|
{
|
|
952
|
-
x:
|
|
953
|
-
y:
|
|
954
|
-
width:
|
|
955
|
-
height:
|
|
952
|
+
x: w.x,
|
|
953
|
+
y: w.y,
|
|
954
|
+
width: w.w,
|
|
955
|
+
height: w.h,
|
|
956
956
|
rx: 4e-3,
|
|
957
|
-
fill:
|
|
958
|
-
stroke:
|
|
959
|
-
strokeWidth: (
|
|
960
|
-
strokeLinecap:
|
|
961
|
-
strokeDasharray:
|
|
962
|
-
pathLength:
|
|
957
|
+
fill: m.fill,
|
|
958
|
+
stroke: m.stroke,
|
|
959
|
+
strokeWidth: (m.strokeWidth ?? 2) * 15e-4,
|
|
960
|
+
strokeLinecap: m.strokeDasharray ? "round" : void 0,
|
|
961
|
+
strokeDasharray: m.strokeDasharray,
|
|
962
|
+
pathLength: m.strokeDasharray ? 1 : void 0,
|
|
963
963
|
style: {
|
|
964
|
-
transition:
|
|
965
|
-
animation:
|
|
964
|
+
transition: g.transition,
|
|
965
|
+
animation: m.animation
|
|
966
966
|
}
|
|
967
967
|
}
|
|
968
968
|
)
|
|
@@ -970,49 +970,49 @@ function Ft({
|
|
|
970
970
|
)
|
|
971
971
|
}
|
|
972
972
|
),
|
|
973
|
-
|
|
973
|
+
i
|
|
974
974
|
] });
|
|
975
975
|
}
|
|
976
|
-
function
|
|
976
|
+
function bt(t) {
|
|
977
977
|
const { filter: r, ...o } = t;
|
|
978
978
|
return o;
|
|
979
979
|
}
|
|
980
|
-
function
|
|
980
|
+
function Ft({
|
|
981
981
|
id: t,
|
|
982
982
|
points: r,
|
|
983
983
|
label: o,
|
|
984
984
|
effect: n,
|
|
985
|
-
children:
|
|
986
|
-
renderLayer:
|
|
985
|
+
children: i,
|
|
986
|
+
renderLayer: c
|
|
987
987
|
}) {
|
|
988
|
-
const
|
|
989
|
-
if (!
|
|
988
|
+
const a = H(Z), s = nt();
|
|
989
|
+
if (!a)
|
|
990
990
|
throw new Error(
|
|
991
991
|
"<CutoutViewer.PolygonCutout> must be used inside <CutoutViewer>"
|
|
992
992
|
);
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
const
|
|
996
|
-
let
|
|
997
|
-
!s.enabled || !s.isAnyActive && !s.showAll ? (
|
|
998
|
-
const
|
|
993
|
+
const f = r.flat().join(",");
|
|
994
|
+
O(() => (a.registerCutout({ type: "polygon", id: t, points: r, label: o }), () => a.unregisterCutout(t)), [t, f, o, a]);
|
|
995
|
+
const l = n ? typeof n == "string" ? J[n] ?? s.effect : n : s.effect, d = s.activeId === t, k = s.hoveredId === t, g = s.selectedId === t, h = { x: 0, y: 0, w: 1, h: 1 }, y = s.boundsMap[t] ?? h;
|
|
996
|
+
let E, x;
|
|
997
|
+
!s.enabled || !s.isAnyActive && !s.showAll ? (x = { ...l.cutoutIdle, filter: "none", opacity: 0 }, E = l.geometryIdle) : s.showAll || d ? (x = bt(l.cutoutActive), E = l.geometryActive) : (x = bt(l.cutoutInactive), E = l.geometryInactive);
|
|
998
|
+
const u = E ?? {
|
|
999
999
|
fill: "rgba(37, 99, 235, 0.15)",
|
|
1000
1000
|
stroke: "rgba(37, 99, 235, 0.6)",
|
|
1001
1001
|
strokeWidth: 2
|
|
1002
|
-
},
|
|
1002
|
+
}, b = B(
|
|
1003
1003
|
() => ({
|
|
1004
1004
|
id: t,
|
|
1005
1005
|
label: o,
|
|
1006
|
-
bounds:
|
|
1007
|
-
isActive:
|
|
1008
|
-
isHovered:
|
|
1009
|
-
isSelected:
|
|
1010
|
-
effect:
|
|
1006
|
+
bounds: y,
|
|
1007
|
+
isActive: d,
|
|
1008
|
+
isHovered: k,
|
|
1009
|
+
isSelected: g,
|
|
1010
|
+
effect: l
|
|
1011
1011
|
}),
|
|
1012
|
-
[t, o,
|
|
1012
|
+
[t, o, y, d, k, g, l]
|
|
1013
1013
|
);
|
|
1014
|
-
return /* @__PURE__ */
|
|
1015
|
-
/* @__PURE__ */
|
|
1014
|
+
return /* @__PURE__ */ I.jsxs(Q.Provider, { value: b, children: [
|
|
1015
|
+
/* @__PURE__ */ I.jsx(
|
|
1016
1016
|
"div",
|
|
1017
1017
|
{
|
|
1018
1018
|
"data-cutout-id": t,
|
|
@@ -1020,11 +1020,11 @@ function zt({
|
|
|
1020
1020
|
pointerEvents: "none",
|
|
1021
1021
|
position: "absolute",
|
|
1022
1022
|
inset: 0,
|
|
1023
|
-
zIndex:
|
|
1024
|
-
transition:
|
|
1025
|
-
...
|
|
1023
|
+
zIndex: d ? 20 : 10,
|
|
1024
|
+
transition: l.transition,
|
|
1025
|
+
...x
|
|
1026
1026
|
},
|
|
1027
|
-
children:
|
|
1027
|
+
children: c ? c({ isActive: d, isHovered: k, isSelected: g, bounds: y, effect: l }) : /* @__PURE__ */ I.jsx(
|
|
1028
1028
|
"svg",
|
|
1029
1029
|
{
|
|
1030
1030
|
viewBox: "0 0 1 1",
|
|
@@ -1035,22 +1035,22 @@ function zt({
|
|
|
1035
1035
|
width: "100%",
|
|
1036
1036
|
height: "100%",
|
|
1037
1037
|
overflow: "visible",
|
|
1038
|
-
filter:
|
|
1038
|
+
filter: u.glow ? `drop-shadow(${u.glow.split(",")[0]?.trim() ?? ""})` : "none"
|
|
1039
1039
|
},
|
|
1040
|
-
children: /* @__PURE__ */
|
|
1040
|
+
children: /* @__PURE__ */ I.jsx(
|
|
1041
1041
|
"polygon",
|
|
1042
1042
|
{
|
|
1043
|
-
points: r.map(([
|
|
1044
|
-
fill:
|
|
1045
|
-
stroke:
|
|
1046
|
-
strokeWidth: (
|
|
1043
|
+
points: r.map(([v, m]) => `${v},${m}`).join(" "),
|
|
1044
|
+
fill: u.fill,
|
|
1045
|
+
stroke: u.stroke,
|
|
1046
|
+
strokeWidth: (u.strokeWidth ?? 2) * 15e-4,
|
|
1047
1047
|
strokeLinejoin: "round",
|
|
1048
|
-
strokeLinecap:
|
|
1049
|
-
strokeDasharray:
|
|
1050
|
-
pathLength:
|
|
1048
|
+
strokeLinecap: u.strokeDasharray ? "round" : void 0,
|
|
1049
|
+
strokeDasharray: u.strokeDasharray,
|
|
1050
|
+
pathLength: u.strokeDasharray ? 1 : void 0,
|
|
1051
1051
|
style: {
|
|
1052
|
-
transition:
|
|
1053
|
-
animation:
|
|
1052
|
+
transition: l.transition,
|
|
1053
|
+
animation: u.animation
|
|
1054
1054
|
}
|
|
1055
1055
|
}
|
|
1056
1056
|
)
|
|
@@ -1058,19 +1058,19 @@ function zt({
|
|
|
1058
1058
|
)
|
|
1059
1059
|
}
|
|
1060
1060
|
),
|
|
1061
|
-
|
|
1061
|
+
i
|
|
1062
1062
|
] });
|
|
1063
1063
|
}
|
|
1064
|
-
function
|
|
1065
|
-
const { x: o, y: n, w:
|
|
1066
|
-
let
|
|
1067
|
-
t.includes("left") ? (
|
|
1068
|
-
let
|
|
1069
|
-
return t.startsWith("top") ? (
|
|
1064
|
+
function zt(t, r) {
|
|
1065
|
+
const { x: o, y: n, w: i, h: c } = r;
|
|
1066
|
+
let a, s;
|
|
1067
|
+
t.includes("left") ? (a = `${o * 100}%`, s = "0") : t.includes("right") ? (a = `${(o + i) * 100}%`, s = "-100%") : (a = `${(o + i / 2) * 100}%`, s = "-50%");
|
|
1068
|
+
let f, l;
|
|
1069
|
+
return t.startsWith("top") ? (f = `${n * 100}%`, l = "-100%") : t.startsWith("bottom") ? (f = `${(n + c) * 100}%`, l = "0") : (f = `${(n + c / 2) * 100}%`, l = "-50%"), {
|
|
1070
1070
|
position: "absolute",
|
|
1071
|
-
left:
|
|
1072
|
-
top:
|
|
1073
|
-
transform: `translate(${s}, ${
|
|
1071
|
+
left: a,
|
|
1072
|
+
top: f,
|
|
1073
|
+
transform: `translate(${s}, ${l})`
|
|
1074
1074
|
};
|
|
1075
1075
|
}
|
|
1076
1076
|
function Ut({
|
|
@@ -1079,22 +1079,22 @@ function Ut({
|
|
|
1079
1079
|
className: o = "",
|
|
1080
1080
|
style: n
|
|
1081
1081
|
}) {
|
|
1082
|
-
const
|
|
1083
|
-
if (!
|
|
1082
|
+
const i = H(Q), c = nt();
|
|
1083
|
+
if (!i)
|
|
1084
1084
|
throw new Error(
|
|
1085
1085
|
"<CutoutViewer.Overlay> must be used inside <CutoutViewer.Cutout>"
|
|
1086
1086
|
);
|
|
1087
|
-
const
|
|
1088
|
-
return /* @__PURE__ */
|
|
1087
|
+
const a = c.enabled && (c.showAll || i.isActive), s = zt(t, i.bounds);
|
|
1088
|
+
return /* @__PURE__ */ I.jsx(
|
|
1089
1089
|
"div",
|
|
1090
1090
|
{
|
|
1091
1091
|
"data-cutout-overlay": "true",
|
|
1092
1092
|
className: o,
|
|
1093
1093
|
style: {
|
|
1094
1094
|
zIndex: 30,
|
|
1095
|
-
transition:
|
|
1096
|
-
opacity:
|
|
1097
|
-
pointerEvents:
|
|
1095
|
+
transition: i.effect.transition,
|
|
1096
|
+
opacity: a ? 1 : 0,
|
|
1097
|
+
pointerEvents: a ? "auto" : "none",
|
|
1098
1098
|
...s,
|
|
1099
1099
|
...n
|
|
1100
1100
|
},
|
|
@@ -1102,6 +1102,200 @@ function Ut({
|
|
|
1102
1102
|
}
|
|
1103
1103
|
);
|
|
1104
1104
|
}
|
|
1105
|
+
function Xt({
|
|
1106
|
+
onComplete: t,
|
|
1107
|
+
minPoints: r = 3,
|
|
1108
|
+
closeThreshold: o = 0.03
|
|
1109
|
+
}) {
|
|
1110
|
+
const [n, i] = F([]), [c, a] = F(null), s = V(null), f = P(
|
|
1111
|
+
(u, b) => {
|
|
1112
|
+
const v = s.current;
|
|
1113
|
+
if (!v) return null;
|
|
1114
|
+
const m = v.getBoundingClientRect(), M = (u - m.left) / m.width, D = (b - m.top) / m.height;
|
|
1115
|
+
return M < 0 || M > 1 || D < 0 || D > 1 ? null : [M, D];
|
|
1116
|
+
},
|
|
1117
|
+
[]
|
|
1118
|
+
), l = P(
|
|
1119
|
+
(u, b) => {
|
|
1120
|
+
if (b.length < r) return !1;
|
|
1121
|
+
const v = u[0] - b[0][0], m = u[1] - b[0][1];
|
|
1122
|
+
return Math.sqrt(v * v + m * m) < o;
|
|
1123
|
+
},
|
|
1124
|
+
[r, o]
|
|
1125
|
+
), d = P(
|
|
1126
|
+
(u) => {
|
|
1127
|
+
u.length < r || (t(u), i([]), a(null));
|
|
1128
|
+
},
|
|
1129
|
+
[t, r]
|
|
1130
|
+
), k = P(() => {
|
|
1131
|
+
i([]), a(null);
|
|
1132
|
+
}, []), g = P(
|
|
1133
|
+
(u) => {
|
|
1134
|
+
a(f(u.clientX, u.clientY));
|
|
1135
|
+
},
|
|
1136
|
+
[f]
|
|
1137
|
+
), h = P(() => {
|
|
1138
|
+
a(null);
|
|
1139
|
+
}, []), y = P(
|
|
1140
|
+
(u) => {
|
|
1141
|
+
u.stopPropagation();
|
|
1142
|
+
const b = f(u.clientX, u.clientY);
|
|
1143
|
+
b && i((v) => l(b, v) ? (d(v), []) : [...v, b]);
|
|
1144
|
+
},
|
|
1145
|
+
[f, l, d]
|
|
1146
|
+
), E = P(
|
|
1147
|
+
(u) => {
|
|
1148
|
+
u.stopPropagation(), i((b) => {
|
|
1149
|
+
const v = b.slice(0, -1);
|
|
1150
|
+
return v.length >= r ? (d(v), []) : v;
|
|
1151
|
+
});
|
|
1152
|
+
},
|
|
1153
|
+
[r, d]
|
|
1154
|
+
), x = P(
|
|
1155
|
+
(u) => {
|
|
1156
|
+
u.preventDefault(), i((b) => b.slice(0, -1));
|
|
1157
|
+
},
|
|
1158
|
+
[]
|
|
1159
|
+
), w = c !== null && l(c, n);
|
|
1160
|
+
return {
|
|
1161
|
+
points: n,
|
|
1162
|
+
previewPoint: c,
|
|
1163
|
+
willClose: w,
|
|
1164
|
+
reset: k,
|
|
1165
|
+
containerRef: s,
|
|
1166
|
+
containerProps: {
|
|
1167
|
+
onPointerMove: g,
|
|
1168
|
+
onPointerLeave: h,
|
|
1169
|
+
onClick: y,
|
|
1170
|
+
onDoubleClick: E,
|
|
1171
|
+
onContextMenu: x
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
function Gt({
|
|
1176
|
+
onComplete: t,
|
|
1177
|
+
minPoints: r = 3,
|
|
1178
|
+
closeThreshold: o = 0.03,
|
|
1179
|
+
strokeColor: n = "#3b82f6",
|
|
1180
|
+
enabled: i = !0,
|
|
1181
|
+
style: c,
|
|
1182
|
+
className: a = ""
|
|
1183
|
+
}) {
|
|
1184
|
+
if (!H(Z))
|
|
1185
|
+
throw new Error(
|
|
1186
|
+
"<CutoutViewer.DrawPolygon> must be used inside <CutoutViewer>"
|
|
1187
|
+
);
|
|
1188
|
+
const {
|
|
1189
|
+
points: f,
|
|
1190
|
+
previewPoint: l,
|
|
1191
|
+
willClose: d,
|
|
1192
|
+
reset: k,
|
|
1193
|
+
containerRef: g,
|
|
1194
|
+
containerProps: h
|
|
1195
|
+
} = Xt({ onComplete: t, minPoints: r, closeThreshold: o });
|
|
1196
|
+
O(() => {
|
|
1197
|
+
function x(w) {
|
|
1198
|
+
w.key === "Escape" && k();
|
|
1199
|
+
}
|
|
1200
|
+
return document.addEventListener("keydown", x), () => document.removeEventListener("keydown", x);
|
|
1201
|
+
}, [k]), O(() => {
|
|
1202
|
+
i || k();
|
|
1203
|
+
}, [i, k]);
|
|
1204
|
+
const y = l ? [...f, l] : f, E = y.map(([x, w]) => `${x},${w}`).join(" ");
|
|
1205
|
+
return /* @__PURE__ */ I.jsx(
|
|
1206
|
+
"div",
|
|
1207
|
+
{
|
|
1208
|
+
ref: g,
|
|
1209
|
+
"data-draw-polygon": "true",
|
|
1210
|
+
className: a,
|
|
1211
|
+
style: {
|
|
1212
|
+
position: "absolute",
|
|
1213
|
+
inset: 0,
|
|
1214
|
+
cursor: i ? d ? "cell" : "crosshair" : "default",
|
|
1215
|
+
zIndex: 30,
|
|
1216
|
+
pointerEvents: i ? "auto" : "none",
|
|
1217
|
+
...c
|
|
1218
|
+
},
|
|
1219
|
+
...i ? h : {},
|
|
1220
|
+
children: f.length > 0 && /* @__PURE__ */ I.jsxs(
|
|
1221
|
+
"svg",
|
|
1222
|
+
{
|
|
1223
|
+
viewBox: "0 0 1 1",
|
|
1224
|
+
preserveAspectRatio: "none",
|
|
1225
|
+
style: {
|
|
1226
|
+
position: "absolute",
|
|
1227
|
+
inset: 0,
|
|
1228
|
+
width: "100%",
|
|
1229
|
+
height: "100%",
|
|
1230
|
+
overflow: "visible",
|
|
1231
|
+
pointerEvents: "none"
|
|
1232
|
+
},
|
|
1233
|
+
children: [
|
|
1234
|
+
f.length >= 3 && /* @__PURE__ */ I.jsx(
|
|
1235
|
+
"polygon",
|
|
1236
|
+
{
|
|
1237
|
+
points: f.map(([x, w]) => `${x},${w}`).join(" "),
|
|
1238
|
+
fill: n,
|
|
1239
|
+
fillOpacity: 0.15,
|
|
1240
|
+
stroke: "none"
|
|
1241
|
+
}
|
|
1242
|
+
),
|
|
1243
|
+
y.length >= 2 && /* @__PURE__ */ I.jsx(
|
|
1244
|
+
"polyline",
|
|
1245
|
+
{
|
|
1246
|
+
points: E,
|
|
1247
|
+
fill: "none",
|
|
1248
|
+
stroke: n,
|
|
1249
|
+
strokeWidth: 3e-3,
|
|
1250
|
+
strokeLinecap: "round",
|
|
1251
|
+
strokeLinejoin: "round",
|
|
1252
|
+
strokeDasharray: l ? "0.015 0.008" : void 0
|
|
1253
|
+
}
|
|
1254
|
+
),
|
|
1255
|
+
l && f.length >= 1 && /* @__PURE__ */ I.jsx(
|
|
1256
|
+
"line",
|
|
1257
|
+
{
|
|
1258
|
+
x1: l[0],
|
|
1259
|
+
y1: l[1],
|
|
1260
|
+
x2: f[0][0],
|
|
1261
|
+
y2: f[0][1],
|
|
1262
|
+
stroke: n,
|
|
1263
|
+
strokeWidth: 2e-3,
|
|
1264
|
+
strokeDasharray: "0.015 0.008",
|
|
1265
|
+
strokeLinecap: "round",
|
|
1266
|
+
opacity: d ? 0.9 : 0.35
|
|
1267
|
+
}
|
|
1268
|
+
),
|
|
1269
|
+
f.map(([x, w], u) => /* @__PURE__ */ I.jsx(
|
|
1270
|
+
"circle",
|
|
1271
|
+
{
|
|
1272
|
+
cx: x,
|
|
1273
|
+
cy: w,
|
|
1274
|
+
r: u === 0 ? 0.012 : 7e-3,
|
|
1275
|
+
fill: u === 0 && d ? n : "white",
|
|
1276
|
+
stroke: n,
|
|
1277
|
+
strokeWidth: 2e-3
|
|
1278
|
+
},
|
|
1279
|
+
u
|
|
1280
|
+
)),
|
|
1281
|
+
l && /* @__PURE__ */ I.jsx(
|
|
1282
|
+
"circle",
|
|
1283
|
+
{
|
|
1284
|
+
cx: l[0],
|
|
1285
|
+
cy: l[1],
|
|
1286
|
+
r: 5e-3,
|
|
1287
|
+
fill: d ? n : "white",
|
|
1288
|
+
stroke: n,
|
|
1289
|
+
strokeWidth: 2e-3,
|
|
1290
|
+
opacity: 0.8
|
|
1291
|
+
}
|
|
1292
|
+
)
|
|
1293
|
+
]
|
|
1294
|
+
}
|
|
1295
|
+
)
|
|
1296
|
+
}
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1105
1299
|
function vt(t) {
|
|
1106
1300
|
switch (t.type) {
|
|
1107
1301
|
case "image":
|
|
@@ -1112,81 +1306,81 @@ function vt(t) {
|
|
|
1112
1306
|
return `polygon:${t.points.flat().join(",")}:${t.label ?? ""}`;
|
|
1113
1307
|
}
|
|
1114
1308
|
}
|
|
1115
|
-
function
|
|
1309
|
+
function qt({
|
|
1116
1310
|
mainImage: t,
|
|
1117
1311
|
mainImageAlt: r = "Main image",
|
|
1118
1312
|
effect: o = "elevate",
|
|
1119
1313
|
enabled: n = !0,
|
|
1120
|
-
showAll:
|
|
1121
|
-
alphaThreshold:
|
|
1122
|
-
hoverLeaveDelay:
|
|
1314
|
+
showAll: i = !1,
|
|
1315
|
+
alphaThreshold: c = 30,
|
|
1316
|
+
hoverLeaveDelay: a = 150,
|
|
1123
1317
|
children: s,
|
|
1124
|
-
className:
|
|
1125
|
-
style:
|
|
1126
|
-
onHover:
|
|
1127
|
-
onActiveChange:
|
|
1128
|
-
onSelect:
|
|
1318
|
+
className: f = "",
|
|
1319
|
+
style: l,
|
|
1320
|
+
onHover: d,
|
|
1321
|
+
onActiveChange: k,
|
|
1322
|
+
onSelect: g
|
|
1129
1323
|
}) {
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
Wt(
|
|
1133
|
-
}, [
|
|
1134
|
-
const [
|
|
1135
|
-
(
|
|
1136
|
-
|
|
1137
|
-
const Y =
|
|
1138
|
-
if (Y && vt(Y) === vt(
|
|
1139
|
-
return
|
|
1140
|
-
const
|
|
1141
|
-
return
|
|
1324
|
+
const h = typeof o == "string" ? J[o] ?? J.elevate : o;
|
|
1325
|
+
O(() => {
|
|
1326
|
+
Wt(h);
|
|
1327
|
+
}, [h]);
|
|
1328
|
+
const [y, E] = F(() => /* @__PURE__ */ new Map()), x = P(
|
|
1329
|
+
($) => {
|
|
1330
|
+
E((N) => {
|
|
1331
|
+
const Y = N.get($.id);
|
|
1332
|
+
if (Y && vt(Y) === vt($))
|
|
1333
|
+
return N;
|
|
1334
|
+
const X = new Map(N);
|
|
1335
|
+
return X.set($.id, $), X;
|
|
1142
1336
|
});
|
|
1143
1337
|
},
|
|
1144
1338
|
[]
|
|
1145
|
-
),
|
|
1146
|
-
|
|
1147
|
-
if (!
|
|
1148
|
-
const Y = new Map(
|
|
1149
|
-
return Y.delete(
|
|
1339
|
+
), w = P(($) => {
|
|
1340
|
+
E((N) => {
|
|
1341
|
+
if (!N.has($)) return N;
|
|
1342
|
+
const Y = new Map(N);
|
|
1343
|
+
return Y.delete($), Y;
|
|
1150
1344
|
});
|
|
1151
|
-
}, []),
|
|
1152
|
-
() => ({ registerCutout:
|
|
1153
|
-
[
|
|
1154
|
-
),
|
|
1155
|
-
|
|
1156
|
-
M !==
|
|
1157
|
-
}, [M,
|
|
1158
|
-
|
|
1159
|
-
}, [
|
|
1160
|
-
|
|
1161
|
-
}, [
|
|
1162
|
-
const
|
|
1345
|
+
}, []), u = B(
|
|
1346
|
+
() => ({ registerCutout: x, unregisterCutout: w }),
|
|
1347
|
+
[x, w]
|
|
1348
|
+
), b = B(() => Array.from(y.values()), [y]), { activeId: v, selectedId: m, hoveredId: M, boundsMap: D, containerRef: z, containerProps: j } = Mt(b, n, c, a), _ = V(null), R = V(null), A = V(null);
|
|
1349
|
+
O(() => {
|
|
1350
|
+
M !== _.current && (_.current = M, d?.(M));
|
|
1351
|
+
}, [M, d]), O(() => {
|
|
1352
|
+
v !== R.current && (R.current = v, k?.(v));
|
|
1353
|
+
}, [v, k]), O(() => {
|
|
1354
|
+
m !== A.current && (A.current = m, g?.(m));
|
|
1355
|
+
}, [m, g]);
|
|
1356
|
+
const W = i || v !== null, U = B(
|
|
1163
1357
|
() => ({
|
|
1164
|
-
activeId:
|
|
1165
|
-
selectedId:
|
|
1358
|
+
activeId: v,
|
|
1359
|
+
selectedId: m,
|
|
1166
1360
|
hoveredId: M,
|
|
1167
|
-
effect:
|
|
1361
|
+
effect: h,
|
|
1168
1362
|
enabled: n,
|
|
1169
|
-
showAll:
|
|
1170
|
-
boundsMap:
|
|
1171
|
-
isAnyActive:
|
|
1363
|
+
showAll: i,
|
|
1364
|
+
boundsMap: D,
|
|
1365
|
+
isAnyActive: W
|
|
1172
1366
|
}),
|
|
1173
|
-
[
|
|
1367
|
+
[v, m, M, h, n, i, D, W]
|
|
1174
1368
|
);
|
|
1175
|
-
return /* @__PURE__ */
|
|
1369
|
+
return /* @__PURE__ */ I.jsx(Z.Provider, { value: u, children: /* @__PURE__ */ I.jsx(xt.Provider, { value: U, children: /* @__PURE__ */ I.jsxs(
|
|
1176
1370
|
"div",
|
|
1177
1371
|
{
|
|
1178
1372
|
ref: z,
|
|
1179
|
-
className:
|
|
1373
|
+
className: f,
|
|
1180
1374
|
style: {
|
|
1181
1375
|
position: "relative",
|
|
1182
1376
|
width: "100%",
|
|
1183
1377
|
overflow: "hidden",
|
|
1184
|
-
cursor:
|
|
1185
|
-
...
|
|
1378
|
+
cursor: W && n ? "pointer" : "default",
|
|
1379
|
+
...l
|
|
1186
1380
|
},
|
|
1187
|
-
...
|
|
1381
|
+
...j,
|
|
1188
1382
|
children: [
|
|
1189
|
-
/* @__PURE__ */
|
|
1383
|
+
/* @__PURE__ */ I.jsx(
|
|
1190
1384
|
"img",
|
|
1191
1385
|
{
|
|
1192
1386
|
src: t,
|
|
@@ -1197,21 +1391,21 @@ function Gt({
|
|
|
1197
1391
|
width: "100%",
|
|
1198
1392
|
height: "auto",
|
|
1199
1393
|
userSelect: "none",
|
|
1200
|
-
transition:
|
|
1201
|
-
|
|
1394
|
+
transition: h.transition,
|
|
1395
|
+
...W && n ? h.mainImageHovered : {}
|
|
1202
1396
|
}
|
|
1203
1397
|
}
|
|
1204
1398
|
),
|
|
1205
|
-
/* @__PURE__ */
|
|
1399
|
+
/* @__PURE__ */ I.jsx(
|
|
1206
1400
|
"div",
|
|
1207
1401
|
{
|
|
1208
1402
|
style: {
|
|
1209
1403
|
pointerEvents: "none",
|
|
1210
1404
|
position: "absolute",
|
|
1211
1405
|
inset: 0,
|
|
1212
|
-
transition:
|
|
1213
|
-
opacity:
|
|
1214
|
-
...
|
|
1406
|
+
transition: h.transition,
|
|
1407
|
+
opacity: W && n ? 1 : 0,
|
|
1408
|
+
...h.vignetteStyle
|
|
1215
1409
|
}
|
|
1216
1410
|
}
|
|
1217
1411
|
),
|
|
@@ -1220,26 +1414,29 @@ function Gt({
|
|
|
1220
1414
|
}
|
|
1221
1415
|
) }) });
|
|
1222
1416
|
}
|
|
1223
|
-
const
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1417
|
+
const tt = qt;
|
|
1418
|
+
tt.Cutout = Ht;
|
|
1419
|
+
tt.BBoxCutout = Lt;
|
|
1420
|
+
tt.PolygonCutout = Ft;
|
|
1421
|
+
tt.Overlay = Ut;
|
|
1422
|
+
tt.DrawPolygon = Gt;
|
|
1228
1423
|
export {
|
|
1229
1424
|
Ut as CutoutOverlay,
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1425
|
+
tt as CutoutViewer,
|
|
1426
|
+
Gt as DrawPolygon,
|
|
1427
|
+
_t as ImageHitTestStrategy,
|
|
1428
|
+
St as PolygonHitTestStrategy,
|
|
1429
|
+
jt as RectHitTestStrategy,
|
|
1430
|
+
Pt as createHitTestStrategy,
|
|
1431
|
+
at as defineKeyframes,
|
|
1236
1432
|
Ot as elevateEffect,
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1433
|
+
Dt as glowEffect,
|
|
1434
|
+
J as hoverEffects,
|
|
1435
|
+
Nt as liftEffect,
|
|
1436
|
+
Bt as shimmerEffect,
|
|
1437
|
+
Yt as subtleEffect,
|
|
1242
1438
|
Vt as traceEffect,
|
|
1243
|
-
|
|
1244
|
-
Mt as useCutoutHitTest
|
|
1439
|
+
Kt as useCutout,
|
|
1440
|
+
Mt as useCutoutHitTest,
|
|
1441
|
+
Xt as useDrawPolygon
|
|
1245
1442
|
};
|