@nivaro/react 0.3.61 → 0.3.63

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.
@@ -1,40 +1,41 @@
1
- import { jsx as t, jsxs as l, Fragment as mt } from "react/jsx-runtime";
2
- import { listNotificationSubscriptions as ut, deleteNotificationSubscription as ht } from "@nivaro/sdk";
3
- import { useQueryClient as pt, useQuery as y, useMutation as oe } from "@tanstack/react-query";
4
- import { LayoutGrid as Te, Bell as $e, BellRing as ce, Clock as xt, ChartColumn as bt, History as Re, FlaskConical as qe, Activity as gt, Plus as me, Gauge as ft, Users as vt, Lock as yt, Pencil as ue, Trash2 as L, Siren as De } from "lucide-react";
5
- import { useState as _, useMemo as z } from "react";
6
- import { toast as Fe } from "sonner";
7
- import { useNivaroClient as kt } from "../../context.js";
8
- import { useMyScopes as Nt, matchScopeDimension as wt, effectiveScopeSeedIds as _t, translateScopeValues as At } from "../../lib/use-my-scopes.js";
1
+ import { jsx as t, jsxs as l, Fragment as ut } from "react/jsx-runtime";
2
+ import { listNotificationSubscriptions as pt, deleteNotificationSubscription as xt } from "@nivaro/sdk";
3
+ import { useQueryClient as bt, useQuery as y, useMutation as me } from "@tanstack/react-query";
4
+ import { LayoutGrid as Re, Bell as De, BellRing as he, Clock as gt, ChartColumn as ft, History as qe, FlaskConical as Le, Activity as vt, Plus as ue, Gauge as yt, Users as Nt, Lock as kt, Pencil as pe, Trash2 as F, Siren as Fe } from "lucide-react";
5
+ import { useState as _, useMemo as J } from "react";
6
+ import { toast as je } from "sonner";
7
+ import { useNivaroClient as wt } from "../../context.js";
8
+ import { useMyScopes as _t, matchScopeDimension as Ct, effectiveScopeSeedIds as At, translateScopeValues as St } from "../../lib/use-my-scopes.js";
9
9
  import { cn as i } from "../../lib/utils.js";
