@nivaro/react 0.3.44 → 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 (51) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +75 -7
  4. package/dist/shared/components/BaseMap.js +149 -103
  5. package/dist/shared/components/CollectionBrowserView.js +1390 -1358
  6. package/dist/shared/components/DataTable.js +356 -334
  7. package/dist/shared/components/ProfileView.js +16 -21
  8. package/dist/shared/components/command-center/CommandCenterView.js +331 -352
  9. package/dist/shared/components/command-center/Customize.js +353 -0
  10. package/dist/shared/components/command-center/Header.js +296 -0
  11. package/dist/shared/components/command-center/KioskLinks.js +198 -0
  12. package/dist/shared/components/command-center/PeekPanel.js +146 -0
  13. package/dist/shared/components/command-center/announce.js +13 -0
  14. package/dist/shared/components/command-center/api.js +26 -0
  15. package/dist/shared/components/command-center/board-prefs.js +99 -0
  16. package/dist/shared/components/command-center/freshness.js +29 -0
  17. package/dist/shared/components/command-center/layout.js +56 -0
  18. package/dist/shared/components/command-center/panels/AttentionPanel.js +135 -0
  19. package/dist/shared/components/command-center/panels/Banner.js +75 -0
  20. package/dist/shared/components/command-center/panels/BoardSettings.js +223 -0
  21. package/dist/shared/components/command-center/panels/FeedPanel.js +149 -0
  22. package/dist/shared/components/command-center/panels/FlowPanel.js +159 -0
  23. package/dist/shared/components/command-center/panels/ForecastPanel.js +247 -0
  24. package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
  25. package/dist/shared/components/command-center/panels/MapPanel.js +224 -0
  26. package/dist/shared/components/command-center/panels/PartnersPanel.js +52 -0
  27. package/dist/shared/components/command-center/panels/PeoplePanel.js +264 -0
  28. package/dist/shared/components/command-center/panels/RegionPicker.js +91 -0
  29. package/dist/shared/components/command-center/panels/SystemPanel.js +173 -0
  30. package/dist/shared/components/command-center/panels/ThroughputPanel.js +310 -0
  31. package/dist/shared/components/command-center/panels/TimeBar.js +231 -0
  32. package/dist/shared/components/command-center/panels/TrafficPanel.js +15 -0
  33. package/dist/shared/components/command-center/panels/WorkloadPanel.js +85 -0
  34. package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
  35. package/dist/shared/components/command-center/panels/map-shared.js +95 -0
  36. package/dist/shared/components/command-center/panels/registry.js +96 -0
  37. package/dist/shared/components/command-center/shell-hooks.js +118 -0
  38. package/dist/shared/components/command-center/shortcuts.js +37 -0
  39. package/dist/shared/components/command-center/state.js +12 -0
  40. package/dist/shared/components/command-center/theme.js +84 -0
  41. package/dist/shared/components/command-center/time.js +52 -0
  42. package/dist/shared/components/command-center/url-state.js +54 -0
  43. package/dist/shared/components/command-center/work-links.js +32 -0
  44. package/dist/shared/components/imports/ImportConsole.js +48 -47
  45. package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
  46. package/dist/shared/components/notifications/TestMyRules.js +39 -38
  47. package/dist/shared/components/profile/TeamsConnect.js +2 -2
  48. package/dist/shared/components/queue/QueueQuickFilters.js +81 -63
  49. package/dist/shared/components/queue/QueueWorklist.js +598 -586
  50. package/dist/shared/lib/quick-filter-cascade.js +29 -0
  51. package/package.json +1 -1
