@camstack/addon-pipeline-orchestrator 0.1.26 → 0.1.28

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.
Files changed (41) hide show
  1. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneForm.d.ts +1 -1
  2. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneForm.d.ts.map +1 -1
  3. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneList.d.ts +1 -1
  4. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneList.d.ts.map +1 -1
  5. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneOverlay.d.ts.map +1 -1
  6. package/dist/@mf-types/compiled-types/widgets/zone-editor/types.d.ts +33 -0
  7. package/dist/@mf-types/compiled-types/widgets/zone-editor/types.d.ts.map +1 -0
  8. package/dist/@mf-types.zip +0 -0
  9. package/dist/{ReactKonva--rywLr1Y.mjs → ReactKonva-Rg9MNR62.mjs} +2 -2
  10. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.mjs-h5aXOPSA.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_sdk__loadShare__.mjs-lantnv8e.mjs} +1 -1
  11. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-C507UJJC.mjs +30 -0
  12. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-Bau3YeQq.mjs +35 -0
  13. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-0qpbQxoV.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-B9__gOco.mjs} +7 -6
  14. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-DekuE8px.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs_commonjs-proxy-7px_s7lQ.mjs} +1 -1
  15. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-Ba_7PYkj.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_dom__loadShare__.mjs_commonjs-proxy-BP356DyI.mjs} +1 -1
  16. package/dist/{__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_konva__loadShare__.mjs-DSZIXeAx.mjs → __mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_konva__loadShare__.mjs-BjxkVuVo.mjs} +5 -4
  17. package/dist/_stub.js +483 -774
  18. package/dist/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-iOQz8pwN.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_orchestrator_widgets-LTEdXGaz.mjs} +6 -6
  19. package/dist/{client-CzjQ3uuI.mjs → client-DRnvBKkB.mjs} +2 -2
  20. package/dist/{hostInit-HZ0iFEJA.mjs → hostInit-I-qi78F9.mjs} +13 -13
  21. package/dist/{index-Cbqs9uJn.mjs → index-B7LnRgSE.mjs} +1 -1
  22. package/dist/{index-BmY66bNn.mjs → index-BRAmQOXI.mjs} +254 -268
  23. package/dist/{index-DaulYonp.mjs → index-CSDhxUNV.mjs} +1 -1
  24. package/dist/index-Dhyr_mtg.mjs +52894 -0
  25. package/dist/index-DtOI1aTU.mjs +18504 -0
  26. package/dist/{index-DOuehnyb.mjs → index-DujcNO2E.mjs} +1 -1
  27. package/dist/{index-C1DnrJuR.mjs → index-LZ9uQOMe.mjs} +1 -1
  28. package/dist/index.js +4887 -935
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.mjs +4887 -935
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/{jsx-runtime-DACJhJOv.mjs → jsx-runtime-C5ymGPwR.mjs} +1 -1
  33. package/dist/remoteEntry.js +1 -1
  34. package/dist/{schemas-ChN4Ih0h.mjs → schemas-B7L0qZtq.mjs} +530 -515
  35. package/package.json +4 -1
  36. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneCanvas.d.ts +0 -60
  37. package/dist/@mf-types/compiled-types/widgets/zone-editor/ZoneCanvas.d.ts.map +0 -1
  38. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-C4HmLg0z.mjs +0 -20
  39. package/dist/__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-DEuqbomC.mjs +0 -34
  40. package/dist/index-BuYTzV_S.mjs +0 -21513
  41. package/dist/index-CUXiTSWS.mjs +0 -13883
package/dist/_stub.js CHANGED
@@ -1,24 +1,23 @@
1
- import { _ as t, a as c, b as De } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-Cg6QsnjR.mjs";
2
- import { _ as Te } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-DoWbefqS.mjs";
3
- import { _ as xe, a as Oe, b as je, c as fe, d as he, e as We, f as me, g as ue, h as Be, i as ge, j as Me, k as qe, l as Ue, m as ee, n as te, o as ne, p as He, q as Ve, r as Ge, s as Ye, t as ze, u as Xe, v as Ke } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-DEuqbomC.mjs";
4
- import { a as Ie, b as pe, c as G, d as H, e as X, f as Se, g as se, h as T } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-0qpbQxoV.mjs";
5
- import { _ as Qe } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-C4HmLg0z.mjs";
6
- import { _ as V, a as Je, b as ae, c as ie, d as et, e as tt, f as le } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_2_konva__loadShare__.mjs-DSZIXeAx.mjs";
1
+ import { _ as t, a as i, b as J } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.mjs-Cg6QsnjR.mjs";
2
+ import { _ as T } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.mjs-DoWbefqS.mjs";
3
+ import { _ as Q, a as re, b as oe, c as B, d as U, e as ae, f as z, g as K, h as se, i as V, j as Y, k as ie, l as le, m as R, n as E, o as L, p as ce, q as de, r as ue, s as pe, t as me, u as fe, v as he, w as ge } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.mjs-Bau3YeQq.mjs";
4
+ import { a as ee, b as O, c as M, d as j, e as be, f as ye, g as w } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare__react__loadShare__.mjs-B9__gOco.mjs";
5
+ import { _ as xe } from "./__mfe_internal__addon_pipeline_orchestrator_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.mjs-C507UJJC.mjs";
7
6
  /**
8
7
  * @license lucide-react v0.511.0 - ISC
9
8
  *
10
9
  * This source code is licensed under the ISC license.
11
10
  * See the LICENSE file in the root directory of this source tree.
12
11
  */
