@nivaro/react 0.3.100 → 0.3.102

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 (32) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +46 -3
  4. package/dist/index.js +623 -620
  5. package/dist/shared/components/ActivityEntry.js +5 -5
  6. package/dist/shared/components/CollectionBrowserView.js +183 -175
  7. package/dist/shared/components/ItemEditForm.js +2708 -2704
  8. package/dist/shared/components/JobsTray.js +74 -63
  9. package/dist/shared/components/NotificationBell.js +80 -73
  10. package/dist/shared/components/TipLayer.js +56 -41
  11. package/dist/shared/components/cbv-file-label.js +46 -0
  12. package/dist/shared/components/integrations/console/SignalCard.js +40 -40
  13. package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
  14. package/dist/shared/components/integrations/console/drill/status.js +23 -18
  15. package/dist/shared/components/item-edit/RecordInsights.js +86 -86
  16. package/dist/shared/components/item-edit/header-path-preview.js +46 -34
  17. package/dist/shared/components/notifications/DeliveryChips.js +1 -2
  18. package/dist/shared/components/panels/BackgroundMove.js +152 -85
  19. package/dist/shared/components/panels/PipelinePanel.js +602 -594
  20. package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
  21. package/dist/shared/components/profile/DayTimeline.js +145 -140
  22. package/dist/shared/components/profile/PersonAccess.js +679 -383
  23. package/dist/shared/components/profile/PersonActivity.js +404 -427
  24. package/dist/shared/components/profile/PersonDidPanel.js +248 -134
  25. package/dist/shared/components/profile/PersonProfile.js +33 -32
  26. package/dist/shared/components/profile/journey-view.js +166 -0
  27. package/dist/shared/lib/activity-sentence.js +319 -236
  28. package/dist/shared/lib/jobs-tray.js +60 -41
  29. package/dist/shared/lib/move-failure.js +16 -6
  30. package/dist/shared/lib/obligation-banner.js +16 -16
  31. package/dist/shared/lib/partner-failure.js +44 -32
  32. package/package.json +1 -1