@@ -0,0 +1,159 @@
1
+ import { jsxs as o, jsx as n, Fragment as w } from "react/jsx-runtime";
2
+ import { Bell as y, ArrowRight as $, ArrowUpRight as k, ArrowDownRight as N } from "lucide-react";
3
+ import { useState as f } from "react";
4
+ import { useCcQuery as A } from "../api.js";
5
+ import { useCc as b } from "../state.js";
6
+ import { PANEL as C, PANEL_HEAD as L, TITLE as O, FAINT as u, FOCUS as d, MUTED as v } from "../theme.js";
7
+ import { ageShort as g, ageWords as x, stateListUrl as M } from "../work-links.js";
8
+ const _ = "#00a5cc";
9
+ function j() {
10
+ var i;
11
+ const t = b(), a = A("/flow", void 0, { refetchInterval: 6e4 }), c = a.data ?? (((i = t.snapshot) == null ? void 0 : i.flow) ?? []).map((l) => ({
12
+ collection: l.collection,
13
+ collection_label: l.collection,
14
+ template_name: l.template_name,
15
+ states: l.states.map((r) => ({ ...r, oldest_age_s: null, median_age_s: null, stuck: 0 })),
16
+ open: l.states.reduce((r, m) => r + m.count, 0),
17
+ wip_7d_delta: null,
18
+ completed_7d: 0,
19
+ clears_in_days: null
20
+ })), s = c.some((l) => l.live_only), p = !!t.region && c.length > 0 && c.every((l) => l.region_applies === !1);
21
+ return /* @__PURE__ */ o("section", { className: C, "data-cc-panel": "flow", "aria-busy": a.isLoading, children: [
22
+ /* @__PURE__ */ o("div", { className: L, children: [
23
+ /* @__PURE__ */ n("h2", { className: O, children: "Pipeline flow" }),
24
+ s && /* @__PURE__ */ n("span", { className: `text-[11px] ${u}`, children: "Live — can't rewind this" }),
25
+ !s && p && /* @__PURE__ */ n("span", { className: `text-[11px] ${u}`, children: "Not placed in regions — showing everywhere" })
26
+ ] }),
27
+ /* @__PURE__ */ o("div", { className: "space-y-4 p-3", children: [
28
+ c.map((l) => /* @__PURE__ */ n(F, { f: l }, `${l.collection}:${l.template_name}`)),
29
+ c.length === 0 && !a.isLoading && /* @__PURE__ */ n("p", { className: `text-[12px] ${u}`, children: "No workflow-bound collections visible to you." })
30
+ ] })
31
+ ] });
32
+ }
33
+ function F({ f: t }) {
34
+ var m;
35
+ const a = b(), [c, s] = f(!1), p = Math.max(
36
+ 1,
37
+ t.states.reduce((e, h) => e + h.count, 0)
38
+ ), i = (e, h) => a.navigate(M(t.collection, { state: e, minAgeHours: h })), l = t.states.filter((e) => e.count > 0), r = ((m = a.config) == null ? void 0 : m.stuck_days) ?? 7;
39
+ return /* @__PURE__ */ o("div", { children: [
40
+ /* @__PURE__ */ o("div", { className: "mb-1 flex items-baseline justify-between gap-2", children: [
41
+ /* @__PURE__ */ n(
42
+ "button",
43
+ {
44
+ type: "button",
45
+ onClick: () => i(null),
46
+ className: `truncate rounded text-left text-[12px] font-medium text-[var(--cc-text)] hover:underline ${d}`,
47
+ "data-tip": `Open ${t.collection_label}`,
48
+ children: t.template_name
49
+ }
50
+ ),
51
+ /* @__PURE__ */ o("span", { className: `shrink-0 text-[11px] tabular-nums ${u}`, children: [
52
+ t.open,
53
+ " open"
54
+ ] })
55
+ ] }),
56
+ /* @__PURE__ */ n("div", { className: "flex h-2.5 gap-[2px] overflow-hidden rounded-full bg-[var(--cc-chip)]", children: l.map((e) => /* @__PURE__ */ n(
57
+ "button",
58
+ {
59
+ type: "button",
60
+ onClick: () => i(e.key),
61
+ className: `h-full transition-opacity hover:opacity-75 ${d}`,
62
+ style: {
63
+ width: `${Math.max(2, e.count / p * 100)}%`,
64
+ background: e.color ?? _
65
+ },
66
+ "aria-label": `${e.label}: ${e.count} open. Open the list filtered to ${e.label}`,
67
+ "data-tip": `${e.label}: ${e.count} — open the list`
68
+ },
69
+ e.key
70
+ )) }),
71
+ /* @__PURE__ */ n("ul", { className: "mt-1.5 space-y-0.5", children: (c ? t.states : l).map((e) => /* @__PURE__ */ o("li", { className: "group flex items-center gap-1.5 text-[11.5px]", children: [
72
+ /* @__PURE__ */ o(
73
+ "button",
74
+ {
75
+ type: "button",
76
+ onClick: () => i(e.key),
77
+ className: `flex min-w-0 flex-1 items-center gap-1.5 rounded px-0.5 text-left hover:bg-[var(--cc-chip)] ${d}`,
78
+ "aria-label": `${e.label}: ${e.count} open, oldest ${x(e.oldest_age_s)}, ${e.stuck} stuck. Open the list`,
79
+ children: [
80
+ /* @__PURE__ */ n(
81
+ "span",
82
+ {
83
+ className: "h-1.5 w-1.5 shrink-0 rounded-full",
84
+ style: { background: e.color ?? _ },
85
+ "aria-hidden": !0
86
+ }
87
+ ),
88
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-[var(--cc-muted)]", children: e.label }),
89
+ /* @__PURE__ */ n("b", { className: "tabular-nums text-[var(--cc-text)]", children: e.count }),
90
+ /* @__PURE__ */ n(
91
+ "span",
92
+ {
93
+ className: `w-[64px] shrink-0 text-right tabular-nums ${u}`,
94
+ "data-tip": e.count ? `Oldest ${x(e.oldest_age_s)} · median ${x(e.median_age_s)}` : void 0,
95
+ children: e.count ? `${g(e.oldest_age_s)} / ${g(e.median_age_s)}` : ""
96
+ }
97
+ )
98
+ ]
99
+ }
100
+ ),
101
+ e.stuck > 0 ? /* @__PURE__ */ o(
102
+ "button",
103
+ {
104
+ type: "button",
105
+ onClick: () => i(e.key, r * 24),
106
+ className: `shrink-0 rounded px-1 text-[11px] font-medium text-[var(--cc-warn-text)] hover:underline ${d}`,
107
+ "data-tip": `In ${e.label} longer than ${r} days — open them`,
108
+ children: [
109
+ e.stuck,
110
+ " stuck"
111
+ ]
112
+ }
113
+ ) : null,
114
+ a.isAdmin && !a.kiosk && e.alert_href ? /* @__PURE__ */ n(
115
+ "button",
116
+ {
117
+ type: "button",
118
+ onClick: () => a.navigate(e.alert_href),
119
+ className: `invisible shrink-0 rounded p-0.5 text-[var(--cc-faint)] hover:text-[var(--cc-text)] group-focus-within:visible group-hover:visible ${d}`,
120
+ "aria-label": `Alert me about ${e.label}`,
121
+ "data-tip": "Alert me",
122
+ children: /* @__PURE__ */ n(y, { className: "h-3 w-3", "aria-hidden": !0 })
123
+ }
124
+ ) : null
125
+ ] }, e.key)) }),
126
+ /* @__PURE__ */ o("div", { className: "mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px]", children: [
127
+ /* @__PURE__ */ n(R, { f: t }),
128
+ t.states.length > l.length && /* @__PURE__ */ n(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ onClick: () => s((e) => !e),
133
+ className: `ml-auto rounded ${v} hover:underline ${d}`,
134
+ "aria-expanded": c,
135
+ children: c ? "Hide empty states" : `Show all ${t.states.length} states`
136
+ }
137
+ )
138
+ ] })
139
+ ] });
140
+ }
141
+ function R({ f: t }) {
142
+ const a = t.wip_7d_delta;
143
+ if (a == null && t.completed_7d === 0) return null;
144
+ const c = a != null && a > 0, s = a == null || a === 0 ? $ : c ? k : N, p = c ? "text-[var(--cc-warn-text)]" : "text-[var(--cc-muted)]";
145
+ return /* @__PURE__ */ o(w, { children: [
146
+ a != null && /* @__PURE__ */ o("span", { className: `flex items-center gap-0.5 ${p}`, children: [
147
+ /* @__PURE__ */ n(s, { className: "h-3 w-3", "aria-hidden": !0 }),
148
+ a === 0 ? "steady this week" : `${a > 0 ? "+" : "−"}${Math.abs(a)} open this week`
149
+ ] }),
150
+ /* @__PURE__ */ o("span", { className: u, children: [
151
+ t.completed_7d,
152
+ " done in 7 days"
153
+ ] }),
154
+ /* @__PURE__ */ n("span", { className: c ? "font-medium text-[var(--cc-warn-text)]" : v, children: c ? "growing" : t.clears_in_days == null ? "not clearing" : t.clears_in_days === 0 ? "clear" : `clears in ~${Math.max(1, Math.round(t.clears_in_days))} day${Math.round(t.clears_in_days) === 1 ? "" : "s"}` })
155
+ ] });
156
+ }
157
+ export {
158
+ j as FlowPanel
159
+ };
@@ -0,0 +1,247 @@
1
+ import { jsxs as t, jsx as e, Fragment as L } from "react/jsx-runtime";
2
+ import { AlertTriangle as T } from "lucide-react";
3
+ import { useMemo as H, useState as C } from "react";
4
+ import { useCcQuery as E } from "../api.js";
5
+ import { useCc as F } from "../state.js";
6
+ import { PANEL as U, PANEL_HEAD as W, TITLE as j, MUTED as _, FAINT as y } from "../theme.js";
7
+ const u = 320, g = 120, o = { l: 26, r: 6, t: 8, b: 18 }, b = (r) => r === 0 ? "12a" : r < 12 ? `${r}a` : r === 12 ? "12p" : `${r - 12}p`, z = () => {
8
+ try {
9
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
10
+ } catch {
11
+ return "UTC";
12
+ }
13
+ };
14
+ function q() {
15
+ const r = F(), i = H(z, []), m = E("/forecast", { tz: i }, { refetchInterval: 12e4 }), n = m.data, [N, k] = C(null);
16
+ if (m.isError) return null;
17
+ const d = r.at ? new Date(r.at).getHours() : (/* @__PURE__ */ new Date()).getHours(), p = (n == null ? void 0 : n.by_hour) ?? [], x = Math.max(
18
+ 1,
19
+ ...p.flatMap((a) => [a.arrivals, a.completions, a.expected_arrivals, a.expected_completions])
20
+ ), h = (a) => o.l + a / 23 * (u - o.l - o.r), l = (a) => o.t + (1 - a / x) * (g - o.t - o.b), v = (a) => a.map((c, f) => c == null ? null : `${h(f).toFixed(1)},${l(c).toFixed(1)}`).filter(Boolean).map((c, f) => `${f ? "L" : "M"}${c}`).join(" "), w = (a) => p.map((c) => c.hour <= d ? c[a] : null), A = n != null && (n.history_days ?? 0) === 0, s = N != null ? p[N] : null;
21
+ return /* @__PURE__ */ t("section", { className: U, "data-cc-panel": "forecast", "data-cc-forecast": !0, "aria-busy": m.isLoading, children: [
22
+ /* @__PURE__ */ e("style", { children: `
23
+ [data-cc-mode='light'] [data-cc-forecast] { --fc-a: #2a78d6; --fc-c: #eb6834; }
24
+ [data-cc-mode='dark'] [data-cc-forecast] { --fc-a: #3987e5; --fc-c: #d95926; }
25
+ ` }),
26
+ /* @__PURE__ */ t("div", { className: W, children: [
27
+ /* @__PURE__ */ e("h2", { className: j, children: "Today’s forecast" }),
28
+ /* @__PURE__ */ t("span", { className: `flex items-center gap-2 text-[10.5px] ${_}`, children: [
29
+ /* @__PURE__ */ e($, { color: "var(--fc-a)", label: "Arrivals" }),
30
+ /* @__PURE__ */ e($, { color: "var(--fc-c)", label: "Completions" }),
31
+ /* @__PURE__ */ t("span", { className: "flex items-center gap-1", children: [
32
+ /* @__PURE__ */ e("span", { className: "w-3.5 border-t-2 border-dashed border-[var(--cc-muted)]", "aria-hidden": !0 }),
33
+ "usual"
34
+ ] })
35
+ ] })
36
+ ] }),
37
+ /* @__PURE__ */ t("div", { className: "p-3", children: [
38
+ n && /* @__PURE__ */ t("div", { className: "relative", children: [
39
+ /* @__PURE__ */ t(
40
+ "svg",
41
+ {
42
+ viewBox: `0 0 ${u} ${g}`,
43
+ className: "block h-auto w-full",
44
+ role: "img",
45
+ "aria-label": M(n),
46
+ onMouseLeave: () => k(null),
47
+ onMouseMove: (a) => {
48
+ const c = a.currentTarget.getBoundingClientRect(), f = (a.clientX - c.left) / Math.max(1, c.width) * u, D = Math.round((f - o.l) / (u - o.l - o.r) * 23);
49
+ k(Math.min(23, Math.max(0, D)));
50
+ },
51
+ children: [
52
+ /* @__PURE__ */ e("line", { x1: o.l, x2: u - o.r, y1: l(0), y2: l(0), stroke: "var(--cc-border)" }),
53
+ /* @__PURE__ */ e(
54
+ "line",
55
+ {
56
+ x1: o.l,
57
+ x2: u - o.r,
58
+ y1: l(x),
59
+ y2: l(x),
60
+ stroke: "var(--cc-border)",
61
+ strokeDasharray: "2 3"
62
+ }
63
+ ),
64
+ /* @__PURE__ */ e(
65
+ "text",
66
+ {
67
+ x: o.l - 4,
68
+ y: l(x) + 3,
69
+ textAnchor: "end",
70
+ fontSize: "8",
71
+ fill: "var(--cc-faint)",
72
+ children: Math.round(x)
73
+ }
74
+ ),
75
+ /* @__PURE__ */ e("text", { x: o.l - 4, y: l(0) + 3, textAnchor: "end", fontSize: "8", fill: "var(--cc-faint)", children: "0" }),
76
+ [0, 6, 12, 18, 23].map((a) => /* @__PURE__ */ e(
77
+ "text",
78
+ {
79
+ x: h(a),
80
+ y: g - 4,
81
+ textAnchor: "middle",
82
+ fontSize: "8",
83
+ fill: "var(--cc-faint)",
84
+ children: b(a)
85
+ },
86
+ a
87
+ )),
88
+ /* @__PURE__ */ e(
89
+ "line",
90
+ {
91
+ x1: h(d),
92
+ x2: h(d),
93
+ y1: o.t,
94
+ y2: l(0),
95
+ stroke: "var(--cc-faint)",
96
+ strokeDasharray: "1 2"
97
+ }
98
+ ),
99
+ !A && /* @__PURE__ */ t(L, { children: [
100
+ /* @__PURE__ */ e(
101
+ "path",
102
+ {
103
+ d: v(p.map((a) => a.expected_arrivals)),
104
+ fill: "none",
105
+ stroke: "var(--fc-a)",
106
+ strokeWidth: "1.5",
107
+ strokeDasharray: "4 3",
108
+ opacity: "0.8"
109
+ }
110
+ ),
111
+ /* @__PURE__ */ e(
112
+ "path",
113
+ {
114
+ d: v(p.map((a) => a.expected_completions)),
115
+ fill: "none",
116
+ stroke: "var(--fc-c)",
117
+ strokeWidth: "1.5",
118
+ strokeDasharray: "4 3",
119
+ opacity: "0.8"
120
+ }
121
+ )
122
+ ] }),
123
+ /* @__PURE__ */ e(
124
+ "path",
125
+ {
126
+ d: v(w("arrivals")),
127
+ fill: "none",
128
+ stroke: "var(--fc-a)",
129
+ strokeWidth: "2",
130
+ strokeLinejoin: "round"
131
+ }
132
+ ),
133
+ /* @__PURE__ */ e(
134
+ "path",
135
+ {
136
+ d: v(w("completions")),
137
+ fill: "none",
138
+ stroke: "var(--fc-c)",
139
+ strokeWidth: "2",
140
+ strokeLinejoin: "round"
141
+ }
142
+ ),
143
+ s && /* @__PURE__ */ e(
144
+ "line",
145
+ {
146
+ x1: h(s.hour),
147
+ x2: h(s.hour),
148
+ y1: o.t,
149
+ y2: l(0),
150
+ stroke: "var(--cc-muted)"
151
+ }
152
+ )
153
+ ]
154
+ }
155
+ ),
156
+ s && /* @__PURE__ */ t(
157
+ "div",
158
+ {
159
+ className: "pointer-events-none absolute top-0 rounded-md border border-[var(--cc-border)] bg-[var(--cc-panel)] px-2 py-1 text-[11px] text-[var(--cc-text)] shadow-sm",
160
+ style: {
161
+ left: `${h(s.hour) / u * 100}%`,
162
+ transform: s.hour > 14 ? "translateX(calc(-100% - 6px))" : "translateX(6px)"
163
+ },
164
+ children: [
165
+ /* @__PURE__ */ t("div", { className: "font-medium", children: [
166
+ b(s.hour),
167
+ "–",
168
+ b((s.hour + 1) % 24)
169
+ ] }),
170
+ /* @__PURE__ */ t("div", { className: "tabular-nums", children: [
171
+ "Arrivals ",
172
+ s.hour <= d ? s.arrivals : "–",
173
+ " ",
174
+ /* @__PURE__ */ t("span", { className: y, children: [
175
+ "(usual ",
176
+ s.expected_arrivals,
177
+ ")"
178
+ ] })
179
+ ] }),
180
+ /* @__PURE__ */ t("div", { className: "tabular-nums", children: [
181
+ "Completions ",
182
+ s.hour <= d ? s.completions : "–",
183
+ " ",
184
+ /* @__PURE__ */ t("span", { className: y, children: [
185
+ "(usual ",
186
+ s.expected_completions,
187
+ ")"
188
+ ] })
189
+ ] })
190
+ ]
191
+ }
192
+ )
193
+ ] }),
194
+ n && /* @__PURE__ */ t("div", { className: "mt-2 space-y-1 text-[11.5px]", children: [
195
+ n.behind && /* @__PURE__ */ t(
196
+ "p",
197
+ {
198
+ className: "flex items-center gap-1 font-medium text-[var(--cc-warn-text)]",
199
+ role: "status",
200
+ children: [
201
+ /* @__PURE__ */ e(T, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
202
+ "Falling behind: work is arriving faster than it is being finished, compared with a usual ",
203
+ S(r.at),
204
+ "."
205
+ ]
206
+ }
207
+ ),
208
+ /* @__PURE__ */ e("p", { className: _, children: M(n) }),
209
+ n.region_applies === !1 && /* @__PURE__ */ e("p", { className: y, children: "These records are not placed in regions — showing everywhere." })
210
+ ] }),
211
+ n && /* @__PURE__ */ t("table", { className: "sr-only", children: [
212
+ /* @__PURE__ */ e("caption", { children: "Arrivals and completions by hour today, with the usual" }),
213
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ t("tr", { children: [
214
+ /* @__PURE__ */ e("th", { children: "Hour" }),
215
+ /* @__PURE__ */ e("th", { children: "Arrivals" }),
216
+ /* @__PURE__ */ e("th", { children: "Usual arrivals" }),
217
+ /* @__PURE__ */ e("th", { children: "Completions" }),
218
+ /* @__PURE__ */ e("th", { children: "Usual completions" })
219
+ ] }) }),
220
+ /* @__PURE__ */ e("tbody", { children: p.map((a) => /* @__PURE__ */ t("tr", { children: [
221
+ /* @__PURE__ */ e("td", { children: b(a.hour) }),
222
+ /* @__PURE__ */ e("td", { children: a.hour <= d ? a.arrivals : "" }),
223
+ /* @__PURE__ */ e("td", { children: a.expected_arrivals }),
224
+ /* @__PURE__ */ e("td", { children: a.hour <= d ? a.completions : "" }),
225
+ /* @__PURE__ */ e("td", { children: a.expected_completions })
226
+ ] }, a.hour)) })
227
+ ] }),
228
+ !n && m.isLoading && /* @__PURE__ */ e("p", { className: `text-[12px] ${y}`, children: "Working out today…" })
229
+ ] })
230
+ ] });
231
+ }
232
+ function $({ color: r, label: i }) {
233
+ return /* @__PURE__ */ t("span", { className: "flex items-center gap-1", children: [
234
+ /* @__PURE__ */ e("span", { className: "h-[2px] w-3 rounded", style: { background: r }, "aria-hidden": !0 }),
235
+ i
236
+ ] });
237
+ }
238
+ function S(r) {
239
+ return new Date(r ?? Date.now()).toLocaleDateString(void 0, { weekday: "long" });
240
+ }
241
+ function M(r) {
242
+ const i = (r.history_days ?? 0) > 0, m = `${r.arrivals_so_far} arrived so far${i ? ` (usually ${Math.round(r.arrivals_expected)} by now)` : ""}`, n = `${r.completions_so_far} completed${i ? ` (usually ${Math.round(r.completions_expected)})` : ""}`;
243
+ return `${m}; ${n}.${i ? "" : " Not enough history yet for a usual day."}`;
244
+ }
245
+ export {
246
+ q as ForecastPanel
247
+ };
@@ -0,0 +1,266 @@
1
+ import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
+ import { X as S, ChevronsUpDown as M, Check as $ } from "lucide-react";
3
+ import { useMemo as C, useState as w } from "react";
4
+ import { cn as y } from "../../../lib/utils.js";
5
+ import { Command as A, CommandInput as L, CommandList as O, CommandEmpty as P, CommandItem as F } from "../../ui/command.js";
6
+ import { Popover as E, PopoverTrigger as _, PopoverContent as I } from "../../ui/popover.js";
7
+ import { useCc as T, EMPTY_FILTERS as j } from "../state.js";
8
+ import { FAINT as N, FOCUS as v, MUTED as R } from "../theme.js";
9
+ import { MAP_COLORS as s } from "./map-shared.js";
10
+ function x({ color: c, pulse: l }) {
11
+ return /* @__PURE__ */ o(
12
+ "span",
13
+ {
14
+ className: "relative inline-flex h-3.5 w-3 shrink-0 items-center justify-center",
15
+ "aria-hidden": "true",
16
+ children: [
17
+ l && /* @__PURE__ */ r(
18
+ "span",
19
+ {
20
+ className: "absolute inset-0 rounded-full motion-safe:animate-ping",
21
+ style: { background: `${c}55` }
22
+ }
23
+ ),
24
+ /* @__PURE__ */ r("svg", { width: "12", height: "15", viewBox: "0 0 24 30", className: "relative", "aria-hidden": "true", children: /* @__PURE__ */ r(
25
+ "path",
26
+ {
27
+ d: "M12 0C5.4 0 0 5.4 0 12c0 8.4 12 18 12 18s12-9.6 12-18C24 5.4 18.6 0 12 0z",
28
+ fill: c,
29
+ stroke: "#fff",
30
+ strokeWidth: "2"
31
+ }
32
+ ) })
33
+ ]
34
+ }
35
+ );
36
+ }
37
+ const b = {
38
+ sla_heat: { color: s.breached, text: "SLA heat — larger, stronger dots are breached" },
39
+ activity: { color: s.activity, text: "Changed in the last 15 minutes" },
40
+ out_today: { color: s.out, text: "Out of office today" }
41
+ };
42
+ function J({
43
+ states: c,
44
+ layers: l,
45
+ showPeople: i
46
+ }) {
47
+ return /* @__PURE__ */ o(
48
+ "section",
49
+ {
50
+ className: "w-[240px] space-y-1.5 rounded-lg border border-[var(--cc-border)] bg-[var(--cc-panel)] p-2.5 text-[11.5px] text-[var(--cc-text)] shadow-lg",
51
+ "aria-label": "Map key",
52
+ children: [
53
+ /* @__PURE__ */ r("p", { className: "font-semibold text-[var(--cc-strong)]", children: "Map key" }),
54
+ c.slice(0, 6).map((t) => /* @__PURE__ */ o("p", { className: "flex items-center gap-2", children: [
55
+ /* @__PURE__ */ r(x, { color: t.color ?? s.ok }),
56
+ " ",
57
+ t.label
58
+ ] }, t.key)),
59
+ c.length === 0 && /* @__PURE__ */ o("p", { className: "flex items-center gap-2", children: [
60
+ /* @__PURE__ */ r(x, { color: s.ok }),
61
+ " A record (no pipeline step)"
62
+ ] }),
63
+ /* @__PURE__ */ o("p", { className: "flex items-center gap-2", children: [
64
+ /* @__PURE__ */ r(x, { color: s.warning }),
65
+ " SLA warning — due soon"
66
+ ] }),
67
+ /* @__PURE__ */ o("p", { className: "flex items-center gap-2", children: [
68
+ /* @__PURE__ */ r(x, { color: s.breached, pulse: !0 }),
69
+ " SLA breached — overdue (pulses)"
70
+ ] }),
71
+ /* @__PURE__ */ o("p", { className: "flex items-center gap-2", children: [
72
+ /* @__PURE__ */ r(
73
+ "span",
74
+ {
75
+ className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full border-2 border-white text-[8px] font-bold text-white",
76
+ style: { background: s.breached },
77
+ "aria-hidden": "true",
78
+ children: "3"
79
+ }
80
+ ),
81
+ "Group of records — takes the colour of the worst one"
82
+ ] }),
83
+ i && /* @__PURE__ */ o("p", { className: "flex items-center gap-2", children: [
84
+ /* @__PURE__ */ r(
85
+ "span",
86
+ {
87
+ className: "h-4 w-4 shrink-0 rounded-full",
88
+ style: {
89
+ background: `${s.people}45`,
90
+ border: `2px dashed ${s.people}`
91
+ },
92
+ "aria-hidden": "true"
93
+ }
94
+ ),
95
+ "People online at an office or in a region"
96
+ ] }),
97
+ l.map((t) => /* @__PURE__ */ o("p", { className: "flex items-center gap-2", children: [
98
+ /* @__PURE__ */ r(
99
+ "span",
100
+ {
101
+ className: "h-3 w-3 shrink-0 rounded-full",
102
+ style: {
103
+ background: `${b[t].color}88`,
104
+ border: `1.5px solid ${b[t].color}`
105
+ },
106
+ "aria-hidden": "true"
107
+ }
108
+ ),
109
+ b[t].text
110
+ ] }, t))
111
+ ]
112
+ }
113
+ );
114
+ }
115
+ const g = (c) => y(
116
+ "inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]",
117
+ v,
118
+ c ? "border-nvr-cyan bg-nvr-cyan/15 font-medium text-[var(--cc-strong)]" : "border-[var(--cc-border)] text-[var(--cc-muted)] hover:bg-[var(--cc-chip)]"
119
+ ), U = [
120
+ { key: "breached", label: "Breached", color: s.breached },
121
+ { key: "warning", label: "Warning", color: s.warning },
122
+ { key: "ok", label: "On time", color: s.people }
123
+ ];
124
+ function Q({
125
+ states: c,
126
+ pins: l
127
+ }) {
128
+ const i = T(), t = i.filters, p = (e) => i.setFilters({ ...t, ...e }), u = (e, n) => e.includes(n) ? e.filter((a) => a !== n) : [...e, n], f = t.states.length > 0 || t.sla.length > 0 || !!t.owner, d = C(() => {
129
+ const e = new Map(c.map((n) => [n.key, n]));
130
+ for (const n of t.states) e.has(n) || e.set(n, { key: n, label: n, color: null });
131
+ return [...e.values()];
132
+ }, [c, t.states]);
133
+ return d.length === 0 && l.length === 0 && !f ? null : /* @__PURE__ */ o("fieldset", { className: "relative m-0 flex min-w-0 flex-wrap items-center gap-1.5 border-0 border-b border-[var(--cc-border)] px-3 py-1.5", children: [
134
+ /* @__PURE__ */ r("legend", { className: "sr-only", children: "Map filters" }),
135
+ d.length > 0 && /* @__PURE__ */ r("span", { className: `text-[11px] ${N}`, children: "Step" }),
136
+ d.map((e) => {
137
+ const n = t.states.includes(e.key);
138
+ return /* @__PURE__ */ o(
139
+ "button",
140
+ {
141
+ type: "button",
142
+ "aria-pressed": n,
143
+ onClick: () => p({ states: u(t.states, e.key) }),
144
+ className: g(n),
145
+ children: [
146
+ /* @__PURE__ */ r(
147
+ "span",
148
+ {
149
+ className: "h-2 w-2 rounded-full",
150
+ style: { background: e.color ?? s.ok },
151
+ "aria-hidden": "true"
152
+ }
153
+ ),
154
+ e.label
155
+ ]
156
+ },
157
+ e.key
158
+ );
159
+ }),
160
+ /* @__PURE__ */ r("span", { className: `ml-1 text-[11px] ${N}`, children: "SLA" }),
161
+ U.map((e) => {
162
+ const n = t.sla.includes(e.key);
163
+ return /* @__PURE__ */ o(
164
+ "button",
165
+ {
166
+ type: "button",
167
+ "aria-pressed": n,
168
+ onClick: () => p({ sla: u(t.sla, e.key) }),
169
+ className: g(n),
170
+ children: [
171
+ /* @__PURE__ */ r(
172
+ "span",
173
+ {
174
+ className: "h-2 w-2 rounded-full",
175
+ style: { background: e.color },
176
+ "aria-hidden": "true"
177
+ }
178
+ ),
179
+ e.label
180
+ ]
181
+ },
182
+ e.key
183
+ );
184
+ }),
185
+ /* @__PURE__ */ r(Y, { pins: l, value: t.owner, onChange: (e) => p({ owner: e }) }),
186
+ f && /* @__PURE__ */ r(
187
+ "button",
188
+ {
189
+ type: "button",
190
+ onClick: () => i.setFilters(j),
191
+ className: y("ml-auto text-[11px] underline-offset-2 hover:underline", R, v),
192
+ children: "Clear filters"
193
+ }
194
+ )
195
+ ] });
196
+ }
197
+ function Y({
198
+ pins: c,
199
+ value: l,
200
+ onChange: i
201
+ }) {
202
+ var n;
203
+ const [t, p] = w(!1), [u, f] = w({}), d = C(() => {
204
+ const a = /* @__PURE__ */ new Map();
205
+ for (const m of c)
206
+ for (const h of m.owners ?? []) {
207
+ const k = a.get(h.id) ?? { ...h, n: 0 };
208
+ k.n++, a.set(h.id, k);
209
+ }
210
+ return [...a.values()].sort((m, h) => h.n - m.n || m.name.localeCompare(h.name));
211
+ }, [c]), e = l ? ((n = d.find((a) => a.id === l)) == null ? void 0 : n.name) ?? u[l] ?? "Chosen person" : null;
212
+ return d.length === 0 && !l ? null : /* @__PURE__ */ o(E, { open: t, onOpenChange: p, children: [
213
+ /* @__PURE__ */ r(_, { asChild: !0, children: /* @__PURE__ */ o(
214
+ "button",
215
+ {
216
+ type: "button",
217
+ className: g(!!l),
218
+ "aria-label": e ? `Owner: ${e}` : "Filter by owner",
219
+ children: [
220
+ e ? `Owner: ${e}` : "Any owner",
221
+ l ? /* @__PURE__ */ r(
222
+ S,
223
+ {
224
+ className: "h-3 w-3",
225
+ "aria-hidden": "true",
226
+ onClick: (a) => {
227
+ a.stopPropagation(), i(null);
228
+ }
229
+ }
230
+ ) : /* @__PURE__ */ r(M, { className: "h-3 w-3", "aria-hidden": "true" })
231
+ ]
232
+ }
233
+ ) }),
234
+ /* @__PURE__ */ r(I, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ o(A, { children: [
235
+ /* @__PURE__ */ r(L, { placeholder: "Find an owner…", className: "h-8 text-[12px]" }),
236
+ /* @__PURE__ */ o(O, { children: [
237
+ /* @__PURE__ */ r(P, { className: "py-3 text-center text-[12px] text-muted-foreground", children: "Nobody matches" }),
238
+ d.map((a) => /* @__PURE__ */ o(
239
+ F,
240
+ {
241
+ value: `${a.name} ${a.id}`,
242
+ onSelect: () => {
243
+ f((m) => ({ ...m, [a.id]: a.name })), i(l === a.id ? null : a.id), p(!1);
244
+ },
245
+ className: "text-[12px]",
246
+ children: [
247
+ /* @__PURE__ */ r(
248
+ $,
249
+ {
250
+ className: y("mr-2 h-3 w-3", l === a.id ? "opacity-100" : "opacity-0")
251
+ }
252
+ ),
253
+ /* @__PURE__ */ r("span", { className: "flex-1 truncate", children: a.name }),
254
+ /* @__PURE__ */ r("span", { className: "text-[11px] tabular-nums text-muted-foreground", children: a.n })
255
+ ]
256
+ },
257
+ a.id
258
+ ))
259
+ ] })
260
+ ] }) })
261
+ ] });
262
+ }
263
+ export {
264
+ Q as MapFilters,
265
+ J as MapLegend
266
+ };