@sentinel-nvr/web 0.16.11 → 0.17.0

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/ui/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import {
2
2
  PlayerController,
3
3
  rlog
4
- } from "../chunk-RJXSSHIR.js";
4
+ } from "../chunk-5RHE6TBS.js";
5
5
  import {
6
6
  SENTINEL_CLASS_PRIORITY,
7
7
  SENTINEL_DAY_MS,
8
8
  SENTINEL_EVENT_CLASSES,
9
+ SentinelHttpError,
9
10
  fmtDay,
10
11
  fmtDayPrefix,
11
12
  fmtMonthYear,
@@ -24,6 +25,7 @@ import {
24
25
  sentinelEventHidden,
25
26
  sentinelEventPlayTs,
26
27
  sentinelEventSpan,
28
+ sentinelHasFeature,
27
29
  sentinelHumanBytes,
28
30
  sentinelMergeDays,
29
31
  sentinelRecordingState,
@@ -31,7 +33,7 @@ import {
31
33
  sentinelWallMarks,
32
34
  sentinelWallSeconds,
33
35
  weekdayShorts
34
- } from "../chunk-CNXMCQJ3.js";
36
+ } from "../chunk-UK7LBC3R.js";
35
37
 
36
38
  // src/ui/context.tsx
37
39
  import { createContext, useContext } from "react";
@@ -625,12 +627,14 @@ function outsideAppHref(url, env = {
625
627
 
626
628
  // src/ui/components/EventList.tsx
627
629
  import { Fragment as Fragment3 } from "react";
630
+ import { Download } from "lucide-react";
628
631
  import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
629
632
  function EventList({
630
633
  camId,
631
634
  events,
632
635
  filterOff,
633
- onPick
636
+ onPick,
637
+ onClip
634
638
  }) {
635
639
  const { client, t, locale } = useSentinelUi();
636
640
  const evs = events.filter((e) => !sentinelEventHidden(e, filterOff)).slice().sort((a, b) => b.timestamp - a.timestamp);
@@ -642,19 +646,32 @@ function EventList({
642
646
  lastDay = d;
643
647
  return /* @__PURE__ */ jsxs3(Fragment3, { children: [
644
648
  head && /* @__PURE__ */ jsx5("div", { className: "nvr-evlist__day nvr-data", children: fmtDay(ev.timestamp, locale) }),
645
- /* @__PURE__ */ jsxs3("button", { type: "button", className: "nvr-evrow", onClick: () => onPick(ev), children: [
646
- /* @__PURE__ */ jsx5("img", { className: "nvr-evrow__img", src: client.eventThumbUrl(camId, ev.timestamp), alt: "", loading: "lazy" }),
647
- /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__text", children: [
648
- /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__cls", children: [
649
- /* @__PURE__ */ jsx5(EventBadges, { ev, size: 16, t }),
650
- " ",
651
- eventLabel(t, ev)
652
- ] }),
653
- /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__t nvr-data", children: [
654
- fmtTimeSec(ev.timestamp, locale),
655
- /* @__PURE__ */ jsx5(EventSpanNote, { ev, t })
649
+ /* @__PURE__ */ jsxs3("div", { className: "nvr-evrow-wrap" + (onClip ? " nvr-evrow-wrap--clip" : ""), children: [
650
+ /* @__PURE__ */ jsxs3("button", { type: "button", className: "nvr-evrow", onClick: () => onPick(ev), children: [
651
+ /* @__PURE__ */ jsx5("img", { className: "nvr-evrow__img", src: client.eventThumbUrl(camId, ev.timestamp), alt: "", loading: "lazy" }),
652
+ /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__text", children: [
653
+ /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__cls", children: [
654
+ /* @__PURE__ */ jsx5(EventBadges, { ev, size: 16, t }),
655
+ " ",
656
+ eventLabel(t, ev)
657
+ ] }),
658
+ /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__t nvr-data", children: [
659
+ fmtTimeSec(ev.timestamp, locale),
660
+ /* @__PURE__ */ jsx5(EventSpanNote, { ev, t })
661
+ ] })
656
662
  ] })
657
- ] })
663
+ ] }),
664
+ onClip && /* @__PURE__ */ jsx5(
665
+ "button",
666
+ {
667
+ type: "button",
668
+ className: "nvr-iconbtn nvr-evrow__clip",
669
+ "aria-label": `${t("nvr.clip.event")} ${fmtTimeSec(ev.timestamp, locale)}`,
670
+ title: t("nvr.clip.event"),
671
+ onClick: () => onClip(ev),
672
+ children: /* @__PURE__ */ jsx5(Download, { size: 16 })
673
+ }
674
+ )
658
675
  ] })
659
676
  ] }, ev.id);
660
677
  }) });
@@ -1186,7 +1203,7 @@ function VerticalTimeline(p) {
1186
1203
  }, []);
