@nivaro/react 0.3.57 → 0.3.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +5 -1
  4. package/dist/shared/components/CollectionBrowserView.js +2633 -2590
  5. package/dist/shared/components/DataTable.js +247 -236
  6. package/dist/shared/components/ItemEditForm.js +1693 -1668
  7. package/dist/shared/components/ProfileView.js +716 -715
  8. package/dist/shared/components/RecordReadView.js +367 -364
  9. package/dist/shared/components/ReportView.js +64 -39
  10. package/dist/shared/components/alerts/AlertManagerView.js +284 -271
  11. package/dist/shared/components/cbv/row-focus.js +19 -0
  12. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  13. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  14. package/dist/shared/components/integrations/console/tone.js +52 -30
  15. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  16. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  17. package/dist/shared/components/item-edit/InlineTableField.js +407 -402
  18. package/dist/shared/components/item-edit/M2MCombobox.js +313 -291
  19. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  20. package/dist/shared/components/item-edit/PlanGrid.js +826 -803
  21. package/dist/shared/components/item-edit/QuickCreateButton.js +115 -79
  22. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  23. package/dist/shared/components/item-edit/RelationCombobox.js +412 -328
  24. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +147 -125
  25. package/dist/shared/components/item-edit/SummaryPanel.js +406 -392
  26. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  27. package/dist/shared/components/item-edit/related-missing.js +45 -0
  28. package/dist/shared/components/item-edit/save-outcome.js +5 -5
  29. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  30. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  31. package/dist/shared/components/panels/ItemLockBanner.js +2 -3
  32. package/dist/shared/components/panels/PipelinePanel.js +1027 -978
  33. package/dist/shared/components/panels/RevisionsPanel.js +4 -1
  34. package/dist/shared/components/panels/TaskPanel.js +265 -249
  35. package/dist/shared/components/panels/landing-state.js +27 -0
  36. package/dist/shared/components/pipeline/PipelineEditorView.js +86 -78
  37. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  38. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  39. package/dist/shared/components/queue/QueueQuickFilters.js +48 -48
  40. package/dist/shared/components/queue/QueueWorklist.js +357 -358
  41. package/dist/shared/components/queue/group-sums.js +27 -0
  42. package/dist/shared/components/widgets/ReviewListWidget.js +186 -168
  43. package/dist/shared/lib/back-closes.js +25 -0
  44. package/dist/shared/lib/form-usage-beacon.js +7 -7
  45. package/dist/shared/lib/list-page-memory.js +41 -0
  46. package/dist/shared/lib/live.js +44 -44
  47. package/dist/shared/lib/own-writes.js +76 -28
  48. package/dist/shared/lib/request-gate.js +110 -109
  49. package/dist/shared/lib/validation-rules.js +34 -19
  50. package/package.json +1 -1
@@ -1,23 +1,23 @@
1
- import { jsx as t, jsxs as l, Fragment as ht } from "react/jsx-runtime";
2
- import { listNotificationSubscriptions as ut, deleteNotificationSubscription as pt } from "@nivaro/sdk";
3
- import { useQueryClient as xt, useQuery as v, useMutation as ce } from "@tanstack/react-query";
4
- import { LayoutGrid as Te, Bell as $e, BellRing as me, Clock as bt, ChartColumn as gt, History as Re, FlaskConical as qe, Activity as ft, Plus as he, Gauge as yt, Users as vt, Lock as kt, Pencil as ue, Trash2 as O, Siren as De } from "lucide-react";
5
- import { useState as k, useMemo as Y } from "react";
1
+ import { jsx as t, jsxs as l, Fragment as ut } from "react/jsx-runtime";
2
+ import { listNotificationSubscriptions as ht, deleteNotificationSubscription as pt } from "@nivaro/sdk";
3
+ import { useQueryClient as xt, useQuery as y, useMutation as me } from "@tanstack/react-query";
4
+ import { LayoutGrid as $e, Bell as Re, BellRing as ue, Clock as bt, ChartColumn as gt, History as qe, FlaskConical as De, Activity as ft, Plus as he, Gauge as vt, Users as yt, Lock as kt, Pencil as pe, Trash2 as O, Siren as Fe } from "lucide-react";
5
+ import { useState as k, useMemo as J } from "react";
6
6
  import { useNivaroClient as Nt } from "../../context.js";
7
7
  import { useMyScopes as wt, matchScopeDimension as _t, effectiveScopeSeedIds as At, translateScopeValues as St } from "../../lib/use-my-scopes.js";
8
8
  import { cn as i } from "../../lib/utils.js";
9
- import { ToggleSwitch as A, SelectInput as Fe, AlertRuleDrawer as Ct, AnomalyRuleDrawer as Et, NotifSubEditDrawer as Tt } from "./drawers.js";
10
- import { OPERATOR_LABELS as Z, fmtMetric as $, fmtDateTime as P } from "./types.js";
9
+ import { ToggleSwitch as S, SelectInput as Le, AlertRuleDrawer as Ct, AnomalyRuleDrawer as Et, NotifSubEditDrawer as Tt } from "./drawers.js";
10
+ import { OPERATOR_LABELS as ee, fmtMetric as _, fmtDateTime as P } from "./types.js";
11
11
  function $t(s, d) {
12
12
  const n = (d ?? []).find(
13
- (c) => {
14
- var C;
15
- return c && (c.field === s || ((C = c.options) == null ? void 0 : C.collection) === s) && c.label;
13
+ (m) => {
14
+ var E;
15
+ return m && (m.field === s || ((E = m.options) == null ? void 0 : E.collection) === s) && m.label;
16
16
  }
17
17
  );
18
18
  if (n != null && n.label) return n.label;
19
- const u = String(s ?? "").replace(/_/g, " ").trim();
20
- return u ? u.charAt(0).toUpperCase() + u.slice(1) : "Filter";
19
+ const h = String(s ?? "").replace(/_/g, " ").trim();
20
+ return h ? h.charAt(0).toUpperCase() + h.slice(1) : "Filter";
21
21
  }
22
22
  function Rt(s, d) {
23
23
  return s != null && s.length ? s.map((n) => `${$t(n.field, d)}: ${(n.labels ?? n.values).join(", ")}`).join(" · ") : "All data";
@@ -53,10 +53,10 @@ function M({ status: s }) {
53
53
  }
54
54
  );
55
55
  }
56
- function J(s) {
56
+ function X(s) {
57
57
  return s.created_by ?? null;
58
58
  }
59
- function pe({ on: s }) {
59
+ function xe({ on: s }) {
60
60
  return /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: s ? "On" : "Off" });
61
61
  }
62
62
  function F({ n: s, tone: d }) {
@@ -77,29 +77,29 @@ function F({ n: s, tone: d }) {
77
77
  ) : null;
78
78
  }
79
79
  const Ft = "px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500", r = "px-3 py-2.5 align-middle text-[12px] text-slate-600 dark:text-slate-300", Lt = i(r, "font-mono tabular-nums text-slate-800 dark:text-slate-100"), w = "inline-flex h-7 w-7 items-center justify-center rounded-md border border-slate-200 text-slate-400 transition-colors hover:border-slate-300 hover:bg-slate-50 hover:text-slate-700 dark:border-border dark:hover:bg-muted/50 dark:hover:text-slate-200";
