@camstack/addon-pipeline-orchestrator 1.2.640 → 1.2.641
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/CHANGELOG.md +7 -0
- package/dist/_stub.js +354 -310
- package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-DgqFPt2m.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-DwQA2kWO.mjs} +2 -2
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D6nTaHNp.mjs +26 -0
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DNaztdEQ.mjs +26 -0
- package/dist/{hostInit-DD8GvZ4U.mjs → hostInit-BFSvtn_R.mjs} +2 -2
- package/dist/index.js +1256 -124
- package/dist/index.mjs +1256 -124
- package/dist/remoteEntry.js +1 -1
- package/package.json +1 -1
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D0_XCtEI.mjs +0 -26
- package/dist/_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DuREsGpg.mjs +0 -26
package/dist/_stub.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as e } from "./_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-BiLBDmU5.mjs";
|
|
2
|
-
import { n as t, r as n, t as r } from "./_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-
|
|
2
|
+
import { n as t, r as n, t as r } from "./_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D6nTaHNp.mjs";
|
|
3
3
|
import { a as i, c as a, i as o, n as s, o as c, r as l, s as u, t as d } from "./_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.js-a8tvh93M.mjs";
|
|
4
|
-
import { C as f, D as p, E as m, O as h, S as g, T as _, _ as v, a as y, b, c as x, d as S, f as C, g as w, h as T, i as E, l as D, m as O, n as k, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as L, x as R, y as z } from "./_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-
|
|
4
|
+
import { C as f, D as p, E as m, O as h, S as g, T as _, _ as v, a as y, b, c as x, d as S, f as C, g as w, h as T, i as E, l as D, m as O, n as k, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as L, x as R, y as z } from "./_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DNaztdEQ.mjs";
|
|
5
5
|
import { n as B, r as V, t as H } from "./_virtual_mf___mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-yD-rMaFX.mjs";
|
|
6
6
|
//#region ../../node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.js
|
|
7
|
-
var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), W = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), G = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()),
|
|
7
|
+
var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), W = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), G = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), ee = (e) => {
|
|
8
8
|
let t = G(e);
|
|
9
9
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
10
|
-
},
|
|
10
|
+
}, te = {
|
|
11
11
|
xmlns: "http://www.w3.org/2000/svg",
|
|
12
12
|
width: 24,
|
|
13
13
|
height: 24,
|
|
@@ -17,34 +17,34 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
17
17
|
strokeWidth: 2,
|
|
18
18
|
strokeLinecap: "round",
|
|
19
19
|
strokeLinejoin: "round"
|
|
20
|
-
},
|
|
20
|
+
}, ne = (e) => {
|
|
21
21
|
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
22
22
|
return !1;
|
|
23
|
-
},
|
|
23
|
+
}, re = s(({ color: e = "currentColor", size: t = 24, strokeWidth: n = 2, absoluteStrokeWidth: r, className: i = "", children: a, iconNode: o, ...s }, c) => d("svg", {
|
|
24
24
|
ref: c,
|
|
25
|
-
...
|
|
25
|
+
...te,
|
|
26
26
|
width: t,
|
|
27
27
|
height: t,
|
|
28
28
|
stroke: e,
|
|
29
29
|
strokeWidth: r ? Number(n) * 24 / Number(t) : n,
|
|
30
30
|
className: U("lucide", i),
|
|
31
|
-
...!a && !
|
|
31
|
+
...!a && !ne(s) && { "aria-hidden": "true" },
|
|
32
32
|
...s
|
|
33
|
-
}, [...o.map(([e, t]) => d(e, t)), ...Array.isArray(a) ? a : [a]])),
|
|
34
|
-
let n = s(({ className: n, ...r }, i) => d(
|
|
33
|
+
}, [...o.map(([e, t]) => d(e, t)), ...Array.isArray(a) ? a : [a]])), K = (e, t) => {
|
|
34
|
+
let n = s(({ className: n, ...r }, i) => d(re, {
|
|
35
35
|
ref: i,
|
|
36
36
|
iconNode: t,
|
|
37
|
-
className: U(`lucide-${W(
|
|
37
|
+
className: U(`lucide-${W(ee(e))}`, `lucide-${e}`, n),
|
|
38
38
|
...r
|
|
39
39
|
}));
|
|
40
|
-
return n.displayName =
|
|
41
|
-
},
|
|
40
|
+
return n.displayName = ee(e), n;
|
|
41
|
+
}, ie = K("activity", [["path", {
|
|
42
42
|
d: "M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",
|
|
43
43
|
key: "169zse"
|
|
44
|
-
}]]),
|
|
44
|
+
}]]), ae = K("check", [["path", {
|
|
45
45
|
d: "M20 6 9 17l-5-5",
|
|
46
46
|
key: "1gmf2c"
|
|
47
|
-
}]]),
|
|
47
|
+
}]]), oe = K("cpu", [
|
|
48
48
|
["path", {
|
|
49
49
|
d: "M12 20v2",
|
|
50
50
|
key: "1lh1kg"
|
|
@@ -109,7 +109,7 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
109
109
|
rx: "1",
|
|
110
110
|
key: "z9xiuo"
|
|
111
111
|
}]
|
|
112
|
-
]),
|
|
112
|
+
]), se = K("eye", [["path", {
|
|
113
113
|
d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
|
|
114
114
|
key: "1nclc0"
|
|
115
115
|
}], ["circle", {
|
|
@@ -117,25 +117,25 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
117
117
|
cy: "12",
|
|
118
118
|
r: "3",
|
|
119
119
|
key: "1v7zrd"
|
|
120
|
-
}]]),
|
|
120
|
+
}]]), ce = K("gauge", [["path", {
|
|
121
121
|
d: "m12 14 4-4",
|
|
122
122
|
key: "9kzdfg"
|
|
123
123
|
}], ["path", {
|
|
124
124
|
d: "M3.34 19a10 10 0 1 1 17.32 0",
|
|
125
125
|
key: "19p75a"
|
|
126
|
-
}]]),
|
|
126
|
+
}]]), le = K("hexagon", [["path", {
|
|
127
127
|
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",
|
|
128
128
|
key: "yt0hxn"
|
|
129
|
-
}]]),
|
|
129
|
+
}]]), ue = K("minus", [["path", {
|
|
130
130
|
d: "M5 12h14",
|
|
131
131
|
key: "1ays0h"
|
|
132
|
-
}]]),
|
|
132
|
+
}]]), de = K("plus", [["path", {
|
|
133
133
|
d: "M5 12h14",
|
|
134
134
|
key: "1ays0h"
|
|
135
135
|
}], ["path", {
|
|
136
136
|
d: "M12 5v14",
|
|
137
137
|
key: "s699le"
|
|
138
|
-
}]]),
|
|
138
|
+
}]]), fe = K("save", [
|
|
139
139
|
["path", {
|
|
140
140
|
d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
|
|
141
141
|
key: "1c8476"
|
|
@@ -148,7 +148,7 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
148
148
|
d: "M7 3v4a1 1 0 0 0 1 1h7",
|
|
149
149
|
key: "t51u73"
|
|
150
150
|
}]
|
|
151
|
-
]),
|
|
151
|
+
]), q = K("trash-2", [
|
|
152
152
|
["path", {
|
|
153
153
|
d: "M10 11v6",
|
|
154
154
|
key: "nco0om"
|
|
@@ -169,7 +169,7 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
169
169
|
d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",
|
|
170
170
|
key: "e791ji"
|
|
171
171
|
}]
|
|
172
|
-
]),
|
|
172
|
+
]), pe = K("video", [["path", {
|
|
173
173
|
d: "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",
|
|
174
174
|
key: "ftymec"
|
|
175
175
|
}], ["rect", {
|
|
@@ -179,7 +179,7 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
179
179
|
height: "12",
|
|
180
180
|
rx: "2",
|
|
181
181
|
key: "158x01"
|
|
182
|
-
}]]),
|
|
182
|
+
}]]), me = K("volume-2", [
|
|
183
183
|
["path", {
|
|
184
184
|
d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
|
|
185
185
|
key: "uqj9uw"
|
|
@@ -192,13 +192,13 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
192
192
|
d: "M19.364 18.364a9 9 0 0 0 0-12.728",
|
|
193
193
|
key: "ijwkga"
|
|
194
194
|
}]
|
|
195
|
-
]),
|
|
195
|
+
]), J = K("x", [["path", {
|
|
196
196
|
d: "M18 6 6 18",
|
|
197
197
|
key: "1bl5f8"
|
|
198
198
|
}], ["path", {
|
|
199
199
|
d: "m6 6 12 12",
|
|
200
200
|
key: "d8bk6v"
|
|
201
|
-
}]]), { useT:
|
|
201
|
+
}]]), { useT: Y, Trans: he, translate: X } = p("pipeline-orchestrator", {
|
|
202
202
|
en: {
|
|
203
203
|
quickStats: {
|
|
204
204
|
requiresDevice: "PipelineQuickStats requires a deviceId",
|
|
@@ -360,30 +360,30 @@ var U = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) =
|
|
|
360
360
|
});
|
|
361
361
|
//#endregion
|
|
362
362
|
//#region src/widgets/PipelineQuickStats.tsx
|
|
363
|
-
function
|
|
364
|
-
let { t } =
|
|
363
|
+
function ge(e) {
|
|
364
|
+
let { t } = Y();
|
|
365
365
|
return e.deviceId === void 0 ? /* @__PURE__ */ B("div", {
|
|
366
366
|
className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
|
|
367
367
|
children: t("quickStats.requiresDevice")
|
|
368
|
-
}) : /* @__PURE__ */ B(
|
|
368
|
+
}) : /* @__PURE__ */ B(_e, { deviceId: e.deviceId });
|
|
369
369
|
}
|
|
370
|
-
function
|
|
371
|
-
let { t: r } =
|
|
370
|
+
function _e({ deviceId: t }) {
|
|
371
|
+
let { t: r } = Y(), i = x();
|
|
372
372
|
M(["pipelineOrchestrator", "getPipelineAssignment"], [
|
|
373
373
|
"pipeline.camera-assigned",
|
|
374
374
|
"pipeline.camera-unassigned",
|
|
375
375
|
"pipeline.camera-updated"
|
|
376
376
|
]), M(["pipelineRunner", "getCameraMetrics"], ["pipeline.camera-metrics-snapshot"]);
|
|
377
|
-
let { data: a } = E({ deviceId:
|
|
378
|
-
deviceId:
|
|
377
|
+
let { data: a } = E({ deviceId: t }, { staleTime: 3e4 }), o = a?.agentNodeId ?? null, s = typeof o == "string" && o.length > 0 && !o.startsWith("addon:") ? o : void 0, { data: c } = y({
|
|
378
|
+
deviceId: t,
|
|
379
379
|
...s ? { nodeId: s } : {}
|
|
380
380
|
}, {
|
|
381
381
|
staleTime: 2e3,
|
|
382
382
|
retry: !1
|
|
383
|
-
}), l = N(), u = P(l.trpcClient,
|
|
383
|
+
}), l = N(), u = P(l.trpcClient, t), { data: d } = e({
|
|
384
384
|
queryKey: [
|
|
385
385
|
"device",
|
|
386
|
-
|
|
386
|
+
t,
|
|
387
387
|
"pipelineAnalytics.getActiveTracks"
|
|
388
388
|
],
|
|
389
389
|
queryFn: () => u?.pipelineAnalytics?.getActiveTracks({}) ?? [],
|
|
@@ -393,7 +393,7 @@ function ge({ deviceId: n }) {
|
|
|
393
393
|
}), { data: f } = e({
|
|
394
394
|
queryKey: [
|
|
395
395
|
"device",
|
|
396
|
-
|
|
396
|
+
t,
|
|
397
397
|
"audioMetrics.getCurrentSnapshot"
|
|
398
398
|
],
|
|
399
399
|
queryFn: () => u?.audioMetrics?.getCurrentSnapshot({}) ?? null,
|
|
@@ -401,63 +401,63 @@ function ge({ deviceId: n }) {
|
|
|
401
401
|
refetchInterval: 2e3,
|
|
402
402
|
retry: !1
|
|
403
403
|
}), { data: p } = e({
|
|
404
|
-
queryKey: ["recordingArchive.getStatus",
|
|
405
|
-
queryFn: async () => await l.trpcClient.recordingArchive.getStatus.query({ deviceId:
|
|
404
|
+
queryKey: ["recordingArchive.getStatus", t],
|
|
405
|
+
queryFn: async () => await l.trpcClient.recordingArchive.getStatus.query({ deviceId: t }),
|
|
406
406
|
refetchInterval: 5e3,
|
|
407
407
|
retry: !1
|
|
408
408
|
}), { data: m } = e({
|
|
409
|
-
queryKey: ["recordingArchive.getDeviceConfig",
|
|
410
|
-
queryFn: async () => await l.trpcClient.recordingArchive.getDeviceConfig.query({ deviceId:
|
|
409
|
+
queryKey: ["recordingArchive.getDeviceConfig", t],
|
|
410
|
+
queryFn: async () => await l.trpcClient.recordingArchive.getDeviceConfig.query({ deviceId: t }),
|
|
411
411
|
staleTime: 3e4,
|
|
412
412
|
retry: !1
|
|
413
413
|
}), { data: g } = e({
|
|
414
414
|
queryKey: [
|
|
415
415
|
"device",
|
|
416
|
-
|
|
416
|
+
t,
|
|
417
417
|
"addonSettings.getDeviceSettings.detectionMode"
|
|
418
418
|
],
|
|
419
419
|
queryFn: () => l.trpcClient.addonSettings.getDeviceSettings.query({
|
|
420
420
|
addonId: "pipeline-orchestrator",
|
|
421
|
-
deviceId:
|
|
421
|
+
deviceId: t
|
|
422
422
|
}),
|
|
423
423
|
staleTime: 3e4,
|
|
424
424
|
retry: !1
|
|
425
|
-
}), _ =
|
|
425
|
+
}), _ = n(g, "detectionMode"), v = typeof _ == "string" ? _ : null, b = c?.phase ?? null, C = v, w = Number(c?.actualFps ?? 0), T = Number(c?.configuredFps ?? 0), D = Number(c?.avgInferenceTimeMs ?? 0), O = Number(c?.queueDepth ?? 0), k = Number(c?.droppedFrames ?? 0), A = h(b ?? "watching", i), j = d?.length ?? 0, F = f?.level.dbfs ?? null, I = typeof F == "number" ? `${F.toFixed(1)} dBFS` : "—", L = p?.enabled ?? !1, z = p?.activeMode ?? "off", H = L && z !== "off", U = L ? z === "off" ? r("quickStats.rec.idle") : z === "continuous" ? r("quickStats.rec.continuous") : z === "onMotion" ? r("quickStats.rec.onMotion") : z === "onAudioThreshold" ? r("quickStats.rec.onAudio") : z : r("quickStats.rec.disabled"), W = (m?.profiles ?? []).join(", "), G = p ? `${ve(p.storageBytes ?? 0)}${W ? ` · ${W}` : ""}` : void 0;
|
|
426
426
|
return /* @__PURE__ */ V("div", {
|
|
427
427
|
className: S,
|
|
428
428
|
children: [
|
|
429
429
|
/* @__PURE__ */ B(R, {
|
|
430
|
-
icon:
|
|
430
|
+
icon: ie,
|
|
431
431
|
label: r("quickStats.phase"),
|
|
432
432
|
value: A.label,
|
|
433
433
|
valueClassName: A.textColor,
|
|
434
434
|
subtext: C ?? void 0
|
|
435
435
|
}),
|
|
436
436
|
/* @__PURE__ */ B(R, {
|
|
437
|
-
icon:
|
|
437
|
+
icon: ce,
|
|
438
438
|
label: r("quickStats.detectionFps"),
|
|
439
439
|
value: `${w.toFixed(1)}`,
|
|
440
440
|
subtext: T > 0 ? r("quickStats.target", { value: T }) : void 0
|
|
441
441
|
}),
|
|
442
442
|
/* @__PURE__ */ B(R, {
|
|
443
|
-
icon:
|
|
443
|
+
icon: oe,
|
|
444
444
|
label: r("quickStats.inference"),
|
|
445
445
|
value: `${D.toFixed(1)} ms`,
|
|
446
446
|
subtext: O > 0 ? r("quickStats.queue", { value: O }) : void 0
|
|
447
447
|
}),
|
|
448
448
|
/* @__PURE__ */ B(R, {
|
|
449
|
-
icon:
|
|
449
|
+
icon: se,
|
|
450
450
|
label: r("quickStats.activeTracks"),
|
|
451
451
|
value: String(j),
|
|
452
452
|
subtext: k > 0 ? r("quickStats.dropped", { value: k }) : void 0
|
|
453
453
|
}),
|
|
454
454
|
/* @__PURE__ */ B(R, {
|
|
455
|
-
icon:
|
|
455
|
+
icon: me,
|
|
456
456
|
label: r("quickStats.currentDb"),
|
|
457
457
|
value: I
|
|
458
458
|
}),
|
|
459
459
|
/* @__PURE__ */ B(R, {
|
|
460
|
-
icon:
|
|
460
|
+
icon: pe,
|
|
461
461
|
label: r("quickStats.recording"),
|
|
462
462
|
value: U,
|
|
463
463
|
valueClassName: H ? "text-success" : void 0,
|
|
@@ -466,7 +466,7 @@ function ge({ deviceId: n }) {
|
|
|
466
466
|
]
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
|
-
function
|
|
469
|
+
function ve(e) {
|
|
470
470
|
if (!Number.isFinite(e) || e <= 0) return "0 B";
|
|
471
471
|
let t = [
|
|
472
472
|
"B",
|
|
@@ -479,12 +479,12 @@ function _e(e) {
|
|
|
479
479
|
}
|
|
480
480
|
//#endregion
|
|
481
481
|
//#region src/widgets/zone-editor/ZoneList.tsx
|
|
482
|
-
var
|
|
482
|
+
var ye = {
|
|
483
483
|
polygon: "bg-info/10 text-info",
|
|
484
484
|
tripwire: "bg-warning/10 text-warning"
|
|
485
485
|
};
|
|
486
|
-
function
|
|
487
|
-
let { t: s } =
|
|
486
|
+
function be({ zones: e, selectedZoneId: t, drawingKind: n, onSelectZone: r, onDeleteZone: i, onStartDraw: a, onCancelDraw: o }) {
|
|
487
|
+
let { t: s } = Y();
|
|
488
488
|
return /* @__PURE__ */ V("div", {
|
|
489
489
|
className: "flex flex-col gap-2",
|
|
490
490
|
children: [/* @__PURE__ */ B("div", {
|
|
@@ -494,21 +494,21 @@ function ye({ zones: e, selectedZoneId: t, drawingKind: n, onSelectZone: r, onDe
|
|
|
494
494
|
onClick: o,
|
|
495
495
|
className: "inline-flex items-center justify-center gap-1 rounded border border-amber-500/30 bg-amber-500/10 text-amber-400 hover:bg-amber-500/20 transition-colors h-8 px-3 text-[11px] font-medium",
|
|
496
496
|
title: s("zoneList.cancelDrawing"),
|
|
497
|
-
children: [/* @__PURE__ */ B(
|
|
497
|
+
children: [/* @__PURE__ */ B(J, { className: "h-3.5 w-3.5" }), /* @__PURE__ */ B("span", { children: s("zoneList.cancel") })]
|
|
498
498
|
}) : /* @__PURE__ */ V(H, { children: [/* @__PURE__ */ B("button", {
|
|
499
499
|
type: "button",
|
|
500
500
|
onClick: () => a("polygon"),
|
|
501
501
|
className: "inline-flex items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors h-8 w-8",
|
|
502
502
|
title: s("zoneList.addPolygon"),
|
|
503
503
|
"aria-label": s("zoneList.addPolygon"),
|
|
504
|
-
children: /* @__PURE__ */ B(
|
|
504
|
+
children: /* @__PURE__ */ B(le, { className: "h-4 w-4" })
|
|
505
505
|
}), /* @__PURE__ */ B("button", {
|
|
506
506
|
type: "button",
|
|
507
507
|
onClick: () => a("tripwire"),
|
|
508
508
|
className: "inline-flex items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:text-primary hover:border-primary/40 hover:bg-primary/5 transition-colors h-8 w-8",
|
|
509
509
|
title: s("zoneList.addTripwire"),
|
|
510
510
|
"aria-label": s("zoneList.addTripwire"),
|
|
511
|
-
children: /* @__PURE__ */ B(
|
|
511
|
+
children: /* @__PURE__ */ B(ue, { className: "h-5 w-5 stroke-[2.5]" })
|
|
512
512
|
})] })
|
|
513
513
|
}), e.length === 0 ? /* @__PURE__ */ B("p", {
|
|
514
514
|
className: "text-center text-[10px] text-foreground-subtle py-3 leading-tight",
|
|
@@ -530,7 +530,7 @@ function ye({ zones: e, selectedZoneId: t, drawingKind: n, onSelectZone: r, onDe
|
|
|
530
530
|
children: e.name
|
|
531
531
|
}),
|
|
532
532
|
/* @__PURE__ */ B("span", {
|
|
533
|
-
className: `inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium flex-shrink-0 ${
|
|
533
|
+
className: `inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium flex-shrink-0 ${ye[e.kind]}`,
|
|
534
534
|
children: e.kind === "tripwire" ? s("zone.kind.tripwire") : s("zone.kind.polygon")
|
|
535
535
|
}),
|
|
536
536
|
/* @__PURE__ */ B("button", {
|
|
@@ -540,7 +540,7 @@ function ye({ zones: e, selectedZoneId: t, drawingKind: n, onSelectZone: r, onDe
|
|
|
540
540
|
onClick: (t) => {
|
|
541
541
|
t.stopPropagation(), i(e.id);
|
|
542
542
|
},
|
|
543
|
-
children: /* @__PURE__ */ B(
|
|
543
|
+
children: /* @__PURE__ */ B(q, { className: "h-3 w-3" })
|
|
544
544
|
})
|
|
545
545
|
]
|
|
546
546
|
}, e.id);
|
|
@@ -550,7 +550,7 @@ function ye({ zones: e, selectedZoneId: t, drawingKind: n, onSelectZone: r, onDe
|
|
|
550
550
|
}
|
|
551
551
|
//#endregion
|
|
552
552
|
//#region src/widgets/zone-editor/ZoneForm.tsx
|
|
553
|
-
var
|
|
553
|
+
var xe = [
|
|
554
554
|
"#3b82f6",
|
|
555
555
|
"#10b981",
|
|
556
556
|
"#f59e0b",
|
|
@@ -560,8 +560,8 @@ var be = [
|
|
|
560
560
|
"#f97316",
|
|
561
561
|
"#ec4899"
|
|
562
562
|
];
|
|
563
|
-
function
|
|
564
|
-
let { t: i } =
|
|
563
|
+
function Se({ zone: e, onSave: t, onDiscard: n, onDelete: r }) {
|
|
564
|
+
let { t: i } = Y(), a = D(), o = (e) => a?.updateDraft({ name: e }), s = (e) => a?.updateDraft({ color: e });
|
|
565
565
|
return /* @__PURE__ */ V("div", {
|
|
566
566
|
className: "flex flex-col gap-2",
|
|
567
567
|
children: [
|
|
@@ -588,7 +588,7 @@ function xe({ zone: e, onSave: t, onDiscard: n, onDelete: r }) {
|
|
|
588
588
|
}),
|
|
589
589
|
/* @__PURE__ */ B("div", {
|
|
590
590
|
className: "flex flex-wrap gap-1",
|
|
591
|
-
children:
|
|
591
|
+
children: xe.map((t) => /* @__PURE__ */ B("button", {
|
|
592
592
|
type: "button",
|
|
593
593
|
title: t,
|
|
594
594
|
className: ["h-4 w-4 rounded border-2 cursor-pointer transition-transform hover:scale-110", e.color === t ? "border-white scale-110" : "border-transparent"].join(" "),
|
|
@@ -622,47 +622,77 @@ function xe({ zone: e, onSave: t, onDiscard: n, onDelete: r }) {
|
|
|
622
622
|
onClick: t,
|
|
623
623
|
className: "inline-flex items-center justify-center gap-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors h-7 flex-1 text-[11px] font-medium",
|
|
624
624
|
title: i("zoneForm.saveTitle"),
|
|
625
|
-
children: [/* @__PURE__ */ B(
|
|
625
|
+
children: [/* @__PURE__ */ B(ae, { className: "h-3 w-3" }), i("zoneForm.save")]
|
|
626
626
|
}), /* @__PURE__ */ V("button", {
|
|
627
627
|
type: "button",
|
|
628
628
|
onClick: n,
|
|
629
629
|
className: "inline-flex items-center justify-center gap-1 rounded border border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors h-7 px-3 text-[11px] font-medium",
|
|
630
630
|
title: i("zoneForm.discardTitle"),
|
|
631
|
-
children: [/* @__PURE__ */ B(
|
|
631
|
+
children: [/* @__PURE__ */ B(J, { className: "h-3 w-3" }), i("zoneForm.discard")]
|
|
632
632
|
})]
|
|
633
633
|
}),
|
|
634
634
|
/* @__PURE__ */ V("button", {
|
|
635
635
|
type: "button",
|
|
636
636
|
onClick: r,
|
|
637
637
|
className: `${j} w-full`,
|
|
638
|
-
children: [/* @__PURE__ */ B(
|
|
638
|
+
children: [/* @__PURE__ */ B(q, { className: "h-3 w-3" }), i("zoneForm.delete")]
|
|
639
639
|
})
|
|
640
640
|
]
|
|
641
641
|
});
|
|
642
642
|
}
|
|
643
643
|
//#endregion
|
|
644
644
|
//#region src/widgets/zone-editor/zone-rule-stage.ts
|
|
645
|
-
function
|
|
645
|
+
function Ce(e) {
|
|
646
646
|
switch (e) {
|
|
647
|
-
case "motion": return
|
|
648
|
-
case "detection": return
|
|
649
|
-
case "package": return
|
|
647
|
+
case "motion": return X("rules.title.motion");
|
|
648
|
+
case "detection": return X("rules.title.detection");
|
|
649
|
+
case "package": return X("rules.title.package");
|
|
650
650
|
}
|
|
651
651
|
}
|
|
652
|
-
|
|
652
|
+
t.options;
|
|
653
653
|
//#endregion
|
|
654
654
|
//#region src/widgets/zone-editor/zone-rule-class-filter.ts
|
|
655
|
-
var
|
|
656
|
-
function
|
|
657
|
-
return
|
|
655
|
+
var we = new Set(["detection"]);
|
|
656
|
+
function Te(e) {
|
|
657
|
+
return we.has(e);
|
|
658
|
+
}
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/widgets/zone-editor/types.ts
|
|
661
|
+
function Ee(e) {
|
|
662
|
+
let t = e.kind === "tripwire" ? {
|
|
663
|
+
kind: "line",
|
|
664
|
+
points: e.points
|
|
665
|
+
} : {
|
|
666
|
+
kind: "polygon",
|
|
667
|
+
points: e.points
|
|
668
|
+
};
|
|
669
|
+
return {
|
|
670
|
+
id: e.id,
|
|
671
|
+
label: e.name,
|
|
672
|
+
color: e.color,
|
|
673
|
+
shape: t
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function De(e) {
|
|
677
|
+
return e === "line" ? "tripwire" : "polygon";
|
|
678
|
+
}
|
|
679
|
+
function Oe(e) {
|
|
680
|
+
return e === "tripwire" ? "line" : "polygon";
|
|
681
|
+
}
|
|
682
|
+
function ke() {
|
|
683
|
+
if (typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
684
|
+
let e = crypto.getRandomValues(new Uint8Array(16));
|
|
685
|
+
e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
|
|
686
|
+
let t = Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
687
|
+
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
658
688
|
}
|
|
659
689
|
//#endregion
|
|
660
690
|
//#region src/widgets/zone-editor/ZoneRulesEditor.tsx
|
|
661
|
-
var
|
|
691
|
+
var Ae = r.map((e) => ({
|
|
662
692
|
id: e.id,
|
|
663
693
|
label: e.name
|
|
664
694
|
}));
|
|
665
|
-
function
|
|
695
|
+
function je(e) {
|
|
666
696
|
return {
|
|
667
697
|
id: e.id,
|
|
668
698
|
name: e.name ?? "",
|
|
@@ -674,7 +704,7 @@ function Ee(e) {
|
|
|
674
704
|
confirmWithLlm: e.confirmWithLlm === !0
|
|
675
705
|
};
|
|
676
706
|
}
|
|
677
|
-
function
|
|
707
|
+
function Me(e, t) {
|
|
678
708
|
return {
|
|
679
709
|
id: e.id,
|
|
680
710
|
zoneIds: e.zoneIds,
|
|
@@ -688,7 +718,7 @@ function De(e, t) {
|
|
|
688
718
|
} : {}
|
|
689
719
|
};
|
|
690
720
|
}
|
|
691
|
-
function
|
|
721
|
+
function Ne({ on: e, label: t, hint: n, onToggle: r }) {
|
|
692
722
|
return /* @__PURE__ */ V("div", {
|
|
693
723
|
className: "flex items-center gap-1.5",
|
|
694
724
|
children: [/* @__PURE__ */ B("button", {
|
|
@@ -706,62 +736,61 @@ function Oe({ on: e, label: t, hint: n, onToggle: r }) {
|
|
|
706
736
|
})]
|
|
707
737
|
});
|
|
708
738
|
}
|
|
709
|
-
function
|
|
710
|
-
let { t:
|
|
739
|
+
function Z({ dev: e, deviceId: t, stage: n, zones: r, title: a }) {
|
|
740
|
+
let { t: o } = Y(), s = N(), l = k(e?.state.zoneRules), d = c(() => l?.[n] ?? [], [l, n]), [p, h] = u([]), [g, v] = u(!1), [y, b] = u(!1), [x, S] = u(null), w = Te(n);
|
|
711
741
|
i(() => {
|
|
712
|
-
|
|
713
|
-
}, [
|
|
714
|
-
let
|
|
715
|
-
|
|
716
|
-
id:
|
|
742
|
+
g || h(d.map(je));
|
|
743
|
+
}, [d, g]);
|
|
744
|
+
let E = () => {
|
|
745
|
+
h((e) => [...e, {
|
|
746
|
+
id: ke(),
|
|
717
747
|
name: "",
|
|
718
|
-
zoneIds:
|
|
748
|
+
zoneIds: r[0] ? [r[0].id] : [],
|
|
719
749
|
mode: "exclude",
|
|
720
750
|
classFilter: [],
|
|
721
751
|
enabled: !0,
|
|
722
752
|
detectBySceneDifference: !1,
|
|
723
753
|
confirmWithLlm: !1
|
|
724
|
-
}]),
|
|
725
|
-
},
|
|
726
|
-
|
|
754
|
+
}]), v(!0);
|
|
755
|
+
}, D = (e, t) => {
|
|
756
|
+
h((n) => n.map((n, r) => {
|
|
727
757
|
if (r !== e) return n;
|
|
728
758
|
let i = n.classFilter.includes(t) ? n.classFilter.filter((e) => e !== t) : [...n.classFilter, t];
|
|
729
759
|
return {
|
|
730
760
|
...n,
|
|
731
761
|
classFilter: i
|
|
732
762
|
};
|
|
733
|
-
})),
|
|
734
|
-
},
|
|
735
|
-
|
|
763
|
+
})), v(!0);
|
|
764
|
+
}, A = (e, t) => {
|
|
765
|
+
h((n) => n.map((n, r) => {
|
|
736
766
|
if (r !== e) return n;
|
|
737
767
|
let i = n.zoneIds.includes(t) ? n.zoneIds.filter((e) => e !== t) : [...n.zoneIds, t];
|
|
738
768
|
return {
|
|
739
769
|
...n,
|
|
740
770
|
zoneIds: i
|
|
741
771
|
};
|
|
742
|
-
})),
|
|
743
|
-
},
|
|
744
|
-
|
|
745
|
-
},
|
|
746
|
-
|
|
772
|
+
})), v(!0);
|
|
773
|
+
}, j = (e) => {
|
|
774
|
+
h((t) => t.filter((t, n) => n !== e)), v(!0);
|
|
775
|
+
}, M = (e, t) => {
|
|
776
|
+
h((n) => n.map((n, r) => r === e ? {
|
|
747
777
|
...n,
|
|
748
778
|
...t
|
|
749
|
-
} : n)),
|
|
750
|
-
},
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
}
|
|
779
|
+
} : n)), v(!0);
|
|
780
|
+
}, P = async () => {
|
|
781
|
+
b(!0), S(null);
|
|
782
|
+
try {
|
|
783
|
+
await s.trpcClient.zoneRules.setRules.mutate({
|
|
784
|
+
deviceId: t,
|
|
785
|
+
stage: n,
|
|
786
|
+
rules: p.map((e) => Me(e, n))
|
|
787
|
+
}), v(!1);
|
|
788
|
+
} catch (e) {
|
|
789
|
+
S(e instanceof Error ? e.message : String(e));
|
|
790
|
+
} finally {
|
|
791
|
+
b(!1);
|
|
763
792
|
}
|
|
764
|
-
},
|
|
793
|
+
}, F = g && !y;
|
|
765
794
|
return /* @__PURE__ */ V("div", {
|
|
766
795
|
className: "rounded-md border border-border bg-surface/40 p-2.5",
|
|
767
796
|
children: [
|
|
@@ -769,37 +798,37 @@ function Q({ dev: e, stage: t, zones: n, title: r }) {
|
|
|
769
798
|
className: "flex items-center justify-between mb-2 gap-2",
|
|
770
799
|
children: [/* @__PURE__ */ B("h3", {
|
|
771
800
|
className: `${f} truncate`,
|
|
772
|
-
children:
|
|
801
|
+
children: a ?? Ce(n)
|
|
773
802
|
}), /* @__PURE__ */ V("div", {
|
|
774
803
|
className: "flex items-center gap-1 flex-shrink-0",
|
|
775
804
|
children: [/* @__PURE__ */ V("button", {
|
|
776
805
|
type: "button",
|
|
777
|
-
onClick:
|
|
778
|
-
disabled:
|
|
806
|
+
onClick: E,
|
|
807
|
+
disabled: r.length === 0 || !e,
|
|
779
808
|
className: C,
|
|
780
|
-
title:
|
|
809
|
+
title: o("rules.add"),
|
|
781
810
|
children: [
|
|
782
|
-
/* @__PURE__ */ B(
|
|
811
|
+
/* @__PURE__ */ B(de, { className: "h-2.5 w-2.5" }),
|
|
783
812
|
" ",
|
|
784
|
-
|
|
813
|
+
o("rules.addShort")
|
|
785
814
|
]
|
|
786
815
|
}), /* @__PURE__ */ V("button", {
|
|
787
816
|
type: "button",
|
|
788
817
|
onClick: () => {
|
|
789
|
-
|
|
818
|
+
P();
|
|
790
819
|
},
|
|
791
|
-
disabled: !
|
|
820
|
+
disabled: !F,
|
|
792
821
|
className: T,
|
|
793
|
-
children: [/* @__PURE__ */ B(
|
|
822
|
+
children: [/* @__PURE__ */ B(fe, { className: "h-2.5 w-2.5" }), y ? "…" : o("rules.save")]
|
|
794
823
|
})]
|
|
795
824
|
})]
|
|
796
825
|
}),
|
|
797
|
-
|
|
826
|
+
p.length === 0 ? /* @__PURE__ */ B("p", {
|
|
798
827
|
className: "text-[10px] text-foreground-subtle italic px-1 py-1.5 leading-tight",
|
|
799
|
-
children:
|
|
828
|
+
children: r.length === 0 ? o("rules.noZones") : o("rules.empty")
|
|
800
829
|
}) : /* @__PURE__ */ B("div", {
|
|
801
830
|
className: "flex flex-col gap-1.5",
|
|
802
|
-
children:
|
|
831
|
+
children: p.map((e, t) => /* @__PURE__ */ V("div", {
|
|
803
832
|
className: "rounded border border-border/50 bg-background/40 px-2 py-1.5 flex flex-col gap-1.5 overflow-hidden",
|
|
804
833
|
children: [
|
|
805
834
|
/* @__PURE__ */ V("div", {
|
|
@@ -809,25 +838,25 @@ function Q({ dev: e, stage: t, zones: n, title: r }) {
|
|
|
809
838
|
type: "button",
|
|
810
839
|
role: "switch",
|
|
811
840
|
"aria-checked": e.enabled,
|
|
812
|
-
"aria-label": e.enabled ?
|
|
813
|
-
title: e.enabled ?
|
|
814
|
-
onClick: () =>
|
|
841
|
+
"aria-label": e.enabled ? o("rules.disable") : o("rules.enable"),
|
|
842
|
+
title: e.enabled ? o("rules.activeTitle") : o("rules.disabledTitle"),
|
|
843
|
+
onClick: () => M(t, { enabled: !e.enabled }),
|
|
815
844
|
className: ["inline-flex items-center justify-center h-5 w-9 rounded-full border transition-colors flex-shrink-0", e.enabled ? "border-primary/50 bg-primary/20 text-primary" : "border-border bg-surface text-foreground-subtle"].join(" "),
|
|
816
845
|
children: /* @__PURE__ */ B("span", { className: ["h-3 w-3 rounded-full transition-transform", e.enabled ? "translate-x-1.5 bg-primary" : "-translate-x-1.5 bg-foreground-subtle"].join(" ") })
|
|
817
846
|
}),
|
|
818
847
|
/* @__PURE__ */ B("input", {
|
|
819
848
|
className: `${O} min-w-0`,
|
|
820
|
-
placeholder:
|
|
849
|
+
placeholder: o("rules.namePlaceholder"),
|
|
821
850
|
value: e.name,
|
|
822
|
-
onChange: (e) =>
|
|
851
|
+
onChange: (e) => M(t, { name: e.target.value })
|
|
823
852
|
}),
|
|
824
853
|
/* @__PURE__ */ B("button", {
|
|
825
854
|
type: "button",
|
|
826
|
-
title:
|
|
827
|
-
"aria-label":
|
|
828
|
-
onClick: () =>
|
|
855
|
+
title: o("rules.remove"),
|
|
856
|
+
"aria-label": o("rules.remove"),
|
|
857
|
+
onClick: () => j(t),
|
|
829
858
|
className: "flex items-center justify-center h-6 w-6 rounded text-foreground-subtle hover:text-danger hover:bg-danger/10 transition-colors flex-shrink-0",
|
|
830
|
-
children: /* @__PURE__ */ B(
|
|
859
|
+
children: /* @__PURE__ */ B(q, { className: "h-3.5 w-3.5" })
|
|
831
860
|
})
|
|
832
861
|
]
|
|
833
862
|
}),
|
|
@@ -836,19 +865,19 @@ function Q({ dev: e, stage: t, zones: n, title: r }) {
|
|
|
836
865
|
children: [
|
|
837
866
|
/* @__PURE__ */ B("span", {
|
|
838
867
|
className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0",
|
|
839
|
-
children:
|
|
868
|
+
children: o("rules.mode")
|
|
840
869
|
}),
|
|
841
870
|
/* @__PURE__ */ B("button", {
|
|
842
871
|
type: "button",
|
|
843
|
-
onClick: () =>
|
|
872
|
+
onClick: () => M(t, { mode: "include" }),
|
|
844
873
|
className: `${_} ${e.mode === "include" ? L : m}`,
|
|
845
|
-
children:
|
|
874
|
+
children: o("rules.include")
|
|
846
875
|
}),
|
|
847
876
|
/* @__PURE__ */ B("button", {
|
|
848
877
|
type: "button",
|
|
849
|
-
onClick: () =>
|
|
878
|
+
onClick: () => M(t, { mode: "exclude" }),
|
|
850
879
|
className: `${_} ${e.mode === "exclude" ? L : m}`,
|
|
851
|
-
children:
|
|
880
|
+
children: o("rules.exclude")
|
|
852
881
|
})
|
|
853
882
|
]
|
|
854
883
|
}),
|
|
@@ -856,92 +885,69 @@ function Q({ dev: e, stage: t, zones: n, title: r }) {
|
|
|
856
885
|
className: "flex items-center gap-1.5 flex-wrap",
|
|
857
886
|
children: [/* @__PURE__ */ B("span", {
|
|
858
887
|
className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0",
|
|
859
|
-
children:
|
|
860
|
-
}),
|
|
888
|
+
children: o("rules.zones")
|
|
889
|
+
}), r.length === 0 ? /* @__PURE__ */ B("span", {
|
|
861
890
|
className: "text-[10px] text-foreground-subtle italic",
|
|
862
|
-
children:
|
|
863
|
-
}) :
|
|
891
|
+
children: o("rules.noneZones")
|
|
892
|
+
}) : r.map((n) => /* @__PURE__ */ V("button", {
|
|
864
893
|
type: "button",
|
|
865
|
-
onClick: () =>
|
|
866
|
-
className: `${_} ${e.zoneIds.includes(
|
|
894
|
+
onClick: () => A(t, n.id),
|
|
895
|
+
className: `${_} ${e.zoneIds.includes(n.id) ? L : m}`,
|
|
867
896
|
children: [/* @__PURE__ */ B("span", {
|
|
868
897
|
className: "h-2 w-2 rounded-sm",
|
|
869
|
-
style: { backgroundColor:
|
|
898
|
+
style: { backgroundColor: n.color || "#3b82f6" }
|
|
870
899
|
}), /* @__PURE__ */ B("span", {
|
|
871
900
|
className: "truncate max-w-[7rem]",
|
|
872
|
-
children:
|
|
901
|
+
children: n.name || n.id
|
|
873
902
|
})]
|
|
874
|
-
},
|
|
903
|
+
}, n.id))]
|
|
875
904
|
}),
|
|
876
|
-
|
|
905
|
+
n === "package" && /* @__PURE__ */ V("div", {
|
|
877
906
|
className: "flex flex-col gap-1",
|
|
878
|
-
children: [/* @__PURE__ */ B(
|
|
907
|
+
children: [/* @__PURE__ */ B(Ne, {
|
|
879
908
|
on: e.detectBySceneDifference,
|
|
880
|
-
label:
|
|
881
|
-
hint:
|
|
882
|
-
onToggle: () =>
|
|
883
|
-
}), /* @__PURE__ */ B(
|
|
909
|
+
label: o("rules.sceneDifference"),
|
|
910
|
+
hint: o("rules.sceneDifferenceHint"),
|
|
911
|
+
onToggle: () => M(t, { detectBySceneDifference: !e.detectBySceneDifference })
|
|
912
|
+
}), /* @__PURE__ */ B(Ne, {
|
|
884
913
|
on: e.confirmWithLlm,
|
|
885
|
-
label:
|
|
886
|
-
hint:
|
|
887
|
-
onToggle: () =>
|
|
914
|
+
label: o("rules.confirmLlm"),
|
|
915
|
+
hint: o("rules.confirmLlmHint"),
|
|
916
|
+
onToggle: () => M(t, { confirmWithLlm: !e.confirmWithLlm })
|
|
888
917
|
})]
|
|
889
918
|
}),
|
|
890
|
-
|
|
919
|
+
w && /* @__PURE__ */ V("div", {
|
|
891
920
|
className: "flex items-center gap-1.5 flex-wrap",
|
|
892
921
|
children: [
|
|
893
922
|
/* @__PURE__ */ B("span", {
|
|
894
923
|
className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0",
|
|
895
|
-
children:
|
|
924
|
+
children: o("rules.class")
|
|
896
925
|
}),
|
|
897
|
-
|
|
926
|
+
Ae.map((n) => /* @__PURE__ */ B("button", {
|
|
898
927
|
type: "button",
|
|
899
|
-
onClick: () =>
|
|
900
|
-
className: `${_} ${e.classFilter.includes(
|
|
901
|
-
children:
|
|
902
|
-
},
|
|
928
|
+
onClick: () => D(t, n.id),
|
|
929
|
+
className: `${_} ${e.classFilter.includes(n.id) ? L : m}`,
|
|
930
|
+
children: n.label
|
|
931
|
+
}, n.id)),
|
|
903
932
|
e.classFilter.length === 0 && /* @__PURE__ */ B("span", {
|
|
904
933
|
className: "text-[10px] text-foreground-subtle italic ml-1",
|
|
905
|
-
children:
|
|
934
|
+
children: o("rules.anyClass")
|
|
906
935
|
})
|
|
907
936
|
]
|
|
908
937
|
})
|
|
909
938
|
]
|
|
910
939
|
}, e.id))
|
|
911
940
|
}),
|
|
912
|
-
|
|
941
|
+
x && /* @__PURE__ */ B("p", {
|
|
913
942
|
className: "mt-2 text-[10px] text-danger",
|
|
914
|
-
children:
|
|
943
|
+
children: x
|
|
915
944
|
})
|
|
916
945
|
]
|
|
917
946
|
});
|
|
918
947
|
}
|
|
919
948
|
//#endregion
|
|
920
|
-
//#region src/widgets/zone-editor/types.ts
|
|
921
|
-
function ke(e) {
|
|
922
|
-
let t = e.kind === "tripwire" ? {
|
|
923
|
-
kind: "line",
|
|
924
|
-
points: e.points
|
|
925
|
-
} : {
|
|
926
|
-
kind: "polygon",
|
|
927
|
-
points: e.points
|
|
928
|
-
};
|
|
929
|
-
return {
|
|
930
|
-
id: e.id,
|
|
931
|
-
label: e.name,
|
|
932
|
-
color: e.color,
|
|
933
|
-
shape: t
|
|
934
|
-
};
|
|
935
|
-
}
|
|
936
|
-
function Ae(e) {
|
|
937
|
-
return e === "line" ? "tripwire" : "polygon";
|
|
938
|
-
}
|
|
939
|
-
function je(e) {
|
|
940
|
-
return e === "tripwire" ? "line" : "polygon";
|
|
941
|
-
}
|
|
942
|
-
//#endregion
|
|
943
949
|
//#region src/widgets/zone-editor/ZoneOverlay.tsx
|
|
944
|
-
var
|
|
950
|
+
var Pe = "#3b82f6", Fe = ["polygon", "line"], Q = [
|
|
945
951
|
"#3b82f6",
|
|
946
952
|
"#10b981",
|
|
947
953
|
"#f59e0b",
|
|
@@ -953,21 +959,21 @@ var Me = "#3b82f6", Ne = ["polygon", "line"], $ = [
|
|
|
953
959
|
"#8b5cf6",
|
|
954
960
|
"#14b8a6"
|
|
955
961
|
];
|
|
956
|
-
function
|
|
962
|
+
function Ie(e) {
|
|
957
963
|
let t = new Set(e.map((e) => (e.color ?? "").toLowerCase()));
|
|
958
|
-
for (let e of
|
|
959
|
-
return
|
|
964
|
+
for (let e of Q) if (!t.has(e.toLowerCase())) return e;
|
|
965
|
+
return Q[e.length % Q.length];
|
|
960
966
|
}
|
|
961
|
-
function
|
|
967
|
+
function Le(e) {
|
|
962
968
|
return {
|
|
963
969
|
id: e.id,
|
|
964
970
|
name: e.name,
|
|
965
971
|
kind: e.kind,
|
|
966
|
-
color: e.color ||
|
|
972
|
+
color: e.color || Pe,
|
|
967
973
|
points: [...e.polygon]
|
|
968
974
|
};
|
|
969
975
|
}
|
|
970
|
-
function
|
|
976
|
+
function $(e) {
|
|
971
977
|
return {
|
|
972
978
|
id: e.id,
|
|
973
979
|
name: e.name,
|
|
@@ -976,64 +982,73 @@ function Ie(e) {
|
|
|
976
982
|
color: e.color
|
|
977
983
|
};
|
|
978
984
|
}
|
|
979
|
-
function
|
|
980
|
-
let t =
|
|
981
|
-
id:
|
|
982
|
-
name:
|
|
983
|
-
kind:
|
|
984
|
-
color:
|
|
985
|
-
points: [...
|
|
986
|
-
} :
|
|
987
|
-
if (
|
|
988
|
-
let
|
|
989
|
-
id:
|
|
985
|
+
function Re({ deviceId: e }) {
|
|
986
|
+
let t = N(), n = k(P(t.trpcClient, e)?.state.zones), r = c(() => n?.zones ?? [], [n]), i = D(), s = i?.drawingKind ?? null, l = i?.selectedZoneId ?? null, d = i?.editingDraft ?? null, f = c(() => r.map((e) => d && d.id === e.id ? {
|
|
987
|
+
id: d.id,
|
|
988
|
+
name: d.name,
|
|
989
|
+
kind: d.kind,
|
|
990
|
+
color: d.color,
|
|
991
|
+
points: [...d.points]
|
|
992
|
+
} : Le(e)), [r, d]), p = c(() => f.map(Ee), [f]), [m, h] = u(null), g = o(async (n) => {
|
|
993
|
+
if (n.kind !== "polygon" && n.kind !== "line") return;
|
|
994
|
+
let r = {
|
|
995
|
+
id: ke(),
|
|
990
996
|
name: "",
|
|
991
|
-
kind:
|
|
992
|
-
color:
|
|
993
|
-
points: [...
|
|
997
|
+
kind: De(n.kind),
|
|
998
|
+
color: Ie(f),
|
|
999
|
+
points: [...n.points]
|
|
994
1000
|
};
|
|
1001
|
+
h(null);
|
|
995
1002
|
try {
|
|
996
|
-
await t
|
|
1003
|
+
await t.trpcClient.zones.addZone.mutate({
|
|
1004
|
+
deviceId: e,
|
|
1005
|
+
zone: $(r)
|
|
1006
|
+
}), i?.setSelectedZoneId(r.id);
|
|
997
1007
|
} catch (e) {
|
|
998
|
-
console.error("zones.addZone failed", e);
|
|
1008
|
+
console.error("zones.addZone failed", e), h(e instanceof Error ? e.message : String(e));
|
|
999
1009
|
}
|
|
1000
|
-
i?.
|
|
1010
|
+
i?.setDrawingKind(null);
|
|
1001
1011
|
}, [
|
|
1002
1012
|
t,
|
|
1003
|
-
|
|
1013
|
+
e,
|
|
1014
|
+
f,
|
|
1004
1015
|
i
|
|
1005
|
-
]),
|
|
1006
|
-
let
|
|
1016
|
+
]), _ = o(async (n, r) => {
|
|
1017
|
+
let a = r.map((e) => ({
|
|
1007
1018
|
x: e.x,
|
|
1008
1019
|
y: e.y
|
|
1009
1020
|
}));
|
|
1010
|
-
if (
|
|
1011
|
-
i?.updateDraft({ points:
|
|
1021
|
+
if (d && d.id === n) {
|
|
1022
|
+
i?.updateDraft({ points: a });
|
|
1012
1023
|
return;
|
|
1013
1024
|
}
|
|
1014
|
-
let
|
|
1015
|
-
if (
|
|
1016
|
-
await t
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1025
|
+
let o = f.find((e) => e.id === n);
|
|
1026
|
+
if (o) try {
|
|
1027
|
+
await t.trpcClient.zones.updateZone.mutate({
|
|
1028
|
+
deviceId: e,
|
|
1029
|
+
zone: $({
|
|
1030
|
+
...o,
|
|
1031
|
+
points: a
|
|
1032
|
+
})
|
|
1033
|
+
});
|
|
1020
1034
|
} catch (e) {
|
|
1021
|
-
console.error("zones.updateZone failed", e);
|
|
1035
|
+
console.error("zones.updateZone failed", e), h(e instanceof Error ? e.message : String(e));
|
|
1022
1036
|
}
|
|
1023
1037
|
}, [
|
|
1024
1038
|
t,
|
|
1039
|
+
e,
|
|
1040
|
+
f,
|
|
1025
1041
|
d,
|
|
1026
|
-
u,
|
|
1027
1042
|
i
|
|
1028
|
-
]),
|
|
1029
|
-
typeof e == "string" && (t.kind !== "polygon" && t.kind !== "line" ||
|
|
1030
|
-
}, [
|
|
1043
|
+
]), v = o((e, t) => {
|
|
1044
|
+
typeof e == "string" && (t.kind !== "polygon" && t.kind !== "line" || _(e, t.points));
|
|
1045
|
+
}, [_]), y = o((e) => {
|
|
1031
1046
|
if (e === null) {
|
|
1032
1047
|
i?.discardDraft(), i?.setSelectedZoneId(null);
|
|
1033
1048
|
return;
|
|
1034
1049
|
}
|
|
1035
1050
|
if (typeof e != "string") return;
|
|
1036
|
-
let t =
|
|
1051
|
+
let t = f.find((t) => t.id === e);
|
|
1037
1052
|
if (!t) {
|
|
1038
1053
|
i?.setSelectedZoneId(e);
|
|
1039
1054
|
return;
|
|
@@ -1045,34 +1060,38 @@ function Le({ deviceId: e }) {
|
|
|
1045
1060
|
color: t.color,
|
|
1046
1061
|
points: t.points
|
|
1047
1062
|
});
|
|
1048
|
-
}, [
|
|
1049
|
-
return
|
|
1063
|
+
}, [f, i]);
|
|
1064
|
+
return f.length === 0 && s === null && m === null ? null : /* @__PURE__ */ V(a, {
|
|
1050
1065
|
fallback: null,
|
|
1051
|
-
children: /* @__PURE__ */ B(w, {
|
|
1066
|
+
children: [/* @__PURE__ */ B(w, {
|
|
1052
1067
|
transparent: !0,
|
|
1053
|
-
items:
|
|
1054
|
-
supportedShapes:
|
|
1068
|
+
items: p,
|
|
1069
|
+
supportedShapes: Fe,
|
|
1055
1070
|
selectedId: l,
|
|
1056
|
-
onSelect:
|
|
1057
|
-
onShapeChange:
|
|
1071
|
+
onSelect: y,
|
|
1072
|
+
onShapeChange: v,
|
|
1058
1073
|
onDrawComplete: (e) => {
|
|
1059
|
-
|
|
1074
|
+
g(e);
|
|
1060
1075
|
},
|
|
1061
|
-
drawingKind: s === null ? null :
|
|
1062
|
-
})
|
|
1076
|
+
drawingKind: s === null ? null : Oe(s)
|
|
1077
|
+
}), m !== null && /* @__PURE__ */ B("p", {
|
|
1078
|
+
role: "alert",
|
|
1079
|
+
className: "absolute inset-x-2 bottom-2 rounded-md border border-danger/40 bg-background-elevated px-2 py-1 text-xs text-danger",
|
|
1080
|
+
children: m
|
|
1081
|
+
})]
|
|
1063
1082
|
});
|
|
1064
1083
|
}
|
|
1065
|
-
var
|
|
1066
|
-
function
|
|
1084
|
+
var ze = l(Re), Be = "#3b82f6";
|
|
1085
|
+
function Ve(e) {
|
|
1067
1086
|
return {
|
|
1068
1087
|
id: e.id,
|
|
1069
1088
|
name: e.name,
|
|
1070
1089
|
kind: e.kind,
|
|
1071
|
-
color: e.color ||
|
|
1090
|
+
color: e.color || Be,
|
|
1072
1091
|
points: [...e.polygon]
|
|
1073
1092
|
};
|
|
1074
1093
|
}
|
|
1075
|
-
function
|
|
1094
|
+
function He(e) {
|
|
1076
1095
|
return {
|
|
1077
1096
|
id: e.id,
|
|
1078
1097
|
name: e.name,
|
|
@@ -1081,62 +1100,76 @@ function Ve(e) {
|
|
|
1081
1100
|
color: e.color
|
|
1082
1101
|
};
|
|
1083
1102
|
}
|
|
1084
|
-
function
|
|
1085
|
-
let { t } =
|
|
1103
|
+
function Ue({ deviceId: e }) {
|
|
1104
|
+
let { t } = Y(), n = N(), r = P(n.trpcClient, e), i = k(r?.state.zones), a = c(() => i?.zones ?? [], [i]), s = c(() => a.map(Ve), [a]), [l, d] = u(null), p = D(), m = p?.drawingKind ?? null, h = p?.selectedZoneId ?? null, _ = p?.editingDraft ?? null;
|
|
1086
1105
|
A(c(() => ({
|
|
1087
1106
|
id: "zones",
|
|
1088
1107
|
order: 100,
|
|
1089
|
-
node: /* @__PURE__ */ B(
|
|
1108
|
+
node: /* @__PURE__ */ B(ze, { deviceId: e })
|
|
1090
1109
|
}), [e]));
|
|
1091
|
-
let
|
|
1110
|
+
let y = o((e) => {
|
|
1092
1111
|
if (e === null) {
|
|
1093
|
-
|
|
1112
|
+
p?.discardDraft(), p?.setSelectedZoneId(null);
|
|
1094
1113
|
return;
|
|
1095
1114
|
}
|
|
1096
|
-
let t =
|
|
1097
|
-
t &&
|
|
1115
|
+
let t = s.find((t) => t.id === e);
|
|
1116
|
+
t && p?.enterDraft({
|
|
1098
1117
|
id: t.id,
|
|
1099
1118
|
kind: t.kind,
|
|
1100
1119
|
name: t.name,
|
|
1101
1120
|
color: t.color,
|
|
1102
1121
|
points: t.points
|
|
1103
1122
|
});
|
|
1104
|
-
}, [
|
|
1105
|
-
let
|
|
1106
|
-
if (
|
|
1123
|
+
}, [s, p]), x = o(async () => {
|
|
1124
|
+
let t = p?.editingDraft;
|
|
1125
|
+
if (t) {
|
|
1107
1126
|
try {
|
|
1108
|
-
await n
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1127
|
+
await n.trpcClient.zones.updateZone.mutate({
|
|
1128
|
+
deviceId: e,
|
|
1129
|
+
zone: He({
|
|
1130
|
+
id: t.id,
|
|
1131
|
+
kind: t.kind,
|
|
1132
|
+
name: t.name,
|
|
1133
|
+
color: t.color,
|
|
1134
|
+
points: [...t.points]
|
|
1135
|
+
})
|
|
1136
|
+
});
|
|
1115
1137
|
} catch (e) {
|
|
1116
|
-
console.error("zones.updateZone failed", e);
|
|
1138
|
+
console.error("zones.updateZone failed", e), d(e instanceof Error ? e.message : String(e));
|
|
1117
1139
|
}
|
|
1118
|
-
|
|
1140
|
+
p?.discardDraft(), p?.setSelectedZoneId(null);
|
|
1119
1141
|
}
|
|
1120
|
-
}, [
|
|
1121
|
-
|
|
1122
|
-
|
|
1142
|
+
}, [
|
|
1143
|
+
n,
|
|
1144
|
+
e,
|
|
1145
|
+
p
|
|
1146
|
+
]), S = o(() => {
|
|
1147
|
+
p?.discardDraft(), p?.setSelectedZoneId(null);
|
|
1148
|
+
}, [p]), C = o(async (t) => {
|
|
1123
1149
|
try {
|
|
1124
|
-
await n
|
|
1150
|
+
await n.trpcClient.zones.removeZone.mutate({
|
|
1151
|
+
deviceId: e,
|
|
1152
|
+
zoneId: t
|
|
1153
|
+
});
|
|
1125
1154
|
} catch (e) {
|
|
1126
|
-
console.error("zones.removeZone failed", e);
|
|
1155
|
+
console.error("zones.removeZone failed", e), d(e instanceof Error ? e.message : String(e));
|
|
1127
1156
|
}
|
|
1128
|
-
|
|
1129
|
-
}, [
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1157
|
+
p?.selectedZoneId === t && p.setSelectedZoneId(null), p?.editingDraft?.id === t && p.discardDraft();
|
|
1158
|
+
}, [
|
|
1159
|
+
n,
|
|
1160
|
+
e,
|
|
1161
|
+
p
|
|
1162
|
+
]), w = o((e) => {
|
|
1163
|
+
p?.startDrawing(e);
|
|
1164
|
+
}, [p]), T = o(() => {
|
|
1165
|
+
p?.setDrawingKind(null);
|
|
1166
|
+
}, [p]), E = c(() => !_ || !s.find((e) => e.id === _.id) ? null : {
|
|
1167
|
+
id: _.id,
|
|
1168
|
+
kind: _.kind,
|
|
1169
|
+
name: _.name,
|
|
1170
|
+
color: _.color,
|
|
1171
|
+
points: [..._.points]
|
|
1172
|
+
}, [s, _]);
|
|
1140
1173
|
return /* @__PURE__ */ V("div", {
|
|
1141
1174
|
className: b,
|
|
1142
1175
|
children: [/* @__PURE__ */ V("div", {
|
|
@@ -1150,7 +1183,7 @@ function He({ deviceId: e }) {
|
|
|
1150
1183
|
children: t("zonesTab.title")
|
|
1151
1184
|
}), /* @__PURE__ */ B("p", {
|
|
1152
1185
|
className: `${g} mt-0.5 leading-tight`,
|
|
1153
|
-
children: /* @__PURE__ */ B(
|
|
1186
|
+
children: /* @__PURE__ */ B(he, {
|
|
1154
1187
|
i18nKey: "zonesTab.hint",
|
|
1155
1188
|
components: { b: /* @__PURE__ */ B("strong", { className: "text-foreground" }) }
|
|
1156
1189
|
})
|
|
@@ -1158,38 +1191,49 @@ function He({ deviceId: e }) {
|
|
|
1158
1191
|
})
|
|
1159
1192
|
}), /* @__PURE__ */ V("div", {
|
|
1160
1193
|
className: `${v} flex flex-col gap-3`,
|
|
1161
|
-
children: [
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1194
|
+
children: [
|
|
1195
|
+
/* @__PURE__ */ B(be, {
|
|
1196
|
+
zones: s,
|
|
1197
|
+
selectedZoneId: h,
|
|
1198
|
+
drawingKind: m,
|
|
1199
|
+
onSelectZone: y,
|
|
1200
|
+
onDeleteZone: C,
|
|
1201
|
+
onStartDraw: w,
|
|
1202
|
+
onCancelDraw: T
|
|
1203
|
+
}),
|
|
1204
|
+
l !== null && /* @__PURE__ */ B("p", {
|
|
1205
|
+
role: "alert",
|
|
1206
|
+
className: "text-xs text-danger",
|
|
1207
|
+
children: l
|
|
1208
|
+
}),
|
|
1209
|
+
E && /* @__PURE__ */ V(H, { children: [/* @__PURE__ */ B("div", { className: "border-t border-border" }), /* @__PURE__ */ B(Se, {
|
|
1210
|
+
zone: E,
|
|
1211
|
+
onSave: x,
|
|
1212
|
+
onDiscard: S,
|
|
1213
|
+
onDelete: () => C(E.id)
|
|
1214
|
+
})] })
|
|
1215
|
+
]
|
|
1175
1216
|
})]
|
|
1176
1217
|
}), /* @__PURE__ */ V("div", {
|
|
1177
1218
|
className: `grid grid-cols-1 2xl:grid-cols-2 ${F}`,
|
|
1178
1219
|
children: [
|
|
1179
|
-
/* @__PURE__ */ B(
|
|
1180
|
-
dev:
|
|
1220
|
+
/* @__PURE__ */ B(Z, {
|
|
1221
|
+
dev: r,
|
|
1222
|
+
deviceId: e,
|
|
1181
1223
|
stage: "motion",
|
|
1182
|
-
zones:
|
|
1224
|
+
zones: a
|
|
1183
1225
|
}),
|
|
1184
|
-
/* @__PURE__ */ B(
|
|
1185
|
-
dev:
|
|
1226
|
+
/* @__PURE__ */ B(Z, {
|
|
1227
|
+
dev: r,
|
|
1228
|
+
deviceId: e,
|
|
1186
1229
|
stage: "detection",
|
|
1187
|
-
zones:
|
|
1230
|
+
zones: a
|
|
1188
1231
|
}),
|
|
1189
|
-
/* @__PURE__ */ B(
|
|
1190
|
-
dev:
|
|
1232
|
+
/* @__PURE__ */ B(Z, {
|
|
1233
|
+
dev: r,
|
|
1234
|
+
deviceId: e,
|
|
1191
1235
|
stage: "package",
|
|
1192
|
-
zones:
|
|
1236
|
+
zones: a
|
|
1193
1237
|
})
|
|
1194
1238
|
]
|
|
1195
1239
|
})]
|
|
@@ -1197,18 +1241,18 @@ function He({ deviceId: e }) {
|
|
|
1197
1241
|
}
|
|
1198
1242
|
//#endregion
|
|
1199
1243
|
//#region src/widgets/ZoneEditor.tsx
|
|
1200
|
-
function
|
|
1201
|
-
let { t } =
|
|
1244
|
+
function We(e) {
|
|
1245
|
+
let { t } = Y();
|
|
1202
1246
|
return e.deviceId === void 0 ? /* @__PURE__ */ B("div", {
|
|
1203
1247
|
className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning",
|
|
1204
1248
|
children: t("zoneEditor.requiresDevice")
|
|
1205
|
-
}) : /* @__PURE__ */ B(
|
|
1249
|
+
}) : /* @__PURE__ */ B(Ue, { deviceId: e.deviceId });
|
|
1206
1250
|
}
|
|
1207
1251
|
//#endregion
|
|
1208
1252
|
//#region src/widgets/index.tsx
|
|
1209
|
-
var
|
|
1210
|
-
"pipeline-quick-stats":
|
|
1211
|
-
"zone-editor":
|
|
1253
|
+
var Ge = {
|
|
1254
|
+
"pipeline-quick-stats": ge,
|
|
1255
|
+
"zone-editor": We
|
|
1212
1256
|
};
|
|
1213
1257
|
//#endregion
|
|
1214
|
-
export {
|
|
1258
|
+
export { Ge as default };
|