@nivaro/react 0.3.45 → 0.3.46

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 (40) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +42 -7
  4. package/dist/shared/components/BaseMap.js +149 -103
  5. package/dist/shared/components/command-center/CommandCenterView.js +313 -69
  6. package/dist/shared/components/command-center/Customize.js +353 -0
  7. package/dist/shared/components/command-center/Header.js +279 -53
  8. package/dist/shared/components/command-center/KioskLinks.js +198 -0
  9. package/dist/shared/components/command-center/PeekPanel.js +143 -3
  10. package/dist/shared/components/command-center/announce.js +13 -0
  11. package/dist/shared/components/command-center/board-prefs.js +99 -0
  12. package/dist/shared/components/command-center/freshness.js +29 -0
  13. package/dist/shared/components/command-center/layout.js +56 -0
  14. package/dist/shared/components/command-center/panels/AttentionPanel.js +132 -3
  15. package/dist/shared/components/command-center/panels/Banner.js +75 -0
  16. package/dist/shared/components/command-center/panels/BoardSettings.js +223 -0
  17. package/dist/shared/components/command-center/panels/FeedPanel.js +145 -29
  18. package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
  19. package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
  20. package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
  21. package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
  22. package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
  23. package/dist/shared/components/command-center/panels/PeoplePanel.js +257 -40
  24. package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
  25. package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
  26. package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
  27. package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
  28. package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
  29. package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
  30. package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
  31. package/dist/shared/components/command-center/panels/map-shared.js +95 -0
  32. package/dist/shared/components/command-center/panels/registry.js +87 -19
  33. package/dist/shared/components/command-center/shell-hooks.js +118 -0
  34. package/dist/shared/components/command-center/shortcuts.js +37 -0
  35. package/dist/shared/components/command-center/theme.js +39 -21
  36. package/dist/shared/components/command-center/time.js +52 -0
  37. package/dist/shared/components/command-center/url-state.js +54 -0
  38. package/dist/shared/components/command-center/work-links.js +32 -0
  39. package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
  40. package/package.json +1 -1