80
- function X(s) {
80
+ function Z(s) {
81
81
  const d = Date.now() - new Date(s).getTime();
82
82
  if (!Number.isFinite(d)) return null;
83
83
  const n = Math.floor(d / 6e4);
84
84
  if (n < 0) return null;
85
85
  if (n < 1) return "just now";
86
86
  if (n < 60) return `${n}m ago`;
87
- const u = Math.floor(n / 60);
88
- if (u < 24) return `${u}h ago`;
89
- const c = Math.floor(u / 24);
90
- return c < 30 ? `${c}d ago` : null;
87
+ const h = Math.floor(n / 60);
88
+ if (h < 24) return `${h}h ago`;
89
+ const m = Math.floor(h / 24);
90
+ return m < 30 ? `${m}d ago` : null;
91
91
  }
92
- function Le(s, d) {
92
+ function je(s, d) {
93
93
  const n = new Date(d).getTime() - new Date(s).getTime();
94
94
  if (!Number.isFinite(n) || n <= 0) return null;
95
- const u = Math.round(n / 6e4);
96
- if (u < 60) return `${u}m`;
97
- const c = Math.round(u / 60);
98
- return c < 48 ? `${c}h` : `${Math.round(c / 24)}d`;
95
+ const h = Math.round(n / 6e4);
96
+ if (h < 60) return `${h}m`;
97
+ const m = Math.round(h / 60);
98
+ return m < 48 ? `${m}h` : `${Math.round(m / 24)}d`;
99
99
  }
100
- function xe({ value: s, className: d }) {
100
+ function be({ value: s, className: d }) {
101
101
  if (!s) return /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" });
102
- const n = X(s);
102
+ const n = Z(s);
103
103
  return /* @__PURE__ */ l("span", { className: i("block leading-tight", d), children: [
104
104
  /* @__PURE__ */ t("span", { className: "block whitespace-nowrap text-[11.5px] text-slate-600 dark:text-slate-300", children: P(s) }),
105
105
  n && /* @__PURE__ */ t("span", { className: "block text-[10.5px] text-slate-500 dark:text-slate-400", children: n })
@@ -109,8 +109,8 @@ function jt({
109
109
  value: s,
110
110
  threshold: d,
111
111
  unit: n,
112
- operator: u,
113
- breaching: c
112
+ operator: h,
113
+ breaching: m
114
114
  }) {
115
115
  return /* @__PURE__ */ l("span", { className: "flex items-baseline gap-1.5 font-mono tabular-nums", children: [
116
116
  /* @__PURE__ */ t(
@@ -118,14 +118,14 @@ function jt({
118
118
  {
119
119
  className: i(
120
120
  "text-[12.5px] font-semibold",
121
- c ? "text-red-600 dark:text-red-400" : "text-slate-800 dark:text-slate-100"
121
+ m ? "text-red-600 dark:text-red-400" : "text-slate-800 dark:text-slate-100"
122
122
  ),
123
- children: $(s, n ?? void 0)
123
+ children: _(s, n ?? void 0)
124
124
  }
125
125
  ),
126
126
  /* @__PURE__ */ l("span", { className: "text-[10.5px] text-slate-400 dark:text-slate-500", children: [
127
- u ? `${Z[u] ?? u} ` : "/ ",
128
- $(d, n ?? void 0)
127
+ h ? `${ee[h] ?? h} ` : "/ ",
128
+ _(d, n ?? void 0)
129
129
  ] })
130
130
  ] });
131
131
  }
@@ -135,14 +135,14 @@ function Ot({
135
135
  unit: n
136
136
  }) {
137
137
  return /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1 rounded-md border border-slate-200 bg-slate-50 px-1.5 py-0.5 font-mono text-[11.5px] tabular-nums text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children: [
138
- /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: Z[s] ?? s }),
139
- $(d, n ?? void 0)
138
+ /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: ee[s] ?? s }),
139
+ _(d, n ?? void 0)
140
140
  ] });
141
141
  }
142
142
  function Mt({ text: s }) {
143
143
  const [d, n] = k(!1);
144
144
  if (!s) return /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" });
145
- const u = s.length > 120;
145
+ const h = s.length > 120;
146
146
  return /* @__PURE__ */ l("span", { className: "block", children: [
147
147
  /* @__PURE__ */ t(
148
148
  "span",
@@ -154,23 +154,23 @@ function Mt({ text: s }) {
154
154
  children: s
155
155
  }
156
156
  ),
157
- u && /* @__PURE__ */ t(
157
+ h && /* @__PURE__ */ t(
158
158
  "button",
159
159
  {
160
160
  type: "button",
161
- onClick: () => n((c) => !c),
161
+ onClick: () => n((m) => !m),
162
162
  className: "mt-0.5 text-[11px] font-medium text-slate-400 underline decoration-slate-300 underline-offset-2 transition-colors hover:text-slate-600 dark:hover:text-slate-200",
163
163
  children: d ? "Show less" : "Show more"
164
164
  }
165
165
  )
166
166
  ] });
167
167
  }
168
- function be({
168
+ function ge({
169
169
  title: s,
170
170
  hint: d,
171
171
  action: n,
172
- wide: u,
173
- children: c
172
+ wide: h,
173
+ children: m
174
174
  }) {
175
175
  return (
176
176
  // Capped and LEFT-aligned, never centred: six columns of short data on a
@@ -179,7 +179,7 @@ function be({
179
179
  /* @__PURE__ */ l(
180
180
  "section",
181
181
  {
182
- className: i("flex min-h-0 flex-col gap-2", u ? "max-w-[1560px]" : "max-w-[1180px]"),
182
+ className: i("flex min-h-0 flex-col gap-2", h ? "max-w-[1560px]" : "max-w-[1180px]"),
183
183
  children: [
184
184
  /* @__PURE__ */ l("header", { className: "flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1", children: [
185
185
  /* @__PURE__ */ l("div", { className: "flex items-baseline gap-2.5", children: [
@@ -188,24 +188,24 @@ function be({
188
188
  ] }),
189
189
  n
190
190
  ] }),
191
- c
191
+ m
192
192
  ]
193
193
  }
194
194
  )
195
195
  );
196
196
  }
197
- function S({
197
+ function C({
198
198
  headers: s,
199
199
  children: d,
200
200
  empty: n,
201
- emptyHint: u,
202
- emptyIcon: c,
203
- emptyAction: C,
204
- loading: _
201
+ emptyHint: h,
202
+ emptyIcon: m,
203
+ emptyAction: E,
204
+ loading: A
205
205
  }) {
206
- const g = !_ && (!d || Array.isArray(d) && d.length === 0);
206
+ const g = !A && (!d || Array.isArray(d) && d.length === 0);
207
207
  return /* @__PURE__ */ t("div", { className: "overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ l("table", { className: "w-full border-collapse", children: [
208
- /* @__PURE__ */ t("thead", { className: "border-b border-slate-200 bg-slate-50/80 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("tr", { children: s.map((f, E) => {
208
+ /* @__PURE__ */ t("thead", { className: "border-b border-slate-200 bg-slate-50/80 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("tr", { children: s.map((f, T) => {
209
209
  const L = typeof f == "string" ? f : f.label, p = typeof f == "string" ? void 0 : f.width, o = typeof f == "string" ? void 0 : f.align;
210
210
  return /* @__PURE__ */ t(
211
211
  "th",
@@ -214,20 +214,20 @@ function S({
214
214
  style: p ? { width: p } : void 0,
215
215
  children: L
216
216
  },
217
- `${L}-${E}`
217
+ `${L}-${T}`
218
218
  );
219
219
  }) }) }),
220
- /* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-100 dark:divide-border/50", children: _ ? Array.from({ length: 5 }, (f, E) => /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-3", colSpan: s.length, children: /* @__PURE__ */ t(
220
+ /* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-100 dark:divide-border/50", children: A ? Array.from({ length: 5 }, (f, T) => /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-3", colSpan: s.length, children: /* @__PURE__ */ t(
221
221
  "span",
222
222
  {
223
223
  className: "block h-3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]",
224
- style: { width: `${45 + E * 19 % 45}%` }
224
+ style: { width: `${45 + T * 19 % 45}%` }
225
225
  }
226
- ) }) }, E)) : g ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-14", colSpan: s.length, children: /* @__PURE__ */ l("div", { className: "mx-auto flex max-w-sm flex-col items-center gap-2 text-center", children: [
227
- c && /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: c }),
226
+ ) }) }, T)) : g ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-14", colSpan: s.length, children: /* @__PURE__ */ l("div", { className: "mx-auto flex max-w-sm flex-col items-center gap-2 text-center", children: [
227
+ m && /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: m }),
228
228
  /* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: n }),
229
- u && /* @__PURE__ */ t("p", { className: "text-[12px] leading-relaxed text-slate-400 dark:text-slate-500", children: u }),
230
- C && /* @__PURE__ */ t("div", { className: "mt-1", children: C })
229
+ h && /* @__PURE__ */ t("p", { className: "text-[12px] leading-relaxed text-slate-400 dark:text-slate-500", children: h }),
230
+ E && /* @__PURE__ */ t("div", { className: "mt-1", children: E })
231
231
  ] }) }) }) : d })
232
232
  ] }) }) });
233
233
  }