1187
1204
  const followTick = () => {
1188
1205
  const v = VT.current;
1189
- if (!v.user) {
1206
+ if (!v.user && !p.hold) {
1190
1207
  const ts = p.live ? Date.now() : p.following() ? p.playhead() : null;
1191
1208
  if (ts != null) {
1192
1209
  const cur = centerTs();
@@ -1297,6 +1314,7 @@ function VerticalTimeline(p) {
1297
1314
  v.lastC = { ts: c, at: now2 };
1298
1315
  v.smooth = v.smooth == null ? c : v.smooth + 0.45 * (c - v.smooth);
1299
1316
  p.scrub.move(c, v.vel, v.smooth);
1317
+ p.onUserCenter?.(clampRange(c));
1300
1318
  notifyCenter();
1301
1319
  tick((n) => n + 1);
1302
1320
  clearTimeout(v.holdT);
@@ -1332,7 +1350,7 @@ function VerticalTimeline(p) {
1332
1350
  setPx(c);
1333
1351
  };
1334
1352
  const zoomStep = (f) => {
1335
- const a = p.live ? Date.now() : p.following() ? p.playhead() ?? centerTs() : centerTs();
1353
+ const a = p.hold ? centerTs() : p.live ? Date.now() : p.following() ? p.playhead() ?? centerTs() : centerTs();
1336
1354
  applyZoom(px * f, a, vh * HEAD);
1337
1355
  };
1338
1356
  const runs = useMemo(() => sentinelClipRuns(p.clips), [p.clips]);
@@ -1376,7 +1394,7 @@ function VerticalTimeline(p) {
1376
1394
  const thumbGap = (window.innerWidth < 900 ? 63 : 77) + 6;
1377
1395
  const now = Date.now();
1378
1396
  const viewCenter = clamp(centerTs(), p.rangeStart, p.rangeEnd - 1);
1379
- const center = VT.current.user || !p.following() ? viewCenter : p.live ? now : p.playhead() ?? viewCenter;
1397
+ const center = VT.current.user || p.hold || !p.following() ? viewCenter : p.live ? now : p.playhead() ?? viewCenter;
1380
1398
  const centerIsToday = new Date(center).toDateString() === (/* @__PURE__ */ new Date()).toDateString();
1381
1399
  const down = () => {
1382
1400
  VT.current.down = true;
@@ -1398,6 +1416,14 @@ function VerticalTimeline(p) {
1398
1416
  }),
1399
1417
  axis.map((t2) => /* @__PURE__ */ jsx8("div", { className: "vaxis nvr-data", style: { top: yFor(t2) }, children: hhmm(t2) }, t2)),
1400
1418
  midnights.map((t2) => /* @__PURE__ */ jsx8("div", { className: "vday", style: { top: yFor(t2) }, children: /* @__PURE__ */ jsx8("span", { className: "nvr-data", children: dayLbl(t2) }) }, "d" + t2)),
1419
+ p.clip && inWin(Math.min(p.clip.from, p.clip.to), Math.max(p.clip.from, p.clip.to)) && /* @__PURE__ */ jsx8(
1420
+ "div",
1421
+ {
1422
+ className: "vclip" + (p.clip.edge ? ` vclip--${p.clip.edge}` : "") + (p.clip.bad ? " vclip--bad" : ""),
1423
+ style: { top: yFor(p.clip.to), height: Math.max(2, (p.clip.to - p.clip.from) * px) },
1424
+ "aria-hidden": "true"
1425
+ }
1426
+ ),
1401
1427
  runs.map(
1402
1428
  (r, i) => inWin(r.s, r.e) && /* @__PURE__ */ jsx8("div", { className: "vseg", style: { top: yFor(r.e), height: Math.max(2, (r.e - r.s) * px) } }, i)
1403
1429
  ),
@@ -1482,12 +1508,13 @@ function VerticalTimeline(p) {
1482
1508
  }
1483
1509
 
1484
1510
  // src/ui/components/CameraPage.tsx
1485
- import { useCallback, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState4 } from "react";
1511
+ import { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef3, useState as useState5 } from "react";
1486
1512
  import {
1487
1513
  Calendar,
1488
1514
  Camera as Camera2,
1489
1515
  ChevronLeft as ChevronLeft2,
1490
1516
  ChevronRight as ChevronRight2,
1517
+ Download as Download2,
1491
1518
  FastForward,
1492
1519
  Maximize2,
1493
1520
  Pause,
@@ -1496,7 +1523,7 @@ import {
1496
1523
  Rewind,
1497
1524
  Volume2,
1498
1525
  VolumeX,
1499
- X
1526
+ X as X2
1500
1527
  } from "lucide-react";
1501
1528
 
1502
1529
  // src/ui/camera-logic.ts
@@ -1533,8 +1560,520 @@ function eventsOnDay(events, day) {
1533
1560
  return n;
1534
1561
  }
1535
1562
 
1563
+ // src/ui/clip-logic.ts
1564
+ var CLIP_MAX_MS = 30 * 6e4;
1565
+ var CLIP_PAD_MS = 5e3;
1566
+ var CLIP_LEAD_MS = 1e4;
1567
+ var CLIP_LIVE_EDGE_MS = 1e4;
1568
+ var CLIP_AROUND_MS = 3e4;
1569
+ var CLIP_LIVE_MS = 6e4;
1570
+ var CLIP_GAP_MS = 2e3;
1571
+ var CLIP_SHARE_MAX = 100 * 1024 * 1024;
1572
+ var CLIP_POLL_MS = 700;
1573
+ var CLIP_POLL_GIVEUP_MS = 6e4;
1574
+ function clipRangeForEvent(ev, now = Date.now()) {
1575
+ const t = ev.timestamp;
1576
+ const start = Math.max(Math.min(ev.startTs ?? t, t), t - CLIP_LEAD_MS);
1577
+ const open = !!ev.open;
1578
+ const end = open ? Math.max(now, ev.endTs ?? t) : Math.max(ev.endTs ?? t, t);
1579
+ return { from: start - CLIP_PAD_MS, to: end + CLIP_PAD_MS, open };
1580
+ }
1581
+ function clampClipRange(r, opts) {
1582
+ const hi = opts.now - CLIP_LIVE_EDGE_MS;
1583
+ let from = r.from, to = r.to;
1584
+ if (opts.oldest != null && from < opts.oldest) from = opts.oldest;
1585
+ if (to > hi) to = hi;
1586
+ if (opts.cap !== false && to - from > CLIP_MAX_MS) to = from + CLIP_MAX_MS;
1587
+ if (to < from) from = to;
1588
+ return { from, to };
1589
+ }
1590
+ function clipProposal(s) {
1591
+ const hi = s.now - CLIP_LIVE_EDGE_MS;
1592
+ if (s.live || s.playhead == null) {
1593
+ return { ...clampClipRange({ from: hi - CLIP_LIVE_MS, to: hi }, s), open: false };
1594
+ }
1595
+ const p = s.playhead;
1596
+ let hit = null;
1597
+ let hitTs = -Infinity;
1598
+ for (const e of s.events) {
1599
+ const r = clipRangeForEvent(e, s.now);
1600
+ if (p >= r.from && p <= r.to && e.timestamp > hitTs) {
1601
+ hit = r;
1602
+ hitTs = e.timestamp;
1603
+ }
1604
+ }
1605
+ if (hit) return { ...clampClipRange(hit, s), open: hit.open };
1606
+ return { ...clampClipRange({ from: p - CLIP_AROUND_MS, to: p + CLIP_AROUND_MS }, s), open: false };
1607
+ }
1608
+ function clipSetEdge(r, edge, ts) {
1609
+ if (edge === "from")
1610
+ return ts <= r.to ? { range: { from: ts, to: r.to }, edge } : { range: { from: r.to, to: ts }, edge: "to" };
1611
+ return ts >= r.from ? { range: { from: r.from, to: ts }, edge } : { range: { from: ts, to: r.from }, edge: "from" };
1612
+ }
1613
+ function clipCoverage(clips, r) {
1614
+ const runs = sentinelClipRuns(clips, CLIP_GAP_MS).filter((x) => x.e > r.from && x.s < r.to);
1615
+ let covered = 0, cur = r.from;
1616
+ const gaps = [];
1617
+ for (const x of runs) {
1618
+ const s = Math.max(x.s, r.from), e = Math.min(x.e, r.to);
1619
+ if (s - cur >= CLIP_GAP_MS) gaps.push([cur, s]);
1620
+ covered += Math.max(0, e - s);
1621
+ cur = Math.max(cur, e);
1622
+ }
1623
+ if (runs.length && r.to - cur >= CLIP_GAP_MS) gaps.push([cur, r.to]);
1624
+ return { covered, gaps };
1625
+ }
1626
+ function clipHints(r, clips, now) {
1627
+ const tooLong = r.to - r.from > CLIP_MAX_MS;
1628
+ const hi = now - CLIP_LIVE_EDGE_MS;
1629
+ const endsAt = r.to > hi ? Math.max(r.from, hi) : null;
1630
+ const cov = clipCoverage(clips, { from: r.from, to: Math.min(r.to, hi) });
1631
+ const noRecording = cov.covered <= 0;
1632
+ return {
1633
+ tooLong,
1634
+ noRecording,
1635
+ gaps: !noRecording && cov.gaps.length > 0,
1636
+ endsAt,
1637
+ canCreate: !tooLong && !noRecording && r.to - r.from >= 1e3 && r.from < hi
1638
+ };
1639
+ }
1640
+ function clipLength(r) {
1641
+ return sentinelDuration(r.to - r.from);
1642
+ }
1643
+ function clipTimeAmbiguous(ts) {
1644
+ const wall = (x) => {
1645
+ const d = new Date(x);
1646
+ return d.getHours() * 3600 + d.getMinutes() * 60 + d.getSeconds();
1647
+ };
1648
+ const w = wall(ts);
1649
+ return wall(ts - 36e5) === w || wall(ts + 36e5) === w;
1650
+ }
1651
+ function fmtClipTime(ts, locale) {
1652
+ const base = { hour: "2-digit", minute: "2-digit", second: "2-digit" };
1653
+ if (!clipTimeAmbiguous(ts)) return new Intl.DateTimeFormat(locale, base).format(ts);
1654
+ try {
1655
+ return new Intl.DateTimeFormat(locale, { ...base, timeZoneName: "shortOffset" }).format(ts);
1656
+ } catch {
1657
+ return new Intl.DateTimeFormat(locale, { ...base, timeZoneName: "short" }).format(ts);
1658
+ }
1659
+ }
1660
+ function clipWays(s) {
1661
+ const fits = s.bytes > 0 && s.bytes <= CLIP_SHARE_MAX;
1662
+ if (s.standalone)
1663
+ return fits ? { prefetch: true, share: s.canShareFiles, save: "blob" } : { prefetch: false, share: false, save: "safari" };
1664
+ if (fits && s.canShareFiles) return { prefetch: true, share: true, save: "link" };
1665
+ return { prefetch: false, share: false, save: "link" };
1666
+ }
1667
+ function clipErrorKind(status, code) {
1668
+ if (code === "busy" || status === 429) return "busy";
1669
+ if (code === "no space" || status === 507) return "noSpace";
1670
+ if (code === "no recording") return "noRecording";
1671
+ if (code === "too long" || status === 413) return "tooLong";
1672
+ if (code === "stream change") return "streamChange";
1673
+ if (code === "unknown export") return "expired";
1674
+ if (status === 404 && !code) return "oldServer";
1675
+ return "failed";
1676
+ }
1677
+
1678
+ // src/ui/components/ClipBar.tsx
1679
+ import { useCallback, useEffect as useEffect3, useRef as useRef2, useState as useState4 } from "react";
1680
+ import { Share2, X } from "lucide-react";
1681
+ import { Fragment as Fragment7, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1682
+ function canShareFiles() {
1683
+ try {
1684
+ const n = navigator;
1685
+ if (typeof n.canShare !== "function" || typeof n.share !== "function") return false;
1686
+ return n.canShare({ files: [new File([new Uint8Array(1)], "clip.mp4", { type: "video/mp4" })] });
1687
+ } catch {
1688
+ return false;
1689
+ }
1690
+ }
1691
+ function viewerTz() {
1692
+ try {
1693
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || void 0;
1694
+ } catch {
1695
+ return void 0;
1696
+ }
1697
+ }
1698
+ function ClipBar(p) {
1699
+ const { client, t, locale } = useSentinelUi();
1700
+ const [job, setJobState] = useState4({ s: "idle" });
1701
+ const jobRef = useRef2(job);
1702
+ const setJob = useCallback((j) => {
1703
+ jobRef.current = j;
1704
+ setJobState(j);
1705
+ }, []);
1706
+ const gen = useRef2(0);
1707
+ const alive = useRef2(true);
1708
+ const abort = useRef2(null);
1709
+ const standalone = isIosHomeScreenApp();
1710
+ const release = useCallback(() => {
1711
+ abort.current?.abort();
1712
+ abort.current = null;
1713
+ const j = jobRef.current;
1714
+ if (j.s === "ready" && j.blobUrl) URL.revokeObjectURL(j.blobUrl);
1715
+ }, []);
1716
+ const cancelRunning = useCallback(() => {
1717
+ const j = jobRef.current;
1718
+ if (j.s === "running") void client.cancelExport(j.id);
1719
+ }, [client]);
1720
+ useEffect3(() => {
1721
+ alive.current = true;
1722
+ return () => {
1723
+ alive.current = false;
1724
+ gen.current++;
1725
+ cancelRunning();
1726
+ release();
1727
+ };
1728
+ }, [cancelRunning, release]);
1729
+ const rangeKey = `${p.range.from}|${p.range.to}`;
1730
+ const lastKey = useRef2(rangeKey);
1731
+ useEffect3(() => {
1732
+ if (lastKey.current === rangeKey) return;
1733
+ lastKey.current = rangeKey;
1734
+ if (jobRef.current.s === "idle") return;
1735
+ cancelRunning();
1736
+ gen.current++;
1737
+ release();
1738
+ setJob({ s: "idle" });
1739
+ }, [rangeKey, cancelRunning, release, setJob]);
1740
+ const fail = useCallback(
1741
+ (kind, vars, extra) => {
1742
+ rlog("clip", { ok: false, err: kind, standalone, ...extra });
1743
+ setJob(vars ? { s: "error", kind, vars } : { s: "error", kind });
1744
+ },
1745
+ [setJob, standalone]
1746
+ );
1747
+ const errorOf = useCallback(
1748
+ (e) => {
1749
+ const st2 = e instanceof SentinelHttpError ? e.status : 0;
1750
+ const code = e instanceof SentinelHttpError ? e.code : void 0;
1751
+ const body = e instanceof SentinelHttpError ? e.body : void 0;
1752
+ const kind = clipErrorKind(st2, code);
1753
+ const vars = {};
1754
+ if (kind === "tooLong") vars.max = Math.round(Number(body?.maxMs ?? CLIP_MAX_MS) / 6e4);
1755
+ let k = kind;
1756
+ if (kind === "streamChange") {
1757
+ if (typeof body?.at === "number") vars.time = fmtClipTime(body.at, locale);
1758
+ else k = "failed";
1759
+ }
1760
+ fail(k, vars, { status: st2, code });
1761
+ },
1762
+ [fail, locale]
1763
+ );
1764
+ const finish = useCallback(
1765
+ async (g, d) => {
1766
+ const ways = clipWays({ bytes: d.bytes, canShareFiles: canShareFiles(), standalone });
1767
+ if (!ways.prefetch) {
1768
+ setJob({ s: "ready", ...d, ways });
1769
+ return;
1770
+ }
1771
+ setJob({ s: "loading", ...d, ways });
1772
+ const ac = new AbortController();
1773
+ abort.current = ac;
1774
+ try {
1775
+ const r = await fetch(client.exportFileUrl(d.id), { cache: "no-store", signal: ac.signal });
1776
+ if (r.status === 404) {
1777
+ if (g === gen.current) fail("expired");
1778
+ return;
1779
+ }
1780
+ if (!r.ok) throw new Error(String(r.status));
1781
+ const blob = await r.blob();
1782
+ if (g !== gen.current || !alive.current) return;
1783
+ const file = new File([blob], d.filename, { type: blob.type || "video/mp4" });
1784
+ setJob({ s: "ready", ...d, ways, file, blobUrl: URL.createObjectURL(blob) });
1785
+ } catch (e) {
1786
+ if (g !== gen.current || !alive.current) return;
1787
+ rlog("clip", {
1788
+ ok: false,
1789
+ err: "prefetch",
1790
+ msg: String(e?.message ?? e).slice(0, 80),
1791
+ bytes: d.bytes,
1792
+ standalone
1793
+ });
1794
+ setJob({ s: "ready", ...d, ways: { prefetch: false, share: false, save: "link" } });
1795
+ } finally {
1796
+ if (abort.current === ac) abort.current = null;
1797
+ }
1798
+ },
1799
+ [client, fail, setJob, standalone]
1800
+ );
1801
+ const running = job.s === "running" ? job.id : null;
1802
+ useEffect3(() => {
1803
+ if (!running) return;
1804
+ const g = gen.current;
1805
+ let timer = 0;
1806
+ let busy2 = false;
1807
+ let lastOk = Date.now();
1808
+ const poll = async () => {
1809
+ if (busy2 || g !== gen.current) return;
1810
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") return;
1811
+ busy2 = true;
1812
+ try {
1813
+ const st2 = await client.exportStatus(running);
1814
+ if (g !== gen.current || !alive.current) return;
1815
+ lastOk = Date.now();
1816
+ const j = jobRef.current;
1817
+ if (j.s !== "running") return;
1818
+ if (st2.state === "running") setJob({ ...j, pct: Math.max(0, Math.min(1, st2.progress || 0)) });
1819
+ else if (st2.state === "done") {
1820
+ window.clearInterval(timer);
1821
+ void finish(g, {
1822
+ id: j.id,
1823
+ bytes: st2.bytes ?? j.start.estBytes,
1824
+ filename: st2.filename || j.start.filename,
1825
+ start: j.start,
1826
+ t0: j.t0,
1827
+ expiresAt: st2.expiresAt
1828
+ });
1829
+ } else if (st2.state === "cancelled") {
1830
+ window.clearInterval(timer);
1831
+ setJob({ s: "idle" });
1832
+ } else {
1833
+ window.clearInterval(timer);
1834
+ fail("failed", void 0, { serverErr: st2.error });
1835
+ }
1836
+ } catch (e) {
1837
+ if (g !== gen.current || !alive.current) return;
1838
+ const status = e instanceof SentinelHttpError ? e.status : 0;
1839
+ if (status === 404 || status === 401 || status === 403 || Date.now() - lastOk > CLIP_POLL_GIVEUP_MS) {
1840
+ window.clearInterval(timer);
1841
+ if (status !== 404) void client.cancelExport(running);
1842
+ gen.current++;
1843
+ fail("failed", void 0, { status, code: e instanceof SentinelHttpError ? e.code : void 0 });
1844
+ }
1845
+ } finally {
1846
+ busy2 = false;
1847
+ }
1848
+ };
1849
+ timer = window.setInterval(() => void poll(), CLIP_POLL_MS);
1850
+ const vis = () => {
1851
+ if (document.visibilityState === "visible") void poll();
1852
+ };
1853
+ document.addEventListener("visibilitychange", vis);
1854
+ return () => {
1855
+ window.clearInterval(timer);
1856
+ document.removeEventListener("visibilitychange", vis);
1857
+ };
1858
+ }, [running, client, finish, fail, setJob]);
1859
+ const expiresAt = job.s === "ready" || job.s === "loading" ? job.expiresAt : void 0;
1860
+ useEffect3(() => {
1861
+ if (!expiresAt) return;
1862
+ const g = gen.current;
1863
+ const i = window.setTimeout(
1864
+ () => {
1865
+ if (g !== gen.current || !alive.current) return;
1866
+ const j = jobRef.current;
1867
+ if (j.s === "ready" && j.file) return;
1868
+ gen.current++;
1869
+ release();
1870
+ setJob({ s: "error", kind: "expired" });
1871
+ },
1872
+ Math.min(2 ** 31 - 1, Math.max(0, expiresAt - Date.now()))
1873
+ );
1874
+ return () => window.clearTimeout(i);
1875
+ }, [expiresAt, release, setJob]);
1876
+ const create = useCallback(async () => {
1877
+ const j = jobRef.current;
1878
+ if (j.s === "starting" || j.s === "running" || j.s === "loading") return;
1879
+ gen.current++;
1880
+ const g = gen.current;
1881
+ release();
1882
+ p.onEdge(null);
1883
+ setJob({ s: "starting" });
1884
+ const t0 = Date.now();
1885
+ try {
1886
+ const start = await client.startExport(p.camId, p.range.from, p.range.to, viewerTz());
1887
+ if (g !== gen.current) {
1888
+ void client.cancelExport(start.id);
1889
+ return;
1890
+ }
1891
+ setJob({ s: "running", id: start.id, pct: 0, start, t0 });
1892
+ } catch (e) {
1893
+ if (g !== gen.current || !alive.current) return;
1894
+ errorOf(e);
1895
+ }
1896
+ }, [client, p, release, setJob, errorOf]);
1897
+ const cancel = useCallback(() => {
1898
+ cancelRunning();
1899
+ gen.current++;
1900
+ release();
1901
+ setJob({ s: "idle" });
1902
+ }, [cancelRunning, release, setJob]);
1903
+ const log = (w, ok = true, err) => {
1904
+ const j = jobRef.current;
1905
+ if (j.s !== "ready" && j.s !== "loading") return;
1906
+ rlog("clip", { ms: Date.now() - j.t0, bytes: j.bytes, w, standalone, ok, ...err ? { err } : {} });
1907
+ };
1908
+ const share = () => {
1909
+ const j = jobRef.current;
1910
+ if (j.s !== "ready" || !j.file) return;
1911
+ try {
1912
+ void navigator.share({ files: [j.file] }).then(
1913
+ () => log("share"),
1914
+ (e) => {
1915
+ const name = e?.name;
1916
+ if (name !== "AbortError") log("share", false, name || "error");
1917
+ }
1918
+ );
1919
+ } catch (e) {
1920
+ log("share", false, e?.name || "error");
1921
+ }
1922
+ };
1923
+ const busy = job.s === "starting" || job.s === "running" || job.s === "loading";
1924
+ const now = Date.now();
1925
+ const hints = clipHints(p.range, p.clips, now);
1926
+ const chip = (e) => {
1927
+ const ts = e === "from" ? p.range.from : p.range.to;
1928
+ const active = p.edge === e;
1929
+ const bad = e === "to" && hints.tooLong;
1930
+ const k = t(e === "from" ? "nvr.clip.from" : "nvr.clip.to");
1931
+ const v = fmtClipTime(ts, locale);
1932
+ return /* @__PURE__ */ jsxs7(
1933
+ "button",
1934
+ {
1935
+ type: "button",
1936
+ className: "nvr-clipchip" + (active ? " nvr-clipchip--active" : "") + (bad ? " nvr-clipchip--bad" : ""),
1937
+ "aria-pressed": active,
1938
+ "aria-label": `${k} ${v}`,
1939
+ disabled: busy,
1940
+ onClick: () => p.onEdge(active ? null : e),
1941
+ children: [
1942
+ /* @__PURE__ */ jsx9("span", { className: "nvr-clipchip__k", children: k }),
1943
+ " ",
1944
+ /* @__PURE__ */ jsx9("span", { className: "nvr-clipchip__v nvr-data", children: v })
1945
+ ]
1946
+ }
1947
+ );
1948
+ };
1949
+ let note = null;
1950
+ const st = job.s === "running" || job.s === "loading" || job.s === "ready" ? job.start : null;
1951
+ if (job.s === "error") {
1952
+ note = { text: t(`nvr.clip.${job.kind}`, job.vars), tone: job.kind === "expired" ? "info" : "bad" };
1953
+ } else if (job.s === "ready" && job.ways.save === "safari") note = { text: t("nvr.clip.tooLarge"), tone: "info" };
1954
+ else if (st) {
1955
+ if (st.clipped) note = { text: t("nvr.clip.endsAt", { time: fmtClipTime(st.to, locale) }), tone: "info" };
1956
+ else if (st.gaps?.length) note = { text: t("nvr.clip.gaps"), tone: "info" };
1957
+ } else if (job.s === "starting") note = null;
1958
+ else if (hints.tooLong) note = { text: t("nvr.clip.tooLong", { max: CLIP_MAX_MS / 6e4 }), tone: "bad" };
1959
+ else if (hints.noRecording) note = { text: t("nvr.clip.noRecording"), tone: "bad" };
1960
+ else if (p.edge) note = { text: t("nvr.clip.edgeHint"), tone: "info" };
1961
+ else if (p.open) note = { text: t("nvr.clip.eventRunning"), tone: "info" };
1962
+ else if (hints.endsAt != null)
1963
+ note = { text: t("nvr.clip.endsAt", { time: fmtClipTime(hints.endsAt, locale) }), tone: "info" };
1964
+ else if (hints.gaps) note = { text: t("nvr.clip.gaps"), tone: "info" };
1965
+ const lenText = t("nvr.clip.length", { d: clipLength(p.range) });
1966
+ const ready = job.s === "ready" || job.s === "loading" ? job : null;
1967
+ const fileUrl = ready ? client.exportFileUrl(ready.id) : "";
1968
+ let state = null;
1969
+ let pct = null;
1970
+ let actions;
1971
+ if (job.s === "starting" || job.s === "running") {
1972
+ pct = job.s === "running" ? Math.round(job.pct * 100) : 0;
1973
+ state = t("nvr.clip.preparing", { pct });
1974
+ actions = /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-btn nvr-btn--ghost", onClick: cancel, children: t("nvr.clip.cancel") });
1975
+ } else if (ready) {
1976
+ state = job.s === "loading" ? t("nvr.clip.loading") : t("nvr.clip.ready", { size: humanBytes(ready.bytes, locale) });
1977
+ const save = ready.ways.save === "safari" ? /* @__PURE__ */ jsx9(
1978
+ "a",
1979
+ {
1980
+ className: "nvr-btn nvr-btn--primary",
1981
+ href: outsideAppHref(fileUrl),
1982
+ target: "_blank",
1983
+ rel: "noopener noreferrer",
1984
+ onClick: () => log("safari"),
1985
+ children: t("nvr.player.openInSafari")
1986
+ }
1987
+ ) : ready.ways.save === "blob" ? job.s === "ready" && job.blobUrl ? /* @__PURE__ */ jsx9(
1988
+ "a",
1989
+ {
1990
+ className: "nvr-btn nvr-btn--primary",
1991
+ href: job.blobUrl,
1992
+ download: ready.filename,
1993
+ onClick: () => log("blob"),
1994
+ children: t("nvr.clip.save")
1995
+ }
1996
+ ) : /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-btn nvr-btn--primary", disabled: true, children: t("nvr.clip.save") }) : /* @__PURE__ */ jsx9(
1997
+ "a",
1998
+ {
1999
+ className: "nvr-btn nvr-btn--primary",
2000
+ href: fileUrl,
2001
+ download: ready.filename,
2002
+ onClick: () => log("download"),
2003
+ children: t("nvr.clip.save")
2004
+ }
2005
+ );
2006
+ actions = /* @__PURE__ */ jsxs7(Fragment7, { children: [
2007
+ save,
2008
+ ready.ways.share && /* @__PURE__ */ jsxs7(
2009
+ "button",
2010
+ {
2011
+ type: "button",
2012
+ className: "nvr-btn nvr-btn--ghost",
2013
+ disabled: !(job.s === "ready" && job.file),
2014
+ onClick: share,
2015
+ children: [
2016
+ /* @__PURE__ */ jsx9(Share2, { size: 16 }),
2017
+ t("nvr.clip.share")
2018
+ ]
2019
+ }
2020
+ )
2021
+ ] });
2022
+ } else {
2023
+ const again = job.s === "error" && job.kind === "expired";
2024
+ actions = /* @__PURE__ */ jsx9(
2025
+ "button",
2026
+ {
2027
+ type: "button",
2028
+ className: "nvr-btn nvr-btn--primary",
2029
+ disabled: !hints.canCreate,
2030
+ onClick: () => void create(),
2031
+ children: t(again ? "nvr.clip.recreate" : "nvr.clip.create")
2032
+ }
2033
+ );
2034
+ }
2035
+ return /* @__PURE__ */ jsxs7("div", { className: "nvr-clipbar", role: "group", "aria-label": t("nvr.clip.download"), children: [
2036
+ /* @__PURE__ */ jsxs7("div", { className: "nvr-clipbar__row", children: [
2037
+ chip("from"),
2038
+ chip("to"),
2039
+ /* @__PURE__ */ jsx9(
2040
+ "button",
2041
+ {
2042
+ type: "button",
2043
+ className: "nvr-iconbtn nvr-clipbar__close",
2044
+ "aria-label": t("nvr.clip.close"),
2045
+ onClick: p.onClose,
2046
+ children: /* @__PURE__ */ jsx9(X, { size: 16 })
2047
+ }
2048
+ )
2049
+ ] }),
2050
+ /* @__PURE__ */ jsxs7(
2051
+ "div",
2052
+ {
2053
+ className: "nvr-clipbar__note" + (note?.tone === "bad" ? " nvr-clipbar__note--bad" : ""),
2054
+ title: [lenText, state, note?.text].filter(Boolean).join(" \xB7 "),
2055
+ children: [
2056
+ /* @__PURE__ */ jsx9("span", { className: "nvr-clipbar__len nvr-data", children: lenText }),
2057
+ /* @__PURE__ */ jsxs7("span", { role: "status", children: [
2058
+ state && /* @__PURE__ */ jsxs7(Fragment7, { children: [
2059
+ " \xB7 ",
2060
+ /* @__PURE__ */ jsx9("span", { className: "nvr-clipbar__state", children: state })
2061
+ ] }),
2062
+ note && /* @__PURE__ */ jsxs7(Fragment7, { children: [
2063
+ " \xB7 ",
2064
+ /* @__PURE__ */ jsx9("span", { className: note.tone === "bad" ? "nvr-clipbar__bad" : void 0, children: note.text })
2065
+ ] })
2066
+ ] })
2067
+ ]
2068
+ }
2069
+ ),
2070
+ pct != null && /* @__PURE__ */ jsx9("div", { className: "nvr-clipbar__prog", "aria-hidden": "true", children: /* @__PURE__ */ jsx9("i", { style: { width: `${pct}%` } }) }),
2071
+ /* @__PURE__ */ jsx9("div", { className: "nvr-clipbar__row nvr-clipbar__actions", children: actions })
2072
+ ] });
2073
+ }
2074
+
1536
2075
  // src/ui/components/CameraPage.tsx
1537
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
2076
+ import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
1538
2077
  var IDLE = {
1539
2078
  live: true,
1540
2079
  label: "live",
@@ -1548,37 +2087,37 @@ var IDLE = {
1548
2087
  var todayStart = () => sentinelDayOf(Date.now());
1549
2088
  function CameraTitle({ name, onBack, children }) {
1550
2089
  const { t } = useSentinelUi();
1551
- return /* @__PURE__ */ jsxs7("div", { className: "nvr-cam__head", children: [
1552
- /* @__PURE__ */ jsxs7("div", { className: "nvr-cam__title", children: [
1553
- /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.back"), onClick: onBack, children: /* @__PURE__ */ jsx9(ChevronLeft2, { size: 20 }) }),
1554
- /* @__PURE__ */ jsx9("h1", { className: "nvr-cam__h1", children: name })
2090
+ return /* @__PURE__ */ jsxs8("div", { className: "nvr-cam__head", children: [
2091
+ /* @__PURE__ */ jsxs8("div", { className: "nvr-cam__title", children: [
2092
+ /* @__PURE__ */ jsx10("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.back"), onClick: onBack, children: /* @__PURE__ */ jsx10(ChevronLeft2, { size: 20 }) }),
2093
+ /* @__PURE__ */ jsx10("h1", { className: "nvr-cam__h1", children: name })
1555
2094
  ] }),
1556
- children ? /* @__PURE__ */ jsx9("div", { className: "nvr-cam__actions", children }) : null
2095
+ children ? /* @__PURE__ */ jsx10("div", { className: "nvr-cam__actions", children }) : null
1557
2096
  ] });
1558
2097
  }
1559
2098
  function CameraPage(p) {
1560
2099
  const { client, t, locale } = useSentinelUi();
1561
2100
  const { camId, name, earliest, startAt = 0, posterTs = 0 } = p;
1562
- const [days, setDays] = useState4({});
1563
- const [nowTick, setNowTick] = useState4(Date.now());
1564
- useEffect3(() => {
2101
+ const [days, setDays] = useState5({});
2102
+ const [nowTick, setNowTick] = useState5(Date.now());
2103
+ useEffect4(() => {
1565
2104
  const i = setInterval(() => setNowTick(Date.now()), 3e4);
1566
2105
  return () => clearInterval(i);
1567
2106
  }, []);
1568
- const [centerDay, setCenterDay] = useState4(todayStart());
1569
- const [jump, setJump] = useState4(null);
1570
- const [tab, setTab] = useState4("tl");
1571
- const [filterOff, setFilterOff] = useState4({});
1572
- const [ps, setPs] = useState4(IDLE);
1573
- const [loadError, setLoadError] = useState4(false);
1574
- const [dt, setDt] = useState4(false);
1575
- const [pipNote, setPipNote] = useState4(null);
1576
- useEffect3(() => {
2107
+ const [centerDay, setCenterDay] = useState5(todayStart());
2108
+ const [jump, setJump] = useState5(null);
2109
+ const [tab, setTab] = useState5("tl");
2110
+ const [filterOff, setFilterOff] = useState5({});
2111
+ const [ps, setPs] = useState5(IDLE);
2112
+ const [loadError, setLoadError] = useState5(false);
2113
+ const [dt, setDt] = useState5(false);
2114
+ const [pipNote, setPipNote] = useState5(null);
2115
+ useEffect4(() => {
1577
2116
  if (!pipNote) return;
1578
2117
  const i = setTimeout(() => setPipNote(null), 15e3);
1579
2118
  return () => clearTimeout(i);
1580
2119
  }, [pipNote]);
1581
- const onPip = useCallback(() => {
2120
+ const onPip = useCallback2(() => {
1582
2121
  const c = ctl.current;
1583
2122
  if (!c) return;
1584
2123
  void c.pip().then((r) => {
@@ -1586,28 +2125,35 @@ function CameraPage(p) {
1586
2125
  else if (r === "entered") setPipNote(null);
1587
2126
  });
1588
2127
  }, []);
1589
- const body = useRef2(null);
1590
- const stage = useRef2(null);
1591
- const video = useRef2(null);
1592
- const freeze = useRef2(null);
1593
- const img = useRef2(null);
1594
- const ctl = useRef2(null);
1595
- const psRef = useRef2(ps);
2128
+ const body = useRef3(null);
2129
+ const stage = useRef3(null);
2130
+ const video = useRef3(null);
2131
+ const freeze = useRef3(null);
2132
+ const img = useRef3(null);
2133
+ const ctl = useRef3(null);
2134
+ const psRef = useRef3(ps);
1596
2135
  psRef.current = ps;
1597
- const loading = useRef2(/* @__PURE__ */ new Set());
1598
- const daysRef = useRef2(days);
2136
+ const loading = useRef3(/* @__PURE__ */ new Set());
2137
+ const daysRef = useRef3(days);
1599
2138
  daysRef.current = days;
1600
- const camRef = useRef2(camId);
2139
+ const camRef = useRef3(camId);
1601
2140
  camRef.current = camId;
1602
- const deepRef = useRef2("");
1603
- const gestureAt = useRef2(0);
2141
+ const deepRef = useRef3("");
2142
+ const [clip, setClip] = useState5(null);
2143
+ const [clipEdge, setClipEdge] = useState5(null);
2144
+ const clipRef = useRef3(clip);
2145
+ clipRef.current = clip;
2146
+ const clipEdgeRef = useRef3(clipEdge);
2147
+ clipEdgeRef.current = clipEdge;
2148
+ const lineTs = useRef3(null);
2149
+ const gestureAt = useRef3(0);
1604
2150
  const merged = useMemo2(() => {
1605
2151
  const m = sentinelMergeDays(days);
1606
2152
  const rangeStart = m.oldestDay ?? todayStart();
1607
2153
  const rangeEnd = Math.min(sentinelDayEnd(todayStart()), nowTick + 20 * 6e4);
1608
2154
  return { ...m, rangeStart, rangeEnd };
1609
2155
  }, [days, nowTick]);
1610
- const mergedNow = useCallback(() => {
2156
+ const mergedNow = useCallback2(() => {
1611
2157
  const m = sentinelMergeDays(daysRef.current);
1612
2158
  return {
1613
2159
  ...m,
@@ -1615,10 +2161,10 @@ function CameraPage(p) {
1615
2161
  rangeEnd: Math.min(sentinelDayEnd(todayStart()), Date.now() + 20 * 6e4)
1616
2162
  };
1617
2163
  }, []);
1618
- useEffect3(() => {
2164
+ useEffect4(() => {
1619
2165
  ctl.current?.setClips(merged.clips, merged.codecs, merged.rangeStart, merged.rangeEnd);
1620
2166
  }, [merged]);
1621
- const fetchDay = useCallback(
2167
+ const fetchDay = useCallback2(
1622
2168
  async (ds) => {
1623
2169
  const d = await client.getJson(
1624
2170
  `api/clips?camera=${encodeURIComponent(camId)}&start=${ds}&end=${sentinelDayEnd(ds)}`
@@ -1630,7 +2176,7 @@ function CameraPage(p) {
1630
2176
  },
1631
2177
  [client, camId]
1632
2178
  );
1633
- const ensureDay = useCallback(
2179
+ const ensureDay = useCallback2(
1634
2180
  async (ds, force = false) => {
1635
2181
  if (ds > todayStart()) return;
1636
2182
  if (earliest && sentinelAddDays(ds, 1) < sentinelDayOf(earliest)) return;
@@ -1648,15 +2194,16 @@ function CameraPage(p) {
1648
2194
  },
1649
2195
  [fetchDay, earliest, camId]
1650
2196
  );
1651
- const onCenter = useCallback(
2197
+ const onCenter = useCallback2(
1652
2198
  (ts) => {
2199
+ lineTs.current = ts;
1653
2200
  const d = sentinelDayOf(ts);
1654
2201
  setCenterDay(d);
1655
2202
  for (const x of [d, sentinelAddDays(d, -1), sentinelAddDays(d, 1)]) ensureDay(x).catch(() => setLoadError(true));
1656
2203
  },
1657
2204
  [ensureDay]
1658
2205
  );
1659
- useEffect3(() => {
2206
+ useEffect4(() => {
1660
2207
  const st = stage.current, cd = body.current;
1661
2208
  if (!st || !cd) return;
1662
2209
  const sync = () => {
@@ -1669,7 +2216,7 @@ function CameraPage(p) {
1669
2216
  mo.observe(st, { attributes: true, attributeFilter: ["style"] });
1670
2217
  return () => mo.disconnect();
1671
2218
  }, []);
1672
- useEffect3(() => {
2219
+ useEffect4(() => {
1673
2220
  const c = new PlayerController(client, {
1674
2221
  onState: (s) => setPs(s),
1675
2222
  onClipsRefresh: async () => {
@@ -1688,7 +2235,7 @@ function CameraPage(p) {
1688
2235
  delete window.__snvr;
1689
2236
  };
1690
2237
  }, [client]);
1691
- useEffect3(() => {
2238
+ useEffect4(() => {
1692
2239
  const c = ctl.current;
1693
2240
  if (!c || !camId) return;
1694
2241
  c.setCamera(camId, name);
@@ -1696,10 +2243,13 @@ function CameraPage(p) {
1696
2243
  daysRef.current = {};
1697
2244
  setFilterOff({});
1698
2245
  setTab("tl");
2246
+ setClip(null);
2247
+ setClipEdge(null);
1699
2248
  setLoadError(false);
1700
2249
  loading.current.clear();
1701
- if (startAt) c.posterEvent(posterTs || startAt);
1702
- else {
2250
+ if (startAt) {
2251
+ if (posterTs) c.posterEvent(posterTs);
2252
+ } else {
1703
2253
  c.posterFromSnapshot(lastTileSnapshot(camId));
1704
2254
  c.goLive();
1705
2255
  }
@@ -1726,19 +2276,19 @@ function CameraPage(p) {
1726
2276
  });
1727
2277
  deepRef.current = `${camId}|${startAt}`;
1728
2278
  }, [camId, client]);
1729
- useEffect3(() => {
2279
+ useEffect4(() => {
1730
2280
  const key = `${camId}|${startAt}`;
1731
2281
  if (!startAt || !ctl.current || key === deepRef.current) return;
1732
2282
  deepRef.current = key;
1733
2283
  const c = ctl.current;
1734
2284
  c.freezeCurrent();
1735
- c.posterEvent(posterTs || startAt);
2285
+ if (posterTs) c.posterEvent(posterTs);
1736
2286
  goToDay(sentinelDayOf(startAt), startAt).catch(() => setLoadError(true));
1737
2287
  }, [startAt, posterTs]);
1738
- useEffect3(() => {
2288
+ useEffect4(() => {
1739
2289
  if (ctl.current && name) ctl.current.camName = name;
1740
2290
  }, [name]);
1741
- useEffect3(() => {
2291
+ useEffect4(() => {
1742
2292
  const i = setInterval(() => {
1743
2293
  const ok = todayRefreshAllowed({
1744
2294
  hidden: document.visibilityState === "hidden",
@@ -1762,11 +2312,11 @@ function CameraPage(p) {
1762
2312
  [merged.events, filterOff]
1763
2313
  );
1764
2314
  const dayCount = useMemo2(() => eventsOnDay(visEvents, centerDay), [visEvents, centerDay]);
1765
- const goLive = useCallback(() => {
2315
+ const goLive = useCallback2(() => {
1766
2316
  ctl.current?.goLive();
1767
2317
  setJump({ ts: Date.now(), n: Date.now() });
1768
2318
  }, []);
1769
- const playEvent = useCallback((ev) => {
2319
+ const playEvent = useCallback2((ev) => {
1770
2320
  const c = ctl.current;
1771
2321
  if (!c) return;
1772
2322
  setTab("tl");
@@ -1774,7 +2324,7 @@ function CameraPage(p) {
1774
2324
  c.posterEvent(ev.timestamp);
1775
2325
  c.playAt(sentinelEventPlayTs(ev), {});
1776
2326
  }, []);
1777
- const seekTo = useCallback(
2327
+ const seekTo = useCallback2(
1778
2328
  (ts) => {
1779
2329
  const c = ctl.current;
1780
2330
  if (!c) return;
@@ -1787,7 +2337,7 @@ function CameraPage(p) {
1787
2337
  },
1788
2338
  [goLive]
1789
2339
  );
1790
- const jumpEvent = useCallback(
2340
+ const jumpEvent = useCallback2(
1791
2341
  (dir) => {
1792
2342
  const c = ctl.current;
1793
2343
  if (!c) return;
@@ -1807,7 +2357,7 @@ function CameraPage(p) {
1807
2357
  },
1808
2358
  [visEvents, playEvent]
1809
2359
  );
1810
- const goToDay = useCallback(
2360
+ const goToDay = useCallback2(
1811
2361
  async (ds, at2) => {
1812
2362
  const c = ctl.current;
1813
2363
  if (!c) return;
@@ -1833,6 +2383,80 @@ function CameraPage(p) {
1833
2383
  },
1834
2384
  [ensureDay, camId, goLive, mergedNow]
1835
2385
  );
2386
+ const canExport = useMemo2(() => Object.values(days).some((d) => sentinelHasFeature(d, "export")), [days]);
2387
+ const oldestRec = earliest ?? merged.clips[0]?.startTime;
2388
+ const clipEvent = useCallback2(
2389
+ (ev) => {
2390
+ const now = Date.now();
2391
+ const r = clipRangeForEvent(ev, now);
2392
+ setClip({ ...clampClipRange(r, { now, oldest: oldestRec }), open: r.open });
2393
+ setClipEdge(null);
2394
+ setTab("tl");
2395
+ const c = ctl.current;
2396
+ if (!c) return;
2397
+ c.freezeCurrent();
2398
+ c.posterEvent(ev.timestamp);
2399
+ c.playAt(Math.max(r.from, oldestRec ?? -Infinity), {});
2400
+ },
2401
+ [oldestRec]
2402
+ );
2403
+ const closeClip = useCallback2(() => {
2404
+ setClip(null);
2405
+ setClipEdge(null);
2406
+ }, []);
2407
+ const toggleClip = useCallback2(() => {
2408
+ if (clipRef.current) {
2409
+ closeClip();
2410
+ return;
2411
+ }
2412
+ const s = psRef.current;
2413
+ setClip(
2414
+ clipProposal({
2415
+ live: s.live,
2416
+ playhead: s.live ? null : ctl.current?.currentTs() ?? s.playhead,
2417
+ now: Date.now(),
2418
+ events: visEvents,
2419
+ oldest: oldestRec
2420
+ })
2421
+ );
2422
+ setClipEdge(null);
2423
+ setTab("tl");
2424
+ }, [closeClip, visEvents, oldestRec]);
2425
+ const activateEdge = useCallback2((e) => {
2426
+ setClipEdge(e);
2427
+ const r = clipRef.current;
2428
+ if (!e || !r) return;
2429
+ const ts = e === "from" ? r.from : r.to;
2430
+ setJump({ ts, n: Date.now() });
2431
+ lineTs.current = ts;
2432
+ const c = ctl.current;
2433
+ if (c && ts < Date.now() - 8e3) {
2434
+ c.freezeCurrent();
2435
+ c.playAt(ts, {});
2436
+ }
2437
+ }, []);
2438
+ const onUserCenter = useCallback2((ts) => {
2439
+ lineTs.current = ts;
2440
+ const e = clipEdgeRef.current, r = clipRef.current;
2441
+ if (!e || !r) return;
2442
+ const n = clipSetEdge(r, e, ts);
2443
+ setClip({ ...n.range, open: false });
2444
+ if (n.edge !== e) setClipEdge(n.edge);
2445
+ }, []);
2446
+ const setEdgeToLine = useCallback2((e) => {
2447
+ const r = clipRef.current;
2448
+ if (!r) return;
2449
+ const s = psRef.current;
2450
+ const ts = clipEdgeRef.current ? lineTs.current : s.live ? Date.now() : ctl.current?.currentTs() ?? lineTs.current;
2451
+ if (ts == null) return;
2452
+ const n = clipSetEdge(r, e, ts);
2453
+ setClip({ ...n.range, open: false });
2454
+ if (clipEdgeRef.current) setClipEdge(n.edge);
2455
+ }, []);
2456
+ const onTimelineEvent = useCallback2(
2457
+ (ev) => clipRef.current ? clipEvent(ev) : playEvent(ev),
2458
+ [clipEvent, playEvent]
2459
+ );
1836
2460
  const scrub = useMemo2(
1837
2461
  () => ({
1838
2462
  begin: () => {
@@ -1858,11 +2482,17 @@ function CameraPage(p) {
1858
2482
  }),
1859
2483
  []
1860
2484
  );
1861
- useEffect3(() => {
2485
+ useEffect4(() => {
1862
2486
  const k = (e) => {
1863
2487
  if (dt || !shouldHandleKey(e)) return;
1864
2488
  const c = ctl.current;
1865
2489
  if (!c) return;
2490
+ if (clipRef.current && (e.key === "Escape" || e.key === "i" || e.key === "o")) {
2491
+ e.preventDefault();
2492
+ if (e.key === "Escape") closeClip();
2493
+ else setEdgeToLine(e.key === "i" ? "from" : "to");
2494
+ return;
2495
+ }
1866
2496
  if (e.key === " ") {
1867
2497
  e.preventDefault();
1868
2498
  c.togglePlayPause();
@@ -1877,7 +2507,7 @@ function CameraPage(p) {
1877
2507
  };
1878
2508
  document.addEventListener("keydown", k);
1879
2509
  return () => document.removeEventListener("keydown", k);
1880
- }, [dt, jumpEvent, goLive]);
2510
+ }, [dt, jumpEvent, goLive, closeClip, setEdgeToLine]);
1881
2511
  const mjpeg = ps.transport === "mjpeg";
1882
2512
  const oldestAllowed = earliest ? sentinelDayOf(earliest) : -Infinity;
1883
2513
  const statusText = stageStatus(ps, t, locale, loadError);
@@ -1886,15 +2516,15 @@ function CameraPage(p) {
1886
2516
  const at = !ps.live && ps.playhead != null ? ps.playhead : void 0;
1887
2517
  const header = typeof p.header === "function" ? p.header(at) : p.header;
1888
2518
  const externalUrl = typeof p.externalUrl === "function" ? p.externalUrl(at) : p.externalUrl;
1889
- return /* @__PURE__ */ jsxs7("div", { className: "nvr-cam", children: [
2519
+ return /* @__PURE__ */ jsxs8("div", { className: "nvr-cam", children: [
1890
2520
  header,
1891
- /* @__PURE__ */ jsxs7("div", { className: "nvr-cam__body", ref: body, children: [
1892
- /* @__PURE__ */ jsx9("div", { className: "nvr-cam__left", children: /* @__PURE__ */ jsxs7("div", { className: "nvr-card nvr-stage-card", children: [
1893
- /* @__PURE__ */ jsx9("div", { className: "nvr-stage-wrap", children: /* @__PURE__ */ jsxs7("div", { className: "nvr-stage", ref: stage, children: [
1894
- /* @__PURE__ */ jsx9("video", { ref: video, playsInline: true, autoPlay: true, muted: true, crossOrigin: cors, className: "nvr-stage__video" }),
1895
- /* @__PURE__ */ jsx9("img", { ref: img, crossOrigin: cors, className: "nvr-stage__video nvr-stage__img hidden", alt: "" }),
1896
- /* @__PURE__ */ jsx9("canvas", { ref: freeze, className: "nvr-stage__video nvr-stage__freeze hidden" }),
1897
- !mjpeg && /* @__PURE__ */ jsx9(
2521
+ /* @__PURE__ */ jsxs8("div", { className: "nvr-cam__body" + (clip ? " nvr-cam__body--clip" : ""), ref: body, children: [
2522
+ /* @__PURE__ */ jsx10("div", { className: "nvr-cam__left", children: /* @__PURE__ */ jsxs8("div", { className: "nvr-card nvr-stage-card", children: [
2523
+ /* @__PURE__ */ jsx10("div", { className: "nvr-stage-wrap", children: /* @__PURE__ */ jsxs8("div", { className: "nvr-stage", ref: stage, children: [
2524
+ /* @__PURE__ */ jsx10("video", { ref: video, playsInline: true, autoPlay: true, muted: true, crossOrigin: cors, className: "nvr-stage__video" }),
2525
+ /* @__PURE__ */ jsx10("img", { ref: img, crossOrigin: cors, className: "nvr-stage__video nvr-stage__img hidden", alt: "" }),
2526
+ /* @__PURE__ */ jsx10("canvas", { ref: freeze, className: "nvr-stage__video nvr-stage__freeze hidden" }),
2527
+ !mjpeg && /* @__PURE__ */ jsx10(
1898
2528
  "button",
1899
2529
  {
1900
2530
  type: "button",
@@ -1902,21 +2532,21 @@ function CameraPage(p) {
1902
2532
  "aria-label": t("nvr.player.sound"),
1903
2533
  "aria-pressed": ps.sound,
1904
2534
  onClick: () => ctl.current?.setSound(!ps.sound),
1905
- children: ps.sound && !ps.muted ? /* @__PURE__ */ jsx9(Volume2, { size: 18 }) : /* @__PURE__ */ jsx9(VolumeX, { size: 18 })
2535
+ children: ps.sound && !ps.muted ? /* @__PURE__ */ jsx10(Volume2, { size: 18 }) : /* @__PURE__ */ jsx10(VolumeX, { size: 18 })
1906
2536
  }
1907
2537
  ),
1908
- /* @__PURE__ */ jsxs7("div", { className: "nvr-pill-ctl" + (ps.live ? " nvr-pill-ctl--live" : ""), children: [
1909
- /* @__PURE__ */ jsx9(
2538
+ /* @__PURE__ */ jsxs8("div", { className: "nvr-pill-ctl" + (ps.live ? " nvr-pill-ctl--live" : ""), children: [
2539
+ /* @__PURE__ */ jsx10(
1910
2540
  "button",
1911
2541
  {
1912
2542
  type: "button",
1913
2543
  className: "nvr-pb",
1914
2544
  "aria-label": t("nvr.player.back15"),
1915
2545
  onClick: () => ctl.current?.skip(-15e3),
1916
- children: /* @__PURE__ */ jsx9(Rewind, { size: 18 })
2546
+ children: /* @__PURE__ */ jsx10(Rewind, { size: 18 })
1917
2547
  }
1918
2548
  ),
1919
- /* @__PURE__ */ jsx9(
2549
+ /* @__PURE__ */ jsx10(
1920
2550
  "button",
1921
2551
  {
1922
2552
  type: "button",
@@ -1924,10 +2554,10 @@ function CameraPage(p) {
1924
2554
  "aria-label": ps.paused ? t("nvr.player.play") : t("nvr.player.pause"),
1925
2555
  disabled: ps.live,
1926
2556
  onClick: () => ctl.current?.togglePlayPause(),
1927
- children: ps.paused ? /* @__PURE__ */ jsx9(Play, { size: 18 }) : /* @__PURE__ */ jsx9(Pause, { size: 18 })
2557
+ children: ps.paused ? /* @__PURE__ */ jsx10(Play, { size: 18 }) : /* @__PURE__ */ jsx10(Pause, { size: 18 })
1928
2558
  }
1929
2559
  ),
1930
- /* @__PURE__ */ jsx9(
2560
+ /* @__PURE__ */ jsx10(
1931
2561
  "button",
1932
2562
  {
1933
2563
  type: "button",
@@ -1935,10 +2565,10 @@ function CameraPage(p) {
1935
2565
  "aria-label": t("nvr.player.fwd15"),
1936
2566
  disabled: ps.live,
1937
2567
  onClick: () => ctl.current?.skip(15e3),
1938
- children: /* @__PURE__ */ jsx9(FastForward, { size: 18 })
2568
+ children: /* @__PURE__ */ jsx10(FastForward, { size: 18 })
1939
2569
  }
1940
2570
  ),
1941
- /* @__PURE__ */ jsxs7(
2571
+ /* @__PURE__ */ jsxs8(
1942
2572
  "button",
1943
2573
  {
1944
2574
  type: "button",
@@ -1954,39 +2584,51 @@ function CameraPage(p) {
1954
2584
  )
1955
2585
  ] })
1956
2586
  ] }) }),
1957
- /* @__PURE__ */ jsxs7("div", { className: "nvr-stage-bar", children: [
1958
- /* @__PURE__ */ jsx9("span", { className: "nvr-statusdot" + (ps.live ? " nvr-statusdot--live" : ""), "aria-hidden": "true" }),
1959
- /* @__PURE__ */ jsxs7("span", { className: "nvr-stage-title", children: [
1960
- /* @__PURE__ */ jsx9("b", { children: name }),
1961
- /* @__PURE__ */ jsx9("small", { children: statusText })
2587
+ /* @__PURE__ */ jsxs8("div", { className: "nvr-stage-bar", children: [
2588
+ /* @__PURE__ */ jsx10("span", { className: "nvr-statusdot" + (ps.live ? " nvr-statusdot--live" : ""), "aria-hidden": "true" }),
2589
+ /* @__PURE__ */ jsxs8("span", { className: "nvr-stage-title", children: [
2590
+ /* @__PURE__ */ jsx10("b", { children: name }),
2591
+ /* @__PURE__ */ jsx10("small", { children: statusText })
1962
2592
  ] }),
1963
- /* @__PURE__ */ jsxs7("span", { className: "nvr-stage-actions", children: [
1964
- /* @__PURE__ */ jsx9(
2593
+ /* @__PURE__ */ jsxs8("span", { className: "nvr-stage-actions", children: [
2594
+ /* @__PURE__ */ jsx10(
1965
2595
  "button",
1966
2596
  {
1967
2597
  type: "button",
1968
2598
  className: "nvr-iconbtn",
1969
2599
  "aria-label": t("nvr.player.snapshot"),
1970
2600
  onClick: () => ctl.current?.snapshot(),
1971
- children: /* @__PURE__ */ jsx9(Camera2, { size: 16 })
2601
+ children: /* @__PURE__ */ jsx10(Camera2, { size: 16 })
2602
+ }
2603
+ ),
2604
+ canExport && /* @__PURE__ */ jsx10(
2605
+ "button",
2606
+ {
2607
+ type: "button",
2608
+ className: "nvr-iconbtn" + (clip ? " nvr-iconbtn--on" : ""),
2609
+ "aria-label": t("nvr.clip.download"),
2610
+ title: t("nvr.clip.download"),
2611
+ "aria-pressed": !!clip,
2612
+ onClick: toggleClip,
2613
+ children: /* @__PURE__ */ jsx10(Download2, { size: 16 })
1972
2614
  }
1973
2615
  ),
1974
- /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.player.pip"), onClick: onPip, children: /* @__PURE__ */ jsx9(PictureInPicture2, { size: 16 }) }),
1975
- /* @__PURE__ */ jsx9(
2616
+ /* @__PURE__ */ jsx10("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.player.pip"), onClick: onPip, children: /* @__PURE__ */ jsx10(PictureInPicture2, { size: 16 }) }),
2617
+ /* @__PURE__ */ jsx10(
1976
2618
  "button",
1977
2619
  {
1978
2620
  type: "button",
1979
2621
  className: "nvr-iconbtn",
1980
2622
  "aria-label": t("nvr.player.fullscreen"),
1981
2623
  onClick: () => ctl.current?.fullscreen(),
1982
- children: /* @__PURE__ */ jsx9(Maximize2, { size: 16 })
2624
+ children: /* @__PURE__ */ jsx10(Maximize2, { size: 16 })
1983
2625
  }
1984
2626
  )
1985
2627
  ] })
1986
2628
  ] }),
1987
- pipNote && /* @__PURE__ */ jsxs7("div", { className: "nvr-pipnote", role: "status", children: [
1988
- /* @__PURE__ */ jsx9("span", { children: t(pipNote === "homescreen" ? "nvr.player.pipHomeScreen" : "nvr.player.pipUnsupported") }),
1989
- pipNote === "homescreen" && externalUrl && /* @__PURE__ */ jsx9(
2629
+ pipNote && /* @__PURE__ */ jsxs8("div", { className: "nvr-pipnote", role: "status", children: [
2630
+ /* @__PURE__ */ jsx10("span", { children: t(pipNote === "homescreen" ? "nvr.player.pipHomeScreen" : "nvr.player.pipUnsupported") }),
2631
+ pipNote === "homescreen" && externalUrl && /* @__PURE__ */ jsx10(
1990
2632
  "a",
1991
2633
  {
1992
2634
  className: "nvr-pipnote__open",
@@ -1997,21 +2639,21 @@ function CameraPage(p) {
1997
2639
  children: t("nvr.player.openInSafari")
1998
2640
  }
1999
2641
  ),
2000
- /* @__PURE__ */ jsx9(
2642
+ /* @__PURE__ */ jsx10(
2001
2643
  "button",
2002
2644
  {
2003
2645
  type: "button",
2004
2646
  className: "nvr-iconbtn nvr-pipnote__close",
2005
2647
  "aria-label": t("nvr.player.dismiss"),
2006
2648
  onClick: () => setPipNote(null),
2007
- children: /* @__PURE__ */ jsx9(X, { size: 14 })
2649
+ children: /* @__PURE__ */ jsx10(X2, { size: 14 })
2008
2650
  }
2009
2651
  )
2010
2652
  ] })
2011
2653
  ] }) }),
2012
- /* @__PURE__ */ jsxs7("aside", { className: "nvr-card nvr-cam__right", children: [
2013
- /* @__PURE__ */ jsxs7("div", { className: "nvr-tabs", role: "tablist", children: [
2014
- /* @__PURE__ */ jsx9(
2654
+ /* @__PURE__ */ jsxs8("aside", { className: "nvr-card nvr-cam__right" + (clip ? " nvr-cam__right--clip" : ""), children: [
2655
+ /* @__PURE__ */ jsxs8("div", { className: "nvr-tabs", role: "tablist", children: [
2656
+ /* @__PURE__ */ jsx10(
2015
2657
  "button",
2016
2658
  {
2017
2659
  type: "button",
@@ -2022,7 +2664,7 @@ function CameraPage(p) {
2022
2664
  children: t("nvr.tab.timeline")
2023
2665
  }
2024
2666
  ),
2025
- /* @__PURE__ */ jsxs7(
2667
+ /* @__PURE__ */ jsxs8(
2026
2668
  "button",
2027
2669
  {
2028
2670
  type: "button",
@@ -2037,7 +2679,7 @@ function CameraPage(p) {
2037
2679
  }
2038
2680
  )
2039
2681
  ] }),
2040
- /* @__PURE__ */ jsx9("div", { className: "nvr-filters", children: SENTINEL_EVENT_CLASSES.filter((k) => present[k]).map((k) => /* @__PURE__ */ jsxs7(
2682
+ /* @__PURE__ */ jsx10("div", { className: "nvr-filters", children: SENTINEL_EVENT_CLASSES.filter((k) => present[k]).map((k) => /* @__PURE__ */ jsxs8(
2041
2683
  "button",
2042
2684
  {
2043
2685
  type: "button",
@@ -2046,13 +2688,13 @@ function CameraPage(p) {
2046
2688
  title: classLabel(t, k),
2047
2689
  "aria-pressed": !filterOff[k],
2048
2690
  children: [
2049
- /* @__PURE__ */ jsx9(ClassBadge, { cls: k, size: 18 }),
2691
+ /* @__PURE__ */ jsx10(ClassBadge, { cls: k, size: 18 }),
2050
2692
  present[k]
2051
2693
  ]
2052
2694
  },
2053
2695
  k
2054
2696
  )) }),
2055
- tab === "tl" ? /* @__PURE__ */ jsx9(
2697
+ tab === "tl" ? /* @__PURE__ */ jsx10(
2056
2698
  VerticalTimeline,
2057
2699
  {
2058
2700
  camId,
@@ -2065,26 +2707,51 @@ function CameraPage(p) {
2065
2707
  playhead: () => ctl.current?.currentTs() ?? null,
2066
2708
  following: () => !psRef.current.paused && !ctl.current?.scrubSettling(),
2067
2709
  filterOff,
2068
- onEvent: playEvent,
2710
+ onEvent: onTimelineEvent,
2069
2711
  onSeekTo: seekTo,
2070
2712
  onGoLive: goLive,
2071
2713
  scrub,
2072
2714
  onCenter,
2073
- jump
2715
+ jump,
2716
+ clip: clip ? { from: clip.from, to: clip.to, edge: clipEdge, bad: clip.to - clip.from > CLIP_MAX_MS } : null,
2717
+ hold: !!clip && !!clipEdge,
2718
+ onUserCenter
2074
2719
  }
2075
- ) : /* @__PURE__ */ jsx9(EventList, { camId, events: merged.events, filterOff, onPick: playEvent }),
2076
- /* @__PURE__ */ jsxs7("div", { className: "nvr-datechip" + (ps.live ? "" : " nvr-datechip--rec"), children: [
2077
- /* @__PURE__ */ jsx9(
2720
+ ) : /* @__PURE__ */ jsx10(
2721
+ EventList,
2722
+ {
2723
+ camId,
2724
+ events: merged.events,
2725
+ filterOff,
2726
+ onPick: playEvent,
2727
+ onClip: canExport ? clipEvent : void 0
2728
+ }
2729
+ ),
2730
+ clip && /* @__PURE__ */ jsx10(
2731
+ ClipBar,
2732
+ {
2733
+ camId,
2734
+ range: clip,
2735
+ open: clip.open,
2736
+ edge: clipEdge,
2737
+ clips: merged.clips,
2738
+ onEdge: activateEdge,
2739
+ onClose: closeClip
2740
+ },
2741
+ camId
2742
+ ),
2743
+ !clip && /* @__PURE__ */ jsxs8("div", { className: "nvr-datechip" + (ps.live ? "" : " nvr-datechip--rec"), children: [
2744
+ /* @__PURE__ */ jsx10(
2078
2745
  "button",
2079
2746
  {
2080
2747
  type: "button",
2081
2748
  onClick: () => goToDay(sentinelAddDays(centerDay, -1)).catch(() => setLoadError(true)),
2082
2749
  disabled: nav.prevDisabled,
2083
2750
  "aria-label": t("nvr.date.prevDay"),
2084
- children: /* @__PURE__ */ jsx9(ChevronLeft2, { size: 14 })
2751
+ children: /* @__PURE__ */ jsx10(ChevronLeft2, { size: 14 })
2085
2752
  }
2086
2753
  ),
2087
- /* @__PURE__ */ jsxs7(
2754
+ /* @__PURE__ */ jsxs8(
2088
2755
  "button",
2089
2756
  {
2090
2757
  type: "button",
@@ -2092,19 +2759,19 @@ function CameraPage(p) {
2092
2759
  onClick: () => setDt(true),
2093
2760
  "aria-label": t("nvr.date.title"),
2094
2761
  children: [
2095
- /* @__PURE__ */ jsx9(Calendar, { size: 13 }),
2762
+ /* @__PURE__ */ jsx10(Calendar, { size: 13 }),
2096
2763
  fmtDay(centerDay, locale)
2097
2764
  ]
2098
2765
  }
2099
2766
  ),
2100
- /* @__PURE__ */ jsx9(
2767
+ /* @__PURE__ */ jsx10(
2101
2768
  "button",
2102
2769
  {
2103
2770
  type: "button",
2104
2771
  onClick: () => goToDay(sentinelAddDays(centerDay, 1)).catch(() => setLoadError(true)),
2105
2772
  disabled: nav.nextDisabled,
2106
2773
  "aria-label": t("nvr.date.nextDay"),
2107
- children: /* @__PURE__ */ jsx9(ChevronRight2, { size: 14 })
2774
+ children: /* @__PURE__ */ jsx10(ChevronRight2, { size: 14 })
2108
2775
  }
2109
2776
  )
2110
2777
  ] })
@@ -2125,9 +2792,9 @@ function CameraPage(p) {
2125
2792
  }
2126
2793
 
2127
2794
  // src/ui/components/Appearance.tsx
2128
- import { useState as useState5 } from "react";
2795
+ import { useState as useState6 } from "react";
2129
2796
  import { ChevronDown, Languages, Palette, Sun } from "lucide-react";
2130
- import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
2797
+ import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
2131
2798
  function hexHue(hex) {
2132
2799
  const r = parseInt(hex.slice(1, 3), 16) / 255, g = parseInt(hex.slice(3, 5), 16) / 255, b = parseInt(hex.slice(5, 7), 16) / 255;
2133
2800
  const max = Math.max(r, g, b), min = Math.min(r, g, b);
@@ -2147,7 +2814,7 @@ function ThemeSwatch({
2147
2814
  ariaLabel
2148
2815
  }) {
2149
2816
  const c = THEMES[name][previewMode];
2150
- return /* @__PURE__ */ jsxs8(
2817
+ return /* @__PURE__ */ jsxs9(
2151
2818
  "button",
2152
2819
  {
2153
2820
  type: "button",
@@ -2156,8 +2823,8 @@ function ThemeSwatch({
2156
2823
  "aria-label": ariaLabel,
2157
2824
  "aria-pressed": active,
2158
2825
  children: [
2159
- /* @__PURE__ */ jsxs8("div", { className: "nvr-swatch__preview", style: { background: c.bg }, "aria-hidden": "true", children: [
2160
- /* @__PURE__ */ jsx10(
2826
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-swatch__preview", style: { background: c.bg }, "aria-hidden": "true", children: [
2827
+ /* @__PURE__ */ jsx11(
2161
2828
  "div",
2162
2829
  {
2163
2830
  style: {
@@ -2172,7 +2839,7 @@ function ThemeSwatch({
2172
2839
  }
2173
2840
  }
2174
2841
  ),
2175
- /* @__PURE__ */ jsx10(
2842
+ /* @__PURE__ */ jsx11(
2176
2843
  "div",
2177
2844
  {
2178
2845
  style: {
@@ -2186,7 +2853,7 @@ function ThemeSwatch({
2186
2853
  }
2187
2854
  }
2188
2855
  ),
2189
- /* @__PURE__ */ jsx10(
2856
+ /* @__PURE__ */ jsx11(
2190
2857
  "div",
2191
2858
  {
2192
2859
  style: {
@@ -2201,7 +2868,7 @@ function ThemeSwatch({
2201
2868
  }
2202
2869
  }
2203
2870
  ),
2204
- /* @__PURE__ */ jsx10(
2871
+ /* @__PURE__ */ jsx11(
2205
2872
  "div",
2206
2873
  {
2207
2874
  style: {
@@ -2217,7 +2884,7 @@ function ThemeSwatch({
2217
2884
  }
2218
2885
  )
2219
2886
  ] }),
2220
- /* @__PURE__ */ jsx10("span", { className: "nvr-swatch__name", children: THEME_LABELS[name] })
2887
+ /* @__PURE__ */ jsx11("span", { className: "nvr-swatch__name", children: THEME_LABELS[name] })
2221
2888
  ]
2222
2889
  }
2223
2890
  );
@@ -2226,19 +2893,19 @@ function AppearanceSection(p) {
2226
2893
  const { t } = useSentinelUi();
2227
2894
  const resolved = resolveMode(p.mode);
2228
2895
  const defaultHue = (name) => hexHue(THEMES[name][resolved].accent);
2229
- const [localHue, setLocalHue] = useState5(p.accentHue ?? defaultHue(p.theme));
2896
+ const [localHue, setLocalHue] = useState6(p.accentHue ?? defaultHue(p.theme));
2230
2897
  const previewColor = p.accentHue !== void 0 ? `hsl(${p.accentHue}, 78%, ${resolved === "dark" ? 60 : 50}%)` : THEMES[p.theme][resolved].accent;
2231
2898
  const modes = ["light", "dark", "auto"];
2232
- const chip = (bg, fg, icon) => /* @__PURE__ */ jsx10("span", { className: "nvr-set__chip", style: { background: bg, color: fg }, children: icon });
2233
- return /* @__PURE__ */ jsxs8("section", { className: "nvr-set__section", children: [
2234
- /* @__PURE__ */ jsx10("div", { className: "nvr-section__label", children: t("nvr.settings.appearance") }),
2235
- /* @__PURE__ */ jsxs8("div", { className: "nvr-card nvr-set-card", children: [
2236
- /* @__PURE__ */ jsxs8("div", { className: "nvr-set__row nvr-set__row--inline", children: [
2237
- /* @__PURE__ */ jsxs8("span", { className: "nvr-set__label", children: [
2238
- chip("var(--warning-soft)", "var(--warning)", /* @__PURE__ */ jsx10(Sun, { size: 14, strokeWidth: 1.75 })),
2899
+ const chip = (bg, fg, icon) => /* @__PURE__ */ jsx11("span", { className: "nvr-set__chip", style: { background: bg, color: fg }, children: icon });
2900
+ return /* @__PURE__ */ jsxs9("section", { className: "nvr-set__section", children: [
2901
+ /* @__PURE__ */ jsx11("div", { className: "nvr-section__label", children: t("nvr.settings.appearance") }),
2902
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-card nvr-set-card", children: [
2903
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-set__row nvr-set__row--inline", children: [
2904
+ /* @__PURE__ */ jsxs9("span", { className: "nvr-set__label", children: [
2905
+ chip("var(--warning-soft)", "var(--warning)", /* @__PURE__ */ jsx11(Sun, { size: 14, strokeWidth: 1.75 })),
2239
2906
  t("nvr.settings.mode")
2240
2907
  ] }),
2241
- /* @__PURE__ */ jsx10("div", { className: "nvr-seg", role: "group", "aria-label": t("nvr.settings.mode"), children: modes.map((m) => /* @__PURE__ */ jsx10(
2908
+ /* @__PURE__ */ jsx11("div", { className: "nvr-seg", role: "group", "aria-label": t("nvr.settings.mode"), children: modes.map((m) => /* @__PURE__ */ jsx11(
2242
2909
  "button",
2243
2910
  {
2244
2911
  type: "button",
@@ -2250,13 +2917,13 @@ function AppearanceSection(p) {
2250
2917
  m
2251
2918
  )) })
2252
2919
  ] }),
2253
- /* @__PURE__ */ jsxs8("div", { className: "nvr-set__row nvr-set__row--inline", children: [
2254
- /* @__PURE__ */ jsxs8("span", { className: "nvr-set__label", children: [
2255
- chip("var(--accent-soft)", "var(--accent)", /* @__PURE__ */ jsx10(Languages, { size: 14, strokeWidth: 1.75 })),
2920
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-set__row nvr-set__row--inline", children: [
2921
+ /* @__PURE__ */ jsxs9("span", { className: "nvr-set__label", children: [
2922
+ chip("var(--accent-soft)", "var(--accent)", /* @__PURE__ */ jsx11(Languages, { size: 14, strokeWidth: 1.75 })),
2256
2923
  t("nvr.settings.language")
2257
2924
  ] }),
2258
- /* @__PURE__ */ jsxs8("div", { className: "nvr-select", children: [
2259
- /* @__PURE__ */ jsxs8(
2925
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-select", children: [
2926
+ /* @__PURE__ */ jsxs9(
2260
2927
  "select",
2261
2928
  {
2262
2929
  className: "nvr-select__native",
@@ -2264,20 +2931,20 @@ function AppearanceSection(p) {
2264
2931
  onChange: (e) => p.onLanguage(e.target.value),
2265
2932
  "aria-label": t("nvr.settings.language"),
2266
2933
  children: [
2267
- /* @__PURE__ */ jsx10("option", { value: "auto", children: t("nvr.settings.language.auto") }),
2268
- p.languages.map((l) => /* @__PURE__ */ jsx10("option", { value: l.id, children: l.label }, l.id))
2934
+ /* @__PURE__ */ jsx11("option", { value: "auto", children: t("nvr.settings.language.auto") }),
2935
+ p.languages.map((l) => /* @__PURE__ */ jsx11("option", { value: l.id, children: l.label }, l.id))
2269
2936
  ]
2270
2937
  }
2271
2938
  ),
2272
- /* @__PURE__ */ jsx10(ChevronDown, { size: 14, strokeWidth: 2, className: "nvr-select__chevron", "aria-hidden": "true" })
2939
+ /* @__PURE__ */ jsx11(ChevronDown, { size: 14, strokeWidth: 2, className: "nvr-select__chevron", "aria-hidden": "true" })
2273
2940
  ] })
2274
2941
  ] }),
2275
- /* @__PURE__ */ jsxs8("div", { className: "nvr-set__row", children: [
2276
- /* @__PURE__ */ jsxs8("div", { className: "nvr-set__label", children: [
2277
- chip("var(--accent-soft)", "var(--accent)", /* @__PURE__ */ jsx10(Palette, { size: 14, strokeWidth: 1.75 })),
2942
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-set__row", children: [
2943
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-set__label", children: [
2944
+ chip("var(--accent-soft)", "var(--accent)", /* @__PURE__ */ jsx11(Palette, { size: 14, strokeWidth: 1.75 })),
2278
2945
  t("nvr.settings.theme")
2279
2946
  ] }),
2280
- /* @__PURE__ */ jsx10("div", { className: "nvr-swatches", children: THEME_NAMES.map((n) => /* @__PURE__ */ jsx10(
2947
+ /* @__PURE__ */ jsx11("div", { className: "nvr-swatches", children: THEME_NAMES.map((n) => /* @__PURE__ */ jsx11(
2281
2948
  ThemeSwatch,
2282
2949
  {
2283
2950
  name: n,
@@ -2292,14 +2959,14 @@ function AppearanceSection(p) {
2292
2959
  n
2293
2960
  )) })
2294
2961
  ] }),
2295
- /* @__PURE__ */ jsx10("div", { className: "nvr-set__row", children: /* @__PURE__ */ jsxs8("div", { className: "nvr-accent", children: [
2296
- /* @__PURE__ */ jsxs8("div", { className: "nvr-accent__label", children: [
2297
- /* @__PURE__ */ jsxs8("span", { className: "nvr-set__label", children: [
2298
- chip("var(--accent-soft)", "var(--accent)", /* @__PURE__ */ jsx10(Palette, { size: 14, strokeWidth: 1.75 })),
2962
+ /* @__PURE__ */ jsx11("div", { className: "nvr-set__row", children: /* @__PURE__ */ jsxs9("div", { className: "nvr-accent", children: [
2963
+ /* @__PURE__ */ jsxs9("div", { className: "nvr-accent__label", children: [
2964
+ /* @__PURE__ */ jsxs9("span", { className: "nvr-set__label", children: [
2965
+ chip("var(--accent-soft)", "var(--accent)", /* @__PURE__ */ jsx11(Palette, { size: 14, strokeWidth: 1.75 })),
2299
2966
  t("nvr.settings.accent"),
2300
- /* @__PURE__ */ jsx10("span", { className: "nvr-accent__dot", style: { background: previewColor }, "aria-hidden": "true" })
2967
+ /* @__PURE__ */ jsx11("span", { className: "nvr-accent__dot", style: { background: previewColor }, "aria-hidden": "true" })
2301
2968
  ] }),
2302
- p.accentHue !== void 0 && /* @__PURE__ */ jsx10(
2969
+ p.accentHue !== void 0 && /* @__PURE__ */ jsx11(
2303
2970
  "button",
2304
2971
  {
2305
2972
  type: "button",
@@ -2312,7 +2979,7 @@ function AppearanceSection(p) {
2312
2979
  }
2313
2980
  )
2314
2981
  ] }),
2315
- /* @__PURE__ */ jsx10(
2982
+ /* @__PURE__ */ jsx11(
2316
2983
  "input",
2317
2984
  {
2318
2985
  type: "range",