@crewlethq/ui 0.122.0 → 0.123.0

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 (47) hide show
  1. package/README.md +45 -2
  2. package/dist/AvatarPicker/index.js +2 -2
  3. package/dist/Charts/StackedRing.d.ts +40 -0
  4. package/dist/Charts/TimeSeries.d.ts +8 -1
  5. package/dist/Charts/index.d.ts +2 -0
  6. package/dist/Charts/index.js +1 -1
  7. package/dist/{Charts-UJKADWXE.css → Charts-4VQ7T3GB.css} +85 -0
  8. package/dist/DataGrid/DataGrid.d.ts +11 -1
  9. package/dist/DataGrid/index.d.ts +1 -1
  10. package/dist/DataGrid/index.js +1 -1
  11. package/dist/{DataGrid-7KUUYSHA.css → DataGrid-KAFVH4B3.css} +3 -1
  12. package/dist/DeepWorkCard/index.js +2 -2
  13. package/dist/Fullscreen/FullscreenToggle.d.ts +21 -0
  14. package/dist/Fullscreen/index.d.ts +2 -0
  15. package/dist/Fullscreen/index.js +11 -1
  16. package/dist/GraphCanvas/GraphCanvas.d.ts +97 -16
  17. package/dist/GraphCanvas/index.d.ts +4 -4
  18. package/dist/GraphCanvas/index.js +3 -3
  19. package/dist/GraphCanvas/layout.d.ts +31 -1
  20. package/dist/GraphCanvas/walk.d.ts +5 -4
  21. package/dist/GraphCanvas-UZPZRP6S.css +793 -0
  22. package/dist/IconTile/IconTile.d.ts +26 -18
  23. package/dist/IconTile/index.d.ts +1 -1
  24. package/dist/IconTile/index.js +1 -1
  25. package/dist/IconTile-6OSCIHYU.css +112 -0
  26. package/dist/OpenInAppCard/index.js +2 -2
  27. package/dist/OrgTable/index.js +3 -3
  28. package/dist/ReviewList/index.js +2 -2
  29. package/dist/TreeGrid/index.js +2 -2
  30. package/dist/{chunk-W5XCNEZC.js → chunk-3JLG6KRU.js} +23 -2
  31. package/dist/{chunk-AGVGX52B.js → chunk-7XYU5PSQ.js} +1 -1
  32. package/dist/{chunk-6KPHU4EB.js → chunk-DSBKVP73.js} +490 -122
  33. package/dist/{chunk-MDD6K5M4.js → chunk-EWJOBD25.js} +1 -1
  34. package/dist/{chunk-X5YI6QLW.js → chunk-NOKZULW3.js} +1 -1
  35. package/dist/{chunk-ZOMTCEHR.js → chunk-OFNJE4BN.js} +6 -1
  36. package/dist/{chunk-75O3HCCD.js → chunk-T4TKY4VZ.js} +1 -1
  37. package/dist/chunk-VRVNLJUA.js +46 -0
  38. package/dist/{chunk-MNTN5ESE.js → chunk-ZY5322MJ.js} +77 -3
  39. package/dist/generated/index.js +46 -46
  40. package/dist/index.js +46 -46
  41. package/dist/styles.css +701 -130
  42. package/package.json +3 -3
  43. package/dist/GraphCanvas-RSBMO2AF.css +0 -388
  44. package/dist/IconTile-G52XZVR4.css +0 -33
  45. package/dist/chunk-3LI4TRUR.js +0 -22
  46. package/dist/{chunk-4Z3AGYOB.js → chunk-P42LNYRX.js} +1 -1
  47. package/dist/{chunk-JWUIGUIS.js → chunk-YCT7LRYR.js} +1 -1
@@ -1,13 +1,14 @@
1
1
  import { useMeasuredSizes, isTypeAheadKey, typeAheadBuffer } from './chunk-MY374UUD.js';
2
- import { IconTile } from './chunk-3LI4TRUR.js';
2
+ import { FilterChip } from './chunk-L6HUVA33.js';
3
+ import { FullscreenToggle } from './chunk-3JLG6KRU.js';
3
4
  import { fitView, CANVAS_FIT_PADDING, Canvas } from './chunk-GKHZSNIV.js';
4
5
  import { Text } from './chunk-XLMURU75.js';
5
- import { StatusDot } from './chunk-QRE6JCHS.js';
6
+ import { LayerHost } from './chunk-FIX72ZEC.js';
6
7
  import { VisuallyHidden } from './chunk-RRRK2KB6.js';
7
8
  import { cx } from './chunk-ODEQTPFM.js';
8
- import './GraphCanvas-RSBMO2AF.css';
9
- import { memo, useMemo, useId, useCallback, useState, useRef, useLayoutEffect, useImperativeHandle } from 'react';
10
- import { ChevronDownGlyph, ChevronRightGlyph } from '@crewlethq/icons/glyphs';
9
+ import './GraphCanvas-UZPZRP6S.css';
10
+ import { memo, useMemo, useId, useState, useCallback, useRef, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
11
+ import { ChevronDownGlyph, ChevronRightGlyph, TriangleAlertGlyph, CircleAlertGlyph, InfoGlyph } from '@crewlethq/icons/glyphs';
11
12
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
12
13
 
13
14
  // src/GraphCanvas/layout.ts
@@ -88,13 +89,15 @@ function layoutGraph(input, metrics) {
88
89
  }
89
90
  }
90
91
  const adjacent = itemLane.map(() => []);
