react-img-cutout 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/cutout-viewer/cutouts/image/alpha-contour.d.ts +27 -0
- package/dist/components/cutout-viewer/cutouts/image/image-hit-test-strategy.d.ts +1 -0
- package/dist/components/cutout-viewer/hit-test-strategy.d.ts +2 -0
- package/dist/components/cutout-viewer/hover-effects.d.ts +3 -2
- package/dist/components/cutout-viewer/use-cutout-hit-test.d.ts +1 -0
- package/dist/components/cutout-viewer/viewer-context.d.ts +1 -0
- package/dist/index.cjs +6 -10
- package/dist/index.js +726 -629
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,286 +1,355 @@
|
|
|
1
|
-
import kt, { useState as
|
|
2
|
-
var
|
|
1
|
+
import kt, { useState as L, useRef as B, useCallback as P, useMemo as F, useEffect as O, useContext as z, createContext as lt } from "react";
|
|
2
|
+
var nt = { exports: {} }, G = {};
|
|
3
3
|
var ut;
|
|
4
4
|
function Et() {
|
|
5
5
|
if (ut) return G;
|
|
6
6
|
ut = 1;
|
|
7
|
-
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"),
|
|
8
|
-
function
|
|
7
|
+
var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), e = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function n(r, i, l) {
|
|
9
9
|
var a = null;
|
|
10
|
-
if (
|
|
11
|
-
|
|
10
|
+
if (l !== void 0 && (a = "" + l), i.key !== void 0 && (a = "" + i.key), "key" in i) {
|
|
11
|
+
l = {};
|
|
12
12
|
for (var s in i)
|
|
13
|
-
s !== "key" && (
|
|
14
|
-
} else
|
|
15
|
-
return i =
|
|
13
|
+
s !== "key" && (l[s] = i[s]);
|
|
14
|
+
} else l = i;
|
|
15
|
+
return i = l.ref, {
|
|
16
16
|
$$typeof: t,
|
|
17
|
-
type:
|
|
17
|
+
type: r,
|
|
18
18
|
key: a,
|
|
19
19
|
ref: i !== void 0 ? i : null,
|
|
20
|
-
props:
|
|
20
|
+
props: l
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
return G.Fragment =
|
|
23
|
+
return G.Fragment = e, G.jsx = n, G.jsxs = n, G;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
25
|
+
var J = {};
|
|
26
26
|
var ft;
|
|
27
27
|
function It() {
|
|
28
28
|
return ft || (ft = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
-
function t(
|
|
30
|
-
if (
|
|
31
|
-
if (typeof
|
|
32
|
-
return
|
|
33
|
-
if (typeof
|
|
34
|
-
switch (
|
|
35
|
-
case
|
|
29
|
+
function t(o) {
|
|
30
|
+
if (o == null) return null;
|
|
31
|
+
if (typeof o == "function")
|
|
32
|
+
return o.$$typeof === X ? null : o.displayName || o.name || null;
|
|
33
|
+
if (typeof o == "string") return o;
|
|
34
|
+
switch (o) {
|
|
35
|
+
case f:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case
|
|
37
|
+
case h:
|
|
38
38
|
return "Profiler";
|
|
39
|
-
case
|
|
39
|
+
case b:
|
|
40
40
|
return "StrictMode";
|
|
41
|
-
case
|
|
41
|
+
case $:
|
|
42
42
|
return "Suspense";
|
|
43
|
-
case
|
|
43
|
+
case N:
|
|
44
44
|
return "SuspenseList";
|
|
45
|
-
case
|
|
45
|
+
case q:
|
|
46
46
|
return "Activity";
|
|
47
47
|
}
|
|
48
|
-
if (typeof
|
|
49
|
-
switch (typeof
|
|
48
|
+
if (typeof o == "object")
|
|
49
|
+
switch (typeof o.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 E:
|
|
53
|
-
return "Portal";
|
|
51
|
+
), o.$$typeof) {
|
|
54
52
|
case v:
|
|
55
|
-
return
|
|
56
|
-
case
|
|
57
|
-
return
|
|
58
|
-
case
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return
|
|
63
|
-
case
|
|
64
|
-
|
|
53
|
+
return "Portal";
|
|
54
|
+
case w:
|
|
55
|
+
return o.displayName || "Context";
|
|
56
|
+
case E:
|
|
57
|
+
return (o._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case x:
|
|
59
|
+
var y = o.render;
|
|
60
|
+
return o = o.displayName, o || (o = y.displayName || y.name || "", o = o !== "" ? "ForwardRef(" + o + ")" : "ForwardRef"), o;
|
|
61
|
+
case H:
|
|
62
|
+
return y = o.displayName || null, y !== null ? y : t(o.type) || "Memo";
|
|
63
|
+
case V:
|
|
64
|
+
y = o._payload, o = o._init;
|
|
65
65
|
try {
|
|
66
|
-
return t(
|
|
66
|
+
return t(o(y));
|
|
67
67
|
} catch {
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
return "" +
|
|
72
|
+
function e(o) {
|
|
73
|
+
return "" + o;
|
|
74
74
|
}
|
|
75
|
-
function o
|
|
75
|
+
function n(o) {
|
|
76
76
|
try {
|
|
77
|
-
|
|
78
|
-
var
|
|
77
|
+
e(o);
|
|
78
|
+
var y = !1;
|
|
79
79
|
} catch {
|
|
80
|
-
|
|
80
|
+
y = !0;
|
|
81
81
|
}
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
var
|
|
85
|
-
return
|
|
86
|
-
|
|
82
|
+
if (y) {
|
|
83
|
+
y = console;
|
|
84
|
+
var A = y.error, S = typeof Symbol == "function" && Symbol.toStringTag && o[Symbol.toStringTag] || o.constructor.name || "Object";
|
|
85
|
+
return A.call(
|
|
86
|
+
y,
|
|
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
|
+
S
|
|
89
|
+
), e(o);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
if (
|
|
94
|
-
if (typeof
|
|
92
|
+
function r(o) {
|
|
93
|
+
if (o === f) return "<>";
|
|
94
|
+
if (typeof o == "object" && o !== null && o.$$typeof === V)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
97
|
-
var
|
|
98
|
-
return
|
|
97
|
+
var y = t(o);
|
|
98
|
+
return y ? "<" + y + ">" : "<...>";
|
|
99
99
|
} catch {
|
|
100
100
|
return "<...>";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function i() {
|
|
104
|
-
var
|
|
105
|
-
return
|
|
104
|
+
var o = j.A;
|
|
105
|
+
return o === null ? null : o.getOwner();
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function l() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
|
-
function a(
|
|
111
|
-
if (
|
|
112
|
-
var
|
|
113
|
-
if (
|
|
110
|
+
function a(o) {
|
|
111
|
+
if (R.call(o, "key")) {
|
|
112
|
+
var y = Object.getOwnPropertyDescriptor(o, "key").get;
|
|
113
|
+
if (y && y.isReactWarning) return !1;
|
|
114
114
|
}
|
|
115
|
-
return
|
|
115
|
+
return o.key !== void 0;
|
|
116
116
|
}
|
|
117
|
-
function s(
|
|
118
|
-
function
|
|
119
|
-
|
|
117
|
+
function s(o, y) {
|
|
118
|
+
function A() {
|
|
119
|
+
M || (M = !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
|
+
y
|
|
122
122
|
));
|
|
123
123
|
}
|
|
124
|
-
|
|
125
|
-
get:
|
|
124
|
+
A.isReactWarning = !0, Object.defineProperty(o, "key", {
|
|
125
|
+
get: A,
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
var
|
|
131
|
-
return
|
|
129
|
+
function u() {
|
|
130
|
+
var o = t(this.type);
|
|
131
|
+
return W[o] || (W[o] = !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
|
+
)), o = this.props.ref, o !== void 0 ? o : null;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
var
|
|
137
|
-
return
|
|
138
|
-
$$typeof:
|
|
139
|
-
type:
|
|
140
|
-
key:
|
|
141
|
-
props:
|
|
142
|
-
_owner:
|
|
143
|
-
}, (
|
|
135
|
+
function c(o, y, A, S, rt, st) {
|
|
136
|
+
var T = A.ref;
|
|
137
|
+
return o = {
|
|
138
|
+
$$typeof: m,
|
|
139
|
+
type: o,
|
|
140
|
+
key: y,
|
|
141
|
+
props: A,
|
|
142
|
+
_owner: S
|
|
143
|
+
}, (T !== void 0 ? T : null) !== null ? Object.defineProperty(o, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
|
-
get:
|
|
146
|
-
}) : Object.defineProperty(
|
|
145
|
+
get: u
|
|
146
|
+
}) : Object.defineProperty(o, "ref", { enumerable: !1, value: null }), o._store = {}, Object.defineProperty(o._store, "validated", {
|
|
147
147
|
configurable: !1,
|
|
148
148
|
enumerable: !1,
|
|
149
149
|
writable: !0,
|
|
150
150
|
value: 0
|
|
151
|
-
}), Object.defineProperty(
|
|
151
|
+
}), Object.defineProperty(o, "_debugInfo", {
|
|
152
152
|
configurable: !1,
|
|
153
153
|
enumerable: !1,
|
|
154
154
|
writable: !0,
|
|
155
155
|
value: null
|
|
156
|
-
}), Object.defineProperty(
|
|
156
|
+
}), Object.defineProperty(o, "_debugStack", {
|
|
157
157
|
configurable: !1,
|
|
158
158
|
enumerable: !1,
|
|
159
159
|
writable: !0,
|
|
160
|
-
value:
|
|
161
|
-
}), Object.defineProperty(
|
|
160
|
+
value: rt
|
|
161
|
+
}), Object.defineProperty(o, "_debugTask", {
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
166
|
-
}), Object.freeze && (Object.freeze(
|
|
165
|
+
value: st
|
|
166
|
+
}), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
|
|
167
167
|
}
|
|
168
|
-
function d(
|
|
169
|
-
var
|
|
170
|
-
if (
|
|
171
|
-
if (
|
|
172
|
-
if (
|
|
173
|
-
for (
|
|
174
|
-
k(S
|
|
175
|
-
Object.freeze && Object.freeze(
|
|
168
|
+
function d(o, y, A, S, rt, st) {
|
|
169
|
+
var T = y.children;
|
|
170
|
+
if (T !== void 0)
|
|
171
|
+
if (S)
|
|
172
|
+
if (C(T)) {
|
|
173
|
+
for (S = 0; S < T.length; S++)
|
|
174
|
+
k(T[S]);
|
|
175
|
+
Object.freeze && Object.freeze(T);
|
|
176
176
|
} else
|
|
177
177
|
console.error(
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
|
-
else k(
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
var
|
|
180
|
+
else k(T);
|
|
181
|
+
if (R.call(y, "key")) {
|
|
182
|
+
T = t(o);
|
|
183
|
+
var U = Object.keys(y).filter(function(wt) {
|
|
184
184
|
return wt !== "key";
|
|
185
185
|
});
|
|
186
|
-
|
|
186
|
+
S = 0 < U.length ? "{key: someKey, " + U.join(": ..., ") + ": ...}" : "{key: someKey}", ct[T + S] || (U = 0 < U.length ? "{" + U.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
|
-
T,
|
|
194
193
|
S,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
T,
|
|
195
|
+
U,
|
|
196
|
+
T
|
|
197
|
+
), ct[T + S] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
for (var
|
|
202
|
-
|
|
203
|
-
} else
|
|
204
|
-
return
|
|
205
|
-
|
|
206
|
-
typeof
|
|
207
|
-
),
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
199
|
+
if (T = null, A !== void 0 && (n(A), T = "" + A), a(y) && (n(y.key), T = "" + y.key), "key" in y) {
|
|
200
|
+
A = {};
|
|
201
|
+
for (var it in y)
|
|
202
|
+
it !== "key" && (A[it] = y[it]);
|
|
203
|
+
} else A = y;
|
|
204
|
+
return T && s(
|
|
205
|
+
A,
|
|
206
|
+
typeof o == "function" ? o.displayName || o.name || "Unknown" : o
|
|
207
|
+
), c(
|
|
208
|
+
o,
|
|
209
|
+
T,
|
|
210
|
+
A,
|
|
211
211
|
i(),
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
rt,
|
|
213
|
+
st
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
|
-
function k(
|
|
217
|
-
|
|
216
|
+
function k(o) {
|
|
217
|
+
p(o) ? o._store && (o._store.validated = 1) : typeof o == "object" && o !== null && o.$$typeof === V && (o._payload.status === "fulfilled" ? p(o._payload.value) && o._payload.value._store && (o._payload.value._store.validated = 1) : o._store && (o._store.validated = 1));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
return typeof
|
|
219
|
+
function p(o) {
|
|
220
|
+
return typeof o == "object" && o !== null && o.$$typeof === m;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var g = kt, m = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), f = /* @__PURE__ */ Symbol.for("react.fragment"), b = /* @__PURE__ */ Symbol.for("react.strict_mode"), h = /* @__PURE__ */ Symbol.for("react.profiler"), E = /* @__PURE__ */ Symbol.for("react.consumer"), w = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), $ = /* @__PURE__ */ Symbol.for("react.suspense"), N = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), V = /* @__PURE__ */ Symbol.for("react.lazy"), q = /* @__PURE__ */ Symbol.for("react.activity"), X = /* @__PURE__ */ Symbol.for("react.client.reference"), j = g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, C = Array.isArray, _ = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
226
|
-
react_stack_bottom_frame: function(
|
|
227
|
-
return
|
|
225
|
+
g = {
|
|
226
|
+
react_stack_bottom_frame: function(o) {
|
|
227
|
+
return o();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
)(),
|
|
234
|
-
|
|
235
|
-
var
|
|
230
|
+
var M, W = {}, Y = g.react_stack_bottom_frame.bind(
|
|
231
|
+
g,
|
|
232
|
+
l
|
|
233
|
+
)(), D = _(r(l)), ct = {};
|
|
234
|
+
J.Fragment = f, J.jsx = function(o, y, A) {
|
|
235
|
+
var S = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return d(
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
o,
|
|
238
|
+
y,
|
|
239
|
+
A,
|
|
240
240
|
!1,
|
|
241
|
-
|
|
242
|
-
|
|
241
|
+
S ? Error("react-stack-top-frame") : Y,
|
|
242
|
+
S ? _(r(o)) : D
|
|
243
243
|
);
|
|
244
|
-
},
|
|
245
|
-
var
|
|
244
|
+
}, J.jsxs = function(o, y, A) {
|
|
245
|
+
var S = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
246
246
|
return d(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
247
|
+
o,
|
|
248
|
+
y,
|
|
249
|
+
A,
|
|
250
250
|
!0,
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
S ? Error("react-stack-top-frame") : Y,
|
|
252
|
+
S ? _(r(o)) : D
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
|
-
})()),
|
|
255
|
+
})()), J;
|
|
256
256
|
}
|
|
257
257
|
var dt;
|
|
258
|
-
function
|
|
259
|
-
return dt || (dt = 1, process.env.NODE_ENV === "production" ?
|
|
258
|
+
function Ct() {
|
|
259
|
+
return dt || (dt = 1, process.env.NODE_ENV === "production" ? nt.exports = Et() : nt.exports = It()), nt.exports;
|
|
260
|
+
}
|
|
261
|
+
var I = Ct();
|
|
262
|
+
const At = 200;
|
|
263
|
+
function Rt(t, e, n) {
|
|
264
|
+
const r = n[0] - e[0], i = n[1] - e[1], l = r * r + i * i;
|
|
265
|
+
if (l === 0) {
|
|
266
|
+
const s = t[0] - e[0], u = t[1] - e[1];
|
|
267
|
+
return Math.sqrt(s * s + u * u);
|
|
268
|
+
}
|
|
269
|
+
return Math.abs(r * (e[1] - t[1]) - i * (e[0] - t[0])) / Math.sqrt(l);
|
|
270
|
+
}
|
|
271
|
+
function at(t, e) {
|
|
272
|
+
if (t.length <= 2) return t;
|
|
273
|
+
let n = 0, r = 0;
|
|
274
|
+
const i = t[0], l = t[t.length - 1];
|
|
275
|
+
for (let a = 1; a < t.length - 1; a++) {
|
|
276
|
+
const s = Rt(t[a], i, l);
|
|
277
|
+
s > n && (n = s, r = a);
|
|
278
|
+
}
|
|
279
|
+
if (n > e) {
|
|
280
|
+
const a = at(t.slice(0, r + 1), e), s = at(t.slice(r), e);
|
|
281
|
+
return a.slice(0, -1).concat(s);
|
|
282
|
+
}
|
|
283
|
+
return [i, l];
|
|
284
|
+
}
|
|
285
|
+
function _t(t, e, n) {
|
|
286
|
+
let r = -1, i = -1;
|
|
287
|
+
t: for (let g = 0; g < n; g++)
|
|
288
|
+
for (let m = 0; m < e; m++)
|
|
289
|
+
if (t[g * e + m]) {
|
|
290
|
+
r = m, i = g;
|
|
291
|
+
break t;
|
|
292
|
+
}
|
|
293
|
+
if (r < 0) return [];
|
|
294
|
+
const l = [1, 1, 0, -1, -1, -1, 0, 1], a = [0, 1, 1, 1, 0, -1, -1, -1], s = [];
|
|
295
|
+
let u = r, c = i, d = 5;
|
|
296
|
+
const k = e * n * 4;
|
|
297
|
+
let p = 0;
|
|
298
|
+
do {
|
|
299
|
+
s.push([u, c]);
|
|
300
|
+
let g = !1;
|
|
301
|
+
for (let m = 0; m < 8; m++) {
|
|
302
|
+
const v = (d + m) % 8, f = u + l[v], b = c + a[v];
|
|
303
|
+
if (f >= 0 && f < e && b >= 0 && b < n && t[b * e + f]) {
|
|
304
|
+
u = f, c = b, d = ((v + 4) % 8 + 1) % 8, g = !0;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!g || ++p > k) break;
|
|
309
|
+
} while (u !== r || c !== i);
|
|
310
|
+
return s;
|
|
260
311
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
for (let
|
|
265
|
-
|
|
266
|
-
|
|
312
|
+
function jt(t, e, n, r = 30, i = 3e-3) {
|
|
313
|
+
if (e <= 0 || n <= 0 || t.length === 0) return [];
|
|
314
|
+
const l = Math.min(1, At / Math.max(e, n)), a = Math.max(1, Math.round(e * l)), s = Math.max(1, Math.round(n * l)), u = new Uint8Array(a * s);
|
|
315
|
+
for (let p = 0; p < s; p++) {
|
|
316
|
+
const g = Math.min(n - 1, Math.floor(p / l));
|
|
317
|
+
for (let m = 0; m < a; m++) {
|
|
318
|
+
const v = Math.min(e - 1, Math.floor(m / l));
|
|
319
|
+
u[p * a + m] = t[g * e + v] > r ? 1 : 0;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const c = _t(u, a, s);
|
|
323
|
+
if (c.length < 3) return [];
|
|
324
|
+
const d = c.map(([p, g]) => [
|
|
325
|
+
(p + 0.5) / a,
|
|
326
|
+
(g + 0.5) / s
|
|
327
|
+
]), k = at(d, i);
|
|
328
|
+
return k.length >= 3 ? k : d;
|
|
267
329
|
}
|
|
268
|
-
function
|
|
269
|
-
|
|
270
|
-
let
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
330
|
+
function St(t, e) {
|
|
331
|
+
const n = new Uint8Array(e);
|
|
332
|
+
for (let r = 0; r < e; r++)
|
|
333
|
+
n[r] = t[r * 4 + 3];
|
|
334
|
+
return n;
|
|
335
|
+
}
|
|
336
|
+
function Tt(t, e, n, r) {
|
|
337
|
+
if (e <= 0 || n <= 0) return { x: 0, y: 0, w: 1, h: 1 };
|
|
338
|
+
let i = e, l = n, a = 0, s = 0, u = !1;
|
|
339
|
+
for (let c = 0; c < n; c++)
|
|
340
|
+
for (let d = 0; d < e; d++)
|
|
341
|
+
t[c * e + d] > r && (d < i && (i = d), d > a && (a = d), c < l && (l = c), c > s && (s = c), u = !0);
|
|
342
|
+
return u ? {
|
|
343
|
+
x: i / e,
|
|
344
|
+
y: l / n,
|
|
345
|
+
w: (a - i + 1) / e,
|
|
346
|
+
h: (s - l + 1) / n
|
|
279
347
|
} : { x: 0, y: 0, w: 1, h: 1 };
|
|
280
348
|
}
|
|
281
|
-
class
|
|
349
|
+
class Pt {
|
|
282
350
|
id;
|
|
283
351
|
bounds = { x: 0, y: 0, w: 1, h: 1 };
|
|
352
|
+
contour = [];
|
|
284
353
|
/** URL of the cutout mask image */
|
|
285
354
|
src;
|
|
286
355
|
/** Alpha value (0-255) a pixel must exceed to be considered "visible" */
|
|
@@ -290,8 +359,8 @@ class _t {
|
|
|
290
359
|
/** Source image dimensions (pixels) — needed to map normalized coords to pixel indices */
|
|
291
360
|
width = 0;
|
|
292
361
|
height = 0;
|
|
293
|
-
constructor(
|
|
294
|
-
this.id =
|
|
362
|
+
constructor(e, n) {
|
|
363
|
+
this.id = e.id, this.src = e.src, this.threshold = n;
|
|
295
364
|
}
|
|
296
365
|
/**
|
|
297
366
|
* Loads the cutout image and pre-computes the alpha buffer + bounding box.
|
|
@@ -308,20 +377,20 @@ class _t {
|
|
|
308
377
|
* empty alpha buffer, which means hitTest will always return false.
|
|
309
378
|
*/
|
|
310
379
|
async prepare() {
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
380
|
+
const e = new Image();
|
|
381
|
+
e.crossOrigin = "anonymous", e.src = this.src, await new Promise((a) => {
|
|
382
|
+
e.onload = () => a(), e.onerror = () => a();
|
|
314
383
|
});
|
|
315
|
-
const
|
|
316
|
-
if (
|
|
384
|
+
const n = e.naturalWidth, r = e.naturalHeight;
|
|
385
|
+
if (n <= 0 || r <= 0) return;
|
|
317
386
|
const i = document.createElement("canvas");
|
|
318
|
-
i.width =
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
387
|
+
i.width = n, i.height = r;
|
|
388
|
+
const l = i.getContext("2d", { willReadFrequently: !0 });
|
|
389
|
+
if (l)
|
|
321
390
|
try {
|
|
322
|
-
|
|
323
|
-
const a =
|
|
324
|
-
this.alpha =
|
|
391
|
+
l.drawImage(e, 0, 0);
|
|
392
|
+
const a = l.getImageData(0, 0, n, r);
|
|
393
|
+
this.alpha = St(a.data, n * r), this.width = n, this.height = r, this.bounds = Tt(this.alpha, n, r, this.threshold), this.contour = jt(this.alpha, n, r, this.threshold);
|
|
325
394
|
} catch {
|
|
326
395
|
this.alpha = new Uint8Array(0);
|
|
327
396
|
}
|
|
@@ -341,50 +410,50 @@ class _t {
|
|
|
341
410
|
* @param nx - normalized x-coordinate (0-1, relative to the image width)
|
|
342
411
|
* @param ny - normalized y-coordinate (0-1, relative to the image height)
|
|
343
412
|
*/
|
|
344
|
-
hitTest(
|
|
413
|
+
hitTest(e, n) {
|
|
345
414
|
if (this.alpha.length === 0) return !1;
|
|
346
|
-
const
|
|
347
|
-
if (
|
|
348
|
-
const i = Math.min(this.width - 1, Math.max(0, Math.floor(
|
|
415
|
+
const r = this.bounds;
|
|
416
|
+
if (e < r.x || e > r.x + r.w || n < r.y || n > r.y + r.h) return !1;
|
|
417
|
+
const i = Math.min(this.width - 1, Math.max(0, Math.floor(e * this.width))), l = Math.min(
|
|
349
418
|
this.height - 1,
|
|
350
|
-
Math.max(0, Math.floor(
|
|
419
|
+
Math.max(0, Math.floor(n * this.height))
|
|
351
420
|
);
|
|
352
|
-
return this.alpha[
|
|
421
|
+
return this.alpha[l * this.width + i] > this.threshold;
|
|
353
422
|
}
|
|
354
423
|
}
|
|
355
|
-
class
|
|
424
|
+
class Mt {
|
|
356
425
|
id;
|
|
357
426
|
bounds;
|
|
358
|
-
constructor(
|
|
359
|
-
this.id =
|
|
427
|
+
constructor(e) {
|
|
428
|
+
this.id = e.id, this.bounds = { ...e.bounds };
|
|
360
429
|
}
|
|
361
|
-
hitTest(
|
|
362
|
-
const
|
|
363
|
-
return
|
|
430
|
+
hitTest(e, n) {
|
|
431
|
+
const r = this.bounds;
|
|
432
|
+
return e >= r.x && e <= r.x + r.w && n >= r.y && n <= r.y + r.h;
|
|
364
433
|
}
|
|
365
434
|
}
|
|
366
|
-
function
|
|
367
|
-
let
|
|
368
|
-
for (let i = 0,
|
|
369
|
-
const a =
|
|
370
|
-
s >
|
|
435
|
+
function $t(t, e, n) {
|
|
436
|
+
let r = !1;
|
|
437
|
+
for (let i = 0, l = n.length - 1; i < n.length; l = i++) {
|
|
438
|
+
const a = n[i][0], s = n[i][1], u = n[l][0], c = n[l][1];
|
|
439
|
+
s > e != c > e && t < (u - a) * (e - s) / (c - s) + a && (r = !r);
|
|
371
440
|
}
|
|
372
|
-
return
|
|
441
|
+
return r;
|
|
373
442
|
}
|
|
374
|
-
class
|
|
443
|
+
class Dt {
|
|
375
444
|
id;
|
|
376
445
|
bounds;
|
|
377
446
|
points;
|
|
378
|
-
constructor(
|
|
379
|
-
this.id =
|
|
380
|
-
let
|
|
381
|
-
for (const [a, s] of
|
|
382
|
-
a <
|
|
447
|
+
constructor(e) {
|
|
448
|
+
this.id = e.id, this.points = e.points;
|
|
449
|
+
let n = 1 / 0, r = 1 / 0, i = -1 / 0, l = -1 / 0;
|
|
450
|
+
for (const [a, s] of e.points)
|
|
451
|
+
a < n && (n = a), a > i && (i = a), s < r && (r = s), s > l && (l = s);
|
|
383
452
|
this.bounds = {
|
|
384
|
-
x:
|
|
385
|
-
y:
|
|
386
|
-
w: i -
|
|
387
|
-
h:
|
|
453
|
+
x: n,
|
|
454
|
+
y: r,
|
|
455
|
+
w: i - n,
|
|
456
|
+
h: l - r
|
|
388
457
|
};
|
|
389
458
|
}
|
|
390
459
|
/**
|
|
@@ -399,22 +468,22 @@ class St {
|
|
|
399
468
|
* @param nx - normalized x-coordinate (0-1, relative to the image width)
|
|
400
469
|
* @param ny - normalized y-coordinate (0-1, relative to the image height)
|
|
401
470
|
*/
|
|
402
|
-
hitTest(
|
|
403
|
-
const
|
|
404
|
-
return
|
|
471
|
+
hitTest(e, n) {
|
|
472
|
+
const r = this.bounds;
|
|
473
|
+
return e < r.x || e > r.x + r.w || n < r.y || n > r.y + r.h ? !1 : $t(e, n, this.points);
|
|
405
474
|
}
|
|
406
475
|
}
|
|
407
|
-
function
|
|
476
|
+
function Wt(t, e) {
|
|
408
477
|
switch (t.type) {
|
|
409
478
|
case "image":
|
|
410
|
-
return new
|
|
479
|
+
return new Pt(t, e);
|
|
411
480
|
case "bbox":
|
|
412
|
-
return new
|
|
481
|
+
return new Mt(t);
|
|
413
482
|
case "polygon":
|
|
414
|
-
return new
|
|
483
|
+
return new Dt(t);
|
|
415
484
|
}
|
|
416
485
|
}
|
|
417
|
-
function
|
|
486
|
+
function Ot(t) {
|
|
418
487
|
switch (t.type) {
|
|
419
488
|
case "image":
|
|
420
489
|
return `${t.id}:image:${t.src}:${t.label ?? ""}`;
|
|
@@ -424,120 +493,121 @@ function $t(t) {
|
|
|
424
493
|
return `${t.id}:polygon:${t.points.flat().join(",")}:${t.label ?? ""}`;
|
|
425
494
|
}
|
|
426
495
|
}
|
|
427
|
-
function
|
|
428
|
-
const [i,
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
},
|
|
432
|
-
}, [
|
|
433
|
-
|
|
434
|
-
}, []),
|
|
496
|
+
function Nt(t, e = !0, n = 30, r = 150) {
|
|
497
|
+
const [i, l] = L(null), [a, s] = L(null), u = B(null), c = B([]), [d, k] = L({}), [p, g] = L({}), m = Math.min(255, Math.max(0, n)), v = B(null), f = P(() => {
|
|
498
|
+
v.current === null && (v.current = setTimeout(() => {
|
|
499
|
+
v.current = null, l(null);
|
|
500
|
+
}, r));
|
|
501
|
+
}, [r]), b = P(() => {
|
|
502
|
+
v.current !== null && (clearTimeout(v.current), v.current = null);
|
|
503
|
+
}, []), h = t.map(Ot).join("|"), E = F(() => t, [h]);
|
|
435
504
|
O(() => {
|
|
436
|
-
if (!
|
|
437
|
-
|
|
505
|
+
if (!e) {
|
|
506
|
+
c.current = [];
|
|
438
507
|
return;
|
|
439
508
|
}
|
|
440
|
-
let j = !1,
|
|
441
|
-
async function
|
|
442
|
-
const
|
|
443
|
-
for (const
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
|
|
509
|
+
let j = !1, R = [];
|
|
510
|
+
async function C() {
|
|
511
|
+
const _ = [], M = {}, W = {};
|
|
512
|
+
for (const Y of E) {
|
|
513
|
+
const D = Wt(Y, m);
|
|
514
|
+
if (D.prepare && await D.prepare(), j) return;
|
|
515
|
+
_.push(D), M[D.id] = D.bounds, D.contour && D.contour.length >= 3 && (W[D.id] = D.contour);
|
|
447
516
|
}
|
|
448
|
-
j || (
|
|
517
|
+
j || (R = _, c.current = _, k(M), g(W));
|
|
449
518
|
}
|
|
450
|
-
return
|
|
519
|
+
return C(), () => {
|
|
451
520
|
j = !0;
|
|
452
|
-
for (const
|
|
453
|
-
|
|
521
|
+
for (const _ of R)
|
|
522
|
+
_.dispose?.();
|
|
454
523
|
};
|
|
455
|
-
}, [
|
|
456
|
-
const
|
|
457
|
-
(j,
|
|
458
|
-
const
|
|
459
|
-
for (let
|
|
460
|
-
if (
|
|
461
|
-
return
|
|
524
|
+
}, [E, e, m]);
|
|
525
|
+
const w = P(
|
|
526
|
+
(j, R) => {
|
|
527
|
+
const C = c.current;
|
|
528
|
+
for (let _ = C.length - 1; _ >= 0; _--)
|
|
529
|
+
if (C[_].hitTest(j, R))
|
|
530
|
+
return C[_].id;
|
|
462
531
|
return null;
|
|
463
532
|
},
|
|
464
533
|
[]
|
|
465
|
-
),
|
|
534
|
+
), x = P(
|
|
466
535
|
(j) => {
|
|
467
|
-
const
|
|
468
|
-
if (!
|
|
469
|
-
const
|
|
470
|
-
return
|
|
536
|
+
const R = u.current;
|
|
537
|
+
if (!R) return null;
|
|
538
|
+
const C = R.getBoundingClientRect(), _ = (j.clientX - C.left) / C.width, M = (j.clientY - C.top) / C.height;
|
|
539
|
+
return _ < 0 || _ > 1 || M < 0 || M > 1 ? null : { nx: _, ny: M };
|
|
471
540
|
},
|
|
472
541
|
[]
|
|
473
|
-
),
|
|
542
|
+
), $ = P(
|
|
474
543
|
(j) => {
|
|
475
|
-
if (!
|
|
476
|
-
const
|
|
477
|
-
if (!
|
|
478
|
-
|
|
544
|
+
if (!e) return;
|
|
545
|
+
const R = x(j);
|
|
546
|
+
if (!R) {
|
|
547
|
+
f();
|
|
479
548
|
return;
|
|
480
549
|
}
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
550
|
+
const C = w(R.nx, R.ny);
|
|
551
|
+
if (C === null) {
|
|
483
552
|
if (j.target?.closest('[data-cutout-overlay="true"]')) {
|
|
484
|
-
|
|
553
|
+
b();
|
|
485
554
|
return;
|
|
486
555
|
}
|
|
487
|
-
|
|
556
|
+
f();
|
|
488
557
|
return;
|
|
489
558
|
}
|
|
490
|
-
|
|
559
|
+
b(), l(C);
|
|
491
560
|
},
|
|
492
|
-
[
|
|
493
|
-
),
|
|
494
|
-
|
|
495
|
-
}, [
|
|
561
|
+
[e, x, w, f, b]
|
|
562
|
+
), N = P(() => {
|
|
563
|
+
f();
|
|
564
|
+
}, [f]), H = P(
|
|
496
565
|
(j) => {
|
|
497
|
-
if (!
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
566
|
+
if (!e) return;
|
|
567
|
+
const R = x(j);
|
|
568
|
+
if (!R) {
|
|
500
569
|
s(null);
|
|
501
570
|
return;
|
|
502
571
|
}
|
|
503
|
-
const
|
|
504
|
-
s(
|
|
572
|
+
const C = w(R.nx, R.ny);
|
|
573
|
+
s(C === a || C === null ? null : C);
|
|
505
574
|
},
|
|
506
|
-
[
|
|
507
|
-
),
|
|
575
|
+
[e, x, w, a]
|
|
576
|
+
), V = a ?? i, q = e ? d : {}, X = e ? p : {};
|
|
508
577
|
return O(() => () => {
|
|
509
|
-
|
|
510
|
-
}, [
|
|
578
|
+
b();
|
|
579
|
+
}, [b]), {
|
|
511
580
|
hoveredId: i,
|
|
512
581
|
selectedId: a,
|
|
513
|
-
activeId:
|
|
514
|
-
boundsMap:
|
|
515
|
-
|
|
582
|
+
activeId: V,
|
|
583
|
+
boundsMap: q,
|
|
584
|
+
contourMap: X,
|
|
585
|
+
containerRef: u,
|
|
516
586
|
containerProps: {
|
|
517
|
-
onPointerMove:
|
|
518
|
-
onPointerLeave:
|
|
519
|
-
onClick:
|
|
587
|
+
onPointerMove: $,
|
|
588
|
+
onPointerLeave: N,
|
|
589
|
+
onClick: H
|
|
520
590
|
}
|
|
521
591
|
};
|
|
522
592
|
}
|
|
523
|
-
function
|
|
524
|
-
return { name: t, css:
|
|
593
|
+
function vt(t, e) {
|
|
594
|
+
return { name: t, css: e };
|
|
525
595
|
}
|
|
526
|
-
const
|
|
527
|
-
function
|
|
596
|
+
const ht = /* @__PURE__ */ new Set();
|
|
597
|
+
function Yt(t) {
|
|
528
598
|
if (!(!t.keyframes?.length || typeof document > "u"))
|
|
529
|
-
for (const
|
|
530
|
-
if (
|
|
531
|
-
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
${
|
|
535
|
-
}`, document.head.appendChild(
|
|
599
|
+
for (const e of t.keyframes) {
|
|
600
|
+
if (ht.has(e.name)) continue;
|
|
601
|
+
ht.add(e.name);
|
|
602
|
+
const n = document.createElement("style");
|
|
603
|
+
n.setAttribute("data-ricut-kf", e.name), n.textContent = `@keyframes ${e.name} {
|
|
604
|
+
${e.css}
|
|
605
|
+
}`, document.head.appendChild(n);
|
|
536
606
|
}
|
|
537
607
|
}
|
|
538
|
-
const
|
|
608
|
+
const Z = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Vt = {
|
|
539
609
|
name: "elevate",
|
|
540
|
-
transition:
|
|
610
|
+
transition: Z,
|
|
541
611
|
mainImageHovered: {
|
|
542
612
|
filter: "brightness(0.45) saturate(0.7)"
|
|
543
613
|
},
|
|
@@ -575,9 +645,9 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
575
645
|
stroke: "transparent",
|
|
576
646
|
strokeWidth: 1
|
|
577
647
|
}
|
|
578
|
-
},
|
|
648
|
+
}, Lt = {
|
|
579
649
|
name: "glow",
|
|
580
|
-
transition:
|
|
650
|
+
transition: Z,
|
|
581
651
|
mainImageHovered: {
|
|
582
652
|
filter: "brightness(0.55) saturate(0.8)"
|
|
583
653
|
},
|
|
@@ -615,9 +685,9 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
615
685
|
stroke: "transparent",
|
|
616
686
|
strokeWidth: 1
|
|
617
687
|
}
|
|
618
|
-
},
|
|
688
|
+
}, Bt = {
|
|
619
689
|
name: "lift",
|
|
620
|
-
transition:
|
|
690
|
+
transition: Z,
|
|
621
691
|
mainImageHovered: {
|
|
622
692
|
filter: "brightness(0.4)"
|
|
623
693
|
},
|
|
@@ -655,7 +725,7 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
655
725
|
stroke: "transparent",
|
|
656
726
|
strokeWidth: 1
|
|
657
727
|
}
|
|
658
|
-
},
|
|
728
|
+
}, Ft = {
|
|
659
729
|
name: "subtle",
|
|
660
730
|
transition: "all 0.3s ease",
|
|
661
731
|
mainImageHovered: {
|
|
@@ -694,21 +764,14 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
694
764
|
stroke: "transparent",
|
|
695
765
|
strokeWidth: 1
|
|
696
766
|
}
|
|
697
|
-
},
|
|
767
|
+
}, gt = vt(
|
|
698
768
|
"_ricut-trace-stroke",
|
|
699
769
|
`from { stroke-dashoffset: 0; }
|
|
700
770
|
to { stroke-dashoffset: -1; }`
|
|
701
|
-
),
|
|
702
|
-
"_ricut-trace-glow",
|
|
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
|
-
25% { filter: drop-shadow(3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
|
|
705
|
-
50% { filter: drop-shadow(3px 3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
|
|
706
|
-
75% { filter: drop-shadow(-3px 3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
|
|
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
|
-
), Vt = {
|
|
771
|
+
), zt = {
|
|
709
772
|
name: "trace",
|
|
710
|
-
transition:
|
|
711
|
-
keyframes: [
|
|
773
|
+
transition: Z,
|
|
774
|
+
keyframes: [gt],
|
|
712
775
|
mainImageHovered: {
|
|
713
776
|
filter: "brightness(0.35) saturate(0.5)"
|
|
714
777
|
},
|
|
@@ -717,9 +780,8 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
717
780
|
},
|
|
718
781
|
cutoutActive: {
|
|
719
782
|
transform: "scale(1)",
|
|
720
|
-
filter: "drop-shadow(
|
|
721
|
-
opacity: 1
|
|
722
|
-
animation: `${gt.name} 3s linear infinite`
|
|
783
|
+
filter: "drop-shadow(0 0 8px rgba(255,255,255,0.15))",
|
|
784
|
+
opacity: 1
|
|
723
785
|
},
|
|
724
786
|
cutoutInactive: {
|
|
725
787
|
transform: "scale(1)",
|
|
@@ -736,7 +798,7 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
736
798
|
stroke: "rgba(255, 255, 255, 0.9)",
|
|
737
799
|
strokeWidth: 2.5,
|
|
738
800
|
strokeDasharray: "0.15 0.85",
|
|
739
|
-
animation: `${
|
|
801
|
+
animation: `${gt.name} 3s linear infinite`,
|
|
740
802
|
glow: "0 0 10px rgba(255, 255, 255, 0.25)"
|
|
741
803
|
},
|
|
742
804
|
geometryInactive: {
|
|
@@ -749,7 +811,7 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
749
811
|
stroke: "transparent",
|
|
750
812
|
strokeWidth: 1
|
|
751
813
|
}
|
|
752
|
-
},
|
|
814
|
+
}, pt = vt(
|
|
753
815
|
"_ricut-shimmer",
|
|
754
816
|
`0%, 100% {
|
|
755
817
|
filter: brightness(1.05) contrast(1.02)
|
|
@@ -766,10 +828,10 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
766
828
|
drop-shadow(0 0 6px rgba(255, 255, 255, 0.12))
|
|
767
829
|
drop-shadow(0 12px 32px rgba(0, 0, 0, 0.4));
|
|
768
830
|
}`
|
|
769
|
-
),
|
|
831
|
+
), Ht = {
|
|
770
832
|
name: "shimmer",
|
|
771
|
-
transition:
|
|
772
|
-
keyframes: [
|
|
833
|
+
transition: Z,
|
|
834
|
+
keyframes: [pt],
|
|
773
835
|
mainImageHovered: {
|
|
774
836
|
filter: "brightness(0.35) saturate(0.6)"
|
|
775
837
|
},
|
|
@@ -782,7 +844,7 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
782
844
|
we set it here so there's a graceful look before the first frame. */
|
|
783
845
|
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))",
|
|
784
846
|
opacity: 1,
|
|
785
|
-
animation: `${
|
|
847
|
+
animation: `${pt.name} 2.4s ease-in-out infinite`
|
|
786
848
|
},
|
|
787
849
|
cutoutInactive: {
|
|
788
850
|
transform: "scale(1)",
|
|
@@ -810,48 +872,48 @@ const K = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
|
|
|
810
872
|
stroke: "transparent",
|
|
811
873
|
strokeWidth: 1
|
|
812
874
|
}
|
|
813
|
-
},
|
|
814
|
-
elevate:
|
|
815
|
-
glow:
|
|
816
|
-
lift:
|
|
817
|
-
subtle:
|
|
818
|
-
trace:
|
|
819
|
-
shimmer:
|
|
820
|
-
},
|
|
821
|
-
function
|
|
822
|
-
const t =
|
|
875
|
+
}, K = {
|
|
876
|
+
elevate: Vt,
|
|
877
|
+
glow: Lt,
|
|
878
|
+
lift: Bt,
|
|
879
|
+
subtle: Ft,
|
|
880
|
+
trace: zt,
|
|
881
|
+
shimmer: Ht
|
|
882
|
+
}, Q = lt(null), xt = lt(null);
|
|
883
|
+
function ot() {
|
|
884
|
+
const t = z(xt);
|
|
823
885
|
if (!t) throw new Error("Must be used inside <CutoutViewer>");
|
|
824
886
|
return t;
|
|
825
887
|
}
|
|
826
|
-
const
|
|
827
|
-
function
|
|
828
|
-
const t =
|
|
888
|
+
const tt = lt(null);
|
|
889
|
+
function ee() {
|
|
890
|
+
const t = z(tt);
|
|
829
891
|
if (!t)
|
|
830
892
|
throw new Error("useCutout must be used inside <CutoutViewer.Cutout>");
|
|
831
893
|
return t;
|
|
832
894
|
}
|
|
833
|
-
function
|
|
834
|
-
const a =
|
|
895
|
+
function Xt({ id: t, src: e, label: n, effect: r, children: i, renderLayer: l }) {
|
|
896
|
+
const a = z(Q), s = ot();
|
|
835
897
|
if (!a)
|
|
836
898
|
throw new Error("<CutoutViewer.Cutout> must be used inside <CutoutViewer>");
|
|
837
|
-
O(() => (a.registerCutout({ type: "image", id: t, src:
|
|
838
|
-
const
|
|
839
|
-
let
|
|
840
|
-
!s.enabled || !s.isAnyActive && !s.showAll ?
|
|
841
|
-
const
|
|
899
|
+
O(() => (a.registerCutout({ type: "image", id: t, src: e, label: n }), () => a.unregisterCutout(t)), [t, e, n, a]);
|
|
900
|
+
const u = r ? typeof r == "string" ? K[r] ?? s.effect : r : s.effect, c = s.contourMap[t] ?? null, d = s.activeId === t, k = s.hoveredId === t, p = s.selectedId === t, g = { x: 0, y: 0, w: 1, h: 1 }, m = s.boundsMap[t] ?? g;
|
|
901
|
+
let v, f;
|
|
902
|
+
!s.enabled || !s.isAnyActive && !s.showAll ? (v = u.cutoutIdle, f = u.geometryIdle) : s.showAll || d ? (v = u.cutoutActive, f = u.geometryActive) : (v = u.cutoutInactive, f = u.geometryInactive);
|
|
903
|
+
const b = F(
|
|
842
904
|
() => ({
|
|
843
905
|
id: t,
|
|
844
|
-
label:
|
|
845
|
-
bounds:
|
|
846
|
-
isActive:
|
|
847
|
-
isHovered:
|
|
848
|
-
isSelected:
|
|
849
|
-
effect:
|
|
906
|
+
label: n,
|
|
907
|
+
bounds: m,
|
|
908
|
+
isActive: d,
|
|
909
|
+
isHovered: k,
|
|
910
|
+
isSelected: p,
|
|
911
|
+
effect: u
|
|
850
912
|
}),
|
|
851
|
-
[t,
|
|
913
|
+
[t, n, m, d, k, p, u]
|
|
852
914
|
);
|
|
853
|
-
return /* @__PURE__ */ I.jsxs(
|
|
854
|
-
/* @__PURE__ */ I.
|
|
915
|
+
return /* @__PURE__ */ I.jsxs(tt.Provider, { value: b, children: [
|
|
916
|
+
/* @__PURE__ */ I.jsxs(
|
|
855
917
|
"div",
|
|
856
918
|
{
|
|
857
919
|
"data-cutout-id": t,
|
|
@@ -859,68 +921,102 @@ function Ht({ id: t, src: r, label: o, effect: n, children: i, renderLayer: c })
|
|
|
859
921
|
pointerEvents: "none",
|
|
860
922
|
position: "absolute",
|
|
861
923
|
inset: 0,
|
|
862
|
-
zIndex:
|
|
863
|
-
transition:
|
|
864
|
-
...
|
|
924
|
+
zIndex: d ? 20 : 10,
|
|
925
|
+
transition: u.transition,
|
|
926
|
+
...v
|
|
865
927
|
},
|
|
866
|
-
children:
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
928
|
+
children: [
|
|
929
|
+
l ? l({ isActive: d, isHovered: k, isSelected: p, bounds: m, effect: u }) : /* @__PURE__ */ I.jsx(
|
|
930
|
+
"img",
|
|
931
|
+
{
|
|
932
|
+
src: e,
|
|
933
|
+
alt: n || t,
|
|
934
|
+
draggable: !1,
|
|
935
|
+
style: {
|
|
936
|
+
width: "100%",
|
|
937
|
+
height: "100%",
|
|
938
|
+
objectFit: "fill",
|
|
939
|
+
userSelect: "none"
|
|
940
|
+
}
|
|
877
941
|
}
|
|
878
|
-
|
|
879
|
-
|
|
942
|
+
),
|
|
943
|
+
c && f && /* @__PURE__ */ I.jsx(
|
|
944
|
+
"svg",
|
|
945
|
+
{
|
|
946
|
+
viewBox: "0 0 1 1",
|
|
947
|
+
preserveAspectRatio: "none",
|
|
948
|
+
style: {
|
|
949
|
+
position: "absolute",
|
|
950
|
+
inset: 0,
|
|
951
|
+
width: "100%",
|
|
952
|
+
height: "100%",
|
|
953
|
+
overflow: "visible",
|
|
954
|
+
filter: f.glow ? `drop-shadow(${f.glow.split(",")[0]?.trim() ?? ""})` : "none"
|
|
955
|
+
},
|
|
956
|
+
children: /* @__PURE__ */ I.jsx(
|
|
957
|
+
"polygon",
|
|
958
|
+
{
|
|
959
|
+
points: c.map(([h, E]) => `${h},${E}`).join(" "),
|
|
960
|
+
fill: f.fill,
|
|
961
|
+
stroke: f.stroke,
|
|
962
|
+
strokeWidth: (f.strokeWidth ?? 2) * 15e-4,
|
|
963
|
+
strokeLinejoin: "round",
|
|
964
|
+
strokeLinecap: f.strokeDasharray ? "round" : void 0,
|
|
965
|
+
strokeDasharray: f.strokeDasharray,
|
|
966
|
+
pathLength: f.strokeDasharray ? 1 : void 0,
|
|
967
|
+
style: {
|
|
968
|
+
transition: u.transition,
|
|
969
|
+
animation: f.animation
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
)
|
|
973
|
+
}
|
|
974
|
+
)
|
|
975
|
+
]
|
|
880
976
|
}
|
|
881
977
|
),
|
|
882
978
|
i
|
|
883
979
|
] });
|
|
884
980
|
}
|
|
885
|
-
function
|
|
886
|
-
const { filter:
|
|
887
|
-
return
|
|
981
|
+
function mt(t) {
|
|
982
|
+
const { filter: e, ...n } = t;
|
|
983
|
+
return n;
|
|
888
984
|
}
|
|
889
|
-
function
|
|
985
|
+
function Ut({
|
|
890
986
|
id: t,
|
|
891
|
-
bounds:
|
|
892
|
-
label:
|
|
893
|
-
effect:
|
|
987
|
+
bounds: e,
|
|
988
|
+
label: n,
|
|
989
|
+
effect: r,
|
|
894
990
|
children: i,
|
|
895
|
-
renderLayer:
|
|
991
|
+
renderLayer: l
|
|
896
992
|
}) {
|
|
897
|
-
const a =
|
|
993
|
+
const a = z(Q), s = ot();
|
|
898
994
|
if (!a)
|
|
899
995
|
throw new Error(
|
|
900
996
|
"<CutoutViewer.BBoxCutout> must be used inside <CutoutViewer>"
|
|
901
997
|
);
|
|
902
|
-
const { x:
|
|
903
|
-
O(() => (a.registerCutout({ type: "bbox", id: t, bounds: { x:
|
|
904
|
-
const
|
|
905
|
-
let
|
|
906
|
-
!s.enabled || !s.isAnyActive && !s.showAll ? (
|
|
907
|
-
const
|
|
998
|
+
const { x: u, y: c, w: d, h: k } = e;
|
|
999
|
+
O(() => (a.registerCutout({ type: "bbox", id: t, bounds: { x: u, y: c, w: d, h: k }, label: n }), () => a.unregisterCutout(t)), [t, u, c, d, k, n, a]);
|
|
1000
|
+
const p = r ? typeof r == "string" ? K[r] ?? s.effect : r : s.effect, g = s.activeId === t, m = s.hoveredId === t, v = s.selectedId === t, f = { x: 0, y: 0, w: 1, h: 1 }, b = s.boundsMap[t] ?? f;
|
|
1001
|
+
let h, E;
|
|
1002
|
+
!s.enabled || !s.isAnyActive && !s.showAll ? (E = { ...p.cutoutIdle, filter: "none", opacity: 0 }, h = p.geometryIdle) : s.showAll || g ? (E = mt(p.cutoutActive), h = p.geometryActive) : (E = mt(p.cutoutInactive), h = p.geometryInactive);
|
|
1003
|
+
const x = h ?? {
|
|
908
1004
|
fill: "rgba(37, 99, 235, 0.15)",
|
|
909
1005
|
stroke: "rgba(37, 99, 235, 0.6)",
|
|
910
1006
|
strokeWidth: 2
|
|
911
|
-
},
|
|
1007
|
+
}, $ = F(
|
|
912
1008
|
() => ({
|
|
913
1009
|
id: t,
|
|
914
|
-
label:
|
|
915
|
-
bounds:
|
|
916
|
-
isActive:
|
|
917
|
-
isHovered:
|
|
918
|
-
isSelected:
|
|
919
|
-
effect:
|
|
1010
|
+
label: n,
|
|
1011
|
+
bounds: b,
|
|
1012
|
+
isActive: g,
|
|
1013
|
+
isHovered: m,
|
|
1014
|
+
isSelected: v,
|
|
1015
|
+
effect: p
|
|
920
1016
|
}),
|
|
921
|
-
[t,
|
|
1017
|
+
[t, n, b, g, m, v, p]
|
|
922
1018
|
);
|
|
923
|
-
return /* @__PURE__ */ I.jsxs(
|
|
1019
|
+
return /* @__PURE__ */ I.jsxs(tt.Provider, { value: $, children: [
|
|
924
1020
|
/* @__PURE__ */ I.jsx(
|
|
925
1021
|
"div",
|
|
926
1022
|
{
|
|
@@ -929,11 +1025,11 @@ function Lt({
|
|
|
929
1025
|
pointerEvents: "none",
|
|
930
1026
|
position: "absolute",
|
|
931
1027
|
inset: 0,
|
|
932
|
-
zIndex:
|
|
933
|
-
transition:
|
|
934
|
-
...
|
|
1028
|
+
zIndex: g ? 20 : 10,
|
|
1029
|
+
transition: p.transition,
|
|
1030
|
+
...E
|
|
935
1031
|
},
|
|
936
|
-
children:
|
|
1032
|
+
children: l ? l({ isActive: g, isHovered: m, isSelected: v, bounds: b, effect: p }) : /* @__PURE__ */ I.jsx(
|
|
937
1033
|
"svg",
|
|
938
1034
|
{
|
|
939
1035
|
viewBox: "0 0 1 1",
|
|
@@ -944,25 +1040,25 @@ function Lt({
|
|
|
944
1040
|
width: "100%",
|
|
945
1041
|
height: "100%",
|
|
946
1042
|
overflow: "visible",
|
|
947
|
-
filter:
|
|
1043
|
+
filter: x.glow ? `drop-shadow(${x.glow.split(",")[0]?.trim() ?? ""})` : "none"
|
|
948
1044
|
},
|
|
949
1045
|
children: /* @__PURE__ */ I.jsx(
|
|
950
1046
|
"rect",
|
|
951
1047
|
{
|
|
952
|
-
x:
|
|
953
|
-
y:
|
|
954
|
-
width:
|
|
955
|
-
height:
|
|
1048
|
+
x: b.x,
|
|
1049
|
+
y: b.y,
|
|
1050
|
+
width: b.w,
|
|
1051
|
+
height: b.h,
|
|
956
1052
|
rx: 4e-3,
|
|
957
|
-
fill:
|
|
958
|
-
stroke:
|
|
959
|
-
strokeWidth: (
|
|
960
|
-
strokeLinecap:
|
|
961
|
-
strokeDasharray:
|
|
962
|
-
pathLength:
|
|
1053
|
+
fill: x.fill,
|
|
1054
|
+
stroke: x.stroke,
|
|
1055
|
+
strokeWidth: (x.strokeWidth ?? 2) * 15e-4,
|
|
1056
|
+
strokeLinecap: x.strokeDasharray ? "round" : void 0,
|
|
1057
|
+
strokeDasharray: x.strokeDasharray,
|
|
1058
|
+
pathLength: x.strokeDasharray ? 1 : void 0,
|
|
963
1059
|
style: {
|
|
964
|
-
transition:
|
|
965
|
-
animation:
|
|
1060
|
+
transition: p.transition,
|
|
1061
|
+
animation: x.animation
|
|
966
1062
|
}
|
|
967
1063
|
}
|
|
968
1064
|
)
|
|
@@ -973,45 +1069,45 @@ function Lt({
|
|
|
973
1069
|
i
|
|
974
1070
|
] });
|
|
975
1071
|
}
|
|
976
|
-
function
|
|
977
|
-
const { filter:
|
|
978
|
-
return
|
|
1072
|
+
function yt(t) {
|
|
1073
|
+
const { filter: e, ...n } = t;
|
|
1074
|
+
return n;
|
|
979
1075
|
}
|
|
980
|
-
function
|
|
1076
|
+
function qt({
|
|
981
1077
|
id: t,
|
|
982
|
-
points:
|
|
983
|
-
label:
|
|
984
|
-
effect:
|
|
1078
|
+
points: e,
|
|
1079
|
+
label: n,
|
|
1080
|
+
effect: r,
|
|
985
1081
|
children: i,
|
|
986
|
-
renderLayer:
|
|
1082
|
+
renderLayer: l
|
|
987
1083
|
}) {
|
|
988
|
-
const a =
|
|
1084
|
+
const a = z(Q), s = ot();
|
|
989
1085
|
if (!a)
|
|
990
1086
|
throw new Error(
|
|
991
1087
|
"<CutoutViewer.PolygonCutout> must be used inside <CutoutViewer>"
|
|
992
1088
|
);
|
|
993
|
-
const
|
|
994
|
-
O(() => (a.registerCutout({ type: "polygon", id: t, points:
|
|
995
|
-
const
|
|
996
|
-
let
|
|
997
|
-
!s.enabled || !s.isAnyActive && !s.showAll ? (
|
|
998
|
-
const
|
|
1089
|
+
const u = e.flat().join(",");
|
|
1090
|
+
O(() => (a.registerCutout({ type: "polygon", id: t, points: e, label: n }), () => a.unregisterCutout(t)), [t, u, n, a]);
|
|
1091
|
+
const c = r ? typeof r == "string" ? K[r] ?? s.effect : r : s.effect, d = s.activeId === t, k = s.hoveredId === t, p = s.selectedId === t, g = { x: 0, y: 0, w: 1, h: 1 }, m = s.boundsMap[t] ?? g;
|
|
1092
|
+
let v, f;
|
|
1093
|
+
!s.enabled || !s.isAnyActive && !s.showAll ? (f = { ...c.cutoutIdle, filter: "none", opacity: 0 }, v = c.geometryIdle) : s.showAll || d ? (f = yt(c.cutoutActive), v = c.geometryActive) : (f = yt(c.cutoutInactive), v = c.geometryInactive);
|
|
1094
|
+
const h = v ?? {
|
|
999
1095
|
fill: "rgba(37, 99, 235, 0.15)",
|
|
1000
1096
|
stroke: "rgba(37, 99, 235, 0.6)",
|
|
1001
1097
|
strokeWidth: 2
|
|
1002
|
-
},
|
|
1098
|
+
}, E = F(
|
|
1003
1099
|
() => ({
|
|
1004
1100
|
id: t,
|
|
1005
|
-
label:
|
|
1006
|
-
bounds:
|
|
1101
|
+
label: n,
|
|
1102
|
+
bounds: m,
|
|
1007
1103
|
isActive: d,
|
|
1008
1104
|
isHovered: k,
|
|
1009
|
-
isSelected:
|
|
1010
|
-
effect:
|
|
1105
|
+
isSelected: p,
|
|
1106
|
+
effect: c
|
|
1011
1107
|
}),
|
|
1012
|
-
[t,
|
|
1108
|
+
[t, n, m, d, k, p, c]
|
|
1013
1109
|
);
|
|
1014
|
-
return /* @__PURE__ */ I.jsxs(
|
|
1110
|
+
return /* @__PURE__ */ I.jsxs(tt.Provider, { value: E, children: [
|
|
1015
1111
|
/* @__PURE__ */ I.jsx(
|
|
1016
1112
|
"div",
|
|
1017
1113
|
{
|
|
@@ -1021,10 +1117,10 @@ function Ft({
|
|
|
1021
1117
|
position: "absolute",
|
|
1022
1118
|
inset: 0,
|
|
1023
1119
|
zIndex: d ? 20 : 10,
|
|
1024
|
-
transition:
|
|
1025
|
-
...
|
|
1120
|
+
transition: c.transition,
|
|
1121
|
+
...f
|
|
1026
1122
|
},
|
|
1027
|
-
children:
|
|
1123
|
+
children: l ? l({ isActive: d, isHovered: k, isSelected: p, bounds: m, effect: c }) : /* @__PURE__ */ I.jsx(
|
|
1028
1124
|
"svg",
|
|
1029
1125
|
{
|
|
1030
1126
|
viewBox: "0 0 1 1",
|
|
@@ -1035,22 +1131,22 @@ function Ft({
|
|
|
1035
1131
|
width: "100%",
|
|
1036
1132
|
height: "100%",
|
|
1037
1133
|
overflow: "visible",
|
|
1038
|
-
filter:
|
|
1134
|
+
filter: h.glow ? `drop-shadow(${h.glow.split(",")[0]?.trim() ?? ""})` : "none"
|
|
1039
1135
|
},
|
|
1040
1136
|
children: /* @__PURE__ */ I.jsx(
|
|
1041
1137
|
"polygon",
|
|
1042
1138
|
{
|
|
1043
|
-
points:
|
|
1044
|
-
fill:
|
|
1045
|
-
stroke:
|
|
1046
|
-
strokeWidth: (
|
|
1139
|
+
points: e.map(([w, x]) => `${w},${x}`).join(" "),
|
|
1140
|
+
fill: h.fill,
|
|
1141
|
+
stroke: h.stroke,
|
|
1142
|
+
strokeWidth: (h.strokeWidth ?? 2) * 15e-4,
|
|
1047
1143
|
strokeLinejoin: "round",
|
|
1048
|
-
strokeLinecap:
|
|
1049
|
-
strokeDasharray:
|
|
1050
|
-
pathLength:
|
|
1144
|
+
strokeLinecap: h.strokeDasharray ? "round" : void 0,
|
|
1145
|
+
strokeDasharray: h.strokeDasharray,
|
|
1146
|
+
pathLength: h.strokeDasharray ? 1 : void 0,
|
|
1051
1147
|
style: {
|
|
1052
|
-
transition:
|
|
1053
|
-
animation:
|
|
1148
|
+
transition: c.transition,
|
|
1149
|
+
animation: h.animation
|
|
1054
1150
|
}
|
|
1055
1151
|
}
|
|
1056
1152
|
)
|
|
@@ -1061,151 +1157,151 @@ function Ft({
|
|
|
1061
1157
|
i
|
|
1062
1158
|
] });
|
|
1063
1159
|
}
|
|
1064
|
-
function
|
|
1065
|
-
const { x:
|
|
1160
|
+
function Gt(t, e) {
|
|
1161
|
+
const { x: n, y: r, w: i, h: l } = e;
|
|
1066
1162
|
let a, s;
|
|
1067
|
-
t.includes("left") ? (a = `${
|
|
1068
|
-
let
|
|
1069
|
-
return t.startsWith("top") ? (
|
|
1163
|
+
t.includes("left") ? (a = `${n * 100}%`, s = "0") : t.includes("right") ? (a = `${(n + i) * 100}%`, s = "-100%") : (a = `${(n + i / 2) * 100}%`, s = "-50%");
|
|
1164
|
+
let u, c;
|
|
1165
|
+
return t.startsWith("top") ? (u = `${r * 100}%`, c = "-100%") : t.startsWith("bottom") ? (u = `${(r + l) * 100}%`, c = "0") : (u = `${(r + l / 2) * 100}%`, c = "-50%"), {
|
|
1070
1166
|
position: "absolute",
|
|
1071
1167
|
left: a,
|
|
1072
|
-
top:
|
|
1073
|
-
transform: `translate(${s}, ${
|
|
1168
|
+
top: u,
|
|
1169
|
+
transform: `translate(${s}, ${c})`
|
|
1074
1170
|
};
|
|
1075
1171
|
}
|
|
1076
|
-
function
|
|
1172
|
+
function Jt({
|
|
1077
1173
|
placement: t = "top-center",
|
|
1078
|
-
children:
|
|
1079
|
-
className:
|
|
1080
|
-
style:
|
|
1174
|
+
children: e,
|
|
1175
|
+
className: n = "",
|
|
1176
|
+
style: r
|
|
1081
1177
|
}) {
|
|
1082
|
-
const i =
|
|
1178
|
+
const i = z(tt), l = ot();
|
|
1083
1179
|
if (!i)
|
|
1084
1180
|
throw new Error(
|
|
1085
1181
|
"<CutoutViewer.Overlay> must be used inside <CutoutViewer.Cutout>"
|
|
1086
1182
|
);
|
|
1087
|
-
const a =
|
|
1183
|
+
const a = l.enabled && (l.showAll || i.isActive), s = Gt(t, i.bounds);
|
|
1088
1184
|
return /* @__PURE__ */ I.jsx(
|
|
1089
1185
|
"div",
|
|
1090
1186
|
{
|
|
1091
1187
|
"data-cutout-overlay": "true",
|
|
1092
|
-
className:
|
|
1188
|
+
className: n,
|
|
1093
1189
|
style: {
|
|
1094
1190
|
zIndex: 30,
|
|
1095
1191
|
transition: i.effect.transition,
|
|
1096
1192
|
opacity: a ? 1 : 0,
|
|
1097
1193
|
pointerEvents: a ? "auto" : "none",
|
|
1098
1194
|
...s,
|
|
1099
|
-
...
|
|
1195
|
+
...r
|
|
1100
1196
|
},
|
|
1101
|
-
children:
|
|
1197
|
+
children: e
|
|
1102
1198
|
}
|
|
1103
1199
|
);
|
|
1104
1200
|
}
|
|
1105
|
-
function
|
|
1201
|
+
function Kt({
|
|
1106
1202
|
onComplete: t,
|
|
1107
|
-
minPoints:
|
|
1108
|
-
closeThreshold:
|
|
1203
|
+
minPoints: e = 3,
|
|
1204
|
+
closeThreshold: n = 0.03
|
|
1109
1205
|
}) {
|
|
1110
|
-
const [
|
|
1111
|
-
(
|
|
1112
|
-
const
|
|
1113
|
-
if (!
|
|
1114
|
-
const
|
|
1115
|
-
return
|
|
1206
|
+
const [r, i] = L([]), [l, a] = L(null), s = B(null), u = P(
|
|
1207
|
+
(h, E) => {
|
|
1208
|
+
const w = s.current;
|
|
1209
|
+
if (!w) return null;
|
|
1210
|
+
const x = w.getBoundingClientRect(), $ = (h - x.left) / x.width, N = (E - x.top) / x.height;
|
|
1211
|
+
return $ < 0 || $ > 1 || N < 0 || N > 1 ? null : [$, N];
|
|
1116
1212
|
},
|
|
1117
1213
|
[]
|
|
1118
|
-
),
|
|
1119
|
-
(
|
|
1120
|
-
if (
|
|
1121
|
-
const
|
|
1122
|
-
return Math.sqrt(
|
|
1214
|
+
), c = P(
|
|
1215
|
+
(h, E) => {
|
|
1216
|
+
if (E.length < e) return !1;
|
|
1217
|
+
const w = h[0] - E[0][0], x = h[1] - E[0][1];
|
|
1218
|
+
return Math.sqrt(w * w + x * x) < n;
|
|
1123
1219
|
},
|
|
1124
|
-
[
|
|
1220
|
+
[e, n]
|
|
1125
1221
|
), d = P(
|
|
1126
|
-
(
|
|
1127
|
-
|
|
1222
|
+
(h) => {
|
|
1223
|
+
h.length < e || (t(h), i([]), a(null));
|
|
1128
1224
|
},
|
|
1129
|
-
[t,
|
|
1225
|
+
[t, e]
|
|
1130
1226
|
), k = P(() => {
|
|
1131
1227
|
i([]), a(null);
|
|
1132
|
-
}, []),
|
|
1133
|
-
(
|
|
1134
|
-
a(
|
|
1228
|
+
}, []), p = P(
|
|
1229
|
+
(h) => {
|
|
1230
|
+
a(u(h.clientX, h.clientY));
|
|
1135
1231
|
},
|
|
1136
|
-
[
|
|
1137
|
-
),
|
|
1232
|
+
[u]
|
|
1233
|
+
), g = P(() => {
|
|
1138
1234
|
a(null);
|
|
1139
|
-
}, []),
|
|
1140
|
-
(
|
|
1141
|
-
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1235
|
+
}, []), m = P(
|
|
1236
|
+
(h) => {
|
|
1237
|
+
h.stopPropagation();
|
|
1238
|
+
const E = u(h.clientX, h.clientY);
|
|
1239
|
+
E && i((w) => c(E, w) ? (d(w), []) : [...w, E]);
|
|
1144
1240
|
},
|
|
1145
|
-
[
|
|
1146
|
-
),
|
|
1147
|
-
(
|
|
1148
|
-
|
|
1149
|
-
const
|
|
1150
|
-
return
|
|
1241
|
+
[u, c, d]
|
|
1242
|
+
), v = P(
|
|
1243
|
+
(h) => {
|
|
1244
|
+
h.stopPropagation(), i((E) => {
|
|
1245
|
+
const w = E.slice(0, -1);
|
|
1246
|
+
return w.length >= e ? (d(w), []) : w;
|
|
1151
1247
|
});
|
|
1152
1248
|
},
|
|
1153
|
-
[
|
|
1154
|
-
),
|
|
1155
|
-
(
|
|
1156
|
-
|
|
1249
|
+
[e, d]
|
|
1250
|
+
), f = P(
|
|
1251
|
+
(h) => {
|
|
1252
|
+
h.preventDefault(), i((E) => E.slice(0, -1));
|
|
1157
1253
|
},
|
|
1158
1254
|
[]
|
|
1159
|
-
),
|
|
1255
|
+
), b = l !== null && c(l, r);
|
|
1160
1256
|
return {
|
|
1161
|
-
points:
|
|
1162
|
-
previewPoint:
|
|
1163
|
-
willClose:
|
|
1257
|
+
points: r,
|
|
1258
|
+
previewPoint: l,
|
|
1259
|
+
willClose: b,
|
|
1164
1260
|
reset: k,
|
|
1165
1261
|
containerRef: s,
|
|
1166
1262
|
containerProps: {
|
|
1167
|
-
onPointerMove:
|
|
1168
|
-
onPointerLeave:
|
|
1169
|
-
onClick:
|
|
1170
|
-
onDoubleClick:
|
|
1171
|
-
onContextMenu:
|
|
1263
|
+
onPointerMove: p,
|
|
1264
|
+
onPointerLeave: g,
|
|
1265
|
+
onClick: m,
|
|
1266
|
+
onDoubleClick: v,
|
|
1267
|
+
onContextMenu: f
|
|
1172
1268
|
}
|
|
1173
1269
|
};
|
|
1174
1270
|
}
|
|
1175
|
-
function
|
|
1271
|
+
function Zt({
|
|
1176
1272
|
onComplete: t,
|
|
1177
|
-
minPoints:
|
|
1178
|
-
closeThreshold:
|
|
1179
|
-
strokeColor:
|
|
1273
|
+
minPoints: e = 3,
|
|
1274
|
+
closeThreshold: n = 0.03,
|
|
1275
|
+
strokeColor: r = "#3b82f6",
|
|
1180
1276
|
enabled: i = !0,
|
|
1181
|
-
style:
|
|
1277
|
+
style: l,
|
|
1182
1278
|
className: a = ""
|
|
1183
1279
|
}) {
|
|
1184
|
-
if (!
|
|
1280
|
+
if (!z(Q))
|
|
1185
1281
|
throw new Error(
|
|
1186
1282
|
"<CutoutViewer.DrawPolygon> must be used inside <CutoutViewer>"
|
|
1187
1283
|
);
|
|
1188
1284
|
const {
|
|
1189
|
-
points:
|
|
1190
|
-
previewPoint:
|
|
1285
|
+
points: u,
|
|
1286
|
+
previewPoint: c,
|
|
1191
1287
|
willClose: d,
|
|
1192
1288
|
reset: k,
|
|
1193
|
-
containerRef:
|
|
1194
|
-
containerProps:
|
|
1195
|
-
} =
|
|
1289
|
+
containerRef: p,
|
|
1290
|
+
containerProps: g
|
|
1291
|
+
} = Kt({ onComplete: t, minPoints: e, closeThreshold: n });
|
|
1196
1292
|
O(() => {
|
|
1197
|
-
function
|
|
1198
|
-
|
|
1293
|
+
function f(b) {
|
|
1294
|
+
b.key === "Escape" && k();
|
|
1199
1295
|
}
|
|
1200
|
-
return document.addEventListener("keydown",
|
|
1296
|
+
return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
|
|
1201
1297
|
}, [k]), O(() => {
|
|
1202
1298
|
i || k();
|
|
1203
1299
|
}, [i, k]);
|
|
1204
|
-
const
|
|
1300
|
+
const m = c ? [...u, c] : u, v = m.map(([f, b]) => `${f},${b}`).join(" ");
|
|
1205
1301
|
return /* @__PURE__ */ I.jsx(
|
|
1206
1302
|
"div",
|
|
1207
1303
|
{
|
|
1208
|
-
ref:
|
|
1304
|
+
ref: p,
|
|
1209
1305
|
"data-draw-polygon": "true",
|
|
1210
1306
|
className: a,
|
|
1211
1307
|
style: {
|
|
@@ -1214,10 +1310,10 @@ function Gt({
|
|
|
1214
1310
|
cursor: i ? d ? "cell" : "crosshair" : "default",
|
|
1215
1311
|
zIndex: 30,
|
|
1216
1312
|
pointerEvents: i ? "auto" : "none",
|
|
1217
|
-
...
|
|
1313
|
+
...l
|
|
1218
1314
|
},
|
|
1219
|
-
...i ?
|
|
1220
|
-
children:
|
|
1315
|
+
...i ? g : {},
|
|
1316
|
+
children: u.length > 0 && /* @__PURE__ */ I.jsxs(
|
|
1221
1317
|
"svg",
|
|
1222
1318
|
{
|
|
1223
1319
|
viewBox: "0 0 1 1",
|
|
@@ -1231,61 +1327,61 @@ function Gt({
|
|
|
1231
1327
|
pointerEvents: "none"
|
|
1232
1328
|
},
|
|
1233
1329
|
children: [
|
|
1234
|
-
|
|
1330
|
+
u.length >= 3 && /* @__PURE__ */ I.jsx(
|
|
1235
1331
|
"polygon",
|
|
1236
1332
|
{
|
|
1237
|
-
points:
|
|
1238
|
-
fill:
|
|
1333
|
+
points: u.map(([f, b]) => `${f},${b}`).join(" "),
|
|
1334
|
+
fill: r,
|
|
1239
1335
|
fillOpacity: 0.15,
|
|
1240
1336
|
stroke: "none"
|
|
1241
1337
|
}
|
|
1242
1338
|
),
|
|
1243
|
-
|
|
1339
|
+
m.length >= 2 && /* @__PURE__ */ I.jsx(
|
|
1244
1340
|
"polyline",
|
|
1245
1341
|
{
|
|
1246
|
-
points:
|
|
1342
|
+
points: v,
|
|
1247
1343
|
fill: "none",
|
|
1248
|
-
stroke:
|
|
1344
|
+
stroke: r,
|
|
1249
1345
|
strokeWidth: 3e-3,
|
|
1250
1346
|
strokeLinecap: "round",
|
|
1251
1347
|
strokeLinejoin: "round",
|
|
1252
|
-
strokeDasharray:
|
|
1348
|
+
strokeDasharray: c ? "0.015 0.008" : void 0
|
|
1253
1349
|
}
|
|
1254
1350
|
),
|
|
1255
|
-
|
|
1351
|
+
c && u.length >= 1 && /* @__PURE__ */ I.jsx(
|
|
1256
1352
|
"line",
|
|
1257
1353
|
{
|
|
1258
|
-
x1:
|
|
1259
|
-
y1:
|
|
1260
|
-
x2:
|
|
1261
|
-
y2:
|
|
1262
|
-
stroke:
|
|
1354
|
+
x1: c[0],
|
|
1355
|
+
y1: c[1],
|
|
1356
|
+
x2: u[0][0],
|
|
1357
|
+
y2: u[0][1],
|
|
1358
|
+
stroke: r,
|
|
1263
1359
|
strokeWidth: 2e-3,
|
|
1264
1360
|
strokeDasharray: "0.015 0.008",
|
|
1265
1361
|
strokeLinecap: "round",
|
|
1266
1362
|
opacity: d ? 0.9 : 0.35
|
|
1267
1363
|
}
|
|
1268
1364
|
),
|
|
1269
|
-
|
|
1365
|
+
u.map(([f, b], h) => /* @__PURE__ */ I.jsx(
|
|
1270
1366
|
"circle",
|
|
1271
1367
|
{
|
|
1272
|
-
cx:
|
|
1273
|
-
cy:
|
|
1274
|
-
r:
|
|
1275
|
-
fill:
|
|
1276
|
-
stroke:
|
|
1368
|
+
cx: f,
|
|
1369
|
+
cy: b,
|
|
1370
|
+
r: h === 0 ? 0.012 : 7e-3,
|
|
1371
|
+
fill: h === 0 && d ? r : "white",
|
|
1372
|
+
stroke: r,
|
|
1277
1373
|
strokeWidth: 2e-3
|
|
1278
1374
|
},
|
|
1279
|
-
|
|
1375
|
+
h
|
|
1280
1376
|
)),
|
|
1281
|
-
|
|
1377
|
+
c && /* @__PURE__ */ I.jsx(
|
|
1282
1378
|
"circle",
|
|
1283
1379
|
{
|
|
1284
|
-
cx:
|
|
1285
|
-
cy:
|
|
1380
|
+
cx: c[0],
|
|
1381
|
+
cy: c[1],
|
|
1286
1382
|
r: 5e-3,
|
|
1287
|
-
fill: d ?
|
|
1288
|
-
stroke:
|
|
1383
|
+
fill: d ? r : "white",
|
|
1384
|
+
stroke: r,
|
|
1289
1385
|
strokeWidth: 2e-3,
|
|
1290
1386
|
opacity: 0.8
|
|
1291
1387
|
}
|
|
@@ -1296,7 +1392,7 @@ function Gt({
|
|
|
1296
1392
|
}
|
|
1297
1393
|
);
|
|
1298
1394
|
}
|
|
1299
|
-
function
|
|
1395
|
+
function bt(t) {
|
|
1300
1396
|
switch (t.type) {
|
|
1301
1397
|
case "image":
|
|
1302
1398
|
return `image:${t.src}:${t.label ?? ""}`;
|
|
@@ -1306,93 +1402,94 @@ function vt(t) {
|
|
|
1306
1402
|
return `polygon:${t.points.flat().join(",")}:${t.label ?? ""}`;
|
|
1307
1403
|
}
|
|
1308
1404
|
}
|
|
1309
|
-
function
|
|
1405
|
+
function Qt({
|
|
1310
1406
|
mainImage: t,
|
|
1311
|
-
mainImageAlt:
|
|
1312
|
-
effect:
|
|
1313
|
-
enabled:
|
|
1407
|
+
mainImageAlt: e = "Main image",
|
|
1408
|
+
effect: n = "elevate",
|
|
1409
|
+
enabled: r = !0,
|
|
1314
1410
|
showAll: i = !1,
|
|
1315
|
-
alphaThreshold:
|
|
1411
|
+
alphaThreshold: l = 30,
|
|
1316
1412
|
hoverLeaveDelay: a = 150,
|
|
1317
1413
|
children: s,
|
|
1318
|
-
className:
|
|
1319
|
-
style:
|
|
1414
|
+
className: u = "",
|
|
1415
|
+
style: c,
|
|
1320
1416
|
onHover: d,
|
|
1321
1417
|
onActiveChange: k,
|
|
1322
|
-
onSelect:
|
|
1418
|
+
onSelect: p
|
|
1323
1419
|
}) {
|
|
1324
|
-
const
|
|
1420
|
+
const g = typeof n == "string" ? K[n] ?? K.elevate : n;
|
|
1325
1421
|
O(() => {
|
|
1326
|
-
|
|
1327
|
-
}, [
|
|
1328
|
-
const [
|
|
1329
|
-
(
|
|
1330
|
-
|
|
1331
|
-
const Y =
|
|
1332
|
-
if (Y &&
|
|
1333
|
-
return
|
|
1334
|
-
const
|
|
1335
|
-
return
|
|
1422
|
+
Yt(g);
|
|
1423
|
+
}, [g]);
|
|
1424
|
+
const [m, v] = L(() => /* @__PURE__ */ new Map()), f = P(
|
|
1425
|
+
(M) => {
|
|
1426
|
+
v((W) => {
|
|
1427
|
+
const Y = W.get(M.id);
|
|
1428
|
+
if (Y && bt(Y) === bt(M))
|
|
1429
|
+
return W;
|
|
1430
|
+
const D = new Map(W);
|
|
1431
|
+
return D.set(M.id, M), D;
|
|
1336
1432
|
});
|
|
1337
1433
|
},
|
|
1338
1434
|
[]
|
|
1339
|
-
),
|
|
1340
|
-
|
|
1341
|
-
if (!
|
|
1342
|
-
const Y = new Map(
|
|
1343
|
-
return Y.delete(
|
|
1435
|
+
), b = P((M) => {
|
|
1436
|
+
v((W) => {
|
|
1437
|
+
if (!W.has(M)) return W;
|
|
1438
|
+
const Y = new Map(W);
|
|
1439
|
+
return Y.delete(M), Y;
|
|
1344
1440
|
});
|
|
1345
|
-
}, []),
|
|
1346
|
-
() => ({ registerCutout:
|
|
1347
|
-
[
|
|
1348
|
-
),
|
|
1441
|
+
}, []), h = F(
|
|
1442
|
+
() => ({ registerCutout: f, unregisterCutout: b }),
|
|
1443
|
+
[f, b]
|
|
1444
|
+
), E = F(() => Array.from(m.values()), [m]), { activeId: w, selectedId: x, hoveredId: $, boundsMap: N, contourMap: H, containerRef: V, containerProps: q } = Nt(E, r, l, a), X = B(null), j = B(null), R = B(null);
|
|
1349
1445
|
O(() => {
|
|
1350
|
-
|
|
1351
|
-
}, [
|
|
1352
|
-
|
|
1353
|
-
}, [
|
|
1354
|
-
|
|
1355
|
-
}, [
|
|
1356
|
-
const
|
|
1446
|
+
$ !== X.current && (X.current = $, d?.($));
|
|
1447
|
+
}, [$, d]), O(() => {
|
|
1448
|
+
w !== j.current && (j.current = w, k?.(w));
|
|
1449
|
+
}, [w, k]), O(() => {
|
|
1450
|
+
x !== R.current && (R.current = x, p?.(x));
|
|
1451
|
+
}, [x, p]);
|
|
1452
|
+
const C = i || w !== null, _ = F(
|
|
1357
1453
|
() => ({
|
|
1358
|
-
activeId:
|
|
1359
|
-
selectedId:
|
|
1360
|
-
hoveredId:
|
|
1361
|
-
effect:
|
|
1362
|
-
enabled:
|
|
1454
|
+
activeId: w,
|
|
1455
|
+
selectedId: x,
|
|
1456
|
+
hoveredId: $,
|
|
1457
|
+
effect: g,
|
|
1458
|
+
enabled: r,
|
|
1363
1459
|
showAll: i,
|
|
1364
|
-
boundsMap:
|
|
1365
|
-
|
|
1460
|
+
boundsMap: N,
|
|
1461
|
+
contourMap: H,
|
|
1462
|
+
isAnyActive: C
|
|
1366
1463
|
}),
|
|
1367
|
-
[
|
|
1464
|
+
[w, x, $, g, r, i, N, H, C]
|
|
1368
1465
|
);
|
|
1369
|
-
return /* @__PURE__ */ I.jsx(
|
|
1466
|
+
return /* @__PURE__ */ I.jsx(Q.Provider, { value: h, children: /* @__PURE__ */ I.jsx(xt.Provider, { value: _, children: /* @__PURE__ */ I.jsxs(
|
|
1370
1467
|
"div",
|
|
1371
1468
|
{
|
|
1372
|
-
ref:
|
|
1373
|
-
className:
|
|
1469
|
+
ref: V,
|
|
1470
|
+
className: u,
|
|
1374
1471
|
style: {
|
|
1375
1472
|
position: "relative",
|
|
1376
1473
|
width: "100%",
|
|
1377
1474
|
overflow: "hidden",
|
|
1378
|
-
cursor:
|
|
1379
|
-
...
|
|
1475
|
+
cursor: C && r ? "pointer" : "default",
|
|
1476
|
+
...c
|
|
1380
1477
|
},
|
|
1381
|
-
...
|
|
1478
|
+
...q,
|
|
1382
1479
|
children: [
|
|
1383
1480
|
/* @__PURE__ */ I.jsx(
|
|
1384
1481
|
"img",
|
|
1385
1482
|
{
|
|
1386
1483
|
src: t,
|
|
1387
|
-
alt:
|
|
1484
|
+
alt: e,
|
|
1388
1485
|
draggable: !1,
|
|
1389
1486
|
style: {
|
|
1390
1487
|
display: "block",
|
|
1391
1488
|
width: "100%",
|
|
1392
1489
|
height: "auto",
|
|
1393
1490
|
userSelect: "none",
|
|
1394
|
-
transition:
|
|
1395
|
-
...
|
|
1491
|
+
transition: g.transition,
|
|
1492
|
+
...C && r ? g.mainImageHovered : {}
|
|
1396
1493
|
}
|
|
1397
1494
|
}
|
|
1398
1495
|
),
|
|
@@ -1403,9 +1500,9 @@ function qt({
|
|
|
1403
1500
|
pointerEvents: "none",
|
|
1404
1501
|
position: "absolute",
|
|
1405
1502
|
inset: 0,
|
|
1406
|
-
transition:
|
|
1407
|
-
opacity:
|
|
1408
|
-
...
|
|
1503
|
+
transition: g.transition,
|
|
1504
|
+
opacity: C && r ? 1 : 0,
|
|
1505
|
+
...g.vignetteStyle
|
|
1409
1506
|
}
|
|
1410
1507
|
}
|
|
1411
1508
|
),
|
|
@@ -1414,29 +1511,29 @@ function qt({
|
|
|
1414
1511
|
}
|
|
1415
1512
|
) }) });
|
|
1416
1513
|
}
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1514
|
+
const et = Qt;
|
|
1515
|
+
et.Cutout = Xt;
|
|
1516
|
+
et.BBoxCutout = Ut;
|
|
1517
|
+
et.PolygonCutout = qt;
|
|
1518
|
+
et.Overlay = Jt;
|
|
1519
|
+
et.DrawPolygon = Zt;
|
|
1423
1520
|
export {
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1521
|
+
Jt as CutoutOverlay,
|
|
1522
|
+
et as CutoutViewer,
|
|
1523
|
+
Zt as DrawPolygon,
|
|
1524
|
+
Pt as ImageHitTestStrategy,
|
|
1525
|
+
Dt as PolygonHitTestStrategy,
|
|
1526
|
+
Mt as RectHitTestStrategy,
|
|
1527
|
+
Wt as createHitTestStrategy,
|
|
1528
|
+
vt as defineKeyframes,
|
|
1529
|
+
Vt as elevateEffect,
|
|
1530
|
+
Lt as glowEffect,
|
|
1531
|
+
K as hoverEffects,
|
|
1532
|
+
Bt as liftEffect,
|
|
1533
|
+
Ht as shimmerEffect,
|
|
1534
|
+
Ft as subtleEffect,
|
|
1535
|
+
zt as traceEffect,
|
|
1536
|
+
ee as useCutout,
|
|
1537
|
+
Nt as useCutoutHitTest,
|
|
1538
|
+
Kt as useDrawPolygon
|
|
1442
1539
|
};
|