@camstack/ui-library 1.2.51 → 1.2.53
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-DRrdkR4U.js → MotionZonesSettings-DNdnFHso.js} +1 -1
- package/dist/{PrivacyMaskSettings-DsyAfD21.js → PrivacyMaskSettings-DNSLc6ww.js} +1 -1
- package/dist/SceneMonitorEditor-DN2ILWCf.cjs +917 -0
- package/dist/SceneMonitorEditor-d_A4kO-M.js +917 -0
- package/dist/composites/cap-settings/SceneMonitorEditor.d.ts +15 -5
- package/dist/composites/cap-settings/SceneReferenceGallery.d.ts +36 -0
- package/dist/composites/cap-settings/SceneSettingsForm.d.ts +21 -0
- package/dist/composites/cap-settings/scene-monitor-copy.d.ts +37 -5
- package/dist/generated/system-hooks.d.ts +2 -0
- package/dist/index.cjs +72 -12
- package/dist/index.js +75 -17
- package/dist/primitives/input.d.ts +6 -0
- package/dist/primitives/select.d.ts +16 -0
- package/package.json +1 -1
- package/dist/SceneMonitorEditor-CfSrNccC.cjs +0 -281
- package/dist/SceneMonitorEditor-D5BNWAM_.js +0 -281
|
@@ -0,0 +1,917 @@
|
|
|
1
|
+
const require_index = require("./index.cjs");
|
|
2
|
+
const require_MaskShapeCanvas = require("./MaskShapeCanvas-BByN3jvt.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* @license lucide-react v0.576.0 - ISC
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the ISC license.
|
|
9
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/
|
|
11
|
+
var Settings2 = require_index.createLucideIcon("settings-2", [
|
|
12
|
+
["path", {
|
|
13
|
+
d: "M14 17H5",
|
|
14
|
+
key: "gfn3mx"
|
|
15
|
+
}],
|
|
16
|
+
["path", {
|
|
17
|
+
d: "M19 7h-9",
|
|
18
|
+
key: "6i9tg"
|
|
19
|
+
}],
|
|
20
|
+
["circle", {
|
|
21
|
+
cx: "17",
|
|
22
|
+
cy: "17",
|
|
23
|
+
r: "3",
|
|
24
|
+
key: "18b49y"
|
|
25
|
+
}],
|
|
26
|
+
["circle", {
|
|
27
|
+
cx: "7",
|
|
28
|
+
cy: "7",
|
|
29
|
+
r: "3",
|
|
30
|
+
key: "dfmy0x"
|
|
31
|
+
}]
|
|
32
|
+
]);
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/composites/cap-settings/SceneReferenceGallery.tsx
|
|
35
|
+
/** The hub-proxied prefix for the pipeline-analytics event-media data plane. */
|
|
36
|
+
var SCENE_MEDIA_BASE = "/addon/pipeline-analytics/event-media";
|
|
37
|
+
/**
|
|
38
|
+
* Flatten `states[].references[]` into per-condition groups while keeping each
|
|
39
|
+
* reference's `(stateId, index)` — the pair `deleteReference` takes.
|
|
40
|
+
*
|
|
41
|
+
* The index is deliberately the position in the state's OWN array rather than
|
|
42
|
+
* anything derived from the grouping: an index computed over the grouped view
|
|
43
|
+
* would address a different reference the moment a scene holds two conditions,
|
|
44
|
+
* and the operator would delete the wrong photograph with no way to tell.
|
|
45
|
+
*/
|
|
46
|
+
function groupReferences(monitor) {
|
|
47
|
+
const byCondition = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const state of monitor.states) state.references.forEach((reference, index) => {
|
|
49
|
+
const list = byCondition.get(reference.condition) ?? [];
|
|
50
|
+
list.push({
|
|
51
|
+
stateId: state.id,
|
|
52
|
+
index,
|
|
53
|
+
reference
|
|
54
|
+
});
|
|
55
|
+
byCondition.set(reference.condition, list);
|
|
56
|
+
});
|
|
57
|
+
return [...byCondition.entries()].map(([condition, tiles]) => ({
|
|
58
|
+
condition,
|
|
59
|
+
tiles: [...tiles].sort((a, b) => b.reference.capturedAt - a.reference.capturedAt)
|
|
60
|
+
})).sort((a, b) => a.condition.localeCompare(b.condition));
|
|
61
|
+
}
|
|
62
|
+
/** Total references across every state — the count that decides whether a
|
|
63
|
+
* delete leaves the scene with no idea what "normal" looks like. */
|
|
64
|
+
function totalReferences(monitor) {
|
|
65
|
+
return monitor.states.reduce((n, s) => n + s.references.length, 0);
|
|
66
|
+
}
|
|
67
|
+
var BTN_TINY = "rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors";
|
|
68
|
+
function SceneReferenceGallery({ monitor, disabled, onDelete }) {
|
|
69
|
+
const groups = groupReferences(monitor);
|
|
70
|
+
const total = totalReferences(monitor);
|
|
71
|
+
const [confirming, setConfirming] = (0, react.useState)(null);
|
|
72
|
+
if (groups.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
73
|
+
className: `${require_index.TEXT_HINT} leading-relaxed`,
|
|
74
|
+
children: "No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against."
|
|
75
|
+
});
|
|
76
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
77
|
+
className: "flex flex-col gap-2",
|
|
78
|
+
children: groups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
79
|
+
className: "flex flex-col gap-1",
|
|
80
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
81
|
+
className: "text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle",
|
|
82
|
+
children: [
|
|
83
|
+
require_index.variantLabel$1(group.condition),
|
|
84
|
+
" · ",
|
|
85
|
+
group.tiles.length
|
|
86
|
+
]
|
|
87
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
88
|
+
className: "flex flex-wrap gap-1.5",
|
|
89
|
+
children: group.tiles.map((tile) => {
|
|
90
|
+
const key = `${tile.stateId}:${String(tile.index)}`;
|
|
91
|
+
const isLastOverall = total === 1;
|
|
92
|
+
const pending = confirming === key;
|
|
93
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
94
|
+
className: "flex w-24 flex-col gap-1 rounded-md border border-border p-1",
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ReferenceThumb, { reference: tile.reference }),
|
|
97
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
98
|
+
className: `${require_index.TEXT_HINT} tabular-nums`,
|
|
99
|
+
children: formatCapturedAt(tile.reference.capturedAt)
|
|
100
|
+
}),
|
|
101
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
className: BTN_TINY,
|
|
104
|
+
disabled,
|
|
105
|
+
"aria-label": `Delete the ${require_index.variantLabel$1(group.condition).toLowerCase()} photograph from ${formatCapturedAt(tile.reference.capturedAt)}`,
|
|
106
|
+
onClick: () => {
|
|
107
|
+
if (isLastOverall && !pending) {
|
|
108
|
+
setConfirming(key);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
setConfirming(null);
|
|
112
|
+
onDelete({
|
|
113
|
+
stateId: tile.stateId,
|
|
114
|
+
index: tile.index
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.Trash2, { className: "mr-1 inline h-3 w-3" }), pending ? "Confirm" : "Delete"]
|
|
118
|
+
}),
|
|
119
|
+
pending && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
120
|
+
className: "text-[10px] leading-snug text-warning",
|
|
121
|
+
children: "This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again."
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
}, key);
|
|
125
|
+
})
|
|
126
|
+
})]
|
|
127
|
+
}, group.condition))
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function ReferenceThumb({ reference }) {
|
|
131
|
+
const [failed, setFailed] = (0, react.useState)(false);
|
|
132
|
+
const key = reference.thumbnailMediaId;
|
|
133
|
+
if (key === void 0 || failed) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
134
|
+
className: "flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle",
|
|
135
|
+
title: "The picture for this reference is no longer stored. The reference itself is intact and still being scored against.",
|
|
136
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.ImageOff, { className: "h-4 w-4" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
137
|
+
className: "text-[9px]",
|
|
138
|
+
children: "no picture"
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
142
|
+
src: `${SCENE_MEDIA_BASE}/${encodeURIComponent(key)}`,
|
|
143
|
+
alt: "",
|
|
144
|
+
loading: "lazy",
|
|
145
|
+
className: "h-16 w-full rounded object-cover",
|
|
146
|
+
onError: () => setFailed(true)
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function formatCapturedAt(at) {
|
|
150
|
+
const d = new Date(at);
|
|
151
|
+
return `${d.toLocaleDateString()} ${d.toLocaleTimeString([], {
|
|
152
|
+
hour: "2-digit",
|
|
153
|
+
minute: "2-digit"
|
|
154
|
+
})}`;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/composites/cap-settings/SceneSettingsForm.tsx
|
|
158
|
+
var FIELD = "rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50";
|
|
159
|
+
var LABEL = "text-[10px] font-medium text-foreground-subtle";
|
|
160
|
+
var GROUP = "flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2";
|
|
161
|
+
var GROUP_TITLE = "text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle";
|
|
162
|
+
/** The two engine-visible interval floors, in the units the operator thinks in. */
|
|
163
|
+
var MIN_INTERVAL_SEC = 5;
|
|
164
|
+
var MAX_INTERVAL_SEC = 3600;
|
|
165
|
+
var TRIGGER_HINT = {
|
|
166
|
+
periodic: "Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.",
|
|
167
|
+
"on-motion": "Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.",
|
|
168
|
+
both: "Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene."
|
|
169
|
+
};
|
|
170
|
+
var UNCOVERED_HINT = {
|
|
171
|
+
skip: "Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.",
|
|
172
|
+
"judge-anyway": "Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen."
|
|
173
|
+
};
|
|
174
|
+
function draftOf(monitor) {
|
|
175
|
+
return {
|
|
176
|
+
label: monitor.label,
|
|
177
|
+
checkIntervalSec: monitor.checkIntervalSec ?? 60,
|
|
178
|
+
threshold: monitor.check.mode === "similarity" ? monitor.check.threshold : .8,
|
|
179
|
+
hysteresisCount: monitor.check.hysteresisCount,
|
|
180
|
+
quietSeconds: monitor.quietSeconds,
|
|
181
|
+
minObservationSpacingSec: monitor.minObservationSpacingSec,
|
|
182
|
+
confirmPrompt: monitor.confirm?.prompt ?? ""
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function SceneSettingsForm({ monitor, disabled, onPatch }) {
|
|
186
|
+
const [draft, setDraft] = (0, react.useState)(() => draftOf(monitor));
|
|
187
|
+
const [editing, setEditing] = (0, react.useState)(false);
|
|
188
|
+
(0, react.useEffect)(() => {
|
|
189
|
+
if (!editing) setDraft(draftOf(monitor));
|
|
190
|
+
}, [monitor, editing]);
|
|
191
|
+
const commit = (patch) => {
|
|
192
|
+
setEditing(false);
|
|
193
|
+
onPatch(patch);
|
|
194
|
+
};
|
|
195
|
+
/** Patch the check union in place, so a mode's own fields travel with it. */
|
|
196
|
+
const patchCheck = (next) => monitor.check.mode === "similarity" ? {
|
|
197
|
+
mode: "similarity",
|
|
198
|
+
threshold: next.threshold ?? monitor.check.threshold,
|
|
199
|
+
hysteresisCount: next.hysteresisCount ?? monitor.check.hysteresisCount
|
|
200
|
+
} : {
|
|
201
|
+
...monitor.check,
|
|
202
|
+
hysteresisCount: next.hysteresisCount ?? monitor.check.hysteresisCount
|
|
203
|
+
};
|
|
204
|
+
const confirmEnabled = monitor.confirm?.enabled === true;
|
|
205
|
+
const storedThreshold = monitor.check.mode === "similarity" ? monitor.check.threshold : null;
|
|
206
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
207
|
+
className: "flex flex-col gap-2",
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
210
|
+
className: GROUP,
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
213
|
+
className: GROUP_TITLE,
|
|
214
|
+
children: "What it watches"
|
|
215
|
+
}),
|
|
216
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
217
|
+
className: "flex flex-col gap-1",
|
|
218
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
219
|
+
className: LABEL,
|
|
220
|
+
children: "Name"
|
|
221
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
222
|
+
type: "text",
|
|
223
|
+
value: draft.label,
|
|
224
|
+
disabled,
|
|
225
|
+
className: FIELD,
|
|
226
|
+
onFocus: () => setEditing(true),
|
|
227
|
+
onChange: (e) => setDraft((d) => ({
|
|
228
|
+
...d,
|
|
229
|
+
label: e.target.value
|
|
230
|
+
})),
|
|
231
|
+
onBlur: () => {
|
|
232
|
+
const label = draft.label.trim();
|
|
233
|
+
if (label.length > 0 && label !== monitor.label) commit({ label });
|
|
234
|
+
else setEditing(false);
|
|
235
|
+
}
|
|
236
|
+
})]
|
|
237
|
+
}),
|
|
238
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
239
|
+
className: "flex items-center gap-2",
|
|
240
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
241
|
+
type: "checkbox",
|
|
242
|
+
checked: monitor.enabled,
|
|
243
|
+
disabled,
|
|
244
|
+
onChange: (e) => commit({ enabled: e.target.checked })
|
|
245
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
246
|
+
className: LABEL,
|
|
247
|
+
children: "Watching"
|
|
248
|
+
})]
|
|
249
|
+
}),
|
|
250
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
251
|
+
className: require_index.TEXT_HINT,
|
|
252
|
+
children: "Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while."
|
|
253
|
+
}),
|
|
254
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
255
|
+
className: "flex flex-col gap-1",
|
|
256
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
257
|
+
className: LABEL,
|
|
258
|
+
children: "When to look"
|
|
259
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
260
|
+
value: monitor.triggerMode,
|
|
261
|
+
disabled,
|
|
262
|
+
className: FIELD,
|
|
263
|
+
onChange: (e) => {
|
|
264
|
+
const value = e.target.value;
|
|
265
|
+
if (value === "periodic" || value === "on-motion" || value === "both") commit({ triggerMode: value });
|
|
266
|
+
},
|
|
267
|
+
children: [
|
|
268
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
269
|
+
value: "both",
|
|
270
|
+
children: "On the clock and after motion settles"
|
|
271
|
+
}),
|
|
272
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
273
|
+
value: "periodic",
|
|
274
|
+
children: "On the clock only"
|
|
275
|
+
}),
|
|
276
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
277
|
+
value: "on-motion",
|
|
278
|
+
children: "After motion settles only"
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
})]
|
|
282
|
+
}),
|
|
283
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
284
|
+
className: require_index.TEXT_HINT,
|
|
285
|
+
children: TRIGGER_HINT[monitor.triggerMode]
|
|
286
|
+
}),
|
|
287
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
288
|
+
className: "flex flex-col gap-1",
|
|
289
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
290
|
+
className: LABEL,
|
|
291
|
+
children: "Check every (seconds)"
|
|
292
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
293
|
+
type: "number",
|
|
294
|
+
min: MIN_INTERVAL_SEC,
|
|
295
|
+
max: MAX_INTERVAL_SEC,
|
|
296
|
+
value: draft.checkIntervalSec,
|
|
297
|
+
disabled,
|
|
298
|
+
className: FIELD,
|
|
299
|
+
onFocus: () => setEditing(true),
|
|
300
|
+
onChange: (e) => setDraft((d) => ({
|
|
301
|
+
...d,
|
|
302
|
+
checkIntervalSec: Number(e.target.value) || 0
|
|
303
|
+
})),
|
|
304
|
+
onBlur: () => {
|
|
305
|
+
const sec = clamp(draft.checkIntervalSec, MIN_INTERVAL_SEC, MAX_INTERVAL_SEC);
|
|
306
|
+
if (sec !== monitor.checkIntervalSec) commit({ checkIntervalSec: sec });
|
|
307
|
+
else setEditing(false);
|
|
308
|
+
}
|
|
309
|
+
})]
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
312
|
+
className: require_index.TEXT_HINT,
|
|
313
|
+
children: "60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own."
|
|
314
|
+
})
|
|
315
|
+
]
|
|
316
|
+
}),
|
|
317
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
318
|
+
className: GROUP,
|
|
319
|
+
children: [
|
|
320
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
321
|
+
className: GROUP_TITLE,
|
|
322
|
+
children: "How sure it has to be"
|
|
323
|
+
}),
|
|
324
|
+
monitor.check.mode === "similarity" && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
325
|
+
className: "flex flex-col gap-1",
|
|
326
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
327
|
+
className: LABEL,
|
|
328
|
+
children: ["Match threshold — ", /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
329
|
+
className: "tabular-nums",
|
|
330
|
+
children: draft.threshold.toFixed(2)
|
|
331
|
+
})]
|
|
332
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
333
|
+
type: "range",
|
|
334
|
+
min: .3,
|
|
335
|
+
max: .99,
|
|
336
|
+
step: .01,
|
|
337
|
+
value: draft.threshold,
|
|
338
|
+
disabled,
|
|
339
|
+
onFocus: () => setEditing(true),
|
|
340
|
+
onChange: (e) => setDraft((d) => ({
|
|
341
|
+
...d,
|
|
342
|
+
threshold: Number(e.target.value)
|
|
343
|
+
})),
|
|
344
|
+
onMouseUp: () => {
|
|
345
|
+
if (draft.threshold !== storedThreshold) commit({ check: patchCheck({ threshold: draft.threshold }) });
|
|
346
|
+
else setEditing(false);
|
|
347
|
+
},
|
|
348
|
+
onBlur: () => {
|
|
349
|
+
if (draft.threshold !== storedThreshold) commit({ check: patchCheck({ threshold: draft.threshold }) });
|
|
350
|
+
else setEditing(false);
|
|
351
|
+
}
|
|
352
|
+
})]
|
|
353
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
354
|
+
className: "text-[10px] text-foreground-subtle",
|
|
355
|
+
children: "How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it."
|
|
356
|
+
})] }),
|
|
357
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
358
|
+
className: "flex flex-col gap-1",
|
|
359
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
360
|
+
className: LABEL,
|
|
361
|
+
children: "Agreeing checks before it changes its mind"
|
|
362
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
363
|
+
type: "number",
|
|
364
|
+
min: 1,
|
|
365
|
+
max: 10,
|
|
366
|
+
value: draft.hysteresisCount,
|
|
367
|
+
disabled,
|
|
368
|
+
className: FIELD,
|
|
369
|
+
onFocus: () => setEditing(true),
|
|
370
|
+
onChange: (e) => setDraft((d) => ({
|
|
371
|
+
...d,
|
|
372
|
+
hysteresisCount: Number(e.target.value) || 1
|
|
373
|
+
})),
|
|
374
|
+
onBlur: () => {
|
|
375
|
+
const n = clamp(draft.hysteresisCount, 1, 10);
|
|
376
|
+
if (n !== monitor.check.hysteresisCount) commit({ check: patchCheck({ hysteresisCount: n }) });
|
|
377
|
+
else setEditing(false);
|
|
378
|
+
}
|
|
379
|
+
})]
|
|
380
|
+
}),
|
|
381
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
382
|
+
className: require_index.TEXT_HINT,
|
|
383
|
+
children: "One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one."
|
|
384
|
+
}),
|
|
385
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
386
|
+
className: "flex flex-col gap-1",
|
|
387
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
388
|
+
className: LABEL,
|
|
389
|
+
children: "Quiet for (seconds) before a check counts"
|
|
390
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
391
|
+
type: "number",
|
|
392
|
+
min: 0,
|
|
393
|
+
max: 3600,
|
|
394
|
+
value: draft.quietSeconds,
|
|
395
|
+
disabled,
|
|
396
|
+
className: FIELD,
|
|
397
|
+
onFocus: () => setEditing(true),
|
|
398
|
+
onChange: (e) => setDraft((d) => ({
|
|
399
|
+
...d,
|
|
400
|
+
quietSeconds: Number(e.target.value) || 0
|
|
401
|
+
})),
|
|
402
|
+
onBlur: () => {
|
|
403
|
+
const sec = clamp(draft.quietSeconds, 0, 3600);
|
|
404
|
+
if (sec !== monitor.quietSeconds) commit({ quietSeconds: sec });
|
|
405
|
+
else setEditing(false);
|
|
406
|
+
}
|
|
407
|
+
})]
|
|
408
|
+
}),
|
|
409
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
410
|
+
className: require_index.TEXT_HINT,
|
|
411
|
+
children: "A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate."
|
|
412
|
+
}),
|
|
413
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
414
|
+
className: "flex flex-col gap-1",
|
|
415
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
416
|
+
className: LABEL,
|
|
417
|
+
children: "Minimum gap between counted checks (seconds)"
|
|
418
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
419
|
+
type: "number",
|
|
420
|
+
min: 0,
|
|
421
|
+
max: 3600,
|
|
422
|
+
value: draft.minObservationSpacingSec,
|
|
423
|
+
disabled,
|
|
424
|
+
className: FIELD,
|
|
425
|
+
onFocus: () => setEditing(true),
|
|
426
|
+
onChange: (e) => setDraft((d) => ({
|
|
427
|
+
...d,
|
|
428
|
+
minObservationSpacingSec: Number(e.target.value) || 0
|
|
429
|
+
})),
|
|
430
|
+
onBlur: () => {
|
|
431
|
+
const sec = clamp(draft.minObservationSpacingSec, 0, 3600);
|
|
432
|
+
if (sec !== monitor.minObservationSpacingSec) commit({ minObservationSpacingSec: sec });
|
|
433
|
+
else setEditing(false);
|
|
434
|
+
}
|
|
435
|
+
})]
|
|
436
|
+
}),
|
|
437
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
438
|
+
className: require_index.TEXT_HINT,
|
|
439
|
+
children: "Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions."
|
|
440
|
+
})
|
|
441
|
+
]
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
444
|
+
className: GROUP,
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
447
|
+
className: GROUP_TITLE,
|
|
448
|
+
children: "Lighting"
|
|
449
|
+
}),
|
|
450
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
451
|
+
className: "flex flex-col gap-1",
|
|
452
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
453
|
+
className: LABEL,
|
|
454
|
+
children: "When a light has no reference of its own"
|
|
455
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
456
|
+
value: monitor.onUncoveredCondition,
|
|
457
|
+
disabled,
|
|
458
|
+
className: FIELD,
|
|
459
|
+
onChange: (e) => {
|
|
460
|
+
const value = e.target.value;
|
|
461
|
+
if (value === "skip" || value === "judge-anyway") commit({ onUncoveredCondition: value });
|
|
462
|
+
},
|
|
463
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
464
|
+
value: "skip",
|
|
465
|
+
children: "Skip the check (recommended)"
|
|
466
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
467
|
+
value: "judge-anyway",
|
|
468
|
+
children: "Judge against the other light anyway"
|
|
469
|
+
})]
|
|
470
|
+
})]
|
|
471
|
+
}),
|
|
472
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
473
|
+
className: require_index.TEXT_HINT,
|
|
474
|
+
children: UNCOVERED_HINT[monitor.onUncoveredCondition]
|
|
475
|
+
})
|
|
476
|
+
]
|
|
477
|
+
}),
|
|
478
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
479
|
+
className: GROUP,
|
|
480
|
+
children: [
|
|
481
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
482
|
+
className: GROUP_TITLE,
|
|
483
|
+
children: "What you get told"
|
|
484
|
+
}),
|
|
485
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
486
|
+
className: "flex flex-col gap-1",
|
|
487
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
488
|
+
className: LABEL,
|
|
489
|
+
children: "Notifications follow"
|
|
490
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
491
|
+
value: monitor.emit,
|
|
492
|
+
disabled,
|
|
493
|
+
className: FIELD,
|
|
494
|
+
onChange: (e) => {
|
|
495
|
+
const value = e.target.value;
|
|
496
|
+
if (value === "latched" || value === "live") commit({ emit: value });
|
|
497
|
+
},
|
|
498
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
499
|
+
value: "latched",
|
|
500
|
+
children: "The flag — told once, still visible at breakfast"
|
|
501
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
502
|
+
value: "live",
|
|
503
|
+
children: "The live state — follows the region as it changes"
|
|
504
|
+
})]
|
|
505
|
+
})]
|
|
506
|
+
}),
|
|
507
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
508
|
+
className: require_index.TEXT_HINT,
|
|
509
|
+
children: "“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state."
|
|
510
|
+
}),
|
|
511
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
512
|
+
className: "flex items-center gap-2",
|
|
513
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
514
|
+
type: "checkbox",
|
|
515
|
+
checked: monitor.autoRestore,
|
|
516
|
+
disabled,
|
|
517
|
+
onChange: (e) => commit({ autoRestore: e.target.checked })
|
|
518
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
519
|
+
className: LABEL,
|
|
520
|
+
children: "Clear the flag by itself when things look normal again"
|
|
521
|
+
})]
|
|
522
|
+
}),
|
|
523
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
524
|
+
className: require_index.TEXT_HINT,
|
|
525
|
+
children: "Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it."
|
|
526
|
+
})
|
|
527
|
+
]
|
|
528
|
+
}),
|
|
529
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
530
|
+
className: GROUP,
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
533
|
+
className: GROUP_TITLE,
|
|
534
|
+
children: "AI double-check"
|
|
535
|
+
}),
|
|
536
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
537
|
+
className: "flex items-center gap-2",
|
|
538
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
539
|
+
type: "checkbox",
|
|
540
|
+
checked: confirmEnabled,
|
|
541
|
+
disabled: disabled || draft.confirmPrompt.trim().length === 0,
|
|
542
|
+
onChange: (e) => commit(e.target.checked ? { confirm: {
|
|
543
|
+
...defaultConfirm(draft.confirmPrompt.trim()),
|
|
544
|
+
enabled: true
|
|
545
|
+
} } : { confirm: null })
|
|
546
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
547
|
+
className: LABEL,
|
|
548
|
+
children: "Ask a vision model before changing the answer"
|
|
549
|
+
})]
|
|
550
|
+
}),
|
|
551
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
552
|
+
className: "flex flex-col gap-1",
|
|
553
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
554
|
+
className: LABEL,
|
|
555
|
+
children: "The question to ask"
|
|
556
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
557
|
+
type: "text",
|
|
558
|
+
value: draft.confirmPrompt,
|
|
559
|
+
placeholder: "e.g. Is the wheelie bin still there?",
|
|
560
|
+
disabled,
|
|
561
|
+
className: FIELD,
|
|
562
|
+
onFocus: () => setEditing(true),
|
|
563
|
+
onChange: (e) => setDraft((d) => ({
|
|
564
|
+
...d,
|
|
565
|
+
confirmPrompt: e.target.value
|
|
566
|
+
})),
|
|
567
|
+
onBlur: () => {
|
|
568
|
+
const prompt = draft.confirmPrompt.trim();
|
|
569
|
+
if (prompt.length > 0 && prompt !== monitor.confirm?.prompt) commit({ confirm: {
|
|
570
|
+
...defaultConfirm(prompt),
|
|
571
|
+
enabled: confirmEnabled
|
|
572
|
+
} });
|
|
573
|
+
else setEditing(false);
|
|
574
|
+
}
|
|
575
|
+
})]
|
|
576
|
+
}),
|
|
577
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
578
|
+
className: require_index.TEXT_HINT,
|
|
579
|
+
children: [
|
|
580
|
+
"The model is asked ",
|
|
581
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "only" }),
|
|
582
|
+
" when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced."
|
|
583
|
+
]
|
|
584
|
+
})
|
|
585
|
+
]
|
|
586
|
+
})
|
|
587
|
+
]
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
function clamp(value, min, max) {
|
|
591
|
+
return Math.min(max, Math.max(min, value));
|
|
592
|
+
}
|
|
593
|
+
/** The adjudicator's own defaults, restated here because a Zod `.default()`
|
|
594
|
+
* does not run on the cap path — the provider receives exactly this object. */
|
|
595
|
+
function defaultConfirm(prompt) {
|
|
596
|
+
return {
|
|
597
|
+
enabled: false,
|
|
598
|
+
prompt,
|
|
599
|
+
timeoutMs: 8e3,
|
|
600
|
+
maxImagePx: 448,
|
|
601
|
+
onTimeout: "hold"
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/composites/cap-settings/SceneMonitorEditor.tsx
|
|
606
|
+
var BTN_NEUTRAL = "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";
|
|
607
|
+
var BTN_PRIMARY = "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";
|
|
608
|
+
var BTN_DANGER = "rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors";
|
|
609
|
+
var TONE_CLASS = {
|
|
610
|
+
alarm: "border-danger/50 bg-danger/15 text-danger",
|
|
611
|
+
ok: "border-success/50 bg-success/15 text-success",
|
|
612
|
+
unknown: "border-border bg-surface text-foreground-subtle"
|
|
613
|
+
};
|
|
614
|
+
/** A scene without at least one reference cannot judge anything, so the
|
|
615
|
+
* similarity threshold only becomes meaningful after the first capture. */
|
|
616
|
+
var DEFAULT_THRESHOLD = .8;
|
|
617
|
+
var DEFAULT_HYSTERESIS = 3;
|
|
618
|
+
function SceneMonitorEditor({ deviceId }) {
|
|
619
|
+
const dev = require_index.useDeviceProxy$1(require_index.useSystem$1().trpcClient, deviceId);
|
|
620
|
+
const pushed = require_index.useDeviceStateSlice$1(dev?.state.sceneMonitor);
|
|
621
|
+
const snapshot = require_index.useDeviceSnapshotImage$1(deviceId, { width: 640 });
|
|
622
|
+
const [fetched, setFetched] = (0, react.useState)(null);
|
|
623
|
+
const [unsupported, setUnsupported] = (0, react.useState)(false);
|
|
624
|
+
const [busy, setBusy] = (0, react.useState)(null);
|
|
625
|
+
const [error, setError] = (0, react.useState)(null);
|
|
626
|
+
const [selectedId, setSelectedId] = (0, react.useState)(null);
|
|
627
|
+
/** Which scene has its settings panel open — one at a time, because the panel
|
|
628
|
+
* is tall and a wall of them would bury the list it belongs to. */
|
|
629
|
+
const [tuningId, setTuningId] = (0, react.useState)(null);
|
|
630
|
+
const [drafting, setDrafting] = (0, react.useState)(false);
|
|
631
|
+
const [draftRoi, setDraftRoi] = (0, react.useState)(null);
|
|
632
|
+
const [draftLabel, setDraftLabel] = (0, react.useState)("");
|
|
633
|
+
const mounted = (0, react.useRef)(true);
|
|
634
|
+
(0, react.useEffect)(() => {
|
|
635
|
+
mounted.current = true;
|
|
636
|
+
return () => {
|
|
637
|
+
mounted.current = false;
|
|
638
|
+
};
|
|
639
|
+
}, []);
|
|
640
|
+
const reload = (0, react.useCallback)(async () => {
|
|
641
|
+
if (!dev) return;
|
|
642
|
+
try {
|
|
643
|
+
const status = await dev.sceneMonitor?.listScenes({});
|
|
644
|
+
if (!mounted.current) return;
|
|
645
|
+
if (status) setFetched(status);
|
|
646
|
+
} catch (err) {
|
|
647
|
+
if (!mounted.current) return;
|
|
648
|
+
if (require_index.isAbsentProvider$1(err)) setUnsupported(true);
|
|
649
|
+
else setError(err instanceof Error ? err.message : String(err));
|
|
650
|
+
}
|
|
651
|
+
}, [dev]);
|
|
652
|
+
(0, react.useEffect)(() => {
|
|
653
|
+
setFetched(null);
|
|
654
|
+
setUnsupported(false);
|
|
655
|
+
setError(null);
|
|
656
|
+
reload();
|
|
657
|
+
}, [reload]);
|
|
658
|
+
const monitors = pushed?.monitors ?? fetched?.monitors ?? [];
|
|
659
|
+
const now = Date.now();
|
|
660
|
+
const run = (0, react.useCallback)(async (key, fn) => {
|
|
661
|
+
setBusy(key);
|
|
662
|
+
setError(null);
|
|
663
|
+
try {
|
|
664
|
+
await fn();
|
|
665
|
+
await reload();
|
|
666
|
+
} catch (err) {
|
|
667
|
+
if (mounted.current) setError(err instanceof Error ? err.message : String(err));
|
|
668
|
+
} finally {
|
|
669
|
+
if (mounted.current) setBusy(null);
|
|
670
|
+
}
|
|
671
|
+
}, [reload]);
|
|
672
|
+
const items = (0, react.useMemo)(() => {
|
|
673
|
+
const existing = monitors.map((m) => ({
|
|
674
|
+
id: m.id,
|
|
675
|
+
shape: m.roi,
|
|
676
|
+
label: m.label,
|
|
677
|
+
enabled: m.enabled
|
|
678
|
+
}));
|
|
679
|
+
return draftRoi !== null ? [...existing, {
|
|
680
|
+
id: "__draft__",
|
|
681
|
+
shape: draftRoi,
|
|
682
|
+
label: "New scene"
|
|
683
|
+
}] : existing;
|
|
684
|
+
}, [monitors, draftRoi]);
|
|
685
|
+
const onShapeChange = (0, react.useCallback)((id, shape) => {
|
|
686
|
+
if (shape.kind !== "rect") return;
|
|
687
|
+
if (id === "__draft__") {
|
|
688
|
+
setDraftRoi(shape);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
run(`roi-${String(id)}`, async () => dev?.sceneMonitor?.updateScene({
|
|
692
|
+
monitorId: String(id),
|
|
693
|
+
patch: { roi: shape }
|
|
694
|
+
}));
|
|
695
|
+
}, [dev, run]);
|
|
696
|
+
const onDrawComplete = (0, react.useCallback)((shape) => {
|
|
697
|
+
if (shape.kind !== "rect") return;
|
|
698
|
+
setDraftRoi(shape);
|
|
699
|
+
}, []);
|
|
700
|
+
const createScene = (0, react.useCallback)(async () => {
|
|
701
|
+
if (draftRoi === null || draftLabel.trim().length === 0) return;
|
|
702
|
+
await run("create", async () => {
|
|
703
|
+
await dev?.sceneMonitor?.createScene({
|
|
704
|
+
label: draftLabel.trim(),
|
|
705
|
+
roi: draftRoi,
|
|
706
|
+
check: {
|
|
707
|
+
mode: "similarity",
|
|
708
|
+
threshold: DEFAULT_THRESHOLD,
|
|
709
|
+
hysteresisCount: DEFAULT_HYSTERESIS
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
});
|
|
713
|
+
setDraftRoi(null);
|
|
714
|
+
setDraftLabel("");
|
|
715
|
+
setDrafting(false);
|
|
716
|
+
}, [
|
|
717
|
+
dev,
|
|
718
|
+
draftRoi,
|
|
719
|
+
draftLabel,
|
|
720
|
+
run
|
|
721
|
+
]);
|
|
722
|
+
if (!dev) return null;
|
|
723
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
724
|
+
className: "flex flex-col gap-3",
|
|
725
|
+
children: unsupported ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
726
|
+
className: `${require_index.TEXT_HINT} leading-relaxed`,
|
|
727
|
+
children: "Scene monitoring is not available for this camera."
|
|
728
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
729
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
730
|
+
className: `${require_index.TEXT_HINT} leading-relaxed`,
|
|
731
|
+
children: "A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem."
|
|
732
|
+
}),
|
|
733
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
734
|
+
className: "relative overflow-hidden rounded-md border border-border",
|
|
735
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_MaskShapeCanvas.MaskShapeCanvas, {
|
|
736
|
+
items,
|
|
737
|
+
supportedShapes: ["rect"],
|
|
738
|
+
selectedId: selectedId ?? (draftRoi !== null ? "__draft__" : null),
|
|
739
|
+
onSelect: (id) => setSelectedId(id === null ? null : String(id)),
|
|
740
|
+
onShapeChange,
|
|
741
|
+
onDrawComplete,
|
|
742
|
+
drawingKind: drafting && draftRoi === null ? "rect" : null,
|
|
743
|
+
backdrop: snapshot.src !== null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
744
|
+
src: snapshot.src,
|
|
745
|
+
alt: "",
|
|
746
|
+
className: "h-full w-full object-contain",
|
|
747
|
+
draggable: false
|
|
748
|
+
}) : null
|
|
749
|
+
})
|
|
750
|
+
}),
|
|
751
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
752
|
+
className: "flex flex-wrap items-center gap-2",
|
|
753
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
754
|
+
type: "button",
|
|
755
|
+
className: drafting ? BTN_PRIMARY : BTN_NEUTRAL,
|
|
756
|
+
"aria-pressed": drafting,
|
|
757
|
+
onClick: () => {
|
|
758
|
+
setDrafting((v) => !v);
|
|
759
|
+
setDraftRoi(null);
|
|
760
|
+
},
|
|
761
|
+
disabled: busy !== null,
|
|
762
|
+
children: drafting ? "Cancel" : "+ New scene"
|
|
763
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
764
|
+
type: "button",
|
|
765
|
+
className: BTN_NEUTRAL,
|
|
766
|
+
onClick: snapshot.refresh,
|
|
767
|
+
disabled: busy !== null,
|
|
768
|
+
children: "Refresh frame"
|
|
769
|
+
})]
|
|
770
|
+
}),
|
|
771
|
+
drafting && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
772
|
+
className: "flex flex-col gap-2 rounded-md border border-border bg-surface p-2",
|
|
773
|
+
children: [
|
|
774
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
775
|
+
className: "text-[10px] text-foreground-subtle",
|
|
776
|
+
children: draftRoi === null ? "Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched." : "Name it, then create. You capture what “normal” looks like next."
|
|
777
|
+
}),
|
|
778
|
+
draftRoi !== null && require_index.roiTooLarge$1(draftRoi) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
779
|
+
className: "text-[11px] leading-relaxed text-warning",
|
|
780
|
+
children: "That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter."
|
|
781
|
+
}),
|
|
782
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
783
|
+
className: "flex items-center gap-2",
|
|
784
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
785
|
+
type: "text",
|
|
786
|
+
value: draftLabel,
|
|
787
|
+
onChange: (e) => setDraftLabel(e.target.value),
|
|
788
|
+
placeholder: "e.g. Immondizia prelevata",
|
|
789
|
+
className: "flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground"
|
|
790
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
791
|
+
type: "button",
|
|
792
|
+
className: BTN_PRIMARY,
|
|
793
|
+
onClick: () => void createScene(),
|
|
794
|
+
disabled: draftRoi === null || draftLabel.trim().length === 0 || busy !== null,
|
|
795
|
+
children: "Create"
|
|
796
|
+
})]
|
|
797
|
+
})
|
|
798
|
+
]
|
|
799
|
+
}),
|
|
800
|
+
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
801
|
+
className: "text-[11px] leading-relaxed text-danger",
|
|
802
|
+
children: error
|
|
803
|
+
}),
|
|
804
|
+
monitors.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
805
|
+
className: `${require_index.TEXT_HINT} leading-relaxed`,
|
|
806
|
+
children: "No scenes on this camera yet."
|
|
807
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
808
|
+
className: "flex flex-col gap-2",
|
|
809
|
+
children: monitors.map((m) => {
|
|
810
|
+
const badge = require_index.badgeFor$1(m);
|
|
811
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
812
|
+
className: `flex flex-col gap-1.5 rounded-md border p-2 ${selectedId === m.id ? "border-primary/50" : "border-border"}`,
|
|
813
|
+
children: [
|
|
814
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
815
|
+
className: "flex items-center gap-2",
|
|
816
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
817
|
+
type: "button",
|
|
818
|
+
className: "flex-1 text-left text-[12px] font-medium text-foreground",
|
|
819
|
+
onClick: () => setSelectedId(m.id),
|
|
820
|
+
children: m.label
|
|
821
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
822
|
+
className: `rounded border px-1.5 py-0.5 text-[10px] font-medium ${TONE_CLASS[badge.tone]}`,
|
|
823
|
+
children: badge.text
|
|
824
|
+
})]
|
|
825
|
+
}),
|
|
826
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
827
|
+
className: `${require_index.TEXT_HINT} leading-relaxed`,
|
|
828
|
+
children: require_index.statusLine$1(m, now)
|
|
829
|
+
}),
|
|
830
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
831
|
+
className: `${require_index.TEXT_HINT} tabular-nums`,
|
|
832
|
+
children: require_index.coverageLine$1(m)
|
|
833
|
+
}),
|
|
834
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SceneReferenceGallery, {
|
|
835
|
+
monitor: m,
|
|
836
|
+
disabled: busy !== null,
|
|
837
|
+
onDelete: ({ stateId, index }) => void run(`refdel-${m.id}-${stateId}-${String(index)}`, async () => dev.sceneMonitor?.deleteReference({
|
|
838
|
+
monitorId: m.id,
|
|
839
|
+
stateId,
|
|
840
|
+
index
|
|
841
|
+
}))
|
|
842
|
+
}),
|
|
843
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
844
|
+
className: "flex flex-wrap items-center gap-1.5",
|
|
845
|
+
children: [
|
|
846
|
+
require_index.SCENE_CAPTURE_VARIANTS$1.map((variant) => {
|
|
847
|
+
const optional = variant === "ir";
|
|
848
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
849
|
+
type: "button",
|
|
850
|
+
className: BTN_NEUTRAL,
|
|
851
|
+
disabled: busy !== null,
|
|
852
|
+
title: optional ? "Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken." : `Take a fresh photo now and store it as the ${require_index.variantLabel$1(variant).toLowerCase()} reference`,
|
|
853
|
+
onClick: () => void run(`cap-${m.id}-${variant}`, async () => dev.sceneMonitor?.captureReference({
|
|
854
|
+
monitorId: m.id,
|
|
855
|
+
condition: variant
|
|
856
|
+
})),
|
|
857
|
+
children: [
|
|
858
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.Camera, { className: "mr-1 inline h-3 w-3" }),
|
|
859
|
+
"Capture ",
|
|
860
|
+
require_index.variantLabel$1(variant).toLowerCase(),
|
|
861
|
+
optional && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
862
|
+
className: "ml-1 text-foreground-subtle/70",
|
|
863
|
+
children: "(optional)"
|
|
864
|
+
})
|
|
865
|
+
]
|
|
866
|
+
}, variant);
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
869
|
+
type: "button",
|
|
870
|
+
className: BTN_PRIMARY,
|
|
871
|
+
disabled: busy !== null || m.states.length === 0,
|
|
872
|
+
title: "Clear the flag and re-photograph what normal looks like right now",
|
|
873
|
+
onClick: () => void run(`reset-${m.id}`, async () => dev.sceneMonitor?.resetScene({ monitorId: m.id })),
|
|
874
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.RotateCcw, { className: "mr-1 inline h-3 w-3" }), "Reset"]
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
877
|
+
type: "button",
|
|
878
|
+
className: BTN_NEUTRAL,
|
|
879
|
+
disabled: busy !== null,
|
|
880
|
+
onClick: () => void run(`check-${m.id}`, async () => dev.sceneMonitor?.recheckNow({ monitorId: m.id })),
|
|
881
|
+
children: "Check now"
|
|
882
|
+
}),
|
|
883
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
884
|
+
type: "button",
|
|
885
|
+
className: tuningId === m.id ? BTN_PRIMARY : BTN_NEUTRAL,
|
|
886
|
+
"aria-pressed": tuningId === m.id,
|
|
887
|
+
"aria-label": `Settings for ${m.label}`,
|
|
888
|
+
disabled: busy !== null,
|
|
889
|
+
onClick: () => setTuningId((id) => id === m.id ? null : m.id),
|
|
890
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Settings2, { className: "mr-1 inline h-3 w-3" }), "Settings"]
|
|
891
|
+
}),
|
|
892
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
893
|
+
type: "button",
|
|
894
|
+
className: BTN_DANGER,
|
|
895
|
+
disabled: busy !== null,
|
|
896
|
+
onClick: () => void run(`del-${m.id}`, async () => dev.sceneMonitor?.deleteScene({ monitorId: m.id })),
|
|
897
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.Trash2, { className: "h-3 w-3" })
|
|
898
|
+
})
|
|
899
|
+
]
|
|
900
|
+
}),
|
|
901
|
+
tuningId === m.id && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SceneSettingsForm, {
|
|
902
|
+
monitor: m,
|
|
903
|
+
disabled: busy !== null,
|
|
904
|
+
onPatch: (patch) => void run(`tune-${m.id}`, async () => dev.sceneMonitor?.updateScene({
|
|
905
|
+
monitorId: m.id,
|
|
906
|
+
patch
|
|
907
|
+
}))
|
|
908
|
+
})
|
|
909
|
+
]
|
|
910
|
+
}, m.id);
|
|
911
|
+
})
|
|
912
|
+
})
|
|
913
|
+
] })
|
|
914
|
+
});
|
|
915
|
+
}
|
|
916
|
+
//#endregion
|
|
917
|
+
exports.SceneMonitorEditor = SceneMonitorEditor;
|