@camstack/addon-osd-manager 0.1.9 → 0.1.11
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/MotionZonesSettings-Cq0OFaxs.mjs +310 -0
- package/dist/PrivacyMaskSettings-C0jj3SDp.mjs +370 -0
- package/dist/SceneMonitorEditor-B25bY2v0.mjs +828 -0
- package/dist/_stub.js +12899 -12924
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-BLRTZ4RM.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-U1DYRszQ.mjs} +4 -4
- package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-rUObp2Qg.mjs +26 -0
- package/dist/addon-osd-manager.css +1 -1
- package/dist/{hostInit-N1Y97Zzt.mjs → hostInit-UKaIppAV.mjs} +3 -3
- package/dist/index.js +2852 -97
- package/dist/index.mjs +2852 -97
- package/dist/player-overlays-Dfe_rxmA.mjs +44 -0
- package/dist/remoteEntry.js +1 -1
- package/dist/responsive-CWwNAY3j.mjs +122 -0
- package/dist/{trash-2-6DuTY6Z3.mjs → square-ax5XLFv8.mjs} +3 -24
- package/dist/trash-2-CWfC2FLD.mjs +25 -0
- package/dist/use-device-snapshot-Z9dNOZFk.mjs +149 -0
- package/dist/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-Bzaw9YeG.mjs → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-DEpr9uky.mjs} +1 -1
- package/package.json +1 -1
- package/dist/MotionZonesSettings-CvRjAHsj.mjs +0 -309
- package/dist/PrivacyMaskSettings-LV8_5mQk.mjs +0 -368
- package/dist/_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BHektQkr.mjs +0 -26
- package/dist/player-overlays-Cb0QIiJ0.mjs +0 -163
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { c as e, h as t, m as n, p as r, u as i, y as a } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react__loadShare__.js-Bs1t18EM.mjs";
|
|
2
|
+
import { a as o, n as s, r as c, s as l, t as u } from "./responsive-CWwNAY3j.mjs";
|
|
3
|
+
import { n as d, t as f } from "./player-overlays-Dfe_rxmA.mjs";
|
|
4
|
+
import { n as p, r as m, t as ee } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DalfdIDw.mjs";
|
|
5
|
+
import { MaskShapeCanvas as h } from "./MaskShapeCanvas-BEVxAjNq.mjs";
|
|
6
|
+
var g = l("grid-2x2", [
|
|
7
|
+
["path", {
|
|
8
|
+
d: "M12 3v18",
|
|
9
|
+
key: "108xh3"
|
|
10
|
+
}],
|
|
11
|
+
["path", {
|
|
12
|
+
d: "M3 12h18",
|
|
13
|
+
key: "1i2n21"
|
|
14
|
+
}],
|
|
15
|
+
["rect", {
|
|
16
|
+
x: "3",
|
|
17
|
+
y: "3",
|
|
18
|
+
width: "18",
|
|
19
|
+
height: "18",
|
|
20
|
+
rx: "2",
|
|
21
|
+
key: "h1oib"
|
|
22
|
+
}]
|
|
23
|
+
]);
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../ui-library/src/composites/cap-settings/MotionZonesSettings.tsx
|
|
26
|
+
a();
|
|
27
|
+
var _ = 110, v = "motion-zones", y = 0, b = [
|
|
28
|
+
1,
|
|
29
|
+
2,
|
|
30
|
+
3
|
|
31
|
+
], x = 1, S = "rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors", C = "rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors";
|
|
32
|
+
function w(e, t, n) {
|
|
33
|
+
let r = t * n, i = Array.from({ length: r });
|
|
34
|
+
for (let t = 0; t < r; t += 1) i[t] = e[t] === !0;
|
|
35
|
+
return i;
|
|
36
|
+
}
|
|
37
|
+
function T(e, t) {
|
|
38
|
+
if (e.length !== t.length) return !1;
|
|
39
|
+
for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
|
|
40
|
+
return !0;
|
|
41
|
+
}
|
|
42
|
+
function E(e, t) {
|
|
43
|
+
return Math.ceil(e / t);
|
|
44
|
+
}
|
|
45
|
+
function D(e, t, n) {
|
|
46
|
+
return Math.min(n - 1, Math.floor((e + .5) / t * n));
|
|
47
|
+
}
|
|
48
|
+
function O(e, t, n, r) {
|
|
49
|
+
let i = E(t, r), a = E(n, r), o = Array.from({ length: i * a }, () => !1);
|
|
50
|
+
for (let r = 0; r < n; r += 1) {
|
|
51
|
+
let s = D(r, n, a);
|
|
52
|
+
for (let n = 0; n < t; n += 1) e[r * t + n] === !0 && (o[s * i + D(n, t, i)] = !0);
|
|
53
|
+
}
|
|
54
|
+
return o;
|
|
55
|
+
}
|
|
56
|
+
function k(e, t, n, r) {
|
|
57
|
+
let i = E(t, r), a = E(n, r), o = Array.from({ length: t * n }, () => !1);
|
|
58
|
+
for (let r = 0; r < n; r += 1) {
|
|
59
|
+
let s = D(r, n, a);
|
|
60
|
+
for (let n = 0; n < t; n += 1) o[r * t + n] = e[s * i + D(n, t, i)] === !0;
|
|
61
|
+
}
|
|
62
|
+
return o;
|
|
63
|
+
}
|
|
64
|
+
function A({ deviceId: a }) {
|
|
65
|
+
let l = c(o().trpcClient, a), [D, A] = t(null), [j, M] = t(!1), [N, P] = t(null), [F, I] = t(null), [L, R] = t(x), [z, B] = t(!1), [V, H] = t(!1), U = n(!1);
|
|
66
|
+
i(() => {
|
|
67
|
+
if (!l) return;
|
|
68
|
+
let e = !1;
|
|
69
|
+
return U.current = !1, A(null), M(!1), P(null), I(null), R(x), H(!1), (async () => {
|
|
70
|
+
try {
|
|
71
|
+
let t = await l.motionZones?.getOptions({});
|
|
72
|
+
if (e) return;
|
|
73
|
+
if (!t) throw Error("device proxy not ready");
|
|
74
|
+
if (A(t), U.current) return;
|
|
75
|
+
let n = await l.motionZones?.getStatus({});
|
|
76
|
+
if (e) return;
|
|
77
|
+
if (!n) throw Error("device proxy not ready");
|
|
78
|
+
U.current = !0;
|
|
79
|
+
let r = n.regions.find((e) => e.shape.kind === "grid"), i = w(r ? r.shape.cells : [], t.grid.width, t.grid.height);
|
|
80
|
+
I(i), P(O(i, t.grid.width, t.grid.height, x));
|
|
81
|
+
} catch (t) {
|
|
82
|
+
if (e) return;
|
|
83
|
+
s(t) ? M(!0) : console.error("Motion Zones load failed", t);
|
|
84
|
+
}
|
|
85
|
+
})(), () => {
|
|
86
|
+
e = !0;
|
|
87
|
+
};
|
|
88
|
+
}, [l]);
|
|
89
|
+
let W = D ? D.grid.width : 0, G = D ? D.grid.height : 0, K = E(W, L), q = E(G, L), J = r(() => N && D ? k(N, W, G, L) : null, [
|
|
90
|
+
N,
|
|
91
|
+
D,
|
|
92
|
+
W,
|
|
93
|
+
G,
|
|
94
|
+
L
|
|
95
|
+
]), Y = r(() => J !== null && F !== null && !T(J, F), [J, F]), te = r(() => J ? J.reduce((e, t) => t ? e + 1 : e, 0) : 0, [J]), ne = W * G, X = K * q, Z = e((e) => {
|
|
96
|
+
X > 0 && P(Array.from({ length: X }, () => e));
|
|
97
|
+
}, [X]), re = e(() => {
|
|
98
|
+
P((e) => e && e.map((e) => !e));
|
|
99
|
+
}, []), ie = e(() => {
|
|
100
|
+
F && D && P(O(F, W, G, L));
|
|
101
|
+
}, [
|
|
102
|
+
F,
|
|
103
|
+
D,
|
|
104
|
+
W,
|
|
105
|
+
G,
|
|
106
|
+
L
|
|
107
|
+
]), ae = e((e) => {
|
|
108
|
+
e === L || !D || P((t) => {
|
|
109
|
+
if (!t) return R(e), t;
|
|
110
|
+
let n = O(k(t, W, G, L), W, G, e);
|
|
111
|
+
return R(e), n;
|
|
112
|
+
});
|
|
113
|
+
}, [
|
|
114
|
+
L,
|
|
115
|
+
D,
|
|
116
|
+
W,
|
|
117
|
+
G
|
|
118
|
+
]), Q = r(() => D && N ? [{
|
|
119
|
+
id: y,
|
|
120
|
+
shape: {
|
|
121
|
+
kind: "grid",
|
|
122
|
+
gridWidth: K,
|
|
123
|
+
gridHeight: q,
|
|
124
|
+
cells: [...N]
|
|
125
|
+
}
|
|
126
|
+
}] : [], [
|
|
127
|
+
D,
|
|
128
|
+
N,
|
|
129
|
+
K,
|
|
130
|
+
q
|
|
131
|
+
]), $ = e((e, t) => {
|
|
132
|
+
t.kind === "grid" && P(t.cells);
|
|
133
|
+
}, []), oe = e(async () => {
|
|
134
|
+
if (!(!l || !N || !D)) {
|
|
135
|
+
B(!0);
|
|
136
|
+
try {
|
|
137
|
+
let e = k(N, D.grid.width, D.grid.height, L), t = {
|
|
138
|
+
kind: "grid",
|
|
139
|
+
gridWidth: D.grid.width,
|
|
140
|
+
gridHeight: D.grid.height,
|
|
141
|
+
cells: e
|
|
142
|
+
};
|
|
143
|
+
await l.motionZones?.setZone({ patch: { regions: [{
|
|
144
|
+
id: y,
|
|
145
|
+
enabled: !0,
|
|
146
|
+
shape: t
|
|
147
|
+
}] } });
|
|
148
|
+
let n = await l.motionZones?.getStatus({});
|
|
149
|
+
if (n) {
|
|
150
|
+
let e = n.regions.find((e) => e.shape.kind === "grid"), t = w(e ? e.shape.cells : [], D.grid.width, D.grid.height);
|
|
151
|
+
I(t), P(O(t, D.grid.width, D.grid.height, L));
|
|
152
|
+
}
|
|
153
|
+
} catch (e) {
|
|
154
|
+
console.error("Motion Zones save failed", e);
|
|
155
|
+
} finally {
|
|
156
|
+
B(!1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}, [
|
|
160
|
+
l,
|
|
161
|
+
N,
|
|
162
|
+
D,
|
|
163
|
+
L
|
|
164
|
+
]);
|
|
165
|
+
return f(r(() => V && !j && D && N ? {
|
|
166
|
+
id: v,
|
|
167
|
+
order: _,
|
|
168
|
+
node: /* @__PURE__ */ p(h, {
|
|
169
|
+
transparent: !0,
|
|
170
|
+
items: Q,
|
|
171
|
+
supportedShapes: ["grid"],
|
|
172
|
+
grid: {
|
|
173
|
+
width: K,
|
|
174
|
+
height: q
|
|
175
|
+
},
|
|
176
|
+
selectedId: y,
|
|
177
|
+
onSelect: () => {},
|
|
178
|
+
onShapeChange: $,
|
|
179
|
+
onDrawComplete: () => {},
|
|
180
|
+
drawingKind: null
|
|
181
|
+
})
|
|
182
|
+
} : null, [
|
|
183
|
+
V,
|
|
184
|
+
j,
|
|
185
|
+
D,
|
|
186
|
+
N,
|
|
187
|
+
Q,
|
|
188
|
+
$,
|
|
189
|
+
K,
|
|
190
|
+
q
|
|
191
|
+
])), l ? /* @__PURE__ */ p(d, {
|
|
192
|
+
title: "Motion Zones",
|
|
193
|
+
icon: /* @__PURE__ */ p(g, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
|
|
194
|
+
children: /* @__PURE__ */ p("div", {
|
|
195
|
+
className: "flex flex-col gap-3",
|
|
196
|
+
children: j ? /* @__PURE__ */ p("p", {
|
|
197
|
+
className: `${u} leading-relaxed`,
|
|
198
|
+
children: "This camera doesn't expose an on-board motion zones grid."
|
|
199
|
+
}) : !j && D !== null && N !== null ? /* @__PURE__ */ m(ee, { children: [/* @__PURE__ */ m("p", {
|
|
200
|
+
className: `${u} leading-relaxed`,
|
|
201
|
+
children: [
|
|
202
|
+
"Toggle ",
|
|
203
|
+
/* @__PURE__ */ p("strong", {
|
|
204
|
+
className: "text-foreground",
|
|
205
|
+
children: "Edit grid"
|
|
206
|
+
}),
|
|
207
|
+
" to paint the region directly on the live frame, then ",
|
|
208
|
+
/* @__PURE__ */ p("strong", {
|
|
209
|
+
className: "text-foreground",
|
|
210
|
+
children: "Save"
|
|
211
|
+
}),
|
|
212
|
+
" to push the mask to the camera. Pick a bigger",
|
|
213
|
+
" ",
|
|
214
|
+
/* @__PURE__ */ p("strong", {
|
|
215
|
+
className: "text-foreground",
|
|
216
|
+
children: "Cell size"
|
|
217
|
+
}),
|
|
218
|
+
" for quicker, broad-stroke painting — it's resampled to the camera's native ",
|
|
219
|
+
D.grid.width,
|
|
220
|
+
"×",
|
|
221
|
+
D.grid.height,
|
|
222
|
+
" grid on save (×1 is the finest)."
|
|
223
|
+
]
|
|
224
|
+
}), /* @__PURE__ */ m("div", {
|
|
225
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
226
|
+
children: [
|
|
227
|
+
/* @__PURE__ */ p("button", {
|
|
228
|
+
type: "button",
|
|
229
|
+
onClick: () => H((e) => !e),
|
|
230
|
+
disabled: z,
|
|
231
|
+
"aria-pressed": V,
|
|
232
|
+
className: V ? C : S,
|
|
233
|
+
children: V ? "Done editing" : "Edit grid"
|
|
234
|
+
}),
|
|
235
|
+
/* @__PURE__ */ p("button", {
|
|
236
|
+
type: "button",
|
|
237
|
+
onClick: () => Z(!0),
|
|
238
|
+
disabled: z,
|
|
239
|
+
className: S,
|
|
240
|
+
children: "All on"
|
|
241
|
+
}),
|
|
242
|
+
/* @__PURE__ */ p("button", {
|
|
243
|
+
type: "button",
|
|
244
|
+
onClick: () => Z(!1),
|
|
245
|
+
disabled: z,
|
|
246
|
+
className: S,
|
|
247
|
+
children: "All off"
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ p("button", {
|
|
250
|
+
type: "button",
|
|
251
|
+
onClick: re,
|
|
252
|
+
disabled: z,
|
|
253
|
+
className: S,
|
|
254
|
+
children: "Invert"
|
|
255
|
+
}),
|
|
256
|
+
/* @__PURE__ */ m("div", {
|
|
257
|
+
className: "flex items-center gap-1 ml-1",
|
|
258
|
+
role: "group",
|
|
259
|
+
"aria-label": "Cell size",
|
|
260
|
+
children: [/* @__PURE__ */ p("span", {
|
|
261
|
+
className: `${u} mr-0.5`,
|
|
262
|
+
children: "Cell size"
|
|
263
|
+
}), b.map((e) => /* @__PURE__ */ m("button", {
|
|
264
|
+
type: "button",
|
|
265
|
+
onClick: () => ae(e),
|
|
266
|
+
disabled: z,
|
|
267
|
+
"aria-pressed": L === e,
|
|
268
|
+
title: e === 1 ? `Camera grid ${W}×${G} (finest)` : `${E(W, e)}×${E(G, e)} painting grid · cells ×${e} bigger`,
|
|
269
|
+
className: L === e ? C : S,
|
|
270
|
+
children: ["×", e]
|
|
271
|
+
}, e))]
|
|
272
|
+
}),
|
|
273
|
+
/* @__PURE__ */ m("span", {
|
|
274
|
+
className: `${u} ml-1 tabular-nums`,
|
|
275
|
+
children: [
|
|
276
|
+
te,
|
|
277
|
+
" / ",
|
|
278
|
+
ne,
|
|
279
|
+
" cells · ",
|
|
280
|
+
D.grid.width,
|
|
281
|
+
"×",
|
|
282
|
+
D.grid.height,
|
|
283
|
+
L === 1 ? "" : ` · paint ${K}×${q}`
|
|
284
|
+
]
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ p("span", { className: "flex-1" }),
|
|
287
|
+
/* @__PURE__ */ p("button", {
|
|
288
|
+
type: "button",
|
|
289
|
+
onClick: ie,
|
|
290
|
+
disabled: z || !Y,
|
|
291
|
+
className: "rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",
|
|
292
|
+
children: "Revert"
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ p("button", {
|
|
295
|
+
type: "button",
|
|
296
|
+
onClick: () => void oe(),
|
|
297
|
+
disabled: z || !Y,
|
|
298
|
+
className: C,
|
|
299
|
+
children: z ? "Saving…" : "Save"
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
})] }) : /* @__PURE__ */ p("p", {
|
|
303
|
+
className: `${u} leading-relaxed`,
|
|
304
|
+
children: "Loading the camera's grid…"
|
|
305
|
+
})
|
|
306
|
+
})
|
|
307
|
+
}) : null;
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
export { A as MotionZonesSettings };
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { c as e, h as t, m as n, p as r, u as i, y as a } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react__loadShare__.js-Bs1t18EM.mjs";
|
|
2
|
+
import { a as ee, n as te, r as ne, s as o, t as s } from "./responsive-CWwNAY3j.mjs";
|
|
3
|
+
import { n as re, t as c } from "./player-overlays-Dfe_rxmA.mjs";
|
|
4
|
+
import { n as l, r as ie, t as ae } from "./square-ax5XLFv8.mjs";
|
|
5
|
+
import { t as oe } from "./trash-2-CWfC2FLD.mjs";
|
|
6
|
+
import { n as u, r as d, t as se } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DalfdIDw.mjs";
|
|
7
|
+
import { MaskShapeCanvas as ce } from "./MaskShapeCanvas-BEVxAjNq.mjs";
|
|
8
|
+
var le = o("hexagon", [["path", {
|
|
9
|
+
d: "M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",
|
|
10
|
+
key: "yt0hxn"
|
|
11
|
+
}]]), ue = o("mic-off", [
|
|
12
|
+
["path", {
|
|
13
|
+
d: "M12 19v3",
|
|
14
|
+
key: "npa21l"
|
|
15
|
+
}],
|
|
16
|
+
["path", {
|
|
17
|
+
d: "M15 9.34V5a3 3 0 0 0-5.68-1.33",
|
|
18
|
+
key: "1gzdoj"
|
|
19
|
+
}],
|
|
20
|
+
["path", {
|
|
21
|
+
d: "M16.95 16.95A7 7 0 0 1 5 12v-2",
|
|
22
|
+
key: "cqa7eg"
|
|
23
|
+
}],
|
|
24
|
+
["path", {
|
|
25
|
+
d: "M18.89 13.23A7 7 0 0 0 19 12v-2",
|
|
26
|
+
key: "16hl24"
|
|
27
|
+
}],
|
|
28
|
+
["path", {
|
|
29
|
+
d: "m2 2 20 20",
|
|
30
|
+
key: "1ooewy"
|
|
31
|
+
}],
|
|
32
|
+
["path", {
|
|
33
|
+
d: "M9 9v3a3 3 0 0 0 5.12 2.12",
|
|
34
|
+
key: "r2i35w"
|
|
35
|
+
}]
|
|
36
|
+
]);
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region ../ui-library/src/composites/cap-settings/privacy-mask-audio.ts
|
|
39
|
+
a();
|
|
40
|
+
var f = "Microphone", p = "The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.";
|
|
41
|
+
function de(e) {
|
|
42
|
+
let t = e.supportsAudioMute === !0, n = t ? e.audioEnabled : null, r = e.pendingOn ?? null;
|
|
43
|
+
return {
|
|
44
|
+
label: f,
|
|
45
|
+
supported: t,
|
|
46
|
+
on: n === null ? null : r ?? n,
|
|
47
|
+
available: t && n !== null,
|
|
48
|
+
costWhenOff: p
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function m(e) {
|
|
52
|
+
return !e.available || e.on === null ? null : { enabled: !e.on };
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region ../ui-library/src/composites/cap-settings/PrivacyMaskSettings.tsx
|
|
56
|
+
var fe = 120, h = "privacy-mask", g = "rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors", _ = "rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors";
|
|
57
|
+
function v(e) {
|
|
58
|
+
return e.kind === "rect" || e.kind === "polygon" ? e : null;
|
|
59
|
+
}
|
|
60
|
+
function pe(e) {
|
|
61
|
+
let t = new Set(e.map((e) => e.id)), n = 0;
|
|
62
|
+
for (; t.has(n);) n += 1;
|
|
63
|
+
return n;
|
|
64
|
+
}
|
|
65
|
+
function y(e, t) {
|
|
66
|
+
if (e.length !== t.length) return !1;
|
|
67
|
+
for (let n = 0; n < e.length; n += 1) if (JSON.stringify(e[n]) !== JSON.stringify(t[n])) return !1;
|
|
68
|
+
return !0;
|
|
69
|
+
}
|
|
70
|
+
function b({ deviceId: a }) {
|
|
71
|
+
let o = ne(ee().trpcClient, a), [f, p] = t(null), [b, x] = t(!1), [S, C] = t(null), [w, T] = t(null), [E, D] = t(!1), [O, k] = t(!1), [A, j] = t(null), [M, N] = t(null), [me, P] = t(null), [F, I] = t(null), [L, R] = t(null), z = n(!1);
|
|
72
|
+
i(() => {
|
|
73
|
+
if (!o) return;
|
|
74
|
+
let e = !1;
|
|
75
|
+
return z.current = !1, p(null), x(!1), C(null), T(null), k(!1), j(null), N(null), P(null), I(null), R(null), (async () => {
|
|
76
|
+
try {
|
|
77
|
+
let t = await o.privacyMask?.getOptions({});
|
|
78
|
+
if (e) return;
|
|
79
|
+
if (!t) throw Error("device proxy not ready");
|
|
80
|
+
if (p(t), z.current) return;
|
|
81
|
+
let n = await o.privacyMask?.getStatus({});
|
|
82
|
+
if (e) return;
|
|
83
|
+
if (!n) throw Error("device proxy not ready");
|
|
84
|
+
z.current = !0;
|
|
85
|
+
let r = {
|
|
86
|
+
enabled: n.enabled,
|
|
87
|
+
regions: n.regions
|
|
88
|
+
};
|
|
89
|
+
T(r), C(r), P(n.audioEnabled);
|
|
90
|
+
} catch (t) {
|
|
91
|
+
if (e) return;
|
|
92
|
+
te(t) ? x(!0) : console.error("Privacy Mask load failed", t);
|
|
93
|
+
}
|
|
94
|
+
})(), () => {
|
|
95
|
+
e = !0;
|
|
96
|
+
};
|
|
97
|
+
}, [o]);
|
|
98
|
+
let B = r(() => S !== null && w !== null && (S.enabled !== w.enabled || !y(S.regions, w.regions)), [S, w]), V = S ? S.regions.length : 0, H = f ? f.maxRegions : 0, U = n(0);
|
|
99
|
+
i(() => {
|
|
100
|
+
U.current = H;
|
|
101
|
+
}, [H]);
|
|
102
|
+
let W = H > 0 && V >= H, he = e(() => {
|
|
103
|
+
C((e) => e && {
|
|
104
|
+
...e,
|
|
105
|
+
enabled: !e.enabled
|
|
106
|
+
});
|
|
107
|
+
}, []), G = e((e) => {
|
|
108
|
+
j(typeof e == "number" ? e : null);
|
|
109
|
+
}, []), K = r(() => S ? S.regions.map((e) => ({
|
|
110
|
+
id: e.id,
|
|
111
|
+
shape: e.shape,
|
|
112
|
+
enabled: e.enabled,
|
|
113
|
+
label: `Zone ${String(e.id)}`
|
|
114
|
+
})) : [], [S]), q = e((e, t) => {
|
|
115
|
+
let n = v(t);
|
|
116
|
+
n && C((t) => t && {
|
|
117
|
+
...t,
|
|
118
|
+
regions: t.regions.map((t) => t.id === e ? {
|
|
119
|
+
...t,
|
|
120
|
+
shape: n
|
|
121
|
+
} : t)
|
|
122
|
+
});
|
|
123
|
+
}, []), J = e((e) => {
|
|
124
|
+
let t = v(e);
|
|
125
|
+
t && (N(null), C((e) => {
|
|
126
|
+
if (!e) return e;
|
|
127
|
+
let n = U.current;
|
|
128
|
+
if (n > 0 && e.regions.length >= n) return e;
|
|
129
|
+
let r = pe(e.regions), i = {
|
|
130
|
+
id: r,
|
|
131
|
+
enabled: !0,
|
|
132
|
+
shape: t
|
|
133
|
+
};
|
|
134
|
+
return j(r), {
|
|
135
|
+
...e,
|
|
136
|
+
regions: [...e.regions, i]
|
|
137
|
+
};
|
|
138
|
+
}));
|
|
139
|
+
}, []), Y = e((e) => {
|
|
140
|
+
k(!0), j(null), N(e);
|
|
141
|
+
}, []), ge = e((e) => {
|
|
142
|
+
k(!0), N(null), j(e);
|
|
143
|
+
}, []), X = e((e) => {
|
|
144
|
+
j((t) => t === e ? null : t), C((t) => t && {
|
|
145
|
+
...t,
|
|
146
|
+
regions: t.regions.filter((t) => t.id !== e)
|
|
147
|
+
});
|
|
148
|
+
}, []), _e = e(() => {
|
|
149
|
+
N(null), j(null), w && C({
|
|
150
|
+
enabled: w.enabled,
|
|
151
|
+
regions: w.regions
|
|
152
|
+
});
|
|
153
|
+
}, [w]), ve = e(async () => {
|
|
154
|
+
if (!(!o || !S)) {
|
|
155
|
+
D(!0);
|
|
156
|
+
try {
|
|
157
|
+
await o.privacyMask?.setMask({ patch: {
|
|
158
|
+
enabled: S.enabled,
|
|
159
|
+
regions: [...S.regions]
|
|
160
|
+
} });
|
|
161
|
+
let e = await o.privacyMask?.getStatus({});
|
|
162
|
+
if (e) {
|
|
163
|
+
let t = {
|
|
164
|
+
enabled: e.enabled,
|
|
165
|
+
regions: e.regions
|
|
166
|
+
};
|
|
167
|
+
T(t), C(t);
|
|
168
|
+
}
|
|
169
|
+
} catch (e) {
|
|
170
|
+
console.error("Privacy Mask save failed", e);
|
|
171
|
+
} finally {
|
|
172
|
+
D(!1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}, [o, S]), Z = de({
|
|
176
|
+
supportsAudioMute: f === null ? null : f.supportsAudioMute,
|
|
177
|
+
audioEnabled: me,
|
|
178
|
+
pendingOn: F
|
|
179
|
+
}), ye = e(async () => {
|
|
180
|
+
let e = m(Z);
|
|
181
|
+
if (!(!o || e === null)) {
|
|
182
|
+
I(e.enabled), R(null);
|
|
183
|
+
try {
|
|
184
|
+
await o.privacyMask?.setAudioEnabled(e);
|
|
185
|
+
let t = await o.privacyMask?.getStatus({});
|
|
186
|
+
t && P(t.audioEnabled);
|
|
187
|
+
} catch (e) {
|
|
188
|
+
console.error("Privacy microphone write failed — reverting", e), R(e instanceof Error ? e.message : String(e));
|
|
189
|
+
} finally {
|
|
190
|
+
I(null);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}, [o, Z]), be = e(() => {
|
|
194
|
+
k((e) => (e && (N(null), j(null)), !e));
|
|
195
|
+
}, []), Q = f?.supportedShapes ?? [];
|
|
196
|
+
c(r(() => O && !b && f && S ? {
|
|
197
|
+
id: h,
|
|
198
|
+
order: fe,
|
|
199
|
+
node: /* @__PURE__ */ u(ce, {
|
|
200
|
+
transparent: !0,
|
|
201
|
+
items: K,
|
|
202
|
+
supportedShapes: Q,
|
|
203
|
+
polygonVertices: f.polygonVertices,
|
|
204
|
+
selectedId: A,
|
|
205
|
+
onSelect: G,
|
|
206
|
+
onShapeChange: q,
|
|
207
|
+
onDrawComplete: J,
|
|
208
|
+
drawingKind: M
|
|
209
|
+
})
|
|
210
|
+
} : null, [
|
|
211
|
+
O,
|
|
212
|
+
b,
|
|
213
|
+
f,
|
|
214
|
+
S,
|
|
215
|
+
K,
|
|
216
|
+
Q,
|
|
217
|
+
A,
|
|
218
|
+
G,
|
|
219
|
+
q,
|
|
220
|
+
J,
|
|
221
|
+
M
|
|
222
|
+
]));
|
|
223
|
+
let xe = f?.supportedShapes.includes("rect") ?? !1, Se = f?.supportedShapes.includes("polygon") ?? !1, $ = f !== null && (f.maxRegions <= 0 || f.supportedShapes.length === 0);
|
|
224
|
+
return o ? /* @__PURE__ */ u(re, {
|
|
225
|
+
title: "Privacy Mask",
|
|
226
|
+
icon: /* @__PURE__ */ u(ie, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
|
|
227
|
+
children: /* @__PURE__ */ d("div", {
|
|
228
|
+
className: "flex flex-col gap-3",
|
|
229
|
+
children: [b || $ ? /* @__PURE__ */ u("p", {
|
|
230
|
+
className: `${s} leading-relaxed`,
|
|
231
|
+
children: "This camera doesn't support an on-board privacy mask."
|
|
232
|
+
}) : !b && !$ && f !== null && S !== null ? /* @__PURE__ */ d(se, { children: [
|
|
233
|
+
/* @__PURE__ */ d("p", {
|
|
234
|
+
className: `${s} leading-relaxed`,
|
|
235
|
+
children: [
|
|
236
|
+
"Toggle ",
|
|
237
|
+
/* @__PURE__ */ u("strong", {
|
|
238
|
+
className: "text-foreground",
|
|
239
|
+
children: "Edit mask"
|
|
240
|
+
}),
|
|
241
|
+
" to draw blanked-out zones on the live frame, then ",
|
|
242
|
+
/* @__PURE__ */ u("strong", {
|
|
243
|
+
className: "text-foreground",
|
|
244
|
+
children: "Save"
|
|
245
|
+
}),
|
|
246
|
+
" to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it."
|
|
247
|
+
]
|
|
248
|
+
}),
|
|
249
|
+
/* @__PURE__ */ d("div", {
|
|
250
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ u("button", {
|
|
253
|
+
type: "button",
|
|
254
|
+
onClick: be,
|
|
255
|
+
disabled: E,
|
|
256
|
+
"aria-pressed": O,
|
|
257
|
+
className: O ? _ : g,
|
|
258
|
+
children: O ? "Done editing" : "Edit mask"
|
|
259
|
+
}),
|
|
260
|
+
/* @__PURE__ */ u("button", {
|
|
261
|
+
type: "button",
|
|
262
|
+
onClick: he,
|
|
263
|
+
disabled: E,
|
|
264
|
+
"aria-pressed": S.enabled,
|
|
265
|
+
className: S.enabled ? _ : g,
|
|
266
|
+
children: S.enabled ? "Mask on" : "Mask off"
|
|
267
|
+
}),
|
|
268
|
+
xe && /* @__PURE__ */ u("button", {
|
|
269
|
+
type: "button",
|
|
270
|
+
onClick: () => Y("rect"),
|
|
271
|
+
disabled: E || W,
|
|
272
|
+
"aria-pressed": M === "rect",
|
|
273
|
+
className: M === "rect" ? _ : g,
|
|
274
|
+
title: W ? "Maximum zones reached" : "Add a rectangle zone",
|
|
275
|
+
children: "+ Rect"
|
|
276
|
+
}),
|
|
277
|
+
Se && /* @__PURE__ */ u("button", {
|
|
278
|
+
type: "button",
|
|
279
|
+
onClick: () => Y("polygon"),
|
|
280
|
+
disabled: E || W,
|
|
281
|
+
"aria-pressed": M === "polygon",
|
|
282
|
+
className: M === "polygon" ? _ : g,
|
|
283
|
+
title: W ? "Maximum zones reached" : "Add a polygon zone",
|
|
284
|
+
children: "+ Polygon"
|
|
285
|
+
}),
|
|
286
|
+
/* @__PURE__ */ d("span", {
|
|
287
|
+
className: `${s} ml-1 tabular-nums`,
|
|
288
|
+
children: [
|
|
289
|
+
V,
|
|
290
|
+
" / ",
|
|
291
|
+
H,
|
|
292
|
+
" zones"
|
|
293
|
+
]
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ u("span", { className: "flex-1" }),
|
|
296
|
+
/* @__PURE__ */ u("button", {
|
|
297
|
+
type: "button",
|
|
298
|
+
onClick: _e,
|
|
299
|
+
disabled: E || !B,
|
|
300
|
+
className: "rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors",
|
|
301
|
+
children: "Revert"
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ u("button", {
|
|
304
|
+
type: "button",
|
|
305
|
+
onClick: () => void ve(),
|
|
306
|
+
disabled: E || !B,
|
|
307
|
+
className: _,
|
|
308
|
+
children: E ? "Saving…" : "Save"
|
|
309
|
+
})
|
|
310
|
+
]
|
|
311
|
+
}),
|
|
312
|
+
V > 0 ? /* @__PURE__ */ u("div", {
|
|
313
|
+
className: "flex flex-col gap-1",
|
|
314
|
+
children: S.regions.map((e) => {
|
|
315
|
+
let t = A === e.id, n = e.shape.kind === "polygon" ? le : ae;
|
|
316
|
+
return /* @__PURE__ */ d("div", {
|
|
317
|
+
className: `flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${t ? "border-primary/50 bg-primary/10" : "border-border bg-surface"}`,
|
|
318
|
+
children: [/* @__PURE__ */ d("button", {
|
|
319
|
+
type: "button",
|
|
320
|
+
onClick: () => ge(e.id),
|
|
321
|
+
disabled: E,
|
|
322
|
+
className: "flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors",
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ u(n, { className: "h-3.5 w-3.5 shrink-0" }),
|
|
325
|
+
/* @__PURE__ */ d("span", { children: ["Zone ", e.id] }),
|
|
326
|
+
/* @__PURE__ */ u("span", {
|
|
327
|
+
className: "text-foreground-faint capitalize",
|
|
328
|
+
children: e.shape.kind
|
|
329
|
+
})
|
|
330
|
+
]
|
|
331
|
+
}), /* @__PURE__ */ u("button", {
|
|
332
|
+
type: "button",
|
|
333
|
+
onClick: () => X(e.id),
|
|
334
|
+
disabled: E,
|
|
335
|
+
"aria-label": `Delete zone ${String(e.id)}`,
|
|
336
|
+
title: "Delete zone",
|
|
337
|
+
className: "inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors",
|
|
338
|
+
children: /* @__PURE__ */ u(oe, { className: "h-3.5 w-3.5" })
|
|
339
|
+
})]
|
|
340
|
+
}, e.id);
|
|
341
|
+
})
|
|
342
|
+
}) : null
|
|
343
|
+
] }) : /* @__PURE__ */ u("p", {
|
|
344
|
+
className: `${s} leading-relaxed`,
|
|
345
|
+
children: "Loading the camera's privacy mask…"
|
|
346
|
+
}), Z.supported && /* @__PURE__ */ d("div", {
|
|
347
|
+
className: "flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2",
|
|
348
|
+
children: [/* @__PURE__ */ u("button", {
|
|
349
|
+
type: "button",
|
|
350
|
+
role: "switch",
|
|
351
|
+
"aria-label": Z.label,
|
|
352
|
+
"aria-checked": Z.on === !0,
|
|
353
|
+
disabled: !Z.available || F !== null,
|
|
354
|
+
onClick: () => void ye(),
|
|
355
|
+
title: Z.on === null ? "Microphone — state unknown; the camera did not answer." : Z.on ? `The camera is capturing sound. Turning it off: ${Z.costWhenOff}` : `The camera is silent. ${Z.costWhenOff}`,
|
|
356
|
+
className: Z.on === !1 || Z.on === null ? g : _,
|
|
357
|
+
children: /* @__PURE__ */ d("span", {
|
|
358
|
+
className: "inline-flex items-center gap-1.5",
|
|
359
|
+
children: [Z.on === !1 ? /* @__PURE__ */ u(ue, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ u(l, { className: "h-3.5 w-3.5" }), Z.on === null ? "Microphone unknown" : Z.on ? "Microphone on" : "Microphone off"]
|
|
360
|
+
})
|
|
361
|
+
}), /* @__PURE__ */ u("p", {
|
|
362
|
+
className: "text-[10px] text-foreground-subtle flex-1 leading-relaxed",
|
|
363
|
+
children: L === null ? Z.on === null ? "The camera did not report its microphone, so this state is unknown." : Z.costWhenOff : `Write failed: ${L}`
|
|
364
|
+
})]
|
|
365
|
+
})]
|
|
366
|
+
})
|
|
367
|
+
}) : null;
|
|
368
|
+
}
|
|
369
|
+
//#endregion
|
|
370
|
+
export { b as PrivacyMaskSettings };
|