91
- for (const edge of input.edges) {
92
+ for (const edge of input.ordering ?? input.edges) {
92
93
  const a = itemIndex.get(keyOfNode.get(edge.from) ?? "");
93
94
  const b = itemIndex.get(keyOfNode.get(edge.to) ?? "");
94
95
  if (a === void 0 || b === void 0 || a === b || itemLane[a] === itemLane[b]) continue;
95
96
  adjacent[a].push(b);
96
97
  adjacent[b].push(a);
97
98
  }
99
+ const columnOf = /* @__PURE__ */ new Map();
100
+ for (const node of nodes) if (node.column !== void 0 && node.group === void 0) columnOf.set(node.id, node.column);
98
101
  const pitch = metrics.cardHeight + metrics.rowGap;
99
102
  const emptyRowsOf = (lane) => {
100
103
  const height = input.emptyHeights?.get(lane);
@@ -109,6 +112,33 @@ function layoutGraph(input, metrics) {
109
112
  cells.push({ key: graphItemKey("empty", lane), kind: "empty", id: lane, col: 0, row: 0, cols: span, rows });
110
113
  return { cells, rows };
111
114
  }
115
+ if (span > 1 && blocks.every((block) => block.kind === "loose") && blocks.some((block) => columnOf.has(block.id))) {
116
+ const stacks = Array.from({ length: span }, () => []);
117
+ for (const block of blocks) {
118
+ const named = columnOf.get(block.id);
119
+ let at = 0;
120
+ if (named === void 0) {
121
+ for (let c = 1; c < span; c++) if (stacks[c].length < stacks[at].length) at = c;
122
+ } else at = Math.min(span - 1, Math.max(0, Math.trunc(named)));
123
+ stacks[at].push(block);
124
+ }
125
+ const rows = Math.max(...stacks.map((stack) => stack.length));
126
+ stacks.forEach((stack, c) => {
127
+ const first = Math.floor((rows - stack.length) / 2);
128
+ stack.forEach(
129
+ (block, i) => cells.push({
130
+ key: graphItemKey("node", block.id),
131
+ kind: "node",
132
+ id: block.id,
133
+ col: c,
134
+ row: first + i,
135
+ cols: 1,
136
+ rows: 1
137
+ })
138
+ );
139
+ });
140
+ return { cells, rows };
141
+ }
112
142
  let row = 0;
113
143
  let col = 0;
114
144
  const cell = (key, kind, id) => {
@@ -147,16 +177,18 @@ function layoutGraph(input, metrics) {
147
177
  if (col > 0) row += 1;
148
178
  return { cells, rows: row };
149
179
  };
150
- const columns = Math.max(1, ...bands.map((band) => band.lanes.length));
180
+ const asked = (lane) => Math.max(1, Math.trunc(input.laneColumns?.get(lane) ?? 1));
181
+ const widthOf = (band) => band.lanes.reduce((sum, lane) => sum + asked(lane), 0);
182
+ const columns = Math.max(1, ...bands.map(widthOf));
151
183
  const laneCols = /* @__PURE__ */ new Map();
152
184
  for (const band of bands) {
153
- const base = Math.floor(columns / Math.max(1, band.lanes.length));
154
- const spans = band.lanes.map(() => base);
185
+ const even = Math.floor((columns - widthOf(band)) / Math.max(1, band.lanes.length));
186
+ const spans = band.lanes.map((lane) => asked(lane) + even);
155
187
  const rowsAt = (i, span) => {
156
188
  const lane = band.lanes[i];
157
189
  return blocksOf.get(lane).length === 0 ? 1 : placeLane(lane, span).rows;
158
190
  };
159
- for (let spare = columns - base * band.lanes.length; spare > 0; spare--) {
191
+ for (let spare = columns - spans.reduce((sum, span) => sum + span, 0); spare > 0; spare--) {
160
192
  let pick = 0;
161
193
  let best = [-1, -1, -Infinity];
162
194
  spans.forEach((span, i) => {
@@ -535,6 +567,49 @@ function routeAll(layout, edges) {
535
567
  });
536
568
  return { routes, routeOfEdge };
537
569
  }
570
+ var TRUNK_INSET = 48;
571
+ function graphTrunks(layout, edges, laneOf) {
572
+ const pairs = /* @__PURE__ */ new Map();
573
+ for (const edge of edges) {
574
+ const a = layout.laneById.get(laneOf(edge.from) ?? "");
575
+ const b = layout.laneById.get(laneOf(edge.to) ?? "");
576
+ if (!a || !b || Math.abs(a.band - b.band) !== 1) continue;
577
+ const [upper, lower] = a.band < b.band ? [a, b] : [b, a];
578
+ const key = `${upper.id}>${lower.id}`;
579
+ const pair = pairs.get(key);
580
+ if (pair) pair.count += 1;
581
+ else pairs.set(key, { upper, lower, count: 1 });
582
+ }
583
+ return [...pairs].map(([key, { upper, lower, count }]) => {
584
+ const from = upper.panel;
585
+ const to = lower.panel;
586
+ const inset = Math.min(TRUNK_INSET, from.width / 4, to.width / 4);
587
+ const lo = Math.max(from.x, to.x) + inset;
588
+ const hi = Math.min(from.x + from.width, to.x + to.width) - inset;
589
+ const mid = from.x + from.width / 2;
590
+ const left = to.x + to.width / 2 < mid;
591
+ const x1 = lo <= hi ? Math.min(hi, Math.max(lo, mid)) : left ? from.x + inset : from.x + from.width - inset;
592
+ const x2 = lo <= hi ? x1 : left ? to.x + to.width - inset : to.x + inset;
593
+ const y1 = from.y + from.height;
594
+ const y2 = to.y;
595
+ const turn = (y1 + y2) / 2;
596
+ const points = simplify([
597
+ { x: x1, y: y1 },
598
+ { x: x1, y: turn },
599
+ { x: x2, y: turn },
600
+ { x: x2, y: y2 }
601
+ ]);
602
+ return {
603
+ key,
604
+ from: upper.id,
605
+ to: lower.id,
606
+ count,
607
+ d: pathOf(points),
608
+ label: { x: (x1 + x2) / 2, y: turn },
609
+ box: boxOf(points)
610
+ };
611
+ });
612
+ }
538
613
  function plan(key, from, to, edge, grid, columns, metrics) {
539
614
  const forward = to.col > from.col;
540
615
  const back = to.col < from.col;
@@ -804,17 +879,16 @@ function graphStep(layout, from, event) {
804
879
  const item = layout.itemByKey.get(from);
805
880
  if (!item) return void 0;
806
881
  const lane = layout.laneById.get(item.lane);
807
- const at = lane.items.indexOf(from);
808
882
  const mod = event.ctrlKey === true || event.metaKey === true;
809
883
  switch (event.key) {
810
884
  case "ArrowDown":
811
- return at < lane.items.length - 1 ? lane.items[at + 1] : acrossBands(layout, item, 1);
885
+ return alongColumn(layout, item, lane, 1) ?? acrossBands(layout, item, 1);
812
886
  case "ArrowUp":
813
- return at > 0 ? lane.items[at - 1] : acrossBands(layout, item, -1);
887
+ return alongColumn(layout, item, lane, -1) ?? acrossBands(layout, item, -1);
814
888
  case "ArrowRight":
815
- return besideLane(layout, item, lane, 1);
889
+ return besideColumn(layout, item, lane, 1) ?? besideLane(layout, item, lane, 1);
816
890
  case "ArrowLeft":
817
- return besideLane(layout, item, lane, -1);
891
+ return besideColumn(layout, item, lane, -1) ?? besideLane(layout, item, lane, -1);
818
892
  case "Home":
819
893
  return mod ? layout.lanes[0]?.items[0] ?? null : lane.items[0];
820
894
  case "End": {
@@ -828,6 +902,38 @@ function graphStep(layout, from, event) {
828
902
  }
829
903
  var middle = (item) => item.y + item.height / 2;
830
904
  var centre = (item) => item.x + item.width / 2;
905
+ var covers = (item, col) => col >= item.col && col < item.col + item.cols;
906
+ function alongColumn(layout, item, lane, step) {
907
+ let best = null;
908
+ let bestRow = Infinity;
909
+ for (const key of lane.items) {
910
+ const other = layout.itemByKey.get(key);
911
+ const away = (other.row - item.row) * step;
912
+ if (other === item || away <= 0 || away >= bestRow) continue;
913
+ let shares = false;
914
+ for (let col = item.col; col < item.col + item.cols && !shares; col++) shares = covers(other, col);
915
+ if (!shares) continue;
916
+ best = key;
917
+ bestRow = away;
918
+ }
919
+ return best;
920
+ }
921
+ function besideColumn(layout, item, lane, step) {
922
+ const edge = step === 1 ? item.col + item.cols - 1 : item.col;
923
+ let best = null;
924
+ let bestCost = Infinity;
925
+ for (const key of lane.items) {
926
+ const other = layout.itemByKey.get(key);
927
+ const away = step === 1 ? other.col - edge : edge - (other.col + other.cols - 1);
928
+ if (other === item || away <= 0) continue;
929
+ const cost = away * 1e6 + Math.abs(middle(other) - middle(item));
930
+ if (cost < bestCost) {
931
+ bestCost = cost;
932
+ best = key;
933
+ }
934
+ }
935
+ return best;
936
+ }
831
937
  function besideLane(layout, item, lane, step) {
832
938
  const inBand = layout.lanes.filter((one) => one.band === lane.band);
833
939
  const next = inBand[inBand.indexOf(lane) + step];
@@ -851,7 +957,7 @@ function acrossBands(layout, item, step) {
851
957
  }
852
958
  }
853
959
  if (!best) return null;
854
- return step === 1 ? best.items[0] : best.items[best.items.length - 1];
960
+ return nearest(layout, best.items, (other) => other.row * step * 1e6 + Math.abs(centre(other) - x));
855
961
  }
856
962
  function nearest(layout, keys, cost) {
857
963
  let best = null;
@@ -865,6 +971,7 @@ function nearest(layout, keys, cost) {
865
971
  }
866
972
  return best;
867
973
  }
974
+ var GRAPH_EDGE_FAMILIES = ["flow", "support", "context"];
868
975
  var plural = (count, one, many) => `${count} ${count === 1 ? one : many}`;
869
976
  var relationWords = (list) => list.map((one) => `${one.relation ?? "depends on"} ${one.name}`).join(", ");
870
977
  var GRAPH_CANVAS_LABELS = {
@@ -887,11 +994,24 @@ var GRAPH_CANVAS_LABELS = {
887
994
  if (dependsOn.length > 0) parts.push(`${relationWords(dependsOn)}.`);
888
995
  if (usedBy.length > 0) parts.push(`Used by ${usedBy.map((one) => one.name).join(", ")}.`);
889
996
  return parts.join(" ");
890
- }
997
+ },
998
+ legend: "Legend",
999
+ families: { flow: "Calls", support: "Runs on", context: "Around it" },
1000
+ quiet: "Quiet",
1001
+ trunk: (lines) => `${lines} run on`,
1002
+ fullscreen: "Fullscreen",
1003
+ leaveFullscreen: "Leave fullscreen"
891
1004
  };
892
1005
  var GRAPH_CANVAS_DETAIL_ZOOM = 0.5;
893
1006
  var GRAPH_CANVAS_OPEN_ZOOM = 0.75;
894
1007
  var GRAPH_CANVAS_FIT_FLOOR = 0.02;
1008
+ var GRAPH_CANVAS_FLOW_LIMIT = 160;
1009
+ var POINT_IN_MS = 90;
1010
+ var POINT_OUT_MS = 120;
1011
+ var PRESS_SLOP = 4;
1012
+ var GRAPH_CANVAS_NARROW_WIDTH = 800;
1013
+ var CARD_GAP = 12;
1014
+ var CARD_INSET = 8;
895
1015
  var CARD_PROBE = "crewlet:graph-canvas-card";
896
1016
  var GAP_PROBE = "crewlet:graph-canvas-gap";
897
1017
  var PAD_PROBE = "crewlet:graph-canvas-pad";
@@ -900,6 +1020,11 @@ var BAND_PROBE = "crewlet:graph-canvas-band";
900
1020
  var PROBES = [CARD_PROBE, GAP_PROBE, PAD_PROBE, HEAD_PROBE, BAND_PROBE];
901
1021
  var emptyProbe = (lane) => `crewlet:graph-canvas-empty:${lane}`;
902
1022
  var NO_GROUPS = [];
1023
+ var AT_REST = /* @__PURE__ */ new Set(["flow"]);
1024
+ var FAMILY_RANK = { context: 0, support: 1, flow: 2 };
1025
+ var TONES = ["danger", "warning", "info"];
1026
+ var EDGE_STATES = ["dim", "rest", "lit"];
1027
+ var DRAW_ORDER = ["context", "support", "flow"];
903
1028
  var TONE_RANK = { info: 1, warning: 2, danger: 3 };
904
1029
  function GraphCanvas({
905
1030
  label,
@@ -913,6 +1038,15 @@ function GraphCanvas({
913
1038
  selectedId = null,
914
1039
  onSelect,
915
1040
  trace = null,
1041
+ hoveredId = null,
1042
+ onHover,
1043
+ renderCard,
1044
+ dock,
1045
+ families,
1046
+ onFamiliesChange,
1047
+ tones,
1048
+ chrome = true,
1049
+ fullscreen = true,
916
1050
  cardDimmed,
917
1051
  overlay,
918
1052
  controlsPlacement,
@@ -934,7 +1068,21 @@ function GraphCanvas({
934
1068
  const uid = useId();
935
1069
  const nodeById = useMemo(() => new Map(nodes.map((node) => [node.id, node])), [nodes]);
936
1070
  const groupById = useMemo(() => new Map(groups.map((group) => [group.id, group])), [groups]);
937
- const restEdges = useMemo(() => edges.filter((edge) => edge.atRest !== false), [edges]);
1071
+ const familyOf = useMemo(() => new Map(edges.map((edge) => [edge.id, edge.family ?? "flow"])), [edges]);
1072
+ const [ownFamilies, setOwnFamilies] = useState(AT_REST);
1073
+ const shown = families ?? ownFamilies;
1074
+ const toggleFamily = useCallback(
1075
+ (family) => {
1076
+ const next = new Set(shown);
1077
+ if (next.has(family)) next.delete(family);
1078
+ else next.add(family);
1079
+ if (!families) setOwnFamilies(next);
1080
+ onFamiliesChange?.(next);
1081
+ },
1082
+ [shown, families, onFamiliesChange]
1083
+ );
1084
+ const restEdges = useMemo(() => edges.filter((edge) => shown.has(edge.family ?? "flow")), [edges, shown]);
1085
+ const carrying = useMemo(() => edges.filter((edge) => (edge.family ?? "flow") !== "context"), [edges]);
938
1086
  const groupOf = useCallback((id) => nodeById.get(id)?.group, [nodeById]);
939
1087
  const [toggled, setToggled] = useState(() => /* @__PURE__ */ new Map());
940
1088
  const startClosed = collapseAbove !== void 0 && nodes.length > collapseAbove;
@@ -958,12 +1106,12 @@ function GraphCanvas({
958
1106
  const { measure, sizes, measured } = useMeasuredSizes();
959
1107
  const metrics = useMemo(() => {
960
1108
  if (!measured(PROBES)) return null;
961
- const card = sizes.get(CARD_PROBE);
1109
+ const card2 = sizes.get(CARD_PROBE);
962
1110
  const gap = sizes.get(GAP_PROBE);
963
1111
  const pad = sizes.get(PAD_PROBE);
964
1112
  return {
965
- cardWidth: card.width,
966
- cardHeight: card.height,
1113
+ cardWidth: card2.width,
1114
+ cardHeight: card2.height,
967
1115
  gutter: gap.width,
968
1116
  rowGap: gap.height,
969
1117
  laneHead: sizes.get(HEAD_PROBE).height,
@@ -989,21 +1137,60 @@ function GraphCanvas({
989
1137
  () => bands.map((band) => ({ id: band.id, titled: Boolean(band.label), lanes: band.lanes.map((lane) => lane.id) })),
990
1138
  [bands]
991
1139
  );
1140
+ const laneColumns = useMemo(() => {
1141
+ const out = /* @__PURE__ */ new Map();
1142
+ for (const band of bands) for (const lane of band.lanes) if (lane.columns !== void 0) out.set(lane.id, lane.columns);
1143
+ return out;
1144
+ }, [bands]);
992
1145
  const layout = useMemo(() => {
993
1146
  if (!metrics) return null;
994
1147
  return layoutGraph(
995
- { bands: layoutBands, nodes, groups, open: (id) => openSet.has(id), edges: restEdges, emptyHeights },
1148
+ {
1149
+ bands: layoutBands,
1150
+ nodes,
1151
+ groups,
1152
+ open: (id) => openSet.has(id),
1153
+ edges: restEdges,
1154
+ ordering: carrying,
1155
+ laneColumns,
1156
+ emptyHeights
1157
+ },
996
1158
  metrics
997
1159
  );
998
- }, [metrics, layoutBands, nodes, groups, openSet, restEdges, emptyHeights]);
1160
+ }, [metrics, layoutBands, nodes, groups, openSet, restEdges, carrying, laneColumns, emptyHeights]);
999
1161
  const everPlaced = useRef(false);
1000
1162
  const placed = layout !== null && (everPlaced.current || measured(emptyLanes.map((lane) => emptyProbe(lane.id))));
1001
1163
  if (placed) everPlaced.current = true;
1002
1164
  const laneOf = useMemo(() => new Map(bands.flatMap((band) => band.lanes.map((lane) => [lane.id, lane]))), [bands]);
1165
+ const [own, setOwn] = useState(null);
1166
+ const [card, setCard] = useState(null);
1167
+ const pointTimer = useRef(void 0);
1168
+ const hoverNow = useRef(onHover);
1169
+ hoverNow.current = onHover;
1170
+ const point = useCallback((id, delay) => {
1171
+ clearTimeout(pointTimer.current);
1172
+ const land = () => {
1173
+ setOwn(id);
1174
+ setCard(id);
1175
+ hoverNow.current?.(id);
1176
+ };
1177
+ if (delay === 0) land();
1178
+ else pointTimer.current = setTimeout(land, delay);
1179
+ }, []);
1180
+ useEffect(() => () => clearTimeout(pointTimer.current), []);
1181
+ const pointed = own ?? hoveredId;
1003
1182
  const reach = useMemo(() => {
1004
- if (selectedId === null || !nodeById.has(selectedId)) return null;
1005
- return trace ? graphReach(edges, selectedId, trace.direction, trace.depth) : graphNeighbourhood(edges, selectedId);
1006
- }, [selectedId, nodeById, trace, edges]);
1183
+ const focus = selectedId !== null && nodeById.has(selectedId) ? selectedId : null;
1184
+ const beside = pointed !== null && nodeById.has(pointed) ? pointed : null;
1185
+ if (focus === null) return beside === null ? null : graphNeighbourhood(edges, beside);
1186
+ const far = graphReach(carrying, focus, trace?.direction ?? "both", trace?.depth ?? Infinity);
1187
+ const near = graphNeighbourhood(edges, focus);
1188
+ const reached = new Map(far.nodes);
1189
+ for (const [id, hops] of near.nodes) if (!reached.has(id)) reached.set(id, hops);
1190
+ if (beside !== null && !reached.has(beside)) reached.set(beside, Infinity);
1191
+ return { nodes: reached, edges: /* @__PURE__ */ new Set([...far.edges, ...near.edges]) };
1192
+ }, [selectedId, pointed, nodeById, trace, edges, carrying]);
1193
+ const focusState = reach === null ? void 0 : selectedId !== null && nodeById.has(selectedId) ? "selected" : "hover";
1007
1194
  const nodeDimmed = useCallback(
1008
1195
  (id) => Boolean(cardDimmed?.(id)) || reach !== null && !reach.nodes.has(id),
1009
1196
  [cardDimmed, reach]
@@ -1021,22 +1208,27 @@ function GraphCanvas({
1021
1208
  }, [selectedGroup, selectedId, openSet, layout, setGroupOpen]);
1022
1209
  const drawn = useMemo(() => {
1023
1210
  if (!layout) return null;
1024
- const lit = /* @__PURE__ */ new Set();
1211
+ const strongest = (ids, only) => {
1212
+ let best = "context";
1213
+ for (const id of ids) {
1214
+ if (only && !only.has(id)) continue;
1215
+ const family = familyOf.get(id) ?? "flow";
1216
+ if (FAMILY_RANK[family] > FAMILY_RANK[best]) best = family;
1217
+ }
1218
+ return best;
1219
+ };
1220
+ const borrowed = /* @__PURE__ */ new Map();
1025
1221
  const extra = [];
1026
1222
  const known = new Set(layout.routes.map((route) => route.key));
1027
1223
  if (reach) {
1028
1224
  for (const edge of edges) {
1029
- if (!reach.edges.has(edge.id)) continue;
1030
- const route = layout.routeOfEdge.get(edge.id);
1031
- if (route !== void 0) {
1032
- lit.add(route);
1033
- continue;
1034
- }
1225
+ if (!reach.edges.has(edge.id) || layout.routeOfEdge.has(edge.id)) continue;
1035
1226
  const from = layout.itemOfNode.get(edge.from);
1036
1227
  const to = layout.itemOfNode.get(edge.to);
1037
1228
  if (from === void 0 || to === void 0 || from === to) continue;
1038
- if (known.has(`${from}>${to}`)) lit.add(`${from}>${to}`);
1039
- else extra.push(edge);
1229
+ const key = `${from}>${to}`;
1230
+ if (!known.has(key)) extra.push(edge);
1231
+ else borrowed.set(key, [...borrowed.get(key) ?? [], edge.id]);
1040
1232
  }
1041
1233
  }
1042
1234
  const itemDimmed = (key) => {
@@ -1044,17 +1236,32 @@ function GraphCanvas({
1044
1236
  if (item.kind === "node") return nodeDimmed(item.id);
1045
1237
  return layout.groupById.get(item.id)?.members.every(nodeDimmed) ?? false;
1046
1238
  };
1047
- const quiet = [];
1048
- const faint = [];
1049
- const strong = [];
1239
+ const layers = /* @__PURE__ */ new Map();
1240
+ const put = (family, state, route) => {
1241
+ const key = `${family}:${state}`;
1242
+ const list = layers.get(key);
1243
+ if (list) list.push(route);
1244
+ else layers.set(key, [route]);
1245
+ };
1050
1246
  for (const route of layout.routes) {
1051
- if (lit.has(route.key)) strong.push(route);
1052
- else if (reach || itemDimmed(route.from) || itemDimmed(route.to)) faint.push(route);
1053
- else quiet.push(route);
1247
+ const also = borrowed.get(route.key);
1248
+ const lit = reach !== null && (also !== void 0 || route.edges.some((id) => reach.edges.has(id)));
1249
+ if (lit) put(strongest(also ? [...route.edges, ...also] : route.edges, reach.edges), "lit", route);
1250
+ else if (reach || itemDimmed(route.from) || itemDimmed(route.to)) put(strongest(route.edges), "dim", route);
1251
+ else put(strongest(route.edges), "rest", route);
1054
1252
  }
1055
- strong.push(...routeGraphEdges(layout, extra));
1056
- return { quiet, faint, strong, itemDimmed };
1057
- }, [layout, reach, edges, nodeDimmed]);
1253
+ for (const route of routeGraphEdges(layout, extra)) put(strongest(route.edges), "lit", route);
1254
+ return { layers, itemDimmed };
1255
+ }, [layout, reach, edges, nodeDimmed, familyOf]);
1256
+ const laneOfNode = useCallback((id) => nodeById.get(id)?.lane, [nodeById]);
1257
+ const trunks = useMemo(() => {
1258
+ if (!layout || !chrome || shown.has("support")) return [];
1259
+ return graphTrunks(
1260
+ layout,
1261
+ edges.filter((edge) => edge.family === "support"),
1262
+ laneOfNode
1263
+ );
1264
+ }, [layout, chrome, shown, edges, laneOfNode]);
1058
1265
  const relationsOf = useMemo(() => {
1059
1266
  const out = /* @__PURE__ */ new Map();
1060
1267
  const entry = (id) => {
@@ -1075,10 +1282,15 @@ function GraphCanvas({
1075
1282
  const [mounted, setMounted] = useState(null);
1076
1283
  const mountedNow = useRef(mounted);
1077
1284
  mountedNow.current = mounted;
1285
+ const viewport = useRef(null);
1286
+ const placeCardNow = useRef(() => {
1287
+ });
1078
1288
  const viewChanged = useCallback(
1079
- (view, viewport) => {
1080
- onViewChange?.(view, viewport);
1081
- const next = graphWindow(mountedNow.current, view, viewport);
1289
+ (view, size) => {
1290
+ onViewChange?.(view, size);
1291
+ viewport.current = size;
1292
+ placeCardNow.current();
1293
+ const next = graphWindow(mountedNow.current, view, size);
1082
1294
  if (next !== mountedNow.current) setMounted(next);
1083
1295
  },
1084
1296
  [onViewChange]
@@ -1086,36 +1298,59 @@ function GraphCanvas({
1086
1298
  const paths = useMemo(() => {
1087
1299
  if (!drawn) return null;
1088
1300
  const near = (route) => !mounted || intersects(route.box, mounted.rect);
1089
- const join = (list, part, all = false) => list.filter((route) => all || near(route)).map((route) => route[part]).join("");
1090
- return {
1091
- quiet: { d: join(drawn.quiet, "d"), arrow: join(drawn.quiet, "arrow") },
1092
- faint: { d: join(drawn.faint, "d"), arrow: join(drawn.faint, "arrow") },
1093
- strong: { d: join(drawn.strong, "d", true), arrow: join(drawn.strong, "arrow", true) }
1094
- };
1301
+ const out = /* @__PURE__ */ new Map();
1302
+ for (const [key, list] of drawn.layers) {
1303
+ const kept = key.endsWith(":lit") ? list : list.filter(near);
1304
+ out.set(key, {
1305
+ d: kept.map((route) => route.d).join(""),
1306
+ arrow: kept.map((route) => route.arrow).join(""),
1307
+ count: kept.length
1308
+ });
1309
+ }
1310
+ return out;
1095
1311
  }, [drawn, mounted]);
1312
+ const still = (paths?.get("flow:rest")?.count ?? 0) > GRAPH_CANVAS_FLOW_LIMIT;
1313
+ const cardEl = useRef(null);
1314
+ const cardItem = card === null || !renderCard || !layout ? void 0 : layout.itemByKey.get(graphItemKey("node", card));
1315
+ placeCardNow.current = () => {
1316
+ const el = cardEl.current;
1317
+ const size = viewport.current;
1318
+ if (!el || !cardItem || !size || !canvas.current) return;
1319
+ const at = canvas.current.screenRect(cardItem);
1320
+ const width2 = el.offsetWidth;
1321
+ const height2 = el.offsetHeight;
1322
+ const fitsAfter = at.x + at.width + CARD_GAP + width2 <= size.width - CARD_INSET;
1323
+ const left = fitsAfter ? at.x + at.width + CARD_GAP : Math.max(CARD_INSET, at.x - CARD_GAP - width2);
1324
+ const top = Math.max(CARD_INSET, Math.min(at.y - CARD_GAP, size.height - height2 - CARD_INSET));
1325
+ el.style.transform = `translate(${Math.round(left)}px, ${Math.round(top)}px)`;
1326
+ };
1327
+ useLayoutEffect(() => placeCardNow.current());
1096
1328
  const root = useRef(null);
1097
1329
  const [frame, setFrame] = useState(null);
1330
+ const [narrow, setNarrow] = useState(false);
1098
1331
  useLayoutEffect(() => {
1099
1332
  const el = root.current;
1100
1333
  if (!el || typeof ResizeObserver === "undefined") return;
1101
1334
  const observer = new ResizeObserver((entries) => {
1102
1335
  const box = entries[entries.length - 1]?.contentRect;
1103
- if (box && box.width > 0 && box.height > 0) setFrame((was) => was ?? { width: box.width, height: box.height });
1336
+ if (!box || box.width <= 0 || box.height <= 0) return;
1337
+ setFrame((was) => was ?? { width: box.width, height: box.height });
1338
+ setNarrow(box.width < GRAPH_CANVAS_NARROW_WIDTH);
1104
1339
  });
1105
1340
  observer.observe(el);
1106
1341
  return () => observer.disconnect();
1107
1342
  }, []);
1108
- const [chrome, setChrome] = useState(0);
1343
+ const [barsBottom, setBarsBottom] = useState(0);
1109
1344
  useLayoutEffect(() => {
1110
1345
  const el = root.current;
1111
1346
  if (!el || !frame) return;
1112
1347
  const top = el.getBoundingClientRect().top;
1113
1348
  let bottom = 0;
1114
- for (const bar of el.querySelectorAll(".crewlet-canvas__controls")) {
1115
- const rect = bar.getBoundingClientRect();
1349
+ for (const bar2 of el.querySelectorAll(".crewlet-canvas__controls")) {
1350
+ const rect = bar2.getBoundingClientRect();
1116
1351
  if (rect.height > 0 && rect.top - top < frame.height / 2) bottom = Math.max(bottom, rect.bottom - top);
1117
1352
  }
1118
- setChrome(bottom);
1353
+ setBarsBottom(bottom);
1119
1354
  }, [frame, controlsStart, controlsPlacement]);
1120
1355
  const opening = useMemo(() => {
1121
1356
  if (initialView) return initialView;
@@ -1123,9 +1358,9 @@ function GraphCanvas({
1123
1358
  const fit = fitView(layout.bounds, frame, CANVAS_FIT_PADDING, minZoom);
1124
1359
  if (fit.k >= GRAPH_CANVAS_DETAIL_ZOOM) return void 0;
1125
1360
  const k = GRAPH_CANVAS_OPEN_ZOOM;
1126
- const y = Math.max(CANVAS_FIT_PADDING, chrome + CANVAS_FIT_PADDING / 2);
1361
+ const y = Math.max(CANVAS_FIT_PADDING, barsBottom + CANVAS_FIT_PADDING / 2);
1127
1362
  return { k, x: CANVAS_FIT_PADDING - layout.bounds.x * k, y: y - layout.bounds.y * k };
1128
- }, [initialView, layout, frame, minZoom, chrome]);
1363
+ }, [initialView, layout, frame, minZoom, barsBottom]);
1129
1364
  const [active, setActive] = useState(null);
1130
1365
  const selectedKey = selectedId === null || !layout ? null : layout.itemOfNode.get(selectedId) ?? null;
1131
1366
  const activeKey = active !== null && layout?.itemByKey.has(active) ? active : selectedKey ?? layout?.lanes.find((lane) => lane.items.length > 0)?.items[0] ?? null;
@@ -1191,9 +1426,9 @@ function GraphCanvas({
1191
1426
  ref,
1192
1427
  () => ({
1193
1428
  focusNode: (id) => {
1194
- const { openSet: shown, groupOf: owner, setGroupOpen: reveal } = openNow.current;
1429
+ const { openSet: shown2, groupOf: owner, setGroupOpen: reveal } = openNow.current;
1195
1430
  const group = owner(id);
1196
- if (group !== void 0 && !shown.has(group)) reveal(group, true);
1431
+ if (group !== void 0 && !shown2.has(group)) reveal(group, true);
1197
1432
  focusItem(graphItemKey("node", id));
1198
1433
  },
1199
1434
  fit: () => canvas.current?.fit()
@@ -1217,18 +1452,31 @@ function GraphCanvas({
1217
1452
  const activate = useCallback(
1218
1453
  (item, focus) => {
1219
1454
  if (item.kind === "node") {
1220
- onSelect?.(item.id);
1455
+ onSelect?.(item.id === selectedId ? null : item.id);
1221
1456
  setActive(item.key);
1222
1457
  if (focus) pendingFocus.current = item.key;
1223
1458
  } else if (item.kind === "head" || item.kind === "summary") {
1224
1459
  toggleGroup(item.id, focus);
1225
1460
  }
1226
1461
  },
1227
- [onSelect, toggleGroup]
1462
+ [onSelect, selectedId, toggleGroup]
1228
1463
  );
1464
+ const pressed = useRef(null);
1465
+ const onPointerDownCapture = (event) => {
1466
+ pressed.current = { x: event.clientX, y: event.clientY };
1467
+ };
1468
+ const onGroundClick = (event) => {
1469
+ const from = pressed.current;
1470
+ pressed.current = null;
1471
+ if (!chrome || selectedId === null || !from) return;
1472
+ if (Math.hypot(event.clientX - from.x, event.clientY - from.y) > PRESS_SLOP) return;
1473
+ if (event.target.closest("[data-graph-key], [data-graph-solid], .crewlet-canvas__controls")) return;
1474
+ onSelect?.(null);
1475
+ };
1229
1476
  function onKeyDown(event) {
1230
1477
  if (!layout) return;
1231
1478
  if (event.key === "Escape") {
1479
+ if (card !== null) setCard(null);
1232
1480
  if (selectedId === null) return;
1233
1481
  event.preventDefault();
1234
1482
  event.stopPropagation();
@@ -1263,6 +1511,10 @@ function GraphCanvas({
1263
1511
  }
1264
1512
  const handlers = useRef({ onKeyDown, activate, setActive, layout });
1265
1513
  handlers.current = { onKeyDown, activate, setActive, layout };
1514
+ const onItemPoint = useCallback(
1515
+ (id, how) => point(id, how === "focus" ? 0 : id === null ? POINT_OUT_MS : POINT_IN_MS),
1516
+ [point]
1517
+ );
1266
1518
  const onItemKey = useCallback((event) => handlers.current.onKeyDown(event), []);
1267
1519
  const onItemPress = useCallback((key) => {
1268
1520
  const item = handlers.current.layout?.itemByKey.get(key);
@@ -1324,7 +1576,8 @@ function GraphCanvas({
1324
1576
  ...common,
1325
1577
  node,
1326
1578
  selected: item.id === selectedId,
1327
- dimmed: nodeDimmed(item.id),
1579
+ state: nodeDimmed(item.id) ? "dim" : reach?.nodes.has(item.id) ? "lit" : "rest",
1580
+ onPoint: onItemPoint,
1328
1581
  description: relations ? text.relations(relations.dependsOn, relations.usedBy) : "",
1329
1582
  descriptionId: `${uid}-d-${encodeURIComponent(item.key)}`,
1330
1583
  unconfirmedLabel: text.unconfirmed
@@ -1355,18 +1608,80 @@ function GraphCanvas({
1355
1608
  };
1356
1609
  const width = layout?.bounds.width ?? 0;
1357
1610
  const height = layout?.bounds.height ?? 0;
1358
- return /* @__PURE__ */ jsx("div", { ref: root, className: cx("crewlet-graph-canvas", className), children: frame ? /* @__PURE__ */ jsxs(
1611
+ const tallies = useMemo(() => {
1612
+ const out = /* @__PURE__ */ new Map();
1613
+ for (const node of nodes) {
1614
+ if (!node.attention) continue;
1615
+ let tally = out.get(node.lane);
1616
+ if (!tally) out.set(node.lane, tally = {});
1617
+ tally[node.attention.tone] = (tally[node.attention.tone] ?? 0) + 1;
1618
+ }
1619
+ return out;
1620
+ }, [nodes]);
1621
+ const laneName = (id, count) => {
1622
+ const tally = tallies.get(id);
1623
+ const words = TONES.flatMap((tone) => tally?.[tone] && tones?.[tone] ? [`${tally[tone]} ${tones[tone]}`] : []);
1624
+ return [text.lane(laneOf.get(id)?.label ?? id, count), ...words].join(", ");
1625
+ };
1626
+ const legend = chrome ? /* @__PURE__ */ jsxs("div", { className: "crewlet-graph-canvas__legend", role: "group", "aria-label": text.legend, children: [
1627
+ TONES.map(
1628
+ (tone) => tones?.[tone] ? /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__key", children: [
1629
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__key-notch", "data-tone": tone, "aria-hidden": "true" }),
1630
+ tones[tone]
1631
+ ] }, tone) : null
1632
+ ),
1633
+ /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__key", children: [
1634
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__key-notch", "aria-hidden": "true" }),
1635
+ text.quiet
1636
+ ] }),
1637
+ /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__key", children: [
1638
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__key-notch", "data-unconfirmed": "", "aria-hidden": "true" }),
1639
+ text.unconfirmed
1640
+ ] }),
1641
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__legend-rule", "aria-hidden": "true" }),
1642
+ GRAPH_EDGE_FAMILIES.map((family) => /* @__PURE__ */ jsx(FilterChip, { pressed: shown.has(family), onPressedChange: () => toggleFamily(family), children: /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__switch", children: [
1643
+ /* @__PURE__ */ jsx("svg", { className: "crewlet-graph-canvas__key-line", "data-family": family, viewBox: "0 0 22 8", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M1 4h20" }) }),
1644
+ text.families[family]
1645
+ ] }) }, family))
1646
+ ] }) : null;
1647
+ const ownFullscreen = fullscreen === true;
1648
+ const fullscreenTarget = typeof fullscreen === "object" ? fullscreen : root;
1649
+ const bar = chrome && fullscreen !== false ? /* @__PURE__ */ jsxs(Fragment, { children: [
1650
+ /* @__PURE__ */ jsx(
1651
+ FullscreenToggle,
1652
+ {
1653
+ target: fullscreenTarget,
1654
+ labels: { enter: text.fullscreen, leave: text.leaveFullscreen }
1655
+ }
1656
+ ),
1657
+ controlsExtra
1658
+ ] }) : controlsExtra;
1659
+ const over = /* @__PURE__ */ jsxs(Fragment, { children: [
1660
+ cardItem && card !== null ? /* @__PURE__ */ jsx("div", { ref: cardEl, className: "crewlet-graph-canvas__popup", role: "tooltip", children: renderCard?.(card) }) : null,
1661
+ dock && !narrow ? /* @__PURE__ */ jsx("div", { className: "crewlet-graph-canvas__dock", "data-graph-solid": "", children: dock }) : null,
1662
+ overlay
1663
+ ] });
1664
+ const end = narrow ? overlayEnd : legend || overlayEnd ? /* @__PURE__ */ jsxs(Fragment, { children: [
1665
+ legend,
1666
+ overlayEnd
1667
+ ] }) : void 0;
1668
+ const foot = narrow && (dock || legend) ? /* @__PURE__ */ jsxs("div", { className: "crewlet-graph-canvas__foot", "data-graph-solid": "", children: [
1669
+ dock ? /* @__PURE__ */ jsx("div", { className: "crewlet-graph-canvas__dock", children: dock }) : null,
1670
+ legend
1671
+ ] }) : null;
1672
+ const body = frame ? /* @__PURE__ */ jsxs(
1359
1673
  Canvas,
1360
1674
  {
1361
1675
  label,
1362
1676
  content: placed ? layout.bounds : null,
1363
1677
  ref: canvas,
1364
- overlay,
1678
+ overlay: over,
1679
+ controls: chrome,
1365
1680
  controlsPlacement,
1366
- controlsExtra,
1681
+ controlsExtra: bar,
1367
1682
  controlsBelow,
1368
1683
  controlsStart,
1369
- overlayEnd,
1684
+ overlayEnd: end,
1370
1685
  hint,
1371
1686
  ground,
1372
1687
  largestItemWidth: metrics?.cardWidth,
@@ -1391,7 +1706,7 @@ function GraphCanvas({
1391
1706
  lane.id
1392
1707
  );
1393
1708
  }),
1394
- layout && placed ? /* @__PURE__ */ jsxs(Fragment, { children: [
1709
+ layout && placed ? /* @__PURE__ */ jsxs("div", { className: "crewlet-graph-canvas__world", style: { width: `${width}px`, height: `${height}px` }, children: [
1395
1710
  /* @__PURE__ */ jsxs("svg", { className: "crewlet-graph-canvas__ground", width, height, "aria-hidden": "true", children: [
1396
1711
  layout.lanes.map((lane) => /* @__PURE__ */ jsx(
1397
1712
  "rect",
@@ -1430,27 +1745,58 @@ function GraphCanvas({
1430
1745
  band.id
1431
1746
  ) : null
1432
1747
  ),
1433
- layout.lanes.map((lane) => /* @__PURE__ */ jsxs(
1434
- "div",
1748
+ paths ? /* @__PURE__ */ jsxs("svg", { className: "crewlet-graph-canvas__edges", width, height, "aria-hidden": "true", children: [
1749
+ trunks.length > 0 ? /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__trunk", d: trunks.map((trunk) => trunk.d).join("") }) : null,
1750
+ EDGE_STATES.flatMap(
1751
+ (state) => DRAW_ORDER.map((family) => {
1752
+ const layer = paths.get(`${family}:${state}`);
1753
+ if (!layer || layer.d === "") return null;
1754
+ return /* @__PURE__ */ jsxs(
1755
+ "g",
1756
+ {
1757
+ className: "crewlet-graph-canvas__edge-layer",
1758
+ "data-family": family,
1759
+ "data-state": state,
1760
+ children: [
1761
+ /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__edge", d: layer.d }),
1762
+ /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__arrow", d: layer.arrow }),
1763
+ family === "flow" && state !== "dim" ? /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__flow", d: layer.d }) : null
1764
+ ]
1765
+ },
1766
+ `${family}:${state}`
1767
+ );
1768
+ })
1769
+ )
1770
+ ] }) : null,
1771
+ trunks.map((trunk) => /* @__PURE__ */ jsx(
1772
+ "span",
1435
1773
  {
1436
- className: "crewlet-graph-canvas__lane-head",
1774
+ className: "crewlet-graph-canvas__trunk-label",
1437
1775
  "aria-hidden": "true",
1438
- style: placedStyle(lane.head),
1439
- children: [
1440
- /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__lane-label", children: laneOf.get(lane.id)?.label }),
1441
- /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__lane-count", children: lane.count })
1442
- ]
1776
+ style: { transform: `translate(${trunk.label.x}px, ${trunk.label.y}px) translate(-50%, -50%)` },
1777
+ children: text.trunk(trunk.count)
1443
1778
  },
1444
- lane.id
1779
+ trunk.key
1445
1780
  )),
1446
- paths ? /* @__PURE__ */ jsxs("svg", { className: "crewlet-graph-canvas__edges", width, height, "aria-hidden": "true", children: [
1447
- /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__edge", "data-state": "faint", d: paths.faint.d }),
1448
- /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__arrow", "data-state": "faint", d: paths.faint.arrow }),
1449
- /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__edge", "data-state": "quiet", d: paths.quiet.d }),
1450
- /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__arrow", "data-state": "quiet", d: paths.quiet.arrow }),
1451
- /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__edge", "data-state": "strong", d: paths.strong.d }),
1452
- /* @__PURE__ */ jsx("path", { className: "crewlet-graph-canvas__arrow", "data-state": "strong", d: paths.strong.arrow })
1453
- ] }) : null,
1781
+ layout.lanes.map((lane) => {
1782
+ const tally = tallies.get(lane.id);
1783
+ return /* @__PURE__ */ jsx(
1784
+ "div",
1785
+ {
1786
+ className: "crewlet-graph-canvas__lane-head",
1787
+ "aria-hidden": "true",
1788
+ style: placedStyle(lane.head),
1789
+ children: /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__lane-title", children: [
1790
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__lane-label", children: laneOf.get(lane.id)?.label }),
1791
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__lane-count", children: lane.count }),
1792
+ TONES.map(
1793
+ (tone) => tally?.[tone] ? /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__lane-tone", "data-tone": tone, children: tally[tone] }, tone) : null
1794
+ )
1795
+ ] })
1796
+ },
1797
+ lane.id
1798
+ );
1799
+ }),
1454
1800
  mounted && !mounted.detail ? /* @__PURE__ */ jsx(
1455
1801
  Shapes,
1456
1802
  {
@@ -1463,21 +1809,35 @@ function GraphCanvas({
1463
1809
  ) : null,
1464
1810
  /* @__PURE__ */ jsx("div", { className: "crewlet-graph-canvas__items", children: bands.map((band, b) => {
1465
1811
  const lanes = layout.lanes.filter((lane) => lane.band === b);
1466
- const body = lanes.map((lane) => /* @__PURE__ */ jsx(
1467
- "div",
1468
- {
1469
- role: "group",
1470
- "aria-label": text.lane(laneOf.get(lane.id)?.label ?? lane.id, lane.count),
1471
- children: (shownByLane.get(lane.id) ?? []).map(renderItem)
1472
- },
1473
- lane.id
1474
- ));
1475
- return band.label ? /* @__PURE__ */ jsx("div", { role: "group", "aria-label": band.label, children: body }, band.id) : /* @__PURE__ */ jsx("div", { role: "none", children: body }, band.id);
1812
+ const inner = lanes.map((lane) => /* @__PURE__ */ jsx("div", { role: "group", "aria-label": laneName(lane.id, lane.count), children: (shownByLane.get(lane.id) ?? []).map(renderItem) }, lane.id));
1813
+ return band.label ? /* @__PURE__ */ jsx("div", { role: "group", "aria-label": band.label, children: inner }, band.id) : /* @__PURE__ */ jsx("div", { role: "none", children: inner }, band.id);
1476
1814
  }) })
1477
1815
  ] }) : null
1478
1816
  ]
1479
1817
  }
1480
- ) : null });
1818
+ ) : null;
1819
+ return (
1820
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events -- a press on the ground clears the selection, which Escape does from the keys
1821
+ /* @__PURE__ */ jsx(
1822
+ "div",
1823
+ {
1824
+ ref: root,
1825
+ className: cx("crewlet-graph-canvas", className),
1826
+ "data-narrow": narrow ? "" : void 0,
1827
+ "data-focus": focusState,
1828
+ "data-still": still ? "" : void 0,
1829
+ onPointerDownCapture,
1830
+ onClick: onGroundClick,
1831
+ children: ownFullscreen ? /* @__PURE__ */ jsxs(LayerHost, { children: [
1832
+ body,
1833
+ foot
1834
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1835
+ body,
1836
+ foot
1837
+ ] })
1838
+ }
1839
+ )
1840
+ );
1481
1841
  }
1482
1842
  function Probes({ measure }) {
1483
1843
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -1525,6 +1885,11 @@ function Probes({ measure }) {
1525
1885
  )
1526
1886
  ] });
1527
1887
  }
1888
+ function toneGlyph(tone) {
1889
+ if (tone === "danger") return /* @__PURE__ */ jsx(TriangleAlertGlyph, {});
1890
+ if (tone === "warning") return /* @__PURE__ */ jsx(CircleAlertGlyph, {});
1891
+ return /* @__PURE__ */ jsx(InfoGlyph, {});
1892
+ }
1528
1893
  var GraphCard = memo(function GraphCard2({
1529
1894
  itemKey,
1530
1895
  item,
@@ -1535,13 +1900,14 @@ var GraphCard = memo(function GraphCard2({
1535
1900
  onItemKey,
1536
1901
  node,
1537
1902
  selected,
1538
- dimmed,
1903
+ state,
1904
+ onPoint,
1539
1905
  description,
1540
1906
  descriptionId,
1541
1907
  unconfirmedLabel
1542
1908
  }) {
1543
1909
  const spoken = [
1544
- node.name,
1910
+ node.title ?? node.name,
1545
1911
  node.kind,
1546
1912
  node.caption,
1547
1913
  node.attention?.label,
@@ -1553,25 +1919,32 @@ var GraphCard = memo(function GraphCard2({
1553
1919
  ref: refFor(itemKey),
1554
1920
  role: "button",
1555
1921
  tabIndex,
1922
+ title: node.title,
1556
1923
  "aria-describedby": description ? descriptionId : void 0,
1557
1924
  "aria-current": selected ? "true" : void 0,
1558
1925
  "data-graph-key": itemKey,
1559
1926
  "data-attention": node.attention?.tone,
1560
1927
  "data-unconfirmed": node.unconfirmed ? "" : void 0,
1561
1928
  "data-selected": selected ? "" : void 0,
1562
- "data-dimmed": dimmed ? "" : void 0,
1929
+ "data-state": state,
1563
1930
  className: "crewlet-graph-canvas__card",
1564
1931
  style: { transform: `translate(${item.x}px, ${item.y}px)` },
1565
1932
  onClick: () => onPress(itemKey),
1566
- onFocus: () => onFocusItem(itemKey),
1933
+ onFocus: () => {
1934
+ onFocusItem(itemKey);
1935
+ onPoint(node.id, "focus");
1936
+ },
1937
+ onBlur: () => onPoint(null, "focus"),
1938
+ onPointerEnter: () => onPoint(node.id, "pointer"),
1939
+ onPointerLeave: () => onPoint(null, "pointer"),
1567
1940
  onKeyDown: onItemKey,
1568
1941
  children: [
1569
- /* @__PURE__ */ jsx(IconTile, { size: "sm", tone: "neutral", className: "crewlet-graph-canvas__tile", children: node.glyph }),
1570
- /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__text", "aria-hidden": "true", children: [
1571
- /* @__PURE__ */ jsx(Text, { variant: "inherit", truncate: true, className: "crewlet-graph-canvas__name", children: node.name }),
1572
- node.caption ? /* @__PURE__ */ jsx(Text, { variant: "inherit", truncate: true, className: "crewlet-graph-canvas__caption", children: node.caption }) : null
1942
+ /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__cell", "aria-hidden": "true", children: [
1943
+ node.glyph,
1944
+ node.mark ? /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__mark", children: node.mark }) : null
1573
1945
  ] }),
1574
- node.attention ? /* @__PURE__ */ jsx(StatusDot, { tone: node.attention.tone, className: "crewlet-graph-canvas__dot" }) : null,
1946
+ /* @__PURE__ */ jsx(Text, { variant: "inherit", truncate: true, className: "crewlet-graph-canvas__name", "aria-hidden": "true", children: node.name }),
1947
+ node.attention ? /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__badge", "aria-hidden": "true", children: node.attention.glyph ?? toneGlyph(node.attention.tone) }) : null,
1575
1948
  /* @__PURE__ */ jsx(SpokenName, { spoken, description, descriptionId })
1576
1949
  ]
1577
1950
  }
@@ -1605,7 +1978,7 @@ var GraphGroupItem = memo(function GraphGroupItem2({
1605
1978
  "data-graph-key": itemKey,
1606
1979
  "aria-current": selected ? "true" : void 0,
1607
1980
  "data-attention": attention?.tone,
1608
- "data-dimmed": dimmed ? "" : void 0,
1981
+ "data-state": dimmed ? "dim" : "rest",
1609
1982
  "data-selected": selected ? "" : void 0,
1610
1983
  className: open ? "crewlet-graph-canvas__head" : "crewlet-graph-canvas__card crewlet-graph-canvas__card--group",
1611
1984
  style: {
@@ -1622,13 +1995,11 @@ var GraphGroupItem = memo(function GraphGroupItem2({
1622
1995
  /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__group-count", "aria-hidden": "true", children: count }),
1623
1996
  /* @__PURE__ */ jsx(SpokenName, { spoken })
1624
1997
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1625
- /* @__PURE__ */ jsx(IconTile, { size: "sm", tone: "neutral", className: "crewlet-graph-canvas__tile", children: lead ?? /* @__PURE__ */ jsx(ChevronRightGlyph, { size: "sm" }) }),
1626
- /* @__PURE__ */ jsxs("span", { className: "crewlet-graph-canvas__text", "aria-hidden": "true", children: [
1627
- /* @__PURE__ */ jsx(Text, { variant: "inherit", truncate: true, className: "crewlet-graph-canvas__name", children: label }),
1628
- /* @__PURE__ */ jsx(Text, { variant: "inherit", truncate: true, className: "crewlet-graph-canvas__caption", children: text.entries(count) })
1629
- ] }),
1998
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__cell", "aria-hidden": "true", children: lead ?? /* @__PURE__ */ jsx(ChevronRightGlyph, { size: "sm" }) }),
1999
+ /* @__PURE__ */ jsx(Text, { variant: "inherit", truncate: true, className: "crewlet-graph-canvas__name", "aria-hidden": "true", children: label }),
2000
+ /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__group-count", "aria-hidden": "true", children: count }),
1630
2001
  /* @__PURE__ */ jsx(ChevronRightGlyph, { size: "xs", "aria-hidden": "true", className: "crewlet-graph-canvas__chevron" }),
1631
- attention ? /* @__PURE__ */ jsx(StatusDot, { tone: attention.tone, className: "crewlet-graph-canvas__dot" }) : null,
2002
+ attention ? /* @__PURE__ */ jsx("span", { className: "crewlet-graph-canvas__badge", "aria-hidden": "true", children: attention.glyph ?? toneGlyph(attention.tone) }) : null,
1632
2003
  /* @__PURE__ */ jsx(SpokenName, { spoken })
1633
2004
  ] })
1634
2005
  }
@@ -1675,6 +2046,8 @@ function GraphEmptyLane({
1675
2046
  )
1676
2047
  );
1677
2048
  }
2049
+ var SHAPE_CORNER = 2;
2050
+ var SHAPE_NOTCH = 4;
1678
2051
  function Shapes({
1679
2052
  layout,
1680
2053
  nodeById,
@@ -1684,7 +2057,7 @@ function Shapes({
1684
2057
  }) {
1685
2058
  const paths = useMemo(() => {
1686
2059
  const out = { card: "", faded: "", dashed: "", danger: "", warning: "", info: "", selected: "" };
1687
- const radius = Math.min(6, layout.metrics.cardHeight / 6);
2060
+ const radius = SHAPE_CORNER;
1688
2061
  for (const item of layout.items) {
1689
2062
  if (item.kind !== "node" && item.kind !== "summary") continue;
1690
2063
  const node = item.kind === "node" ? nodeById.get(item.id) : void 0;
@@ -1694,12 +2067,7 @@ function Shapes({
1694
2067
  else if (node?.unconfirmed) out.dashed += rect;
1695
2068
  else out.card += rect;
1696
2069
  const attention = node ? node.attention : worstOf(layout.groupById.get(item.id)?.members ?? []);
1697
- if (attention) {
1698
- const r = layout.metrics.cardHeight / 8;
1699
- const cx2 = item.x + item.width - r * 2;
1700
- const cy = item.y + r * 2;
1701
- out[attention.tone] += `M${cx2 - r} ${cy}a${r} ${r} 0 1 0 ${2 * r} 0a${r} ${r} 0 1 0 ${ -2 * r} 0Z`;
1702
- }
2070
+ if (attention) out[attention.tone] += `M${item.x} ${item.y}h${SHAPE_NOTCH}v${item.height}h${-SHAPE_NOTCH}Z`;
1703
2071
  }
1704
2072
  return out;
1705
2073
  }, [layout, nodeById, dimmed, worstOf, selectedKey]);
@@ -1767,4 +2135,4 @@ function typeAhead(layout, from, text, nameOf) {
1767
2135
  return null;
1768
2136
  }
1769
2137
 
1770
- export { GRAPH_CANVAS_DETAIL_ZOOM, GRAPH_CANVAS_FIT_FLOOR, GRAPH_CANVAS_LABELS, GRAPH_CANVAS_OPEN_ZOOM, GRAPH_ORDER_SWEEPS, GraphCanvas, graphItemKey, graphNeighbourhood, graphReach, graphStep, graphWindow, layoutGraph, routeGraphEdges };
2138
+ export { GRAPH_CANVAS_DETAIL_ZOOM, GRAPH_CANVAS_FIT_FLOOR, GRAPH_CANVAS_FLOW_LIMIT, GRAPH_CANVAS_LABELS, GRAPH_CANVAS_NARROW_WIDTH, GRAPH_CANVAS_OPEN_ZOOM, GRAPH_EDGE_FAMILIES, GRAPH_ORDER_SWEEPS, GraphCanvas, graphItemKey, graphNeighbourhood, graphReach, graphStep, graphTrunks, graphWindow, layoutGraph, routeGraphEdges };