@camstack/addon-osd-manager 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -29488,13 +29488,24 @@ var recordingCapability = {
29488
29488
  /** Playback-speed multiplier for the render (1 = realtime). */
29489
29489
  var ExportSpeedSchema = number().min(.25).max(32);
29490
29490
  /**
29491
- * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
29491
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
29492
29492
  *
29493
- * Relative and not absolute epoch on purpose: the renderer's frame-select
29494
- * expression sees ffmpeg's `t`, which starts at 0 for the export's source
29495
- * playlist. Handing it absolute epochs would make every call site responsible
29496
- * for the same subtraction, and the one that forgot would emit a filter that
29497
- * selects nothing silently, as a uniform timelapse.
29493
+ * **Wall clock, not ffmpeg's `t`** and the recorder translates. A caller
29494
+ * derives these bounds from things that happened at a TIME (a track's
29495
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
29496
+ * every segment present for the range, with each recording GAP removed. The
29497
+ * two agree only on a window that recorded without one interruption, and only
29498
+ * the render side knows the segments, so the translation lives there
29499
+ * (`export-dense-map.ts`, addon-pipeline).
29500
+ *
29501
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
29502
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
29503
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
29504
+ * the video was a uniform timelapse, and the log line reported the five ranges
29505
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
29506
+ *
29507
+ * Relative and not absolute epoch, because an absolute epoch would make every
29508
+ * call site responsible for the same subtraction.
29498
29509
  */
29499
29510
  var ExportDenseRangeSchema = object({
29500
29511
  fromSec: number().nonnegative(),
@@ -37460,25 +37471,32 @@ object({
37460
37471
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
37461
37472
  object({
37462
37473
  /**
37463
- * How long a retained native frame is served before it counts as a miss.
37474
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
37475
+ * detection result.
37464
37476
  *
37465
- * Must cover the FULL late-crop horizon: detection inference + the
37466
- * cross-process inference-result hop to hub post-analysis + tracking + the
37467
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
37468
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
37469
- * RAM per busy camera grows linearly with no measured hit-rate gain.
37477
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
37478
+ * a time window was never related to the event the pixels were waiting for.
37479
+ * A held frame now lives from delivery until the runner has its `FrameResult`
37480
+ * at which moment the runner cuts the subject tiles it actually wanted and
37481
+ * releases the frame. The bound exists only so a runner that stops answering
37482
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
37483
+ *
37484
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
37485
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
37486
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
37487
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
37488
+ * `holdOverflow` on the metrics line is what says you need it.
37470
37489
  */
37471
- ttlMs: number().int().min(250).max(1e4),
37490
+ holdFrames: number().int().min(1).max(64),
37472
37491
  /**
37473
37492
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
37474
37493
  *
37475
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
37476
- * which one is actually binding before reasoning from that. At the shipped
37477
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
37478
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
37479
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
37480
- * change that admits fewer frames buys retention WINDOW at constant RAM
37481
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
37494
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
37495
+ * is what decides how much is held, and the ceiling is the number above which
37496
+ * something is wrong. Before that it was the effective cap at 1024 MB with
37497
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
37498
+ * with the TTL expiring nothing, which is exactly the confusion the hold
37499
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
37482
37500
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
37483
37501
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
37484
37502
  * to replace).
@@ -37504,22 +37522,45 @@ object({
37504
37522
  * there is the signal that some caller names frames outside the inference set
37505
37523
  * and that this must go back to `all`.
37506
37524
  */
37507
- admission: NativeLeaseAdmissionSchema
37525
+ admission: NativeLeaseAdmissionSchema,
37526
+ /**
37527
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
37528
+ * compressed native crops the worker cuts at the moment a frame's detection
37529
+ * result arrives, and keeps long after the frame itself is freed.
37530
+ *
37531
+ * This is the knob that replaced the old retention window, and it buys about
37532
+ * three orders of magnitude more of it: a tile is one subject at native
37533
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
37534
+ * the frame it was cut from. A frame on which nothing was detected costs
37535
+ * nothing at all, which is the real change — the old lease paid per FRAME and
37536
+ * was interrogated per SUBJECT.
37537
+ *
37538
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
37539
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
37540
+ * reproduce that.
37541
+ */
37542
+ tileBudgetMb: number().int().min(0).max(1024)
37508
37543
  });
37509
37544
  /**
37510
- * The values in force when the operator has set nothing — byte-for-byte the
37511
- * constants the decode worker shipped with as env-var defaults, so making these
37512
- * settings changed no behaviour on the day it landed.
37545
+ * The values in force when the operator has set nothing.
37546
+ *
37547
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
37548
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
37549
+ * in the same change that redefines it would make a regression and a retune
37550
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
37551
+ * live traffic.
37513
37552
  */
37514
37553
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
37515
- ttlMs: 1200,
37554
+ holdFrames: 8,
37516
37555
  budgetMb: 1024,
37517
37556
  activityMs: 15e3,
37557
+ tileBudgetMb: 64,
37518
37558
  admission: "inferred"
37519
37559
  };
37520
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
37560
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
37521
37561
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37522
37562
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37563
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37523
37564
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37524
37565
  //#endregion
37525
37566
  //#region src/bindings-store.ts
package/dist/index.mjs CHANGED
@@ -29484,13 +29484,24 @@ var recordingCapability = {
29484
29484
  /** Playback-speed multiplier for the render (1 = realtime). */
29485
29485
  var ExportSpeedSchema = number().min(.25).max(32);
29486
29486
  /**
29487
- * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
29487
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
29488
29488
  *
29489
- * Relative and not absolute epoch on purpose: the renderer's frame-select
29490
- * expression sees ffmpeg's `t`, which starts at 0 for the export's source
29491
- * playlist. Handing it absolute epochs would make every call site responsible
29492
- * for the same subtraction, and the one that forgot would emit a filter that
29493
- * selects nothing silently, as a uniform timelapse.
29489
+ * **Wall clock, not ffmpeg's `t`** and the recorder translates. A caller
29490
+ * derives these bounds from things that happened at a TIME (a track's
29491
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
29492
+ * every segment present for the range, with each recording GAP removed. The
29493
+ * two agree only on a window that recorded without one interruption, and only
29494
+ * the render side knows the segments, so the translation lives there
29495
+ * (`export-dense-map.ts`, addon-pipeline).
29496
+ *
29497
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
29498
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
29499
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
29500
+ * the video was a uniform timelapse, and the log line reported the five ranges
29501
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
29502
+ *
29503
+ * Relative and not absolute epoch, because an absolute epoch would make every
29504
+ * call site responsible for the same subtraction.
29494
29505
  */
29495
29506
  var ExportDenseRangeSchema = object({
29496
29507
  fromSec: number().nonnegative(),
@@ -37456,25 +37467,32 @@ object({
37456
37467
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
37457
37468
  object({
37458
37469
  /**
37459
- * How long a retained native frame is served before it counts as a miss.
37470
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
37471
+ * detection result.
37460
37472
  *
37461
- * Must cover the FULL late-crop horizon: detection inference + the
37462
- * cross-process inference-result hop to hub post-analysis + tracking + the
37463
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
37464
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
37465
- * RAM per busy camera grows linearly with no measured hit-rate gain.
37473
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
37474
+ * a time window was never related to the event the pixels were waiting for.
37475
+ * A held frame now lives from delivery until the runner has its `FrameResult`
37476
+ * at which moment the runner cuts the subject tiles it actually wanted and
37477
+ * releases the frame. The bound exists only so a runner that stops answering
37478
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
37479
+ *
37480
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
37481
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
37482
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
37483
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
37484
+ * `holdOverflow` on the metrics line is what says you need it.
37466
37485
  */
37467
- ttlMs: number().int().min(250).max(1e4),
37486
+ holdFrames: number().int().min(1).max(64),
37468
37487
  /**
37469
37488
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
37470
37489
  *
37471
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
37472
- * which one is actually binding before reasoning from that. At the shipped
37473
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
37474
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
37475
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
37476
- * change that admits fewer frames buys retention WINDOW at constant RAM
37477
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
37490
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
37491
+ * is what decides how much is held, and the ceiling is the number above which
37492
+ * something is wrong. Before that it was the effective cap at 1024 MB with
37493
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
37494
+ * with the TTL expiring nothing, which is exactly the confusion the hold
37495
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
37478
37496
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
37479
37497
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
37480
37498
  * to replace).
@@ -37500,22 +37518,45 @@ object({
37500
37518
  * there is the signal that some caller names frames outside the inference set
37501
37519
  * and that this must go back to `all`.
37502
37520
  */
37503
- admission: NativeLeaseAdmissionSchema
37521
+ admission: NativeLeaseAdmissionSchema,
37522
+ /**
37523
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
37524
+ * compressed native crops the worker cuts at the moment a frame's detection
37525
+ * result arrives, and keeps long after the frame itself is freed.
37526
+ *
37527
+ * This is the knob that replaced the old retention window, and it buys about
37528
+ * three orders of magnitude more of it: a tile is one subject at native
37529
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
37530
+ * the frame it was cut from. A frame on which nothing was detected costs
37531
+ * nothing at all, which is the real change — the old lease paid per FRAME and
37532
+ * was interrogated per SUBJECT.
37533
+ *
37534
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
37535
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
37536
+ * reproduce that.
37537
+ */
37538
+ tileBudgetMb: number().int().min(0).max(1024)
37504
37539
  });
37505
37540
  /**
37506
- * The values in force when the operator has set nothing — byte-for-byte the
37507
- * constants the decode worker shipped with as env-var defaults, so making these
37508
- * settings changed no behaviour on the day it landed.
37541
+ * The values in force when the operator has set nothing.
37542
+ *
37543
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
37544
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
37545
+ * in the same change that redefines it would make a regression and a retune
37546
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
37547
+ * live traffic.
37509
37548
  */
37510
37549
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
37511
- ttlMs: 1200,
37550
+ holdFrames: 8,
37512
37551
  budgetMb: 1024,
37513
37552
  activityMs: 15e3,
37553
+ tileBudgetMb: 64,
37514
37554
  admission: "inferred"
37515
37555
  };
37516
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
37556
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
37517
37557
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
37518
37558
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
37559
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
37519
37560
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
37520
37561
  //#endregion
37521
37562
  //#region src/bindings-store.ts
@@ -1,6 +1,6 @@
1
1
  import { c as e, g as t, h as n, l as r, n as i, p as a, r as o, t as s, u as c, y as l } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react__loadShare__.js-Bs1t18EM.mjs";
2
2
  import { n as u, r as d, t as f } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DalfdIDw.mjs";
3
- import { g as p } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-6nLtsGYu.mjs";
3
+ import { g as p } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DnJsIsjP.mjs";
4
4
  //#region ../ui-library/src/lib/cap-error.ts
5
5
  function m(e) {
6
6
  if (typeof e != "object" || !e) return null;
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-DEpsNfV9.mjs";
1
+ import { n as e, t } from "./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__addon_osd_manager_page__remoteEntry_js-CtbZFj0W.mjs";
2
2
  export { t as get, e as init };
@@ -1,4 +1,4 @@
1
- import { s as e } from "./player-overlays-n9zDppCx.mjs";
1
+ import { s as e } from "./player-overlays-Gaf1VP0P.mjs";
2
2
  var t = e("eye-off", [
3
3
  ["path", {
4
4
  d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
@@ -16,14 +16,31 @@ var t = e("eye-off", [
16
16
  d: "m2 2 20 20",
17
17
  key: "1ooewy"
18
18
  }]
19
- ]), n = e("square", [["rect", {
19
+ ]), n = e("mic", [
20
+ ["path", {
21
+ d: "M12 19v3",
22
+ key: "npa21l"
23
+ }],
24
+ ["path", {
25
+ d: "M19 10v2a7 7 0 0 1-14 0v-2",
26
+ key: "1vc78b"
27
+ }],
28
+ ["rect", {
29
+ x: "9",
30
+ y: "2",
31
+ width: "6",
32
+ height: "13",
33
+ rx: "3",
34
+ key: "s6n7sd"
35
+ }]
36
+ ]), r = e("square", [["rect", {
20
37
  width: "18",
21
38
  height: "18",
22
39
  x: "3",
23
40
  y: "3",
24
41
  rx: "2",
25
42
  key: "afitv7"
26
- }]]), r = e("trash-2", [
43
+ }]]), i = e("trash-2", [
27
44
  ["path", {
28
45
  d: "M10 11v6",
29
46
  key: "nco0om"
@@ -46,4 +63,4 @@ var t = e("eye-off", [
46
63
  }]
47
64
  ]);
48
65
  //#endregion
49
- export { n, t as r, r as t };
66
+ export { t as i, r as n, n as r, i as t };
@@ -2753,7 +2753,7 @@ async function rr(e) {
2753
2753
  }
2754
2754
  }
2755
2755
  async function ir() {
2756
- return tr ||= rr(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-DRb4j3WE.mjs")).catch((e) => {
2756
+ return tr ||= rr(() => import("./_virtual_mf-localSharedImportMap___mfe_internal__addon_osd_manager_page-D3Zb_bul.mjs")).catch((e) => {
2757
2757
  throw tr = void 0, e;
2758
2758
  }), tr;
2759
2759
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-osd-manager",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Binds camera on-screen-display slots to live state and recognitions",
5
5
  "keywords": [
6
6
  "camstack",
@@ -1,290 +0,0 @@
1
- import { c as e, h as t, m as n, p as r, u as i, y as a } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react__loadShare__.js-Bs1t18EM.mjs";
2
- import { n as o, r as s, t as c } from "./_virtual_mf___mfe_internal__addon_osd_manager_page__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-DalfdIDw.mjs";
3
- import { a as l, l as u, n as ee, r as te, s as d, t as ne, u as re } from "./player-overlays-n9zDppCx.mjs";
4
- import { n as f, r as p, t as m } from "./trash-2--V8aFmX3.mjs";
5
- import { MaskShapeCanvas as h } from "./MaskShapeCanvas-BEVxAjNq.mjs";
6
- var g = d("hexagon", [["path", {
7
- d: "M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z",
8
- key: "yt0hxn"
9
- }]]);
10
- //#endregion
11
- //#region ../ui-library/src/composites/cap-settings/PrivacyMaskSettings.tsx
12
- a();
13
- var _ = 120, v = "privacy-mask", y = "rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors", b = "rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors";
14
- function x(e) {
15
- return e.kind === "rect" || e.kind === "polygon" ? e : null;
16
- }
17
- function S(e) {
18
- let t = new Set(e.map((e) => e.id)), n = 0;
19
- for (; t.has(n);) n += 1;
20
- return n;
21
- }
22
- function C(e, t) {
23
- if (e.length !== t.length) return !1;
24
- for (let n = 0; n < e.length; n += 1) if (JSON.stringify(e[n]) !== JSON.stringify(t[n])) return !1;
25
- return !0;
26
- }
27
- function w({ deviceId: a }) {
28
- let d = te(l().trpcClient, a), [w, T] = t(null), [E, D] = t(!1), [O, k] = t(null), [A, j] = t(null), [M, N] = t(!1), [P, F] = t(!1), [I, L] = t(null), [R, z] = t(null), B = n(!1);
29
- i(() => {
30
- if (!d) return;
31
- let e = !1;
32
- return B.current = !1, T(null), D(!1), k(null), j(null), F(!1), L(null), z(null), (async () => {
33
- try {
34
- let t = await d.privacyMask?.getOptions({});
35
- if (e) return;
36
- if (!t) throw Error("device proxy not ready");
37
- if (T(t), B.current) return;
38
- let n = await d.privacyMask?.getStatus({});
39
- if (e) return;
40
- if (!n) throw Error("device proxy not ready");
41
- B.current = !0;
42
- let r = {
43
- enabled: n.enabled,
44
- regions: n.regions
45
- };
46
- j(r), k(r);
47
- } catch (t) {
48
- if (e) return;
49
- re(t) ? D(!0) : console.error("Privacy Mask load failed", t);
50
- }
51
- })(), () => {
52
- e = !0;
53
- };
54
- }, [d]);
55
- let V = r(() => O !== null && A !== null && (O.enabled !== A.enabled || !C(O.regions, A.regions)), [O, A]), H = O ? O.regions.length : 0, U = w ? w.maxRegions : 0, W = n(0);
56
- i(() => {
57
- W.current = U;
58
- }, [U]);
59
- let G = U > 0 && H >= U, K = e(() => {
60
- k((e) => e && {
61
- ...e,
62
- enabled: !e.enabled
63
- });
64
- }, []), q = e((e) => {
65
- L(typeof e == "number" ? e : null);
66
- }, []), J = r(() => O ? O.regions.map((e) => ({
67
- id: e.id,
68
- shape: e.shape,
69
- enabled: e.enabled,
70
- label: `Zone ${String(e.id)}`
71
- })) : [], [O]), Y = e((e, t) => {
72
- let n = x(t);
73
- n && k((t) => t && {
74
- ...t,
75
- regions: t.regions.map((t) => t.id === e ? {
76
- ...t,
77
- shape: n
78
- } : t)
79
- });
80
- }, []), X = e((e) => {
81
- let t = x(e);
82
- t && (z(null), k((e) => {
83
- if (!e) return e;
84
- let n = W.current;
85
- if (n > 0 && e.regions.length >= n) return e;
86
- let r = S(e.regions), i = {
87
- id: r,
88
- enabled: !0,
89
- shape: t
90
- };
91
- return L(r), {
92
- ...e,
93
- regions: [...e.regions, i]
94
- };
95
- }));
96
- }, []), Z = e((e) => {
97
- F(!0), L(null), z(e);
98
- }, []), ie = e((e) => {
99
- F(!0), z(null), L(e);
100
- }, []), ae = e((e) => {
101
- L((t) => t === e ? null : t), k((t) => t && {
102
- ...t,
103
- regions: t.regions.filter((t) => t.id !== e)
104
- });
105
- }, []), oe = e(() => {
106
- z(null), L(null), A && k({
107
- enabled: A.enabled,
108
- regions: A.regions
109
- });
110
- }, [A]), se = e(async () => {
111
- if (!(!d || !O)) {
112
- N(!0);
113
- try {
114
- await d.privacyMask?.setMask({ patch: {
115
- enabled: O.enabled,
116
- regions: [...O.regions]
117
- } });
118
- let e = await d.privacyMask?.getStatus({});
119
- if (e) {
120
- let t = {
121
- enabled: e.enabled,
122
- regions: e.regions
123
- };
124
- j(t), k(t);
125
- }
126
- } catch (e) {
127
- console.error("Privacy Mask save failed", e);
128
- } finally {
129
- N(!1);
130
- }
131
- }
132
- }, [d, O]), ce = e(() => {
133
- F((e) => (e && (z(null), L(null)), !e));
134
- }, []), Q = w?.supportedShapes ?? [];
135
- ne(r(() => P && !E && w && O ? {
136
- id: v,
137
- order: _,
138
- node: /* @__PURE__ */ o(h, {
139
- transparent: !0,
140
- items: J,
141
- supportedShapes: Q,
142
- polygonVertices: w.polygonVertices,
143
- selectedId: I,
144
- onSelect: q,
145
- onShapeChange: Y,
146
- onDrawComplete: X,
147
- drawingKind: R
148
- })
149
- } : null, [
150
- P,
151
- E,
152
- w,
153
- O,
154
- J,
155
- Q,
156
- I,
157
- q,
158
- Y,
159
- X,
160
- R
161
- ]));
162
- let le = w?.supportedShapes.includes("rect") ?? !1, ue = w?.supportedShapes.includes("polygon") ?? !1, $ = w !== null && (w.maxRegions <= 0 || w.supportedShapes.length === 0);
163
- return d ? /* @__PURE__ */ o(ee, {
164
- title: "Privacy Mask",
165
- icon: /* @__PURE__ */ o(p, { className: "h-3.5 w-3.5 text-foreground-subtle" }),
166
- children: /* @__PURE__ */ o("div", {
167
- className: "flex flex-col gap-3",
168
- children: E || $ ? /* @__PURE__ */ o("p", {
169
- className: `${u} leading-relaxed`,
170
- children: "This camera doesn't support an on-board privacy mask."
171
- }) : !E && !$ && w !== null && O !== null ? /* @__PURE__ */ s(c, { children: [
172
- /* @__PURE__ */ s("p", {
173
- className: `${u} leading-relaxed`,
174
- children: [
175
- "Toggle ",
176
- /* @__PURE__ */ o("strong", {
177
- className: "text-foreground",
178
- children: "Edit mask"
179
- }),
180
- " to draw blanked-out zones on the live frame, then ",
181
- /* @__PURE__ */ o("strong", {
182
- className: "text-foreground",
183
- children: "Save"
184
- }),
185
- " to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it."
186
- ]
187
- }),
188
- /* @__PURE__ */ s("div", {
189
- className: "flex items-center gap-2 flex-wrap",
190
- children: [
191
- /* @__PURE__ */ o("button", {
192
- type: "button",
193
- onClick: ce,
194
- disabled: M,
195
- "aria-pressed": P,
196
- className: P ? b : y,
197
- children: P ? "Done editing" : "Edit mask"
198
- }),
199
- /* @__PURE__ */ o("button", {
200
- type: "button",
201
- onClick: K,
202
- disabled: M,
203
- "aria-pressed": O.enabled,
204
- className: O.enabled ? b : y,
205
- children: O.enabled ? "Mask on" : "Mask off"
206
- }),
207
- le && /* @__PURE__ */ o("button", {
208
- type: "button",
209
- onClick: () => Z("rect"),
210
- disabled: M || G,
211
- "aria-pressed": R === "rect",
212
- className: R === "rect" ? b : y,
213
- title: G ? "Maximum zones reached" : "Add a rectangle zone",
214
- children: "+ Rect"
215
- }),
216
- ue && /* @__PURE__ */ o("button", {
217
- type: "button",
218
- onClick: () => Z("polygon"),
219
- disabled: M || G,
220
- "aria-pressed": R === "polygon",
221
- className: R === "polygon" ? b : y,
222
- title: G ? "Maximum zones reached" : "Add a polygon zone",
223
- children: "+ Polygon"
224
- }),
225
- /* @__PURE__ */ s("span", {
226
- className: `${u} ml-1 tabular-nums`,
227
- children: [
228
- H,
229
- " / ",
230
- U,
231
- " zones"
232
- ]
233
- }),
234
- /* @__PURE__ */ o("span", { className: "flex-1" }),
235
- /* @__PURE__ */ o("button", {
236
- type: "button",
237
- onClick: oe,
238
- disabled: M || !V,
239
- 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",
240
- children: "Revert"
241
- }),
242
- /* @__PURE__ */ o("button", {
243
- type: "button",
244
- onClick: () => void se(),
245
- disabled: M || !V,
246
- className: b,
247
- children: M ? "Saving…" : "Save"
248
- })
249
- ]
250
- }),
251
- H > 0 ? /* @__PURE__ */ o("div", {
252
- className: "flex flex-col gap-1",
253
- children: O.regions.map((e) => {
254
- let t = I === e.id, n = e.shape.kind === "polygon" ? g : f;
255
- return /* @__PURE__ */ s("div", {
256
- className: `flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${t ? "border-primary/50 bg-primary/10" : "border-border bg-surface"}`,
257
- children: [/* @__PURE__ */ s("button", {
258
- type: "button",
259
- onClick: () => ie(e.id),
260
- disabled: M,
261
- className: "flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors",
262
- children: [
263
- /* @__PURE__ */ o(n, { className: "h-3.5 w-3.5 shrink-0" }),
264
- /* @__PURE__ */ s("span", { children: ["Zone ", e.id] }),
265
- /* @__PURE__ */ o("span", {
266
- className: "text-foreground-faint capitalize",
267
- children: e.shape.kind
268
- })
269
- ]
270
- }), /* @__PURE__ */ o("button", {
271
- type: "button",
272
- onClick: () => ae(e.id),
273
- disabled: M,
274
- "aria-label": `Delete zone ${String(e.id)}`,
275
- title: "Delete zone",
276
- className: "inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors",
277
- children: /* @__PURE__ */ o(m, { className: "h-3.5 w-3.5" })
278
- })]
279
- }, e.id);
280
- })
281
- }) : null
282
- ] }) : /* @__PURE__ */ o("p", {
283
- className: `${u} leading-relaxed`,
284
- children: "Loading the camera's privacy mask…"
285
- })
286
- })
287
- }) : null;
288
- }
289
- //#endregion
290
- export { w as PrivacyMaskSettings };