@camstack/addon-benchmark 1.0.2 → 1.0.3
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/MaskShapeCanvas-DwXCR2iE.mjs +686 -0
- package/dist/MotionZonesSettings-CkSSpN1f.mjs +309 -0
- package/dist/PrivacyMaskSettings-Cfff_PeN.mjs +290 -0
- package/dist/ReactKonva-xvRRqI5S.mjs +5416 -0
- package/dist/_stub.js +13162 -46280
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_benchmark_page-CAP5kXP6.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_benchmark_page-BdEJcXzG.mjs} +4 -4
- package/dist/{_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.js-DHm30T13.mjs → _virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.js-Bnj8XQnA.mjs} +1 -1
- package/dist/hls-R1zGmDT3.mjs +18476 -0
- package/dist/{hostInit-BqmNZvnz.mjs → hostInit-77398d3m.mjs} +3 -3
- package/dist/lib-CVGFTwe0.mjs +7770 -0
- package/dist/player-overlays-97shCqYZ.mjs +188 -0
- package/dist/remoteEntry.js +1 -1
- package/dist/trash-2-I9mqk3Ix.mjs +49 -0
- package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_benchmark_page__remoteEntry_js-CtFXNqc6.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_benchmark_page__remoteEntry_js-2Fj6lA7Z.mjs} +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,686 @@
|
|
|
1
|
+
import { a as e, b as t, c as n, h as r, m as i, u as a } from "./_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react__loadShare__.js-Bnj8XQnA.mjs";
|
|
2
|
+
import { n as o, r as s } from "./_virtual_mf___mfe_internal__addon_benchmark_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-SOU_VnTj.mjs";
|
|
3
|
+
import { a as c, c as l, i as u, l as d, n as f, o as p, r as m, s as h } from "./ReactKonva-xvRRqI5S.mjs";
|
|
4
|
+
//#region ../ui-library/src/composites/cap-settings/MaskShapeCanvas.tsx
|
|
5
|
+
t();
|
|
6
|
+
var g = {
|
|
7
|
+
rect: "#ef4444",
|
|
8
|
+
polygon: "#3b82f6",
|
|
9
|
+
grid: "#6366f1",
|
|
10
|
+
line: "#f59e0b"
|
|
11
|
+
}, _ = "33", v = "66", y = "#6366f1", b = 3, x = 2, S = 12, C = 16, w = 9;
|
|
12
|
+
function T(e, t, n) {
|
|
13
|
+
return {
|
|
14
|
+
x: e.x * t,
|
|
15
|
+
y: e.y * n
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function E(e, t, n) {
|
|
19
|
+
return {
|
|
20
|
+
x: e.x / t,
|
|
21
|
+
y: e.y / n
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function D(e, t, n) {
|
|
25
|
+
return e.flatMap((e) => [e.x * t, e.y * n]);
|
|
26
|
+
}
|
|
27
|
+
function O(e) {
|
|
28
|
+
return !Number.isFinite(e) || e < 0 ? 0 : e > 1 ? 1 : e;
|
|
29
|
+
}
|
|
30
|
+
function k(e) {
|
|
31
|
+
return e.color ?? g[e.shape.kind];
|
|
32
|
+
}
|
|
33
|
+
function A(e, t) {
|
|
34
|
+
let n = e[t], r = e[(t + 1) % e.length];
|
|
35
|
+
if (!n || !r) return [...e];
|
|
36
|
+
let i = {
|
|
37
|
+
x: (n.x + r.x) / 2,
|
|
38
|
+
y: (n.y + r.y) / 2
|
|
39
|
+
};
|
|
40
|
+
return [
|
|
41
|
+
...e.slice(0, t + 1),
|
|
42
|
+
i,
|
|
43
|
+
...e.slice(t + 1)
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
function j(e, t) {
|
|
47
|
+
return e.length === t.length ? e.every((e, n) => {
|
|
48
|
+
let r = t[n];
|
|
49
|
+
return Math.abs(e.x - r.x) < 1e-6 && Math.abs(e.y - r.y) < 1e-6;
|
|
50
|
+
}) : !1;
|
|
51
|
+
}
|
|
52
|
+
function M(e) {
|
|
53
|
+
return e.kind === "polygon" || e.kind === "line";
|
|
54
|
+
}
|
|
55
|
+
function N({ items: e, selectedId: t, onSelect: u, onShapeChange: d, onDrawComplete: f, drawingKind: m, supportedShapes: h, transparent: _ = !1, backdrop: v, polygonVertices: A, grid: N }) {
|
|
56
|
+
let P = i(null), [F, z] = r({
|
|
57
|
+
w: 800,
|
|
58
|
+
h: 450
|
|
59
|
+
}), [B, V] = r([]), [H, U] = r(null), [W, G] = r(null), [K, q] = r(null), J = m !== null && h.includes(m);
|
|
60
|
+
a(() => {
|
|
61
|
+
if (!K) return;
|
|
62
|
+
let t = e.find((e) => e.id === K.itemId);
|
|
63
|
+
if (!t || !M(t.shape)) {
|
|
64
|
+
q(null);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
j(t.shape.points, K.points) && q(null);
|
|
68
|
+
}, [e, K]), a(() => {
|
|
69
|
+
let e = P.current;
|
|
70
|
+
if (!e) return;
|
|
71
|
+
let t = new ResizeObserver((e) => {
|
|
72
|
+
let t = e[0];
|
|
73
|
+
if (!t) return;
|
|
74
|
+
let { width: n, height: r } = t.contentRect;
|
|
75
|
+
z(_ ? {
|
|
76
|
+
w: n,
|
|
77
|
+
h: r
|
|
78
|
+
} : {
|
|
79
|
+
w: n,
|
|
80
|
+
h: n * 9 / 16
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return t.observe(e), () => t.disconnect();
|
|
84
|
+
}, [_]), a(() => {
|
|
85
|
+
!J && H !== null && U(null);
|
|
86
|
+
}, [J, H]);
|
|
87
|
+
let Y = n((e) => {
|
|
88
|
+
f(e), V([]);
|
|
89
|
+
}, [f]), X = n((e) => {
|
|
90
|
+
if (!J || m === null) {
|
|
91
|
+
u(null);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let t = e.target.getStage();
|
|
95
|
+
if (!t) return;
|
|
96
|
+
let n = t.getPointerPosition();
|
|
97
|
+
if (!n) return;
|
|
98
|
+
let r = E(n, F.w, F.h);
|
|
99
|
+
if (m === "rect") {
|
|
100
|
+
let e = O(r.x), t = O(r.y);
|
|
101
|
+
Y({
|
|
102
|
+
kind: "rect",
|
|
103
|
+
x: e,
|
|
104
|
+
y: t,
|
|
105
|
+
width: Math.min(.2, 1 - e),
|
|
106
|
+
height: Math.min(.2, 1 - t)
|
|
107
|
+
});
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (m === "grid") {
|
|
111
|
+
let e = N?.width ?? C, t = N?.height ?? w;
|
|
112
|
+
Y({
|
|
113
|
+
kind: "grid",
|
|
114
|
+
gridWidth: e,
|
|
115
|
+
gridHeight: t,
|
|
116
|
+
cells: Array.from({ length: e * t }, () => !1)
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (m === "line") {
|
|
121
|
+
if (B.length === 0) {
|
|
122
|
+
V([r]);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
Y({
|
|
126
|
+
kind: "line",
|
|
127
|
+
points: [...B, r]
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (m === "polygon") {
|
|
132
|
+
if (B.length === 0) {
|
|
133
|
+
V([r]);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (B.length >= b) {
|
|
137
|
+
let e = T(B[0], F.w, F.h);
|
|
138
|
+
if (Math.hypot(n.x - e.x, n.y - e.y) < S) {
|
|
139
|
+
Y({
|
|
140
|
+
kind: "polygon",
|
|
141
|
+
points: B
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
V((e) => [...e, r]);
|
|
147
|
+
}
|
|
148
|
+
}, [
|
|
149
|
+
J,
|
|
150
|
+
m,
|
|
151
|
+
B,
|
|
152
|
+
F,
|
|
153
|
+
N,
|
|
154
|
+
Y,
|
|
155
|
+
u
|
|
156
|
+
]), ee = n((e) => {
|
|
157
|
+
!J || m !== "polygon" || B.length < b || (e.cancelBubble = !0, Y({
|
|
158
|
+
kind: "polygon",
|
|
159
|
+
points: B
|
|
160
|
+
}));
|
|
161
|
+
}, [
|
|
162
|
+
J,
|
|
163
|
+
m,
|
|
164
|
+
B,
|
|
165
|
+
Y
|
|
166
|
+
]), Z = i(null), Q = i(null);
|
|
167
|
+
a(() => () => {
|
|
168
|
+
Z.current !== null && cancelAnimationFrame(Z.current);
|
|
169
|
+
}, []);
|
|
170
|
+
let te = n((e) => {
|
|
171
|
+
if (!J) return;
|
|
172
|
+
let t = e.target.getStage();
|
|
173
|
+
t && (Q.current = t.getPointerPosition() ?? null, Z.current === null && (Z.current = requestAnimationFrame(() => {
|
|
174
|
+
Z.current = null, U(Q.current);
|
|
175
|
+
})));
|
|
176
|
+
}, [J]), ne = i(!1), re = i(!0), ie = i(/* @__PURE__ */ new Set()), ae = n((e, t, n, r) => {
|
|
177
|
+
let i = t.gridWidth * t.gridHeight;
|
|
178
|
+
if (n < 0 || n >= i || t.cells[n] === r) return;
|
|
179
|
+
let a = [...t.cells];
|
|
180
|
+
for (; a.length < i;) a.push(!1);
|
|
181
|
+
a.length = i, a[n] = r, d(e, {
|
|
182
|
+
...t,
|
|
183
|
+
cells: a
|
|
184
|
+
});
|
|
185
|
+
}, [d]), $ = [];
|
|
186
|
+
if (!_) {
|
|
187
|
+
for (let e = 1; e < C; e++) {
|
|
188
|
+
let t = F.w / C * e;
|
|
189
|
+
$.push(/* @__PURE__ */ o(p, {
|
|
190
|
+
points: [
|
|
191
|
+
t,
|
|
192
|
+
0,
|
|
193
|
+
t,
|
|
194
|
+
F.h
|
|
195
|
+
],
|
|
196
|
+
stroke: "#ffffff",
|
|
197
|
+
strokeWidth: .5,
|
|
198
|
+
opacity: .08
|
|
199
|
+
}, `gv-${e}`));
|
|
200
|
+
}
|
|
201
|
+
for (let e = 1; e < w; e++) {
|
|
202
|
+
let t = F.h / w * e;
|
|
203
|
+
$.push(/* @__PURE__ */ o(p, {
|
|
204
|
+
points: [
|
|
205
|
+
0,
|
|
206
|
+
t,
|
|
207
|
+
F.w,
|
|
208
|
+
t
|
|
209
|
+
],
|
|
210
|
+
stroke: "#ffffff",
|
|
211
|
+
strokeWidth: .5,
|
|
212
|
+
opacity: .08
|
|
213
|
+
}, `gh-${e}`));
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return /* @__PURE__ */ s("div", {
|
|
217
|
+
ref: P,
|
|
218
|
+
className: _ ? "absolute inset-0" : "relative w-full bg-zinc-900 rounded-lg overflow-hidden",
|
|
219
|
+
style: { cursor: J ? "crosshair" : "default" },
|
|
220
|
+
children: [
|
|
221
|
+
v && !_ ? /* @__PURE__ */ o("div", {
|
|
222
|
+
className: "absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover",
|
|
223
|
+
style: {
|
|
224
|
+
width: F.w,
|
|
225
|
+
height: F.h
|
|
226
|
+
},
|
|
227
|
+
children: v
|
|
228
|
+
}) : null,
|
|
229
|
+
/* @__PURE__ */ s(l, {
|
|
230
|
+
width: F.w,
|
|
231
|
+
height: F.h,
|
|
232
|
+
onClick: X,
|
|
233
|
+
onDblClick: ee,
|
|
234
|
+
onMouseMove: te,
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ s(c, {
|
|
237
|
+
listening: !1,
|
|
238
|
+
children: [/* @__PURE__ */ o(p, {
|
|
239
|
+
points: [
|
|
240
|
+
0,
|
|
241
|
+
0,
|
|
242
|
+
F.w,
|
|
243
|
+
0,
|
|
244
|
+
F.w,
|
|
245
|
+
F.h,
|
|
246
|
+
0,
|
|
247
|
+
F.h,
|
|
248
|
+
0,
|
|
249
|
+
0
|
|
250
|
+
],
|
|
251
|
+
stroke: "transparent",
|
|
252
|
+
strokeWidth: 0
|
|
253
|
+
}), $]
|
|
254
|
+
}),
|
|
255
|
+
/* @__PURE__ */ o(c, { children: e.map((e) => {
|
|
256
|
+
let n = e.id === t, r = e.enabled === !1, i = k(e), a = n && !J && !r;
|
|
257
|
+
if (e.shape.kind === "rect") return /* @__PURE__ */ o(I, {
|
|
258
|
+
item: e,
|
|
259
|
+
shape: e.shape,
|
|
260
|
+
color: i,
|
|
261
|
+
selected: n,
|
|
262
|
+
dimmed: r,
|
|
263
|
+
editable: a,
|
|
264
|
+
isDrawing: J,
|
|
265
|
+
size: F,
|
|
266
|
+
onSelect: u,
|
|
267
|
+
onShapeChange: d
|
|
268
|
+
}, e.id);
|
|
269
|
+
if (e.shape.kind === "grid") return /* @__PURE__ */ o(L, {
|
|
270
|
+
item: e,
|
|
271
|
+
shape: e.shape,
|
|
272
|
+
color: i,
|
|
273
|
+
dimmed: r,
|
|
274
|
+
editable: a,
|
|
275
|
+
size: F,
|
|
276
|
+
onSelect: u,
|
|
277
|
+
paintingRef: ne,
|
|
278
|
+
paintValueRef: re,
|
|
279
|
+
paintedRef: ie,
|
|
280
|
+
paintCell: ae
|
|
281
|
+
}, e.id);
|
|
282
|
+
let s = e.shape.kind === "line", c = s ? x : Math.max(b, A?.min ?? b), l = s ? x : A?.max, f = K && K.itemId === e.id ? K.points : e.shape.points;
|
|
283
|
+
return /* @__PURE__ */ o(R, {
|
|
284
|
+
item: e,
|
|
285
|
+
shape: e.shape,
|
|
286
|
+
color: i,
|
|
287
|
+
selected: n,
|
|
288
|
+
dimmed: r,
|
|
289
|
+
editable: a,
|
|
290
|
+
isLine: s,
|
|
291
|
+
isDrawing: J,
|
|
292
|
+
size: F,
|
|
293
|
+
effectivePoints: f,
|
|
294
|
+
minVertices: c,
|
|
295
|
+
maxVertices: l,
|
|
296
|
+
isDragging: W === e.id,
|
|
297
|
+
onSelect: u,
|
|
298
|
+
onShapeChange: d,
|
|
299
|
+
setDragOverride: q,
|
|
300
|
+
setDraggingItemId: G
|
|
301
|
+
}, e.id);
|
|
302
|
+
}) }),
|
|
303
|
+
/* @__PURE__ */ o(c, {
|
|
304
|
+
listening: !1,
|
|
305
|
+
children: J && B.length > 0 && /* @__PURE__ */ s("Group", { children: [
|
|
306
|
+
m === "polygon" && B.length >= 2 && /* @__PURE__ */ o("Line", {
|
|
307
|
+
points: D(B, F.w, F.h),
|
|
308
|
+
stroke: y,
|
|
309
|
+
strokeWidth: 1.5,
|
|
310
|
+
dash: [6, 3],
|
|
311
|
+
opacity: .8
|
|
312
|
+
}),
|
|
313
|
+
m === "line" && B.length === 1 && H && /* @__PURE__ */ o("Line", {
|
|
314
|
+
points: [
|
|
315
|
+
B[0].x * F.w,
|
|
316
|
+
B[0].y * F.h,
|
|
317
|
+
H.x,
|
|
318
|
+
H.y
|
|
319
|
+
],
|
|
320
|
+
stroke: g.line,
|
|
321
|
+
strokeWidth: 1.5,
|
|
322
|
+
dash: [6, 3],
|
|
323
|
+
opacity: .7
|
|
324
|
+
}),
|
|
325
|
+
m === "polygon" && H && B.length >= 1 && /* @__PURE__ */ o("Line", {
|
|
326
|
+
points: [
|
|
327
|
+
B[B.length - 1].x * F.w,
|
|
328
|
+
B[B.length - 1].y * F.h,
|
|
329
|
+
H.x,
|
|
330
|
+
H.y
|
|
331
|
+
],
|
|
332
|
+
stroke: y,
|
|
333
|
+
strokeWidth: 1,
|
|
334
|
+
dash: [4, 4],
|
|
335
|
+
opacity: .5
|
|
336
|
+
}),
|
|
337
|
+
B.map((e, t) => {
|
|
338
|
+
let n = T(e, F.w, F.h), r = t === 0 && m === "polygon" && B.length >= b;
|
|
339
|
+
return /* @__PURE__ */ o("Circle", {
|
|
340
|
+
x: n.x,
|
|
341
|
+
y: n.y,
|
|
342
|
+
radius: r ? 7 : 4,
|
|
343
|
+
fill: r ? y : "#ffffff",
|
|
344
|
+
stroke: y,
|
|
345
|
+
strokeWidth: 1.5,
|
|
346
|
+
opacity: .9
|
|
347
|
+
}, t);
|
|
348
|
+
})
|
|
349
|
+
] })
|
|
350
|
+
})
|
|
351
|
+
]
|
|
352
|
+
}),
|
|
353
|
+
J ? /* @__PURE__ */ o("div", {
|
|
354
|
+
className: "px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700",
|
|
355
|
+
children: m === "line" ? "Click to set the start point, click again to complete the line" : m === "rect" ? "Click to drop a rectangle, then drag the corner to resize" : m === "grid" ? "Click to add the grid, then paint cells" : B.length < b ? "Click to add points (min 3). Double-click or click the first point to close." : "Continue adding points. Double-click or click the first point to close."
|
|
356
|
+
}) : null
|
|
357
|
+
]
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
var P = .02;
|
|
361
|
+
function F(e, t) {
|
|
362
|
+
return Math.abs(e.x - t.x) < 1e-6 && Math.abs(e.y - t.y) < 1e-6 && Math.abs(e.width - t.width) < 1e-6 && Math.abs(e.height - t.height) < 1e-6;
|
|
363
|
+
}
|
|
364
|
+
function I({ item: e, shape: t, color: n, selected: i, dimmed: c, editable: l, isDrawing: f, size: p, onSelect: g, onShapeChange: y }) {
|
|
365
|
+
let [b, x] = r(null), S = {
|
|
366
|
+
x: t.x,
|
|
367
|
+
y: t.y,
|
|
368
|
+
width: t.width,
|
|
369
|
+
height: t.height
|
|
370
|
+
};
|
|
371
|
+
a(() => {
|
|
372
|
+
b && F(S, b) && x(null);
|
|
373
|
+
}, [
|
|
374
|
+
t.x,
|
|
375
|
+
t.y,
|
|
376
|
+
t.width,
|
|
377
|
+
t.height,
|
|
378
|
+
b
|
|
379
|
+
]);
|
|
380
|
+
let C = b ?? S, w = C.x * p.w, T = C.y * p.h, E = C.width * p.w, D = C.height * p.h, k = c ? .35 : i ? 1 : .85, A = (t) => {
|
|
381
|
+
x(t), y(e.id, {
|
|
382
|
+
kind: "rect",
|
|
383
|
+
x: t.x,
|
|
384
|
+
y: t.y,
|
|
385
|
+
width: t.width,
|
|
386
|
+
height: t.height
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
return /* @__PURE__ */ o(u, {
|
|
390
|
+
onClick: (t) => {
|
|
391
|
+
t.cancelBubble = !0, f || g(e.id);
|
|
392
|
+
},
|
|
393
|
+
children: /* @__PURE__ */ s(u, {
|
|
394
|
+
draggable: l,
|
|
395
|
+
dragBoundFunc: l ? (e) => ({
|
|
396
|
+
x: Math.max(-w, Math.min(p.w - (w + E), e.x)),
|
|
397
|
+
y: Math.max(-T, Math.min(p.h - (T + D), e.y))
|
|
398
|
+
}) : void 0,
|
|
399
|
+
onDragEnd: l ? (e) => {
|
|
400
|
+
let t = e.target, n = t.x() / p.w, r = t.y() / p.h;
|
|
401
|
+
if (t.position({
|
|
402
|
+
x: 0,
|
|
403
|
+
y: 0
|
|
404
|
+
}), n === 0 && r === 0) return;
|
|
405
|
+
let i = Math.min(Math.max(0, C.x + n), Math.max(0, 1 - C.width)), a = Math.min(Math.max(0, C.y + r), Math.max(0, 1 - C.height));
|
|
406
|
+
A({
|
|
407
|
+
...C,
|
|
408
|
+
x: i,
|
|
409
|
+
y: a
|
|
410
|
+
});
|
|
411
|
+
} : void 0,
|
|
412
|
+
onMouseEnter: (e) => {
|
|
413
|
+
if (!l) return;
|
|
414
|
+
let t = e.target.getStage();
|
|
415
|
+
t && (t.container().style.cursor = "move");
|
|
416
|
+
},
|
|
417
|
+
onMouseLeave: (e) => {
|
|
418
|
+
if (!l) return;
|
|
419
|
+
let t = e.target.getStage();
|
|
420
|
+
t && (t.container().style.cursor = f ? "crosshair" : "default");
|
|
421
|
+
},
|
|
422
|
+
children: [
|
|
423
|
+
/* @__PURE__ */ o(h, {
|
|
424
|
+
x: w,
|
|
425
|
+
y: T,
|
|
426
|
+
width: E,
|
|
427
|
+
height: D,
|
|
428
|
+
fill: n + (i ? v : _),
|
|
429
|
+
stroke: n,
|
|
430
|
+
strokeWidth: i ? 2.5 : 1.5,
|
|
431
|
+
opacity: k
|
|
432
|
+
}),
|
|
433
|
+
e.label ? /* @__PURE__ */ o(d, {
|
|
434
|
+
x: w,
|
|
435
|
+
y: T - 16,
|
|
436
|
+
text: e.label,
|
|
437
|
+
fontSize: 12,
|
|
438
|
+
fill: n,
|
|
439
|
+
stroke: "#000000",
|
|
440
|
+
strokeWidth: 3,
|
|
441
|
+
fillAfterStrokeEnabled: !0,
|
|
442
|
+
fontStyle: "bold",
|
|
443
|
+
listening: !1
|
|
444
|
+
}) : null,
|
|
445
|
+
l ? /* @__PURE__ */ o(m, {
|
|
446
|
+
x: w + E,
|
|
447
|
+
y: T + D,
|
|
448
|
+
radius: 6,
|
|
449
|
+
fill: n,
|
|
450
|
+
stroke: "#ffffff",
|
|
451
|
+
strokeWidth: 1.5,
|
|
452
|
+
draggable: !0,
|
|
453
|
+
dragBoundFunc: (e) => ({
|
|
454
|
+
x: Math.min(p.w, Math.max(w, e.x)),
|
|
455
|
+
y: Math.min(p.h, Math.max(T, e.y))
|
|
456
|
+
}),
|
|
457
|
+
onDragStart: (e) => {
|
|
458
|
+
e.cancelBubble = !0;
|
|
459
|
+
},
|
|
460
|
+
onDragMove: (e) => {
|
|
461
|
+
let t = e.target, n = O(t.x() / p.w - C.x), r = O(t.y() / p.h - C.y);
|
|
462
|
+
x({
|
|
463
|
+
...C,
|
|
464
|
+
width: Math.max(P, Math.min(n, 1 - C.x)),
|
|
465
|
+
height: Math.max(P, Math.min(r, 1 - C.y))
|
|
466
|
+
});
|
|
467
|
+
},
|
|
468
|
+
onDragEnd: (e) => {
|
|
469
|
+
let t = e.target, n = O(t.x() / p.w - C.x), r = O(t.y() / p.h - C.y);
|
|
470
|
+
A({
|
|
471
|
+
...C,
|
|
472
|
+
width: Math.max(P, Math.min(n, 1 - C.x)),
|
|
473
|
+
height: Math.max(P, Math.min(r, 1 - C.y))
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
onMouseEnter: (e) => {
|
|
477
|
+
let t = e.target.getStage();
|
|
478
|
+
t && (t.container().style.cursor = "nwse-resize");
|
|
479
|
+
},
|
|
480
|
+
onMouseLeave: (e) => {
|
|
481
|
+
let t = e.target.getStage();
|
|
482
|
+
t && (t.container().style.cursor = "default");
|
|
483
|
+
}
|
|
484
|
+
}) : null
|
|
485
|
+
]
|
|
486
|
+
})
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
function L({ item: e, shape: t, color: n, dimmed: r, editable: i, size: a, onSelect: s, paintingRef: c, paintValueRef: l, paintedRef: d, paintCell: f }) {
|
|
490
|
+
let { gridWidth: p, gridHeight: m, cells: g } = t, _ = a.w / p, y = a.h / m, b = p * m, x = r ? .3 : 1, S = (n) => {
|
|
491
|
+
if (!i) {
|
|
492
|
+
s(e.id);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
let r = g[n] !== !0;
|
|
496
|
+
c.current = !0, l.current = r, d.current = new Set([n]), f(e.id, t, n, r);
|
|
497
|
+
}, C = (n) => {
|
|
498
|
+
!c.current || !i || d.current.has(n) || (d.current.add(n), f(e.id, t, n, l.current));
|
|
499
|
+
}, w = () => {
|
|
500
|
+
c.current && (c.current = !1, d.current = /* @__PURE__ */ new Set());
|
|
501
|
+
};
|
|
502
|
+
return /* @__PURE__ */ o(u, {
|
|
503
|
+
opacity: x,
|
|
504
|
+
onMouseUp: w,
|
|
505
|
+
onMouseLeave: w,
|
|
506
|
+
children: Array.from({ length: b }, (e, t) => {
|
|
507
|
+
let r = t % p, i = Math.floor(t / p), a = g[t] === !0;
|
|
508
|
+
return /* @__PURE__ */ o(h, {
|
|
509
|
+
x: r * _,
|
|
510
|
+
y: i * y,
|
|
511
|
+
width: _,
|
|
512
|
+
height: y,
|
|
513
|
+
fill: a ? n + v : "#ffffff10",
|
|
514
|
+
stroke: a ? n : "#ffffff40",
|
|
515
|
+
strokeWidth: .5,
|
|
516
|
+
onMouseDown: (e) => {
|
|
517
|
+
e.cancelBubble = !0, S(t);
|
|
518
|
+
},
|
|
519
|
+
onMouseEnter: () => C(t)
|
|
520
|
+
}, t);
|
|
521
|
+
})
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
function R({ item: e, shape: t, color: n, selected: r, dimmed: i, editable: a, isLine: c, isDrawing: l, size: m, effectivePoints: h, minVertices: g, maxVertices: y, isDragging: b, onSelect: x, onShapeChange: S, setDragOverride: C, setDraggingItemId: w }) {
|
|
525
|
+
let O = D(h, m.w, m.h), k = i ? .35 : r ? 1 : c ? .8 : .85, j = (e) => c ? {
|
|
526
|
+
kind: "line",
|
|
527
|
+
points: [...e]
|
|
528
|
+
} : {
|
|
529
|
+
kind: "polygon",
|
|
530
|
+
points: [...e]
|
|
531
|
+
}, M = h.map((e) => e.x * m.w), N = h.map((e) => e.y * m.h), P = M.length > 0 ? Math.min(...M) : 0, F = M.length > 0 ? Math.max(...M) : 0, I = N.length > 0 ? Math.min(...N) : 0, L = N.length > 0 ? Math.max(...N) : 0, R = (e) => ({
|
|
532
|
+
x: Math.max(-P, Math.min(m.w - F, e.x)),
|
|
533
|
+
y: Math.max(-I, Math.min(m.h - L, e.y))
|
|
534
|
+
}), z = (n) => {
|
|
535
|
+
let r = n.target, i = r.x() / m.w, a = r.y() / m.h;
|
|
536
|
+
if (r.position({
|
|
537
|
+
x: 0,
|
|
538
|
+
y: 0
|
|
539
|
+
}), w(null), i === 0 && a === 0) return;
|
|
540
|
+
let o = t.points.map((e) => ({
|
|
541
|
+
x: e.x + i,
|
|
542
|
+
y: e.y + a
|
|
543
|
+
}));
|
|
544
|
+
C({
|
|
545
|
+
itemId: e.id,
|
|
546
|
+
points: o
|
|
547
|
+
}), S(e.id, j(o));
|
|
548
|
+
}, B = !c && h.length > g, V = !c && (y === void 0 || h.length < y);
|
|
549
|
+
return /* @__PURE__ */ s(u, {
|
|
550
|
+
onClick: (t) => {
|
|
551
|
+
t.cancelBubble = !0, l || x(e.id);
|
|
552
|
+
},
|
|
553
|
+
children: [
|
|
554
|
+
/* @__PURE__ */ s(u, {
|
|
555
|
+
draggable: a,
|
|
556
|
+
dragBoundFunc: a ? R : void 0,
|
|
557
|
+
onDragStart: a ? () => w(e.id) : void 0,
|
|
558
|
+
onDragEnd: a ? z : void 0,
|
|
559
|
+
onMouseEnter: (e) => {
|
|
560
|
+
if (!a) return;
|
|
561
|
+
let t = e.target.getStage();
|
|
562
|
+
t && (t.container().style.cursor = "move");
|
|
563
|
+
},
|
|
564
|
+
onMouseLeave: (e) => {
|
|
565
|
+
if (!a) return;
|
|
566
|
+
let t = e.target.getStage();
|
|
567
|
+
t && (t.container().style.cursor = l ? "crosshair" : "default");
|
|
568
|
+
},
|
|
569
|
+
children: [c ? /* @__PURE__ */ o(f, {
|
|
570
|
+
points: O,
|
|
571
|
+
stroke: n,
|
|
572
|
+
strokeWidth: r ? 3 : 2,
|
|
573
|
+
fill: n,
|
|
574
|
+
pointerLength: 10,
|
|
575
|
+
pointerWidth: 8,
|
|
576
|
+
opacity: k
|
|
577
|
+
}) : /* @__PURE__ */ o(p, {
|
|
578
|
+
points: O,
|
|
579
|
+
closed: !0,
|
|
580
|
+
fill: n + (r ? v : _),
|
|
581
|
+
stroke: n,
|
|
582
|
+
strokeWidth: r ? 2.5 : 1.5,
|
|
583
|
+
opacity: k
|
|
584
|
+
}), e.label && h.length > 0 ? (() => {
|
|
585
|
+
let t = T({
|
|
586
|
+
x: h.reduce((e, t) => e + t.x, 0) / h.length,
|
|
587
|
+
y: h.reduce((e, t) => e + t.y, 0) / h.length
|
|
588
|
+
}, m.w, m.h), r = Math.max(40, e.label.length * 11 * .62);
|
|
589
|
+
return /* @__PURE__ */ o(d, {
|
|
590
|
+
x: t.x - r / 2,
|
|
591
|
+
y: t.y - 7,
|
|
592
|
+
width: r,
|
|
593
|
+
align: "center",
|
|
594
|
+
text: e.label,
|
|
595
|
+
fontSize: 12,
|
|
596
|
+
fill: n,
|
|
597
|
+
stroke: "#000000",
|
|
598
|
+
strokeWidth: 3,
|
|
599
|
+
fillAfterStrokeEnabled: !0,
|
|
600
|
+
fontStyle: "bold",
|
|
601
|
+
listening: !1
|
|
602
|
+
});
|
|
603
|
+
})() : null]
|
|
604
|
+
}),
|
|
605
|
+
a && !b && h.map((r, i) => {
|
|
606
|
+
let a = T(r, m.w, m.h);
|
|
607
|
+
return /* @__PURE__ */ o("Circle", {
|
|
608
|
+
x: a.x,
|
|
609
|
+
y: a.y,
|
|
610
|
+
radius: 5,
|
|
611
|
+
fill: n,
|
|
612
|
+
stroke: "#ffffff",
|
|
613
|
+
strokeWidth: 1.5,
|
|
614
|
+
draggable: !0,
|
|
615
|
+
onDragMove: (n) => {
|
|
616
|
+
let r = E({
|
|
617
|
+
x: n.target.x(),
|
|
618
|
+
y: n.target.y()
|
|
619
|
+
}, m.w, m.h);
|
|
620
|
+
C((n) => {
|
|
621
|
+
let a = n && n.itemId === e.id ? n.points : t.points;
|
|
622
|
+
return {
|
|
623
|
+
itemId: e.id,
|
|
624
|
+
points: a.map((e, t) => t === i ? r : e)
|
|
625
|
+
};
|
|
626
|
+
});
|
|
627
|
+
},
|
|
628
|
+
onDragEnd: (n) => {
|
|
629
|
+
let r = E({
|
|
630
|
+
x: n.target.x(),
|
|
631
|
+
y: n.target.y()
|
|
632
|
+
}, m.w, m.h), a = t.points.map((e, t) => t === i ? r : e);
|
|
633
|
+
C({
|
|
634
|
+
itemId: e.id,
|
|
635
|
+
points: a
|
|
636
|
+
}), S(e.id, j(a));
|
|
637
|
+
},
|
|
638
|
+
onContextMenu: (n) => {
|
|
639
|
+
n.evt.preventDefault(), n.cancelBubble = !0, B && S(e.id, j(t.points.filter((e, t) => t !== i)));
|
|
640
|
+
}
|
|
641
|
+
}, `pt-${i}`);
|
|
642
|
+
}),
|
|
643
|
+
a && !b && V && h.length >= 2 && h.map((r, i) => {
|
|
644
|
+
let a = h[(i + 1) % h.length], s = T({
|
|
645
|
+
x: (r.x + a.x) / 2,
|
|
646
|
+
y: (r.y + a.y) / 2
|
|
647
|
+
}, m.w, m.h);
|
|
648
|
+
return /* @__PURE__ */ o("Circle", {
|
|
649
|
+
x: s.x,
|
|
650
|
+
y: s.y,
|
|
651
|
+
radius: 4,
|
|
652
|
+
fill: "#ffffff",
|
|
653
|
+
stroke: n,
|
|
654
|
+
strokeWidth: 1.5,
|
|
655
|
+
opacity: .6,
|
|
656
|
+
onMouseEnter: (e) => {
|
|
657
|
+
let t = e.target;
|
|
658
|
+
t.to({
|
|
659
|
+
radius: 6,
|
|
660
|
+
opacity: 1,
|
|
661
|
+
duration: .1
|
|
662
|
+
});
|
|
663
|
+
let n = t.getStage();
|
|
664
|
+
n && (n.container().style.cursor = "copy");
|
|
665
|
+
},
|
|
666
|
+
onMouseLeave: (e) => {
|
|
667
|
+
let t = e.target;
|
|
668
|
+
t.to({
|
|
669
|
+
radius: 4,
|
|
670
|
+
opacity: .6,
|
|
671
|
+
duration: .1
|
|
672
|
+
});
|
|
673
|
+
let n = t.getStage();
|
|
674
|
+
n && (n.container().style.cursor = l ? "crosshair" : "default");
|
|
675
|
+
},
|
|
676
|
+
onClick: (n) => {
|
|
677
|
+
n.cancelBubble = !0, S(e.id, j(A(t.points, i)));
|
|
678
|
+
}
|
|
679
|
+
}, `mid-${i}`);
|
|
680
|
+
})
|
|
681
|
+
]
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
var z = e(N);
|
|
685
|
+
//#endregion
|
|
686
|
+
export { z as MaskShapeCanvas };
|