@@ -235,120 +235,120 @@ function Yt({
235
235
  defaultTab: s = "catalog",
236
236
  hiddenTabs: d = [],
237
237
  onOpenReport: n,
238
- className: u
238
+ className: h
239
239
  }) {
240
- const c = Nt(), C = xt(), { scopes: _ } = wt(), [g, f] = k(s), [E, L] = k(null), p = (e) => {
240
+ const m = Nt(), E = xt(), { scopes: A } = wt(), [g, f] = k(s), [T, L] = k(null), p = (e) => {
241
241
  L(e), window.setTimeout(() => L(null), 2500);
242
- }, o = (e, a, m) => c.request({ _method: e, _path: a, _body: m }), { data: R } = v({
242
+ }, o = (e, a, u) => m.request({ _method: e, _path: a, _body: u }), { data: R } = y({
243
243
  queryKey: ["nvr-ma-me"],
244
244
  queryFn: () => o("GET", "/auth/me").then((e) => e.data)
245
- }), je = String((R == null ? void 0 : R.id) ?? "").toLowerCase(), Oe = !!(R != null && R.is_admin), b = (...e) => {
246
- for (const a of e) C.invalidateQueries({ queryKey: [a] });
247
- }, { data: q = [], isLoading: ee } = v({
245
+ }), Oe = String((R == null ? void 0 : R.id) ?? "").toLowerCase(), Me = !!(R != null && R.is_admin), b = (...e) => {
246
+ for (const a of e) E.invalidateQueries({ queryKey: [a] });
247
+ }, { data: q = [], isLoading: te } = y({
248
248
  queryKey: ["nvr-ma-definitions"],
249
249
  queryFn: () => o("GET", "/metric-alerts/definitions").then((e) => e.data)
250
- }), { data: I = [], isLoading: Me } = v({
250
+ }), { data: I = [], isLoading: Pe } = y({
251
251
  queryKey: ["nvr-ma-rules"],
252
252
  queryFn: () => o("GET", "/metric-alerts/rules").then((e) => e.data)
253
- }), { data: G = [], isLoading: Pe } = v({
253
+ }), { data: G = [], isLoading: Ie } = y({
254
254
  queryKey: ["nvr-ma-subs"],
255
255
  queryFn: () => o("GET", "/metric-alerts/subscriptions").then(
256
256
  (e) => e.data
257
257
  )
258
- }), { data: H = [], isLoading: Ie } = v({
258
+ }), { data: H = [], isLoading: Ge } = y({
259
259
  queryKey: ["nvr-ma-log"],
260
260
  queryFn: () => o("GET", "/metric-alerts/log?limit=100").then(
261
261
  (e) => e.data
262
262
  )
263
- }), { data: ge = [], isLoading: Ge } = v({
263
+ }), { data: fe = [], isLoading: He } = y({
264
264
  queryKey: ["nvr-ma-notif-subs"],
265
- queryFn: () => c.request(ut()).then((e) => e.data)
266
- }), K = ce({
265
+ queryFn: () => m.request(ht()).then((e) => e.data)
266
+ }), K = me({
267
267
  // Raw PATCH — the route accepts label/filter_field/filter_value/filters/
268
268
  // digest_frequency/is_active; the typed SDK command covers a subset.
269
269
  mutationFn: ({ id: e, patch: a }) => o("PATCH", `/notification-subscriptions/${e}`, a),
270
270
  onSuccess: () => b("nvr-ma-notif-subs")
271
- }), He = ce({
272
- mutationFn: (e) => c.request(pt(e)),
271
+ }), Ke = me({
272
+ mutationFn: (e) => m.request(pt(e)),
273
273
  onSuccess: () => b("nvr-ma-notif-subs")
274
- }), fe = d.includes("widget_alerts"), { data: te = [], isLoading: Ke } = v({
274
+ }), ve = d.includes("widget_alerts"), { data: ae = [], isLoading: Be } = y({
275
275
  queryKey: ["nvr-ma-report-alerts"],
276
- enabled: !fe,
276
+ enabled: !ve,
277
277
  queryFn: () => o("GET", "/metric-alerts/report-alerts").then((e) => e.data)
278
- }), Be = te.some((e) => (e.filters ?? []).length > 0), { data: ae } = v({
278
+ }), ze = ae.some((e) => (e.filters ?? []).length > 0), { data: le } = y({
279
279
  queryKey: ["nvr-ma-report-filter-bars"],
280
- enabled: !fe && Be,
280
+ enabled: !ve && ze,
281
281
  staleTime: 3e5,
282
282
  queryFn: () => o("GET", "/report-studio").then(
283
283
  (e) => new Map((e.data ?? []).map((a) => {
284
- var m;
285
- return [String(a.id), ((m = a.global_filters) == null ? void 0 : m.filter_bar) ?? []];
284
+ var u;
285
+ return [String(a.id), ((u = a.global_filters) == null ? void 0 : u.filter_bar) ?? []];
286
286
  }))
287
287
  ).catch(() => /* @__PURE__ */ new Map())
288
- }), { data: ye = [], isLoading: ze } = v({
288
+ }), { data: ye = [], isLoading: We } = y({
289
289
  queryKey: ["nvr-ma-report-alerts-log"],
290
290
  enabled: !d.includes("widget_alert_history"),
291
291
  queryFn: () => o("GET", "/metric-alerts/report-alerts-log").then(
292
292
  (e) => e.data
293
293
  )
294
- }), { data: We = [] } = v({
294
+ }), { data: Ue = [] } = y({
295
295
  queryKey: ["nvr-ma-anomaly-defs"],
296
296
  queryFn: () => o("GET", "/metric-alerts/anomaly-definitions").then(
297
297
  (e) => e.data
298
298
  )
299
- }), { data: ve = [], isLoading: Ue } = v({
299
+ }), { data: ke = [], isLoading: Ve } = y({
300
300
  queryKey: ["nvr-ma-anomaly-rules"],
301
301
  queryFn: () => o("GET", "/metric-alerts/anomaly-rules").then((e) => e.data)
302
- }), { data: B = [], isLoading: Ve } = v({
302
+ }), { data: B = [], isLoading: Qe } = y({
303
303
  queryKey: ["nvr-ma-anomaly-log"],
304
304
  queryFn: () => o("GET", "/metric-alerts/anomaly-log").then((e) => e.data)
305
- }), [Qe, z] = k(!1), [le, ke] = k(null), [Ye, Ne] = k(null), [Je, W] = k(!1), [re, U] = k(null), [V, se] = k(null), [we, Q] = k(!1), _e = Y(
305
+ }), [Ye, z] = k(!1), [re, Ne] = k(null), [Je, we] = k(null), [Xe, W] = k(!1), [se, U] = k(null), [V, ne] = k(null), [_e, Q] = k(!1), Ae = J(
306
306
  () => Object.fromEntries(G.map((e) => [e.rule_id, e])),
307
307
  [G]
308
- ), Xe = Y(() => {
308
+ ), Ze = J(() => {
309
309
  const e = {};
310
310
  for (const a of H)
311
311
  a.status === "firing" && !a.resolved_at && (e[a.rule_id] = a);
312
312
  return e;
313
- }, [H]), Ae = Y(
313
+ }, [H]), Se = J(
314
314
  () => B.filter((e) => e.status !== "resolved").length,
315
315
  [B]
316
- ), Ze = async (e) => {
317
- const a = _e[e.id];
316
+ ), et = async (e) => {
317
+ const a = Ae[e.id];
318
318
  try {
319
319
  a ? (await o("DELETE", `/metric-alerts/subscriptions/${a.id}`), p("Unsubscribed from alert")) : (await o("POST", "/metric-alerts/subscriptions", { rule_id: e.id }), p("Subscribed to alert")), b("nvr-ma-subs");
320
320
  } catch {
321
321
  p("Failed to update subscription");
322
322
  }
323
- }, ne = async (e, a) => {
323
+ }, ie = async (e, a) => {
324
324
  try {
325
325
  await o("PATCH", `/metric-alerts/subscriptions/${e}`, a), b("nvr-ma-subs");
326
326
  } catch {
327
327
  p("Failed to update subscription");
328
328
  }
329
- }, et = async (e) => {
330
- var a, m;
329
+ }, tt = async (e) => {
330
+ var a, u;
331
331
  Q(!0);
332
332
  try {
333
- if (le)
334
- await o("PATCH", `/metric-alerts/rules/${le.id}`, e), p("Alert rule updated");
333
+ if (re)
334
+ await o("PATCH", `/metric-alerts/rules/${re.id}`, e), p("Alert rule updated");
335
335
  else {
336
- const h = q.find((x) => x.id === e.definition_id), y = { ...e.filters ?? {} };
337
- for (const x of (h == null ? void 0 : h.supported_filters) ?? []) {
338
- if ((a = y[x.key]) != null && a.length) continue;
339
- const N = _t(_, { key: x.key, collection: x.collection });
336
+ const c = q.find((x) => x.id === e.definition_id), v = { ...e.filters ?? {} };
337
+ for (const x of (c == null ? void 0 : c.supported_filters) ?? []) {
338
+ if ((a = v[x.key]) != null && a.length) continue;
339
+ const N = _t(A, { key: x.key, collection: x.collection });
340
340
  if (!N) continue;
341
- const T = (m = _ == null ? void 0 : _.restricted) == null ? void 0 : m[N.name];
342
- if (!(T != null && T.length)) continue;
343
- const j = At(_, N.name), mt = j.length ? j : T;
344
- y[x.key] = await St(
345
- c,
341
+ const $ = (u = A == null ? void 0 : A.restricted) == null ? void 0 : u[N.name];
342
+ if (!($ != null && $.length)) continue;
343
+ const j = At(A, N.name), Y = j.length ? j : $;
344
+ v[x.key] = await St(
345
+ m,
346
346
  N,
347
- mt,
347
+ Y,
348
348
  x.value_field
349
349
  );
350
350
  }
351
- await o("POST", "/metric-alerts/rules", { ...e, filters: y }), p("Alert rule created");
351
+ await o("POST", "/metric-alerts/rules", { ...e, filters: v }), p("Alert rule created");
352
352
  }
353
353
  z(!1), b("nvr-ma-rules", "nvr-ma-subs");
354
354
  } catch {
@@ -356,112 +356,112 @@ function Yt({
356
356
  } finally {
357
357
  Q(!1);
358
358
  }
359
- }, tt = async (e) => {
359
+ }, at = async (e) => {
360
360
  if (window.confirm(`Delete rule "${e.name}"? This removes the rule and all subscriptions.`))
361
361
  try {
362
362
  await o("DELETE", `/metric-alerts/rules/${e.id}`), p("Alert rule deleted"), b("nvr-ma-rules", "nvr-ma-subs", "nvr-ma-log");
363
363
  } catch {
364
364
  p("Failed to delete rule");
365
365
  }
366
- }, at = async (e) => {
366
+ }, lt = async (e) => {
367
367
  Q(!0);
368
368
  try {
369
- re ? (await o("PATCH", `/metric-alerts/anomaly-rules/${re.id}`, e), p("Anomaly rule updated")) : (await o("POST", "/metric-alerts/anomaly-rules", e), p("Anomaly rule created")), W(!1), U(null), b("nvr-ma-anomaly-rules");
369
+ se ? (await o("PATCH", `/metric-alerts/anomaly-rules/${se.id}`, e), p("Anomaly rule updated")) : (await o("POST", "/metric-alerts/anomaly-rules", e), p("Anomaly rule created")), W(!1), U(null), b("nvr-ma-anomaly-rules");
370
370
  } catch {
371
371
  p("Failed to save anomaly rule");
372
372
  } finally {
373
373
  Q(!1);
374
374
  }
375
- }, lt = async (e) => {
375
+ }, rt = async (e) => {
376
376
  if (window.confirm(`Delete anomaly rule "${e.name}"? Its log entries are also removed.`))
377
377
  try {
378
378
  await o("DELETE", `/metric-alerts/anomaly-rules/${e.id}`), p("Anomaly rule deleted"), b("nvr-ma-anomaly-rules", "nvr-ma-anomaly-log");
379
379
  } catch {
380
380
  p("Failed to delete anomaly rule");
381
381
  }
382
- }, Se = async (e, a) => {
382
+ }, Ce = async (e, a) => {
383
383
  try {
384
384
  await o("PATCH", `/metric-alerts/anomaly-rules/${e}`, a), b("nvr-ma-anomaly-rules");
385
385
  } catch {
386
386
  p("Failed to update anomaly rule");
387
387
  }
388
- }, Ce = async (e, a) => {
388
+ }, Ee = async (e, a) => {
389
389
  try {
390
390
  await o("PATCH", `/metric-alerts/anomaly-log/${e}`, { status: a }), b("nvr-ma-anomaly-log");
391
391
  } catch {
392
392
  p("Failed to update anomaly");
393
393
  }
394
- }, ie = async (e, a) => {
394
+ }, de = async (e, a) => {
395
395
  try {
396
396
  await o("PATCH", `/report-studio/${e.report}/alerts/${e.id}`, a), b("nvr-ma-report-alerts");
397
397
  } catch {
398
398
  p("Failed to update widget alert");
399
399
  }
400
- }, rt = async (e) => {
400
+ }, st = async (e) => {
401
401
  if (window.confirm(`Delete widget alert "${e.name}"?`))
402
402
  try {
403
403
  await o("DELETE", `/report-studio/${e.report}/alerts/${e.id}`), p("Widget alert deleted"), b("nvr-ma-report-alerts", "nvr-ma-report-alerts-log");
404
404
  } catch {
405
405
  p("Failed to delete widget alert");
406
406
  }
407
- }, st = ce({
407
+ }, nt = me({
408
408
  mutationFn: (e) => o("POST", `/report-studio/${e.report_id}/alerts/${e.alert}/resolve`),
409
409
  onSuccess: () => b("nvr-ma-report-alerts-log", "nvr-ma-report-alerts")
410
- }), nt = Y(() => {
410
+ }), it = J(() => {
411
411
  const e = /* @__PURE__ */ new Map();
412
412
  for (const a of q)
413
413
  e.has(a.category) || e.set(a.category, []), e.get(a.category).push(a);
414
414
  return e;
415
- }, [q]), de = H.filter((e) => e.status === "firing").length, it = ye.filter((e) => e.status === "firing").length, dt = ve.filter((e) => e.status === "active").length, ot = B.filter((e) => e.status === "new").length, ct = [
416
- { key: "catalog", label: "Alert Catalog", icon: /* @__PURE__ */ t(Te, { className: "h-3.5 w-3.5" }) },
417
- { key: "rules", label: "Alert Rules", icon: /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5" }) },
415
+ }, [q]), oe = H.filter((e) => e.status === "firing").length, dt = ye.filter((e) => e.status === "firing").length, ot = ke.filter((e) => e.status === "active").length, ct = B.filter((e) => e.status === "new").length, mt = [
416
+ { key: "catalog", label: "Alert Catalog", icon: /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5" }) },
417
+ { key: "rules", label: "Alert Rules", icon: /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" }) },
418
418
  {
419
419
  key: "subscriptions",
420
420
  label: "My Subscriptions",
421
- icon: /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
422
- badge: /* @__PURE__ */ t(F, { n: G.length + ge.length, tone: "cyan" })
421
+ icon: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" }),
422
+ badge: /* @__PURE__ */ t(F, { n: G.length + fe.length, tone: "cyan" })
423
423
  },
424
424
  {
425
425
  key: "history",
426
426
  label: "Alert History",
427
427
  icon: /* @__PURE__ */ t(bt, { className: "h-3.5 w-3.5" }),
428
- badge: /* @__PURE__ */ t(F, { n: de, tone: "red" })
428
+ badge: /* @__PURE__ */ t(F, { n: oe, tone: "red" })
429
429
  },
430
430
  {
431
431
  key: "widget_alerts",
432
432
  label: "Widget Alerts",
433
433
  icon: /* @__PURE__ */ t(gt, { className: "h-3.5 w-3.5" }),
434
- badge: /* @__PURE__ */ t(F, { n: te.length, tone: "violet" })
434
+ badge: /* @__PURE__ */ t(F, { n: ae.length, tone: "violet" })
435
435
  },
436
436
  {
437
437
  key: "widget_alert_history",
438
438
  label: "Widget Alert History",
439
- icon: /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" }),
440
- badge: /* @__PURE__ */ t(F, { n: it, tone: "red" })
439
+ icon: /* @__PURE__ */ t(qe, { className: "h-3.5 w-3.5" }),
440
+ badge: /* @__PURE__ */ t(F, { n: dt, tone: "red" })
441
441
  },
442
442
  {
443
443
  key: "anomaly_rules",
444
444
  label: "Anomaly Rules",
445
- icon: /* @__PURE__ */ t(qe, { className: "h-3.5 w-3.5" }),
446
- badge: /* @__PURE__ */ t(F, { n: dt, tone: "teal" })
445
+ icon: /* @__PURE__ */ t(De, { className: "h-3.5 w-3.5" }),
446
+ badge: /* @__PURE__ */ t(F, { n: ot, tone: "teal" })
447
447
  },
448
448
  {
449
449
  key: "anomaly_history",
450
450
  label: "Anomaly History",
451
451
  icon: /* @__PURE__ */ t(ft, { className: "h-3.5 w-3.5" }),
452
- badge: /* @__PURE__ */ t(F, { n: ot, tone: "red" })
452
+ badge: /* @__PURE__ */ t(F, { n: ct, tone: "red" })
453
453
  }
454
- ].filter((e) => !d.includes(e.key)), Ee = (e) => {
455
- ke(null), Ne(e ?? null), z(!0);
456
- }, D = (e) => Oe || e != null && String(e).toLowerCase() === je, oe = "inline-flex h-7 items-center gap-1.5 rounded-md bg-nvr-cyan px-2.5 text-[12px] font-semibold text-white hover:opacity-90";
457
- return /* @__PURE__ */ l("div", { className: i("flex flex-col gap-3", u), "data-alert-manager": "", children: [
458
- E && /* @__PURE__ */ t("div", { className: "fixed right-4 top-4 z-[60] rounded-md bg-[#0f172a] px-3 py-2 text-[12.5px] text-white shadow-lg dark:bg-slate-100 dark:text-slate-900", children: E }),
454
+ ].filter((e) => !d.includes(e.key)), Te = (e) => {
455
+ Ne(null), we(e ?? null), z(!0);
456
+ }, D = (e) => Me || e != null && String(e).toLowerCase() === Oe, ce = "inline-flex h-7 items-center gap-1.5 rounded-md bg-nvr-cyan px-2.5 text-[12px] font-semibold text-white hover:opacity-90";
457
+ return /* @__PURE__ */ l("div", { className: i("flex flex-col gap-3", h), "data-alert-manager": "", children: [
458
+ T && /* @__PURE__ */ t("div", { className: "fixed right-4 top-4 z-[60] rounded-md bg-[#0f172a] px-3 py-2 text-[12.5px] text-white shadow-lg dark:bg-slate-100 dark:text-slate-900", children: T }),
459
459
  /* @__PURE__ */ t(
460
460
  "div",
461
461
  {
462
462
  className: "flex flex-wrap gap-1 border-b border-slate-200 pb-px dark:border-border",
463
463
  "data-alert-tabs": "",
464
- children: ct.map((e) => /* @__PURE__ */ l(
464
+ children: mt.map((e) => /* @__PURE__ */ l(
465
465
  "button",
466
466
  {
467
467
  type: "button",
@@ -480,7 +480,7 @@ function Yt({
480
480
  ))
481
481
  }
482
482
  ),
483
- g === "catalog" && ee && /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: Array.from({ length: 6 }, (e, a) => /* @__PURE__ */ l(
483
+ g === "catalog" && te && /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: Array.from({ length: 6 }, (e, a) => /* @__PURE__ */ l(
484
484
  "div",
485
485
  {
486
486
  className: "rounded-lg border border-slate-200 bg-white p-3 dark:border-border dark:bg-card",
@@ -492,18 +492,18 @@ function Yt({
492
492
  },
493
493
  a
494
494
  )) }),
495
- g === "catalog" && !ee && q.length > 0 && // One continuous list, not a card grid: the old layout repeated an
495
+ g === "catalog" && !te && q.length > 0 && // One continuous list, not a card grid: the old layout repeated an
496
496
  // identical box (and an identical saturated button) fourteen times,
497
497
  // and its per-category grids left orphan holes on odd counts. Rows
498
498
  // also make room for the fact that actually matters here — whether
499
499
  // this metric is already being watched.
500
- /* @__PURE__ */ t("section", { className: "max-w-[1180px] overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [...nt.entries()].map(([e, a], m) => /* @__PURE__ */ l("div", { children: [
500
+ /* @__PURE__ */ t("section", { className: "max-w-[1180px] overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [...it.entries()].map(([e, a], u) => /* @__PURE__ */ l("div", { children: [
501
501
  /* @__PURE__ */ l(
502
502
  "div",
503
503
  {
504
504
  className: i(
505
505
  "flex items-center gap-2 bg-slate-50/80 px-3 py-1.5 dark:bg-muted/30",
506
- m > 0 && "border-t border-slate-200 dark:border-border"
506
+ u > 0 && "border-t border-slate-200 dark:border-border"
507
507
  ),
508
508
  children: [
509
509
  /* @__PURE__ */ t("span", { className: Dt(e), children: e }),
@@ -515,8 +515,8 @@ function Yt({
515
515
  ]
516
516
  }
517
517
  ),
518
- /* @__PURE__ */ t("ul", { className: "divide-y divide-slate-100 dark:divide-border/50", children: a.map((h) => {
519
- const y = I.filter((x) => x.definition_id === h.id).length;
518
+ /* @__PURE__ */ t("ul", { className: "divide-y divide-slate-100 dark:divide-border/50", children: a.map((c) => {
519
+ const v = I.filter((x) => x.definition_id === c.id).length;
520
520
  return /* @__PURE__ */ l(
521
521
  "li",
522
522
  {
@@ -524,21 +524,21 @@ function Yt({
524
524
  children: [
525
525
  /* @__PURE__ */ l("div", { className: "min-w-0 flex-1", children: [
526
526
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
527
- /* @__PURE__ */ t("p", { className: "truncate text-[13px] font-medium text-slate-800 dark:text-slate-100", children: h.name }),
528
- y > 0 && /* @__PURE__ */ l("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full bg-nvr-cyan/10 px-1.5 py-px text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: [
529
- /* @__PURE__ */ t(me, { className: "h-2.5 w-2.5" }),
530
- y
527
+ /* @__PURE__ */ t("p", { className: "truncate text-[13px] font-medium text-slate-800 dark:text-slate-100", children: c.name }),
528
+ v > 0 && /* @__PURE__ */ l("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full bg-nvr-cyan/10 px-1.5 py-px text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: [
529
+ /* @__PURE__ */ t(ue, { className: "h-2.5 w-2.5" }),
530
+ v
531
531
  ] })
532
532
  ] }),
533
- h.description && /* @__PURE__ */ t("p", { className: "truncate text-[11.5px] text-slate-500 dark:text-slate-400", children: h.description })
533
+ c.description && /* @__PURE__ */ t("p", { className: "truncate text-[11.5px] text-slate-500 dark:text-slate-400", children: c.description })
534
534
  ] }),
535
535
  /* @__PURE__ */ l("div", { className: "hidden shrink-0 items-baseline gap-1.5 font-mono text-[11.5px] tabular-nums text-slate-500 dark:text-slate-400 sm:flex", children: [
536
- /* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-wide text-slate-400 dark:text-slate-500", children: h.unit }),
536
+ /* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-wide text-slate-400 dark:text-slate-500", children: c.unit }),
537
537
  /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "·" }),
538
538
  /* @__PURE__ */ l("span", { children: [
539
- Z[h.default_operator] ?? h.default_operator,
539
+ ee[c.default_operator] ?? c.default_operator,
540
540
  " ",
541
- h.default_threshold != null ? $(h.default_threshold, h.unit) : "—"
541
+ c.default_threshold != null ? _(c.default_threshold, c.unit) : "—"
542
542
  ] })
543
543
  ] }),
544
544
  /* @__PURE__ */ l(
@@ -547,7 +547,7 @@ function Yt({
547
547
  type: "button",
548
548
  className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[12px] font-medium text-slate-600 transition-colors hover:border-nvr-cyan hover:bg-nvr-cyan/[0.08] hover:text-nvr-navy dark:border-border dark:text-slate-300 dark:hover:text-nvr-cyan",
549
549
  onClick: () => {
550
- Ee(h.id), f("rules");
550
+ Te(c.id), f("rules");
551
551
  },
552
552
  children: [
553
553
  /* @__PURE__ */ t(he, { className: "h-3 w-3" }),
@@ -557,26 +557,26 @@ function Yt({
557
557
  )
558
558
  ]
559
559
  },
560
- h.id
560
+ c.id
561
561
  );
562
562
  }) })
563
563
  ] }, e)) }),
564
- g === "catalog" && !ee && q.length === 0 && /* @__PURE__ */ t("div", { className: "rounded-lg border border-slate-200 bg-white py-16 dark:border-border dark:bg-card", children: /* @__PURE__ */ l("div", { className: "mx-auto flex max-w-sm flex-col items-center gap-2 text-center", children: [
565
- /* @__PURE__ */ t(yt, { className: "h-5 w-5 text-slate-300 dark:text-slate-600" }),
564
+ g === "catalog" && !te && q.length === 0 && /* @__PURE__ */ t("div", { className: "rounded-lg border border-slate-200 bg-white py-16 dark:border-border dark:bg-card", children: /* @__PURE__ */ l("div", { className: "mx-auto flex max-w-sm flex-col items-center gap-2 text-center", children: [
565
+ /* @__PURE__ */ t(vt, { className: "h-5 w-5 text-slate-300 dark:text-slate-600" }),
566
566
  /* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: "No metrics in the catalog yet" }),
567
567
  /* @__PURE__ */ t("p", { className: "text-[12px] leading-relaxed text-slate-400 dark:text-slate-500", children: "Metric definitions describe what can be measured — once an admin adds them, you can build alert rules on top." })
568
568
  ] }) }),
569
569
  g === "rules" && /* @__PURE__ */ t(
570
- be,
570
+ ge,
571
571
  {
572
572
  title: "Alert rules",
573
573
  hint: `${I.length} rule${I.length === 1 ? "" : "s"} · shared and personal`,
574
- action: /* @__PURE__ */ l("button", { type: "button", className: oe, onClick: () => Ee(), children: [
574
+ action: /* @__PURE__ */ l("button", { type: "button", className: ce, onClick: () => Te(), children: [
575
575
  /* @__PURE__ */ t(he, { className: "h-3 w-3" }),
576
576
  " New rule"
577
577
  ] }),
578
578
  children: /* @__PURE__ */ t(
579
- S,
579
+ C,
580
580
  {
581
581
  headers: [
582
582
  "Rule",
@@ -588,21 +588,21 @@ function Yt({
588
588
  ],
589
589
  empty: "No alert rules yet",
590
590
  emptyHint: "Pick a metric from the catalog and set the threshold that should page you.",
591
- emptyIcon: /* @__PURE__ */ t(De, { className: "h-5 w-5" }),
592
- emptyAction: /* @__PURE__ */ l("button", { type: "button", className: oe, onClick: () => f("catalog"), children: [
593
- /* @__PURE__ */ t(Te, { className: "h-3 w-3" }),
591
+ emptyIcon: /* @__PURE__ */ t(Fe, { className: "h-5 w-5" }),
592
+ emptyAction: /* @__PURE__ */ l("button", { type: "button", className: ce, onClick: () => f("catalog"), children: [
593
+ /* @__PURE__ */ t($e, { className: "h-3 w-3" }),
594
594
  " Browse catalog"
595
595
  ] }),
596
- loading: Me,
596
+ loading: Pe,
597
597
  children: I.map((e) => {
598
- var T, j;
599
- const a = !!_e[e.id], m = D(e.created_by), h = Xe[e.id], y = e.status !== "active", x = e.last_checked_at, N = x ? X(x) : null;
598
+ var $, j, Y;
599
+ const a = !!Ae[e.id], u = D(e.created_by), c = Ze[e.id], v = e.status !== "active", x = e.last_checked_at, N = x ? Z(x) : null;
600
600
  return /* @__PURE__ */ l(
601
601
  "tr",
602
602
  {
603
603
  className: i(
604
604
  "transition-colors hover:bg-slate-50/70 dark:hover:bg-muted/25",
605
- y && "opacity-60"
605
+ v && "opacity-60"
606
606
  ),
607
607
  children: [
608
608
  /* @__PURE__ */ l("td", { className: r, children: [
@@ -614,10 +614,10 @@ function Yt({
614
614
  {
615
615
  operator: e.operator,
616
616
  threshold: e.threshold_value,
617
- unit: (T = e.definition) == null ? void 0 : T.unit
617
+ unit: ($ = e.definition) == null ? void 0 : $.unit
618
618
  }
619
619
  ) }),
620
- /* @__PURE__ */ t("td", { className: r, children: y ? /* @__PURE__ */ t(M, { status: e.status }) : h ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
620
+ /* @__PURE__ */ t("td", { className: r, children: v ? /* @__PURE__ */ t(M, { status: e.status }) : c ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
621
621
  /* @__PURE__ */ l("span", { className: "inline-flex w-fit items-center gap-1.5 rounded-full bg-red-50 px-2 py-px text-[10.5px] font-semibold text-red-600 dark:bg-red-500/10 dark:text-red-400", children: [
622
622
  /* @__PURE__ */ t(
623
623
  "span",
@@ -629,8 +629,8 @@ function Yt({
629
629
  "Firing"
630
630
  ] }),
631
631
  /* @__PURE__ */ l("span", { className: "font-mono text-[10.5px] tabular-nums text-slate-500 dark:text-slate-400", children: [
632
- $(h.metric_value, (j = e.definition) == null ? void 0 : j.unit),
633
- X(h.fired_at) ? ` · ${X(h.fired_at)}` : ""
632
+ c.current_value != null ? `${_(c.current_value, (j = e.definition) == null ? void 0 : j.unit)} now` : _(c.metric_value, (Y = e.definition) == null ? void 0 : Y.unit),
633
+ Z(c.fired_at) ? ` · fired ${Z(c.fired_at)}` : ""
634
634
  ] })
635
635
  ] }) : x ? /* @__PURE__ */ l(
636
636
  "span",
@@ -658,7 +658,7 @@ function Yt({
658
658
  ) }),
659
659
  /* @__PURE__ */ t("td", { className: i(r, "capitalize text-slate-500 dark:text-slate-400"), children: e.check_frequency }),
660
660
  /* @__PURE__ */ t("td", { className: r, children: e.is_shared ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
661
- /* @__PURE__ */ t(vt, { className: "h-3 w-3" }),
661
+ /* @__PURE__ */ t(yt, { className: "h-3 w-3" }),
662
662
  " Team"
663
663
  ] }) : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1 text-[11.5px] text-slate-400 dark:text-slate-500", children: [
664
664
  /* @__PURE__ */ t(kt, { className: "h-3 w-3" }),
@@ -671,15 +671,15 @@ function Yt({
671
671
  type: "button",
672
672
  title: a ? "Unsubscribe from this rule" : "Subscribe to this rule",
673
673
  "aria-pressed": a,
674
- onClick: () => Ze(e),
674
+ onClick: () => et(e),
675
675
  className: i(
676
676
  w,
677
677
  a && "border-nvr-cyan bg-nvr-cyan/10 text-nvr-navy hover:bg-nvr-cyan/15 dark:text-nvr-cyan"
678
678
  ),
679
- children: a ? /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5" })
679
+ children: a ? /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" })
680
680
  }
681
681
  ),
682
- m && /* @__PURE__ */ l(ht, { children: [
682
+ u && /* @__PURE__ */ l(ut, { children: [
683
683
  /* @__PURE__ */ t(
684
684
  "button",
685
685
  {
@@ -687,9 +687,9 @@ function Yt({
687
687
  title: "Edit rule",
688
688
  className: w,
689
689
  onClick: () => {
690
- ke(e), Ne(null), z(!0);
690
+ Ne(e), we(null), z(!0);
691
691
  },
692
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
692
+ children: /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" })
693
693
  }
694
694
  ),
695
695
  /* @__PURE__ */ t(
@@ -701,7 +701,7 @@ function Yt({
701
701
  w,
702
702
  "hover:border-red-300 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-500/10 dark:hover:text-red-400"
703
703
  ),
704
- onClick: () => tt(e),
704
+ onClick: () => at(e),
705
705
  children: /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5" })
706
706
  }
707
707
  )
@@ -719,7 +719,7 @@ function Yt({
719
719
  g === "subscriptions" && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
720
720
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Manage how you receive alert notifications" }),
721
721
  /* @__PURE__ */ t(
722
- S,
722
+ C,
723
723
  {
724
724
  headers: [
725
725
  "Alert Rule",
@@ -731,31 +731,31 @@ function Yt({
731
731
  { label: "", width: 40 }
732
732
  ],
733
733
  empty: "No subscriptions yet — browse the Alert Catalog or Rules tab to subscribe",
734
- loading: Pe,
734
+ loading: Ie,
735
735
  children: G.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
736
736
  /* @__PURE__ */ l("td", { className: r, children: [
737
737
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.rule_name ?? `Rule #${e.rule_id}` }),
738
738
  e.definition_name && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400", children: e.definition_name })
739
739
  ] }),
740
740
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
741
- A,
741
+ S,
742
742
  {
743
743
  checked: !!e.delivery_in_app,
744
- onChange: (a) => ne(e.id, { delivery_in_app: a })
744
+ onChange: (a) => ie(e.id, { delivery_in_app: a })
745
745
  }
746
746
  ) }),
747
747
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
748
- A,
748
+ S,
749
749
  {
750
750
  checked: !!e.delivery_email,
751
- onChange: (a) => ne(e.id, { delivery_email: a })
751
+ onChange: (a) => ie(e.id, { delivery_email: a })
752
752
  }
753
753
  ) }),
754
754
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
755
- Fe,
755
+ Le,
756
756
  {
757
757
  value: String(e.digest_frequency),
758
- onChange: (a) => ne(e.id, { digest_frequency: a }),
758
+ onChange: (a) => ie(e.id, { digest_frequency: a }),
759
759
  options: [
760
760
  { label: "Immediate", value: "immediate" },
761
761
  { label: "Daily", value: "daily" },
@@ -784,7 +784,7 @@ function Yt({
784
784
  /* @__PURE__ */ t("p", { className: "pt-3 text-[11px] font-semibold uppercase tracking-wider text-slate-400", children: "Record & workflow notifications" }),
785
785
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Subscriptions to record events and workflow state changes (created from records, queues, or notification settings)" }),
786
786
  /* @__PURE__ */ t(
787
- S,
787
+ C,
788
788
  {
789
789
  headers: [
790
790
  "Subscription",
@@ -794,8 +794,8 @@ function Yt({
794
794
  { label: "", width: 80 }
795
795
  ],
796
796
  empty: "No record notifications yet — subscribe from a record, queue, or workflow",
797
- loading: Ge,
798
- children: ge.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
797
+ loading: He,
798
+ children: fe.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
799
799
  /* @__PURE__ */ l("td", { className: r, children: [
800
800
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.label || (e.collection ? e.collection.replace(/_/g, " ") : "Queue digest") }),
801
801
  /* @__PURE__ */ l("div", { className: "mt-0.5 flex flex-wrap items-center gap-1", children: [
@@ -807,7 +807,7 @@ function Yt({
807
807
  " ",
808
808
  e.filter_value ?? "any"
809
809
  ] }),
810
- (e.filters ?? []).map((a, m) => /* @__PURE__ */ l(
810
+ (e.filters ?? []).map((a, u) => /* @__PURE__ */ l(
811
811
  "span",
812
812
  {
813
813
  className: "inline-flex rounded bg-nvr-cyan/10 px-1.5 py-px text-[10.5px] text-slate-600 dark:text-slate-300",
@@ -819,13 +819,13 @@ function Yt({
819
819
  Array.isArray(a.value) ? a.value.join(", ") : String(a.value ?? "")
820
820
  ]
821
821
  },
822
- `${a.field}-${m}`
822
+ `${a.field}-${u}`
823
823
  ))
824
824
  ] })
825
825
  ] }),
826
826
  /* @__PURE__ */ t("td", { className: i(r, "capitalize"), children: String(e.event_type).replace(/_/g, " ") }),
827
827
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
828
- Fe,
828
+ Le,
829
829
  {
830
830
  value: String(e.digest_frequency ?? "instant"),
831
831
  onChange: (a) => K.mutate({ id: e.id, patch: { digest_frequency: a } }),
@@ -838,7 +838,7 @@ function Yt({
838
838
  }
839
839
  ) }),
840
840
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
841
- A,
841
+ S,
842
842
  {
843
843
  checked: !!e.is_active,
844
844
  onChange: (a) => K.mutate({ id: e.id, patch: { is_active: a } })
@@ -851,8 +851,8 @@ function Yt({
851
851
  type: "button",
852
852
  title: "Edit",
853
853
  className: w,
854
- onClick: () => se(e),
855
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
854
+ onClick: () => ne(e),
855
+ children: /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" })
856
856
  }
857
857
  ),
858
858
  /* @__PURE__ */ t(
@@ -862,7 +862,7 @@ function Yt({
862
862
  title: "Remove subscription",
863
863
  className: i(w, "hover:border-red-300 hover:text-red-500"),
864
864
  onClick: () => {
865
- window.confirm("Remove this notification subscription?") && He.mutate(e.id);
865
+ window.confirm("Remove this notification subscription?") && Ke.mutate(e.id);
866
866
  },
867
867
  children: /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5" })
868
868
  }
@@ -873,26 +873,26 @@ function Yt({
873
873
  )
874
874
  ] }),
875
875
  g === "history" && /* @__PURE__ */ t(
876
- be,
876
+ ge,
877
877
  {
878
878
  title: "Alert history",
879
- hint: de > 0 ? `${de} open · last 100 events` : "Last 100 events — none open",
879
+ hint: oe > 0 ? `${oe} open · last 100 events` : "Last 100 events — none open",
880
880
  children: /* @__PURE__ */ t(
881
- S,
881
+ C,
882
882
  {
883
883
  headers: [
884
884
  "Alert rule",
885
- { label: "Reading", width: 168 },
885
+ { label: "Reading when fired", width: 168 },
886
886
  { label: "Fired", width: 150 },
887
887
  { label: "Resolved", width: 150 },
888
888
  { label: "Open for", width: 92, align: "right" }
889
889
  ],
890
890
  empty: "No alerts have fired",
891
891
  emptyHint: "Events appear here the first time a rule crosses its threshold.",
892
- emptyIcon: /* @__PURE__ */ t(Re, { className: "h-5 w-5" }),
893
- loading: Ie,
892
+ emptyIcon: /* @__PURE__ */ t(qe, { className: "h-5 w-5" }),
893
+ loading: Ge,
894
894
  children: H.map((e) => {
895
- const a = e.status === "firing" && !e.resolved_at, m = e.resolved_at ? Le(e.fired_at, e.resolved_at) : Le(e.fired_at, (/* @__PURE__ */ new Date()).toISOString());
895
+ const a = e.status === "firing" && !e.resolved_at, u = e.resolved_at ? je(e.fired_at, e.resolved_at) : je(e.fired_at, (/* @__PURE__ */ new Date()).toISOString());
896
896
  return /* @__PURE__ */ l(
897
897
  "tr",
898
898
  {
@@ -917,18 +917,31 @@ function Yt({
917
917
  }
918
918
  )
919
919
  ] }) }),
920
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
921
- jt,
922
- {
923
- value: e.metric_value,
924
- threshold: e.threshold_value,
925
- unit: e.definition_unit,
926
- breaching: a
927
- }
928
- ) }),
929
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(xe, { value: e.fired_at }) }),
930
- /* @__PURE__ */ t("td", { className: r, children: e.resolved_at ? /* @__PURE__ */ t(xe, { value: e.resolved_at }) : /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-red-50 px-2 py-px text-[10.5px] font-semibold text-red-600 dark:bg-red-500/10 dark:text-red-400", children: "Still open" }) }),
931
- /* @__PURE__ */ t("td", { className: i(Lt, "text-right"), children: /* @__PURE__ */ t("span", { className: i(a && "text-red-600 dark:text-red-400"), children: m ?? "—" }) })
920
+ /* @__PURE__ */ l("td", { className: r, children: [
921
+ /* @__PURE__ */ t(
922
+ jt,
923
+ {
924
+ value: e.metric_value,
925
+ threshold: e.threshold_value,
926
+ unit: e.definition_unit,
927
+ breaching: a
928
+ }
929
+ ),
930
+ a && e.current_value != null && /* @__PURE__ */ l(
931
+ "span",
932
+ {
933
+ "data-alert-current": !0,
934
+ className: "mt-0.5 block font-mono text-[10.5px] tabular-nums text-slate-500 dark:text-slate-400",
935
+ children: [
936
+ _(e.current_value, e.definition_unit ?? void 0),
937
+ " now, as you see it"
938
+ ]
939
+ }
940
+ )
941
+ ] }),
942
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(be, { value: e.fired_at }) }),
943
+ /* @__PURE__ */ t("td", { className: r, children: e.resolved_at ? /* @__PURE__ */ t(be, { value: e.resolved_at }) : /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-red-50 px-2 py-px text-[10.5px] font-semibold text-red-600 dark:bg-red-500/10 dark:text-red-400", children: "Still open" }) }),
944
+ /* @__PURE__ */ t("td", { className: i(Lt, "text-right"), children: /* @__PURE__ */ t("span", { className: i(a && "text-red-600 dark:text-red-400"), children: u ?? "—" }) })
932
945
  ]
933
946
  },
934
947
  e.id
@@ -941,7 +954,7 @@ function Yt({
941
954
  g === "widget_alerts" && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
942
955
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Alerts set up directly on report widgets" }),
943
956
  /* @__PURE__ */ t(
944
- S,
957
+ C,
945
958
  {
946
959
  headers: [
947
960
  "Alert",
@@ -954,8 +967,8 @@ function Yt({
954
967
  { label: "", width: 40 }
955
968
  ],
956
969
  empty: "No widget alerts yet — open any report widget and click the bell icon",
957
- loading: Ke,
958
- children: te.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
970
+ loading: Be,
971
+ children: ae.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
959
972
  /* @__PURE__ */ l("td", { className: r, children: [
960
973
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.name }),
961
974
  e.report_name && /* @__PURE__ */ t(
@@ -971,50 +984,50 @@ function Yt({
971
984
  }
972
985
  )
973
986
  ] }),
974
- /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: Rt(e.filters, ae == null ? void 0 : ae.get(String(e.report))) }),
975
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: (e.conditions ?? []).map((a, m) => /* @__PURE__ */ l(
987
+ /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: Rt(e.filters, le == null ? void 0 : le.get(String(e.report))) }),
988
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: (e.conditions ?? []).map((a, u) => /* @__PURE__ */ l(
976
989
  "span",
977
990
  {
978
991
  className: "inline-flex rounded bg-slate-100 px-1.5 py-px text-[11px] text-slate-600 dark:bg-muted dark:text-slate-300",
979
992
  children: [
980
993
  a.field,
981
994
  " ",
982
- Z[a.op] ?? a.op,
995
+ ee[a.op] ?? a.op,
983
996
  " ",
984
997
  a.value
985
998
  ]
986
999
  },
987
- `${a.field}-${m}`
1000
+ `${a.field}-${u}`
988
1001
  )) }) }),
989
- /* @__PURE__ */ t("td", { className: r, children: D(J(e)) ? /* @__PURE__ */ t(
990
- A,
1002
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) ? /* @__PURE__ */ t(
1003
+ S,
991
1004
  {
992
1005
  checked: !!e.delivery_inapp,
993
- onChange: (a) => ie(e, { delivery_inapp: a })
1006
+ onChange: (a) => de(e, { delivery_inapp: a })
994
1007
  }
995
- ) : /* @__PURE__ */ t(pe, { on: !!e.delivery_inapp }) }),
996
- /* @__PURE__ */ t("td", { className: r, children: D(J(e)) ? /* @__PURE__ */ t(
997
- A,
1008
+ ) : /* @__PURE__ */ t(xe, { on: !!e.delivery_inapp }) }),
1009
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) ? /* @__PURE__ */ t(
1010
+ S,
998
1011
  {
999
1012
  checked: !!e.delivery_email,
1000
- onChange: (a) => ie(e, { delivery_email: a })
1013
+ onChange: (a) => de(e, { delivery_email: a })
1001
1014
  }
1002
- ) : /* @__PURE__ */ t(pe, { on: !!e.delivery_email }) }),
1015
+ ) : /* @__PURE__ */ t(xe, { on: !!e.delivery_email }) }),
1003
1016
  /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: P(e.last_fired) }),
1004
- /* @__PURE__ */ t("td", { className: r, children: D(J(e)) ? /* @__PURE__ */ t(
1005
- A,
1017
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) ? /* @__PURE__ */ t(
1018
+ S,
1006
1019
  {
1007
1020
  checked: !!e.is_active,
1008
- onChange: (a) => ie(e, { is_active: a })
1021
+ onChange: (a) => de(e, { is_active: a })
1009
1022
  }
1010
- ) : /* @__PURE__ */ t(pe, { on: !!e.is_active }) }),
1011
- /* @__PURE__ */ t("td", { className: r, children: D(J(e)) && /* @__PURE__ */ t(
1023
+ ) : /* @__PURE__ */ t(xe, { on: !!e.is_active }) }),
1024
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) && /* @__PURE__ */ t(
1012
1025
  "button",
1013
1026
  {
1014
1027
  type: "button",
1015
1028
  title: "Delete",
1016
1029
  className: i(w, "hover:border-red-300 hover:text-red-500"),
1017
- onClick: () => rt(e),
1030
+ onClick: () => st(e),
1018
1031
  children: /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5" })
1019
1032
  }
1020
1033
  ) })
@@ -1025,7 +1038,7 @@ function Yt({
1025
1038
  g === "widget_alert_history" && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
1026
1039
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Last 200 widget alert events" }),
1027
1040
  /* @__PURE__ */ t(
1028
- S,
1041
+ C,
1029
1042
  {
1030
1043
  headers: [
1031
1044
  "Alert",
@@ -1036,20 +1049,20 @@ function Yt({
1036
1049
  { label: "", width: 90 }
1037
1050
  ],
1038
1051
  empty: "No widget alert history yet",
1039
- loading: ze,
1052
+ loading: We,
1040
1053
  children: ye.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
1041
1054
  /* @__PURE__ */ l("td", { className: r, children: [
1042
1055
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.alert_name }),
1043
1056
  e.report_name && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400", children: e.report_name })
1044
1057
  ] }),
1045
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: Object.entries(e.metric_snapshot ?? {}).map(([a, m]) => /* @__PURE__ */ l(
1058
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: Object.entries(e.metric_snapshot ?? {}).map(([a, u]) => /* @__PURE__ */ l(
1046
1059
  "span",
1047
1060
  {
1048
1061
  className: "inline-flex rounded bg-orange-50 px-1.5 py-px text-[11px] text-orange-600 dark:bg-orange-500/10 dark:text-orange-400",
1049
1062
  children: [
1050
1063
  a,
1051
1064
  ": ",
1052
- String(m)
1065
+ String(u)
1053
1066
  ]
1054
1067
  },
1055
1068
  a
@@ -1062,7 +1075,7 @@ function Yt({
1062
1075
  {
1063
1076
  type: "button",
1064
1077
  className: "rounded border border-nvr-cyan px-2 py-0.5 text-[11.5px] font-medium text-nvr-navy hover:bg-nvr-cyan/10 dark:text-nvr-cyan",
1065
- onClick: () => st.mutate(e),
1078
+ onClick: () => nt.mutate(e),
1066
1079
  children: "Resolve"
1067
1080
  }
1068
1081
  ) })
@@ -1077,7 +1090,7 @@ function Yt({
1077
1090
  "button",
1078
1091
  {
1079
1092
  type: "button",
1080
- className: oe,
1093
+ className: ce,
1081
1094
  onClick: () => {
1082
1095
  U(null), W(!0);
1083
1096
  },
@@ -1089,7 +1102,7 @@ function Yt({
1089
1102
  )
1090
1103
  ] }),
1091
1104
  /* @__PURE__ */ t(
1092
- S,
1105
+ C,
1093
1106
  {
1094
1107
  headers: [
1095
1108
  "Rule",
@@ -1101,8 +1114,8 @@ function Yt({
1101
1114
  { label: "", width: 80 }
1102
1115
  ],
1103
1116
  empty: "No anomaly rules yet — create one to start detecting unusual patterns",
1104
- loading: Ue,
1105
- children: ve.map((e) => {
1117
+ loading: Ve,
1118
+ children: ke.map((e) => {
1106
1119
  const a = D(e.created_by);
1107
1120
  return /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
1108
1121
  /* @__PURE__ */ l("td", { className: r, children: [
@@ -1121,19 +1134,19 @@ function Yt({
1121
1134
  ) }),
1122
1135
  /* @__PURE__ */ t("td", { className: i(r, "capitalize"), children: e.check_frequency }),
1123
1136
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
1124
- A,
1137
+ S,
1125
1138
  {
1126
1139
  checked: !!e.delivery_in_app,
1127
1140
  disabled: !a,
1128
- onChange: (m) => Se(e.id, { delivery_in_app: m })
1141
+ onChange: (u) => Ce(e.id, { delivery_in_app: u })
1129
1142
  }
1130
1143
  ) }),
1131
1144
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
1132
- A,
1145
+ S,
1133
1146
  {
1134
1147
  checked: !!e.delivery_email,
1135
1148
  disabled: !a,
1136
- onChange: (m) => Se(e.id, { delivery_email: m })
1149
+ onChange: (u) => Ce(e.id, { delivery_email: u })
1137
1150
  }
1138
1151
  ) }),
1139
1152
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(M, { status: e.status }) }),
@@ -1147,7 +1160,7 @@ function Yt({
1147
1160
  onClick: () => {
1148
1161
  U(e), W(!0);
1149
1162
  },
1150
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
1163
+ children: /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" })
1151
1164
  }
1152
1165
  ),
1153
1166
  /* @__PURE__ */ t(
@@ -1156,7 +1169,7 @@ function Yt({
1156
1169
  type: "button",
1157
1170
  title: "Delete",
1158
1171
  className: i(w, "hover:border-red-300 hover:text-red-500"),
1159
- onClick: () => lt(e),
1172
+ onClick: () => rt(e),
1160
1173
  children: /* @__PURE__ */ t(O, { className: "h-3.5 w-3.5" })
1161
1174
  }
1162
1175
  )
@@ -1167,13 +1180,13 @@ function Yt({
1167
1180
  )
1168
1181
  ] }),
1169
1182
  g === "anomaly_history" && /* @__PURE__ */ t(
1170
- be,
1183
+ ge,
1171
1184
  {
1172
1185
  wide: !0,
1173
1186
  title: "Detected anomalies",
1174
- hint: `Last 200 detections${Ae ? ` · ${Ae} needing review` : ""}`,
1187
+ hint: `Last 200 detections${Se ? ` · ${Se} needing review` : ""}`,
1175
1188
  children: /* @__PURE__ */ t(
1176
- S,
1189
+ C,
1177
1190
  {
1178
1191
  headers: [
1179
1192
  "Subject",
@@ -1184,12 +1197,12 @@ function Yt({
1184
1197
  ],
1185
1198
  empty: "No anomalies detected",
1186
1199
  emptyHint: "Detections appear here when a subject deviates from its own recent pattern.",
1187
- emptyIcon: /* @__PURE__ */ t(qe, { className: "h-5 w-5" }),
1188
- loading: Ve,
1200
+ emptyIcon: /* @__PURE__ */ t(De, { className: "h-5 w-5" }),
1201
+ loading: Qe,
1189
1202
  children: B.map((e) => {
1190
- const a = e.stats_snapshot ?? {}, m = Object.values(
1203
+ const a = e.stats_snapshot ?? {}, u = Object.values(
1191
1204
  a.group ?? {}
1192
- ).filter(Boolean), h = typeof a.multiplier == "number" ? a.multiplier : null, y = typeof a.value == "number" ? a.value : null, x = typeof a.mean == "number" ? a.mean : null, N = e.status !== "resolved";
1205
+ ).filter(Boolean), c = typeof a.multiplier == "number" ? a.multiplier : null, v = typeof a.value == "number" ? a.value : null, x = typeof a.mean == "number" ? a.mean : null, N = e.status !== "resolved";
1193
1206
  return /* @__PURE__ */ l(
1194
1207
  "tr",
1195
1208
  {
@@ -1205,32 +1218,32 @@ function Yt({
1205
1218
  ),
1206
1219
  /* @__PURE__ */ l("div", { className: "min-w-0", children: [
1207
1220
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: String(a.subject_label ?? e.subject_id) }),
1208
- /* @__PURE__ */ t("p", { className: "truncate text-[11px] text-slate-500 dark:text-slate-400", children: [e.rule_name ?? `Rule #${e.rule_id}`, ...m].join(" · ") })
1221
+ /* @__PURE__ */ t("p", { className: "truncate text-[11px] text-slate-500 dark:text-slate-400", children: [e.rule_name ?? `Rule #${e.rule_id}`, ...u].join(" · ") })
1209
1222
  ] })
1210
1223
  ] }) }),
1211
- /* @__PURE__ */ t("td", { className: r, children: h != null ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
1224
+ /* @__PURE__ */ t("td", { className: r, children: c != null ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
1212
1225
  /* @__PURE__ */ l(
1213
1226
  "span",
1214
1227
  {
1215
1228
  className: i(
1216
1229
  "font-mono text-[13px] font-semibold tabular-nums",
1217
- h >= 3 ? "text-red-600 dark:text-red-400" : "text-amber-600 dark:text-amber-400"
1230
+ c >= 3 ? "text-red-600 dark:text-red-400" : "text-amber-600 dark:text-amber-400"
1218
1231
  ),
1219
1232
  children: [
1220
- h.toFixed(1),
1233
+ c.toFixed(1),
1221
1234
  "×"
1222
1235
  ]
1223
1236
  }
1224
1237
  ),
1225
- y != null && x != null && /* @__PURE__ */ l("span", { className: "font-mono text-[10.5px] tabular-nums text-slate-400 dark:text-slate-500", children: [
1226
- $(y, "dollar"),
1238
+ v != null && x != null && /* @__PURE__ */ l("span", { className: "font-mono text-[10.5px] tabular-nums text-slate-400 dark:text-slate-500", children: [
1239
+ _(v, "dollar"),
1227
1240
  " vs ",
1228
- $(x, "dollar")
1241
+ _(x, "dollar")
1229
1242
  ] })
1230
1243
  ] }) : /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
1231
1244
  /* @__PURE__ */ t("td", { className: i(r, "max-w-0"), children: /* @__PURE__ */ t(Mt, { text: e.ai_explanation }) }),
1232
1245
  /* @__PURE__ */ l("td", { className: r, children: [
1233
- /* @__PURE__ */ t(xe, { value: e.detected_at }),
1246
+ /* @__PURE__ */ t(be, { value: e.detected_at }),
1234
1247
  e.status !== "new" && /* @__PURE__ */ t("span", { className: "mt-1 block", children: /* @__PURE__ */ t(M, { status: e.status }) })
1235
1248
  ] }),
1236
1249
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ l("div", { className: "flex items-center justify-end gap-1", children: [
@@ -1239,7 +1252,7 @@ function Yt({
1239
1252
  {
1240
1253
  type: "button",
1241
1254
  className: "inline-flex h-7 items-center rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
1242
- onClick: () => Ce(e.id, "acknowledged"),
1255
+ onClick: () => Ee(e.id, "acknowledged"),
1243
1256
  children: "Acknowledge"
1244
1257
  }
1245
1258
  ),
@@ -1248,7 +1261,7 @@ function Yt({
1248
1261
  {
1249
1262
  type: "button",
1250
1263
  className: "inline-flex h-7 items-center rounded-md border border-nvr-cyan px-2.5 text-[11.5px] font-medium text-nvr-navy transition-colors hover:bg-nvr-cyan/10 dark:text-nvr-cyan",
1251
- onClick: () => Ce(e.id, "resolved"),
1264
+ onClick: () => Ee(e.id, "resolved"),
1252
1265
  children: "Resolve"
1253
1266
  }
1254
1267
  )
@@ -1262,30 +1275,30 @@ function Yt({
1262
1275
  )
1263
1276
  }
1264
1277
  ),
1265
- /* @__PURE__ */ t("span", { className: "hidden", children: /* @__PURE__ */ t(De, { className: "h-4 w-4" }) }),
1278
+ /* @__PURE__ */ t("span", { className: "hidden", children: /* @__PURE__ */ t(Fe, { className: "h-4 w-4" }) }),
1266
1279
  /* @__PURE__ */ t(
1267
1280
  Ct,
1268
1281
  {
1269
- open: Qe,
1282
+ open: Ye,
1270
1283
  definitions: q,
1271
- editRule: le,
1272
- preselectedDefinitionId: Ye,
1284
+ editRule: re,
1285
+ preselectedDefinitionId: Je,
1273
1286
  onClose: () => z(!1),
1274
- onSave: et,
1275
- saving: we
1287
+ onSave: tt,
1288
+ saving: _e
1276
1289
  }
1277
1290
  ),
1278
1291
  /* @__PURE__ */ t(
1279
1292
  Et,
1280
1293
  {
1281
- open: Je,
1282
- definitions: We,
1283
- editRule: re,
1294
+ open: Xe,
1295
+ definitions: Ue,
1296
+ editRule: se,
1284
1297
  onClose: () => {
1285
1298
  W(!1), U(null);
1286
1299
  },
1287
- onSave: at,
1288
- saving: we
1300
+ onSave: lt,
1301
+ saving: _e
1289
1302
  }
1290
1303
  ),
1291
1304
  /* @__PURE__ */ t(
@@ -1293,12 +1306,12 @@ function Yt({
1293
1306
  {
1294
1307
  open: V != null,
1295
1308
  sub: V,
1296
- onClose: () => se(null),
1309
+ onClose: () => ne(null),
1297
1310
  saving: K.isPending,
1298
1311
  onSave: (e) => {
1299
1312
  V && K.mutate(
1300
1313
  { id: V.id, patch: e },
1301
- { onSuccess: () => se(null) }
1314
+ { onSuccess: () => ne(null) }
1302
1315
  );
1303
1316
  }
1304
1317
  }