10
- import { ToggleSwitch as S, SelectInput as Le, AlertRuleDrawer as Ct, AnomalyRuleDrawer as St, NotifSubEditDrawer as Et } from "./drawers.js";
11
- import { categoryLabel as Tt, OPERATOR_LABELS as be, fmtMetric as A, fmtDateTime as O, reportConditionText as $t } from "./types.js";
12
- function Rt(s, d) {
10
+ import { ConfirmButton as j } from "../profile/primitives.js";
11
+ import { ToggleSwitch as S, SelectInput as Oe, AlertRuleDrawer as Tt, AnomalyRuleDrawer as Et, NotifSubEditDrawer as $t } from "./drawers.js";
12
+ import { categoryLabel as Rt, OPERATOR_LABELS as fe, fmtMetric as C, fmtDateTime as P, reportConditionText as Dt } from "./types.js";
13
+ function qt(s, d) {
13
14
  const n = (d ?? []).find(
14
15
  (m) => {
15
- var T;
16
- return m && (m.field === s || ((T = m.options) == null ? void 0 : T.collection) === s) && m.label;
16
+ var E;
17
+ return m && (m.field === s || ((E = m.options) == null ? void 0 : E.collection) === s) && m.label;
17
18
  }
18
19
  );
19
20
  if (n != null && n.label) return n.label;
20
- const h = String(s ?? "").replace(/_/g, " ").trim();
21
- return h ? h.charAt(0).toUpperCase() + h.slice(1) : "Filter";
21
+ const u = String(s ?? "").replace(/_/g, " ").trim();
22
+ return u ? u.charAt(0).toUpperCase() + u.slice(1) : "Filter";
22
23
  }
23
- function qt(s, d) {
24
- return s != null && s.length ? s.map((n) => `${Rt(n.field, d)}: ${(n.labels ?? n.values).join(", ")}`).join(" · ") : "All data";
24
+ function Lt(s, d) {
25
+ return s != null && s.length ? s.map((n) => `${qt(n.field, d)}: ${(n.labels ?? n.values).join(", ")}`).join(" · ") : "All data";
25
26
  }
26
- const Dt = {
27
+ const Ft = {
27
28
  budget: "bg-orange-50 text-orange-600 dark:bg-orange-500/10 dark:text-orange-400",
28
29
  workflows: "bg-sky-50 text-sky-600 dark:bg-sky-500/10 dark:text-sky-400",
29
30
  inventory: "bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400",
30
31
  sla: "bg-pink-50 text-pink-600 dark:bg-pink-500/10 dark:text-pink-400",
31
32
  compliance: "bg-violet-50 text-violet-600 dark:bg-violet-500/10 dark:text-violet-400",
32
33
  spend: "bg-amber-50 text-amber-600 dark:bg-amber-500/10 dark:text-amber-400"
33
- }, Ft = (s) => i(
34
+ }, jt = (s) => i(
34
35
  "inline-flex rounded-full px-2 py-px text-[10.5px] font-semibold",
35
- Dt[s] ?? "bg-slate-100 text-slate-600 dark:bg-muted dark:text-slate-300"
36
+ Ft[s] ?? "bg-slate-100 text-slate-600 dark:bg-muted dark:text-slate-300"
36
37
  );
37
- function j({ status: s }) {
38
+ function O({ status: s }) {
38
39
  return /* @__PURE__ */ t(
39
40
  "span",
40
41
  {
@@ -54,13 +55,13 @@ function j({ status: s }) {
54
55
  }
55
56
  );
56
57
  }
57
- function Y(s) {
58
+ function X(s) {
58
59
  return s.created_by ?? null;
59
60
  }
60
- function he({ on: s }) {
61
+ function xe({ on: s }) {
61
62
  return /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: s ? "On" : "Off" });
62
63
  }
63
- function D({ n: s, tone: d }) {
64
+ function q({ n: s, tone: d }) {
64
65
  return s ? /* @__PURE__ */ t(
65
66
  "span",
66
67
  {
@@ -77,40 +78,40 @@ function D({ n: s, tone: d }) {
77
78
  }
78
79
  ) : null;
79
80
  }
80
- const Lt = "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", jt = 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";
81
- function J(s) {
81
+ const Ot = "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", Mt = 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", M = "w-auto border-red-300 bg-red-50 px-2 text-[11px] font-semibold text-red-700 hover:border-red-300 hover:bg-red-50 hover:text-red-700 dark:border-red-500/40 dark:bg-red-500/10 dark:text-red-400 dark:hover:bg-red-500/10 dark:hover:text-red-400";
82
+ function Z(s) {
82
83
  const d = Date.now() - new Date(s).getTime();
83
84
  if (!Number.isFinite(d)) return null;
84
85
  const n = Math.floor(d / 6e4);
85
86
  if (n < 0) return null;
86
87
  if (n < 1) return "just now";
87
88
  if (n < 60) return `${n}m ago`;
88
- const h = Math.floor(n / 60);
89
- if (h < 24) return `${h}h ago`;
90
- const m = Math.floor(h / 24);
89
+ const u = Math.floor(n / 60);
90
+ if (u < 24) return `${u}h ago`;
91
+ const m = Math.floor(u / 24);
91
92
  return m < 30 ? `${m}d ago` : null;
92
93
  }
93
- function je(s, d) {
94
+ function Me(s, d) {
94
95
  const n = new Date(d).getTime() - new Date(s).getTime();
95
96
  if (!Number.isFinite(n) || n <= 0) return null;
96
- const h = Math.round(n / 6e4);
97
- if (h < 60) return `${h}m`;
98
- const m = Math.round(h / 60);
97
+ const u = Math.round(n / 6e4);
98
+ if (u < 60) return `${u}m`;
99
+ const m = Math.round(u / 60);
99
100
  return m < 48 ? `${m}h` : `${Math.round(m / 24)}d`;
100
101
  }
101
- function pe({ value: s, className: d }) {
102
+ function be({ value: s, className: d }) {
102
103
  if (!s) return /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" });
103
- const n = J(s);
104
+ const n = Z(s);
104
105
  return /* @__PURE__ */ l("span", { className: i("block leading-tight", d), children: [
105
- /* @__PURE__ */ t("span", { className: "block whitespace-nowrap text-[11.5px] text-slate-600 dark:text-slate-300", children: O(s) }),
106
+ /* @__PURE__ */ t("span", { className: "block whitespace-nowrap text-[11.5px] text-slate-600 dark:text-slate-300", children: P(s) }),
106
107
  n && /* @__PURE__ */ t("span", { className: "block text-[10.5px] text-slate-500 dark:text-slate-400", children: n })
107
108
  ] });
108
109
  }
109
- function Ot({
110
+ function Pt({
110
111
  value: s,
111
112
  threshold: d,
112
113
  unit: n,
113
- operator: h,
114
+ operator: u,
114
115
  breaching: m
115
116
  }) {
116
117
  return /* @__PURE__ */ l("span", { className: "flex items-baseline gap-1.5 font-mono tabular-nums", children: [
@@ -121,29 +122,29 @@ function Ot({
121
122
  "text-[12.5px] font-semibold",
122
123
  m ? "text-red-600 dark:text-red-400" : "text-slate-800 dark:text-slate-100"
123
124
  ),
124
- children: A(s, n ?? void 0)
125
+ children: C(s, n ?? void 0)
125
126
  }
126
127
  ),
127
128
  /* @__PURE__ */ l("span", { className: "text-[10.5px] text-slate-400 dark:text-slate-500", children: [
128
- h ? `${be[h] ?? h} ` : "/ ",
129
- A(d, n ?? void 0)
129
+ u ? `${fe[u] ?? u} ` : "/ ",
130
+ C(d, n ?? void 0)
130
131
  ] })
131
132
  ] });
132
133
  }
133
- function Mt({
134
+ function It({
134
135
  operator: s,
135
136
  threshold: d,
136
137
  unit: n
137
138
  }) {
138
139
  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: [
139
- /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: be[s] ?? s }),
140
- A(d, n ?? void 0)
140
+ /* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: fe[s] ?? s }),
141
+ C(d, n ?? void 0)
141
142
  ] });
142
143
  }
143
- function Pt({ text: s }) {
144
+ function Gt({ text: s }) {
144
145
  const [d, n] = _(!1);
145
146
  if (!s) return /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" });
146
- const h = s.length > 120;
147
+ const u = s.length > 120;
147
148
  return /* @__PURE__ */ l("span", { className: "block", children: [
148
149
  /* @__PURE__ */ t(
149
150
  "span",
@@ -155,7 +156,7 @@ function Pt({ text: s }) {
155
156
  children: s
156
157
  }
157
158
  ),
158
- h && /* @__PURE__ */ t(
159
+ u && /* @__PURE__ */ t(
159
160
  "button",
160
161
  {
161
162
  type: "button",
@@ -166,11 +167,11 @@ function Pt({ text: s }) {
166
167
  )
167
168
  ] });
168
169
  }
169
- function xe({
170
+ function ge({
170
171
  title: s,
171
172
  hint: d,
172
173
  action: n,
173
- wide: h,
174
+ wide: u,
174
175
  children: m
175
176
  }) {
176
177
  return (
@@ -180,7 +181,7 @@ function xe({
180
181
  /* @__PURE__ */ l(
181
182
  "section",
182
183
  {
183
- className: i("flex min-h-0 flex-col gap-2", h ? "max-w-[1560px]" : "max-w-[1180px]"),
184
+ className: i("flex min-h-0 flex-col gap-2", u ? "max-w-[1560px]" : "max-w-[1180px]"),
184
185
  children: [
185
186
  /* @__PURE__ */ l("header", { className: "flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1", children: [
186
187
  /* @__PURE__ */ l("div", { className: "flex items-baseline gap-2.5", children: [
@@ -195,30 +196,30 @@ function xe({
195
196
  )
196
197
  );
197
198
  }
198
- function E({
199
+ function T({
199
200
  headers: s,
200
201
  children: d,
201
202
  empty: n,
202
- emptyHint: h,
203
+ emptyHint: u,
203
204
  emptyIcon: m,
204
- emptyAction: T,
205
- loading: C
205
+ emptyAction: E,
206
+ loading: A
206
207
  }) {
207
- const g = !C && (!d || Array.isArray(d) && d.length === 0);
208
+ const g = !A && (!d || Array.isArray(d) && d.length === 0);
208
209
  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: [
209
210
  /* @__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, p) => {
210
- const o = typeof f == "string" ? f : f.label, k = typeof f == "string" ? void 0 : f.width, X = typeof f == "string" ? void 0 : f.align;
211
+ const o = typeof f == "string" ? f : f.label, N = typeof f == "string" ? void 0 : f.width, ee = typeof f == "string" ? void 0 : f.align;
211
212
  return /* @__PURE__ */ t(
212
213
  "th",
213
214
  {
214
- className: i(Lt, X === "right" && "text-right"),
215
- style: k ? { width: k } : void 0,
215
+ className: i(Ot, ee === "right" && "text-right"),
216
+ style: N ? { width: N } : void 0,
216
217
  children: o
217
218
  },
218
219
  `${o}-${p}`
219
220
  );
220
221
  }) }) }),
221
- /* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-100 dark:divide-border/50", children: C ? Array.from({ length: 5 }, (f, p) => /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-3", colSpan: s.length, children: /* @__PURE__ */ t(
222
+ /* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-100 dark:divide-border/50", children: A ? Array.from({ length: 5 }, (f, p) => /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-3", colSpan: s.length, children: /* @__PURE__ */ t(
222
223
  "span",
223
224
  {
224
225
  className: "block h-3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]",
@@ -227,241 +228,238 @@ function E({
227
228
  ) }) }, p)) : 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: [
228
229
  m && /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: m }),
229
230
  /* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: n }),
230
- h && /* @__PURE__ */ t("p", { className: "text-[12px] leading-relaxed text-slate-400 dark:text-slate-500", children: h }),
231
- T && /* @__PURE__ */ t("div", { className: "mt-1", children: T })
231
+ u && /* @__PURE__ */ t("p", { className: "text-[12px] leading-relaxed text-slate-400 dark:text-slate-500", children: u }),
232
+ E && /* @__PURE__ */ t("div", { className: "mt-1", children: E })
232
233
  ] }) }) }) : d })
233
234
  ] }) }) });
234
235
  }
235
- function Xt({
236
+ function ta({
236
237
  defaultTab: s = "catalog",
237
238
  hiddenTabs: d = [],
238
239
  onOpenReport: n,
239
- className: h
240
+ className: u
240
241
  }) {
241
- const m = kt(), T = pt(), { scopes: C } = Nt(), [g, f] = _(s), p = (e) => {
242
- /^Failed\b/.test(e) ? Fe.error(e) : Fe.success(e);
243
- }, o = (e, a, u) => m.request({ _method: e, _path: a, _body: u }), { data: k } = y({
242
+ const m = wt(), E = bt(), { scopes: A } = _t(), [g, f] = _(s), p = (e) => {
243
+ /^Failed\b/.test(e) ? je.error(e) : je.success(e);
244
+ }, o = (e, a, h) => m.request({ _method: e, _path: a, _body: h }), { data: N } = y({
244
245
  queryKey: ["nvr-ma-me"],
245
246
  queryFn: () => o("GET", "/auth/me").then((e) => e.data)
246
- }), X = String((k == null ? void 0 : k.id) ?? "").toLowerCase(), Oe = !!(k != null && k.is_admin), b = (...e) => {
247
- for (const a of e) T.invalidateQueries({ queryKey: [a] });
248
- }, { data: R = [], isLoading: Z } = y({
247
+ }), ee = String((N == null ? void 0 : N.id) ?? "").toLowerCase(), Pe = !!(N != null && N.is_admin), b = (...e) => {
248
+ for (const a of e) E.invalidateQueries({ queryKey: [a] });
249
+ }, { data: R = [], isLoading: te } = y({
249
250
  queryKey: ["nvr-ma-definitions"],
250
251
  queryFn: () => o("GET", "/metric-alerts/definitions").then((e) => e.data)
251
- }), { data: M = [], isLoading: Me } = y({
252
+ }), { data: I = [], isLoading: Ie } = y({
252
253
  queryKey: ["nvr-ma-rules"],
253
254
  queryFn: () => o("GET", "/metric-alerts/rules").then((e) => e.data)
254
- }), { data: P = [], isLoading: Pe } = y({
255
+ }), { data: G = [], isLoading: Ge } = y({
255
256
  queryKey: ["nvr-ma-subs"],
256
257
  queryFn: () => o("GET", "/metric-alerts/subscriptions").then(
257
258
  (e) => e.data
258
259
  )
259
- }), { data: I = [], isLoading: Ie } = y({
260
+ }), { data: H = [], isLoading: He } = y({
260
261
  queryKey: ["nvr-ma-log"],
261
262
  queryFn: () => o("GET", "/metric-alerts/log?limit=100").then(
262
263
  (e) => e.data
263
264
  )
264
- }), { data: ge = [], isLoading: Ge } = y({
265
+ }), { data: ve = [], isLoading: Be } = y({
265
266
  queryKey: ["nvr-ma-notif-subs"],
266
- queryFn: () => m.request(ut()).then((e) => e.data)
267
- }), G = oe({
267
+ queryFn: () => m.request(pt()).then((e) => e.data)
268
+ }), B = me({
268
269
  // Raw PATCH — the route accepts label/filter_field/filter_value/filters/
269
270
  // digest_frequency/is_active; the typed SDK command covers a subset.
270
271
  mutationFn: ({ id: e, patch: a }) => o("PATCH", `/notification-subscriptions/${e}`, a),
271
272
  onSuccess: () => b("nvr-ma-notif-subs")
272
- }), He = oe({
273
- mutationFn: (e) => m.request(ht(e)),
273
+ }), Ke = me({
274
+ mutationFn: (e) => m.request(xt(e)),
274
275
  onSuccess: () => b("nvr-ma-notif-subs")
275
- }), fe = d.includes("widget_alerts"), { data: ee = [], isLoading: Ke } = y({
276
+ }), ye = d.includes("widget_alerts"), { data: ae = [], isLoading: Ue } = y({
276
277
  queryKey: ["nvr-ma-report-alerts"],
277
- enabled: !fe,
278
+ enabled: !ye,
278
279
  queryFn: () => o("GET", "/metric-alerts/report-alerts").then((e) => e.data)
279
- }), Be = ee.some((e) => (e.filters ?? []).length > 0), { data: te } = y({
280
+ }), We = ae.some((e) => (e.filters ?? []).length > 0), { data: le } = y({
280
281
  queryKey: ["nvr-ma-report-filter-bars"],
281
- enabled: !fe && Be,
282
+ enabled: !ye && We,
282
283
  staleTime: 3e5,
283
284
  queryFn: () => o("GET", "/report-studio").then(
284
285
  (e) => new Map((e.data ?? []).map((a) => {
285
- var u;
286
- return [String(a.id), ((u = a.global_filters) == null ? void 0 : u.filter_bar) ?? []];
286
+ var h;
287
+ return [String(a.id), ((h = a.global_filters) == null ? void 0 : h.filter_bar) ?? []];
287
288
  }))
288
289
  ).catch(() => /* @__PURE__ */ new Map())
289
- }), { data: ve = [], isLoading: We } = y({
290
+ }), { data: Ne = [], isLoading: Ve } = y({
290
291
  queryKey: ["nvr-ma-report-alerts-log"],
291
292
  enabled: !d.includes("widget_alert_history"),
292
293
  queryFn: () => o("GET", "/metric-alerts/report-alerts-log").then(
293
294
  (e) => e.data
294
295
  )
295
- }), { data: Ue = [] } = y({
296
+ }), { data: Qe = [] } = y({
296
297
  queryKey: ["nvr-ma-anomaly-defs"],
297
298
  queryFn: () => o("GET", "/metric-alerts/anomaly-definitions").then(
298
299
  (e) => e.data
299
300
  )
300
- }), { data: ye = [], isLoading: Ve } = y({
301
+ }), { data: ke = [], isLoading: ze } = y({
301
302
  queryKey: ["nvr-ma-anomaly-rules"],
302
303
  queryFn: () => o("GET", "/metric-alerts/anomaly-rules").then((e) => e.data)
303
- }), { data: H = [], isLoading: Qe } = y({
304
+ }), { data: K = [], isLoading: Ye } = y({
304
305
  queryKey: ["nvr-ma-anomaly-log"],
305
306
  queryFn: () => o("GET", "/metric-alerts/anomaly-log").then((e) => e.data)
306
- }), [ze, K] = _(!1), [ae, ke] = _(null), [Ye, Ne] = _(null), [Je, B] = _(!1), [le, W] = _(null), [U, re] = _(null), [we, V] = _(!1), _e = z(
307
- () => Object.fromEntries(P.map((e) => [e.rule_id, e])),
308
- [P]
309
- ), Xe = z(() => {
307
+ }), [Je, U] = _(!1), [re, we] = _(null), [Xe, _e] = _(null), [Ze, W] = _(!1), [se, V] = _(null), [Q, ne] = _(null), [Ce, z] = _(!1), Ae = J(
308
+ () => Object.fromEntries(G.map((e) => [e.rule_id, e])),
309
+ [G]
310
+ ), et = J(() => {
310
311
  const e = {};
311
- for (const a of I)
312
+ for (const a of H)
312
313
  a.status === "firing" && !a.resolved_at && (e[a.rule_id] = a);
313
314
  return e;
314
- }, [I]), Ae = z(
315
- () => H.filter((e) => e.status !== "resolved").length,
316
- [H]
317
- ), Ze = async (e) => {
318
- const a = _e[e.id];
315
+ }, [H]), Se = J(
316
+ () => K.filter((e) => e.status !== "resolved").length,
317
+ [K]
318
+ ), tt = async (e) => {
319
+ const a = Ae[e.id];
319
320
  try {
320
321
  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");
321
322
  } catch {
322
323
  p("Failed to update subscription");
323
324
  }
324
- }, se = async (e, a) => {
325
+ }, ie = async (e, a) => {
325
326
  try {
326
327
  await o("PATCH", `/metric-alerts/subscriptions/${e}`, a), b("nvr-ma-subs");
327
328
  } catch {
328
329
  p("Failed to update subscription");
329
330
  }
330
- }, et = async (e) => {
331
- var a, u;
332
- V(!0);
331
+ }, at = async (e) => {
332
+ var a, h;
333
+ z(!0);
333
334
  try {
334
- if (ae)
335
- await o("PATCH", `/metric-alerts/rules/${ae.id}`, e), p("Alert rule updated");
335
+ if (re)
336
+ await o("PATCH", `/metric-alerts/rules/${re.id}`, e), p("Alert rule updated");
336
337
  else {
337
338
  const c = R.find((x) => x.id === e.definition_id), v = { ...e.filters ?? {} };
338
339
  for (const x of (c == null ? void 0 : c.supported_filters) ?? []) {
339
340
  if ((a = v[x.key]) != null && a.length) continue;
340
- const N = wt(C, { key: x.key, collection: x.collection });
341
- if (!N) continue;
342
- const $ = (u = C == null ? void 0 : C.restricted) == null ? void 0 : u[N.name];
341
+ const k = Ct(A, { key: x.key, collection: x.collection });
342
+ if (!k) continue;
343
+ const $ = (h = A == null ? void 0 : A.restricted) == null ? void 0 : h[k.name];
343
344
  if (!($ != null && $.length)) continue;
344
- const F = _t(C, N.name), Q = F.length ? F : $;
345
- v[x.key] = await At(
345
+ const L = At(A, k.name), Y = L.length ? L : $;
346
+ v[x.key] = await St(
346
347
  m,
347
- N,
348
- Q,
348
+ k,
349
+ Y,
349
350
  x.value_field
350
351
  );
351
352
  }
352
353
  await o("POST", "/metric-alerts/rules", { ...e, filters: v }), p("Alert rule created");
353
354
  }
354
- K(!1), b("nvr-ma-rules", "nvr-ma-subs");
355
+ U(!1), b("nvr-ma-rules", "nvr-ma-subs");
355
356
  } catch {
356
357
  p("Failed to save rule");
357
358
  } finally {
358
- V(!1);
359
+ z(!1);
359
360
  }
360
- }, tt = async (e) => {
361
- if (window.confirm(`Delete rule "${e.name}"? This removes the rule and all subscriptions.`))
362
- try {
363
- await o("DELETE", `/metric-alerts/rules/${e.id}`), p("Alert rule deleted"), b("nvr-ma-rules", "nvr-ma-subs", "nvr-ma-log");
364
- } catch {
365
- p("Failed to delete rule");
366
- }
367
- }, at = async (e) => {
368
- V(!0);
361
+ }, lt = async (e) => {
369
362
  try {
370
- le ? (await o("PATCH", `/metric-alerts/anomaly-rules/${le.id}`, e), p("Anomaly rule updated")) : (await o("POST", "/metric-alerts/anomaly-rules", e), p("Anomaly rule created")), B(!1), W(null), b("nvr-ma-anomaly-rules");
363
+ await o("DELETE", `/metric-alerts/rules/${e.id}`), p("Alert rule deleted"), b("nvr-ma-rules", "nvr-ma-subs", "nvr-ma-log");
364
+ } catch {
365
+ p("Failed to delete rule");
366
+ }
367
+ }, rt = async (e) => {
368
+ z(!0);
369
+ try {
370
+ 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), V(null), b("nvr-ma-anomaly-rules");
371
371
  } catch {
372
372
  p("Failed to save anomaly rule");
373
373
  } finally {
374
- V(!1);
374
+ z(!1);
375
375
  }
376
- }, lt = async (e) => {
377
- if (window.confirm(`Delete anomaly rule "${e.name}"? Its log entries are also removed.`))
378
- try {
379
- await o("DELETE", `/metric-alerts/anomaly-rules/${e.id}`), p("Anomaly rule deleted"), b("nvr-ma-anomaly-rules", "nvr-ma-anomaly-log");
380
- } catch {
381
- p("Failed to delete anomaly rule");
382
- }
383
- }, Ce = async (e, a) => {
376
+ }, st = async (e) => {
377
+ try {
378
+ await o("DELETE", `/metric-alerts/anomaly-rules/${e.id}`), p("Anomaly rule deleted"), b("nvr-ma-anomaly-rules", "nvr-ma-anomaly-log");
379
+ } catch {
380
+ p("Failed to delete anomaly rule");
381
+ }
382
+ }, Te = async (e, a) => {
384
383
  try {
385
384
  await o("PATCH", `/metric-alerts/anomaly-rules/${e}`, a), b("nvr-ma-anomaly-rules");
386
385
  } catch {
387
386
  p("Failed to update anomaly rule");
388
387
  }
389
- }, Se = async (e, a) => {
388
+ }, Ee = async (e, a) => {
390
389
  try {
391
390
  await o("PATCH", `/metric-alerts/anomaly-log/${e}`, { status: a }), b("nvr-ma-anomaly-log");
392
391
  } catch {
393
392
  p("Failed to update anomaly");
394
393
  }
395
- }, ne = async (e, a) => {
394
+ }, de = async (e, a) => {
396
395
  try {
397
396
  await o("PATCH", `/report-studio/${e.report}/alerts/${e.id}`, a), b("nvr-ma-report-alerts");
398
397
  } catch {
399
398
  p("Failed to update widget alert");
400
399
  }
401
- }, rt = async (e) => {
402
- if (window.confirm(`Delete widget alert "${e.name}"?`))
403
- try {
404
- await o("DELETE", `/report-studio/${e.report}/alerts/${e.id}`), p("Widget alert deleted"), b("nvr-ma-report-alerts", "nvr-ma-report-alerts-log");
405
- } catch {
406
- p("Failed to delete widget alert");
407
- }
408
- }, st = oe({
400
+ }, nt = async (e) => {
401
+ try {
402
+ await o("DELETE", `/report-studio/${e.report}/alerts/${e.id}`), p("Widget alert deleted"), b("nvr-ma-report-alerts", "nvr-ma-report-alerts-log");
403
+ } catch {
404
+ p("Failed to delete widget alert");
405
+ }
406
+ }, it = me({
409
407
  mutationFn: (e) => o("POST", `/report-studio/${e.report_id}/alerts/${e.alert}/resolve`),
410
408
  onSuccess: () => b("nvr-ma-report-alerts-log", "nvr-ma-report-alerts")
411
- }), nt = z(() => {
409
+ }), dt = J(() => {
412
410
  const e = /* @__PURE__ */ new Map();
413
411
  for (const a of R)
414
412
  e.has(a.category) || e.set(a.category, []), e.get(a.category).push(a);
415
413
  return e;
416
- }, [R]), ie = I.filter((e) => e.status === "firing").length, it = ve.filter((e) => e.status === "firing").length, dt = ye.filter((e) => e.status === "active").length, ot = H.filter((e) => e.status === "new").length, ct = [
417
- { key: "catalog", label: "Alert Catalog", icon: /* @__PURE__ */ t(Te, { className: "h-3.5 w-3.5" }) },
418
- { key: "rules", label: "Alert Rules", icon: /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5" }) },
414
+ }, [R]), oe = H.filter((e) => e.status === "firing").length, ot = Ne.filter((e) => e.status === "firing").length, ct = ke.filter((e) => e.status === "active").length, mt = K.filter((e) => e.status === "new").length, ht = [
415
+ { key: "catalog", label: "Alert Catalog", icon: /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" }) },
416
+ { key: "rules", label: "Alert Rules", icon: /* @__PURE__ */ t(De, { className: "h-3.5 w-3.5" }) },
419
417
  {
420
418
  key: "subscriptions",
421
419
  label: "My Subscriptions",
422
- icon: /* @__PURE__ */ t(ce, { className: "h-3.5 w-3.5" }),
423
- badge: /* @__PURE__ */ t(D, { n: P.length + ge.length, tone: "cyan" })
420
+ icon: /* @__PURE__ */ t(he, { className: "h-3.5 w-3.5" }),
421
+ badge: /* @__PURE__ */ t(q, { n: G.length + ve.length, tone: "cyan" })
424
422
  },
425
423
  {
426
424
  key: "history",
427
425
  label: "Alert History",
428
- icon: /* @__PURE__ */ t(xt, { className: "h-3.5 w-3.5" }),
429
- badge: /* @__PURE__ */ t(D, { n: ie, tone: "red" })
426
+ icon: /* @__PURE__ */ t(gt, { className: "h-3.5 w-3.5" }),
427
+ badge: /* @__PURE__ */ t(q, { n: oe, tone: "red" })
430
428
  },
431
429
  {
432
430
  key: "widget_alerts",
433
431
  label: "Widget Alerts",
434
- icon: /* @__PURE__ */ t(bt, { className: "h-3.5 w-3.5" }),
435
- badge: /* @__PURE__ */ t(D, { n: ee.length, tone: "violet" })
432
+ icon: /* @__PURE__ */ t(ft, { className: "h-3.5 w-3.5" }),
433
+ badge: /* @__PURE__ */ t(q, { n: ae.length, tone: "violet" })
436
434
  },
437
435
  {
438
436
  key: "widget_alert_history",
439
437
  label: "Widget Alert History",
440
- icon: /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" }),
441
- badge: /* @__PURE__ */ t(D, { n: it, tone: "red" })
438
+ icon: /* @__PURE__ */ t(qe, { className: "h-3.5 w-3.5" }),
439
+ badge: /* @__PURE__ */ t(q, { n: ot, tone: "red" })
442
440
  },
443
441
  {
444
442
  key: "anomaly_rules",
445
443
  label: "Anomaly Rules",
446
- icon: /* @__PURE__ */ t(qe, { className: "h-3.5 w-3.5" }),
447
- badge: /* @__PURE__ */ t(D, { n: dt, tone: "teal" })
444
+ icon: /* @__PURE__ */ t(Le, { className: "h-3.5 w-3.5" }),
445
+ badge: /* @__PURE__ */ t(q, { n: ct, tone: "teal" })
448
446
  },
449
447
  {
450
448
  key: "anomaly_history",
451
449
  label: "Anomaly History",
452
- icon: /* @__PURE__ */ t(gt, { className: "h-3.5 w-3.5" }),
453
- badge: /* @__PURE__ */ t(D, { n: ot, tone: "red" })
450
+ icon: /* @__PURE__ */ t(vt, { className: "h-3.5 w-3.5" }),
451
+ badge: /* @__PURE__ */ t(q, { n: mt, tone: "red" })
454
452
  }
455
- ].filter((e) => !d.includes(e.key)), Ee = (e) => {
456
- ke(null), Ne(e ?? null), K(!0);
457
- }, q = (e) => Oe || e != null && String(e).toLowerCase() === X, de = "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";
458
- return /* @__PURE__ */ l("div", { className: i("flex flex-col gap-3", h), "data-alert-manager": "", children: [
453
+ ].filter((e) => !d.includes(e.key)), $e = (e) => {
454
+ we(null), _e(e ?? null), U(!0);
455
+ }, D = (e) => Pe || e != null && String(e).toLowerCase() === ee, 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";
456
+ return /* @__PURE__ */ l("div", { className: i("flex flex-col gap-3", u), "data-alert-manager": "", children: [
459
457
  /* @__PURE__ */ t(
460
458
  "div",
461
459
  {
462
460
  className: "flex flex-wrap gap-1 border-b border-slate-200 pb-px dark:border-border",
463
461
  "data-alert-tabs": "",
464
- children: ct.map((e) => /* @__PURE__ */ l(
462
+ children: ht.map((e) => /* @__PURE__ */ l(
465
463
  "button",
466
464
  {
467
465
  type: "button",
@@ -480,7 +478,7 @@ function Xt({
480
478
  ))
481
479
  }
482
480
  ),
483
- g === "catalog" && Z && /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: Array.from({ length: 6 }, (e, a) => /* @__PURE__ */ l(
481
+ 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
482
  "div",
485
483
  {
486
484
  className: "rounded-lg border border-slate-200 bg-white p-3 dark:border-border dark:bg-card",
@@ -492,21 +490,21 @@ function Xt({
492
490
  },
493
491
  a
494
492
  )) }),
495
- g === "catalog" && !Z && R.length > 0 && // One continuous list, not a card grid: the old layout repeated an
493
+ g === "catalog" && !te && R.length > 0 && // One continuous list, not a card grid: the old layout repeated an
496
494
  // identical box (and an identical saturated button) fourteen times,
497
495
  // and its per-category grids left orphan holes on odd counts. Rows
498
496
  // also make room for the fact that actually matters here — whether
499
497
  // 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], u) => /* @__PURE__ */ l("div", { children: [
498
+ /* @__PURE__ */ t("section", { className: "max-w-[1180px] overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [...dt.entries()].map(([e, a], h) => /* @__PURE__ */ l("div", { children: [
501
499
  /* @__PURE__ */ l(
502
500
  "div",
503
501
  {
504
502
  className: i(
505
503
  "flex items-center gap-2 bg-slate-50/80 px-3 py-1.5 dark:bg-muted/30",
506
- u > 0 && "border-t border-slate-200 dark:border-border"
504
+ h > 0 && "border-t border-slate-200 dark:border-border"
507
505
  ),
508
506
  children: [
509
- /* @__PURE__ */ t("span", { className: Ft(e), children: Tt(e) }),
507
+ /* @__PURE__ */ t("span", { className: jt(e), children: Rt(e) }),
510
508
  /* @__PURE__ */ l("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: [
511
509
  a.length,
512
510
  " metric",
@@ -516,7 +514,7 @@ function Xt({
516
514
  }
517
515
  ),
518
516
  /* @__PURE__ */ t("ul", { className: "divide-y divide-slate-100 dark:divide-border/50", children: a.map((c) => {
519
- const v = M.filter((x) => x.definition_id === c.id).length;
517
+ const v = I.filter((x) => x.definition_id === c.id).length;
520
518
  return /* @__PURE__ */ l(
521
519
  "li",
522
520
  {
@@ -526,7 +524,7 @@ function Xt({
526
524
  /* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
527
525
  /* @__PURE__ */ t("p", { className: "truncate text-[13px] font-medium text-slate-800 dark:text-slate-100", children: c.name }),
528
526
  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(ce, { className: "h-2.5 w-2.5" }),
527
+ /* @__PURE__ */ t(he, { className: "h-2.5 w-2.5" }),
530
528
  v
531
529
  ] })
532
530
  ] }),
@@ -536,9 +534,9 @@ function Xt({
536
534
  /* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-wide text-slate-400 dark:text-slate-500", children: c.unit }),
537
535
  /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "·" }),
538
536
  /* @__PURE__ */ l("span", { children: [
539
- be[c.default_operator] ?? c.default_operator,
537
+ fe[c.default_operator] ?? c.default_operator,
540
538
  " ",
541
- c.default_threshold != null ? A(c.default_threshold, c.unit) : "—"
539
+ c.default_threshold != null ? C(c.default_threshold, c.unit) : "—"
542
540
  ] })
543
541
  ] }),
544
542
  /* @__PURE__ */ l(
@@ -547,10 +545,10 @@ function Xt({
547
545
  type: "button",
548
546
  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
547
  onClick: () => {
550
- Ee(c.id), f("rules");
548
+ $e(c.id), f("rules");
551
549
  },
552
550
  children: [
553
- /* @__PURE__ */ t(me, { className: "h-3 w-3" }),
551
+ /* @__PURE__ */ t(ue, { className: "h-3 w-3" }),
554
552
  " Rule"
555
553
  ]
556
554
  }
@@ -561,22 +559,22 @@ function Xt({
561
559
  );
562
560
  }) })
563
561
  ] }, e)) }),
564
- g === "catalog" && !Z && R.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(ft, { className: "h-5 w-5 text-slate-300 dark:text-slate-600" }),
562
+ g === "catalog" && !te && R.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: [
563
+ /* @__PURE__ */ t(yt, { className: "h-5 w-5 text-slate-300 dark:text-slate-600" }),
566
564
  /* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: "No metrics in the catalog yet" }),
567
565
  /* @__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
566
  ] }) }),
569
567
  g === "rules" && /* @__PURE__ */ t(
570
- xe,
568
+ ge,
571
569
  {
572
570
  title: "Alert rules",
573
- hint: `${M.length} rule${M.length === 1 ? "" : "s"} · shared and personal`,
574
- action: /* @__PURE__ */ l("button", { type: "button", className: de, onClick: () => Ee(), children: [
575
- /* @__PURE__ */ t(me, { className: "h-3 w-3" }),
571
+ hint: `${I.length} rule${I.length === 1 ? "" : "s"} · shared and personal`,
572
+ action: /* @__PURE__ */ l("button", { type: "button", className: ce, onClick: () => $e(), children: [
573
+ /* @__PURE__ */ t(ue, { className: "h-3 w-3" }),
576
574
  " New rule"
577
575
  ] }),
578
576
  children: /* @__PURE__ */ t(
579
- E,
577
+ T,
580
578
  {
581
579
  headers: [
582
580
  "Rule",
@@ -588,15 +586,15 @@ function Xt({
588
586
  ],
589
587
  empty: "No alert rules yet",
590
588
  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: de, onClick: () => f("catalog"), children: [
593
- /* @__PURE__ */ t(Te, { className: "h-3 w-3" }),
589
+ emptyIcon: /* @__PURE__ */ t(Fe, { className: "h-5 w-5" }),
590
+ emptyAction: /* @__PURE__ */ l("button", { type: "button", className: ce, onClick: () => f("catalog"), children: [
591
+ /* @__PURE__ */ t(Re, { className: "h-3 w-3" }),
594
592
  " Browse catalog"
595
593
  ] }),
596
- loading: Me,
597
- children: M.map((e) => {
598
- var $, F, Q;
599
- const a = !!_e[e.id], u = q(e.created_by), c = Xe[e.id], v = e.status !== "active", x = e.last_checked_at, N = x ? J(x) : null;
594
+ loading: Ie,
595
+ children: I.map((e) => {
596
+ var $, L, Y;
597
+ const a = !!Ae[e.id], h = D(e.created_by), c = et[e.id], v = e.status !== "active", x = e.last_checked_at, k = x ? Z(x) : null;
600
598
  return /* @__PURE__ */ l(
601
599
  "tr",
602
600
  {
@@ -610,14 +608,14 @@ function Xt({
610
608
  e.definition && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: e.definition.name })
611
609
  ] }),
612
610
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
613
- Mt,
611
+ It,
614
612
  {
615
613
  operator: e.operator,
616
614
  threshold: e.threshold_value,
617
615
  unit: ($ = e.definition) == null ? void 0 : $.unit
618
616
  }
619
617
  ) }),
620
- /* @__PURE__ */ t("td", { className: r, children: v ? /* @__PURE__ */ t(j, { status: e.status }) : c ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
618
+ /* @__PURE__ */ t("td", { className: r, children: v ? /* @__PURE__ */ t(O, { status: e.status }) : c ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
621
619
  /* @__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
620
  /* @__PURE__ */ t(
623
621
  "span",
@@ -629,14 +627,14 @@ function Xt({
629
627
  "Firing"
630
628
  ] }),
631
629
  /* @__PURE__ */ l("span", { className: "font-mono text-[10.5px] tabular-nums text-slate-500 dark:text-slate-400", children: [
632
- c.current_value != null ? `${A(c.current_value, (F = e.definition) == null ? void 0 : F.unit)} now` : A(c.metric_value, (Q = e.definition) == null ? void 0 : Q.unit),
633
- J(c.fired_at) ? ` · fired ${J(c.fired_at)}` : ""
630
+ c.current_value != null ? `${C(c.current_value, (L = e.definition) == null ? void 0 : L.unit)} now` : C(c.metric_value, (Y = e.definition) == null ? void 0 : Y.unit),
631
+ Z(c.fired_at) ? ` · fired ${Z(c.fired_at)}` : ""
634
632
  ] })
635
633
  ] }) : x ? /* @__PURE__ */ l(
636
634
  "span",
637
635
  {
638
636
  className: "inline-flex items-center gap-1.5 text-[11.5px] text-slate-500 dark:text-slate-400",
639
- "data-tip": N ? `Checked ${N}` : void 0,
637
+ "data-tip": k ? `Checked ${k}` : void 0,
640
638
  children: [
641
639
  /* @__PURE__ */ t("span", { "aria-hidden": !0, className: "h-1.5 w-1.5 rounded-full bg-emerald-500/70" }),
642
640
  "Within threshold"
@@ -658,10 +656,10 @@ function Xt({
658
656
  ) }),
659
657
  /* @__PURE__ */ t("td", { className: i(r, "capitalize text-slate-500 dark:text-slate-400"), children: e.check_frequency }),
660
658
  /* @__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" }),
659
+ /* @__PURE__ */ t(Nt, { className: "h-3 w-3" }),
662
660
  " Team"
663
661
  ] }) : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1 text-[11.5px] text-slate-400 dark:text-slate-500", children: [
664
- /* @__PURE__ */ t(yt, { className: "h-3 w-3" }),
662
+ /* @__PURE__ */ t(kt, { className: "h-3 w-3" }),
665
663
  " Private"
666
664
  ] }) }),
667
665
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ l("div", { className: "flex items-center justify-end gap-1", children: [
@@ -671,15 +669,15 @@ function Xt({
671
669
  type: "button",
672
670
  title: a ? "Unsubscribe from this rule" : "Subscribe to this rule",
673
671
  "aria-pressed": a,
674
- onClick: () => Ze(e),
672
+ onClick: () => tt(e),
675
673
  className: i(
676
674
  w,
677
675
  a && "border-nvr-cyan bg-nvr-cyan/10 text-nvr-navy hover:bg-nvr-cyan/15 dark:text-nvr-cyan"
678
676
  ),
679
- children: a ? /* @__PURE__ */ t(ce, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5" })
677
+ children: a ? /* @__PURE__ */ t(he, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(De, { className: "h-3.5 w-3.5" })
680
678
  }
681
679
  ),
682
- u && /* @__PURE__ */ l(mt, { children: [
680
+ h && /* @__PURE__ */ l(ut, { children: [
683
681
  /* @__PURE__ */ t(
684
682
  "button",
685
683
  {
@@ -687,22 +685,24 @@ function Xt({
687
685
  title: "Edit rule",
688
686
  className: w,
689
687
  onClick: () => {
690
- ke(e), Ne(null), K(!0);
688
+ we(e), _e(null), U(!0);
691
689
  },
692
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
690
+ children: /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" })
693
691
  }
694
692
  ),
695
693
  /* @__PURE__ */ t(
696
- "button",
694
+ j,
697
695
  {
698
- type: "button",
699
696
  title: "Delete rule",
697
+ confirmLabel: "Delete?",
698
+ confirmTitle: `Delete rule "${e.name}"? This removes the rule and all subscriptions.`,
700
699
  className: i(
701
700
  w,
702
701
  "hover:border-red-300 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-500/10 dark:hover:text-red-400"
703
702
  ),
704
- onClick: () => tt(e),
705
- children: /* @__PURE__ */ t(L, { className: "h-3.5 w-3.5" })
703
+ armedClassName: M,
704
+ onConfirm: () => void lt(e),
705
+ children: /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5" })
706
706
  }
707
707
  )
708
708
  ] })
@@ -719,7 +719,7 @@ function Xt({
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
- E,
722
+ T,
723
723
  {
724
724
  headers: [
725
725
  "Alert Rule",
@@ -731,8 +731,8 @@ function Xt({
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,
735
- children: P.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
734
+ loading: Ge,
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 })
@@ -741,21 +741,21 @@ function Xt({
741
741
  S,
742
742
  {
743
743
  checked: !!e.delivery_in_app,
744
- onChange: (a) => se(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
748
  S,
749
749
  {
750
750
  checked: !!e.delivery_email,
751
- onChange: (a) => se(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
- Le,
755
+ Oe,
756
756
  {
757
757
  value: String(e.digest_frequency),
758
- onChange: (a) => se(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" },
@@ -764,18 +764,20 @@ function Xt({
764
764
  className: "h-7 w-[105px] text-[11.5px]"
765
765
  }
766
766
  ) }),
767
- /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: O(e.last_notified) }),
768
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(j, { status: e.status }) }),
767
+ /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: P(e.last_notified) }),
768
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(O, { status: e.status }) }),
769
769
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
770
- "button",
770
+ j,
771
771
  {
772
- type: "button",
773
772
  title: "Unsubscribe",
773
+ confirmLabel: "Unsubscribe?",
774
+ confirmTitle: "Unsubscribe from this alert?",
774
775
  className: i(w, "hover:border-red-300 hover:text-red-500"),
775
- onClick: async () => {
776
- window.confirm("Unsubscribe from this alert?") && (await o("DELETE", `/metric-alerts/subscriptions/${e.id}`), b("nvr-ma-subs"));
776
+ armedClassName: M,
777
+ onConfirm: async () => {
778
+ await o("DELETE", `/metric-alerts/subscriptions/${e.id}`), b("nvr-ma-subs");
777
779
  },
778
- children: /* @__PURE__ */ t(L, { className: "h-3.5 w-3.5" })
780
+ children: /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5" })
779
781
  }
780
782
  ) })
781
783
  ] }, e.id))
@@ -784,7 +786,7 @@ function Xt({
784
786
  /* @__PURE__ */ t("p", { className: "pt-3 text-[11px] font-semibold uppercase tracking-wider text-slate-400", children: "Record & workflow notifications" }),
785
787
  /* @__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
788
  /* @__PURE__ */ t(
787
- E,
789
+ T,
788
790
  {
789
791
  headers: [
790
792
  "Subscription",
@@ -794,8 +796,8 @@ function Xt({
794
796
  { label: "", width: 80 }
795
797
  ],
796
798
  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: [
799
+ loading: Be,
800
+ children: ve.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
799
801
  /* @__PURE__ */ l("td", { className: r, children: [
800
802
  /* @__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
803
  /* @__PURE__ */ l("div", { className: "mt-0.5 flex flex-wrap items-center gap-1", children: [
@@ -807,7 +809,7 @@ function Xt({
807
809
  " ",
808
810
  e.filter_value ?? "any"
809
811
  ] }),
810
- (e.filters ?? []).map((a, u) => /* @__PURE__ */ l(
812
+ (e.filters ?? []).map((a, h) => /* @__PURE__ */ l(
811
813
  "span",
812
814
  {
813
815
  className: "inline-flex rounded bg-nvr-cyan/10 px-1.5 py-px text-[10.5px] text-slate-600 dark:text-slate-300",
@@ -819,16 +821,16 @@ function Xt({
819
821
  Array.isArray(a.value) ? a.value.join(", ") : String(a.value ?? "")
820
822
  ]
821
823
  },
822
- `${a.field}-${u}`
824
+ `${a.field}-${h}`
823
825
  ))
824
826
  ] })
825
827
  ] }),
826
828
  /* @__PURE__ */ t("td", { className: i(r, "capitalize"), children: String(e.event_type).replace(/_/g, " ") }),
827
829
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
828
- Le,
830
+ Oe,
829
831
  {
830
832
  value: String(e.digest_frequency ?? "instant"),
831
- onChange: (a) => G.mutate({ id: e.id, patch: { digest_frequency: a } }),
833
+ onChange: (a) => B.mutate({ id: e.id, patch: { digest_frequency: a } }),
832
834
  options: [
833
835
  { label: "Instant", value: "instant" },
834
836
  { label: "Daily", value: "daily" },
@@ -841,7 +843,7 @@ function Xt({
841
843
  S,
842
844
  {
843
845
  checked: !!e.is_active,
844
- onChange: (a) => G.mutate({ id: e.id, patch: { is_active: a } })
846
+ onChange: (a) => B.mutate({ id: e.id, patch: { is_active: a } })
845
847
  }
846
848
  ) }),
847
849
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
@@ -851,20 +853,20 @@ function Xt({
851
853
  type: "button",
852
854
  title: "Edit",
853
855
  className: w,
854
- onClick: () => re(e),
855
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
856
+ onClick: () => ne(e),
857
+ children: /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" })
856
858
  }
857
859
  ),
858
860
  /* @__PURE__ */ t(
859
- "button",
861
+ j,
860
862
  {
861
- type: "button",
862
863
  title: "Remove subscription",
864
+ confirmLabel: "Remove?",
865
+ confirmTitle: "Remove this notification subscription?",
863
866
  className: i(w, "hover:border-red-300 hover:text-red-500"),
864
- onClick: () => {
865
- window.confirm("Remove this notification subscription?") && He.mutate(e.id);
866
- },
867
- children: /* @__PURE__ */ t(L, { className: "h-3.5 w-3.5" })
867
+ armedClassName: M,
868
+ onConfirm: () => Ke.mutate(e.id),
869
+ children: /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5" })
868
870
  }
869
871
  )
870
872
  ] }) })
@@ -873,12 +875,12 @@ function Xt({
873
875
  )
874
876
  ] }),
875
877
  g === "history" && /* @__PURE__ */ t(
876
- xe,
878
+ ge,
877
879
  {
878
880
  title: "Alert history",
879
- hint: ie > 0 ? `${ie} open · last 100 events` : "Last 100 events — none open",
881
+ hint: oe > 0 ? `${oe} open · last 100 events` : "Last 100 events — none open",
880
882
  children: /* @__PURE__ */ t(
881
- E,
883
+ T,
882
884
  {
883
885
  headers: [
884
886
  "Alert rule",
@@ -889,10 +891,10 @@ function Xt({
889
891
  ],
890
892
  empty: "No alerts have fired",
891
893
  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,
894
- children: I.map((e) => {
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());
894
+ emptyIcon: /* @__PURE__ */ t(qe, { className: "h-5 w-5" }),
895
+ loading: He,
896
+ children: H.map((e) => {
897
+ const a = e.status === "firing" && !e.resolved_at, h = e.resolved_at ? Me(e.fired_at, e.resolved_at) : Me(e.fired_at, (/* @__PURE__ */ new Date()).toISOString());
896
898
  return /* @__PURE__ */ l(
897
899
  "tr",
898
900
  {
@@ -919,7 +921,7 @@ function Xt({
919
921
  ] }) }),
920
922
  /* @__PURE__ */ l("td", { className: r, children: [
921
923
  /* @__PURE__ */ t(
922
- Ot,
924
+ Pt,
923
925
  {
924
926
  value: e.metric_value,
925
927
  threshold: e.threshold_value,
@@ -933,15 +935,15 @@ function Xt({
933
935
  "data-alert-current": !0,
934
936
  className: "mt-0.5 block font-mono text-[10.5px] tabular-nums text-slate-500 dark:text-slate-400",
935
937
  children: [
936
- A(e.current_value, e.definition_unit ?? void 0),
938
+ C(e.current_value, e.definition_unit ?? void 0),
937
939
  " now, as you see it"
938
940
  ]
939
941
  }
940
942
  )
941
943
  ] }),
942
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(pe, { value: e.fired_at }) }),
943
- /* @__PURE__ */ t("td", { className: r, children: e.resolved_at ? /* @__PURE__ */ t(pe, { 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(jt, "text-right"), children: /* @__PURE__ */ t("span", { className: i(a && "text-red-600 dark:text-red-400"), children: u ?? "—" }) })
944
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(be, { value: e.fired_at }) }),
945
+ /* @__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" }) }),
946
+ /* @__PURE__ */ t("td", { className: i(Mt, "text-right"), children: /* @__PURE__ */ t("span", { className: i(a && "text-red-600 dark:text-red-400"), children: h ?? "—" }) })
945
947
  ]
946
948
  },
947
949
  e.id
@@ -954,7 +956,7 @@ function Xt({
954
956
  g === "widget_alerts" && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
955
957
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Alerts set up directly on report widgets" }),
956
958
  /* @__PURE__ */ t(
957
- E,
959
+ T,
958
960
  {
959
961
  headers: [
960
962
  "Alert",
@@ -967,8 +969,8 @@ function Xt({
967
969
  { label: "", width: 40 }
968
970
  ],
969
971
  empty: "No widget alerts yet — open any report widget and click the bell icon",
970
- loading: Ke,
971
- children: ee.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
972
+ loading: Ue,
973
+ children: ae.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
972
974
  /* @__PURE__ */ l("td", { className: r, children: [
973
975
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.name }),
974
976
  e.report_name && /* @__PURE__ */ t(
@@ -984,45 +986,47 @@ function Xt({
984
986
  }
985
987
  )
986
988
  ] }),
987
- /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: qt(e.filters, te == null ? void 0 : te.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__ */ t(
989
+ /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: Lt(e.filters, le == null ? void 0 : le.get(String(e.report))) }),
990
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: (e.conditions ?? []).map((a, h) => /* @__PURE__ */ t(
989
991
  "span",
990
992
  {
991
993
  className: "inline-flex rounded bg-slate-100 px-1.5 py-px text-[11px] text-slate-600 dark:bg-muted dark:text-slate-300",
992
- children: $t(a)
994
+ children: Dt(a)
993
995
  },
994
- `${a.field}-${u}`
996
+ `${a.field}-${h}`
995
997
  )) }) }),
996
- /* @__PURE__ */ t("td", { className: r, children: q(Y(e)) ? /* @__PURE__ */ t(
998
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) ? /* @__PURE__ */ t(
997
999
  S,
998
1000
  {
999
1001
  checked: !!e.delivery_inapp,
1000
- onChange: (a) => ne(e, { delivery_inapp: a })
1002
+ onChange: (a) => de(e, { delivery_inapp: a })
1001
1003
  }
1002
- ) : /* @__PURE__ */ t(he, { on: !!e.delivery_inapp }) }),
1003
- /* @__PURE__ */ t("td", { className: r, children: q(Y(e)) ? /* @__PURE__ */ t(
1004
+ ) : /* @__PURE__ */ t(xe, { on: !!e.delivery_inapp }) }),
1005
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) ? /* @__PURE__ */ t(
1004
1006
  S,
1005
1007
  {
1006
1008
  checked: !!e.delivery_email,
1007
- onChange: (a) => ne(e, { delivery_email: a })
1009
+ onChange: (a) => de(e, { delivery_email: a })
1008
1010
  }
1009
- ) : /* @__PURE__ */ t(he, { on: !!e.delivery_email }) }),
1010
- /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: O(e.last_fired) }),
1011
- /* @__PURE__ */ t("td", { className: r, children: q(Y(e)) ? /* @__PURE__ */ t(
1011
+ ) : /* @__PURE__ */ t(xe, { on: !!e.delivery_email }) }),
1012
+ /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: P(e.last_fired) }),
1013
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) ? /* @__PURE__ */ t(
1012
1014
  S,
1013
1015
  {
1014
1016
  checked: !!e.is_active,
1015
- onChange: (a) => ne(e, { is_active: a })
1017
+ onChange: (a) => de(e, { is_active: a })
1016
1018
  }
1017
- ) : /* @__PURE__ */ t(he, { on: !!e.is_active }) }),
1018
- /* @__PURE__ */ t("td", { className: r, children: q(Y(e)) && /* @__PURE__ */ t(
1019
- "button",
1019
+ ) : /* @__PURE__ */ t(xe, { on: !!e.is_active }) }),
1020
+ /* @__PURE__ */ t("td", { className: r, children: D(X(e)) && /* @__PURE__ */ t(
1021
+ j,
1020
1022
  {
1021
- type: "button",
1022
1023
  title: "Delete",
1024
+ confirmLabel: "Delete?",
1025
+ confirmTitle: `Delete widget alert "${e.name}"?`,
1023
1026
  className: i(w, "hover:border-red-300 hover:text-red-500"),
1024
- onClick: () => rt(e),
1025
- children: /* @__PURE__ */ t(L, { className: "h-3.5 w-3.5" })
1027
+ armedClassName: M,
1028
+ onConfirm: () => void nt(e),
1029
+ children: /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5" })
1026
1030
  }
1027
1031
  ) })
1028
1032
  ] }, e.id))
@@ -1032,7 +1036,7 @@ function Xt({
1032
1036
  g === "widget_alert_history" && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
1033
1037
  /* @__PURE__ */ t("p", { className: "text-[12px] text-slate-400", children: "Last 200 widget alert events" }),
1034
1038
  /* @__PURE__ */ t(
1035
- E,
1039
+ T,
1036
1040
  {
1037
1041
  headers: [
1038
1042
  "Alert",
@@ -1043,33 +1047,33 @@ function Xt({
1043
1047
  { label: "", width: 90 }
1044
1048
  ],
1045
1049
  empty: "No widget alert history yet",
1046
- loading: We,
1047
- children: ve.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
1050
+ loading: Ve,
1051
+ children: Ne.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
1048
1052
  /* @__PURE__ */ l("td", { className: r, children: [
1049
1053
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.alert_name }),
1050
1054
  e.report_name && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400", children: e.report_name })
1051
1055
  ] }),
1052
- /* @__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(
1056
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: Object.entries(e.metric_snapshot ?? {}).map(([a, h]) => /* @__PURE__ */ l(
1053
1057
  "span",
1054
1058
  {
1055
1059
  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",
1056
1060
  children: [
1057
1061
  a,
1058
1062
  ": ",
1059
- String(u)
1063
+ String(h)
1060
1064
  ]
1061
1065
  },
1062
1066
  a
1063
1067
  )) }) }),
1064
- /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px]"), children: O(e.fired_at) }),
1065
- /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: O(e.resolved_at) }),
1066
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(j, { status: e.status }) }),
1068
+ /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px]"), children: P(e.fired_at) }),
1069
+ /* @__PURE__ */ t("td", { className: i(r, "text-[11.5px] text-slate-400"), children: P(e.resolved_at) }),
1070
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(O, { status: e.status }) }),
1067
1071
  /* @__PURE__ */ t("td", { className: r, children: e.status === "firing" && /* @__PURE__ */ t(
1068
1072
  "button",
1069
1073
  {
1070
1074
  type: "button",
1071
1075
  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",
1072
- onClick: () => st.mutate(e),
1076
+ onClick: () => it.mutate(e),
1073
1077
  children: "Resolve"
1074
1078
  }
1075
1079
  ) })
@@ -1084,19 +1088,19 @@ function Xt({
1084
1088
  "button",
1085
1089
  {
1086
1090
  type: "button",
1087
- className: de,
1091
+ className: ce,
1088
1092
  onClick: () => {
1089
- W(null), B(!0);
1093
+ V(null), W(!0);
1090
1094
  },
1091
1095
  children: [
1092
- /* @__PURE__ */ t(me, { className: "h-3 w-3" }),
1096
+ /* @__PURE__ */ t(ue, { className: "h-3 w-3" }),
1093
1097
  " New Rule"
1094
1098
  ]
1095
1099
  }
1096
1100
  )
1097
1101
  ] }),
1098
1102
  /* @__PURE__ */ t(
1099
- E,
1103
+ T,
1100
1104
  {
1101
1105
  headers: [
1102
1106
  "Rule",
@@ -1108,9 +1112,9 @@ function Xt({
1108
1112
  { label: "", width: 80 }
1109
1113
  ],
1110
1114
  empty: "No anomaly rules yet — create one to start detecting unusual patterns",
1111
- loading: Ve,
1112
- children: ye.map((e) => {
1113
- const a = q(e.created_by);
1115
+ loading: ze,
1116
+ children: ke.map((e) => {
1117
+ const a = D(e.created_by);
1114
1118
  return /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
1115
1119
  /* @__PURE__ */ l("td", { className: r, children: [
1116
1120
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.name }),
@@ -1132,7 +1136,7 @@ function Xt({
1132
1136
  {
1133
1137
  checked: !!e.delivery_in_app,
1134
1138
  disabled: !a,
1135
- onChange: (u) => Ce(e.id, { delivery_in_app: u })
1139
+ onChange: (h) => Te(e.id, { delivery_in_app: h })
1136
1140
  }
1137
1141
  ) }),
1138
1142
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
@@ -1140,10 +1144,10 @@ function Xt({
1140
1144
  {
1141
1145
  checked: !!e.delivery_email,
1142
1146
  disabled: !a,
1143
- onChange: (u) => Ce(e.id, { delivery_email: u })
1147
+ onChange: (h) => Te(e.id, { delivery_email: h })
1144
1148
  }
1145
1149
  ) }),
1146
- /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(j, { status: e.status }) }),
1150
+ /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(O, { status: e.status }) }),
1147
1151
  /* @__PURE__ */ t("td", { className: r, children: a && /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
1148
1152
  /* @__PURE__ */ t(
1149
1153
  "button",
@@ -1152,19 +1156,21 @@ function Xt({
1152
1156
  title: "Edit",
1153
1157
  className: w,
1154
1158
  onClick: () => {
1155
- W(e), B(!0);
1159
+ V(e), W(!0);
1156
1160
  },
1157
- children: /* @__PURE__ */ t(ue, { className: "h-3.5 w-3.5" })
1161
+ children: /* @__PURE__ */ t(pe, { className: "h-3.5 w-3.5" })
1158
1162
  }
1159
1163
  ),
1160
1164
  /* @__PURE__ */ t(
1161
- "button",
1165
+ j,
1162
1166
  {
1163
- type: "button",
1164
1167
  title: "Delete",
1168
+ confirmLabel: "Delete?",
1169
+ confirmTitle: `Delete anomaly rule "${e.name}"? Its log entries are also removed.`,
1165
1170
  className: i(w, "hover:border-red-300 hover:text-red-500"),
1166
- onClick: () => lt(e),
1167
- children: /* @__PURE__ */ t(L, { className: "h-3.5 w-3.5" })
1171
+ armedClassName: M,
1172
+ onConfirm: () => void st(e),
1173
+ children: /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5" })
1168
1174
  }
1169
1175
  )
1170
1176
  ] }) })
@@ -1174,13 +1180,13 @@ function Xt({
1174
1180
  )
1175
1181
  ] }),
1176
1182
  g === "anomaly_history" && /* @__PURE__ */ t(
1177
- xe,
1183
+ ge,
1178
1184
  {
1179
1185
  wide: !0,
1180
1186
  title: "Detected anomalies",
1181
- hint: `Last 200 detections${Ae ? ` · ${Ae} needing review` : ""}`,
1187
+ hint: `Last 200 detections${Se ? ` · ${Se} needing review` : ""}`,
1182
1188
  children: /* @__PURE__ */ t(
1183
- E,
1189
+ T,
1184
1190
  {
1185
1191
  headers: [
1186
1192
  "Subject",
@@ -1191,12 +1197,12 @@ function Xt({
1191
1197
  ],
1192
1198
  empty: "No anomalies detected",
1193
1199
  emptyHint: "Detections appear here when a subject deviates from its own recent pattern.",
1194
- emptyIcon: /* @__PURE__ */ t(qe, { className: "h-5 w-5" }),
1195
- loading: Qe,
1196
- children: H.map((e) => {
1197
- const a = e.stats_snapshot ?? {}, u = Object.values(
1200
+ emptyIcon: /* @__PURE__ */ t(Le, { className: "h-5 w-5" }),
1201
+ loading: Ye,
1202
+ children: K.map((e) => {
1203
+ const a = e.stats_snapshot ?? {}, h = Object.values(
1198
1204
  a.group ?? {}
1199
- ).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";
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, k = e.status !== "resolved";
1200
1206
  return /* @__PURE__ */ l(
1201
1207
  "tr",
1202
1208
  {
@@ -1212,7 +1218,7 @@ function Xt({
1212
1218
  ),
1213
1219
  /* @__PURE__ */ l("div", { className: "min-w-0", children: [
1214
1220
  /* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: String(a.subject_label ?? e.subject_id) }),
1215
- /* @__PURE__ */ t("p", { className: "truncate text-[11px] text-slate-500 dark:text-slate-400", children: [e.rule_name ?? `Rule #${e.rule_id}`, ...u].join(" · ") })
1221
+ /* @__PURE__ */ t("p", { className: "truncate text-[11px] text-slate-500 dark:text-slate-400", children: [e.rule_name ?? `Rule #${e.rule_id}`, ...h].join(" · ") })
1216
1222
  ] })
1217
1223
  ] }) }),
1218
1224
  /* @__PURE__ */ t("td", { className: r, children: c != null ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
@@ -1230,15 +1236,15 @@ function Xt({
1230
1236
  }
1231
1237
  ),
1232
1238
  v != null && x != null && /* @__PURE__ */ l("span", { className: "font-mono text-[10.5px] tabular-nums text-slate-400 dark:text-slate-500", children: [
1233
- A(v, "dollar"),
1239
+ C(v, "dollar"),
1234
1240
  " vs ",
1235
- A(x, "dollar")
1241
+ C(x, "dollar")
1236
1242
  ] })
1237
1243
  ] }) : /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
1238
- /* @__PURE__ */ t("td", { className: i(r, "max-w-0"), children: /* @__PURE__ */ t(Pt, { text: e.ai_explanation }) }),
1244
+ /* @__PURE__ */ t("td", { className: i(r, "max-w-0"), children: /* @__PURE__ */ t(Gt, { text: e.ai_explanation }) }),
1239
1245
  /* @__PURE__ */ l("td", { className: r, children: [
1240
- /* @__PURE__ */ t(pe, { value: e.detected_at }),
1241
- e.status !== "new" && /* @__PURE__ */ t("span", { className: "mt-1 block", children: /* @__PURE__ */ t(j, { status: e.status }) })
1246
+ /* @__PURE__ */ t(be, { value: e.detected_at }),
1247
+ e.status !== "new" && /* @__PURE__ */ t("span", { className: "mt-1 block", children: /* @__PURE__ */ t(O, { status: e.status }) })
1242
1248
  ] }),
1243
1249
  /* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ l("div", { className: "flex items-center justify-end gap-1", children: [
1244
1250
  e.status === "new" && /* @__PURE__ */ t(
@@ -1246,16 +1252,16 @@ function Xt({
1246
1252
  {
1247
1253
  type: "button",
1248
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",
1249
- onClick: () => Se(e.id, "acknowledged"),
1255
+ onClick: () => Ee(e.id, "acknowledged"),
1250
1256
  children: "Acknowledge"
1251
1257
  }
1252
1258
  ),
1253
- N && /* @__PURE__ */ t(
1259
+ k && /* @__PURE__ */ t(
1254
1260
  "button",
1255
1261
  {
1256
1262
  type: "button",
1257
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",
1258
- onClick: () => Se(e.id, "resolved"),
1264
+ onClick: () => Ee(e.id, "resolved"),
1259
1265
  children: "Resolve"
1260
1266
  }
1261
1267
  )
@@ -1269,43 +1275,43 @@ function Xt({
1269
1275
  )
1270
1276
  }
1271
1277
  ),
1272
- /* @__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" }) }),
1273
1279
  /* @__PURE__ */ t(
1274
- Ct,
1280
+ Tt,
1275
1281
  {
1276
- open: ze,
1282
+ open: Je,
1277
1283
  definitions: R,
1278
- editRule: ae,
1279
- preselectedDefinitionId: Ye,
1280
- onClose: () => K(!1),
1281
- onSave: et,
1282
- saving: we
1284
+ editRule: re,
1285
+ preselectedDefinitionId: Xe,
1286
+ onClose: () => U(!1),
1287
+ onSave: at,
1288
+ saving: Ce
1283
1289
  }
1284
1290
  ),
1285
1291
  /* @__PURE__ */ t(
1286
- St,
1292
+ Et,
1287
1293
  {
1288
- open: Je,
1289
- definitions: Ue,
1290
- editRule: le,
1294
+ open: Ze,
1295
+ definitions: Qe,
1296
+ editRule: se,
1291
1297
  onClose: () => {
1292
- B(!1), W(null);
1298
+ W(!1), V(null);
1293
1299
  },
1294
- onSave: at,
1295
- saving: we
1300
+ onSave: rt,
1301
+ saving: Ce
1296
1302
  }
1297
1303
  ),
1298
1304
  /* @__PURE__ */ t(
1299
- Et,
1305
+ $t,
1300
1306
  {
1301
- open: U != null,
1302
- sub: U,
1303
- onClose: () => re(null),
1304
- saving: G.isPending,
1307
+ open: Q != null,
1308
+ sub: Q,
1309
+ onClose: () => ne(null),
1310
+ saving: B.isPending,
1305
1311
  onSave: (e) => {
1306
- U && G.mutate(
1307
- { id: U.id, patch: e },
1308
- { onSuccess: () => re(null) }
1312
+ Q && B.mutate(
1313
+ { id: Q.id, patch: e },
1314
+ { onSuccess: () => ne(null) }
1309
1315
  );
1310
1316
  }
1311
1317
  }
@@ -1313,7 +1319,7 @@ function Xt({
1313
1319
  ] });
1314
1320
  }
1315
1321
  export {
1316
- Xt as AlertManagerView,
1317
- Rt as alertFilterLabel,
1318
- qt as alertScopeText
1322
+ ta as AlertManagerView,
1323
+ qt as alertFilterLabel,
1324
+ Lt as alertScopeText
1319
1325
  };