@@ -1,70 +1,71 @@
1
- import { jsxs as a, jsx as e, Fragment as Q } from "react/jsx-runtime";
2
- import { useQuery as k, useMutation as L, useQueryClient as K } from "@tanstack/react-query";
3
- import { Undo2 as j, Loader2 as B, Check as I, ShieldCheck as z, ShieldAlert as J, SlidersHorizontal as G, RefreshCw as T, BookUser as H, MonitorSmartphone as V, EyeOff as W, Eye as X, Copy as Y, Trash2 as Z, KeyRound as ee } from "lucide-react";
4
- import { useMemo as te, useState as $ } from "react";
5
- import { toast as g } from "sonner";
6
- import { useNivaroClient as S } from "../../context.js";
7
- import { get as v, patch as ae, put as re, post as D, del as U } from "../../lib/commands.js";
8
- import { formatRelative as ne, cn as N } from "../../lib/utils.js";
9
- import { SimpleSelect as P } from "../ui/SimpleSelect.js";
10
- import { SectionCard as R, EmptyLine as M, ConfirmButton as F } from "./primitives.js";
11
- import { useInvalidatePerson as E, errorText as w } from "./types.js";
12
- const se = [
1
+ import { jsxs as a, jsx as t, Fragment as z } from "react/jsx-runtime";
2
+ import { useQuery as P, useMutation as j, useQueryClient as ae } from "@tanstack/react-query";
3
+ import { Undo2 as Ne, Loader2 as ne, Check as be, ShieldCheck as we, ShieldAlert as he, SlidersHorizontal as Se, RefreshCw as te, BookUser as Ce, MonitorSmartphone as $e, EyeOff as _e, Eye as qe, Copy as Re, Trash2 as Le, KeyRound as Ae } from "lucide-react";
4
+ import { useMemo as xe, useState as K, useRef as W, useEffect as de } from "react";
5
+ import { toast as L } from "sonner";
6
+ import { useNivaroClient as E } from "../../context.js";
7
+ import { get as F, patch as Te, put as De, post as se, del as ge } from "../../lib/commands.js";
8
+ import { toastError as Ke } from "../../lib/error-toast.js";
9
+ import { formatRelative as Pe, cn as A, formatNumber as I } from "../../lib/utils.js";
10
+ import { SimpleSelect as Z } from "../ui/SimpleSelect.js";
11
+ import { SectionCard as J, EmptyLine as fe, ConfirmButton as Y } from "./primitives.js";
12
+ import { useInvalidatePerson as ie, errorText as M } from "./types.js";
13
+ const Fe = [
13
14
  { value: "", label: "Person" },
14
15
  { value: "integration", label: "Integration — an external system writes as it" },
15
16
  { value: "service", label: "Service login" },
16
17
  { value: "bot", label: "Bot" },
17
18
  { value: "placeholder", label: "Placeholder — kept so old references resolve" }
18
19
  ];
19
- function fe({ profile: t }) {
20
- const u = S(), b = E(t.id), { data: d = [] } = k({
20
+ function tt({ profile: e }) {
21
+ const n = E(), d = ie(e.id), { data: i = [] } = P({
21
22
  queryKey: ["nvr-roles"],
22
- queryFn: () => u.request(
23
- v("/roles")
24
- ).then((o) => o.data),
23
+ queryFn: () => n.request(
24
+ F("/roles")
25
+ ).then((m) => m.data),
25
26
  staleTime: 5 * 6e4
26
- }), p = te(
27
+ }), u = xe(
27
28
  () => {
28
- var o;
29
+ var m;
29
30
  return {
30
- role: t.role_id ?? "",
31
- status: t.status,
32
- account_kind: ((o = t.admin) == null ? void 0 : o.account_kind) ?? ""
31
+ role: e.role_id ?? "",
32
+ status: e.status,
33
+ account_kind: ((m = e.admin) == null ? void 0 : m.account_kind) ?? ""
33
34
  };
34
35
  },
35
- [t]
36
- ), [s, m] = $(null), h = s ?? p, l = JSON.stringify(h) !== JSON.stringify(p), i = L({
37
- mutationFn: () => u.request(
38
- ae(`/users/${t.id}`, {
39
- role: h.role || null,
40
- status: h.status,
41
- account_kind: h.account_kind || null
36
+ [e]
37
+ ), [c, x] = K(null), p = c ?? u, N = JSON.stringify(p) !== JSON.stringify(u), o = j({
38
+ mutationFn: () => n.request(
39
+ Te(`/users/${e.id}`, {
40
+ role: p.role || null,
41
+ status: p.status,
42
+ account_kind: p.account_kind || null
42
43
  })
43
44
  ),
44
45
  onSuccess: () => {
45
- m(null), b(), g.success("Access saved");
46
+ x(null), d(), L.success("Access saved");
46
47
  },
47
- onError: (o) => g.error(w(o, "Could not save access"))
48
- }), r = [
48
+ onError: (m) => L.error(M(m, "Could not save access"))
49
+ }), g = [
49
50
  { value: "", label: "No role" },
50
- ...d.map((o) => ({ value: o.id, label: o.admin_access ? `${o.name} · admin` : o.name }))
51
+ ...i.map((m) => ({ value: m.id, label: m.admin_access ? `${m.name} · admin` : m.name }))
51
52
  ];
52
- return /* @__PURE__ */ e(
53
- R,
53
+ return /* @__PURE__ */ t(
54
+ J,
54
55
  {
55
- icon: /* @__PURE__ */ e(z, { className: "h-4 w-4" }),
56
+ icon: /* @__PURE__ */ t(we, { className: "h-4 w-4" }),
56
57
  title: "Access",
57
58
  hint: "Role decides what they can do; status decides whether they can sign in",
58
59
  testId: "access",
59
- actions: l && /* @__PURE__ */ a("span", { className: "flex items-center gap-1.5", children: [
60
+ actions: N && /* @__PURE__ */ a("span", { className: "flex items-center gap-1.5", children: [
60
61
  /* @__PURE__ */ a(
61
62
  "button",
62
63
  {
63
64
  type: "button",
64
- onClick: () => m(null),
65
+ onClick: () => x(null),
65
66
  className: "inline-flex h-7 items-center gap-1 rounded-md px-2 text-[11.5px] font-medium text-slate-400 transition-colors hover:text-slate-600 dark:hover:text-slate-200",
66
67
  children: [
67
- /* @__PURE__ */ e(j, { className: "h-3 w-3" }),
68
+ /* @__PURE__ */ t(Ne, { className: "h-3 w-3" }),
68
69
  " Reset"
69
70
  ]
70
71
  }
@@ -73,12 +74,12 @@ function fe({ profile: t }) {
73
74
  "button",
74
75
  {
75
76
  type: "button",
76
- disabled: i.isPending,
77
- onClick: () => i.mutate(),
77
+ disabled: o.isPending,
78
+ onClick: () => o.mutate(),
78
79
  "data-person-access-save": !0,
79
80
  className: "inline-flex h-7 items-center gap-1 rounded-md bg-nvr-cyan px-2.5 text-[11.5px] font-semibold text-white transition-opacity disabled:opacity-50",
80
81
  children: [
81
- i.isPending ? /* @__PURE__ */ e(B, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(I, { className: "h-3 w-3" }),
82
+ o.isPending ? /* @__PURE__ */ t(ne, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ t(be, { className: "h-3 w-3" }),
82
83
  " ",
83
84
  "Save"
84
85
  ]
@@ -87,26 +88,26 @@ function fe({ profile: t }) {
87
88
  ] }),
88
89
  children: /* @__PURE__ */ a("div", { className: "grid gap-3 sm:grid-cols-2", children: [
89
90
  /* @__PURE__ */ a("div", { className: "block", children: [
90
- /* @__PURE__ */ e("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Role" }),
91
- /* @__PURE__ */ e(
92
- P,
91
+ /* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Role" }),
92
+ /* @__PURE__ */ t(
93
+ Z,
93
94
  {
94
95
  ariaLabel: "Role",
95
- value: h.role,
96
- onChange: (o) => m({ ...h, role: o }),
97
- options: r,
96
+ value: p.role,
97
+ onChange: (m) => x({ ...p, role: m }),
98
+ options: g,
98
99
  className: "h-8 text-[12.5px]"
99
100
  }
100
101
  )
101
102
  ] }),
102
103
  /* @__PURE__ */ a("div", { className: "block", children: [
103
- /* @__PURE__ */ e("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Status" }),
104
- /* @__PURE__ */ e(
105
- P,
104
+ /* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Status" }),
105
+ /* @__PURE__ */ t(
106
+ Z,
106
107
  {
107
108
  ariaLabel: "Status",
108
- value: h.status,
109
- onChange: (o) => m({ ...h, status: o }),
109
+ value: p.status,
110
+ onChange: (m) => x({ ...p, status: m }),
110
111
  options: [
111
112
  { value: "active", label: "Active" },
112
113
  { value: "inactive", label: "Inactive" },
@@ -117,24 +118,24 @@ function fe({ profile: t }) {
117
118
  )
118
119
  ] }),
119
120
  /* @__PURE__ */ a("div", { className: "block sm:col-span-2", children: [
120
- /* @__PURE__ */ e("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Account type" }),
121
- /* @__PURE__ */ e(
122
- P,
121
+ /* @__PURE__ */ t("span", { className: "mb-1 block text-[11px] font-medium uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Account type" }),
122
+ /* @__PURE__ */ t(
123
+ Z,
123
124
  {
124
125
  ariaLabel: "Account type",
125
- value: h.account_kind,
126
- onChange: (o) => m({ ...h, account_kind: o }),
127
- options: se,
126
+ value: p.account_kind,
127
+ onChange: (m) => x({ ...p, account_kind: m }),
128
+ options: Fe,
128
129
  className: "h-8 text-[12.5px]"
129
130
  }
130
131
  ),
131
- /* @__PURE__ */ e("span", { className: "mt-1 block text-[11px] text-slate-500 dark:text-slate-400", children: 'Anything but Person is left out of people pickers, never checked against the company directory or retention, and its edits read as "integration" in field history.' })
132
+ /* @__PURE__ */ t("span", { className: "mt-1 block text-[11px] text-slate-500 dark:text-slate-400", children: 'Anything but Person is left out of people pickers, never checked against the company directory or retention, and its edits read as "integration" in field history.' })
132
133
  ] })
133
134
  ] })
134
135
  }
135
136
  );
136
137
  }
137
- const oe = {
138
+ const Ee = {
138
139
  directory: "Directory sync",
139
140
  retention: "Retention policy",
140
141
  offboarding: "Offboarding",
@@ -143,292 +144,587 @@ const oe = {
143
144
  "legacy-redaction": "Legacy redaction job",
144
145
  unknown: "Unknown"
145
146
  };
146
- function ke({ profile: t }) {
147
- var p;
148
- const u = S(), b = t.status === "suspended" || !!((p = t.admin) != null && p.is_redacted), { data: d } = k({
149
- queryKey: ["nvr-user-suspension", t.id],
150
- queryFn: () => u.request(v(`/users/${t.id}/suspension`)).then((s) => s.data).catch(() => null),
151
- enabled: b,
147
+ function rt({ profile: e }) {
148
+ var u;
149
+ const n = E(), d = e.status === "suspended" || !!((u = e.admin) != null && u.is_redacted), { data: i } = P({
150
+ queryKey: ["nvr-user-suspension", e.id],
151
+ queryFn: () => n.request(F(`/users/${e.id}/suspension`)).then((c) => c.data).catch(() => null),
152
+ enabled: d,
152
153
  staleTime: 6e4
153
154
  });
154
- return !b || !d ? null : /* @__PURE__ */ a(
155
+ return !d || !i ? null : /* @__PURE__ */ a(
155
156
  "div",
156
157
  {
157
158
  className: "rounded-lg border border-[#e9c46a] bg-[#fbefd9] px-4 py-3 text-[12.5px] text-[#6b4300] dark:border-[#7a5a14] dark:bg-[#3a2a0d] dark:text-[#f1b95c]",
158
- "data-suspension-reason": d.source,
159
+ "data-suspension-reason": i.source,
159
160
  children: [
160
161
  /* @__PURE__ */ a("p", { className: "font-medium", children: [
161
162
  "Cannot sign in — ",
162
- oe[d.source] ?? d.source,
163
- d.at ? ` · ${new Date(d.at).toLocaleString()}` : "",
164
- d.by ? ` · by ${d.by.name}` : ""
163
+ Ee[i.source] ?? i.source,
164
+ i.at ? ` · ${new Date(i.at).toLocaleString()}` : "",
165
+ i.by ? ` · by ${i.by.name}` : ""
165
166
  ] }),
166
- /* @__PURE__ */ e("p", { className: "mt-0.5", children: d.text }),
167
- /* @__PURE__ */ e("p", { className: "mt-1 text-[11.5px] opacity-80", children: "Set Status back to Active to restore access; a redacted account also needs its details re-entered." })
167
+ /* @__PURE__ */ t("p", { className: "mt-0.5", children: i.text }),
168
+ /* @__PURE__ */ t("p", { className: "mt-1 text-[11.5px] opacity-80", children: "Set Status back to Active to restore access; a redacted account also needs its details re-entered." })
168
169
  ]
169
170
  }
170
171
  );
171
172
  }
172
- function O({
173
- dimension: t,
174
- selected: u,
175
- accent: b,
176
- onToggle: d
177
- }) {
178
- const p = S(), s = t.display_field ?? "name", [m, h] = $(""), l = (n) => n.map((x) => ({ id: x.id, label: String(x[s] ?? x.id) })), { data: i = [] } = k({
179
- queryKey: ["nvr-scope-options", t.name],
180
- queryFn: () => p.request(
181
- v(`/items/${t.target_collection}`, {
182
- fields: `id,${s}`,
173
+ const oe = (e, n) => e.map((d) => ({ id: d.id, label: String(d[n] ?? d.id) }));
174
+ function ye(e) {
175
+ const n = E(), d = e.display_field ?? "name", { data: i = [] } = P({
176
+ queryKey: ["nvr-scope-options", e.name],
177
+ queryFn: () => n.request(
178
+ F(`/items/${e.target_collection}`, {
179
+ fields: `id,${d}`,
183
180
  limit: 200,
184
- ...t.options_sort ? { sort: t.options_sort } : {}
181
+ ...e.options_sort ? { sort: e.options_sort } : {}
185
182
  })
186
- ).then((n) => l(n.data ?? []))
187
- }), r = i.length > 24, { data: o = [], isFetching: C } = k({
188
- queryKey: ["nvr-scope-search", t.name, m],
189
- queryFn: () => p.request(
190
- v(`/items/${t.target_collection}`, {
191
- fields: `id,${s}`,
192
- limit: 30,
193
- filter: JSON.stringify({ [s]: { _contains: m } }),
194
- ...t.options_sort ? { sort: t.options_sort } : {}
195
- })
196
- ).then((n) => l(n.data ?? [])),
197
- enabled: r && m.trim().length > 0,
198
- placeholderData: (n) => n
199
- }), y = new Map(i.map((n) => [String(n.id), n.label]));
200
- for (const n of o) y.set(String(n.id), n.label);
201
- const _ = u.filter((n) => !y.has(String(n))), { data: A = [] } = k({
202
- queryKey: ["nvr-scope-selected-labels", t.name, _.map(String).sort().join(",")],
203
- queryFn: () => p.request(
204
- v(`/items/${t.target_collection}`, {
205
- fields: `id,${s}`,
183
+ ).then((u) => oe(u.data ?? [], d))
184
+ });
185
+ return i;
186
+ }
187
+ function ke(e, n, d = []) {
188
+ const i = E(), u = e.display_field ?? "name", c = ye(e), x = new Map(c.map((o) => [String(o.id), o.label]));
189
+ for (const o of d) x.set(String(o.id), o.label);
190
+ const p = n.filter((o) => !x.has(String(o))), { data: N = [] } = P({
191
+ queryKey: ["nvr-scope-selected-labels", e.name, p.map(String).sort().join(",")],
192
+ queryFn: () => i.request(
193
+ F(`/items/${e.target_collection}`, {
194
+ fields: `id,${u}`,
206
195
  limit: 100,
207
- filter: JSON.stringify({ id: { _in: _ } })
196
+ filter: JSON.stringify({ id: { _in: p } })
208
197
  })
209
- ).then((n) => l(n.data ?? [])),
210
- enabled: _.length > 0
198
+ ).then((o) => oe(o.data ?? [], u)),
199
+ enabled: p.length > 0
211
200
  });
212
- for (const n of A) y.set(String(n.id), n.label);
213
- const q = new Set(u.map(String)), c = (n) => d(
214
- q.has(String(n)) ? u.filter((x) => String(x) !== String(n)) : [...u, n]
215
- ), f = b === "amber" ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400" : "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan";
216
- return r ? /* @__PURE__ */ a("div", { className: "max-w-xl", children: [
217
- u.length > 0 && /* @__PURE__ */ e("div", { className: "mb-1.5 flex flex-wrap gap-1", children: u.map((n) => /* @__PURE__ */ a(
201
+ for (const o of N) x.set(String(o.id), o.label);
202
+ return x;
203
+ }
204
+ function ce({
205
+ dimension: e,
206
+ selected: n,
207
+ accent: d,
208
+ disabled: i,
209
+ staged: u,
210
+ removing: c,
211
+ onToggle: x
212
+ }) {
213
+ const p = E(), N = e.display_field ?? "name", [o, g] = K(""), m = new Set((u ?? []).map(String)), D = new Set((c ?? []).map(String)), _ = ye(e), q = _.length > 24, { data: v = [], isFetching: y } = P({
214
+ queryKey: ["nvr-scope-search", e.name, o],
215
+ queryFn: () => p.request(
216
+ F(`/items/${e.target_collection}`, {
217
+ fields: `id,${N}`,
218
+ limit: 30,
219
+ filter: JSON.stringify({ [N]: { _contains: o } }),
220
+ ...e.options_sort ? { sort: e.options_sort } : {}
221
+ })
222
+ ).then((b) => oe(b.data ?? [], N)),
223
+ enabled: q && o.trim().length > 0,
224
+ placeholderData: (b) => b
225
+ }), s = ke(e, n, v), w = new Set(n.map(String)), S = (b) => x(
226
+ w.has(String(b)) ? n.filter((R) => String(R) !== String(b)) : [...n, b]
227
+ ), C = d === "amber" ? "border-amber-400 bg-amber-50 font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-400" : "border-nvr-cyan bg-accent font-medium text-nvr-navy dark:text-nvr-cyan";
228
+ return q ? /* @__PURE__ */ a("div", { className: "max-w-xl", children: [
229
+ n.length > 0 && /* @__PURE__ */ t("div", { className: "mb-1.5 flex flex-wrap gap-1", children: n.map((b) => /* @__PURE__ */ a(
218
230
  "span",
219
231
  {
220
- className: N(
232
+ className: A(
221
233
  "inline-flex items-center gap-1 rounded-full border py-0.5 pl-2.5 pr-1 text-[11.5px]",
222
- f
234
+ C,
235
+ m.has(String(b)) && "border-dashed"
223
236
  ),
224
237
  children: [
225
- y.get(String(n)) ?? String(n),
226
- /* @__PURE__ */ e(
238
+ s.get(String(b)) ?? String(b),
239
+ /* @__PURE__ */ t(
227
240
  "button",
228
241
  {
229
242
  type: "button",
230
- onClick: () => c(n),
231
- "aria-label": `Remove ${y.get(String(n)) ?? n}`,
243
+ disabled: i,
244
+ onClick: () => S(b),
245
+ "aria-label": `Remove ${s.get(String(b)) ?? b}`,
232
246
  className: "rounded-full px-1 text-slate-400 hover:text-slate-600 dark:hover:text-slate-200",
233
247
  children: "×"
234
248
  }
235
249
  )
236
250
  ]
237
251
  },
238
- String(n)
252
+ String(b)
239
253
  )) }),
240
- /* @__PURE__ */ e(
254
+ /* @__PURE__ */ t(
241
255
  "input",
242
256
  {
243
- value: m,
244
- onChange: (n) => h(n.target.value),
245
- placeholder: `Search ${t.label.toLowerCase()} to add…`,
257
+ value: o,
258
+ onChange: (b) => g(b.target.value),
259
+ disabled: i,
260
+ placeholder: `Search ${e.label.toLowerCase()} to add…`,
246
261
  className: "h-8 w-full rounded-md border border-slate-200 bg-white px-2.5 text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-card"
247
262
  }
248
263
  ),
249
- m.trim().length > 0 && /* @__PURE__ */ a("div", { className: "mt-1 max-h-44 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: [
250
- o.map((n) => {
251
- const x = q.has(String(n.id));
264
+ o.trim().length > 0 && /* @__PURE__ */ a("div", { className: "mt-1 max-h-44 overflow-y-auto rounded-md border border-slate-200 dark:border-border", children: [
265
+ v.map((b) => {
266
+ const R = w.has(String(b.id));
252
267
  return /* @__PURE__ */ a(
253
268
  "button",
254
269
  {
255
270
  type: "button",
256
- onClick: () => c(n.id),
257
- className: N(
271
+ disabled: i,
272
+ onClick: () => S(b.id),
273
+ className: A(
258
274
  "flex w-full items-center justify-between px-2.5 py-1.5 text-left text-[12px] hover:bg-muted",
259
- x ? "font-medium text-nvr-navy dark:text-nvr-cyan" : "text-slate-600 dark:text-slate-300"
275
+ R ? "font-medium text-nvr-navy dark:text-nvr-cyan" : "text-slate-600 dark:text-slate-300"
260
276
  ),
261
277
  children: [
262
- /* @__PURE__ */ e("span", { className: "truncate", children: n.label }),
263
- /* @__PURE__ */ e("span", { className: "pl-2 text-[11px] text-slate-400", children: x ? "Remove" : "Add" })
278
+ /* @__PURE__ */ t("span", { className: "truncate", children: b.label }),
279
+ /* @__PURE__ */ t("span", { className: "pl-2 text-[11px] text-slate-400", children: R ? "Remove" : "Add" })
264
280
  ]
265
281
  },
266
- String(n.id)
282
+ String(b.id)
267
283
  );
268
284
  }),
269
- o.length === 0 && /* @__PURE__ */ e("p", { className: "px-2.5 py-2 text-[11.5px] text-slate-400", children: C ? "Searching…" : "No matches." })
285
+ v.length === 0 && /* @__PURE__ */ t("p", { className: "px-2.5 py-2 text-[11.5px] text-slate-400", children: y ? "Searching…" : "No matches." })
270
286
  ] })
271
- ] }) : /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1", children: i.map((n) => {
272
- const x = q.has(String(n.id));
273
- return /* @__PURE__ */ e(
287
+ ] }) : /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: _.map((b) => {
288
+ const R = w.has(String(b.id));
289
+ return /* @__PURE__ */ t(
274
290
  "button",
275
291
  {
276
292
  type: "button",
277
- "aria-pressed": x,
278
- onClick: () => c(n.id),
279
- className: N(
280
- "rounded-full border px-2.5 py-0.5 text-[11.5px] transition-colors",
281
- x ? f : "border-slate-200 text-slate-500 hover:border-slate-300 dark:border-border dark:text-slate-400"
293
+ "aria-pressed": R,
294
+ disabled: i,
295
+ onClick: () => S(b.id),
296
+ className: A(
297
+ // No colour transition: a press shows its new state at once.
298
+ "rounded-full border px-2.5 py-0.5 text-[11.5px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 disabled:cursor-wait",
299
+ R ? C : D.has(String(b.id)) ? "border-dashed border-amber-400 text-amber-800 line-through decoration-amber-500/70 dark:border-amber-500/60 dark:text-amber-300" : "border-slate-200 text-slate-600 hover:border-slate-300 dark:border-border dark:text-slate-400 dark:hover:border-slate-500",
300
+ R && m.has(String(b.id)) && "border-dashed"
282
301
  ),
283
- children: n.label
302
+ children: b.label
284
303
  },
285
- String(n.id)
304
+ String(b.id)
286
305
  );
287
306
  }) });
288
307
  }
289
- function ve({ userId: t }) {
290
- const u = S(), b = K(), { data: d } = k({
291
- queryKey: ["nvr-user-scopes", t],
292
- queryFn: () => u.request(v(`/user-scopes/${t}`)).then((l) => l.data)
293
- }), p = L({
294
- mutationFn: (l) => u.request(re(`/user-scopes/${t}`, l)),
295
- onSuccess: () => {
296
- b.invalidateQueries({ queryKey: ["nvr-user-scopes", t] }), b.invalidateQueries({ queryKey: ["nvr-person-profile", t] }), b.invalidateQueries({ queryKey: ["nvr-my-scopes"] }), b.invalidateQueries({ queryKey: ["nvr-profile-scopes"] });
308
+ const X = (e, n) => {
309
+ if (e.length !== n.length) return !1;
310
+ const d = new Set(e.map(String));
311
+ return n.every((i) => d.has(String(i)));
312
+ }, Oe = (e, n) => `${e}:${n.map(String).sort().join(",")}`, re = (e) => e.replace(/_/g, " ").replace(/^\w/, (n) => n.toUpperCase()), me = (e) => /s$/i.test(e) ? e : `${e}s`;
313
+ function ee(e) {
314
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e.at(-1)}`;
315
+ }
316
+ function at({
317
+ userId: e,
318
+ previewDelayMs: n = 400
319
+ }) {
320
+ const d = E(), i = ae(), u = xe(() => ["nvr-user-scopes", e], [e]), { data: c } = P({
321
+ queryKey: u,
322
+ queryFn: () => d.request(F(`/user-scopes/${e}`)).then((r) => r.data)
323
+ }), [x, p] = K({}), [N, o] = K({}), g = W({}), m = W({}), D = W({});
324
+ de(() => {
325
+ const r = D.current;
326
+ return () => {
327
+ for (const l of Object.values(r)) clearTimeout(l);
328
+ };
329
+ }, []);
330
+ const _ = (r, l) => {
331
+ clearTimeout(D.current[r]), o((k) => {
332
+ const { [r]: f, ...$ } = k;
333
+ return l ? { ...$, [r]: l } : $;
334
+ }), l === "saved" && (D.current[r] = setTimeout(() => _(r, null), 2400));
335
+ }, q = (r) => i.setQueryData(u, (l) => {
336
+ if (!l) return l;
337
+ const k = r.mode === "restrict" ? "restricted" : "defaults";
338
+ return { ...l, [k]: { ...l[k], [r.dimension]: r.values } };
339
+ }), v = j({
340
+ // One person's scope saves go out one after another, in click order.
341
+ scope: { id: `nvr-user-scopes:${e}` },
342
+ mutationFn: (r) => d.request(De(`/user-scopes/${e}`, r)),
343
+ onMutate: (r) => {
344
+ var $, B;
345
+ const l = `${r.dimension}:${r.mode}`, k = r.mode === "restrict" ? "restricted" : "defaults", f = ((B = ($ = i.getQueryData(u)) == null ? void 0 : $[k]) == null ? void 0 : B[r.dimension]) ?? [];
346
+ return m.current[l] = (m.current[l] ?? 0) + 1, delete g.current[l], p((Q) => ({ ...Q, [l]: r.values })), _(l, "saving"), i.cancelQueries({ queryKey: u }), q(r), { before: f };
347
+ },
348
+ onSuccess: (r, l) => q(l),
349
+ onError: (r, l, k) => {
350
+ var Q, le;
351
+ const f = `${l.dimension}:${l.mode}`, $ = l.mode === "restrict" ? "restricted" : "defaults", B = ((le = (Q = i.getQueryData(u)) == null ? void 0 : Q[$]) == null ? void 0 : le[l.dimension]) ?? [];
352
+ k && X(B, l.values) && q({ ...l, values: k.before }), p((V) => {
353
+ if (!V[f] || !X(V[f], l.values)) return V;
354
+ const { [f]: Ue, ...ve } = V;
355
+ return ve;
356
+ }), g.current[f] = l, Ke(
357
+ r,
358
+ l.mode === "restrict" ? "Could not apply the restriction" : "Could not save the default",
359
+ { retry: () => v.mutate(l) }
360
+ );
297
361
  },
298
- onError: (l) => g.error(w(l, "Could not save scopes"))
299
- }), [s, m] = $(null), h = async (l, i) => {
300
- m({ dimension: l, values: i, loading: !0, impact: null });
301
- try {
302
- const r = await u.request(
303
- D(`/user-scopes/${t}/impact`, { dimension: l, values: i })
362
+ onSettled: (r, l, k) => {
363
+ const f = `${k.dimension}:${k.mode}`;
364
+ m.current[f] = Math.max(0, (m.current[f] ?? 1) - 1), l || p(($) => {
365
+ if (!$[f] || !X($[f], k.values)) return $;
366
+ const { [f]: B, ...Q } = $;
367
+ return Q;
368
+ }), m.current[f] === 0 && _(f, l ? "failed" : "saved"), i.invalidateQueries({ queryKey: u }), i.invalidateQueries({ queryKey: ["nvr-person-profile", e] }), i.invalidateQueries({ queryKey: ["nvr-my-scopes"] }), i.invalidateQueries({ queryKey: ["nvr-profile-scopes"] });
369
+ }
370
+ }), y = (r, l) => x[`${r}:${l}`] ?? (l === "restrict" ? c == null ? void 0 : c.restricted[r] : c == null ? void 0 : c.defaults[r]) ?? [], [s, w] = K(null), [S, C] = K(null), [b, R] = K(0), O = W(0), T = s ? Oe(s.dimension, s.values) : null;
371
+ de(() => {
372
+ if (!s || !T) return;
373
+ const r = ++O.current, l = setTimeout(() => {
374
+ d.request(
375
+ se(`/user-scopes/${e}/impact`, {
376
+ dimension: s.dimension,
377
+ values: s.values
378
+ })
379
+ ).then(
380
+ (k) => {
381
+ r === O.current && C({ key: T, answer: k.data, error: null });
382
+ },
383
+ (k) => {
384
+ r === O.current && C({ key: T, answer: null, error: k });
385
+ }
304
386
  );
305
- m({ dimension: l, values: i, loading: !1, impact: r.data.impact });
306
- } catch {
307
- m({ dimension: l, values: i, loading: !1, impact: null });
387
+ }, n);
388
+ return () => clearTimeout(l);
389
+ }, [T, b, d, e, n]);
390
+ const G = (r, l) => {
391
+ if (X(l, y(r, "restrict"))) {
392
+ O.current++, w(null), C(null);
393
+ return;
308
394
  }
395
+ s && s.dimension !== r && C(null), w({ dimension: r, values: l });
396
+ }, U = () => {
397
+ O.current++, w(null), C(null);
398
+ }, H = () => {
399
+ s && (v.mutate({ dimension: s.dimension, mode: "restrict", values: s.values }), U());
400
+ }, h = (r) => {
401
+ const l = g.current[r];
402
+ l && v.mutate(l);
309
403
  };
310
- return !d || d.dimensions.length === 0 ? null : /* @__PURE__ */ e(
311
- R,
404
+ return !c || c.dimensions.length === 0 ? null : /* @__PURE__ */ t(
405
+ J,
312
406
  {
313
- icon: /* @__PURE__ */ e(G, { className: "h-4 w-4" }),
407
+ icon: /* @__PURE__ */ t(Se, { className: "h-4 w-4" }),
314
408
  title: "Scopes",
315
409
  hint: "Defaults pre-fill their filters; restrictions limit what they can see",
316
410
  testId: "scopes",
317
- children: /* @__PURE__ */ e("div", { className: "space-y-4", children: d.dimensions.map((l) => {
318
- var i;
411
+ children: /* @__PURE__ */ t("div", { className: "space-y-5", children: c.dimensions.map((r) => {
412
+ const l = x[`${r.name}:restrict`] != null, k = (s == null ? void 0 : s.dimension) === r.name;
319
413
  return /* @__PURE__ */ a("div", { children: [
320
- /* @__PURE__ */ e("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: l.label }),
321
- /* @__PURE__ */ a("div", { className: "mt-1.5 space-y-2", children: [
322
- /* @__PURE__ */ a("div", { children: [
323
- /* @__PURE__ */ e("p", { className: "mb-1 text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: "Defaults" }),
324
- /* @__PURE__ */ e(
325
- O,
414
+ /* @__PURE__ */ t("p", { className: "text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: r.label }),
415
+ /* @__PURE__ */ a("div", { className: "mt-1.5 space-y-2.5", children: [
416
+ /* @__PURE__ */ a("div", { "data-scope-defaults": r.name, children: [
417
+ /* @__PURE__ */ a("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
418
+ "Defaults",
419
+ /* @__PURE__ */ t("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: "pre-filled in their filters" }),
420
+ /* @__PURE__ */ t(
421
+ ue,
422
+ {
423
+ slot: `${r.name}:default`,
424
+ status: N[`${r.name}:default`],
425
+ onRetry: h
426
+ }
427
+ )
428
+ ] }),
429
+ /* @__PURE__ */ t(
430
+ ce,
326
431
  {
327
- dimension: l,
328
- selected: d.defaults[l.name] ?? [],
432
+ dimension: r,
433
+ selected: y(r.name, "default"),
329
434
  accent: "cyan",
330
- onToggle: (r) => p.mutate({ dimension: l.name, mode: "default", values: r })
435
+ onToggle: (f) => v.mutate({ dimension: r.name, mode: "default", values: f })
331
436
  }
332
437
  )
333
438
  ] }),
334
- /* @__PURE__ */ a("div", { children: [
335
- /* @__PURE__ */ a("p", { className: "mb-1 flex items-center gap-1 text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: [
336
- /* @__PURE__ */ e(J, { className: "h-3 w-3 text-amber-500" }),
337
- " Restricted to",
338
- /* @__PURE__ */ e("span", { className: "normal-case tracking-normal", children: "(empty = unrestricted; enforced on every read)" })
439
+ /* @__PURE__ */ a("div", { "data-scope-restrict": r.name, children: [
440
+ /* @__PURE__ */ a("p", { className: "mb-1 flex min-h-4 items-center gap-1.5 text-[11px] font-medium text-slate-600 dark:text-slate-300", children: [
441
+ /* @__PURE__ */ t(he, { className: "h-3 w-3 text-amber-500", "aria-hidden": !0 }),
442
+ "Restricted to",
443
+ y(r.name, "restrict").length === 0 && !k ? /* @__PURE__ */ a("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: [
444
+ "none — sees every ",
445
+ r.label.toLowerCase()
446
+ ] }) : /* @__PURE__ */ t("span", { className: "font-normal text-slate-500 dark:text-slate-400", children: "enforced on every read" }),
447
+ /* @__PURE__ */ t(
448
+ ue,
449
+ {
450
+ slot: `${r.name}:restrict`,
451
+ status: N[`${r.name}:restrict`],
452
+ onRetry: h
453
+ }
454
+ )
339
455
  ] }),
340
- /* @__PURE__ */ e(
341
- O,
456
+ /* @__PURE__ */ t(
457
+ ce,
342
458
  {
343
- dimension: l,
344
- selected: (s == null ? void 0 : s.dimension) === l.name ? s.values : d.restricted[l.name] ?? [],
459
+ dimension: r,
460
+ selected: k && s ? s.values : y(r.name, "restrict"),
345
461
  accent: "amber",
346
- onToggle: (r) => void h(l.name, r)
462
+ disabled: l,
463
+ staged: k && s ? s.values.filter(
464
+ (f) => !y(r.name, "restrict").some(($) => String($) === String(f))
465
+ ) : void 0,
466
+ removing: k && s ? y(r.name, "restrict").filter(
467
+ (f) => !s.values.some(($) => String($) === String(f))
468
+ ) : void 0,
469
+ onToggle: (f) => G(r.name, f)
347
470
  }
348
471
  ),
349
- (s == null ? void 0 : s.dimension) === l.name && /* @__PURE__ */ e("div", { className: "mt-1.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[11.5px] text-amber-900 dark:border-amber-500/30 dark:bg-amber-400/10 dark:text-amber-200", children: s.loading ? /* @__PURE__ */ e("p", { children: "Computing impact…" }) : /* @__PURE__ */ a(Q, { children: [
350
- (s.impact ?? []).map((r) => {
351
- var o, C;
352
- return /* @__PURE__ */ a("div", { "data-scope-impact-row": r.collection, children: [
353
- /* @__PURE__ */ a("p", { children: [
354
- /* @__PURE__ */ e("span", { className: "font-mono", children: r.collection }),
355
- ":",
356
- " ",
357
- r.current.toLocaleString(),
358
- " → ",
359
- r.proposed.toLocaleString(),
360
- " of",
361
- " ",
362
- r.total.toLocaleString(),
363
- " visible",
364
- r.proposed === 0 && /* @__PURE__ */ e("span", { className: "ml-1 font-semibold text-red-600 dark:text-red-400", children: "(sees nothing)" })
365
- ] }),
366
- ((r.gained ?? 0) > 0 || (r.lost ?? 0) > 0) && /* @__PURE__ */ a("div", { className: "ml-3 mt-0.5 space-y-0.5 text-[11px]", children: [
367
- (r.gained ?? 0) > 0 && /* @__PURE__ */ a("p", { "data-scope-impact-gained": r.gained, children: [
368
- /* @__PURE__ */ a("span", { className: "font-semibold text-emerald-700 dark:text-emerald-300", children: [
369
- "+",
370
- (r.gained ?? 0).toLocaleString(),
371
- " gained"
372
- ] }),
373
- (((o = r.gained_sample) == null ? void 0 : o.length) ?? 0) > 0 && /* @__PURE__ */ a("span", { className: "opacity-80", children: [
374
- " ",
375
- "· ",
376
- r.gained_sample.map((y) => y.label).join(", "),
377
- (r.gained ?? 0) > r.gained_sample.length ? " …" : ""
378
- ] })
379
- ] }),
380
- (r.lost ?? 0) > 0 && /* @__PURE__ */ a("p", { "data-scope-impact-lost": r.lost, children: [
381
- /* @__PURE__ */ a("span", { className: "font-semibold text-red-700 dark:text-red-300", children: [
382
- "−",
383
- (r.lost ?? 0).toLocaleString(),
384
- " lost"
385
- ] }),
386
- (((C = r.lost_sample) == null ? void 0 : C.length) ?? 0) > 0 && /* @__PURE__ */ a("span", { className: "opacity-80", children: [
387
- " ",
388
- "· ",
389
- r.lost_sample.map((y) => y.label).join(", "),
390
- (r.lost ?? 0) > r.lost_sample.length ? " …" : ""
391
- ] })
392
- ] })
393
- ] })
394
- ] }, r.collection);
395
- }),
396
- (((i = s.impact) == null ? void 0 : i.length) ?? 0) === 0 && /* @__PURE__ */ e("p", { children: "Impact preview unavailable — apply with care." }),
397
- /* @__PURE__ */ a("div", { className: "mt-1.5 flex gap-2", children: [
398
- /* @__PURE__ */ e(
399
- "button",
400
- {
401
- type: "button",
402
- className: "rounded bg-amber-600 px-2 py-0.5 text-[11px] font-medium text-white",
403
- onClick: () => {
404
- p.mutate({
405
- dimension: l.name,
406
- mode: "restrict",
407
- values: s.values
408
- }), m(null);
409
- },
410
- children: "Apply restriction"
411
- }
412
- ),
413
- /* @__PURE__ */ e(
414
- "button",
415
- {
416
- type: "button",
417
- className: "text-[11px] text-slate-500 underline decoration-dotted underline-offset-2",
418
- onClick: () => m(null),
419
- children: "Cancel"
420
- }
421
- )
422
- ] })
423
- ] }) })
472
+ k && s && /* @__PURE__ */ t(
473
+ Qe,
474
+ {
475
+ dimension: r,
476
+ saved: y(r.name, "restrict"),
477
+ values: s.values,
478
+ result: (S == null ? void 0 : S.key) === T ? S : null,
479
+ stale: S && S.key !== T ? S.answer : null,
480
+ onApply: H,
481
+ onCancel: U,
482
+ onRetry: () => R((f) => f + 1)
483
+ }
484
+ )
424
485
  ] })
425
486
  ] })
426
- ] }, l.name);
487
+ ] }, r.name);
427
488
  }) })
428
489
  }
429
490
  );
430
491
  }
431
- const le = [
492
+ function ue({
493
+ slot: e,
494
+ status: n,
495
+ onRetry: d
496
+ }) {
497
+ return /* @__PURE__ */ a(
498
+ "span",
499
+ {
500
+ "data-scope-status": e,
501
+ "aria-live": "polite",
502
+ className: A(
503
+ "inline-flex items-center gap-1 font-normal",
504
+ n === "saved" && "text-emerald-700 dark:text-emerald-400",
505
+ n === "failed" && "font-medium text-red-700 dark:text-red-400",
506
+ n === "saving" && "text-slate-600 dark:text-slate-300"
507
+ ),
508
+ children: [
509
+ n === "saving" && /* @__PURE__ */ a(z, { children: [
510
+ /* @__PURE__ */ t(ne, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
511
+ "Saving…"
512
+ ] }),
513
+ n === "saved" && /* @__PURE__ */ a(z, { children: [
514
+ /* @__PURE__ */ t(be, { className: "h-3 w-3", "aria-hidden": !0 }),
515
+ "Saved"
516
+ ] }),
517
+ n === "failed" && /* @__PURE__ */ a(z, { children: [
518
+ "Not saved",
519
+ /* @__PURE__ */ t(
520
+ "button",
521
+ {
522
+ type: "button",
523
+ onClick: () => d(e),
524
+ className: "rounded font-medium underline decoration-dotted underline-offset-2 hover:decoration-solid focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500/40",
525
+ children: "Retry"
526
+ }
527
+ )
528
+ ] })
529
+ ]
530
+ }
531
+ );
532
+ }
533
+ function Qe({
534
+ dimension: e,
535
+ saved: n,
536
+ values: d,
537
+ result: i,
538
+ stale: u,
539
+ onApply: c,
540
+ onCancel: x,
541
+ onRetry: p
542
+ }) {
543
+ var U, H;
544
+ const N = ke(e, [...n, ...d]), o = (h) => N.get(String(h)) ?? `#${h}`, g = e.label.toLowerCase(), m = new Set(n.map(String)), D = new Set(d.map(String)), _ = d.filter((h) => !m.has(String(h))).map(o), q = n.filter((h) => !D.has(String(h))).map(o), v = (i == null ? void 0 : i.answer) ?? u, y = i ? i.error ? "error" : "ready" : u ? "updating" : "loading", s = (v == null ? void 0 : v.impact) ?? [], w = s.filter((h) => h.proposed === 0 && h.total > 0), S = d.length === 0, C = (h, r = 5) => h.length <= r ? ee(h) : `${h.slice(0, r - 1).join(", ")} and ${h.length - (r - 1)} more`, b = S ? `Remove the ${g} restriction` : n.length === 0 ? `Limit them to ${C(d.map(o))}` : [
545
+ _.length > 0 ? `Also let them see ${C(_)}` : null,
546
+ q.length > 0 ? `${_.length > 0 ? "stop" : "Stop"} them seeing ${C(q)}` : null
547
+ ].filter(Boolean).join("; "), R = S ? `They will see records in every ${g}.` : `After this they only see records in ${C(d.map(o))}.`, O = y === "updating" ? "opacity-40" : "", T = w.map((h) => h.label ?? re(h.collection)), G = T.length <= 2 ? `they lose all ${ee(T)}` : `they lose ${T.length} record types`;
548
+ return /* @__PURE__ */ a(
549
+ "div",
550
+ {
551
+ "data-scope-preview": y,
552
+ className: "mt-2 rounded-md border border-amber-300 bg-amber-50 text-[12px] text-amber-950 dark:border-amber-500/30 dark:bg-amber-400/[0.07] dark:text-amber-50",
553
+ children: [
554
+ /* @__PURE__ */ a("div", { className: "flex items-start gap-3 px-3 pt-2.5", children: [
555
+ /* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
556
+ /* @__PURE__ */ t("p", { className: "font-semibold", children: b }),
557
+ /* @__PURE__ */ t("p", { className: "mt-0.5 text-amber-900 dark:text-amber-200", children: R })
558
+ ] }),
559
+ (y === "loading" || y === "updating") && /* @__PURE__ */ a("span", { className: "mt-0.5 inline-flex shrink-0 items-center gap-1 text-[11px] text-amber-900 dark:text-amber-200", children: [
560
+ /* @__PURE__ */ t(ne, { className: "h-3 w-3 animate-spin motion-reduce:animate-none", "aria-hidden": !0 }),
561
+ y === "loading" ? "Counting records…" : "Recounting — showing the last count"
562
+ ] })
563
+ ] }),
564
+ w.length > 0 && /* @__PURE__ */ a(
565
+ "p",
566
+ {
567
+ className: A(
568
+ "mx-3 mt-2 flex items-start gap-1.5 font-semibold text-red-700 dark:text-red-300",
569
+ O
570
+ ),
571
+ "data-scope-blind": !0,
572
+ children: [
573
+ /* @__PURE__ */ t(he, { className: "mt-px h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
574
+ "They would see nothing in ",
575
+ ee(w.map((h) => h.label ?? re(h.collection))),
576
+ "."
577
+ ]
578
+ }
579
+ ),
580
+ y === "error" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 text-amber-900 dark:text-amber-200", children: /* @__PURE__ */ a("p", { children: [
581
+ "Couldn’t count what changes. Count again, or check the ",
582
+ me(g),
583
+ " above before applying."
584
+ ] }) }) : s.length > 0 ? /* @__PURE__ */ t(
585
+ "ul",
586
+ {
587
+ className: A(
588
+ "mx-3 mt-2 w-fit max-w-[calc(100%-1.5rem)] border-t border-amber-200 dark:border-amber-500/20",
589
+ O
590
+ ),
591
+ "aria-busy": y === "updating",
592
+ children: s.map((h) => /* @__PURE__ */ t(je, { row: h }, h.collection))
593
+ }
594
+ ) : y === "loading" ? /* @__PURE__ */ t("div", { className: "mx-3 mt-2 space-y-1.5", "aria-hidden": !0, children: [0, 1, 2].map((h) => /* @__PURE__ */ t("div", { className: "h-4 max-w-md rounded bg-amber-200/60 dark:bg-amber-400/10" }, h)) }) : /* @__PURE__ */ a("p", { className: "mx-3 mt-2", children: [
595
+ "No records route to ",
596
+ me(g),
597
+ ", so nothing they see changes."
598
+ ] }),
599
+ (((U = v == null ? void 0 : v.partial) == null ? void 0 : U.length) ?? 0) > 0 && /* @__PURE__ */ a("p", { className: "mx-3 mt-1.5 text-[11px] text-amber-900 dark:text-amber-200", children: [
600
+ "Not counted in time: ",
601
+ (H = v == null ? void 0 : v.partial) == null ? void 0 : H.map((h) => h.label).join(", "),
602
+ "."
603
+ ] }),
604
+ /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2 px-3 pb-2.5 pt-2.5", children: [
605
+ y === "error" ? /* @__PURE__ */ a(z, { children: [
606
+ /* @__PURE__ */ t(
607
+ "button",
608
+ {
609
+ type: "button",
610
+ onClick: p,
611
+ className: "inline-flex h-7 items-center rounded-md bg-amber-700 px-3 text-[11.5px] font-medium text-[#fff] hover:bg-amber-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 focus-visible:ring-offset-1 dark:bg-amber-400 dark:text-[#1c1003] dark:hover:bg-amber-300",
612
+ children: "Count again"
613
+ }
614
+ ),
615
+ /* @__PURE__ */ t(
616
+ "button",
617
+ {
618
+ type: "button",
619
+ "data-scope-apply": !0,
620
+ onClick: c,
621
+ className: "inline-flex h-7 items-center rounded-md border border-amber-400 px-3 text-[11.5px] font-medium text-amber-900 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 dark:border-amber-500/50 dark:text-amber-200 dark:hover:bg-amber-400/10",
622
+ children: "Apply without counts"
623
+ }
624
+ )
625
+ ] }) : w.length > 0 && y === "ready" ? /* @__PURE__ */ t("span", { "data-scope-apply-danger": !0, children: /* @__PURE__ */ a(
626
+ Y,
627
+ {
628
+ onConfirm: c,
629
+ confirmLabel: `Press again — ${G}`,
630
+ className: "inline-flex h-7 items-center rounded-md bg-red-600 px-3 text-[11.5px] font-medium text-white hover:bg-red-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-500/50 focus-visible:ring-offset-1 dark:bg-red-700 dark:hover:bg-red-600",
631
+ armedClassName: "bg-red-700 dark:bg-red-800",
632
+ children: [
633
+ "Apply — ",
634
+ G
635
+ ]
636
+ }
637
+ ) }) : /* @__PURE__ */ t(
638
+ "button",
639
+ {
640
+ type: "button",
641
+ "data-scope-apply": !0,
642
+ disabled: !i,
643
+ onClick: c,
644
+ className: "inline-flex h-7 items-center rounded-md bg-amber-700 px-3 text-[11.5px] font-medium text-[#fff] hover:bg-amber-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/50 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:bg-amber-700/45 dark:bg-amber-400 dark:text-[#1c1003] dark:hover:bg-amber-300 dark:disabled:bg-amber-400/40",
645
+ children: S ? "Remove restriction" : "Apply restriction"
646
+ }
647
+ ),
648
+ /* @__PURE__ */ t(
649
+ "button",
650
+ {
651
+ type: "button",
652
+ onClick: x,
653
+ className: "inline-flex h-7 items-center rounded-md px-2 text-[11.5px] text-amber-900 hover:bg-amber-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-500/40 dark:text-amber-200 dark:hover:bg-amber-400/10",
654
+ children: "Cancel"
655
+ }
656
+ ),
657
+ !i && /* @__PURE__ */ t("span", { className: "text-[11px] text-amber-900 dark:text-amber-200", children: "Apply opens once the count is in." })
658
+ ] })
659
+ ]
660
+ }
661
+ );
662
+ }
663
+ function pe({ items: e }) {
664
+ return /* @__PURE__ */ t(z, { children: e.map((n, d) => /* @__PURE__ */ a("span", { children: [
665
+ d > 0 && ", ",
666
+ /^\d+$/.test(n.label) ? /* @__PURE__ */ a("span", { className: "font-mono text-[10.5px]", children: [
667
+ "#",
668
+ n.label
669
+ ] }) : n.label
670
+ ] }, n.id)) });
671
+ }
672
+ function je({ row: e }) {
673
+ var x, p, N, o;
674
+ const n = e.label ?? re(e.collection), d = e.gained ?? 0, i = e.lost ?? 0, u = e.proposed - e.current, c = (g, m) => g > m ? ` and ${I(g - m)} more` : "";
675
+ return /* @__PURE__ */ a(
676
+ "li",
677
+ {
678
+ className: "grid grid-cols-[minmax(9rem,16rem)_9.5rem_5.5rem] items-baseline justify-start gap-x-4 border-b border-amber-200 py-1.5 dark:border-amber-500/20",
679
+ "data-scope-impact-row": e.collection,
680
+ children: [
681
+ /* @__PURE__ */ t("span", { className: "min-w-0 truncate font-medium", children: n }),
682
+ /* @__PURE__ */ a("span", { className: "text-right tabular-nums", children: [
683
+ e.proposed === 0 && e.total > 0 ? /* @__PURE__ */ t("span", { className: "font-semibold text-red-700 dark:text-red-300", children: "none" }) : I(e.proposed),
684
+ /* @__PURE__ */ a("span", { className: "text-amber-900 dark:text-amber-200", children: [
685
+ " of ",
686
+ I(e.total)
687
+ ] })
688
+ ] }),
689
+ /* @__PURE__ */ t(
690
+ "span",
691
+ {
692
+ className: A(
693
+ "text-right text-[11.5px] tabular-nums",
694
+ u > 0 ? "font-semibold text-emerald-700 dark:text-emerald-400" : u < 0 ? "font-semibold text-red-700 dark:text-red-400" : "text-amber-900 dark:text-amber-200"
695
+ ),
696
+ children: u > 0 ? `+${I(u)}` : u < 0 ? `−${I(-u)}` : "no change"
697
+ }
698
+ ),
699
+ d > 0 && (((x = e.gained_sample) == null ? void 0 : x.length) ?? 0) > 0 && /* @__PURE__ */ a(
700
+ "p",
701
+ {
702
+ className: "col-span-3 mt-0.5 truncate text-[11px] text-amber-900 dark:text-amber-200",
703
+ "data-scope-impact-gained": d,
704
+ children: [
705
+ "Newly visible: ",
706
+ /* @__PURE__ */ t(pe, { items: e.gained_sample ?? [] }),
707
+ c(d, ((p = e.gained_sample) == null ? void 0 : p.length) ?? 0)
708
+ ]
709
+ }
710
+ ),
711
+ i > 0 && (((N = e.lost_sample) == null ? void 0 : N.length) ?? 0) > 0 && /* @__PURE__ */ a(
712
+ "p",
713
+ {
714
+ className: "col-span-3 mt-0.5 truncate text-[11px] text-amber-900 dark:text-amber-200",
715
+ "data-scope-impact-lost": i,
716
+ children: [
717
+ "No longer visible: ",
718
+ /* @__PURE__ */ t(pe, { items: e.lost_sample ?? [] }),
719
+ c(i, ((o = e.lost_sample) == null ? void 0 : o.length) ?? 0)
720
+ ]
721
+ }
722
+ )
723
+ ]
724
+ }
725
+ );
726
+ }
727
+ const Me = [
432
728
  { key: "first_name", label: "First name" },
433
729
  { key: "last_name", label: "Last name" },
434
730
  { key: "title", label: "Title" },
@@ -442,51 +738,51 @@ const le = [
442
738
  { key: "employee_id", label: "Employee id" },
443
739
  { key: "preferred_language", label: "Language" }
444
740
  ];
445
- function Ne({ profile: t }) {
446
- var y, _, A, q;
447
- const u = S(), b = K(), d = E(t.id), p = k({
741
+ function nt({ profile: e }) {
742
+ var _, q, v, y;
743
+ const n = E(), d = ae(), i = ie(e.id), u = P({
448
744
  queryKey: ["nvr-directory-status"],
449
- queryFn: () => u.request(v("/directory/status")).then((c) => c.data),
745
+ queryFn: () => n.request(F("/directory/status")).then((s) => s.data),
450
746
  staleTime: 5 * 6e4
451
- }), s = k({
452
- queryKey: ["nvr-directory-entry", t.email],
453
- queryFn: () => u.request(v(`/directory/users/${encodeURIComponent(t.email)}`)).then((c) => c.data).catch((c) => {
454
- if ((c == null ? void 0 : c.status) === 404) return null;
455
- throw c;
747
+ }), c = P({
748
+ queryKey: ["nvr-directory-entry", e.email],
749
+ queryFn: () => n.request(F(`/directory/users/${encodeURIComponent(e.email)}`)).then((s) => s.data).catch((s) => {
750
+ if ((s == null ? void 0 : s.status) === 404) return null;
751
+ throw s;
456
752
  }),
457
- enabled: !!((y = p.data) != null && y.granted && t.email),
753
+ enabled: !!((_ = u.data) != null && _.granted && e.email),
458
754
  staleTime: 6e4
459
- }), m = L({
460
- mutationFn: () => u.request(D(`/directory/sync/${t.id}`)).then((c) => c.data),
461
- onSuccess: ({ summary: c }) => {
462
- d(), b.invalidateQueries({ queryKey: ["nvr-directory-entry", t.email] }), c.active > 0 ? g.success("Still with the company — profile synced from the directory") : g.warning(
463
- `${c.missing > 0 ? "Not in the directory" : "Disabled in Azure"}${c.suspended > 0 ? " — suspended" : ""}`
755
+ }), x = j({
756
+ mutationFn: () => n.request(se(`/directory/sync/${e.id}`)).then((s) => s.data),
757
+ onSuccess: ({ summary: s }) => {
758
+ i(), d.invalidateQueries({ queryKey: ["nvr-directory-entry", e.email] }), s.active > 0 ? L.success("Still with the company — profile synced from the directory") : L.warning(
759
+ `${s.missing > 0 ? "Not in the directory" : "Disabled in Azure"}${s.suspended > 0 ? " — suspended" : ""}`
464
760
  );
465
761
  },
466
- onError: (c) => g.error(w(c, "Directory sync failed"))
762
+ onError: (s) => L.error(M(s, "Directory sync failed"))
467
763
  });
468
- if (p.isLoading || !((_ = p.data) != null && _.configured)) return null;
469
- const h = t, l = (c) => {
470
- var f;
471
- return h[c] ?? ((f = t.admin) == null ? void 0 : f[c]) ?? null;
472
- }, i = s.data, r = ((A = t.admin) == null ? void 0 : A.directory_status) ?? null, o = r === "active" ? "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-200" : r === "disabled" || r === "missing" ? "border-red-200 bg-red-50 text-red-800 dark:border-red-400/30 dark:bg-red-400/10 dark:text-red-200" : "border-slate-200 bg-slate-50 text-slate-600 dark:border-border dark:bg-muted dark:text-muted-foreground", C = r === "active" ? "Still with the company" : r === "disabled" ? "Account disabled in Azure — no longer with the company" : r === "missing" ? "Not in the Microsoft directory — no longer with the company" : "Not checked against the directory yet";
764
+ if (u.isLoading || !((q = u.data) != null && q.configured)) return null;
765
+ const p = e, N = (s) => {
766
+ var w;
767
+ return p[s] ?? ((w = e.admin) == null ? void 0 : w[s]) ?? null;
768
+ }, o = c.data, g = ((v = e.admin) == null ? void 0 : v.directory_status) ?? null, m = g === "active" ? "border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-400/30 dark:bg-emerald-400/10 dark:text-emerald-200" : g === "disabled" || g === "missing" ? "border-red-200 bg-red-50 text-red-800 dark:border-red-400/30 dark:bg-red-400/10 dark:text-red-200" : "border-slate-200 bg-slate-50 text-slate-600 dark:border-border dark:bg-muted dark:text-muted-foreground", D = g === "active" ? "Still with the company" : g === "disabled" ? "Account disabled in Azure — no longer with the company" : g === "missing" ? "Not in the Microsoft directory — no longer with the company" : "Not checked against the directory yet";
473
769
  return /* @__PURE__ */ a(
474
- R,
770
+ J,
475
771
  {
476
- icon: /* @__PURE__ */ e(H, { className: "h-4 w-4" }),
772
+ icon: /* @__PURE__ */ t(Ce, { className: "h-4 w-4" }),
477
773
  title: "Microsoft directory",
478
774
  hint: "Pulling writes every field the directory has a value for; blanks never clear",
479
775
  testId: "directory",
480
- actions: p.data.granted && /* @__PURE__ */ a(
776
+ actions: u.data.granted && /* @__PURE__ */ a(
481
777
  "button",
482
778
  {
483
779
  type: "button",
484
- onClick: () => m.mutate(),
485
- disabled: m.isPending,
780
+ onClick: () => x.mutate(),
781
+ disabled: x.isPending,
486
782
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
487
783
  children: [
488
- /* @__PURE__ */ e(T, { className: N("h-3 w-3", m.isPending && "animate-spin") }),
489
- m.isPending ? "Checking…" : "Sync from directory"
784
+ /* @__PURE__ */ t(te, { className: A("h-3 w-3", x.isPending && "animate-spin") }),
785
+ x.isPending ? "Checking…" : "Sync from directory"
490
786
  ]
491
787
  }
492
788
  ),
@@ -494,155 +790,155 @@ function Ne({ profile: t }) {
494
790
  /* @__PURE__ */ a(
495
791
  "div",
496
792
  {
497
- className: N("rounded-md border px-3 py-2 text-[12.5px]", o),
498
- "data-directory-verdict": r ?? "unchecked",
793
+ className: A("rounded-md border px-3 py-2 text-[12.5px]", m),
794
+ "data-directory-verdict": g ?? "unchecked",
499
795
  children: [
500
- /* @__PURE__ */ e("span", { className: "font-medium", children: C }),
501
- ((q = t.admin) == null ? void 0 : q.directory_checked_at) && /* @__PURE__ */ a("span", { className: "ml-2 text-[11px] opacity-70", children: [
796
+ /* @__PURE__ */ t("span", { className: "font-medium", children: D }),
797
+ ((y = e.admin) == null ? void 0 : y.directory_checked_at) && /* @__PURE__ */ a("span", { className: "ml-2 text-[11px] opacity-70", children: [
502
798
  "checked ",
503
- ne(t.admin.directory_checked_at)
799
+ Pe(e.admin.directory_checked_at)
504
800
  ] }),
505
- (r === "disabled" || r === "missing") && /* @__PURE__ */ e("p", { className: "mt-0.5 text-[11.5px] opacity-80", children: "Hand off what they still own under Admin tools. Redaction stays a separate step." })
801
+ (g === "disabled" || g === "missing") && /* @__PURE__ */ t("p", { className: "mt-0.5 text-[11.5px] opacity-80", children: "Hand off what they still own under Admin tools. Redaction stays a separate step." })
506
802
  ]
507
803
  }
508
804
  ),
509
- p.data.granted ? s.isLoading ? /* @__PURE__ */ e("p", { className: "mt-3 text-[12px] text-slate-400", children: "Looking up the directory…" }) : s.isError ? /* @__PURE__ */ e("p", { className: "mt-3 text-[12px] text-red-600 dark:text-red-400", children: w(s.error, "The directory lookup failed.") }) : i ? /* @__PURE__ */ a("div", { className: "mt-3 space-y-3", children: [
805
+ u.data.granted ? c.isLoading ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-slate-400", children: "Looking up the directory…" }) : c.isError ? /* @__PURE__ */ t("p", { className: "mt-3 text-[12px] text-red-600 dark:text-red-400", children: M(c.error, "The directory lookup failed.") }) : o ? /* @__PURE__ */ a("div", { className: "mt-3 space-y-3", children: [
510
806
  /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2 text-[12px]", children: [
511
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-800 dark:text-foreground", children: i.display_name ?? `${i.first_name ?? ""} ${i.last_name ?? ""}`.trim() }),
512
- i.upn && i.upn.toLowerCase() !== t.email.toLowerCase() && /* @__PURE__ */ a("span", { className: "text-slate-400", children: [
807
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-800 dark:text-foreground", children: o.display_name ?? `${o.first_name ?? ""} ${o.last_name ?? ""}`.trim() }),
808
+ o.upn && o.upn.toLowerCase() !== e.email.toLowerCase() && /* @__PURE__ */ a("span", { className: "text-slate-400", children: [
513
809
  "UPN ",
514
- i.upn
810
+ o.upn
515
811
  ] }),
516
- i.account_enabled === !1 && /* @__PURE__ */ e("span", { className: "rounded-full bg-red-50 px-2 py-0.5 text-[11px] font-medium text-red-700 dark:bg-red-400/10 dark:text-red-300", children: "Disabled in Azure" }),
517
- i.manager && /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: [
812
+ o.account_enabled === !1 && /* @__PURE__ */ t("span", { className: "rounded-full bg-red-50 px-2 py-0.5 text-[11px] font-medium text-red-700 dark:bg-red-400/10 dark:text-red-300", children: "Disabled in Azure" }),
813
+ o.manager && /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: [
518
814
  "Reports to",
519
815
  " ",
520
- /* @__PURE__ */ e("span", { className: "font-medium text-slate-700 dark:text-foreground", children: i.manager.display_name ?? i.manager.email })
816
+ /* @__PURE__ */ t("span", { className: "font-medium text-slate-700 dark:text-foreground", children: o.manager.display_name ?? o.manager.email })
521
817
  ] })
522
818
  ] }),
523
- /* @__PURE__ */ e("dl", { className: "grid gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-2 lg:grid-cols-3", children: le.filter((c) => c.key in i).map((c) => {
524
- const f = i[c.key] ?? null, n = l(c.key), x = !!f && f !== n;
819
+ /* @__PURE__ */ t("dl", { className: "grid gap-px overflow-hidden rounded-lg border border-slate-200 bg-slate-200 dark:border-border dark:bg-border sm:grid-cols-2 lg:grid-cols-3", children: Me.filter((s) => s.key in o).map((s) => {
820
+ const w = o[s.key] ?? null, S = N(s.key), C = !!w && w !== S;
525
821
  return /* @__PURE__ */ a(
526
822
  "div",
527
823
  {
528
- className: N(
824
+ className: A(
529
825
  "bg-white px-3 py-2 dark:bg-card",
530
- x && "bg-amber-50/60 dark:bg-amber-400/10"
826
+ C && "bg-amber-50/60 dark:bg-amber-400/10"
531
827
  ),
532
828
  children: [
533
- /* @__PURE__ */ e("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: c.label }),
534
- /* @__PURE__ */ e("dd", { className: "mt-0.5 text-[12.5px] text-slate-800 dark:text-foreground", children: f ?? /* @__PURE__ */ e("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
535
- x && /* @__PURE__ */ a("dd", { className: "text-[11px] text-slate-400", children: [
829
+ /* @__PURE__ */ t("dt", { className: "text-[10.5px] font-medium uppercase tracking-wide text-slate-400", children: s.label }),
830
+ /* @__PURE__ */ t("dd", { className: "mt-0.5 text-[12.5px] text-slate-800 dark:text-foreground", children: w ?? /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
831
+ C && /* @__PURE__ */ a("dd", { className: "text-[11px] text-slate-400", children: [
536
832
  "stored: ",
537
- n ?? /* @__PURE__ */ e("span", { className: "italic", children: "empty" })
833
+ S ?? /* @__PURE__ */ t("span", { className: "italic", children: "empty" })
538
834
  ] })
539
835
  ]
540
836
  },
541
- c.key
837
+ s.key
542
838
  );
543
839
  }) })
544
840
  ] }) : /* @__PURE__ */ a("p", { className: "mt-3 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
545
841
  "No directory entry matches ",
546
- t.email,
842
+ e.email,
547
843
  "."
548
844
  ] }) : /* @__PURE__ */ a("div", { className: "mt-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200", children: [
549
- /* @__PURE__ */ e("p", { className: "font-medium", children: "Directory access is not granted yet." }),
550
- /* @__PURE__ */ e("p", { className: "mt-0.5", children: p.data.reason ?? "The app token cannot read other users. Grant User.Read.All as an application permission with admin consent." })
845
+ /* @__PURE__ */ t("p", { className: "font-medium", children: "Directory access is not granted yet." }),
846
+ /* @__PURE__ */ t("p", { className: "mt-0.5", children: u.data.reason ?? "The app token cannot read other users. Grant User.Read.All as an application permission with admin consent." })
551
847
  ] })
552
848
  ]
553
849
  }
554
850
  );
555
851
  }
556
- function we({ profile: t }) {
557
- var r;
558
- const u = S(), b = E(t.id), [d, p] = $(null), [s, m] = $(!1), h = L({
559
- mutationFn: () => u.request(D(`/users/${t.id}/token`)).then((o) => o.data.token),
560
- onSuccess: (o) => {
561
- p(o), m(!0), b(), g.success("Token generated — copy it now, it is shown once");
852
+ function st({ profile: e }) {
853
+ var g;
854
+ const n = E(), d = ie(e.id), [i, u] = K(null), [c, x] = K(!1), p = j({
855
+ mutationFn: () => n.request(se(`/users/${e.id}/token`)).then((m) => m.data.token),
856
+ onSuccess: (m) => {
857
+ u(m), x(!0), d(), L.success("Token generated — copy it now, it is shown once");
562
858
  },
563
- onError: (o) => g.error(w(o, "Could not generate a token"))
564
- }), l = L({
565
- mutationFn: () => u.request(U(`/users/${t.id}/token`)),
859
+ onError: (m) => L.error(M(m, "Could not generate a token"))
860
+ }), N = j({
861
+ mutationFn: () => n.request(ge(`/users/${e.id}/token`)),
566
862
  onSuccess: () => {
567
- p(null), m(!1), b(), g.success("Token revoked");
863
+ u(null), x(!1), d(), L.success("Token revoked");
568
864
  },
569
- onError: (o) => g.error(w(o, "Could not revoke the token"))
570
- }), i = !!((r = t.admin) != null && r.has_static_token) || !!d;
571
- return /* @__PURE__ */ e(
572
- R,
865
+ onError: (m) => L.error(M(m, "Could not revoke the token"))
866
+ }), o = !!((g = e.admin) != null && g.has_static_token) || !!i;
867
+ return /* @__PURE__ */ t(
868
+ J,
573
869
  {
574
- icon: /* @__PURE__ */ e(ee, { className: "h-4 w-4" }),
870
+ icon: /* @__PURE__ */ t(Ae, { className: "h-4 w-4" }),
575
871
  title: "API token",
576
872
  hint: "Static bearer token for scripts and the SDK",
577
873
  testId: "api-token",
578
- children: i ? /* @__PURE__ */ a("div", { className: "space-y-3", children: [
579
- d ? /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
580
- /* @__PURE__ */ e("code", { className: "flex-1 break-all rounded-md border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-[12px] text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children: s ? d : "•".repeat(24) }),
581
- /* @__PURE__ */ e(
874
+ children: o ? /* @__PURE__ */ a("div", { className: "space-y-3", children: [
875
+ i ? /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
876
+ /* @__PURE__ */ t("code", { className: "flex-1 break-all rounded-md border border-slate-200 bg-slate-50 px-3 py-2 font-mono text-[12px] text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children: c ? i : "•".repeat(24) }),
877
+ /* @__PURE__ */ t(
582
878
  "button",
583
879
  {
584
880
  type: "button",
585
- onClick: () => m((o) => !o),
586
- "aria-label": s ? "Hide token" : "Reveal token",
881
+ onClick: () => x((m) => !m),
882
+ "aria-label": c ? "Hide token" : "Reveal token",
587
883
  className: "rounded-md border border-slate-200 p-2 text-slate-500 hover:bg-slate-50 dark:border-border dark:hover:bg-muted",
588
- children: s ? /* @__PURE__ */ e(W, { className: "h-4 w-4" }) : /* @__PURE__ */ e(X, { className: "h-4 w-4" })
884
+ children: c ? /* @__PURE__ */ t(_e, { className: "h-4 w-4" }) : /* @__PURE__ */ t(qe, { className: "h-4 w-4" })
589
885
  }
590
886
  ),
591
- /* @__PURE__ */ e(
887
+ /* @__PURE__ */ t(
592
888
  "button",
593
889
  {
594
890
  type: "button",
595
891
  onClick: () => {
596
- navigator.clipboard.writeText(d), g.success("Copied");
892
+ navigator.clipboard.writeText(i), L.success("Copied");
597
893
  },
598
894
  "aria-label": "Copy token",
599
895
  className: "rounded-md border border-slate-200 p-2 text-slate-500 hover:bg-slate-50 dark:border-border dark:hover:bg-muted",
600
- children: /* @__PURE__ */ e(Y, { className: "h-4 w-4" })
896
+ children: /* @__PURE__ */ t(Re, { className: "h-4 w-4" })
601
897
  }
602
898
  )
603
- ] }) : /* @__PURE__ */ e("p", { className: "text-[12.5px] text-slate-600 dark:text-slate-300", children: "A token is set. The value is never shown again — regenerate to issue a new one." }),
899
+ ] }) : /* @__PURE__ */ t("p", { className: "text-[12.5px] text-slate-600 dark:text-slate-300", children: "A token is set. The value is never shown again — regenerate to issue a new one." }),
604
900
  /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
605
901
  /* @__PURE__ */ a(
606
- F,
902
+ Y,
607
903
  {
608
- onConfirm: () => h.mutate(),
609
- disabled: h.isPending,
904
+ onConfirm: () => p.mutate(),
905
+ disabled: p.isPending,
610
906
  confirmLabel: "Replace the current token?",
611
907
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
612
908
  armedClassName: "border-amber-300 text-amber-700 dark:text-amber-300",
613
909
  children: [
614
- /* @__PURE__ */ e(T, { className: "h-3 w-3" }),
910
+ /* @__PURE__ */ t(te, { className: "h-3 w-3" }),
615
911
  " Regenerate"
616
912
  ]
617
913
  }
618
914
  ),
619
915
  /* @__PURE__ */ a(
620
- F,
916
+ Y,
621
917
  {
622
- onConfirm: () => l.mutate(),
623
- disabled: l.isPending,
918
+ onConfirm: () => N.mutate(),
919
+ disabled: N.isPending,
624
920
  confirmLabel: "Revoke — scripts using it stop working?",
625
921
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-red-600 transition-colors hover:bg-red-50 disabled:opacity-50 dark:border-border dark:text-red-400 dark:hover:bg-red-500/10",
626
922
  armedClassName: "border-red-300",
627
923
  children: [
628
- /* @__PURE__ */ e(Z, { className: "h-3 w-3" }),
924
+ /* @__PURE__ */ t(Le, { className: "h-3 w-3" }),
629
925
  " Revoke"
630
926
  ]
631
927
  }
632
928
  )
633
929
  ] })
634
930
  ] }) : /* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-3", children: [
635
- /* @__PURE__ */ e(M, { children: "No token issued." }),
931
+ /* @__PURE__ */ t(fe, { children: "No token issued." }),
636
932
  /* @__PURE__ */ a(
637
933
  "button",
638
934
  {
639
935
  type: "button",
640
- onClick: () => h.mutate(),
641
- disabled: h.isPending,
936
+ onClick: () => p.mutate(),
937
+ disabled: p.isPending,
642
938
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
643
939
  children: [
644
- /* @__PURE__ */ e(T, { className: N("h-3 w-3", h.isPending && "animate-spin") }),
645
- h.isPending ? "Generating…" : "Generate token"
940
+ /* @__PURE__ */ t(te, { className: A("h-3 w-3", p.isPending && "animate-spin") }),
941
+ p.isPending ? "Generating…" : "Generate token"
646
942
  ]
647
943
  }
648
944
  )
@@ -650,45 +946,45 @@ function we({ profile: t }) {
650
946
  }
651
947
  );
652
948
  }
653
- function Se({ userId: t }) {
654
- const u = S(), b = K(), { data: d = [] } = k({
655
- queryKey: ["nvr-user-sessions", t],
656
- queryFn: () => u.request(
657
- v("/security/sessions", { user_id: t })
658
- ).then((s) => s.data).catch(() => []),
949
+ function it({ userId: e }) {
950
+ const n = E(), d = ae(), { data: i = [] } = P({
951
+ queryKey: ["nvr-user-sessions", e],
952
+ queryFn: () => n.request(
953
+ F("/security/sessions", { user_id: e })
954
+ ).then((c) => c.data).catch(() => []),
659
955
  staleTime: 3e4
660
- }), p = L({
661
- mutationFn: (s) => u.request(U(`/security/sessions/${s}`)),
956
+ }), u = j({
957
+ mutationFn: (c) => n.request(ge(`/security/sessions/${c}`)),
662
958
  onSuccess: () => {
663
- b.invalidateQueries({ queryKey: ["nvr-user-sessions", t] }), g.success("Session revoked");
959
+ d.invalidateQueries({ queryKey: ["nvr-user-sessions", e] }), L.success("Session revoked");
664
960
  },
665
- onError: (s) => g.error(w(s, "Could not revoke"))
961
+ onError: (c) => L.error(M(c, "Could not revoke"))
666
962
  });
667
- return /* @__PURE__ */ e(
668
- R,
963
+ return /* @__PURE__ */ t(
964
+ J,
669
965
  {
670
- icon: /* @__PURE__ */ e(V, { className: "h-4 w-4" }),
671
- title: `Live sessions · ${d.length}`,
966
+ icon: /* @__PURE__ */ t($e, { className: "h-4 w-4" }),
967
+ title: `Live sessions · ${i.length}`,
672
968
  hint: "Revoking one signs that browser out on its next request",
673
969
  testId: "sessions",
674
- children: d.length === 0 ? /* @__PURE__ */ e(M, { children: "No live sessions." }) : /* @__PURE__ */ e("ul", { className: "space-y-1.5", children: d.map((s) => /* @__PURE__ */ a(
970
+ children: i.length === 0 ? /* @__PURE__ */ t(fe, { children: "No live sessions." }) : /* @__PURE__ */ t("ul", { className: "space-y-1.5", children: i.map((c) => /* @__PURE__ */ a(
675
971
  "li",
676
972
  {
677
973
  className: "flex items-center gap-2 text-[12px] text-slate-600 dark:text-slate-300",
678
974
  children: [
679
975
  /* @__PURE__ */ a("span", { className: "font-mono text-slate-400", children: [
680
- s.sid_prefix,
976
+ c.sid_prefix,
681
977
  "…"
682
978
  ] }),
683
979
  /* @__PURE__ */ a("span", { className: "text-[11px] text-slate-400", children: [
684
980
  "expires in ",
685
- Math.max(1, Math.round(s.ttl_seconds / 3600)),
981
+ Math.max(1, Math.round(c.ttl_seconds / 3600)),
686
982
  "h"
687
983
  ] }),
688
- /* @__PURE__ */ e(
689
- F,
984
+ /* @__PURE__ */ t(
985
+ Y,
690
986
  {
691
- onConfirm: () => p.mutate(s.sid_prefix),
987
+ onConfirm: () => u.mutate(c.sid_prefix),
692
988
  confirmLabel: "Sign them out?",
693
989
  className: "ml-auto text-[11px] text-red-500 underline decoration-dotted hover:text-red-600",
694
990
  children: "Revoke"
@@ -696,16 +992,16 @@ function Se({ userId: t }) {
696
992
  )
697
993
  ]
698
994
  },
699
- s.sid_prefix
995
+ c.sid_prefix
700
996
  )) })
701
997
  }
702
998
  );
703
999
  }
704
1000
  export {
705
- fe as AccessCard,
706
- we as ApiTokenCard,
707
- Se as SessionsCard,
708
- ke as SuspensionBanner,
709
- Ne as UserDirectoryCard,
710
- ve as UserScopesCard
1001
+ tt as AccessCard,
1002
+ st as ApiTokenCard,
1003
+ it as SessionsCard,
1004
+ rt as SuspensionBanner,
1005
+ nt as UserDirectoryCard,
1006
+ at as UserScopesCard
711
1007
  };