13
- const nt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), rt = (e) => e.replace(
12
+ const _e = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ve = (e) => e.replace(
14
13
  /^([A-Z])|[\s-_]+(\w)/g,
15
- (i, r, u) => u ? u.toUpperCase() : r.toLowerCase()
16
- ), _e = (e) => {
17
- const i = rt(e);
18
- return i.charAt(0).toUpperCase() + i.slice(1);
19
- }, $e = (...e) => e.filter((i, r, u) => !!i && i.trim() !== "" && u.indexOf(i) === r).join(" ").trim(), ot = (e) => {
20
- for (const i in e)
21
- if (i.startsWith("aria-") || i === "role" || i === "title")
14
+ (o, n, d) => d ? d.toUpperCase() : n.toLowerCase()
15
+ ), W = (e) => {
16
+ const o = ve(e);
17
+ return o.charAt(0).toUpperCase() + o.slice(1);
18
+ }, te = (...e) => e.filter((o, n, d) => !!o && o.trim() !== "" && d.indexOf(o) === n).join(" ").trim(), ke = (e) => {
19
+ for (const o in e)
20
+ if (o.startsWith("aria-") || o === "role" || o === "title")
22
21
  return !0;
23
22
  };
24
23
  /**
@@ -27,7 +26,7 @@ const nt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), rt = (
27
26
  * This source code is licensed under the ISC license.
28
27
  * See the LICENSE file in the root directory of this source tree.
29
28
  */
30
- var st = {
29
+ var we = {
31
30
  xmlns: "http://www.w3.org/2000/svg",
32
31
  width: 24,
33
32
  height: 24,
@@ -44,31 +43,31 @@ var st = {
44
43
  * This source code is licensed under the ISC license.
45
44
  * See the LICENSE file in the root directory of this source tree.
46
45
  */
47
- const at = Ie(
46
+ const Ne = ee(
48
47
  ({
49
48
  color: e = "currentColor",
50
- size: i = 24,
51
- strokeWidth: r = 2,
52
- absoluteStrokeWidth: u,
49
+ size: o = 24,
50
+ strokeWidth: n = 2,
51
+ absoluteStrokeWidth: d,
53
52
  className: f = "",
54
53
  children: s,
55
- iconNode: l,
56
- ...a
57
- }, g) => pe(
54
+ iconNode: a,
55
+ ...r
56
+ }, h) => O(
58
57
  "svg",
59
58
  {
60
- ref: g,
61
- ...st,
62
- width: i,
63
- height: i,
59
+ ref: h,
60
+ ...we,
61
+ width: o,
62
+ height: o,
64
63
  stroke: e,
65
- strokeWidth: u ? Number(r) * 24 / Number(i) : r,
66
- className: $e("lucide", f),
67
- ...!s && !ot(a) && { "aria-hidden": "true" },
68
- ...a
64
+ strokeWidth: d ? Number(n) * 24 / Number(o) : n,
65
+ className: te("lucide", f),
66
+ ...!s && !ke(r) && { "aria-hidden": "true" },
67
+ ...r
69
68
  },
70
69
  [
71
- ...l.map(([n, F]) => pe(n, F)),
70
+ ...a.map(([l, v]) => O(l, v)),
72
71
  ...Array.isArray(s) ? s : [s]
73
72
  ]
74
73
  )
@@ -79,20 +78,20 @@ const at = Ie(
79
78
  * This source code is licensed under the ISC license.
80
79
  * See the LICENSE file in the root directory of this source tree.
81
80
  */
82
- const O = (e, i) => {
83
- const r = Ie(
84
- ({ className: u, ...f }, s) => pe(at, {
81
+ const k = (e, o) => {
82
+ const n = ee(
83
+ ({ className: d, ...f }, s) => O(Ne, {
85
84
  ref: s,
86
- iconNode: i,
87
- className: $e(
88
- `lucide-${nt(_e(e))}`,
85
+ iconNode: o,
86
+ className: te(
87
+ `lucide-${_e(W(e))}`,
89
88
  `lucide-${e}`,
90
- u
89
+ d
91
90
  ),
92
91
  ...f
93
92
  })
94
93
  );
95
- return r.displayName = _e(e), r;
94
+ return n.displayName = W(e), n;
96
95
  };
97
96
  /**
98
97
  * @license lucide-react v0.511.0 - ISC
@@ -100,7 +99,7 @@ const O = (e, i) => {
100
99
  * This source code is licensed under the ISC license.
101
100
  * See the LICENSE file in the root directory of this source tree.
102
101
  */
103
- const it = [
102
+ const Ce = [
104
103
  [
105
104
  "path",
106
105
  {
@@ -108,21 +107,21 @@ const it = [
108
107
  key: "169zse"
109
108
  }
110
109
  ]
111
- ], lt = O("activity", it);
110
+ ], De = k("activity", Ce);
112
111
  /**
113
112
  * @license lucide-react v0.511.0 - ISC
114
113
  *
115
114
  * This source code is licensed under the ISC license.
116
115
  * See the LICENSE file in the root directory of this source tree.
117
116
  */
118
- const ct = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], dt = O("check", ct);
117
+ const Se = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Me = k("check", Se);
119
118
  /**
120
119
  * @license lucide-react v0.511.0 - ISC
121
120
  *
122
121
  * This source code is licensed under the ISC license.
123
122
  * See the LICENSE file in the root directory of this source tree.
124
123
  */
125
- const ut = [
124
+ const $e = [
126
125
  ["path", { d: "M12 20v2", key: "1lh1kg" }],
127
126
  ["path", { d: "M12 2v2", key: "tus03m" }],
128
127
  ["path", { d: "M17 20v2", key: "1rnc9c" }],
@@ -137,14 +136,14 @@ const ut = [
137
136
  ["path", { d: "M7 2v2", key: "1i4yhu" }],
138
137
  ["rect", { x: "4", y: "4", width: "16", height: "16", rx: "2", key: "1vbyd7" }],
139
138
  ["rect", { x: "8", y: "8", width: "8", height: "8", rx: "1", key: "z9xiuo" }]
140
- ], pt = O("cpu", ut);
139
+ ], Ze = k("cpu", $e);
141
140
  /**
142
141
  * @license lucide-react v0.511.0 - ISC
143
142
  *
144
143
  * This source code is licensed under the ISC license.
145
144
  * See the LICENSE file in the root directory of this source tree.
146
145
  */
147
- const ft = [
146
+ const Ie = [
148
147
  [
149
148
  "path",
150
149
  {
@@ -153,24 +152,24 @@ const ft = [
153
152
  }
154
153
  ],
155
154
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
156
- ], ht = O("eye", ft);
155
+ ], Ae = k("eye", Ie);
157
156
  /**
158
157
  * @license lucide-react v0.511.0 - ISC
159
158
  *
160
159
  * This source code is licensed under the ISC license.
161
160
  * See the LICENSE file in the root directory of this source tree.
162
161
  */
163
- const mt = [
162
+ const Fe = [
164
163
  ["path", { d: "m12 14 4-4", key: "9kzdfg" }],
165
164
  ["path", { d: "M3.34 19a10 10 0 1 1 17.32 0", key: "19p75a" }]
166
- ], gt = O("gauge", mt);
165
+ ], Te = k("gauge", Fe);
167
166
  /**
168
167
  * @license lucide-react v0.511.0 - ISC
169
168
  *
170
169
  * This source code is licensed under the ISC license.
171
170
  * See the LICENSE file in the root directory of this source tree.
172
171
  */
173
- const bt = [
172
+ const Re = [
174
173
  [
175
174
  "path",
176
175
  {
@@ -178,31 +177,31 @@ const bt = [
178
177
  key: "yt0hxn"
179
178
  }
180
179
  ]
181
- ], yt = O("hexagon", bt);
180
+ ], Ee = k("hexagon", Re);
182
181
  /**
183
182
  * @license lucide-react v0.511.0 - ISC
184
183
  *
185
184
  * This source code is licensed under the ISC license.
186
185
  * See the LICENSE file in the root directory of this source tree.
187
186
  */
188
- const xt = [["path", { d: "M5 12h14", key: "1ays0h" }]], _t = O("minus", xt);
187
+ const Le = [["path", { d: "M5 12h14", key: "1ays0h" }]], je = k("minus", Le);
189
188
  /**
190
189
  * @license lucide-react v0.511.0 - ISC
191
190
  *
192
191
  * This source code is licensed under the ISC license.
193
192
  * See the LICENSE file in the root directory of this source tree.
194
193
  */
195
- const vt = [
194
+ const Pe = [
196
195
  ["path", { d: "M5 12h14", key: "1ays0h" }],
197
196
  ["path", { d: "M12 5v14", key: "s699le" }]
198
- ], kt = O("plus", vt);
197
+ ], qe = k("plus", Pe);
199
198
  /**
200
199
  * @license lucide-react v0.511.0 - ISC
201
200
  *
202
201
  * This source code is licensed under the ISC license.
203
202
  * See the LICENSE file in the root directory of this source tree.
204
203
  */
205
- const wt = [
204
+ const Ke = [
206
205
  [
207
206
  "path",
208
207
  {
@@ -212,107 +211,179 @@ const wt = [
212
211
  ],
213
212
  ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
214
213
  ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
215
- ], Nt = O("save", wt);
214
+ ], Oe = k("save", Ke);
216
215
  /**
217
216
  * @license lucide-react v0.511.0 - ISC
218
217
  *
219
218
  * This source code is licensed under the ISC license.
220
219
  * See the LICENSE file in the root directory of this source tree.
221
220
  */
222
- const Ct = [
221
+ const Be = [
223
222
  ["path", { d: "M3 6h18", key: "d0wm0j" }],
224
223
  ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
225
224
  ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
226
225
  ["line", { x1: "10", x2: "10", y1: "11", y2: "17", key: "1uufr5" }],
227
226
  ["line", { x1: "14", x2: "14", y1: "11", y2: "17", key: "xtxkd" }]
228
- ], be = O("trash-2", Ct);
227
+ ], H = k("trash-2", Be);
229
228
  /**
230
229
  * @license lucide-react v0.511.0 - ISC
231
230
  *
232
231
  * This source code is licensed under the ISC license.
233
232
  * See the LICENSE file in the root directory of this source tree.
234
233
  */
235
- const Dt = [
234
+ const Ue = [
235
+ [
236
+ "path",
237
+ {
238
+ d: "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",
239
+ key: "ftymec"
240
+ }
241
+ ],
242
+ ["rect", { x: "2", y: "6", width: "14", height: "12", rx: "2", key: "158x01" }]
243
+ ], ze = k("video", Ue);
244
+ /**
245
+ * @license lucide-react v0.511.0 - ISC
246
+ *
247
+ * This source code is licensed under the ISC license.
248
+ * See the LICENSE file in the root directory of this source tree.
249
+ */
250
+ const Ve = [
251
+ [
252
+ "path",
253
+ {
254
+ 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",
255
+ key: "uqj9uw"
256
+ }
257
+ ],
258
+ ["path", { d: "M16 9a5 5 0 0 1 0 6", key: "1q6k2b" }],
259
+ ["path", { d: "M19.364 18.364a9 9 0 0 0 0-12.728", key: "ijwkga" }]
260
+ ], He = k("volume-2", Ve);
261
+ /**
262
+ * @license lucide-react v0.511.0 - ISC
263
+ *
264
+ * This source code is licensed under the ISC license.
265
+ * See the LICENSE file in the root directory of this source tree.
266
+ */
267
+ const Qe = [
236
268
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
237
269
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
238
- ], Ze = O("x", Dt);
239
- function Mt(e) {
240
- return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "PipelineQuickStats requires a deviceId" }) : /* @__PURE__ */ t(It, { deviceId: e.deviceId });
270
+ ], ne = k("x", Qe);
271
+ function We(e) {
272
+ return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "PipelineQuickStats requires a deviceId" }) : /* @__PURE__ */ t(Ge, { deviceId: e.deviceId });
241
273
  }
242
- function It({ deviceId: e }) {
243
- xe(
274
+ function Ge({ deviceId: e }) {
275
+ Q(
244
276
  ["pipelineOrchestrator", "getPipelineAssignment"],
245
277
  ["pipeline.camera-assigned", "pipeline.camera-unassigned", "pipeline.camera-updated"]
246
- ), xe(
278
+ ), Q(
247
279
  ["pipelineRunner", "getCameraMetrics"],
248
280
  ["pipeline.camera-metrics-snapshot"]
249
281
  );
250
- const { data: i } = Oe(
282
+ const { data: o } = re(
251
283
  { deviceId: e },
252
284
  { staleTime: 3e4 }
253
- ), r = i?.agentNodeId ?? null, f = typeof r == "string" && r.length > 0 && !r.startsWith("addon:") ? r : void 0, { data: s } = je(
285
+ ), n = o?.agentNodeId ?? null, f = typeof n == "string" && n.length > 0 && !n.startsWith("addon:") ? n : void 0, { data: s } = oe(
254
286
  {
255
287
  deviceId: e,
256
288
  ...f ? { nodeId: f } : {}
257
289
  },
258
290
  { staleTime: 2e3, retry: !1 }
259
- ), l = fe(), a = he(l.trpcClient, e), { data: g } = Te({
291
+ ), a = B(), r = U(a.trpcClient, e), { data: h } = T({
260
292
  queryKey: ["device", e, "pipelineAnalytics.getActiveTracks"],
261
- queryFn: () => a?.pipelineAnalytics?.getActiveTracks({}) ?? [],
262
- enabled: !!a,
293
+ queryFn: () => r?.pipelineAnalytics?.getActiveTracks({}) ?? [],
294
+ enabled: !!r,
295
+ refetchInterval: 5e3,
296
+ retry: !1
297
+ }), { data: l } = T({
298
+ queryKey: ["device", e, "audioMetrics.getCurrentSnapshot"],
299
+ queryFn: () => r?.audioMetrics?.getCurrentSnapshot({}) ?? null,
300
+ enabled: !!r,
301
+ refetchInterval: 2e3,
302
+ retry: !1
303
+ }), { data: v } = T({
304
+ queryKey: ["recording.getStatus", e],
305
+ queryFn: async () => await a.trpcClient.recording.getStatus.query({ deviceId: e }),
263
306
  refetchInterval: 5e3,
264
307
  retry: !1
265
- }), n = s?.phase ?? null, F = s?.detectionMode ?? null, d = Number(s?.actualFps ?? 0), $ = Number(s?.configuredFps ?? 0), b = Number(s?.avgInferenceTimeMs ?? 0), k = Number(s?.queueDepth ?? 0), Z = Number(s?.droppedFrames ?? 0), L = We(n ?? "watching"), S = g?.length ?? 0;
266
- return /* @__PURE__ */ t("div", { className: "@container", style: { containerType: "inline-size" }, children: /* @__PURE__ */ c("div", { className: "grid grid-cols-1 @[360px]:grid-cols-2 @[720px]:grid-cols-4 gap-3", children: [
308
+ }), { data: C } = T({
309
+ queryKey: ["recording.getDeviceConfig", e],
310
+ queryFn: async () => await a.trpcClient.recording.getDeviceConfig.query({ deviceId: e }),
311
+ staleTime: 3e4,
312
+ retry: !1
313
+ }), N = s?.phase ?? null, D = s?.detectionMode ?? null, S = Number(s?.actualFps ?? 0), u = Number(s?.configuredFps ?? 0), y = Number(s?.avgInferenceTimeMs ?? 0), _ = Number(s?.queueDepth ?? 0), p = Number(s?.droppedFrames ?? 0), g = ae(N ?? "watching"), A = h?.length ?? 0, c = l?.level.dbfs ?? null, x = typeof c == "number" ? `${c.toFixed(1)} dBFS` : "—", b = v?.enabled ?? !1, m = v?.activeMode ?? "off", $ = b && m !== "off", P = b ? m === "off" ? "Idle" : m === "continuous" ? "Continuous" : m === "onMotion" ? "On motion" : m === "onAudioThreshold" ? "On audio" : m : "Disabled", Z = (C?.profiles ?? []).join(", "), F = v ? `${Xe(v.storageBytes ?? 0)}${Z ? ` · ${Z}` : ""}` : void 0;
314
+ return /* @__PURE__ */ i("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3", children: [
267
315
  /* @__PURE__ */ t(
268
- re,
316
+ I,
269
317
  {
270
- icon: lt,
318
+ icon: De,
271
319
  label: "Phase",
272
- value: L.label,
273
- color: L.textColor,
274
- subtext: F ?? void 0
320
+ value: g.label,
321
+ color: g.textColor,
322
+ subtext: D ?? void 0
275
323
  }
276
324
  ),
277
325
  /* @__PURE__ */ t(
278
- re,
326
+ I,
279
327
  {
280
- icon: gt,
328
+ icon: Te,
281
329
  label: "Detection FPS",
282
- value: `${d.toFixed(1)}`,
283
- subtext: $ > 0 ? `target: ${$}` : void 0
330
+ value: `${S.toFixed(1)}`,
331
+ subtext: u > 0 ? `target: ${u}` : void 0
284
332
  }
285
333
  ),
286
334
  /* @__PURE__ */ t(
287
- re,
335
+ I,
288
336
  {
289
- icon: pt,
337
+ icon: Ze,
290
338
  label: "Inference",
291
- value: `${b.toFixed(1)} ms`,
292
- subtext: k > 0 ? `queue: ${k}` : void 0
339
+ value: `${y.toFixed(1)} ms`,
340
+ subtext: _ > 0 ? `queue: ${_}` : void 0
293
341
  }
294
342
  ),
295
343
  /* @__PURE__ */ t(
296
- re,
344
+ I,
297
345
  {
298
- icon: ht,
346
+ icon: Ae,
299
347
  label: "Active Tracks",
300
- value: String(S),
301
- subtext: Z > 0 ? `dropped: ${Z}` : void 0
348
+ value: String(A),
349
+ subtext: p > 0 ? `dropped: ${p}` : void 0
350
+ }
351
+ ),
352
+ /* @__PURE__ */ t(
353
+ I,
354
+ {
355
+ icon: He,
356
+ label: "Current dB",
357
+ value: x
358
+ }
359
+ ),
360
+ /* @__PURE__ */ t(
361
+ I,
362
+ {
363
+ icon: ze,
364
+ label: "Recording",
365
+ value: P,
366
+ color: $ ? "text-success" : void 0,
367
+ subtext: F
302
368
  }
303
369
  )
304
- ] }) });
370
+ ] });
305
371
  }
306
- function re({ icon: e, label: i, value: r, subtext: u, color: f }) {
307
- return /* @__PURE__ */ c("div", { className: "rounded-lg border border-border bg-surface p-3 min-w-0", children: [
308
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 mb-1 min-w-0", children: [
372
+ function Xe(e) {
373
+ if (!Number.isFinite(e) || e <= 0) return "0 B";
374
+ const o = ["B", "KB", "MB", "GB", "TB"], n = Math.min(o.length - 1, Math.floor(Math.log(e) / Math.log(1024))), d = e / 1024 ** n;
375
+ return `${n === 0 ? Math.round(d) : d.toFixed(1)} ${o[n]}`;
376
+ }
377
+ function I({ icon: e, label: o, value: n, subtext: d, color: f }) {
378
+ return /* @__PURE__ */ i("div", { className: "rounded-lg border border-border bg-surface p-3 min-w-0", children: [
379
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 mb-1 min-w-0", children: [
309
380
  /* @__PURE__ */ t(e, { className: "h-3.5 w-3.5 text-foreground-subtle flex-shrink-0" }),
310
381
  /* @__PURE__ */ t(
311
382
  "span",
312
383
  {
313
384
  className: "text-[10px] text-foreground-subtle uppercase tracking-wider truncate",
314
- title: i,
315
- children: i
385
+ title: o,
386
+ children: o
316
387
  }
317
388
  )
318
389
  ] }),
@@ -320,43 +391,43 @@ function re({ icon: e, label: i, value: r, subtext: u, color: f }) {
320
391
  "p",
321
392
  {
322
393
  className: `text-lg font-semibold leading-tight truncate ${f ?? "text-foreground"}`,
323
- title: r,
324
- children: r
394
+ title: n,
395
+ children: n
325
396
  }
326
397
  ),
327
- u && /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle mt-0.5 truncate", title: u, children: u })
398
+ d && /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle mt-0.5 truncate", title: d, children: d })
328
399
  ] });
329
400
  }
330
- const St = {
401
+ const Je = {
331
402
  polygon: "Polygon",
332
403
  tripwire: "Tripwire"
333
- }, $t = {
404
+ }, Ye = {
334
405
  polygon: "bg-info/10 text-info",
335
406
  tripwire: "bg-warning/10 text-warning"
336
407
  };
337
- function Zt({
408
+ function et({
338
409
  zones: e,
339
- selectedZoneId: i,
340
- drawingKind: r,
341
- onSelectZone: u,
410
+ selectedZoneId: o,
411
+ drawingKind: n,
412
+ onSelectZone: d,
342
413
  onDeleteZone: f,
343
414
  onStartDraw: s,
344
- onCancelDraw: l
415
+ onCancelDraw: a
345
416
  }) {
346
- return /* @__PURE__ */ c("div", { className: "flex flex-col gap-2", children: [
347
- /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: r ? /* @__PURE__ */ c(
417
+ return /* @__PURE__ */ i("div", { className: "flex flex-col gap-2", children: [
418
+ /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: n ? /* @__PURE__ */ i(
348
419
  "button",
349
420
  {
350
421
  type: "button",
351
- onClick: l,
422
+ onClick: a,
352
423
  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",
353
424
  title: "Cancel drawing",
354
425
  children: [
355
- /* @__PURE__ */ t(Ze, { className: "h-3.5 w-3.5" }),
426
+ /* @__PURE__ */ t(ne, { className: "h-3.5 w-3.5" }),
356
427
  /* @__PURE__ */ t("span", { children: "Cancel" })
357
428
  ]
358
429
  }
359
- ) : /* @__PURE__ */ c(De, { children: [
430
+ ) : /* @__PURE__ */ i(J, { children: [
360
431
  /* @__PURE__ */ t(
361
432
  "button",
362
433
  {
@@ -365,7 +436,7 @@ function Zt({
365
436
  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",
366
437
  title: "Add polygon zone",
367
438
  "aria-label": "Add polygon zone",
368
- children: /* @__PURE__ */ t(yt, { className: "h-4 w-4" })
439
+ children: /* @__PURE__ */ t(Ee, { className: "h-4 w-4" })
369
440
  }
370
441
  ),
371
442
  /* @__PURE__ */ t(
@@ -376,34 +447,34 @@ function Zt({
376
447
  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",
377
448
  title: "Add tripwire",
378
449
  "aria-label": "Add tripwire",
379
- children: /* @__PURE__ */ t(_t, { className: "h-5 w-5 stroke-[2.5]" })
450
+ children: /* @__PURE__ */ t(je, { className: "h-5 w-5 stroke-[2.5]" })
380
451
  }
381
452
  )
382
453
  ] }) }),
383
- e.length === 0 ? /* @__PURE__ */ t("p", { className: "text-center text-[10px] text-foreground-subtle py-3 leading-tight", children: 'No zones yet — pick "Zone" or "Tripwire" to draw.' }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1", children: e.map((a) => {
384
- const g = a.id === i;
385
- return /* @__PURE__ */ c(
454
+ e.length === 0 ? /* @__PURE__ */ t("p", { className: "text-center text-[10px] text-foreground-subtle py-3 leading-tight", children: 'No zones yet — pick "Zone" or "Tripwire" to draw.' }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1", children: e.map((r) => {
455
+ const h = r.id === o;
456
+ return /* @__PURE__ */ i(
386
457
  "div",
387
458
  {
388
459
  className: [
389
460
  "flex items-center gap-1.5 rounded border px-1.5 py-1 cursor-pointer transition-colors",
390
- g ? "border-primary/50 bg-primary/10" : "border-border bg-surface hover:bg-surface-hover"
461
+ h ? "border-primary/50 bg-primary/10" : "border-border bg-surface hover:bg-surface-hover"
391
462
  ].join(" "),
392
- onClick: () => u(g ? null : a.id),
463
+ onClick: () => d(h ? null : r.id),
393
464
  children: [
394
465
  /* @__PURE__ */ t(
395
466
  "div",
396
467
  {
397
468
  className: "h-2.5 w-2.5 rounded-sm flex-shrink-0",
398
- style: { backgroundColor: a.color }
469
+ style: { backgroundColor: r.color }
399
470
  }
400
471
  ),
401
- /* @__PURE__ */ t("span", { className: "flex-1 truncate text-[11px] font-medium text-foreground", children: a.name }),
472
+ /* @__PURE__ */ t("span", { className: "flex-1 truncate text-[11px] font-medium text-foreground", children: r.name }),
402
473
  /* @__PURE__ */ t(
403
474
  "span",
404
475
  {
405
- className: `inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium flex-shrink-0 ${$t[a.kind]}`,
406
- children: St[a.kind]
476
+ className: `inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium flex-shrink-0 ${Ye[r.kind]}`,
477
+ children: Je[r.kind]
407
478
  }
408
479
  ),
409
480
  /* @__PURE__ */ t(
@@ -412,20 +483,20 @@ function Zt({
412
483
  type: "button",
413
484
  title: "Delete zone",
414
485
  className: "p-0.5 text-foreground-subtle hover:text-danger rounded transition-colors flex-shrink-0",
415
- onClick: (n) => {
416
- n.stopPropagation(), f(a.id);
486
+ onClick: (l) => {
487
+ l.stopPropagation(), f(r.id);
417
488
  },
418
- children: /* @__PURE__ */ t(be, { className: "h-3 w-3" })
489
+ children: /* @__PURE__ */ t(H, { className: "h-3 w-3" })
419
490
  }
420
491
  )
421
492
  ]
422
493
  },
423
- a.id
494
+ r.id
424
495
  );
425
496
  }) })
426
497
  ] });
427
498
  }
428
- const At = [
499
+ const tt = [
429
500
  "#3b82f6",
430
501
  // blue
431
502
  "#10b981",
@@ -443,10 +514,10 @@ const At = [
443
514
  "#ec4899"
444
515
  // pink
445
516
  ];
446
- function Ft({ zone: e, onSave: i, onDiscard: r, onDelete: u }) {
447
- const f = me(), s = (a) => f?.updateDraft({ name: a }), l = (a) => f?.updateDraft({ color: a });
448
- return /* @__PURE__ */ c("div", { className: "flex flex-col gap-2", children: [
449
- /* @__PURE__ */ c("div", { className: "flex items-center justify-between", children: [
517
+ function nt({ zone: e, onSave: o, onDiscard: n, onDelete: d }) {
518
+ const f = z(), s = (r) => f?.updateDraft({ name: r }), a = (r) => f?.updateDraft({ color: r });
519
+ return /* @__PURE__ */ i("div", { className: "flex flex-col gap-2", children: [
520
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
450
521
  /* @__PURE__ */ t("h3", { className: "text-[10px] font-semibold text-foreground-subtle uppercase tracking-wider", children: "Editing" }),
451
522
  /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-full px-1.5 py-0.5 text-[9px] font-medium bg-surface border border-border text-foreground-subtle", children: e.kind === "tripwire" ? "Tripwire" : "Polygon" })
452
523
  ] }),
@@ -454,101 +525,101 @@ function Ft({ zone: e, onSave: i, onDiscard: r, onDelete: u }) {
454
525
  "input",
455
526
  {
456
527
  type: "text",
457
- className: ue,
528
+ className: K,
458
529
  value: e.name,
459
530
  autoFocus: !0,
460
- onChange: (a) => s(a.target.value),
461
- onKeyDown: (a) => {
462
- a.key === "Enter" ? (a.preventDefault(), i()) : a.key === "Escape" && (a.preventDefault(), r());
531
+ onChange: (r) => s(r.target.value),
532
+ onKeyDown: (r) => {
533
+ r.key === "Enter" ? (r.preventDefault(), o()) : r.key === "Escape" && (r.preventDefault(), n());
463
534
  },
464
535
  placeholder: "Zone name"
465
536
  }
466
537
  ),
467
- /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: At.map((a) => /* @__PURE__ */ t(
538
+ /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: tt.map((r) => /* @__PURE__ */ t(
468
539
  "button",
469
540
  {
470
541
  type: "button",
471
- title: a,
542
+ title: r,
472
543
  className: [
473
544
  "h-4 w-4 rounded border-2 cursor-pointer transition-transform hover:scale-110",
474
- e.color === a ? "border-white scale-110" : "border-transparent"
545
+ e.color === r ? "border-white scale-110" : "border-transparent"
475
546
  ].join(" "),
476
- style: { backgroundColor: a },
477
- onClick: () => l(a)
547
+ style: { backgroundColor: r },
548
+ onClick: () => a(r)
478
549
  },
479
- a
550
+ r
480
551
  )) }),
481
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5", children: [
552
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
482
553
  /* @__PURE__ */ t(
483
554
  "input",
484
555
  {
485
556
  type: "color",
486
557
  className: "h-6 w-6 rounded border border-border bg-background cursor-pointer p-0.5",
487
558
  value: e.color,
488
- onChange: (a) => l(a.target.value)
559
+ onChange: (r) => a(r.target.value)
489
560
  }
490
561
  ),
491
562
  /* @__PURE__ */ t(
492
563
  "input",
493
564
  {
494
565
  type: "text",
495
- className: `${ue} font-mono`,
566
+ className: `${K} font-mono`,
496
567
  value: e.color,
497
568
  placeholder: "#000000",
498
- onChange: (a) => l(a.target.value)
569
+ onChange: (r) => a(r.target.value)
499
570
  }
500
571
  )
501
572
  ] }),
502
- /* @__PURE__ */ c("p", { className: "text-[9px] text-foreground-subtle leading-tight", children: [
573
+ /* @__PURE__ */ i("p", { className: "text-[9px] text-foreground-subtle leading-tight", children: [
503
574
  e.kind === "tripwire" ? "2 points" : `${e.points.length} pts`,
504
575
  e.points.length > 0 && " · drag handles to reshape"
505
576
  ] }),
506
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5", children: [
507
- /* @__PURE__ */ c(
577
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5", children: [
578
+ /* @__PURE__ */ i(
508
579
  "button",
509
580
  {
510
581
  type: "button",
511
- onClick: i,
582
+ onClick: o,
512
583
  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",
513
584
  title: "Save changes (Enter)",
514
585
  children: [
515
- /* @__PURE__ */ t(dt, { className: "h-3 w-3" }),
586
+ /* @__PURE__ */ t(Me, { className: "h-3 w-3" }),
516
587
  "Save"
517
588
  ]
518
589
  }
519
590
  ),
520
- /* @__PURE__ */ c(
591
+ /* @__PURE__ */ i(
521
592
  "button",
522
593
  {
523
594
  type: "button",
524
- onClick: r,
595
+ onClick: n,
525
596
  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",
526
597
  title: "Discard changes (Esc)",
527
598
  children: [
528
- /* @__PURE__ */ t(Ze, { className: "h-3 w-3" }),
599
+ /* @__PURE__ */ t(ne, { className: "h-3 w-3" }),
529
600
  "Discard"
530
601
  ]
531
602
  }
532
603
  )
533
604
  ] }),
534
- /* @__PURE__ */ c(
605
+ /* @__PURE__ */ i(
535
606
  "button",
536
607
  {
537
608
  type: "button",
538
- onClick: u,
539
- className: `${Be} w-full`,
609
+ onClick: d,
610
+ className: `${se} w-full`,
540
611
  children: [
541
- /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
612
+ /* @__PURE__ */ t(H, { className: "h-3 w-3" }),
542
613
  "Delete"
543
614
  ]
544
615
  }
545
616
  )
546
617
  ] });
547
618
  }
548
- const Lt = Qe.map(
619
+ const rt = xe.map(
549
620
  (e) => ({ id: e.id, label: e.name })
550
621
  );
551
- function Et(e) {
622
+ function ot(e) {
552
623
  return {
553
624
  id: e.id,
554
625
  name: e.name ?? "",
@@ -558,127 +629,127 @@ function Et(e) {
558
629
  enabled: e.enabled !== !1
559
630
  };
560
631
  }
561
- function Pt(e) {
562
- const i = {
632
+ function at(e) {
633
+ const o = {
563
634
  id: e.id,
564
635
  zoneIds: e.zoneIds,
565
636
  mode: e.mode,
566
637
  enabled: e.enabled
567
638
  };
568
- return e.name && (i.name = e.name), e.classFilter.length > 0 && (i.classFilter = e.classFilter), i;
639
+ return e.name && (o.name = e.name), e.classFilter.length > 0 && (o.classFilter = e.classFilter), o;
569
640
  }
570
- function ve({ dev: e, stage: i, zones: r, title: u }) {
571
- const f = ge(e?.state.zoneRules), s = G(
572
- () => f?.[i] ?? [],
573
- [f, i]
574
- ), [l, a] = H([]), [g, n] = H(!1), [F, d] = H(!1), [$, b] = H(null);
575
- X(() => {
576
- g || a(s.map(Et));
577
- }, [s, g]);
578
- const k = () => {
579
- a((m) => [
580
- ...m,
641
+ function G({ dev: e, stage: o, zones: n, title: d }) {
642
+ const f = V(e?.state.zoneRules), s = M(
643
+ () => f?.[o] ?? [],
644
+ [f, o]
645
+ ), [a, r] = j([]), [h, l] = j(!1), [v, C] = j(!1), [N, D] = j(null);
646
+ be(() => {
647
+ h || r(s.map(ot));
648
+ }, [s, h]);
649
+ const S = () => {
650
+ r((c) => [
651
+ ...c,
581
652
  {
582
653
  id: crypto.randomUUID(),
583
654
  name: "",
584
- zoneIds: r[0] ? [r[0].id] : [],
655
+ zoneIds: n[0] ? [n[0].id] : [],
585
656
  mode: "exclude",
586
657
  classFilter: [],
587
658
  enabled: !0
588
659
  }
589
- ]), n(!0);
590
- }, Z = (m, _) => {
591
- a(
592
- (w) => w.map((N, B) => {
593
- if (B !== m) return N;
594
- const o = N.classFilter.includes(_) ? N.classFilter.filter((p) => p !== _) : [...N.classFilter, _];
595
- return { ...N, classFilter: o };
660
+ ]), l(!0);
661
+ }, u = (c, x) => {
662
+ r(
663
+ (b) => b.map((m, $) => {
664
+ if ($ !== c) return m;
665
+ const Z = m.classFilter.includes(x) ? m.classFilter.filter((F) => F !== x) : [...m.classFilter, x];
666
+ return { ...m, classFilter: Z };
596
667
  })
597
- ), n(!0);
598
- }, L = (m, _) => {
599
- a(
600
- (w) => w.map((N, B) => {
601
- if (B !== m) return N;
602
- const o = N.zoneIds.includes(_) ? N.zoneIds.filter((p) => p !== _) : [...N.zoneIds, _];
603
- return { ...N, zoneIds: o };
668
+ ), l(!0);
669
+ }, y = (c, x) => {
670
+ r(
671
+ (b) => b.map((m, $) => {
672
+ if ($ !== c) return m;
673
+ const Z = m.zoneIds.includes(x) ? m.zoneIds.filter((F) => F !== x) : [...m.zoneIds, x];
674
+ return { ...m, zoneIds: Z };
604
675
  })
605
- ), n(!0);
606
- }, S = (m) => {
607
- a((_) => _.filter((w, N) => N !== m)), n(!0);
608
- }, y = (m, _) => {
609
- a((w) => w.map((N, B) => B === m ? { ...N, ..._ } : N)), n(!0);
610
- }, h = async () => {
676
+ ), l(!0);
677
+ }, _ = (c) => {
678
+ r((x) => x.filter((b, m) => m !== c)), l(!0);
679
+ }, p = (c, x) => {
680
+ r((b) => b.map((m, $) => $ === c ? { ...m, ...x } : m)), l(!0);
681
+ }, g = async () => {
611
682
  if (e?.zoneRules) {
612
- d(!0), b(null);
683
+ C(!0), D(null);
613
684
  try {
614
- await e.zoneRules.setRules({ stage: i, rules: l.map(Pt) }), n(!1);
615
- } catch (m) {
616
- b(m instanceof Error ? m.message : String(m));
685
+ await e.zoneRules.setRules({ stage: o, rules: a.map(at) }), l(!1);
686
+ } catch (c) {
687
+ D(c instanceof Error ? c.message : String(c));
617
688
  } finally {
618
- d(!1);
689
+ C(!1);
619
690
  }
620
691
  }
621
- }, Y = g && !!e?.zoneRules && !F;
622
- return /* @__PURE__ */ c("div", { className: "rounded-md border border-border bg-surface/40 p-2.5", children: [
623
- /* @__PURE__ */ c("div", { className: "flex items-center justify-between mb-2 gap-2", children: [
624
- /* @__PURE__ */ t("h3", { className: `${Me} truncate`, children: u ?? `${i === "motion" ? "Motion" : "Detection"} Rules` }),
625
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
626
- /* @__PURE__ */ c(
692
+ }, A = h && !!e?.zoneRules && !v;
693
+ return /* @__PURE__ */ i("div", { className: "rounded-md border border-border bg-surface/40 p-2.5", children: [
694
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-2 gap-2", children: [
695
+ /* @__PURE__ */ t("h3", { className: `${Y} truncate`, children: d ?? `${o === "motion" ? "Motion" : "Detection"} Rules` }),
696
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1 flex-shrink-0", children: [
697
+ /* @__PURE__ */ i(
627
698
  "button",
628
699
  {
629
700
  type: "button",
630
- onClick: k,
631
- disabled: r.length === 0 || !e,
632
- className: qe,
701
+ onClick: S,
702
+ disabled: n.length === 0 || !e,
703
+ className: ie,
633
704
  title: "Add rule",
634
705
  children: [
635
- /* @__PURE__ */ t(kt, { className: "h-2.5 w-2.5" }),
706
+ /* @__PURE__ */ t(qe, { className: "h-2.5 w-2.5" }),
636
707
  " Add"
637
708
  ]
638
709
  }
639
710
  ),
640
- /* @__PURE__ */ c(
711
+ /* @__PURE__ */ i(
641
712
  "button",
642
713
  {
643
714
  type: "button",
644
715
  onClick: () => {
645
- h();
716
+ g();
646
717
  },
647
- disabled: !Y,
648
- className: Ue,
718
+ disabled: !A,
719
+ className: le,
649
720
  children: [
650
- /* @__PURE__ */ t(Nt, { className: "h-2.5 w-2.5" }),
651
- F ? "…" : "Save"
721
+ /* @__PURE__ */ t(Oe, { className: "h-2.5 w-2.5" }),
722
+ v ? "…" : "Save"
652
723
  ]
653
724
  }
654
725
  )
655
726
  ] })
656
727
  ] }),
657
- l.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle italic px-1 py-1.5 leading-tight", children: r.length === 0 ? "Define a zone first — rules reference zone ids." : "No rules — every detection at this stage passes through." }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1.5", children: l.map((m, _) => /* @__PURE__ */ c(
728
+ a.length === 0 ? /* @__PURE__ */ t("p", { className: "text-[10px] text-foreground-subtle italic px-1 py-1.5 leading-tight", children: n.length === 0 ? "Define a zone first — rules reference zone ids." : "No rules — every detection at this stage passes through." }) : /* @__PURE__ */ t("div", { className: "flex flex-col gap-1.5", children: a.map((c, x) => /* @__PURE__ */ i(
658
729
  "div",
659
730
  {
660
731
  className: "rounded border border-border/50 bg-background/40 px-2 py-1.5 flex flex-col gap-1.5 overflow-hidden",
661
732
  children: [
662
- /* @__PURE__ */ c("div", { className: "grid grid-cols-[auto_1fr_auto] items-center gap-1.5", children: [
733
+ /* @__PURE__ */ i("div", { className: "grid grid-cols-[auto_1fr_auto] items-center gap-1.5", children: [
663
734
  /* @__PURE__ */ t(
664
735
  "button",
665
736
  {
666
737
  type: "button",
667
738
  role: "switch",
668
- "aria-checked": m.enabled,
669
- "aria-label": m.enabled ? "Disable rule" : "Enable rule",
670
- title: m.enabled ? "Rule is active — click to disable" : "Rule is disabled — click to enable",
671
- onClick: () => y(_, { enabled: !m.enabled }),
739
+ "aria-checked": c.enabled,
740
+ "aria-label": c.enabled ? "Disable rule" : "Enable rule",
741
+ title: c.enabled ? "Rule is active — click to disable" : "Rule is disabled — click to enable",
742
+ onClick: () => p(x, { enabled: !c.enabled }),
672
743
  className: [
673
744
  "inline-flex items-center justify-center h-5 w-9 rounded-full border transition-colors flex-shrink-0",
674
- m.enabled ? "border-primary/50 bg-primary/20 text-primary" : "border-border bg-surface text-foreground-subtle"
745
+ c.enabled ? "border-primary/50 bg-primary/20 text-primary" : "border-border bg-surface text-foreground-subtle"
675
746
  ].join(" "),
676
747
  children: /* @__PURE__ */ t(
677
748
  "span",
678
749
  {
679
750
  className: [
680
751
  "h-3 w-3 rounded-full transition-transform",
681
- m.enabled ? "translate-x-1.5 bg-primary" : "-translate-x-1.5 bg-foreground-subtle"
752
+ c.enabled ? "translate-x-1.5 bg-primary" : "-translate-x-1.5 bg-foreground-subtle"
682
753
  ].join(" ")
683
754
  }
684
755
  )
@@ -687,10 +758,10 @@ function ve({ dev: e, stage: i, zones: r, title: u }) {
687
758
  /* @__PURE__ */ t(
688
759
  "input",
689
760
  {
690
- className: `${ue} min-w-0`,
761
+ className: `${K} min-w-0`,
691
762
  placeholder: "Rule name (optional)",
692
- value: m.name,
693
- onChange: (w) => y(_, { name: w.target.value })
763
+ value: c.name,
764
+ onChange: (b) => p(x, { name: b.target.value })
694
765
  }
695
766
  ),
696
767
  /* @__PURE__ */ t(
@@ -699,20 +770,20 @@ function ve({ dev: e, stage: i, zones: r, title: u }) {
699
770
  type: "button",
700
771
  title: "Remove rule",
701
772
  "aria-label": "Remove rule",
702
- onClick: () => S(_),
773
+ onClick: () => _(x),
703
774
  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",
704
- children: /* @__PURE__ */ t(be, { className: "h-3.5 w-3.5" })
775
+ children: /* @__PURE__ */ t(H, { className: "h-3.5 w-3.5" })
705
776
  }
706
777
  )
707
778
  ] }),
708
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
779
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
709
780
  /* @__PURE__ */ t("span", { className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0", children: "Mode" }),
710
781
  /* @__PURE__ */ t(
711
782
  "button",
712
783
  {
713
784
  type: "button",
714
- onClick: () => y(_, { mode: "include" }),
715
- className: `${ee} ${m.mode === "include" ? te : ne}`,
785
+ onClick: () => p(x, { mode: "include" }),
786
+ className: `${R} ${c.mode === "include" ? E : L}`,
716
787
  children: "Include"
717
788
  }
718
789
  ),
@@ -720,451 +791,72 @@ function ve({ dev: e, stage: i, zones: r, title: u }) {
720
791
  "button",
721
792
  {
722
793
  type: "button",
723
- onClick: () => y(_, { mode: "exclude" }),
724
- className: `${ee} ${m.mode === "exclude" ? te : ne}`,
794
+ onClick: () => p(x, { mode: "exclude" }),
795
+ className: `${R} ${c.mode === "exclude" ? E : L}`,
725
796
  children: "Exclude"
726
797
  }
727
798
  )
728
799
  ] }),
729
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
800
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
730
801
  /* @__PURE__ */ t("span", { className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0", children: "Zones" }),
731
- r.length === 0 ? /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic", children: "none" }) : r.map((w) => {
732
- const N = m.zoneIds.includes(w.id);
733
- return /* @__PURE__ */ c(
802
+ n.length === 0 ? /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic", children: "none" }) : n.map((b) => {
803
+ const m = c.zoneIds.includes(b.id);
804
+ return /* @__PURE__ */ i(
734
805
  "button",
735
806
  {
736
807
  type: "button",
737
- onClick: () => L(_, w.id),
738
- className: `${ee} ${N ? te : ne}`,
808
+ onClick: () => y(x, b.id),
809
+ className: `${R} ${m ? E : L}`,
739
810
  children: [
740
811
  /* @__PURE__ */ t(
741
812
  "span",
742
813
  {
743
814
  className: "h-2 w-2 rounded-sm",
744
- style: { backgroundColor: w.color || "#3b82f6" }
815
+ style: { backgroundColor: b.color || "#3b82f6" }
745
816
  }
746
817
  ),
747
- /* @__PURE__ */ t("span", { className: "truncate max-w-[7rem]", children: w.name || w.id })
818
+ /* @__PURE__ */ t("span", { className: "truncate max-w-[7rem]", children: b.name || b.id })
748
819
  ]
749
820
  },
750
- w.id
821
+ b.id
751
822
  );
752
823
  })
753
824
  ] }),
754
- /* @__PURE__ */ c("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
825
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1.5 flex-wrap", children: [
755
826
  /* @__PURE__ */ t("span", { className: "text-[9px] uppercase tracking-wider text-foreground-subtle w-12 sm:w-14 flex-shrink-0", children: "Class" }),
756
- Lt.map((w) => {
757
- const N = m.classFilter.includes(w.id);
827
+ rt.map((b) => {
828
+ const m = c.classFilter.includes(b.id);
758
829
  return /* @__PURE__ */ t(
759
830
  "button",
760
831
  {
761
832
  type: "button",
762
- onClick: () => Z(_, w.id),
763
- className: `${ee} ${N ? te : ne}`,
764
- children: w.label
833
+ onClick: () => u(x, b.id),
834
+ className: `${R} ${m ? E : L}`,
835
+ children: b.label
765
836
  },
766
- w.id
837
+ b.id
767
838
  );
768
839
  }),
769
- m.classFilter.length === 0 && /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic ml-1", children: "any" })
840
+ c.classFilter.length === 0 && /* @__PURE__ */ t("span", { className: "text-[10px] text-foreground-subtle italic ml-1", children: "any" })
770
841
  ] })
771
842
  ]
772
843
  },
773
- m.id
844
+ c.id
774
845
  )) }),
775
- $ && /* @__PURE__ */ t("p", { className: "mt-2 text-[10px] text-danger", children: $ })
846
+ N && /* @__PURE__ */ t("p", { className: "mt-2 text-[10px] text-danger", children: N })
776
847
  ] });
777
848
  }
778
- function z(e, i, r) {
779
- return { x: e.x * i, y: e.y * r };
780
- }
781
- function ce(e, i, r) {
782
- return { x: e.x / i, y: e.y / r };
849
+ function st(e) {
850
+ const o = e.kind === "tripwire" ? { kind: "line", points: e.points } : { kind: "polygon", points: e.points };
851
+ return { id: e.id, label: e.name, color: e.color, shape: o };
783
852
  }
784
- function ke(e, i, r) {
785
- return e.flatMap((u) => [u.x * i, u.y * r]);
853
+ function it(e) {
854
+ return e === "line" ? "tripwire" : "polygon";
786
855
  }
787
- function Rt(e, i) {
788
- return e.color;
856
+ function lt(e) {
857
+ return e === "tripwire" ? "line" : "polygon";
789
858
  }
790
- const Tt = "33", Ot = "66", we = 16, Ne = 9;
791
- function jt({
792
- zones: e,
793
- selectedZoneId: i,
794
- onSelectZone: r,
795
- onZonePointsChange: u,
796
- onZoneComplete: f,
797
- drawingKind: s,
798
- backdrop: l,
799
- transparent: a = !1
800
- }) {
801
- const g = se(null), [n, F] = H({ w: 800, h: 450 }), [d, $] = H([]), [b, k] = H(null), [Z, L] = H(null), [S, y] = H(null);
802
- X(() => {
803
- if (!S) return;
804
- const o = e.find((v) => v.id === S.zoneId);
805
- if (!o) {
806
- y(null);
807
- return;
808
- }
809
- if (o.points.length !== S.points.length) return;
810
- o.points.every((v, x) => {
811
- const E = S.points[x];
812
- return Math.abs(v.x - E.x) < 1e-6 && Math.abs(v.y - E.y) < 1e-6;
813
- }) && y(null);
814
- }, [e, S]), X(() => {
815
- const o = g.current;
816
- if (!o) return;
817
- const p = new ResizeObserver((v) => {
818
- const x = v[0];
819
- if (x) {
820
- const { width: E, height: P } = x.contentRect;
821
- F(a ? { w: E, h: P } : { w: E, h: E * 9 / 16 });
822
- }
823
- });
824
- return p.observe(o), () => p.disconnect();
825
- }, [a]);
826
- const h = s !== null;
827
- X(() => {
828
- !h && b !== null && k(null);
829
- }, [h, b]);
830
- const Y = T(
831
- (o) => {
832
- if (!h) {
833
- r(null);
834
- return;
835
- }
836
- const p = o.target.getStage();
837
- if (!p) return;
838
- const v = p.getPointerPosition();
839
- if (!v) return;
840
- const x = ce(v, n.w, n.h), E = s === "tripwire";
841
- if (d.length === 0) {
842
- $([x]);
843
- return;
844
- }
845
- if (E && d.length === 1) {
846
- const P = [...d, x], q = {
847
- id: crypto.randomUUID(),
848
- name: "Tripwire",
849
- kind: "tripwire",
850
- color: "#f59e0b",
851
- points: P
852
- };
853
- f(q), $([]);
854
- return;
855
- }
856
- if (d.length >= 3 && !E) {
857
- const P = z(d[0], n.w, n.h);
858
- if (Math.hypot(v.x - P.x, v.y - P.y) < 12) {
859
- const K = {
860
- id: crypto.randomUUID(),
861
- name: "Zone",
862
- kind: "polygon",
863
- color: "#3b82f6",
864
- points: d
865
- };
866
- f(K), $([]);
867
- return;
868
- }
869
- }
870
- $((P) => [...P, x]);
871
- },
872
- [h, d, n, s, f, r]
873
- ), m = T(
874
- (o) => {
875
- if (!h || s === "tripwire" || d.length < 3) return;
876
- o.cancelBubble = !0;
877
- const p = {
878
- id: crypto.randomUUID(),
879
- name: "Zone",
880
- kind: "polygon",
881
- color: "#3b82f6",
882
- points: d
883
- };
884
- f(p), $([]);
885
- },
886
- [h, s, d, f]
887
- ), _ = se(null), w = se(null);
888
- X(() => () => {
889
- _.current !== null && cancelAnimationFrame(_.current);
890
- }, []);
891
- const N = T(
892
- (o) => {
893
- if (!h) return;
894
- const p = o.target.getStage();
895
- if (!p) return;
896
- const v = p.getPointerPosition();
897
- w.current = v ?? null, _.current === null && (_.current = requestAnimationFrame(() => {
898
- _.current = null, k(w.current);
899
- }));
900
- },
901
- [h]
902
- ), B = [];
903
- if (!a) {
904
- for (let o = 1; o < we; o++) {
905
- const p = n.w / we * o;
906
- B.push(
907
- /* @__PURE__ */ t(V, { points: [p, 0, p, n.h], stroke: "#ffffff", strokeWidth: 0.5, opacity: 0.08 }, `gv-${o}`)
908
- );
909
- }
910
- for (let o = 1; o < Ne; o++) {
911
- const p = n.h / Ne * o;
912
- B.push(
913
- /* @__PURE__ */ t(V, { points: [0, p, n.w, p], stroke: "#ffffff", strokeWidth: 0.5, opacity: 0.08 }, `gh-${o}`)
914
- );
915
- }
916
- }
917
- return /* @__PURE__ */ c(
918
- "div",
919
- {
920
- ref: g,
921
- className: a ? "absolute inset-0" : "relative w-full bg-zinc-900 rounded-lg overflow-hidden",
922
- style: { cursor: h ? "crosshair" : "default" },
923
- children: [
924
- l && !a ? /* @__PURE__ */ t(
925
- "div",
926
- {
927
- className: "absolute inset-0 pointer-events-none [&>*]:w-full [&>*]:h-full [&>img]:object-cover [&>video]:object-cover",
928
- style: { width: n.w, height: n.h },
929
- children: l
930
- }
931
- ) : null,
932
- /* @__PURE__ */ c(
933
- Je,
934
- {
935
- width: n.w,
936
- height: n.h,
937
- onClick: Y,
938
- onDblClick: m,
939
- onMouseMove: N,
940
- children: [
941
- /* @__PURE__ */ c(ae, { listening: !1, children: [
942
- /* @__PURE__ */ t(V, { points: [0, 0, n.w, 0, n.w, n.h, 0, n.h, 0, 0], stroke: "transparent", strokeWidth: 0 }),
943
- B
944
- ] }),
945
- /* @__PURE__ */ t(ae, { children: e.map((o) => {
946
- const p = o.id === i, v = Rt(o), x = S && S.zoneId === o.id ? S.points : o.points, E = ke(x, n.w, n.h), P = o.kind === "tripwire", q = p && !h, K = Z === o.id, Q = x.map((C) => C.x * n.w), J = x.map((C) => C.y * n.h), Ae = Q.length > 0 ? Math.min(...Q) : 0, Fe = Q.length > 0 ? Math.max(...Q) : 0, Le = J.length > 0 ? Math.min(...J) : 0, Ee = J.length > 0 ? Math.max(...J) : 0;
947
- return /* @__PURE__ */ c(
948
- ie,
949
- {
950
- onClick: (C) => {
951
- C.cancelBubble = !0, h || r(o.id);
952
- },
953
- children: [
954
- /* @__PURE__ */ c(
955
- ie,
956
- {
957
- draggable: q,
958
- dragBoundFunc: q ? (C) => ({
959
- x: Math.max(-Ae, Math.min(n.w - Fe, C.x)),
960
- y: Math.max(-Le, Math.min(n.h - Ee, C.y))
961
- }) : void 0,
962
- onDragStart: q ? () => {
963
- L(o.id);
964
- } : void 0,
965
- onDragEnd: q ? (C) => {
966
- const D = C.target, j = D.x() / n.w, U = D.y() / n.h;
967
- if (D.position({ x: 0, y: 0 }), L(null), j === 0 && U === 0) return;
968
- const W = o.points.map((I) => ({ x: I.x + j, y: I.y + U }));
969
- y({ zoneId: o.id, points: W }), u(o.id, W);
970
- } : void 0,
971
- onMouseEnter: (C) => {
972
- if (!q) return;
973
- const D = C.target.getStage();
974
- D && (D.container().style.cursor = "move");
975
- },
976
- onMouseLeave: (C) => {
977
- if (!q) return;
978
- const D = C.target.getStage();
979
- D && (D.container().style.cursor = h ? "crosshair" : "default");
980
- },
981
- children: [
982
- P ? /* @__PURE__ */ t(
983
- et,
984
- {
985
- points: E,
986
- stroke: v,
987
- strokeWidth: p ? 3 : 2,
988
- fill: v,
989
- pointerLength: 10,
990
- pointerWidth: 8,
991
- opacity: p ? 1 : 0.8
992
- }
993
- ) : /* @__PURE__ */ t(
994
- V,
995
- {
996
- points: E,
997
- closed: !0,
998
- fill: v + (p ? Ot : Tt),
999
- stroke: v,
1000
- strokeWidth: p ? 2.5 : 1.5,
1001
- opacity: p ? 1 : 0.85
1002
- }
1003
- ),
1004
- x.length > 0 && (() => {
1005
- const C = x.reduce((A, M) => A + M.x, 0), D = x.reduce((A, M) => A + M.y, 0), j = C / x.length, U = D / x.length, W = z({ x: j, y: U }, n.w, n.h), I = Math.max(40, o.name.length * 11 * 0.62);
1006
- return /* @__PURE__ */ t(
1007
- tt,
1008
- {
1009
- x: W.x - I / 2,
1010
- y: W.y - 7,
1011
- width: I,
1012
- align: "center",
1013
- text: o.name,
1014
- fontSize: 12,
1015
- fill: v,
1016
- stroke: "#000000",
1017
- strokeWidth: 3,
1018
- fillAfterStrokeEnabled: !0,
1019
- fontStyle: "bold",
1020
- listening: !1
1021
- }
1022
- );
1023
- })()
1024
- ]
1025
- }
1026
- ),
1027
- p && !K && x.map((C, D) => {
1028
- const j = z(C, n.w, n.h), U = P ? 2 : 3, W = x.length > U;
1029
- return /* @__PURE__ */ t(
1030
- le,
1031
- {
1032
- x: j.x,
1033
- y: j.y,
1034
- radius: 5,
1035
- fill: v,
1036
- stroke: "#ffffff",
1037
- strokeWidth: 1.5,
1038
- draggable: !0,
1039
- onDragMove: (I) => {
1040
- const A = ce({ x: I.target.x(), y: I.target.y() }, n.w, n.h);
1041
- y((M) => {
1042
- const oe = (M && M.zoneId === o.id ? M.points : o.points).map((Pe, Re) => Re === D ? A : Pe);
1043
- return { zoneId: o.id, points: oe };
1044
- });
1045
- },
1046
- onDragEnd: (I) => {
1047
- const A = ce({ x: I.target.x(), y: I.target.y() }, n.w, n.h), M = o.points.map((R, oe) => oe === D ? A : R);
1048
- y({ zoneId: o.id, points: M }), u(o.id, M);
1049
- },
1050
- onContextMenu: (I) => {
1051
- if (I.evt.preventDefault(), I.cancelBubble = !0, !W) return;
1052
- const A = o.points.filter((M, R) => R !== D);
1053
- u(o.id, A);
1054
- }
1055
- },
1056
- `pt-${D}`
1057
- );
1058
- }),
1059
- p && !K && !P && x.length >= 2 && x.map((C, D) => {
1060
- const j = x[(D + 1) % x.length], U = (C.x + j.x) / 2, W = (C.y + j.y) / 2, I = z({ x: U, y: W }, n.w, n.h);
1061
- return /* @__PURE__ */ t(
1062
- le,
1063
- {
1064
- x: I.x,
1065
- y: I.y,
1066
- radius: 4,
1067
- fill: "#ffffff",
1068
- stroke: v,
1069
- strokeWidth: 1.5,
1070
- opacity: 0.6,
1071
- onMouseEnter: (A) => {
1072
- const M = A.target;
1073
- M.to({ radius: 6, opacity: 1, duration: 0.1 });
1074
- const R = M.getStage();
1075
- R && (R.container().style.cursor = "copy");
1076
- },
1077
- onMouseLeave: (A) => {
1078
- const M = A.target;
1079
- M.to({ radius: 4, opacity: 0.6, duration: 0.1 });
1080
- const R = M.getStage();
1081
- R && (R.container().style.cursor = h ? "crosshair" : "default");
1082
- },
1083
- onClick: (A) => {
1084
- A.cancelBubble = !0;
1085
- const M = D + 1, R = [
1086
- ...o.points.slice(0, M),
1087
- { x: U, y: W },
1088
- ...o.points.slice(M)
1089
- ];
1090
- u(o.id, R);
1091
- }
1092
- },
1093
- `mid-${D}`
1094
- );
1095
- })
1096
- ]
1097
- },
1098
- o.id
1099
- );
1100
- }) }),
1101
- /* @__PURE__ */ t(ae, { listening: !1, children: h && d.length > 0 && /* @__PURE__ */ c(ie, { children: [
1102
- d.length >= 2 && s !== "tripwire" && /* @__PURE__ */ t(
1103
- V,
1104
- {
1105
- points: ke(d, n.w, n.h),
1106
- stroke: "#6366f1",
1107
- strokeWidth: 1.5,
1108
- dash: [6, 3],
1109
- opacity: 0.8
1110
- }
1111
- ),
1112
- d.length === 1 && s === "tripwire" && b && /* @__PURE__ */ t(
1113
- V,
1114
- {
1115
- points: [
1116
- d[0].x * n.w,
1117
- d[0].y * n.h,
1118
- b.x,
1119
- b.y
1120
- ],
1121
- stroke: "#f59e0b",
1122
- strokeWidth: 1.5,
1123
- dash: [6, 3],
1124
- opacity: 0.7
1125
- }
1126
- ),
1127
- b && d.length >= 1 && s !== "tripwire" && /* @__PURE__ */ t(
1128
- V,
1129
- {
1130
- points: [
1131
- d[d.length - 1].x * n.w,
1132
- d[d.length - 1].y * n.h,
1133
- b.x,
1134
- b.y
1135
- ],
1136
- stroke: "#6366f1",
1137
- strokeWidth: 1,
1138
- dash: [4, 4],
1139
- opacity: 0.5
1140
- }
1141
- ),
1142
- d.map((o, p) => {
1143
- const v = z(o, n.w, n.h), x = p === 0;
1144
- return /* @__PURE__ */ t(
1145
- le,
1146
- {
1147
- x: v.x,
1148
- y: v.y,
1149
- radius: x && d.length >= 3 ? 7 : 4,
1150
- fill: x && d.length >= 3 ? "#6366f1" : "#ffffff",
1151
- stroke: "#6366f1",
1152
- strokeWidth: 1.5,
1153
- opacity: 0.9
1154
- },
1155
- p
1156
- );
1157
- })
1158
- ] }) })
1159
- ]
1160
- }
1161
- ),
1162
- h ? /* @__PURE__ */ t("div", { className: "px-3 py-1.5 bg-zinc-800/80 text-[11px] text-zinc-400 border-t border-zinc-700", children: s === "tripwire" ? "Click to set start point, click again to complete the tripwire" : d.length < 3 ? "Click to add points (min 3). Double-click or click first point to close." : "Continue adding points. Double-click or click first point to close." }) : null
1163
- ]
1164
- }
1165
- );
1166
- }
1167
- const Wt = Se(jt), Bt = "#3b82f6", de = [
859
+ const ct = "#3b82f6", dt = ["polygon", "line"], q = [
1168
860
  "#3b82f6",
1169
861
  "#10b981",
1170
862
  "#f59e0b",
@@ -1176,22 +868,22 @@ const Wt = Se(jt), Bt = "#3b82f6", de = [
1176
868
  "#8b5cf6",
1177
869
  "#14b8a6"
1178
870
  ];
1179
- function qt(e) {
1180
- const i = new Set(e.map((r) => (r.color ?? "").toLowerCase()));
1181
- for (const r of de)
1182
- if (!i.has(r.toLowerCase())) return r;
1183
- return de[e.length % de.length];
871
+ function ut(e) {
872
+ const o = new Set(e.map((n) => (n.color ?? "").toLowerCase()));
873
+ for (const n of q)
874
+ if (!o.has(n.toLowerCase())) return n;
875
+ return q[e.length % q.length];
1184
876
  }
1185
- function Ut(e) {
877
+ function pt(e) {
1186
878
  return {
1187
879
  id: e.id,
1188
880
  name: e.name,
1189
881
  kind: e.kind,
1190
- color: e.color || Bt,
882
+ color: e.color || ct,
1191
883
  points: [...e.polygon]
1192
884
  };
1193
885
  }
1194
- function Ce(e) {
886
+ function X(e) {
1195
887
  return {
1196
888
  id: e.id,
1197
889
  name: e.name,
@@ -1200,84 +892,101 @@ function Ce(e) {
1200
892
  color: e.color
1201
893
  };
1202
894
  }
1203
- function Ht({ deviceId: e }) {
1204
- const i = fe(), r = he(i.trpcClient, e), u = ge(r?.state.zones), f = G(() => u?.zones ?? [], [u]), s = me(), l = s?.drawingKind ?? null, a = s?.selectedZoneId ?? null, g = s?.editingDraft ?? null, n = G(() => f.map((b) => g && g.id === b.id ? {
1205
- id: g.id,
1206
- name: g.name,
1207
- kind: g.kind,
1208
- color: g.color,
1209
- points: [...g.points]
1210
- } : Ut(b)), [f, g]), F = T(
1211
- async (b) => {
1212
- const k = { ...b, color: qt(n) };
895
+ function mt({ deviceId: e }) {
896
+ const o = B(), n = U(o.trpcClient, e), d = V(n?.state.zones), f = M(() => d?.zones ?? [], [d]), s = z(), a = s?.drawingKind ?? null, r = s?.selectedZoneId ?? null, h = s?.editingDraft ?? null, l = M(() => f.map((u) => h && h.id === u.id ? {
897
+ id: h.id,
898
+ name: h.name,
899
+ kind: h.kind,
900
+ color: h.color,
901
+ points: [...h.points]
902
+ } : pt(u)), [f, h]), v = M(() => l.map(st), [l]), C = w(
903
+ async (u) => {
904
+ if (u.kind !== "polygon" && u.kind !== "line") return;
905
+ const y = {
906
+ id: crypto.randomUUID(),
907
+ name: "",
908
+ kind: it(u.kind),
909
+ color: ut(l),
910
+ points: [...u.points]
911
+ };
1213
912
  try {
1214
- await r?.zones?.addZone({ zone: Ce(k) });
1215
- } catch (Z) {
1216
- console.error("zones.addZone failed", Z);
913
+ await n?.zones?.addZone({ zone: X(y) });
914
+ } catch (_) {
915
+ console.error("zones.addZone failed", _);
1217
916
  }
1218
- s?.setSelectedZoneId(k.id), s?.setDrawingKind(null);
917
+ s?.setSelectedZoneId(y.id), s?.setDrawingKind(null);
1219
918
  },
1220
- [r, n, s]
1221
- ), d = T(
1222
- async (b, k) => {
1223
- if (g && g.id === b) {
1224
- s?.updateDraft({ points: k });
919
+ [n, l, s]
920
+ ), N = w(
921
+ async (u, y) => {
922
+ const _ = y.map((g) => ({ x: g.x, y: g.y }));
923
+ if (h && h.id === u) {
924
+ s?.updateDraft({ points: _ });
1225
925
  return;
1226
926
  }
1227
- const Z = n.find((L) => L.id === b);
1228
- if (Z)
927
+ const p = l.find((g) => g.id === u);
928
+ if (p)
1229
929
  try {
1230
- await r?.zones?.updateZone({ zone: Ce({ ...Z, points: k }) });
1231
- } catch (L) {
1232
- console.error("zones.updateZone failed", L);
930
+ await n?.zones?.updateZone({ zone: X({ ...p, points: _ }) });
931
+ } catch (g) {
932
+ console.error("zones.updateZone failed", g);
1233
933
  }
1234
934
  },
1235
- [r, n, g, s]
1236
- ), $ = T(
1237
- (b) => {
1238
- if (b === null) {
935
+ [n, l, h, s]
936
+ ), D = w(
937
+ (u, y) => {
938
+ typeof u == "string" && (y.kind !== "polygon" && y.kind !== "line" || N(u, y.points));
939
+ },
940
+ [N]
941
+ ), S = w(
942
+ (u) => {
943
+ if (u === null) {
1239
944
  s?.discardDraft(), s?.setSelectedZoneId(null);
1240
945
  return;
1241
946
  }
1242
- const k = n.find((Z) => Z.id === b);
1243
- if (!k) {
1244
- s?.setSelectedZoneId(b);
947
+ if (typeof u != "string") return;
948
+ const y = l.find((_) => _.id === u);
949
+ if (!y) {
950
+ s?.setSelectedZoneId(u);
1245
951
  return;
1246
952
  }
1247
953
  s?.enterDraft({
1248
- id: k.id,
1249
- kind: k.kind,
1250
- name: k.name,
1251
- color: k.color,
1252
- points: k.points
954
+ id: y.id,
955
+ kind: y.kind,
956
+ name: y.name,
957
+ color: y.color,
958
+ points: y.points
1253
959
  });
1254
960
  },
1255
- [n, s]
961
+ [l, s]
1256
962
  );
1257
- return n.length === 0 && l === null ? null : /* @__PURE__ */ t(
1258
- Wt,
963
+ return l.length === 0 && a === null ? null : /* @__PURE__ */ t(
964
+ ce,
1259
965
  {
1260
- zones: n,
1261
- selectedZoneId: a,
1262
- onSelectZone: $,
1263
- onZonePointsChange: d,
1264
- onZoneComplete: F,
1265
- drawingKind: l,
1266
- transparent: !0
966
+ transparent: !0,
967
+ items: v,
968
+ supportedShapes: dt,
969
+ selectedId: r,
970
+ onSelect: S,
971
+ onShapeChange: D,
972
+ onDrawComplete: (u) => {
973
+ C(u);
974
+ },
975
+ drawingKind: a === null ? null : lt(a)
1267
976
  }
1268
977
  );
1269
978
  }
1270
- const Vt = Se(Ht), Gt = "#3b82f6";
1271
- function Yt(e) {
979
+ const ft = ye(mt), ht = "#3b82f6";
980
+ function gt(e) {
1272
981
  return {
1273
982
  id: e.id,
1274
983
  name: e.name,
1275
984
  kind: e.kind,
1276
- color: e.color || Gt,
985
+ color: e.color || ht,
1277
986
  points: [...e.polygon]
1278
987
  };
1279
988
  }
1280
- function zt(e) {
989
+ function bt(e) {
1281
990
  return {
1282
991
  id: e.id,
1283
992
  name: e.name,
@@ -1286,127 +995,127 @@ function zt(e) {
1286
995
  color: e.color
1287
996
  };
1288
997
  }
1289
- function Xt({ deviceId: e }) {
1290
- const i = fe(), r = he(i.trpcClient, e), u = ge(r?.state.zones), f = G(() => u?.zones ?? [], [u]), s = G(() => f.map(Yt), [f]), l = me(), a = l?.drawingKind ?? null, g = l?.selectedZoneId ?? null, n = l?.editingDraft ?? null, F = G(
998
+ function yt({ deviceId: e }) {
999
+ const o = B(), n = U(o.trpcClient, e), d = V(n?.state.zones), f = M(() => d?.zones ?? [], [d]), s = M(() => f.map(gt), [f]), a = z(), r = a?.drawingKind ?? null, h = a?.selectedZoneId ?? null, l = a?.editingDraft ?? null, v = M(
1291
1000
  () => ({
1292
1001
  id: "zones",
1293
1002
  order: 100,
1294
1003
  // above PTZ overlay (order 0) so handles aren't occluded
1295
- node: /* @__PURE__ */ t(Vt, { deviceId: e })
1004
+ node: /* @__PURE__ */ t(ft, { deviceId: e })
1296
1005
  }),
1297
1006
  [e]
1298
1007
  );
1299
- He(F);
1300
- const d = T(
1301
- (y) => {
1302
- if (y === null) {
1303
- l?.discardDraft(), l?.setSelectedZoneId(null);
1008
+ de(v);
1009
+ const C = w(
1010
+ (p) => {
1011
+ if (p === null) {
1012
+ a?.discardDraft(), a?.setSelectedZoneId(null);
1304
1013
  return;
1305
1014
  }
1306
- const h = s.find((Y) => Y.id === y);
1307
- h && l?.enterDraft({
1308
- id: h.id,
1309
- kind: h.kind,
1310
- name: h.name,
1311
- color: h.color,
1312
- points: h.points
1015
+ const g = s.find((A) => A.id === p);
1016
+ g && a?.enterDraft({
1017
+ id: g.id,
1018
+ kind: g.kind,
1019
+ name: g.name,
1020
+ color: g.color,
1021
+ points: g.points
1313
1022
  });
1314
1023
  },
1315
- [s, l]
1316
- ), $ = T(async () => {
1317
- const y = l?.editingDraft;
1318
- if (y) {
1024
+ [s, a]
1025
+ ), N = w(async () => {
1026
+ const p = a?.editingDraft;
1027
+ if (p) {
1319
1028
  try {
1320
- await r?.zones?.updateZone({
1321
- zone: zt({
1322
- id: y.id,
1323
- kind: y.kind,
1324
- name: y.name,
1325
- color: y.color,
1326
- points: [...y.points]
1029
+ await n?.zones?.updateZone({
1030
+ zone: bt({
1031
+ id: p.id,
1032
+ kind: p.kind,
1033
+ name: p.name,
1034
+ color: p.color,
1035
+ points: [...p.points]
1327
1036
  })
1328
1037
  });
1329
- } catch (h) {
1330
- console.error("zones.updateZone failed", h);
1038
+ } catch (g) {
1039
+ console.error("zones.updateZone failed", g);
1331
1040
  }
1332
- l?.discardDraft(), l?.setSelectedZoneId(null);
1041
+ a?.discardDraft(), a?.setSelectedZoneId(null);
1333
1042
  }
1334
- }, [r, l]), b = T(() => {
1335
- l?.discardDraft(), l?.setSelectedZoneId(null);
1336
- }, [l]), k = T(
1337
- async (y) => {
1043
+ }, [n, a]), D = w(() => {
1044
+ a?.discardDraft(), a?.setSelectedZoneId(null);
1045
+ }, [a]), S = w(
1046
+ async (p) => {
1338
1047
  try {
1339
- await r?.zones?.removeZone({ zoneId: y });
1340
- } catch (h) {
1341
- console.error("zones.removeZone failed", h);
1048
+ await n?.zones?.removeZone({ zoneId: p });
1049
+ } catch (g) {
1050
+ console.error("zones.removeZone failed", g);
1342
1051
  }
1343
- l?.selectedZoneId === y && l.setSelectedZoneId(null), l?.editingDraft?.id === y && l.discardDraft();
1052
+ a?.selectedZoneId === p && a.setSelectedZoneId(null), a?.editingDraft?.id === p && a.discardDraft();
1344
1053
  },
1345
- [r, l]
1346
- ), Z = T(
1347
- (y) => {
1348
- l?.startDrawing(y);
1054
+ [n, a]
1055
+ ), u = w(
1056
+ (p) => {
1057
+ a?.startDrawing(p);
1349
1058
  },
1350
- [l]
1351
- ), L = T(() => {
1352
- l?.setDrawingKind(null);
1353
- }, [l]), S = G(() => !n || !s.find((h) => h.id === n.id) ? null : {
1354
- id: n.id,
1355
- kind: n.kind,
1356
- name: n.name,
1357
- color: n.color,
1358
- points: [...n.points]
1359
- }, [s, n]);
1360
- return /* @__PURE__ */ c("div", { className: Ve, children: [
1361
- /* @__PURE__ */ c("div", { className: Ge, children: [
1362
- /* @__PURE__ */ t("div", { className: Ye, children: /* @__PURE__ */ c("div", { className: "min-w-0", children: [
1363
- /* @__PURE__ */ t("h2", { className: Me, children: "Detection Zones" }),
1364
- /* @__PURE__ */ c("p", { className: `${ze} mt-0.5 leading-tight`, children: [
1059
+ [a]
1060
+ ), y = w(() => {
1061
+ a?.setDrawingKind(null);
1062
+ }, [a]), _ = M(() => !l || !s.find((g) => g.id === l.id) ? null : {
1063
+ id: l.id,
1064
+ kind: l.kind,
1065
+ name: l.name,
1066
+ color: l.color,
1067
+ points: [...l.points]
1068
+ }, [s, l]);
1069
+ return /* @__PURE__ */ i("div", { className: ue, children: [
1070
+ /* @__PURE__ */ i("div", { className: pe, children: [
1071
+ /* @__PURE__ */ t("div", { className: me, children: /* @__PURE__ */ i("div", { className: "min-w-0", children: [
1072
+ /* @__PURE__ */ t("h2", { className: Y, children: "Detection Zones" }),
1073
+ /* @__PURE__ */ i("p", { className: `${fe} mt-0.5 leading-tight`, children: [
1365
1074
  "Pick a shape below or use the ",
1366
1075
  /* @__PURE__ */ t("strong", { className: "text-foreground", children: "Zones" }),
1367
1076
  " button on the live frame to draw new polygons or tripwires. Behaviour is set per-stage in the rules editors below — a zone with no rule is observed by analytics but never filters."
1368
1077
  ] })
1369
1078
  ] }) }),
1370
- /* @__PURE__ */ c("div", { className: `${Xe} flex flex-col gap-3`, children: [
1079
+ /* @__PURE__ */ i("div", { className: `${he} flex flex-col gap-3`, children: [
1371
1080
  /* @__PURE__ */ t(
1372
- Zt,
1081
+ et,
1373
1082
  {
1374
1083
  zones: s,
1375
- selectedZoneId: g,
1376
- drawingKind: a,
1377
- onSelectZone: d,
1378
- onDeleteZone: k,
1379
- onStartDraw: Z,
1380
- onCancelDraw: L
1084
+ selectedZoneId: h,
1085
+ drawingKind: r,
1086
+ onSelectZone: C,
1087
+ onDeleteZone: S,
1088
+ onStartDraw: u,
1089
+ onCancelDraw: y
1381
1090
  }
1382
1091
  ),
1383
- S && /* @__PURE__ */ c(De, { children: [
1092
+ _ && /* @__PURE__ */ i(J, { children: [
1384
1093
  /* @__PURE__ */ t("div", { className: "border-t border-border" }),
1385
1094
  /* @__PURE__ */ t(
1386
- Ft,
1095
+ nt,
1387
1096
  {
1388
- zone: S,
1389
- onSave: $,
1390
- onDiscard: b,
1391
- onDelete: () => k(S.id)
1097
+ zone: _,
1098
+ onSave: N,
1099
+ onDiscard: D,
1100
+ onDelete: () => S(_.id)
1392
1101
  }
1393
1102
  )
1394
1103
  ] })
1395
1104
  ] })
1396
1105
  ] }),
1397
- /* @__PURE__ */ c("div", { className: `grid grid-cols-1 2xl:grid-cols-2 ${Ke}`, children: [
1398
- /* @__PURE__ */ t(ve, { dev: r, stage: "motion", zones: f }),
1399
- /* @__PURE__ */ t(ve, { dev: r, stage: "detection", zones: f })
1106
+ /* @__PURE__ */ i("div", { className: `grid grid-cols-1 2xl:grid-cols-2 ${ge}`, children: [
1107
+ /* @__PURE__ */ t(G, { dev: n, stage: "motion", zones: f }),
1108
+ /* @__PURE__ */ t(G, { dev: n, stage: "detection", zones: f })
1400
1109
  ] })
1401
1110
  ] });
1402
1111
  }
1403
- function Kt(e) {
1404
- return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "ZoneEditor requires a deviceId" }) : /* @__PURE__ */ t(Xt, { deviceId: e.deviceId });
1112
+ function xt(e) {
1113
+ return e.deviceId === void 0 ? /* @__PURE__ */ t("div", { className: "rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning", children: "ZoneEditor requires a deviceId" }) : /* @__PURE__ */ t(yt, { deviceId: e.deviceId });
1405
1114
  }
1406
- const ln = {
1407
- "pipeline-quick-stats": Mt,
1408
- "zone-editor": Kt
1115
+ const Ct = {
1116
+ "pipeline-quick-stats": We,
1117
+ "zone-editor": xt
1409
1118
  };
1410
1119
  export {
1411
- ln as default
1120
+ Ct as default
1412
1121
  };