@@ -1,6 +1,146 @@
1
- function e() {
2
- return null;
1
+ import { jsxs as l, jsx as n } from "react/jsx-runtime";
2
+ import { useQueryClient as y, useMutation as k } from "@tanstack/react-query";
3
+ import { ExternalLink as C } from "lucide-react";
4
+ import { useState as w, useEffect as $ } from "react";
5
+ import { toast as b } from "sonner";
6
+ import { useNivaroClient as P } from "../../context.js";
7
+ import { post as T } from "../../lib/commands.js";
8
+ import { cn as p } from "../../lib/utils.js";
9
+ import { useCcQuery as S } from "./api.js";
10
+ import { CcSidePanel as E, slaWords as U } from "./panels/map-shared.js";
11
+ import { useCc as A } from "./state.js";
12
+ import { MUTED as u, FOCUS as v, BUTTON as x, FAINT as d } from "./theme.js";
13
+ function z() {
14
+ var r;
15
+ const e = A(), s = e.peek, m = () => e.setPeek(null), i = S(
16
+ "/peek",
17
+ s ? { collection: s.collection, id: s.id } : {},
18
+ { enabled: !!s, lenses: !1, retry: !1, staleTime: 15e3 }
19
+ ), a = i.data, o = i.isError && ((r = i.error) == null ? void 0 : r.status) === 404;
20
+ return /* @__PURE__ */ l(
21
+ E,
22
+ {
23
+ peek: !0,
24
+ open: !!s,
25
+ label: "Record preview",
26
+ title: a ? a.title : o ? "Not available" : "Loading…",
27
+ subtitle: a == null ? void 0 : a.collection_label,
28
+ onClose: m,
29
+ footer: a && /* @__PURE__ */ l(
30
+ "button",
31
+ {
32
+ type: "button",
33
+ onClick: () => {
34
+ e.navigate(e.recordUrl(a.collection, a.id)), m();
35
+ },
36
+ className: p(x, v, "inline-flex items-center gap-1.5"),
37
+ children: [
38
+ /* @__PURE__ */ n(C, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
39
+ " Open full record"
40
+ ]
41
+ }
42
+ ),
43
+ children: [
44
+ i.isLoading && /* @__PURE__ */ n(M, {}),
45
+ o && /* @__PURE__ */ n("p", { className: `text-[12px] ${u}`, children: "This record is not there any more, or you do not have access to it." }),
46
+ i.isError && !o && /* @__PURE__ */ n("p", { className: "text-[12px] text-[var(--cc-bad-text)]", children: "Could not load this record." }),
47
+ a && /* @__PURE__ */ n(q, { rec: a, canAct: !e.kiosk })
48
+ ]
49
+ }
50
+ );
51
+ }
52
+ function M() {
53
+ return /* @__PURE__ */ n("div", { className: "space-y-2", "aria-hidden": "true", children: [70, 45, 90, 60].map((e) => /* @__PURE__ */ n(
54
+ "div",
55
+ {
56
+ className: "h-3 animate-pulse rounded bg-[var(--cc-chip-hover)]",
57
+ style: { width: `${e}%` }
58
+ },
59
+ e
60
+ )) });
61
+ }
62
+ function q({ rec: e, canAct: s }) {
63
+ const m = P(), i = y(), [a, o] = w(null);
64
+ $(() => {
65
+ if (!a) return;
66
+ const t = setTimeout(() => o(null), 6e3);
67
+ return () => clearTimeout(t);
68
+ }, [a]);
69
+ const r = k({
70
+ mutationFn: (t) => m.request(
71
+ T(
72
+ `/pipelines/instance/${encodeURIComponent(e.collection)}/${encodeURIComponent(e.id)}/transition`,
73
+ { transition_id: t }
74
+ )
75
+ ),
76
+ onSuccess: (t, c) => {
77
+ var f;
78
+ const g = ((f = e.transitions.find((N) => N.key === c)) == null ? void 0 : f.label) ?? "Moved";
79
+ b.success(`${g} — done`), o(null), i.invalidateQueries({ queryKey: ["command-center"] });
80
+ },
81
+ onError: (t) => {
82
+ o(null), b.error(t.message || "That move did not go through");
83
+ }
84
+ }), h = U(e.sla);
85
+ return /* @__PURE__ */ l("div", { className: "space-y-4 text-[12px]", children: [
86
+ /* @__PURE__ */ l("div", { className: "flex flex-wrap items-center gap-1.5", children: [
87
+ e.state && /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-[var(--cc-chip)] px-2 py-0.5", children: [
88
+ /* @__PURE__ */ n(
89
+ "span",
90
+ {
91
+ className: "h-2 w-2 rounded-full",
92
+ style: { background: e.state.color ?? "#00a5cc" },
93
+ "aria-hidden": "true"
94
+ }
95
+ ),
96
+ e.state.label
97
+ ] }),
98
+ h && /* @__PURE__ */ n(
99
+ "span",
100
+ {
101
+ className: p(
102
+ "rounded-full px-2 py-0.5 font-medium",
103
+ e.sla === "breached" ? "bg-red-500/15 text-[var(--cc-bad-text)]" : "bg-amber-500/15 text-[var(--cc-warn-text)]"
104
+ ),
105
+ children: h
106
+ }
107
+ ),
108
+ e.sla === "ok" && /* @__PURE__ */ n("span", { className: `rounded-full bg-[var(--cc-chip)] px-2 py-0.5 ${u}`, children: "SLA on time" }),
109
+ !e.state && /* @__PURE__ */ n("span", { className: d, children: "Not in a pipeline" })
110
+ ] }),
111
+ /* @__PURE__ */ l("div", { children: [
112
+ /* @__PURE__ */ n("p", { className: `mb-1 ${d}`, children: "Owners" }),
113
+ e.owners.length > 0 ? /* @__PURE__ */ n("p", { className: "text-[var(--cc-text)]", children: e.owners.map((t) => t.name).join(", ") }) : /* @__PURE__ */ n("p", { className: u, children: "Nobody owns this step" })
114
+ ] }),
115
+ e.facts.length > 0 && /* @__PURE__ */ n("dl", { className: "grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5", children: e.facts.map((t) => /* @__PURE__ */ l("div", { className: "contents", children: [
116
+ /* @__PURE__ */ n("dt", { className: d, children: t.label }),
117
+ /* @__PURE__ */ n("dd", { className: "min-w-0 break-words text-[var(--cc-text)]", children: t.value })
118
+ ] }, t.label)) }),
119
+ s && e.transitions.length > 0 && /* @__PURE__ */ l("div", { children: [
120
+ /* @__PURE__ */ n("p", { className: `mb-1.5 ${d}`, children: "Move it" }),
121
+ /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-1.5", children: e.transitions.map((t) => {
122
+ const c = a === t.key;
123
+ return /* @__PURE__ */ n(
124
+ "button",
125
+ {
126
+ type: "button",
127
+ disabled: r.isPending,
128
+ onClick: () => c ? r.mutate(t.key) : o(t.key),
129
+ "aria-label": c ? `Confirm: ${t.label}` : t.label,
130
+ className: p(
131
+ x,
132
+ v,
133
+ c && "border-nvr-cyan bg-nvr-cyan text-white hover:bg-nvr-cyan"
134
+ ),
135
+ children: r.isPending && c ? "Moving…" : c ? `Confirm ${t.label}` : t.label
136
+ },
137
+ t.key
138
+ );
139
+ }) }),
140
+ a && !r.isPending && /* @__PURE__ */ n("p", { className: `mt-1.5 ${d}`, role: "status", children: "Click again to confirm. Some moves ask for more on the full record." })
141
+ ] })
142
+ ] });
3
143
  }
