@camstack/addon-pipeline-orchestrator 0.1.22 → 0.1.23

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