@camstack/addon-agent-ui 1.2.223 → 1.2.225
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/addon.js +154 -15
- package/dist/assets/{MotionZonesSettings-b6j5P0td.js → MotionZonesSettings-CPKtd12O.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-DlZOnQ9p.js → PrivacyMaskSettings-6Q_POrNo.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-CVC2AazP.js → SceneMonitorEditor-CrPdjhSZ.js} +1 -1
- package/dist/assets/index-3obeECEN.js +112 -0
- package/dist/assets/{index-BiU4ptxq.css → index-CVOTA2bi.css} +1 -1
- package/dist/index.html +2 -2
- package/package.json +9 -3
- package/dist/assets/index-D2J511q8.js +0 -112
package/dist/addon.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
//#region ../types/dist/event-category-
|
|
3
|
+
//#region ../types/dist/event-category-C4hVnRo8.mjs
|
|
4
4
|
var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
5
5
|
EventCategory["SystemBoot"] = "system.boot";
|
|
6
6
|
EventCategory["SystemAddonsReady"] = "system.addons-ready";
|
|
@@ -219,7 +219,17 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
|
|
|
219
219
|
EventCategory["RecordingStopped"] = "recording.stopped";
|
|
220
220
|
EventCategory["RecordingError"] = "recording.error";
|
|
221
221
|
EventCategory["RecordingHealthDegraded"] = "recording.health.degraded";
|
|
222
|
+
/** Recording enabled but no segment finalized for the NC stall window. */
|
|
223
|
+
EventCategory["RecordingHealthStalled"] = "recording.health.stalled";
|
|
224
|
+
/** Recovery from {@link RecordingHealthStalled}. */
|
|
225
|
+
EventCategory["RecordingHealthOk"] = "recording.health.ok";
|
|
222
226
|
EventCategory["RecordingStorageCritical"] = "recording.storage.critical";
|
|
227
|
+
/** Free space on a storage location crossed the warn bar. */
|
|
228
|
+
EventCategory["StorageLocationLow"] = "storage.location.low";
|
|
229
|
+
/** Free space at/under the critical bar, or capacity probe failed (`null`). */
|
|
230
|
+
EventCategory["StorageLocationCritical"] = "storage.location.critical";
|
|
231
|
+
/** Recovery from low/critical on a storage location. */
|
|
232
|
+
EventCategory["StorageLocationOk"] = "storage.location.ok";
|
|
223
233
|
EventCategory["RecordingSegmentWritten"] = "recording.segment.written";
|
|
224
234
|
EventCategory["RecordingPolicyFallback"] = "recording.policy.fallback";
|
|
225
235
|
EventCategory["RecordingRetentionCompleted"] = "recording.retention.completed";
|
|
@@ -5378,7 +5388,7 @@ var ZodIssueCode = {
|
|
|
5378
5388
|
var ZodFirstPartyTypeKind;
|
|
5379
5389
|
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
|
|
5380
5390
|
//#endregion
|
|
5381
|
-
//#region ../types/dist/sleep-
|
|
5391
|
+
//#region ../types/dist/sleep-B_3F_YwS.mjs
|
|
5382
5392
|
/**
|
|
5383
5393
|
* The audio chunk plane's byte format, and the ONE expansion from a coded
|
|
5384
5394
|
* window to float samples (D455).
|
|
@@ -7979,6 +7989,21 @@ var ProfileRtspEntrySchema = object({
|
|
|
7979
7989
|
codec: string().optional(),
|
|
7980
7990
|
resolution: CamStreamResolutionSchema.optional()
|
|
7981
7991
|
});
|
|
7992
|
+
/**
|
|
7993
|
+
* The model weight formats a catalog entry can ship. Schema-free on purpose:
|
|
7994
|
+
* `types/models.ts` builds Zod schemas from it, but a runner-closure consumer
|
|
7995
|
+
* (the model downloader in `@camstack/system`) needs only the list and must
|
|
7996
|
+
* reach it through `@camstack/types/addon` without building the cap schema
|
|
7997
|
+
* graph (D28).
|
|
7998
|
+
*/
|
|
7999
|
+
var MODEL_FORMATS = [
|
|
8000
|
+
"onnx",
|
|
8001
|
+
"coreml",
|
|
8002
|
+
"openvino",
|
|
8003
|
+
"tflite",
|
|
8004
|
+
"pt",
|
|
8005
|
+
"gguf"
|
|
8006
|
+
];
|
|
7982
8007
|
object({
|
|
7983
8008
|
field: string().min(1),
|
|
7984
8009
|
on: literal("advance")
|
|
@@ -8470,7 +8495,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
|
|
|
8470
8495
|
return DeviceRole;
|
|
8471
8496
|
}({});
|
|
8472
8497
|
//#endregion
|
|
8473
|
-
//#region ../types/dist/composition-
|
|
8498
|
+
//#region ../types/dist/composition-C-WpVYTX.mjs
|
|
8474
8499
|
/**
|
|
8475
8500
|
* The ffmpeg build every CamStack node downloads, per platform and arch.
|
|
8476
8501
|
*
|
|
@@ -8522,7 +8547,7 @@ var BASE = `https://github.com/jellyfin/jellyfin-ffmpeg/releases/download/v${FFM
|
|
|
8522
8547
|
function portable(target) {
|
|
8523
8548
|
return `${BASE}/jellyfin-ffmpeg_${FFMPEG_RELEASE}_portable_${target}-gpl.tar.xz`;
|
|
8524
8549
|
}
|
|
8525
|
-
portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64")
|
|
8550
|
+
portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac64"), `${BASE}${FFMPEG_RELEASE}`;
|
|
8526
8551
|
/**
|
|
8527
8552
|
* THE table "which boolean of this device type counts as HIGH", and the
|
|
8528
8553
|
* pure evaluator of its EDGE.
|
|
@@ -11714,14 +11739,6 @@ var MASK_SUPPLY_STEP_IDS = ["segmentation"];
|
|
|
11714
11739
|
...CROP_SUPPLY_STEP_IDS,
|
|
11715
11740
|
...MASK_SUPPLY_STEP_IDS
|
|
11716
11741
|
];
|
|
11717
|
-
var MODEL_FORMATS = [
|
|
11718
|
-
"onnx",
|
|
11719
|
-
"coreml",
|
|
11720
|
-
"openvino",
|
|
11721
|
-
"tflite",
|
|
11722
|
-
"pt",
|
|
11723
|
-
"gguf"
|
|
11724
|
-
];
|
|
11725
11742
|
/**
|
|
11726
11743
|
* Multi-file format payload.
|
|
11727
11744
|
*
|
|
@@ -13868,6 +13885,16 @@ var BrokerClientsSchema = object({
|
|
|
13868
13885
|
/** Total encoded + raw-RTP callback subscriber count (sum of `encoded[].length`). */
|
|
13869
13886
|
encodedSubscribers: number()
|
|
13870
13887
|
});
|
|
13888
|
+
/**
|
|
13889
|
+
* How many people are watching one camera LIVE right now — see
|
|
13890
|
+
* `getLiveViewerCounts`. A camera with nobody watching is absent from the list
|
|
13891
|
+
* (so `viewers` is always at least 1): the listing carries the cameras that
|
|
13892
|
+
* have viewers, never a row of zeros.
|
|
13893
|
+
*/
|
|
13894
|
+
var LiveViewerCountSchema = object({
|
|
13895
|
+
deviceId: number().int().nonnegative(),
|
|
13896
|
+
viewers: number().int().positive()
|
|
13897
|
+
});
|
|
13871
13898
|
_enum([
|
|
13872
13899
|
"reconnecting",
|
|
13873
13900
|
"sleeping",
|
|
@@ -14228,7 +14255,7 @@ method(object({
|
|
|
14228
14255
|
}), {
|
|
14229
14256
|
kind: "mutation",
|
|
14230
14257
|
auth: "admin"
|
|
14231
|
-
}), method(object({ brokerId: string() }), BrokerClientsSchema), method(object({
|
|
14258
|
+
}), method(object({ brokerId: string() }), BrokerClientsSchema), method(_void(), array(LiveViewerCountSchema).readonly()), method(object({
|
|
14232
14259
|
brokerId: string(),
|
|
14233
14260
|
channel: _enum(["rtsp", "audio"]),
|
|
14234
14261
|
handle: string()
|
|
@@ -20165,6 +20192,12 @@ var NcSystemEventKindSchema = _enum([
|
|
|
20165
20192
|
"node-updating",
|
|
20166
20193
|
"node-inference-unavailable",
|
|
20167
20194
|
"detection-blind",
|
|
20195
|
+
"recording-stalled",
|
|
20196
|
+
"recording-healthy",
|
|
20197
|
+
"recording-degraded",
|
|
20198
|
+
"storage-location-low",
|
|
20199
|
+
"storage-location-critical",
|
|
20200
|
+
"storage-location-ok",
|
|
20168
20201
|
"addon-crash-loop",
|
|
20169
20202
|
"addon-update-available",
|
|
20170
20203
|
"server-update-available",
|
|
@@ -27633,6 +27666,12 @@ var CameraStepOverridePatchSchema = object({
|
|
|
27633
27666
|
settings: record(string(), unknown()).readonly().optional()
|
|
27634
27667
|
});
|
|
27635
27668
|
var CameraStepSettingsSchema = record(string(), record(string(), unknown()).readonly());
|
|
27669
|
+
/** The three root-detector choices a camera has (D507: at most one root). */
|
|
27670
|
+
var CameraDetectionSourceSchema = _enum([
|
|
27671
|
+
"pipeline",
|
|
27672
|
+
"onboard",
|
|
27673
|
+
"none"
|
|
27674
|
+
]);
|
|
27636
27675
|
var CameraPipelineSettingsSchema = object({
|
|
27637
27676
|
stepToggles: record(string(), boolean()).optional(),
|
|
27638
27677
|
stepSettings: CameraStepSettingsSchema.optional(),
|
|
@@ -28210,6 +28249,26 @@ method(object({
|
|
|
28210
28249
|
}), object({ success: literal(true) }), {
|
|
28211
28250
|
kind: "mutation",
|
|
28212
28251
|
auth: "admin"
|
|
28252
|
+
}), method(object({ deviceId: number() }), object({
|
|
28253
|
+
source: CameraDetectionSourceSchema,
|
|
28254
|
+
explicit: boolean(),
|
|
28255
|
+
onboard: object({
|
|
28256
|
+
/** The camera has an onboard detector this system can read. */
|
|
28257
|
+
available: boolean(),
|
|
28258
|
+
/** What its detections carry — a camera with no box cannot be a root step. */
|
|
28259
|
+
geometry: _enum([
|
|
28260
|
+
"boxed",
|
|
28261
|
+
"while-streaming",
|
|
28262
|
+
"flag-only",
|
|
28263
|
+
"unknown"
|
|
28264
|
+
])
|
|
28265
|
+
})
|
|
28266
|
+
})), method(object({
|
|
28267
|
+
deviceId: number(),
|
|
28268
|
+
source: CameraDetectionSourceSchema
|
|
28269
|
+
}), object({ success: literal(true) }), {
|
|
28270
|
+
kind: "mutation",
|
|
28271
|
+
auth: "admin"
|
|
28213
28272
|
}), method(object({ deviceId: number() }), record(string(), record(string(), record(string(), CameraStepOverridePatchSchema))).nullable()), method(object({
|
|
28214
28273
|
deviceId: number(),
|
|
28215
28274
|
agentNodeId: string(),
|
|
@@ -31541,6 +31600,17 @@ var BatteryStatusSchema = object({
|
|
|
31541
31600
|
*/
|
|
31542
31601
|
lastContactAt: number().optional(),
|
|
31543
31602
|
/**
|
|
31603
|
+
* Ms epoch of the last COMPLETE scheduled refresh — every fact the provider
|
|
31604
|
+
* holds for the device (level, charging, link, device info, state slices) and
|
|
31605
|
+
* its cached snapshot, read together. Absent = never since this slice was
|
|
31606
|
+
* born. Unlike `lastUpdated` (any write, even a push of one field) this is
|
|
31607
|
+
* the staleness an operator can trust: the provider owns the device fact and
|
|
31608
|
+
* so owns the window on its age (D224, D847). Not a clock in the
|
|
31609
|
+
* runtime-state-durability sense: it moves once per window and must survive
|
|
31610
|
+
* a restart, or every restart would owe the camera a wake.
|
|
31611
|
+
*/
|
|
31612
|
+
lastFullRefreshAt: number().optional(),
|
|
31613
|
+
/**
|
|
31544
31614
|
* True when the source is a BINARY low-battery indicator (HA
|
|
31545
31615
|
* `binary_sensor` device_class=battery / `LOW_BAT`) that has no real
|
|
31546
31616
|
* charge level — `percentage` is then a coarse stand-in (100 = normal,
|
|
@@ -34756,7 +34826,14 @@ var TopologyNodeSchema = object({
|
|
|
34756
34826
|
* completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
|
|
34757
34827
|
* for offline rows and when the hub cannot tell.
|
|
34758
34828
|
*/
|
|
34759
|
-
meshTransport: _enum(["tls", "clear"]).optional()
|
|
34829
|
+
meshTransport: _enum(["tls", "clear"]).optional(),
|
|
34830
|
+
/**
|
|
34831
|
+
* Whether the hub holds this online AGENT's capability registration (its
|
|
34832
|
+
* `registerNode` manifest). `false` = online in the mesh but not ready: the
|
|
34833
|
+
* hub dropped the registration on a disconnect only it saw and the agent has
|
|
34834
|
+
* not re-sent it. Absent for the hub and offline rows.
|
|
34835
|
+
*/
|
|
34836
|
+
capabilitiesRegistered: boolean().optional()
|
|
34760
34837
|
});
|
|
34761
34838
|
var CapUsageEdgeSchema = object({
|
|
34762
34839
|
callerAddonId: string(),
|
|
@@ -44918,6 +44995,12 @@ Object.freeze({
|
|
|
44918
44995
|
addonId: null,
|
|
44919
44996
|
access: "view"
|
|
44920
44997
|
},
|
|
44998
|
+
"pipelineOrchestrator.getCameraDetectionSource": {
|
|
44999
|
+
capName: "pipeline-orchestrator",
|
|
45000
|
+
capScope: "system",
|
|
45001
|
+
addonId: null,
|
|
45002
|
+
access: "view"
|
|
45003
|
+
},
|
|
44921
45004
|
"pipelineOrchestrator.getCameraMetrics": {
|
|
44922
45005
|
capName: "pipeline-orchestrator",
|
|
44923
45006
|
capScope: "system",
|
|
@@ -45146,6 +45229,12 @@ Object.freeze({
|
|
|
45146
45229
|
addonId: null,
|
|
45147
45230
|
access: "create"
|
|
45148
45231
|
},
|
|
45232
|
+
"pipelineOrchestrator.setCameraDetectionSource": {
|
|
45233
|
+
capName: "pipeline-orchestrator",
|
|
45234
|
+
capScope: "system",
|
|
45235
|
+
addonId: null,
|
|
45236
|
+
access: "create"
|
|
45237
|
+
},
|
|
45149
45238
|
"pipelineOrchestrator.setCameraPipelineForAgent": {
|
|
45150
45239
|
capName: "pipeline-orchestrator",
|
|
45151
45240
|
capScope: "system",
|
|
@@ -46598,6 +46687,12 @@ Object.freeze({
|
|
|
46598
46687
|
addonId: null,
|
|
46599
46688
|
access: "view"
|
|
46600
46689
|
},
|
|
46690
|
+
"streamBroker.getLiveViewerCounts": {
|
|
46691
|
+
capName: "stream-broker",
|
|
46692
|
+
capScope: "system",
|
|
46693
|
+
addonId: null,
|
|
46694
|
+
access: "view"
|
|
46695
|
+
},
|
|
46601
46696
|
"streamBroker.getPreBufferInfo": {
|
|
46602
46697
|
capName: "stream-broker",
|
|
46603
46698
|
capScope: "system",
|
|
@@ -50743,6 +50838,11 @@ Object.freeze({
|
|
|
50743
50838
|
form: "single",
|
|
50744
50839
|
optional: false
|
|
50745
50840
|
}],
|
|
50841
|
+
"pipelineOrchestrator.getCameraDetectionSource": [{
|
|
50842
|
+
name: "deviceId",
|
|
50843
|
+
form: "single",
|
|
50844
|
+
optional: false
|
|
50845
|
+
}],
|
|
50746
50846
|
"pipelineOrchestrator.getCameraMetrics": [{
|
|
50747
50847
|
name: "deviceId",
|
|
50748
50848
|
form: "single",
|
|
@@ -50803,6 +50903,11 @@ Object.freeze({
|
|
|
50803
50903
|
form: "single",
|
|
50804
50904
|
optional: false
|
|
50805
50905
|
}],
|
|
50906
|
+
"pipelineOrchestrator.setCameraDetectionSource": [{
|
|
50907
|
+
name: "deviceId",
|
|
50908
|
+
form: "single",
|
|
50909
|
+
optional: false
|
|
50910
|
+
}],
|
|
50806
50911
|
"pipelineOrchestrator.setCameraPipelineForAgent": [{
|
|
50807
50912
|
name: "deviceId",
|
|
50808
50913
|
form: "single",
|
|
@@ -51832,6 +51937,9 @@ new Map(Object.entries({
|
|
|
51832
51937
|
"stream-online": "device-events",
|
|
51833
51938
|
"stream-offline": "device-events",
|
|
51834
51939
|
"detection-blind": "device-events",
|
|
51940
|
+
"recording-stalled": "device-events",
|
|
51941
|
+
"recording-healthy": "device-events",
|
|
51942
|
+
"recording-degraded": "device-events",
|
|
51835
51943
|
"node-online": "system",
|
|
51836
51944
|
"node-offline": "system",
|
|
51837
51945
|
"node-restarting": "system",
|
|
@@ -51845,6 +51953,9 @@ new Map(Object.entries({
|
|
|
51845
51953
|
"wrapper-update-available": "system",
|
|
51846
51954
|
"backup-completed": "system",
|
|
51847
51955
|
"export-completed": "system",
|
|
51956
|
+
"storage-location-low": "system",
|
|
51957
|
+
"storage-location-critical": "system",
|
|
51958
|
+
"storage-location-ok": "system",
|
|
51848
51959
|
"alarm-triggered": "alarm",
|
|
51849
51960
|
"alarm-armed": "alarm",
|
|
51850
51961
|
"alarm-disarmed": "alarm",
|
|
@@ -51906,6 +52017,16 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
51906
52017
|
label: "Detecting nothing",
|
|
51907
52018
|
kinds: ["detection-blind"]
|
|
51908
52019
|
},
|
|
52020
|
+
{
|
|
52021
|
+
id: "recording",
|
|
52022
|
+
family: "device-events",
|
|
52023
|
+
label: "Recording",
|
|
52024
|
+
kinds: [
|
|
52025
|
+
"recording-stalled",
|
|
52026
|
+
"recording-healthy",
|
|
52027
|
+
"recording-degraded"
|
|
52028
|
+
]
|
|
52029
|
+
},
|
|
51909
52030
|
{
|
|
51910
52031
|
id: "nodes",
|
|
51911
52032
|
family: "system",
|
|
@@ -51946,6 +52067,16 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
|
|
|
51946
52067
|
label: "Backups & exports",
|
|
51947
52068
|
kinds: ["backup-completed", "export-completed"]
|
|
51948
52069
|
},
|
|
52070
|
+
{
|
|
52071
|
+
id: "storage",
|
|
52072
|
+
family: "system",
|
|
52073
|
+
label: "Storage locations",
|
|
52074
|
+
kinds: [
|
|
52075
|
+
"storage-location-low",
|
|
52076
|
+
"storage-location-critical",
|
|
52077
|
+
"storage-location-ok"
|
|
52078
|
+
]
|
|
52079
|
+
},
|
|
51949
52080
|
{
|
|
51950
52081
|
id: "alarm",
|
|
51951
52082
|
family: "alarm",
|
|
@@ -52028,6 +52159,9 @@ var DEVICE_EVENTS = [
|
|
|
52028
52159
|
"stream-online",
|
|
52029
52160
|
"stream-offline",
|
|
52030
52161
|
"detection-blind",
|
|
52162
|
+
"recording-stalled",
|
|
52163
|
+
"recording-healthy",
|
|
52164
|
+
"recording-degraded",
|
|
52031
52165
|
...ALARM
|
|
52032
52166
|
];
|
|
52033
52167
|
/** Every kind a summary may speak about — the two summarisable families. */
|
|
@@ -52195,6 +52329,11 @@ var STATE_SUMMARY_VARS = [
|
|
|
52195
52329
|
[...RULE_TEXT],
|
|
52196
52330
|
[...RULE_TEXT],
|
|
52197
52331
|
[...RULE_TEXT],
|
|
52332
|
+
[...RULE_TEXT],
|
|
52333
|
+
[...RULE_TEXT],
|
|
52334
|
+
[...RULE_TEXT],
|
|
52335
|
+
[...RULE_TEXT],
|
|
52336
|
+
[...RULE_TEXT],
|
|
52198
52337
|
([...RULE_TEXT], [...UPDATES]),
|
|
52199
52338
|
([...RULE_TEXT], [...PACKAGE_UPDATES]),
|
|
52200
52339
|
([...RULE_TEXT], [...PACKAGE_UPDATES]),
|
|
@@ -52767,7 +52906,7 @@ var AgentUIAddon = class extends BaseAddon {
|
|
|
52767
52906
|
capability: adminUiCapability,
|
|
52768
52907
|
provider: {
|
|
52769
52908
|
getStaticDir: async () => ({ staticDir: path.resolve(__dirname) }),
|
|
52770
|
-
getVersion: async () => ({ version: "1.2.
|
|
52909
|
+
getVersion: async () => ({ version: "1.2.225" })
|
|
52771
52910
|
}
|
|
52772
52911
|
}];
|
|
52773
52912
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,r as n}from"./scheduler-mSeF_D00.js";import{C as r,c as i,d as a,h as o,l as s,p as c,t as l}from"./index-
|
|
1
|
+
import{n as e,o as t,r as n}from"./scheduler-mSeF_D00.js";import{C as r,c as i,d as a,h as o,l as s,p as c,t as l}from"./index-3obeECEN.js";import{MaskShapeCanvas as u}from"./MaskShapeCanvas-u4Ka7P5T.js";var d=r(`grid-2x2`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}]]),f=t(n(),1),p=t(e(),1),m=110,h=`motion-zones`,g=0,_=[1,2,3],v=1,y=`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`,b=`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`;function x(e,t,n){let r=t*n,i=Array.from({length:r});for(let t=0;t<r;t+=1)i[t]=e[t]===!0;return i}function S(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]!==t[n])return!1;return!0}function C(e,t){return Math.ceil(e/t)}function w(e,t,n){return Math.min(n-1,Math.floor((e+.5)/t*n))}function T(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:i*a},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)e[r*t+n]===!0&&(o[s*i+w(n,t,i)]=!0)}return o}function E(e,t,n,r){let i=C(t,r),a=C(n,r),o=Array.from({length:t*n},()=>!1);for(let r=0;r<n;r+=1){let s=w(r,n,a);for(let n=0;n<t;n+=1)o[r*t+n]=e[s*i+w(n,t,i)]===!0}return o}function D({deviceId:e}){let t=a(o().trpcClient,e),[n,r]=(0,f.useState)(null),[w,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(null),[M,N]=(0,f.useState)(v),[P,F]=(0,f.useState)(!1),[I,L]=(0,f.useState)(!1),R=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(!t)return;let e=!1;return R.current=!1,r(null),D(!1),k(null),j(null),N(v),L(!1),(async()=>{try{let n=await t.motionZones?.getOptions({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(r(n),R.current)return;let i=await t.motionZones?.getStatus({});if(e)return;if(!i)throw Error(`device proxy not ready`);R.current=!0;let a=i.regions.find(e=>e.shape.kind===`grid`),o=x(a?a.shape.cells:[],n.grid.width,n.grid.height);j(o),k(T(o,n.grid.width,n.grid.height,v))}catch(t){if(e)return;s(t)?D(!0):console.error(`Motion Zones load failed`,t)}})(),()=>{e=!0}},[t]);let z=n?n.grid.width:0,B=n?n.grid.height:0,V=C(z,M),H=C(B,M),U=(0,f.useMemo)(()=>O&&n?E(O,z,B,M):null,[O,n,z,B,M]),W=(0,f.useMemo)(()=>U!==null&&A!==null&&!S(U,A),[U,A]),G=(0,f.useMemo)(()=>U?U.reduce((e,t)=>t?e+1:e,0):0,[U]),K=z*B,q=V*H,J=(0,f.useCallback)(e=>{q>0&&k(Array.from({length:q},()=>e))},[q]),Y=(0,f.useCallback)(()=>{k(e=>e&&e.map(e=>!e))},[]),X=(0,f.useCallback)(()=>{A&&n&&k(T(A,z,B,M))},[A,n,z,B,M]),Z=(0,f.useCallback)(e=>{e===M||!n||k(t=>{if(!t)return N(e),t;let n=T(E(t,z,B,M),z,B,e);return N(e),n})},[M,n,z,B]),Q=(0,f.useMemo)(()=>n&&O?[{id:g,shape:{kind:`grid`,gridWidth:V,gridHeight:H,cells:[...O]}}]:[],[n,O,V,H]),$=(0,f.useCallback)((e,t)=>{t.kind===`grid`&&k(t.cells)},[]),ee=(0,f.useCallback)(async()=>{if(!(!t||!O||!n)){F(!0);try{let e=E(O,n.grid.width,n.grid.height,M),r={kind:`grid`,gridWidth:n.grid.width,gridHeight:n.grid.height,cells:e};await t.motionZones?.setZone({patch:{regions:[{id:g,enabled:!0,shape:r}]}});let i=await t.motionZones?.getStatus({});if(i){let e=i.regions.find(e=>e.shape.kind===`grid`),t=x(e?e.shape.cells:[],n.grid.width,n.grid.height);j(t),k(T(t,n.grid.width,n.grid.height,M))}}catch(e){console.error(`Motion Zones save failed`,e)}finally{F(!1)}}},[t,O,n,M]);l((0,f.useMemo)(()=>I&&!w&&n&&O?{id:h,order:m,node:(0,p.jsx)(u,{transparent:!0,items:Q,supportedShapes:[`grid`],grid:{width:V,height:H},selectedId:g,onSelect:()=>{},onShapeChange:$,onDrawComplete:()=>{},drawingKind:null})}:null,[I,w,n,O,Q,$,V,H]));let te=!w&&n!==null&&O!==null;return t?(0,p.jsx)(c,{title:`Motion Zones`,icon:(0,p.jsx)(d,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,p.jsx)(`div`,{className:`flex flex-col gap-3`,children:w?(0,p.jsx)(`p`,{className:`${i} leading-relaxed`,children:`This camera doesn't expose an on-board motion zones grid.`}):te?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`${i} leading-relaxed`,children:[`Toggle `,(0,p.jsx)(`strong`,{className:`text-foreground`,children:`Edit grid`}),` to paint the region directly on the live frame, then `,(0,p.jsx)(`strong`,{className:`text-foreground`,children:`Save`}),` to push the mask to the camera. Pick a bigger`,` `,(0,p.jsx)(`strong`,{className:`text-foreground`,children:`Cell size`}),` for quicker, broad-stroke painting — it's resampled to the camera's native `,n.grid.width,`×`,n.grid.height,` grid on save (×1 is the finest).`]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,p.jsx)(`button`,{type:`button`,onClick:()=>L(e=>!e),disabled:P,"aria-pressed":I,className:I?b:y,children:I?`Done editing`:`Edit grid`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>J(!0),disabled:P,className:y,children:`All on`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>J(!1),disabled:P,className:y,children:`All off`}),(0,p.jsx)(`button`,{type:`button`,onClick:Y,disabled:P,className:y,children:`Invert`}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1 ml-1`,role:`group`,"aria-label":`Cell size`,children:[(0,p.jsx)(`span`,{className:`${i} mr-0.5`,children:`Cell size`}),_.map(e=>(0,p.jsxs)(`button`,{type:`button`,onClick:()=>Z(e),disabled:P,"aria-pressed":M===e,title:e===1?`Camera grid ${z}×${B} (finest)`:`${C(z,e)}×${C(B,e)} painting grid · cells ×${e} bigger`,className:M===e?b:y,children:[`×`,e]},e))]}),(0,p.jsxs)(`span`,{className:`${i} ml-1 tabular-nums`,children:[G,` / `,K,` cells · `,n.grid.width,`×`,n.grid.height,M===1?``:` · paint ${V}×${H}`]}),(0,p.jsx)(`span`,{className:`flex-1`}),(0,p.jsx)(`button`,{type:`button`,onClick:X,disabled:P||!W,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`,children:`Revert`}),(0,p.jsx)(`button`,{type:`button`,onClick:()=>void ee(),disabled:P||!W,className:b,children:P?`Saving…`:`Save`})]})]}):(0,p.jsx)(`p`,{className:`${i} leading-relaxed`,children:`Loading the camera's grid…`})})}):null}export{D as MotionZonesSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,r as n}from"./scheduler-mSeF_D00.js";import{C as r,_ as i,c as a,d as o,g as ee,h as te,l as s,p as c,t as l,x as ne,y as u}from"./index-
|
|
1
|
+
import{n as e,o as t,r as n}from"./scheduler-mSeF_D00.js";import{C as r,_ as i,c as a,d as o,g as ee,h as te,l as s,p as c,t as l,x as ne,y as u}from"./index-3obeECEN.js";import{MaskShapeCanvas as re}from"./MaskShapeCanvas-u4Ka7P5T.js";var ie=r(`hexagon`,[[`path`,{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`,key:`yt0hxn`}]]),d=r(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),f=t(n(),1),p=`Microphone`,m=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function h(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:p,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:m}}function ae(e){return!e.available||e.on===null?null:{enabled:!e.on}}var g=t(e(),1),oe=120,_=`privacy-mask`,v=`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`,y=`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`;function b(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function se(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function ce(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function x({deviceId:e}){let t=o(te().trpcClient,e),[n,r]=(0,f.useState)(null),[p,m]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(!1),[k,A]=(0,f.useState)(!1),[j,M]=(0,f.useState)(null),[N,P]=(0,f.useState)(null),[le,F]=(0,f.useState)(null),[I,L]=(0,f.useState)(null),[R,z]=(0,f.useState)(null),B=(0,f.useRef)(!1);(0,f.useEffect)(()=>{if(!t)return;let e=!1;return B.current=!1,r(null),m(!1),S(!1),w(null),E(null),A(!1),M(null),P(null),F(null),L(null),z(null),(async()=>{try{let n=await t.privacyMask?.getOptions({});if(e)return;if(!n)throw Error(`device proxy not ready`);if(r(n),B.current)return;let i=await t.privacyMask?.getStatus({});if(e)return;if(!i)throw Error(`device proxy not ready`);if(i.regions===null){S(!0),F(i.audioEnabled);return}B.current=!0;let a={enabled:i.enabled,regions:i.regions};E(a),w(a),F(i.audioEnabled)}catch(t){if(e)return;s(t)?m(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[t]);let V=(0,f.useMemo)(()=>C!==null&&T!==null&&(C.enabled!==T.enabled||!ce(C.regions,T.regions)),[C,T]),H=C?C.regions.length:0,U=n?n.maxRegions:0,W=(0,f.useRef)(0);(0,f.useEffect)(()=>{W.current=U},[U]);let G=U>0&&H>=U,ue=(0,f.useCallback)(()=>{w(e=>e&&{...e,enabled:!e.enabled})},[]),K=(0,f.useCallback)(e=>{M(typeof e==`number`?e:null)},[]),q=(0,f.useMemo)(()=>C?C.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:`Zone ${String(e.id)}`})):[],[C]),J=(0,f.useCallback)((e,t)=>{let n=b(t);n&&w(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),Y=(0,f.useCallback)(e=>{let t=b(e);t&&(P(null),w(e=>{if(!e)return e;let n=W.current;if(n>0&&e.regions.length>=n)return e;let r=se(e.regions),i={id:r,enabled:!0,shape:t};return M(r),{...e,regions:[...e.regions,i]}}))},[]),X=(0,f.useCallback)(e=>{A(!0),M(null),P(e)},[]),de=(0,f.useCallback)(e=>{A(!0),P(null),M(e)},[]),fe=(0,f.useCallback)(e=>{M(t=>t===e?null:t),w(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),pe=(0,f.useCallback)(()=>{P(null),M(null),T&&w({enabled:T.enabled,regions:T.regions})},[T]),me=(0,f.useCallback)(async()=>{if(!(!t||!C)){O(!0);try{await t.privacyMask?.setMask({patch:{enabled:C.enabled,regions:[...C.regions]}});let e=await t.privacyMask?.getStatus({});if(e&&e.regions!==null){let t={enabled:e.enabled,regions:e.regions};E(t),w(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{O(!1)}}},[t,C]),Z=h({supportsAudioMute:n===null?null:n.supportsAudioMute,audioEnabled:le,pendingOn:I}),he=(0,f.useCallback)(async()=>{let e=ae(Z);if(!(!t||e===null)){L(e.enabled),z(null);try{await t.privacyMask?.setAudioEnabled(e);let n=await t.privacyMask?.getStatus({});n&&F(n.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),z(e instanceof Error?e.message:String(e))}finally{L(null)}}},[t,Z]),ge=(0,f.useCallback)(()=>{A(e=>(e&&(P(null),M(null)),!e))},[]),Q=n?.supportedShapes??[];l((0,f.useMemo)(()=>k&&!p&&n&&C?{id:_,order:oe,node:(0,g.jsx)(re,{transparent:!0,items:q,supportedShapes:Q,polygonVertices:n.polygonVertices,selectedId:j,onSelect:K,onShapeChange:J,onDrawComplete:Y,drawingKind:N})}:null,[k,p,n,C,q,Q,j,K,J,Y,N]));let _e=n?.supportedShapes.includes(`rect`)??!1,ve=n?.supportedShapes.includes(`polygon`)??!1,$=n!==null&&(n.maxRegions<=0||n.supportedShapes.length===0),ye=!p&&!$&&!x&&n!==null&&C!==null;return t?(0,g.jsx)(c,{title:`Privacy Mask`,icon:(0,g.jsx)(ne,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:(0,g.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[p||$?(0,g.jsx)(`p`,{className:`${a} leading-relaxed`,children:`This camera doesn't support an on-board privacy mask.`}):x?(0,g.jsx)(`p`,{className:`${a} leading-relaxed`,children:`This camera hasn't answered, so what it currently masks is unknown — the editor stays closed rather than showing an empty frame you could save over. A battery camera answers once it wakes; otherwise check that it is reachable.`}):ye?(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`p`,{className:`${a} leading-relaxed`,children:[`Toggle `,(0,g.jsx)(`strong`,{className:`text-foreground`,children:`Edit mask`}),` to draw blanked-out zones on the live frame, then `,(0,g.jsx)(`strong`,{className:`text-foreground`,children:`Save`}),` 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.`]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,g.jsx)(`button`,{type:`button`,onClick:ge,disabled:D,"aria-pressed":k,className:k?y:v,children:k?`Done editing`:`Edit mask`}),(0,g.jsx)(`button`,{type:`button`,onClick:ue,disabled:D,"aria-pressed":C.enabled,className:C.enabled?y:v,children:C.enabled?`Mask on`:`Mask off`}),_e&&(0,g.jsx)(`button`,{type:`button`,onClick:()=>X(`rect`),disabled:D||G,"aria-pressed":N===`rect`,className:N===`rect`?y:v,title:G?`Maximum zones reached`:`Add a rectangle zone`,children:`+ Rect`}),ve&&(0,g.jsx)(`button`,{type:`button`,onClick:()=>X(`polygon`),disabled:D||G,"aria-pressed":N===`polygon`,className:N===`polygon`?y:v,title:G?`Maximum zones reached`:`Add a polygon zone`,children:`+ Polygon`}),(0,g.jsxs)(`span`,{className:`${a} ml-1 tabular-nums`,children:[H,` / `,U,` zones`]}),(0,g.jsx)(`span`,{className:`flex-1`}),(0,g.jsx)(`button`,{type:`button`,onClick:pe,disabled:D||!V,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`,children:`Revert`}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>void me(),disabled:D||!V,className:y,children:D?`Saving…`:`Save`})]}),H>0?(0,g.jsx)(`div`,{className:`flex flex-col gap-1`,children:C.regions.map(e=>{let t=j===e.id,n=e.shape.kind===`polygon`?ie:i;return(0,g.jsxs)(`div`,{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`}`,children:[(0,g.jsxs)(`button`,{type:`button`,onClick:()=>de(e.id),disabled:D,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`,children:[(0,g.jsx)(n,{className:`h-3.5 w-3.5 shrink-0`}),(0,g.jsxs)(`span`,{children:[`Zone `,e.id]}),(0,g.jsx)(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>fe(e.id),disabled:D,"aria-label":`Delete zone ${String(e.id)}`,title:`Delete zone`,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`,children:(0,g.jsx)(ee,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):(0,g.jsx)(`p`,{className:`${a} leading-relaxed`,children:`Loading the camera's privacy mask…`}),Z.supported&&(0,g.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[(0,g.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":Z.label,"aria-checked":Z.on===!0,disabled:!Z.available||I!==null,onClick:()=>void he(),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}`,className:Z.on===!1||Z.on===null?v:y,children:(0,g.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[Z.on===!1?(0,g.jsx)(d,{className:`h-3.5 w-3.5`}):(0,g.jsx)(u,{className:`h-3.5 w-3.5`}),Z.on===null?`Microphone unknown`:Z.on?`Microphone on`:`Microphone off`]})}),(0,g.jsx)(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:R===null?Z.on===null?`The camera did not report its microphone, so this state is unknown.`:Z.costWhenOff:`Write failed: ${R}`})]})]})}):null}export{x as PrivacyMaskSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,o as t,r as n}from"./scheduler-mSeF_D00.js";import{C as r,S as i,a,b as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,r as _,s as v,u as y,v as b}from"./index-D2J511q8.js";import{MaskShapeCanvas as x}from"./MaskShapeCanvas-u4Ka7P5T.js";var S=r(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),C=t(n(),1),w=t(e(),1),T=m(`/addon/pipeline-analytics/event-media`);function E(e){return`${T}/m/${e}`}function D(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function O(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var k=`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`;function A({monitor:e,disabled:t,onDelete:n}){let r=D(e),i=O(e),[a,o]=(0,C.useState)(null);return r.length===0?(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`}):(0,w.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,w.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,w.jsxs)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[v(e.condition),` · `,e.tiles.length]}),(0,w.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(r=>{let c=`${r.stateId}:${String(r.index)}`,l=i===1,d=a===c;return(0,w.jsxs)(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[(0,w.jsx)(j,{reference:r.reference}),(0,w.jsx)(`span`,{className:`${s} tabular-nums`,children:M(r.reference.capturedAt)}),(0,w.jsxs)(`button`,{type:`button`,className:k,disabled:t,"aria-label":`Delete the ${v(e.condition).toLowerCase()} photograph from ${M(r.reference.capturedAt)}`,onClick:()=>{if(l&&!d){o(c);return}o(null),n({stateId:r.stateId,index:r.index})},children:[(0,w.jsx)(u,{className:`mr-1 inline h-3 w-3`}),d?`Confirm`:`Delete`]}),d&&(0,w.jsx)(`p`,{className:`text-[10px] leading-snug text-warning`,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.`})]},c)})})]},e.condition))})}function j({reference:e}){let[t,n]=(0,C.useState)(!1),r=e.thumbnailMediaId;return r===void 0||t?(0,w.jsxs)(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`,children:[(0,w.jsx)(o,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`text-[9px]`,children:`no picture`})]}):(0,w.jsx)(`img`,{src:E(r),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>n(!0)})}function M(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}var N=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,P=`text-[10px] font-medium text-foreground-subtle`,F=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,I=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,L=5,R=3600,z={periodic:`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`,"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.`,both:`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`},B={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.`,"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.`};function V(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function H({monitor:e,disabled:t,onPatch:n}){let[r,i]=(0,C.useState)(()=>V(e)),[a,o]=(0,C.useState)(!1);(0,C.useEffect)(()=>{a||i(V(e))},[e,a]);let c=e=>{o(!1),n(e)},l=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},u=e.confirm?.enabled===!0,d=e.check.mode===`similarity`?e.check.threshold:null;return(0,w.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`What it watches`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Name`}),(0,w.jsx)(`input`,{type:`text`,value:r.label,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,label:e.target.value})),onBlur:()=>{let t=r.label.trim();t.length>0&&t!==e.label?c({label:t}):o(!1)}})]}),(0,w.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:t,onChange:e=>c({enabled:e.target.checked})}),(0,w.jsx)(`span`,{className:P,children:`Watching`})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`When to look`}),(0,w.jsxs)(`select`,{value:e.triggerMode,disabled:t,className:N,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&c({triggerMode:t})},children:[(0,w.jsx)(`option`,{value:`both`,children:`On the clock and after motion settles`}),(0,w.jsx)(`option`,{value:`periodic`,children:`On the clock only`}),(0,w.jsx)(`option`,{value:`on-motion`,children:`After motion settles only`})]})]}),(0,w.jsx)(`p`,{className:s,children:z[e.triggerMode]}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Check every (seconds)`}),(0,w.jsx)(`input`,{type:`number`,min:L,max:R,value:r.checkIntervalSec,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=U(r.checkIntervalSec,L,R);t===e.checkIntervalSec?o(!1):c({checkIntervalSec:t})}})]}),(0,w.jsx)(`p`,{className:s,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.`})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`How sure it has to be`}),e.check.mode===`similarity`&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsxs)(`span`,{className:P,children:[`Match threshold — `,(0,w.jsx)(`span`,{className:`tabular-nums`,children:r.threshold.toFixed(2)})]}),(0,w.jsx)(`input`,{type:`range`,min:.3,max:.99,step:.01,value:r.threshold,disabled:t,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{r.threshold===d?o(!1):c({check:l({threshold:r.threshold})})},onBlur:()=>{r.threshold===d?o(!1):c({check:l({threshold:r.threshold})})}})]}),(0,w.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,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.`})]}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Agreeing checks before it changes its mind`}),(0,w.jsx)(`input`,{type:`number`,min:1,max:10,value:r.hysteresisCount,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=U(r.hysteresisCount,1,10);t===e.check.hysteresisCount?o(!1):c({check:l({hysteresisCount:t})})}})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Quiet for (seconds) before a check counts`}),(0,w.jsx)(`input`,{type:`number`,min:0,max:3600,value:r.quietSeconds,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=U(r.quietSeconds,0,3600);t===e.quietSeconds?o(!1):c({quietSeconds:t})}})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Minimum gap between counted checks (seconds)`}),(0,w.jsx)(`input`,{type:`number`,min:0,max:3600,value:r.minObservationSpacingSec,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=U(r.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?o(!1):c({minObservationSpacingSec:t})}})]}),(0,w.jsx)(`p`,{className:s,children:`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`Lighting`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`When a light has no reference of its own`}),(0,w.jsxs)(`select`,{value:e.onUncoveredCondition,disabled:t,className:N,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&c({onUncoveredCondition:t})},children:[(0,w.jsx)(`option`,{value:`skip`,children:`Skip the check (recommended)`}),(0,w.jsx)(`option`,{value:`judge-anyway`,children:`Judge against the other light anyway`})]})]}),(0,w.jsx)(`p`,{className:s,children:B[e.onUncoveredCondition]})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`What you get told`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Notifications follow`}),(0,w.jsxs)(`select`,{value:e.emit,disabled:t,className:N,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&c({emit:t})},children:[(0,w.jsx)(`option`,{value:`latched`,children:`The flag — told once, still visible at breakfast`}),(0,w.jsx)(`option`,{value:`live`,children:`The live state — follows the region as it changes`})]})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:t,onChange:e=>c({autoRestore:e.target.checked})}),(0,w.jsx)(`span`,{className:P,children:`Clear the flag by itself when things look normal again`})]}),(0,w.jsx)(`p`,{className:s,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.`})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`AI double-check`}),(0,w.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:u,disabled:t||r.confirmPrompt.trim().length===0,onChange:e=>c(e.target.checked?{confirm:{...W(r.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),(0,w.jsx)(`span`,{className:P,children:`Ask a vision model before changing the answer`})]}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`The question to ask`}),(0,w.jsx)(`input`,{type:`text`,value:r.confirmPrompt,placeholder:`e.g. Is the wheelie bin still there?`,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=r.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?c({confirm:{...W(t),enabled:u}}):o(!1)}})]}),(0,w.jsxs)(`p`,{className:s,children:[`The model is asked `,(0,w.jsx)(`strong`,{children:`only`}),` 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.`]})]})]})}function U(e,t,n){return Math.min(n,Math.max(t,e))}function W(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}var 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`,K=`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`,q=`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`,J={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},Y=.8,X=3;function Z({deviceId:e}){let t=c(d().trpcClient,e),n=l(t?.state.sceneMonitor),r=y(e,{width:640}),[o,m]=(0,C.useState)(null),[T,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(null),[k,j]=(0,C.useState)(null),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(``),U=(0,C.useRef)(!0);(0,C.useEffect)(()=>(U.current=!0,()=>{U.current=!1}),[]);let W=(0,C.useCallback)(async()=>{if(t)try{let e=await t.sceneMonitor?.listScenes({});if(!U.current)return;e&&m(e)}catch(e){if(!U.current)return;p(e)?E(!0):j(e instanceof Error?e.message:String(e))}},[t]);(0,C.useEffect)(()=>{m(null),E(!1),j(null),W()},[W]);let Z=n?.monitors??o?.monitors??[],Q=Date.now(),$=(0,C.useCallback)(async(e,t)=>{O(e),j(null);try{await t(),await W()}catch(e){U.current&&j(e instanceof Error?e.message:String(e))}finally{U.current&&O(null)}},[W]),ee=(0,C.useMemo)(()=>{let e=Z.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return R===null?e:[...e,{id:`__draft__`,shape:R,label:`New scene`}]},[Z,R]),te=(0,C.useCallback)((e,n)=>{if(n.kind===`rect`){if(e===`__draft__`){z(n);return}$(`roi-${String(e)}`,async()=>t?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:n}}))}},[t,$]),ne=(0,C.useCallback)(e=>{e.kind===`rect`&&z(e)},[]),re=(0,C.useCallback)(async()=>{R===null||B.trim().length===0||(await $(`create`,async()=>{await t?.sceneMonitor?.createScene({label:B.trim(),roi:R,check:{mode:`similarity`,threshold:Y,hysteresisCount:X}})}),z(null),V(``),L(!1))},[t,R,B,$]);return t?(0,w.jsx)(`div`,{className:`flex flex-col gap-3`,children:T?(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:`Scene monitoring is not available for this camera.`}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,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.`}),(0,w.jsx)(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:(0,w.jsx)(x,{items:ee,supportedShapes:[`rect`],selectedId:M??(R===null?null:`__draft__`),onSelect:e=>N(e===null?null:String(e)),onShapeChange:te,onDrawComplete:ne,drawingKind:I&&R===null?`rect`:null,backdrop:r.src===null?null:(0,w.jsx)(`img`,{src:r.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(`button`,{type:`button`,className:I?K:G,"aria-pressed":I,onClick:()=>{L(e=>!e),z(null)},disabled:D!==null,children:I?`Cancel`:`+ New scene`}),(0,w.jsx)(`button`,{type:`button`,className:G,onClick:r.refresh,disabled:D!==null,children:`Refresh frame`})]}),I&&(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[(0,w.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:R===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.`}),R!==null&&a(R)&&(0,w.jsx)(`p`,{className:`text-[11px] leading-relaxed text-warning`,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.`}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`text`,value:B,onChange:e=>V(e.target.value),placeholder:`e.g. Immondizia prelevata`,className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),(0,w.jsx)(`button`,{type:`button`,className:K,onClick:()=>void re(),disabled:R===null||B.trim().length===0||D!==null,children:`Create`})]})]}),k!==null&&(0,w.jsx)(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:k}),Z.length===0?(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:`No scenes on this camera yet.`}):(0,w.jsx)(`ul`,{className:`flex flex-col gap-2`,children:Z.map(e=>{let n=_(e);return(0,w.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${M===e.id?`border-primary/50`:`border-border`}`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>N(e.id),children:e.label}),(0,w.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${J[n.tone]}`,children:n.text})]}),(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:g(e,Q)}),(0,w.jsx)(`p`,{className:`${s} tabular-nums`,children:f(e)}),(0,w.jsx)(A,{monitor:e,disabled:D!==null,onDelete:({stateId:n,index:r})=>void $(`refdel-${e.id}-${n}-${String(r)}`,async()=>t.sceneMonitor?.deleteReference({monitorId:e.id,stateId:n,index:r}))}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[h.map(n=>{let r=n===`ir`;return(0,w.jsxs)(`button`,{type:`button`,className:G,disabled:D!==null,title:r?`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 ${v(n).toLowerCase()} reference`,onClick:()=>void $(`cap-${e.id}-${n}`,async()=>t.sceneMonitor?.captureReference({monitorId:e.id,condition:n})),children:[(0,w.jsx)(i,{className:`mr-1 inline h-3 w-3`}),`Capture `,v(n).toLowerCase(),r&&(0,w.jsx)(`span`,{className:`ml-1 text-foreground-subtle/70`,children:`(optional)`})]},n)}),(0,w.jsxs)(`button`,{type:`button`,className:K,disabled:D!==null||e.states.length===0,title:`Clear the flag and re-photograph what normal looks like right now`,onClick:()=>void $(`reset-${e.id}`,async()=>t.sceneMonitor?.resetScene({monitorId:e.id})),children:[(0,w.jsx)(b,{className:`mr-1 inline h-3 w-3`}),`Reset`]}),(0,w.jsx)(`button`,{type:`button`,className:G,disabled:D!==null,onClick:()=>void $(`check-${e.id}`,async()=>t.sceneMonitor?.recheckNow({monitorId:e.id})),children:`Check now`}),(0,w.jsxs)(`button`,{type:`button`,className:P===e.id?K:G,"aria-pressed":P===e.id,"aria-label":`Settings for ${e.label}`,disabled:D!==null,onClick:()=>F(t=>t===e.id?null:e.id),children:[(0,w.jsx)(S,{className:`mr-1 inline h-3 w-3`}),`Settings`]}),(0,w.jsx)(`button`,{type:`button`,className:q,disabled:D!==null,onClick:()=>void $(`del-${e.id}`,async()=>t.sceneMonitor?.deleteScene({monitorId:e.id})),children:(0,w.jsx)(u,{className:`h-3 w-3`})})]}),P===e.id&&(0,w.jsx)(H,{monitor:e,disabled:D!==null,onPatch:n=>void $(`tune-${e.id}`,async()=>t.sceneMonitor?.updateScene({monitorId:e.id,patch:n}))})]},e.id)})})]})}):null}export{Z as SceneMonitorEditor};
|
|
1
|
+
import{n as e,o as t,r as n}from"./scheduler-mSeF_D00.js";import{C as r,S as i,a,b as o,c as s,d as c,f as l,g as u,h as d,i as f,l as p,m,n as h,o as g,r as _,s as v,u as y,v as b}from"./index-3obeECEN.js";import{MaskShapeCanvas as x}from"./MaskShapeCanvas-u4Ka7P5T.js";var S=r(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),C=t(n(),1),w=t(e(),1),T=m(`/addon/pipeline-analytics/event-media`);function E(e){return`${T}/m/${e}`}function D(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function O(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var k=`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`;function A({monitor:e,disabled:t,onDelete:n}){let r=D(e),i=O(e),[a,o]=(0,C.useState)(null);return r.length===0?(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`}):(0,w.jsx)(`div`,{className:`flex flex-col gap-2`,children:r.map(e=>(0,w.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,w.jsxs)(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[v(e.condition),` · `,e.tiles.length]}),(0,w.jsx)(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(r=>{let c=`${r.stateId}:${String(r.index)}`,l=i===1,d=a===c;return(0,w.jsxs)(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[(0,w.jsx)(j,{reference:r.reference}),(0,w.jsx)(`span`,{className:`${s} tabular-nums`,children:M(r.reference.capturedAt)}),(0,w.jsxs)(`button`,{type:`button`,className:k,disabled:t,"aria-label":`Delete the ${v(e.condition).toLowerCase()} photograph from ${M(r.reference.capturedAt)}`,onClick:()=>{if(l&&!d){o(c);return}o(null),n({stateId:r.stateId,index:r.index})},children:[(0,w.jsx)(u,{className:`mr-1 inline h-3 w-3`}),d?`Confirm`:`Delete`]}),d&&(0,w.jsx)(`p`,{className:`text-[10px] leading-snug text-warning`,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.`})]},c)})})]},e.condition))})}function j({reference:e}){let[t,n]=(0,C.useState)(!1),r=e.thumbnailMediaId;return r===void 0||t?(0,w.jsxs)(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`,children:[(0,w.jsx)(o,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{className:`text-[9px]`,children:`no picture`})]}):(0,w.jsx)(`img`,{src:E(r),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>n(!0)})}function M(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}var N=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,P=`text-[10px] font-medium text-foreground-subtle`,F=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,I=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,L=5,R=3600,z={periodic:`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`,"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.`,both:`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`},B={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.`,"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.`};function V(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function H({monitor:e,disabled:t,onPatch:n}){let[r,i]=(0,C.useState)(()=>V(e)),[a,o]=(0,C.useState)(!1);(0,C.useEffect)(()=>{a||i(V(e))},[e,a]);let c=e=>{o(!1),n(e)},l=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},u=e.confirm?.enabled===!0,d=e.check.mode===`similarity`?e.check.threshold:null;return(0,w.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`What it watches`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Name`}),(0,w.jsx)(`input`,{type:`text`,value:r.label,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,label:e.target.value})),onBlur:()=>{let t=r.label.trim();t.length>0&&t!==e.label?c({label:t}):o(!1)}})]}),(0,w.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:t,onChange:e=>c({enabled:e.target.checked})}),(0,w.jsx)(`span`,{className:P,children:`Watching`})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`When to look`}),(0,w.jsxs)(`select`,{value:e.triggerMode,disabled:t,className:N,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&c({triggerMode:t})},children:[(0,w.jsx)(`option`,{value:`both`,children:`On the clock and after motion settles`}),(0,w.jsx)(`option`,{value:`periodic`,children:`On the clock only`}),(0,w.jsx)(`option`,{value:`on-motion`,children:`After motion settles only`})]})]}),(0,w.jsx)(`p`,{className:s,children:z[e.triggerMode]}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Check every (seconds)`}),(0,w.jsx)(`input`,{type:`number`,min:L,max:R,value:r.checkIntervalSec,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=U(r.checkIntervalSec,L,R);t===e.checkIntervalSec?o(!1):c({checkIntervalSec:t})}})]}),(0,w.jsx)(`p`,{className:s,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.`})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`How sure it has to be`}),e.check.mode===`similarity`&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsxs)(`span`,{className:P,children:[`Match threshold — `,(0,w.jsx)(`span`,{className:`tabular-nums`,children:r.threshold.toFixed(2)})]}),(0,w.jsx)(`input`,{type:`range`,min:.3,max:.99,step:.01,value:r.threshold,disabled:t,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{r.threshold===d?o(!1):c({check:l({threshold:r.threshold})})},onBlur:()=>{r.threshold===d?o(!1):c({check:l({threshold:r.threshold})})}})]}),(0,w.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,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.`})]}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Agreeing checks before it changes its mind`}),(0,w.jsx)(`input`,{type:`number`,min:1,max:10,value:r.hysteresisCount,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=U(r.hysteresisCount,1,10);t===e.check.hysteresisCount?o(!1):c({check:l({hysteresisCount:t})})}})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Quiet for (seconds) before a check counts`}),(0,w.jsx)(`input`,{type:`number`,min:0,max:3600,value:r.quietSeconds,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=U(r.quietSeconds,0,3600);t===e.quietSeconds?o(!1):c({quietSeconds:t})}})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Minimum gap between counted checks (seconds)`}),(0,w.jsx)(`input`,{type:`number`,min:0,max:3600,value:r.minObservationSpacingSec,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=U(r.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?o(!1):c({minObservationSpacingSec:t})}})]}),(0,w.jsx)(`p`,{className:s,children:`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`Lighting`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`When a light has no reference of its own`}),(0,w.jsxs)(`select`,{value:e.onUncoveredCondition,disabled:t,className:N,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&c({onUncoveredCondition:t})},children:[(0,w.jsx)(`option`,{value:`skip`,children:`Skip the check (recommended)`}),(0,w.jsx)(`option`,{value:`judge-anyway`,children:`Judge against the other light anyway`})]})]}),(0,w.jsx)(`p`,{className:s,children:B[e.onUncoveredCondition]})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`What you get told`}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`Notifications follow`}),(0,w.jsxs)(`select`,{value:e.emit,disabled:t,className:N,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&c({emit:t})},children:[(0,w.jsx)(`option`,{value:`latched`,children:`The flag — told once, still visible at breakfast`}),(0,w.jsx)(`option`,{value:`live`,children:`The live state — follows the region as it changes`})]})]}),(0,w.jsx)(`p`,{className:s,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.`}),(0,w.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:t,onChange:e=>c({autoRestore:e.target.checked})}),(0,w.jsx)(`span`,{className:P,children:`Clear the flag by itself when things look normal again`})]}),(0,w.jsx)(`p`,{className:s,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.`})]}),(0,w.jsxs)(`div`,{className:F,children:[(0,w.jsx)(`p`,{className:I,children:`AI double-check`}),(0,w.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`checkbox`,checked:u,disabled:t||r.confirmPrompt.trim().length===0,onChange:e=>c(e.target.checked?{confirm:{...W(r.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),(0,w.jsx)(`span`,{className:P,children:`Ask a vision model before changing the answer`})]}),(0,w.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,w.jsx)(`span`,{className:P,children:`The question to ask`}),(0,w.jsx)(`input`,{type:`text`,value:r.confirmPrompt,placeholder:`e.g. Is the wheelie bin still there?`,disabled:t,className:N,onFocus:()=>o(!0),onChange:e=>i(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=r.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?c({confirm:{...W(t),enabled:u}}):o(!1)}})]}),(0,w.jsxs)(`p`,{className:s,children:[`The model is asked `,(0,w.jsx)(`strong`,{children:`only`}),` 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.`]})]})]})}function U(e,t,n){return Math.min(n,Math.max(t,e))}function W(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}var 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`,K=`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`,q=`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`,J={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},Y=.8,X=3;function Z({deviceId:e}){let t=c(d().trpcClient,e),n=l(t?.state.sceneMonitor),r=y(e,{width:640}),[o,m]=(0,C.useState)(null),[T,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(null),[k,j]=(0,C.useState)(null),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(null),[I,L]=(0,C.useState)(!1),[R,z]=(0,C.useState)(null),[B,V]=(0,C.useState)(``),U=(0,C.useRef)(!0);(0,C.useEffect)(()=>(U.current=!0,()=>{U.current=!1}),[]);let W=(0,C.useCallback)(async()=>{if(t)try{let e=await t.sceneMonitor?.listScenes({});if(!U.current)return;e&&m(e)}catch(e){if(!U.current)return;p(e)?E(!0):j(e instanceof Error?e.message:String(e))}},[t]);(0,C.useEffect)(()=>{m(null),E(!1),j(null),W()},[W]);let Z=n?.monitors??o?.monitors??[],Q=Date.now(),$=(0,C.useCallback)(async(e,t)=>{O(e),j(null);try{await t(),await W()}catch(e){U.current&&j(e instanceof Error?e.message:String(e))}finally{U.current&&O(null)}},[W]),ee=(0,C.useMemo)(()=>{let e=Z.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return R===null?e:[...e,{id:`__draft__`,shape:R,label:`New scene`}]},[Z,R]),te=(0,C.useCallback)((e,n)=>{if(n.kind===`rect`){if(e===`__draft__`){z(n);return}$(`roi-${String(e)}`,async()=>t?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:n}}))}},[t,$]),ne=(0,C.useCallback)(e=>{e.kind===`rect`&&z(e)},[]),re=(0,C.useCallback)(async()=>{R===null||B.trim().length===0||(await $(`create`,async()=>{await t?.sceneMonitor?.createScene({label:B.trim(),roi:R,check:{mode:`similarity`,threshold:Y,hysteresisCount:X}})}),z(null),V(``),L(!1))},[t,R,B,$]);return t?(0,w.jsx)(`div`,{className:`flex flex-col gap-3`,children:T?(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:`Scene monitoring is not available for this camera.`}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,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.`}),(0,w.jsx)(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:(0,w.jsx)(x,{items:ee,supportedShapes:[`rect`],selectedId:M??(R===null?null:`__draft__`),onSelect:e=>N(e===null?null:String(e)),onShapeChange:te,onDrawComplete:ne,drawingKind:I&&R===null?`rect`:null,backdrop:r.src===null?null:(0,w.jsx)(`img`,{src:r.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsx)(`button`,{type:`button`,className:I?K:G,"aria-pressed":I,onClick:()=>{L(e=>!e),z(null)},disabled:D!==null,children:I?`Cancel`:`+ New scene`}),(0,w.jsx)(`button`,{type:`button`,className:G,onClick:r.refresh,disabled:D!==null,children:`Refresh frame`})]}),I&&(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[(0,w.jsx)(`p`,{className:`text-[10px] text-foreground-subtle`,children:R===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.`}),R!==null&&a(R)&&(0,w.jsx)(`p`,{className:`text-[11px] leading-relaxed text-warning`,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.`}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`input`,{type:`text`,value:B,onChange:e=>V(e.target.value),placeholder:`e.g. Immondizia prelevata`,className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),(0,w.jsx)(`button`,{type:`button`,className:K,onClick:()=>void re(),disabled:R===null||B.trim().length===0||D!==null,children:`Create`})]})]}),k!==null&&(0,w.jsx)(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:k}),Z.length===0?(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:`No scenes on this camera yet.`}):(0,w.jsx)(`ul`,{className:`flex flex-col gap-2`,children:Z.map(e=>{let n=_(e);return(0,w.jsxs)(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${M===e.id?`border-primary/50`:`border-border`}`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>N(e.id),children:e.label}),(0,w.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${J[n.tone]}`,children:n.text})]}),(0,w.jsx)(`p`,{className:`${s} leading-relaxed`,children:g(e,Q)}),(0,w.jsx)(`p`,{className:`${s} tabular-nums`,children:f(e)}),(0,w.jsx)(A,{monitor:e,disabled:D!==null,onDelete:({stateId:n,index:r})=>void $(`refdel-${e.id}-${n}-${String(r)}`,async()=>t.sceneMonitor?.deleteReference({monitorId:e.id,stateId:n,index:r}))}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[h.map(n=>{let r=n===`ir`;return(0,w.jsxs)(`button`,{type:`button`,className:G,disabled:D!==null,title:r?`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 ${v(n).toLowerCase()} reference`,onClick:()=>void $(`cap-${e.id}-${n}`,async()=>t.sceneMonitor?.captureReference({monitorId:e.id,condition:n})),children:[(0,w.jsx)(i,{className:`mr-1 inline h-3 w-3`}),`Capture `,v(n).toLowerCase(),r&&(0,w.jsx)(`span`,{className:`ml-1 text-foreground-subtle/70`,children:`(optional)`})]},n)}),(0,w.jsxs)(`button`,{type:`button`,className:K,disabled:D!==null||e.states.length===0,title:`Clear the flag and re-photograph what normal looks like right now`,onClick:()=>void $(`reset-${e.id}`,async()=>t.sceneMonitor?.resetScene({monitorId:e.id})),children:[(0,w.jsx)(b,{className:`mr-1 inline h-3 w-3`}),`Reset`]}),(0,w.jsx)(`button`,{type:`button`,className:G,disabled:D!==null,onClick:()=>void $(`check-${e.id}`,async()=>t.sceneMonitor?.recheckNow({monitorId:e.id})),children:`Check now`}),(0,w.jsxs)(`button`,{type:`button`,className:P===e.id?K:G,"aria-pressed":P===e.id,"aria-label":`Settings for ${e.label}`,disabled:D!==null,onClick:()=>F(t=>t===e.id?null:e.id),children:[(0,w.jsx)(S,{className:`mr-1 inline h-3 w-3`}),`Settings`]}),(0,w.jsx)(`button`,{type:`button`,className:q,disabled:D!==null,onClick:()=>void $(`del-${e.id}`,async()=>t.sceneMonitor?.deleteScene({monitorId:e.id})),children:(0,w.jsx)(u,{className:`h-3 w-3`})})]}),P===e.id&&(0,w.jsx)(H,{monitor:e,disabled:D!==null,onPatch:n=>void $(`tune-${e.id}`,async()=>t.sceneMonitor?.updateScene({monitorId:e.id,patch:n}))})]},e.id)})})]})}):null}export{Z as SceneMonitorEditor};
|