4
144
  export {
5
- e as PeekPanel
145
+ z as PeekPanel
6
146
  };
@@ -0,0 +1,13 @@
1
+ function i(n) {
2
+ return Array.isArray(n) ? n.length : n && typeof n == "object" && Array.isArray(n.items) ? n.items.length : null;
3
+ }
4
+ function r(n, t) {
5
+ if (n === null || t === null || n === t) return "";
6
+ if (t === 0) return "Nothing needs attention now.";
7
+ const e = t === 1 ? "1 item needs attention" : `${t} items need attention`;
8
+ return t > n ? `${e} — ${t - n} new.` : `${e}.`;
9
+ }
10
+ export {
11
+ r as attentionAnnouncement,
12
+ i as attentionCount
13
+ };
@@ -0,0 +1,99 @@
1
+ import { useQuery as c, useQueryClient as a, useMutation as i } from "@tanstack/react-query";
2
+ import { useNivaroClient as o } from "../../context.js";
3
+ import { get as l, put as d, post as f, del as q } from "../../lib/commands.js";
4
+ const s = ["command-center", "prefs"], y = ["command-center", "role-defaults"], m = ["command-center", "kiosk-links"], k = {
5
+ layout: null,
6
+ theme: "app",
7
+ saved_views: [],
8
+ role_default: null,
9
+ tv_cycle_seconds: 30
10
+ };
11
+ function _(t) {
12
+ const n = o();
13
+ return c({
14
+ queryKey: s,
15
+ queryFn: () => n.request(l("/command-center/prefs")).then((e) => e.data),
16
+ enabled: t,
17
+ staleTime: 5 * 6e4,
18
+ retry: !1
19
+ });
20
+ }
21
+ function p() {
22
+ const t = o(), n = a();
23
+ return i({
24
+ mutationFn: (e) => t.request(d("/command-center/prefs", e)).then((r) => r.data),
25
+ onMutate: async (e) => {
26
+ await n.cancelQueries({ queryKey: s });
27
+ const r = n.getQueryData(s);
28
+ return n.setQueryData(s, { ...k, ...r ?? {}, ...e }), { before: r };
29
+ },
30
+ onError: (e, r, u) => {
31
+ u != null && u.before && n.setQueryData(s, u.before);
32
+ },
33
+ onSuccess: (e) => n.setQueryData(s, e)
34
+ });
35
+ }
36
+ function Q(t) {
37
+ const n = o();
38
+ return c({
39
+ queryKey: y,
40
+ queryFn: () => n.request(l("/command-center/role-defaults")).then((e) => e.data),
41
+ enabled: t
42
+ });
43
+ }
44
+ function S() {
45
+ const t = o(), n = a();
46
+ return i({
47
+ mutationFn: (e) => t.request(d("/command-center/role-defaults", e)).then((r) => r.data),
48
+ onSuccess: (e) => {
49
+ n.setQueryData(y, e), n.invalidateQueries({ queryKey: s });
50
+ }
51
+ });
52
+ }
53
+ function h(t) {
54
+ const n = o();
55
+ return c({
56
+ queryKey: m,
57
+ queryFn: () => n.request(l("/command-center/kiosk-links")).then((e) => e.data),
58
+ enabled: t
59
+ });
60
+ }
61
+ function D() {
62
+ const t = o(), n = a();
63
+ return i({
64
+ mutationFn: (e) => t.request(f("/command-center/kiosk-links", e)).then((r) => r.data),
65
+ onSuccess: () => void n.invalidateQueries({ queryKey: m })
66
+ });
67
+ }
68
+ function E() {
69
+ const t = o(), n = a();
70
+ return i({
71
+ mutationFn: (e) => t.request(q(`/command-center/kiosk-links/${e}`)),
72
+ onSuccess: () => void n.invalidateQueries({ queryKey: m })
73
+ });
74
+ }
75
+ function L(t) {
76
+ const n = o();
77
+ return c({
78
+ queryKey: ["command-center", "kiosk-info", t],
79
+ queryFn: () => n.request(l("/command-center/kiosk", { kiosk: t })).then((e) => e.data),
80
+ enabled: !!t,
81
+ // Re-checked every few minutes, so a revoked or expired link leaves the wall promptly.
82
+ refetchInterval: 5 * 6e4,
83
+ retry: 1
84
+ });
85
+ }
86
+ export {
87
+ k as DEFAULT_PREFS,
88
+ m as KIOSK_LINKS_KEY,
89
+ s as PREFS_KEY,
90
+ y as ROLE_DEFAULTS_KEY,
91
+ _ as useCcPrefs,
92
+ Q as useCcRoleDefaults,
93
+ D as useCreateKioskLink,
94
+ L as useKioskInfo,
95
+ h as useKioskLinks,
96
+ E as useRevokeKioskLink,
97
+ p as useSaveCcPrefs,
98
+ S as useSaveRoleDefault
99
+ };
@@ -0,0 +1,29 @@
1
+ const u = 2;
2
+ function i(n) {
3
+ const t = Math.max(0, Math.floor(n / 1e3));
4
+ if (t < 2) return "just now";
5
+ if (t < 60) return `${t}s ago`;
6
+ const r = Math.floor(t / 60);
7
+ if (r < 60) return `${r}m ago`;
8
+ const o = Math.floor(r / 60);
9
+ return o < 24 ? `${o}h ago` : `${Math.floor(o / 24)}d ago`;
10
+ }
11
+ function a(n) {
12
+ return new Date(n).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
13
+ }
14
+ function f(n) {
15
+ const { updatedAt: t, failures: r, now: o } = n;
16
+ if (!t) return r >= 2 ? { kind: "failed" } : { kind: "loading" };
17
+ const e = `Updated ${i(o - t)}`;
18
+ return r >= 2 ? { kind: "stale", since: a(t), label: e } : { kind: "fresh", label: e };
19
+ }
20
+ function s(n, t) {
21
+ return Math.max(0, n - t);
22
+ }
23
+ export {
24
+ u as STALE_AFTER_FAILURES,
25
+ a as clockTime,
26
+ s as countFailures,
27
+ i as formatAge,
28
+ f as freshness
29
+ };
@@ -0,0 +1,56 @@
1
+ function s(n, r) {
2
+ return n ?? r ?? null;
3
+ }
4
+ function u(n, r) {
5
+ const o = new Set(n), i = new Set((r == null ? void 0 : r.hidden) ?? []), c = /* @__PURE__ */ new Set(), a = [];
6
+ for (const e of (r == null ? void 0 : r.order) ?? [])
7
+ o.has(e) && !c.has(e) && (c.add(e), a.push(e));
8
+ return n.forEach((e, t) => {
9
+ if (c.has(e)) return;
10
+ c.add(e);
11
+ const f = n.slice(0, t).reverse().find((l) => a.includes(l));
12
+ a.splice(f ? a.indexOf(f) + 1 : 0, 0, e);
13
+ }), a.map((e) => ({ key: e, visible: !i.has(e) }));
14
+ }
15
+ function d(n, r, o) {
16
+ const i = new Set(o), c = ((r == null ? void 0 : r.order) ?? []).filter((e) => !i.has(e)), a = ((r == null ? void 0 : r.hidden) ?? []).filter((e) => !i.has(e));
17
+ return {
18
+ order: [
19
+ ...n.map((e) => e.key),
20
+ ...c.filter((e) => !n.some((t) => t.key === e))
21
+ ],
22
+ hidden: [...n.filter((e) => !e.visible).map((e) => e.key), ...a]
23
+ };
24
+ }
25
+ function m(n, r, o) {
26
+ const i = n.findIndex((t) => t.key === r), c = i + o;
27
+ if (i < 0 || c < 0 || c >= n.length) return n;
28
+ const a = [...n], [e] = a.splice(i, 1);
29
+ return a.splice(c, 0, e), a;
30
+ }
31
+ function h(n, r, o) {
32
+ const i = n.findIndex((t) => t.key === r), c = n.findIndex((t) => t.key === o);
33
+ if (i < 0 || c < 0 || i === c) return n;
34
+ const a = [...n], [e] = a.splice(i, 1);
35
+ return a.splice(c, 0, e), a;
36
+ }
37
+ function p(n, r, o) {
38
+ return n.map((i) => i.key === r ? { ...i, visible: o } : i);
39
+ }
40
+ function w(n) {
41
+ return n < 768 ? "phone" : n < 1280 ? "medium" : n < 1800 ? "wide" : "xwide";
42
+ }
43
+ function x(n, r) {
44
+ const o = n.filter((t) => t.area === "main"), i = n.filter((t) => t.area === "bottom"), c = n.filter((t) => t.area === "lead"), a = n.filter((t) => t.area === "rail"), e = n.filter((t) => t.area === "lead" || t.area === "rail");
45
+ return r === "xwide" ? { columns: "three", lead: c, main: o, under: i, rail: a } : r === "wide" ? { columns: "two", lead: [], main: o, under: i, rail: e } : { columns: "one", lead: c, main: o, under: i, rail: a };
46
+ }
47
+ export {
48
+ x as arrangeBoard,
49
+ w as boardSizeFor,
50
+ s as effectiveLayout,
51
+ d as layoutToSave,
52
+ m as movePanel,
53
+ h as movePanelTo,
54
+ u as resolvePanels,
55
+ p as setPanelVisible
56
+ };
@@ -1,6 +1,135 @@
1
- function n() {
2
- return null;
1
+ import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
+ import { AlertOctagon as N, AlertTriangle as b, Info as I } from "lucide-react";
3
+ import { useState as w } from "react";
4
+ import { useCcQuery as $ } from "../api.js";
5
+ import { useCc as g } from "../state.js";
6
+ import { PANEL as _, PANEL_HEAD as A, TITLE as T, FAINT as u, FOCUS as h, MUTED as p, BUTTON as E } from "../theme.js";
7
+ import { sinceShort as C, stateListUrl as F } from "../work-links.js";
8
+ import { NudgeForm as L, TransitionForm as D, ApproveForm as S, ReassignForm as P } from "./attention-actions.js";
9
+ const O = {
10
+ critical: { Icon: N, word: "Critical", tone: "text-[var(--cc-bad-text)]" },
11
+ warning: { Icon: b, word: "Warning", tone: "text-[var(--cc-warn-text)]" },
12
+ info: { Icon: I, word: "Info", tone: "text-[var(--cc-muted)]" }
13
+ }, k = 8;
14
+ function Y() {
15
+ const r = g(), e = $("/attention", void 0, { refetchInterval: 6e4 }), n = e.data ?? [], [s, i] = w(!1), c = s ? n : n.slice(0, k), d = n.length - c.length;
16
+ return /* @__PURE__ */ o("section", { className: _, "data-cc-panel": "attention", "aria-busy": e.isLoading, children: [
17
+ /* @__PURE__ */ o("div", { className: A, children: [
18
+ /* @__PURE__ */ a("h2", { className: T, children: "Needs attention" }),
19
+ /* @__PURE__ */ a("span", { className: `text-[11px] tabular-nums ${u}`, children: r.at ? "Live — not rewound" : n.length > 0 ? n.length : "" })
20
+ ] }),
21
+ /* @__PURE__ */ a(R, {}),
22
+ /* @__PURE__ */ a("ul", { className: "divide-y divide-[var(--cc-border)]", children: c.map((l) => /* @__PURE__ */ a(H, { item: l }, l.id)) }),
23
+ (d > 0 || s) && n.length > k && /* @__PURE__ */ a("div", { className: "border-t border-[var(--cc-border)] px-3 py-2", children: r.kiosk || r.tv ? /* @__PURE__ */ o("span", { className: `text-[11.5px] ${u}`, children: [
24
+ "+",
25
+ d,
26
+ " more"
27
+ ] }) : /* @__PURE__ */ a(
28
+ "button",
29
+ {
30
+ type: "button",
31
+ onClick: () => i((l) => !l),
32
+ "aria-expanded": s,
33
+ className: `text-[11.5px] font-medium text-[var(--cc-text)] underline-offset-2 hover:underline ${h}`,
34
+ children: s ? "Show fewer" : `Show all ${n.length}`
35
+ }
36
+ ) }),
37
+ !e.isLoading && n.length === 0 && /* @__PURE__ */ a("p", { className: `px-3 py-3 text-[12px] ${u}`, children: e.isError ? "Could not load this list." : "Nothing needs attention right now." })
38
+ ] });
39
+ }
40
+ function R() {
41
+ var s;
42
+ const e = (s = g().snapshot) == null ? void 0 : s.risk;
43
+ if (!e) return null;
44
+ const n = [];
45
+ return e.sla_breached != null && n.push({
46
+ key: "b",
47
+ text: `${e.sla_breached} past deadline`,
48
+ tone: e.sla_breached > 0 ? "text-[var(--cc-bad-text)]" : p,
49
+ Icon: e.sla_breached > 0 ? N : void 0
50
+ }), e.sla_warning != null && n.push({
51
+ key: "w",
52
+ text: `${e.sla_warning} near deadline`,
53
+ tone: e.sla_warning > 0 ? "text-[var(--cc-warn-text)]" : p,
54
+ Icon: e.sla_warning > 0 ? b : void 0
55
+ }), e.tracked > 0 && n.push({ key: "r", text: `${e.at_risk} at risk of ${e.tracked} tracked`, tone: p }), (e.open_issues ?? 0) > 0 && n.push({ key: "i", text: `${e.open_issues} open issues`, tone: p }), n.length === 0 ? null : /* @__PURE__ */ o("p", { className: "flex flex-wrap gap-x-3 gap-y-1 border-b border-[var(--cc-border)] px-3 py-2 text-[11.5px]", children: [
56
+ /* @__PURE__ */ a("span", { className: "sr-only", children: "Risk summary:" }),
57
+ n.map((i) => /* @__PURE__ */ o("span", { className: `flex items-center gap-1 tabular-nums ${i.tone}`, children: [
58
+ i.Icon && /* @__PURE__ */ a(i.Icon, { className: "h-3 w-3", "aria-hidden": !0 }),
59
+ i.text
60
+ ] }, i.key))
61
+ ] });
62
+ }
63
+ function H({ item: r }) {
64
+ const e = g(), [n, s] = w(null), i = O[r.severity], c = C(r.since), d = r.list ? F(r.list.collection, {
65
+ state: r.list.state,
66
+ minAgeHours: r.list.min_age_hours
67
+ }) : null, l = () => {
68
+ r.record && !r.list ? e.setPeek(r.record) : d ? e.navigate(d) : r.href ? e.navigate(r.href) : r.record && e.setPeek(r.record);
69
+ }, m = !e.kiosk, y = (t) => {
70
+ var f, v;
71
+ if (t.kind === "open") {
72
+ t.href ? e.navigate(t.href) : t.target ? e.setPeek({ collection: t.target.collection, id: t.target.id }) : l();
73
+ return;
74
+ }
75
+ if (t.kind === "alert" && t.href) return e.navigate(t.href);
76
+ if (t.kind === "nudge" && t.target) return s({ kind: "nudge", target: t.target });
77
+ if (t.kind === "transition" && t.target)
78
+ return s({ kind: "transition", target: t.target });
79
+ if (t.kind === "approve" && ((f = t.target) == null ? void 0 : f.approval_id) != null)
80
+ return s({ kind: "approve", approvalId: t.target.approval_id });
81
+ if (t.kind === "reassign" && ((v = t.targets) != null && v.length))
82
+ return s({ kind: "reassign", targets: t.targets });
83
+ }, x = r.actions.filter(
84
+ (t) => t.kind === "open" || m && (t.kind !== "alert" || e.isAdmin)
85
+ );
86
+ return /* @__PURE__ */ o("li", { className: "px-3 py-2", children: [
87
+ /* @__PURE__ */ o("div", { className: "flex items-start gap-2", children: [
88
+ /* @__PURE__ */ o(
89
+ "span",
90
+ {
91
+ className: `mt-0.5 flex shrink-0 items-center gap-1 text-[10.5px] font-semibold ${i.tone}`,
92
+ children: [
93
+ /* @__PURE__ */ a(i.Icon, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
94
+ /* @__PURE__ */ a("span", { className: "w-[50px]", children: i.word })
95
+ ]
96
+ }
97
+ ),
98
+ /* @__PURE__ */ o("div", { className: "min-w-0 flex-1", children: [
99
+ /* @__PURE__ */ a(
100
+ "button",
101
+ {
102
+ type: "button",
103
+ onClick: l,
104
+ className: `block max-w-full truncate rounded text-left text-[12.5px] font-medium text-[var(--cc-strong)] hover:underline ${h}`,
105
+ children: r.title
106
+ }
107
+ ),
108
+ r.detail && /* @__PURE__ */ a("p", { className: `truncate text-[11.5px] ${p}`, children: r.detail })
109
+ ] }),
110
+ /* @__PURE__ */ o("div", { className: "shrink-0 text-right text-[11px] tabular-nums", children: [
111
+ r.count != null && r.count > 1 && /* @__PURE__ */ a("div", { className: "font-semibold text-[var(--cc-text)]", children: r.count }),
112
+ c && /* @__PURE__ */ a("div", { className: u, "data-tip": "How long it has been like this", children: c })
113
+ ] })
114
+ ] }),
115
+ x.length > 0 && !n && /* @__PURE__ */ a("div", { className: "mt-1.5 flex flex-wrap gap-1.5 pl-[70px]", children: x.map((t) => /* @__PURE__ */ a(
116
+ "button",
117
+ {
118
+ type: "button",
119
+ onClick: () => y(t),
120
+ className: `${E} py-0.5 ${h}`,
121
+ children: t.label
122
+ },
123
+ `${t.kind}:${t.label}`
124
+ )) }),
125
+ n && m && /* @__PURE__ */ o("div", { className: "mt-2 ml-[70px] rounded-md bg-[var(--cc-raised)] p-2", children: [
126
+ n.kind === "nudge" && /* @__PURE__ */ a(L, { target: n.target, onDone: () => s(null) }),
127
+ n.kind === "transition" && /* @__PURE__ */ a(D, { target: n.target, onDone: () => s(null) }),
128
+ n.kind === "approve" && /* @__PURE__ */ a(S, { approvalId: n.approvalId, onDone: () => s(null) }),
129
+ n.kind === "reassign" && /* @__PURE__ */ a(P, { targets: n.targets, onDone: () => s(null) })
130
+ ] })
131
+ ] });
3
132
  }
4
133
  export {
5
- n as AttentionPanel
134
+ Y as AttentionPanel
6
135
  };
@@ -0,0 +1,75 @@
1
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
2
+ import { useArmedFaults as s } from "../../chaos/DrillBanner.js";
3
+ import { useCcQuery as d } from "../api.js";
4
+ import { useCc as m } from "../state.js";
5
+ import { FOCUS as u } from "../theme.js";
6
+ import { whenLabel as l, clockLabel as f } from "../time.js";
7
+ function p(e, t) {
8
+ const i = [];
9
+ if (e != null && e.incident && i.push({
10
+ key: "incident",
11
+ tone: "critical",
12
+ text: `Incident open since ${l(new Date(e.incident.started_at).getTime())}: ${e.incident.title}`,
13
+ href: e.incident.href,
14
+ action: "Open the incident"
15
+ }), e != null && e.maintenance && i.push({
16
+ key: "maintenance",
17
+ tone: "warning",
18
+ text: `Maintenance in progress${e.maintenance.until ? ` until ${l(new Date(e.maintenance.until).getTime())}` : ""} — saving changes is paused.${e.maintenance.message ? ` ${e.maintenance.message}` : ""}`,
19
+ href: null,
20
+ action: null
21
+ }), t.length > 0) {
22
+ const r = t[0];
23
+ i.push({
24
+ key: "drill",
25
+ tone: "info",
26
+ text: `Practice drill running: ${r.label} on ${r.target}${t.length > 1 ? ` (+${t.length - 1} more)` : ""}, until ${f(r.ends_at)}. Some failures on this board are deliberate.`,
27
+ href: null,
28
+ action: null
29
+ });
30
+ }
31
+ return i;
32
+ }
33
+ const h = {
34
+ critical: { box: "bg-red-500/15 text-[var(--cc-bad-text)]", glyph: "■", word: "Incident" },
35
+ warning: { box: "bg-amber-500/15 text-[var(--cc-warn-text)]", glyph: "▲", word: "Maintenance" },
36
+ info: { box: "bg-nvr-cyan/10 text-[var(--cc-text)]", glyph: "◆", word: "Drill" }
37
+ };
38
+ function w() {
39
+ const e = m(), { data: t } = d("/banner", void 0, {
40
+ lenses: !1,
41
+ refetchInterval: 3e4,
42
+ staleTime: 15e3
43
+ }), { armed: i } = s(), r = p(t, i);
44
+ return r.length === 0 ? null : /* @__PURE__ */ a("div", { className: "flex shrink-0 flex-col gap-1.5", role: "status", "data-cc-banner": "", children: r.map((n) => {
45
+ const c = h[n.tone];
46
+ return /* @__PURE__ */ o(
47
+ "div",
48
+ {
49
+ className: `relative flex flex-wrap items-center gap-2 rounded-lg px-3 py-2 text-[12.5px] ${c.box}`,
50
+ children: [
51
+ /* @__PURE__ */ a("span", { "aria-hidden": !0, className: "text-[10px]", children: c.glyph }),
52
+ /* @__PURE__ */ o("span", { className: "sr-only", children: [
53
+ c.word,
54
+ ": "
55
+ ] }),
56
+ /* @__PURE__ */ a("span", { className: "min-w-0 flex-1 font-medium", children: n.text }),
57
+ n.href && n.action && /* @__PURE__ */ a(
58
+ "button",
59
+ {
60
+ type: "button",
61
+ className: `rounded px-1.5 text-[12px] font-semibold underline-offset-2 hover:underline ${u}`,
62
+ onClick: () => e.navigate(n.href),
63
+ children: n.action
64
+ }
65
+ )
66
+ ]
67
+ },
68
+ n.key
69
+ );
70
+ }) });
71
+ }
72
+ export {
73
+ w as BoardBanner,
74
+ p as bannerLines
75
+ };