dsh-recency-guard 0.11.3 → 0.12.1

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.
package/dist/client.js CHANGED
@@ -31,10 +31,10 @@ __export(entry_exports, {
31
31
  module.exports = __toCommonJS(entry_exports);
32
32
 
33
33
  // src/client/index.ts
34
- var import_react5 = require("react");
34
+ var import_react7 = require("react");
35
35
 
36
36
  // src/client/GuardPanel.tsx
37
- var import_react3 = require("react");
37
+ var import_react5 = require("react");
38
38
 
39
39
  // locale/zh.json
40
40
  var zh_default = {
@@ -50,6 +50,8 @@ var zh_default = {
50
50
  archive: "\u5F52\u6863\u91CD\u7F6E",
51
51
  archiveConfirm: "\u5F52\u6863\u5F53\u524D\u4EA7\u7269\u5E76\u6309\u6700\u65B0\u4E8B\u5B9E\u91CD\u8DD1\uFF1F",
52
52
  archiveDefaultReason: "\u9762\u677F\u624B\u52A8\u5F52\u6863",
53
+ conflictNotice: "\u72B6\u6001\u5DF2\u53D8\u5316\uFF0C\u4E0A\u4E00\u6B21\u52A8\u4F5C\u672A\u6267\u884C\u3002\u753B\u9762\u5DF2\u5237\u65B0\u4E3A\u6700\u65B0\u4E8B\u5B9E\uFF0C\u8BF7\u636E\u6B64\u91CD\u65B0\u51B3\u5B9A\u3002",
54
+ conflictDismiss: "\u77E5\u9053\u4E86",
53
55
  recover: "\u7ACB\u5373\u6062\u590D",
54
56
  reenable: "\u91CD\u65B0\u542F\u7528",
55
57
  empty: "\u6682\u65E0\u6570\u636E",
@@ -89,7 +91,9 @@ var zh_default = {
89
91
  transitions: "\u8FC1\u79FB\u6B21\u6570",
90
92
  noTransitions: "\u5C1A\u65E0\u8FC1\u79FB\u8BB0\u5F55",
91
93
  autoDisabled: "\u81EA\u52A8\u5173\u95ED",
92
- restored: "\u5DF2\u6062\u590D"
94
+ restored: "\u5DF2\u6062\u590D",
95
+ moreTransitions: "\u8FD8\u6709 {count} \u6B21\u66F4\u65E9\u7684\u8FC1\u79FB\u672A\u663E\u793A",
96
+ fewerTransitions: "\u6536\u8D77\u8F83\u65E9\u7684\u8FC1\u79FB"
93
97
  },
94
98
  metrics: {
95
99
  crashRate: "\u5D29\u6E83\u7387",
@@ -113,7 +117,9 @@ var zh_default = {
113
117
  converged: "\u5DF2\u6536\u655B",
114
118
  notConverged: "\u672A\u6536\u655B",
115
119
  samples: "{count} \u6B21\u8FC1\u79FB",
116
- empty: "\u5C1A\u65E0\u8FC1\u79FB\u8BB0\u5F55\uFF0C\u8F6C\u79FB\u77E9\u9635\u4E0D\u53EF\u5224\u5B9A"
120
+ empty: "\u5C1A\u65E0\u8FC1\u79FB\u8BB0\u5F55\uFF0C\u8F6C\u79FB\u77E9\u9635\u4E0D\u53EF\u5224\u5B9A",
121
+ stationaryMore: "\u5176\u4F59 {count} \u4E2A\u9636\u6BB5",
122
+ stationaryAll: "\u5171 {count} \u4E2A\u9636\u6BB5\u6709\u957F\u671F\u5360\u6BD4"
117
123
  },
118
124
  dataflow: {
119
125
  title: "\u6570\u636E\u6D41",
@@ -276,7 +282,19 @@ var zh_default = {
276
282
  edgeTo: "\u6D88\u8D39\u65B9\uFF08\u7EC8\u70B9\uFF09",
277
283
  edgeKind: "\u8BED\u4E49",
278
284
  edgeTransitions: "\u72B6\u6001\u8FC1\u79FB",
279
- edgeRanks: "\u6392\u5E8F\u5F15\u7528"
285
+ edgeRanks: "\u6392\u5E8F\u5F15\u7528",
286
+ minimap: "\u5C0F\u5730\u56FE",
287
+ minimapHint: "\u65B9\u6846\u662F\u5F53\u524D\u53EF\u89C1\u533A\u57DF\uFF1B\u70B9\u51FB\u6216\u62D6\u52A8\u65B9\u6846\u53EF\u628A\u4E3B\u89C6\u56FE\u79FB\u5230\u8BE5\u5904\u3002",
288
+ arrowHint: "\u65B9\u5411\u952E\u6362\u8282\u70B9",
289
+ linkRange: {
290
+ label: "\u5173\u8054\u8303\u56F4",
291
+ hops1: "\u76F4\u63A5",
292
+ hops2: "\u4E24\u8DF3",
293
+ closure: "\u5168\u8FDE\u901A"
294
+ },
295
+ filteredEmpty: "\u5F53\u524D\u8FC7\u6EE4\u6761\u4EF6\u628A\u56FE\u6EE4\u7A7A\u4E86\u3002",
296
+ filteredEmptyReset: "\u6062\u590D\u663E\u793A",
297
+ searchMore: "\u5176\u4F59 {count} \u4E2A\u5339\u914D"
280
298
  },
281
299
  events: {
282
300
  title: "\u4E8B\u4EF6\u6D41",
@@ -332,6 +350,8 @@ var en_default = {
332
350
  archive: "Archive & reset",
333
351
  archiveConfirm: "Archive the current artifacts and restart from the latest facts?",
334
352
  archiveDefaultReason: "manual archive from the panel",
353
+ conflictNotice: "State changed, so the last action was not executed. The view now shows the latest facts \u2014 decide again from them.",
354
+ conflictDismiss: "Got it",
335
355
  recover: "Recover now",
336
356
  reenable: "Re-enable",
337
357
  empty: "No data",
@@ -371,7 +391,9 @@ var en_default = {
371
391
  transitions: "Transitions",
372
392
  noTransitions: "No transitions recorded",
373
393
  autoDisabled: "Auto-disabled",
374
- restored: "Restored"
394
+ restored: "Restored",
395
+ moreTransitions: "{count} earlier transitions hidden",
396
+ fewerTransitions: "Show fewer transitions"
375
397
  },
376
398
  metrics: {
377
399
  crashRate: "Crash rate",
@@ -395,7 +417,9 @@ var en_default = {
395
417
  converged: "converged",
396
418
  notConverged: "not converged",
397
419
  samples: "{count} transitions",
398
- empty: "No transitions recorded yet \u2014 the matrix is not determinable"
420
+ empty: "No transitions recorded yet \u2014 the matrix is not determinable",
421
+ stationaryMore: "{count} more stages",
422
+ stationaryAll: "{count} stages have a long-run share"
399
423
  },
400
424
  dataflow: {
401
425
  title: "Data flow",
@@ -502,7 +526,7 @@ var en_default = {
502
526
  },
503
527
  graph: {
504
528
  title: "Capability production and consumption",
505
- hint: "Ctrl/\u2318+scroll to zoom \xB7 drag to pan \xB7 drag a node to rearrange \xB7 click to highlight \xB7 double-click to centre \xB7 Esc to exit",
529
+ hint: "ctrl/\u2318 + wheel zoom \xB7 drag to pan \xB7 drag a node to nudge it \xB7 click to highlight \xB7 double-click to centre \xB7 Esc to exit",
506
530
  zoomGroup: "Zoom",
507
531
  zoomIn: "Zoom in",
508
532
  zoomOut: "Zoom out",
@@ -558,7 +582,19 @@ var en_default = {
558
582
  edgeTo: "Consumes (to)",
559
583
  edgeKind: "Semantics",
560
584
  edgeTransitions: "transition",
561
- edgeRanks: "ranking"
585
+ edgeRanks: "ranking",
586
+ minimap: "Minimap",
587
+ minimapHint: "the box is what you can see right now; click or drag it to move the main view",
588
+ arrowHint: "arrow keys move between nodes",
589
+ linkRange: {
590
+ label: "Link range",
591
+ hops1: "direct",
592
+ hops2: "2 hops",
593
+ closure: "all linked"
594
+ },
595
+ filteredEmpty: "The current filters hid every node.",
596
+ filteredEmptyReset: "Show everything",
597
+ searchMore: "{count} more matches"
562
598
  },
563
599
  events: {
564
600
  title: "Event stream",
@@ -647,7 +683,7 @@ function flatten(dict, prefix = "") {
647
683
  }
648
684
 
649
685
  // src/client/GuardGraph.tsx
650
- var import_react = require("react");
686
+ var import_react2 = require("react");
651
687
 
652
688
  // src/client/viewport.ts
653
689
  var SCALE_MIN = 0.25;
@@ -674,6 +710,22 @@ function zoomAt(viewport, anchor, nextScale) {
674
710
  function zoomBy(viewport, anchor, factor) {
675
711
  return zoomAt(viewport, anchor, clampScale(viewport.scale) * finite(factor, 1));
676
712
  }
713
+ function pinchViewport(viewport, prev, next) {
714
+ const prevDx = finite(prev.b.x, 0) - finite(prev.a.x, 0);
715
+ const prevDy = finite(prev.b.y, 0) - finite(prev.a.y, 0);
716
+ const nextDx = finite(next.b.x, 0) - finite(next.a.x, 0);
717
+ const nextDy = finite(next.b.y, 0) - finite(next.a.y, 0);
718
+ const prevDist = Math.hypot(prevDx, prevDy);
719
+ const nextDist = Math.hypot(nextDx, nextDy);
720
+ if (!(prevDist > 0.01) || !Number.isFinite(nextDist)) return viewport;
721
+ const s0 = clampScale(viewport.scale);
722
+ const s1 = clampScale(s0 * nextDist / prevDist);
723
+ const prevMid = { x: (finite(prev.a.x, 0) + finite(prev.b.x, 0)) / 2, y: (finite(prev.a.y, 0) + finite(prev.b.y, 0)) / 2 };
724
+ const nextMid = { x: (finite(next.a.x, 0) + finite(next.b.x, 0)) / 2, y: (finite(next.a.y, 0) + finite(next.b.y, 0)) / 2 };
725
+ const worldX = (prevMid.x - viewport.tx) / s0;
726
+ const worldY = (prevMid.y - viewport.ty) / s0;
727
+ return { scale: s1, tx: nextMid.x - worldX * s1, ty: nextMid.y - worldY * s1 };
728
+ }
677
729
  function centerOf(size) {
678
730
  return { x: finite(size.width, 0) / 2, y: finite(size.height, 0) / 2 };
679
731
  }
@@ -832,7 +884,7 @@ function parallelCurvature(parallelIndex, unit = 18) {
832
884
  const magnitude = Math.ceil(parallelIndex / 2) * unit;
833
885
  return parallelIndex % 2 === 1 ? magnitude : -magnitude;
834
886
  }
835
- function matchNodes(nodes, query, limit = 8) {
887
+ function matchNodes(nodes, query, limit = Number.POSITIVE_INFINITY) {
836
888
  const q = query.trim().toLowerCase();
837
889
  if (q === "") return [];
838
890
  const scored = [];
@@ -848,7 +900,36 @@ function matchNodes(nodes, query, limit = 8) {
848
900
  if (rank !== null) scored.push({ node, rank });
849
901
  }
850
902
  scored.sort((a, b) => a.rank - b.rank || a.node.id.localeCompare(b.node.id));
851
- return scored.slice(0, limit).map((s) => s.node);
903
+ const cap = Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : scored.length;
904
+ return scored.slice(0, cap).map((s) => s.node);
905
+ }
906
+ function searchSummary(all, displayLimit, cursor) {
907
+ const total = all.length;
908
+ if (total === 0) {
909
+ return { all: [], visible: [], total: 0, omitted: 0, cycleIndex: 0, indexInVisible: -1 };
910
+ }
911
+ const raw = Number.isFinite(cursor) ? Math.floor(cursor) : 0;
912
+ const cycleIndex = (raw % total + total) % total;
913
+ const cap = Number.isFinite(displayLimit) ? Math.max(0, Math.floor(displayLimit)) : total;
914
+ const shown = Math.min(total, cap);
915
+ const start = Math.min(Math.max(0, cycleIndex - shown + 1), Math.max(0, total - shown));
916
+ const visible = all.slice(start, start + shown);
917
+ return {
918
+ all: [...all],
919
+ visible,
920
+ total,
921
+ omitted: Math.max(0, total - visible.length),
922
+ cycleIndex,
923
+ indexInVisible: cycleIndex - start
924
+ };
925
+ }
926
+ function isWorldPointVisible(viewport, size, world, margin = 0) {
927
+ const scale = viewport.scale;
928
+ if (!Number.isFinite(scale) || !(scale > 0)) return false;
929
+ if (!Number.isFinite(world.x) || !Number.isFinite(world.y)) return false;
930
+ const x = world.x * scale + viewport.tx;
931
+ const y = world.y * scale + viewport.ty;
932
+ return x >= margin && y >= margin && x <= finite(size.width, 0) - margin && y <= finite(size.height, 0) - margin;
852
933
  }
853
934
  function centerOn(viewport, size, world, targetScale) {
854
935
  const scale = clampScale(targetScale ?? viewport.scale);
@@ -921,8 +1002,12 @@ function buildNodeIndex(nodes) {
921
1002
  function hitNodesOf(nodes) {
922
1003
  return nodes.map((node) => ({ id: node.id, x: node.x, y: node.y, w: NODE_WIDTH, h: NODE_HEIGHT }));
923
1004
  }
1005
+ function linkRangeHops(range) {
1006
+ return range === "closure" ? null : range === "hops2" ? 2 : 1;
1007
+ }
924
1008
  function filterGraph(nodes, edges, filter) {
925
- const linked = filter.onlyConnectedWith === null ? null : traceFrom(filter.onlyConnectedWith, edges, "both");
1009
+ const hops = filter.maxHops ?? null;
1010
+ const linked = filter.onlyConnectedWith === null ? null : hops === null ? traceFrom(filter.onlyConnectedWith, edges, "both") : kHopNeighborhood(filter.onlyConnectedWith, edges, hops);
926
1011
  const keptNodes = nodes.filter(
927
1012
  (node) => !filter.hidden.has(node.kind) && (linked === null || linked.has(node.id))
928
1013
  );
@@ -930,6 +1015,35 @@ function filterGraph(nodes, edges, filter) {
930
1015
  const keptEdges = edges.filter((edge) => keptIndex.has(edge.from) && keptIndex.has(edge.to));
931
1016
  return { nodes: keptNodes, edges: keptEdges };
932
1017
  }
1018
+ function kHopNeighborhood(startId, edges, hops) {
1019
+ const visited = /* @__PURE__ */ new Set([startId]);
1020
+ const depth = Math.floor(hops);
1021
+ if (!(depth > 0)) return visited;
1022
+ const adjacency = /* @__PURE__ */ new Map();
1023
+ const push = (from, to) => {
1024
+ const list = adjacency.get(from);
1025
+ if (list) list.push(to);
1026
+ else adjacency.set(from, [to]);
1027
+ };
1028
+ for (const edge of edges) {
1029
+ push(edge.from, edge.to);
1030
+ push(edge.to, edge.from);
1031
+ }
1032
+ let frontier = [startId];
1033
+ for (let d = 0; d < depth; d += 1) {
1034
+ const next = [];
1035
+ for (const id of frontier) {
1036
+ for (const neighbor of adjacency.get(id) ?? []) {
1037
+ if (visited.has(neighbor)) continue;
1038
+ visited.add(neighbor);
1039
+ next.push(neighbor);
1040
+ }
1041
+ }
1042
+ frontier = next;
1043
+ if (frontier.length === 0) break;
1044
+ }
1045
+ return visited;
1046
+ }
933
1047
  function graphBounds(nodes) {
934
1048
  let minX = Infinity;
935
1049
  let minY = Infinity;
@@ -969,6 +1083,32 @@ function degreeOf(id, edges) {
969
1083
  }
970
1084
  return { in: incoming, out: outgoing };
971
1085
  }
1086
+ function degreeTally(edges) {
1087
+ const tally = /* @__PURE__ */ new Map();
1088
+ for (const edge of edges) {
1089
+ tally.set(edge.from, (tally.get(edge.from) ?? 0) + 1);
1090
+ tally.set(edge.to, (tally.get(edge.to) ?? 0) + 1);
1091
+ }
1092
+ return tally;
1093
+ }
1094
+ function edgeDegreeSum(tally, edge) {
1095
+ return (tally.get(edge.from) ?? 0) + (tally.get(edge.to) ?? 0);
1096
+ }
1097
+ var EDGE_DEGREE_SUM_MIN = 2;
1098
+ var EDGE_DEGREE_SUM_MAX = 20;
1099
+ function logScale(value, domainMax) {
1100
+ if (!Number.isFinite(value) || value <= 0) return 0;
1101
+ if (!Number.isFinite(domainMax) || domainMax <= 0) return 0;
1102
+ return Math.min(1, Math.log1p(value) / Math.log1p(domainMax));
1103
+ }
1104
+ var EDGE_WIDTH_MIN = 1.2;
1105
+ var EDGE_WIDTH_MAX = 3.4;
1106
+ function edgeWidthOf(tally, edge, referenceMax = EDGE_DEGREE_SUM_MAX, minPx = EDGE_WIDTH_MIN, maxPx = EDGE_WIDTH_MAX) {
1107
+ const excess = edgeDegreeSum(tally, edge) - EDGE_DEGREE_SUM_MIN;
1108
+ const domainExcess = referenceMax - EDGE_DEGREE_SUM_MIN;
1109
+ const raw = minPx + (maxPx - minPx) * logScale(excess, domainExcess);
1110
+ return Math.min(maxPx, Math.max(minPx, raw));
1111
+ }
972
1112
  function edgeDetailOf(edge, index) {
973
1113
  const from = index.get(edge.from);
974
1114
  const to = index.get(edge.to);
@@ -1081,6 +1221,32 @@ function withLayout(nodes, positions, offsets) {
1081
1221
  };
1082
1222
  });
1083
1223
  }
1224
+ function directionalCandidate(from, direction, candidates) {
1225
+ const horizontal = direction === "left" || direction === "right";
1226
+ const sign = direction === "left" || direction === "up" ? -1 : 1;
1227
+ const ahead = candidates.filter((node) => {
1228
+ const delta = horizontal ? node.x - from.x : node.y - from.y;
1229
+ return delta * sign > 0;
1230
+ });
1231
+ if (ahead.length === 0) return null;
1232
+ const crossOf = (node) => Math.abs(horizontal ? node.y - from.y : node.x - from.x);
1233
+ const alongOf = (node) => Math.abs((horizontal ? node.x - from.x : node.y - from.y) * sign);
1234
+ const bestCross = Math.min(...ahead.map(crossOf));
1235
+ const tolerance = Math.max(bestCross, horizontal ? NODE_HEIGHT : NODE_WIDTH / 2);
1236
+ const band = ahead.filter((node) => crossOf(node) <= tolerance);
1237
+ const pool = band.length > 0 ? band : ahead;
1238
+ let best = pool[0];
1239
+ if (!best) return null;
1240
+ let bestScore = alongOf(best) * 4 + crossOf(best);
1241
+ for (const node of pool) {
1242
+ const score = alongOf(node) * 4 + crossOf(node);
1243
+ if (score < bestScore) {
1244
+ best = node;
1245
+ bestScore = score;
1246
+ }
1247
+ }
1248
+ return best?.id ?? null;
1249
+ }
1084
1250
  function zoomLabel(scale) {
1085
1251
  if (!Number.isFinite(scale)) return "100%";
1086
1252
  return `${Math.round(scale * 100)}%`;
@@ -1102,10 +1268,108 @@ function shapePath(shape, size, cy) {
1102
1268
  }
1103
1269
  }
1104
1270
 
1271
+ // src/client/minimap-model.ts
1272
+ var NODE_WIDTH2 = LAYOUT.nodeWidth;
1273
+ var NODE_HEIGHT2 = LAYOUT.nodeHeight;
1274
+ var MINIMAP_PADDING = 4;
1275
+ function minimapProjection(bounds, canvas, padding = MINIMAP_PADDING) {
1276
+ const drawWidth = canvas.width - padding * 2;
1277
+ const drawHeight = canvas.height - padding * 2;
1278
+ if (!(bounds.width > 0) || !(bounds.height > 0) || !(drawWidth > 0) || !(drawHeight > 0)) {
1279
+ return {
1280
+ worldScale: 1,
1281
+ offsetX: padding,
1282
+ offsetY: padding,
1283
+ minX: 0,
1284
+ minY: 0,
1285
+ figureWidth: 0,
1286
+ figureHeight: 0
1287
+ };
1288
+ }
1289
+ const worldScale = Math.min(drawWidth / bounds.width, drawHeight / bounds.height);
1290
+ const figureWidth = bounds.width * worldScale;
1291
+ const figureHeight = bounds.height * worldScale;
1292
+ return {
1293
+ worldScale,
1294
+ // 居中:空白在两侧均分,小地图里的「图居中」才与主视口 fit 的居中同构。
1295
+ offsetX: padding + (drawWidth - figureWidth) / 2,
1296
+ offsetY: padding + (drawHeight - figureHeight) / 2,
1297
+ minX: bounds.minX,
1298
+ minY: bounds.minY,
1299
+ figureWidth,
1300
+ figureHeight
1301
+ };
1302
+ }
1303
+ function worldToMinimap(proj, point) {
1304
+ return {
1305
+ x: proj.offsetX + (point.x - proj.minX) * proj.worldScale,
1306
+ y: proj.offsetY + (point.y - proj.minY) * proj.worldScale
1307
+ };
1308
+ }
1309
+ function minimapToWorld(proj, point) {
1310
+ if (!(proj.worldScale > 0) || !Number.isFinite(proj.worldScale)) return { x: proj.minX, y: proj.minY };
1311
+ return {
1312
+ x: (point.x - proj.offsetX) / proj.worldScale + proj.minX,
1313
+ y: (point.y - proj.offsetY) / proj.worldScale + proj.minY
1314
+ };
1315
+ }
1316
+ function minimapNodeRects(nodes, proj, color) {
1317
+ return nodes.map((node) => {
1318
+ const at = worldToMinimap(proj, { x: node.x, y: node.y });
1319
+ return {
1320
+ id: node.id,
1321
+ x: at.x,
1322
+ y: at.y,
1323
+ w: Math.max(1.5, NODE_WIDTH2 * proj.worldScale),
1324
+ h: Math.max(1, NODE_HEIGHT2 * proj.worldScale),
1325
+ fill: color(node)
1326
+ };
1327
+ });
1328
+ }
1329
+ function minimapViewportRect(proj, viewport, size) {
1330
+ const scale = viewport.scale;
1331
+ if (!(proj.figureWidth > 0) || !(proj.figureHeight > 0)) {
1332
+ return { x: 0, y: 0, w: 0, h: 0, zoomedOut: true };
1333
+ }
1334
+ const figureLeft = proj.offsetX;
1335
+ const figureTop = proj.offsetY;
1336
+ if (!(scale > 0) || !Number.isFinite(scale)) {
1337
+ return { x: figureLeft, y: figureTop, w: proj.figureWidth, h: proj.figureHeight, zoomedOut: true };
1338
+ }
1339
+ const toWorld = (point) => ({
1340
+ x: (point.x - viewport.tx) / scale,
1341
+ y: (point.y - viewport.ty) / scale
1342
+ });
1343
+ const a = worldToMinimap(proj, toWorld({ x: 0, y: 0 }));
1344
+ const b = worldToMinimap(proj, toWorld({ x: size.width, y: size.height }));
1345
+ const left = Math.max(Math.min(a.x, b.x), figureLeft);
1346
+ const top = Math.max(Math.min(a.y, b.y), figureTop);
1347
+ const right = Math.min(Math.max(a.x, b.x), figureLeft + proj.figureWidth);
1348
+ const bottom = Math.min(Math.max(a.y, b.y), figureTop + proj.figureHeight);
1349
+ const epsilon = 0.5;
1350
+ const w = Math.max(0, right - left);
1351
+ const h = Math.max(0, bottom - top);
1352
+ if (w + epsilon >= proj.figureWidth && h + epsilon >= proj.figureHeight) {
1353
+ return { x: figureLeft, y: figureTop, w: proj.figureWidth, h: proj.figureHeight, zoomedOut: true };
1354
+ }
1355
+ if (w <= 0 || h <= 0) {
1356
+ return {
1357
+ x: Math.min(Math.max(Math.min(a.x, b.x), figureLeft), figureLeft + proj.figureWidth),
1358
+ y: Math.min(Math.max(Math.min(a.y, b.y), figureTop), figureTop + proj.figureHeight),
1359
+ w: 0,
1360
+ h: 0,
1361
+ zoomedOut: false
1362
+ };
1363
+ }
1364
+ return { x: left, y: top, w, h, zoomedOut: false };
1365
+ }
1366
+
1105
1367
  // src/client/GraphParts.tsx
1368
+ var import_react = require("react");
1106
1369
  var import_jsx_runtime = require("react/jsx-runtime");
1107
1370
  var LAYOUT_MODES = ["layered", "radial"];
1108
1371
  var COLOR_MODES = ["tone", "kind", "stage"];
1372
+ var LINK_RANGES = ["hops1", "hops2", "closure"];
1109
1373
  function GraphToolbar(props) {
1110
1374
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rg-graph-toolbar", role: "toolbar", "aria-label": t("graph.title"), children: [
1111
1375
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rg-graph-zoom", role: "group", "aria-label": t("graph.zoomGroup"), children: [
@@ -1123,7 +1387,7 @@ function GraphToolbar(props) {
1123
1387
  placeholder: t("graph.search"),
1124
1388
  onChange: (event) => props.onQuery(event.target.value),
1125
1389
  onKeyDown: (event) => {
1126
- if (event.key === "Enter" && props.matches.length > 0) {
1390
+ if (event.key === "Enter" && props.matchTotal > 0) {
1127
1391
  event.preventDefault?.();
1128
1392
  props.onMatchNext();
1129
1393
  }
@@ -1134,19 +1398,22 @@ function GraphToolbar(props) {
1134
1398
  "aria-keyshortcuts": "Enter"
1135
1399
  }
1136
1400
  ),
1137
- props.query.trim() !== "" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "rg-search-results", role: "listbox", "aria-label": t("graph.searchResults"), children: props.matches.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "rg-search-noresult", children: t("graph.noResults") }) : props.matches.map((node, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1138
- "button",
1139
- {
1140
- type: "button",
1141
- onClick: () => props.onLocate(node.id),
1142
- "aria-current": index === props.matchIndex,
1143
- children: [
1144
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `rg-dot rg-dot-${node.tone}`, "aria-hidden": true }),
1145
- node.label
1146
- ]
1147
- }
1148
- ) }, node.id)) }),
1149
- props.query.trim() !== "" && props.matches.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rg-search-index", role: "status", children: t("graph.matchIndex", { index: props.matchIndex + 1, total: props.matches.length }) })
1401
+ props.query.trim() !== "" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "rg-search-results", role: "listbox", "aria-label": t("graph.searchResults"), children: props.matchTotal === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "rg-search-noresult", children: t("graph.noResults") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1402
+ props.matches.map((node) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1403
+ "button",
1404
+ {
1405
+ type: "button",
1406
+ onClick: () => props.onLocate(node.id),
1407
+ "aria-current": node.id === props.currentMatchId,
1408
+ children: [
1409
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: `rg-dot rg-dot-${node.tone}`, "aria-hidden": true }),
1410
+ node.label
1411
+ ]
1412
+ }
1413
+ ) }, node.id)),
1414
+ props.matchOmitted > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { className: "rg-search-omitted", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "rg-link", onClick: props.onToggleResults, children: t("graph.searchMore", { count: props.matchOmitted }) }) })
1415
+ ] }) }),
1416
+ props.query.trim() !== "" && props.matchTotal > 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rg-search-index", role: "status", children: t("graph.matchIndex", { index: props.matchOrdinal, total: props.matchTotal }) })
1150
1417
  ] }),
1151
1418
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1152
1419
  Segmented,
@@ -1166,6 +1433,15 @@ function GraphToolbar(props) {
1166
1433
  onSelect: (value) => props.onColorMode(value)
1167
1434
  }
1168
1435
  ),
1436
+ props.onlyConnected && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1437
+ Segmented,
1438
+ {
1439
+ label: t("graph.linkRange.label"),
1440
+ options: LINK_RANGES.map((range) => ({ value: range, label: t(`graph.linkRange.${range}`) })),
1441
+ active: props.linkRange,
1442
+ onSelect: (value) => props.onLinkRange(value)
1443
+ }
1444
+ ),
1169
1445
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1170
1446
  "button",
1171
1447
  {
@@ -1178,6 +1454,17 @@ function GraphToolbar(props) {
1178
1454
  children: t("graph.onlyConnected")
1179
1455
  }
1180
1456
  ),
1457
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1458
+ "button",
1459
+ {
1460
+ type: "button",
1461
+ className: `rg-button rg-button-small${props.minimapVisible ? " rg-button-active" : ""}`,
1462
+ onClick: props.onToggleMinimap,
1463
+ "aria-pressed": props.minimapVisible,
1464
+ title: t("graph.minimapHint"),
1465
+ children: t("graph.minimap")
1466
+ }
1467
+ ),
1181
1468
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1182
1469
  "button",
1183
1470
  {
@@ -1304,6 +1591,106 @@ function edgeKindKey(kind) {
1304
1591
  return "graph.edgeRanks";
1305
1592
  }
1306
1593
  }
1594
+ function GraphMinimap({ width, height, rects, view, focusRect, onNavigate }) {
1595
+ const svgRef = (0, import_react.useRef)(null);
1596
+ const draggingRef = (0, import_react.useRef)(false);
1597
+ const localPoint = (clientX, clientY) => {
1598
+ const box = svgRef.current?.getBoundingClientRect();
1599
+ if (!box || box.width === 0 || box.height === 0) return { x: 0, y: 0 };
1600
+ return { x: (clientX - box.left) / box.width * width, y: (clientY - box.top) / box.height * height };
1601
+ };
1602
+ const capturePointer = (event) => {
1603
+ try {
1604
+ event.currentTarget.setPointerCapture(event.pointerId);
1605
+ } catch {
1606
+ }
1607
+ };
1608
+ const releasePointer = (event) => {
1609
+ try {
1610
+ event.currentTarget.releasePointerCapture(event.pointerId);
1611
+ } catch {
1612
+ }
1613
+ };
1614
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
1615
+ "svg",
1616
+ {
1617
+ ref: svgRef,
1618
+ className: "rg-minimap",
1619
+ viewBox: `0 0 ${width} ${height}`,
1620
+ width,
1621
+ height,
1622
+ role: "img",
1623
+ "aria-label": t("graph.minimap"),
1624
+ onPointerDown: (event) => {
1625
+ event.stopPropagation();
1626
+ draggingRef.current = true;
1627
+ capturePointer(event);
1628
+ onNavigate(localPoint(event.clientX, event.clientY));
1629
+ },
1630
+ onPointerMove: (event) => {
1631
+ event.stopPropagation();
1632
+ if (!draggingRef.current) return;
1633
+ onNavigate(localPoint(event.clientX, event.clientY));
1634
+ },
1635
+ onPointerUp: (event) => {
1636
+ event.stopPropagation();
1637
+ draggingRef.current = false;
1638
+ releasePointer(event);
1639
+ },
1640
+ onPointerCancel: (event) => {
1641
+ event.stopPropagation();
1642
+ draggingRef.current = false;
1643
+ },
1644
+ onClick: (event) => {
1645
+ event.stopPropagation();
1646
+ },
1647
+ onDoubleClick: (event) => event.stopPropagation(),
1648
+ children: [
1649
+ rects.map((rect) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1650
+ "rect",
1651
+ {
1652
+ x: rect.x,
1653
+ y: rect.y,
1654
+ width: rect.w,
1655
+ height: rect.h,
1656
+ rx: 1,
1657
+ fill: rect.fill,
1658
+ fillOpacity: 0.75
1659
+ },
1660
+ rect.id
1661
+ )),
1662
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1663
+ "rect",
1664
+ {
1665
+ className: `rg-minimap-view${view.zoomedOut ? " rg-minimap-view-all" : ""}`,
1666
+ x: view.x,
1667
+ y: view.y,
1668
+ width: Math.max(4, view.w),
1669
+ height: Math.max(4, view.h),
1670
+ rx: 2,
1671
+ fill: "none",
1672
+ stroke: "var(--dsw-alias-brand-primary)",
1673
+ strokeWidth: 1.5
1674
+ }
1675
+ ),
1676
+ focusRect !== null && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1677
+ "rect",
1678
+ {
1679
+ className: "rg-minimap-focus",
1680
+ x: focusRect.x,
1681
+ y: focusRect.y,
1682
+ width: Math.max(3, focusRect.w),
1683
+ height: Math.max(2, focusRect.h),
1684
+ rx: 1,
1685
+ fill: "none",
1686
+ stroke: "var(--dsw-alias-state-warn-primary)",
1687
+ strokeWidth: 1.5
1688
+ }
1689
+ )
1690
+ ]
1691
+ }
1692
+ );
1693
+ }
1307
1694
  function GraphTooltip({ node, degree, x, y, containerWidth }) {
1308
1695
  const halfWidth = 130;
1309
1696
  const left = Math.min(Math.max(x, halfWidth), Math.max(halfWidth, containerWidth - halfWidth));
@@ -1323,60 +1710,69 @@ function GraphTooltip({ node, degree, x, y, containerWidth }) {
1323
1710
 
1324
1711
  // src/client/GuardGraph.tsx
1325
1712
  var import_jsx_runtime2 = require("react/jsx-runtime");
1713
+ var MINIMAP_CANVAS = { width: 152, height: 96 };
1714
+ var MINIMAP_CANVAS_NARROW = { width: 112, height: 72 };
1715
+ var SEARCH_RESULTS_INITIAL = 8;
1326
1716
  function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChange, locateRequest = null }) {
1327
- const [viewport, setViewport] = (0, import_react.useState)(IDENTITY);
1328
- const [hoverId, setHoverId] = (0, import_react.useState)(null);
1329
- const [hoverEdgeId, setHoverEdgeId] = (0, import_react.useState)(null);
1330
- const [selectedEdgeId, setSelectedEdgeId] = (0, import_react.useState)(null);
1331
- const [hidden, setHidden] = (0, import_react.useState)(/* @__PURE__ */ new Set());
1332
- const [size, setSize] = (0, import_react.useState)({ width: 0, height });
1333
- const [query, setQuery] = (0, import_react.useState)("");
1334
- const [matchIndex, setMatchIndex] = (0, import_react.useState)(0);
1335
- const [layoutMode, setLayoutMode] = (0, import_react.useState)("layered");
1336
- const [colorMode, setColorMode] = (0, import_react.useState)("tone");
1337
- const [onlyConnected, setOnlyConnected] = (0, import_react.useState)(false);
1338
- const [layoutEpoch, setLayoutEpoch] = (0, import_react.useState)(0);
1339
- const [offsets, setOffsets] = (0, import_react.useState)({});
1340
- const wrapRef = (0, import_react.useRef)(null);
1341
- const dragRef = (0, import_react.useRef)({
1717
+ const [viewport, setViewport] = (0, import_react2.useState)(IDENTITY);
1718
+ const [hoverId, setHoverId] = (0, import_react2.useState)(null);
1719
+ const [hoverEdgeId, setHoverEdgeId] = (0, import_react2.useState)(null);
1720
+ const [selectedEdgeId, setSelectedEdgeId] = (0, import_react2.useState)(null);
1721
+ const [hidden, setHidden] = (0, import_react2.useState)(/* @__PURE__ */ new Set());
1722
+ const [size, setSize] = (0, import_react2.useState)({ width: 0, height });
1723
+ const [query, setQuery] = (0, import_react2.useState)("");
1724
+ const [matchIndex, setMatchIndex] = (0, import_react2.useState)(0);
1725
+ const [showAllResults, setShowAllResults] = (0, import_react2.useState)(false);
1726
+ const [layoutMode, setLayoutMode] = (0, import_react2.useState)("layered");
1727
+ const [colorMode, setColorMode] = (0, import_react2.useState)("tone");
1728
+ const [onlyConnected, setOnlyConnected] = (0, import_react2.useState)(false);
1729
+ const [linkRange, setLinkRange] = (0, import_react2.useState)("hops1");
1730
+ const [minimapVisible, setMinimapVisible] = (0, import_react2.useState)(true);
1731
+ const [layoutEpoch, setLayoutEpoch] = (0, import_react2.useState)(0);
1732
+ const pointersRef = (0, import_react2.useRef)(/* @__PURE__ */ new Map());
1733
+ const pinchPrevRef = (0, import_react2.useRef)(null);
1734
+ const [offsets, setOffsets] = (0, import_react2.useState)({});
1735
+ const wrapRef = (0, import_react2.useRef)(null);
1736
+ const dragRef = (0, import_react2.useRef)({
1342
1737
  active: false,
1343
1738
  moved: false,
1344
1739
  x: 0,
1345
1740
  y: 0
1346
1741
  });
1347
- const nodeDragRef = (0, import_react.useRef)(null);
1348
- const suppressClickRef = (0, import_react.useRef)(false);
1349
- const fittedRef = (0, import_react.useRef)(false);
1350
- const lastLocateNonceRef = (0, import_react.useRef)(0);
1351
- const counts = (0, import_react.useMemo)(() => kindCounts(graph.nodes), [graph.nodes]);
1352
- const positions = (0, import_react.useMemo)(() => layoutPositionsOf(graph.nodes, layoutMode), [graph.nodes, layoutMode]);
1353
- const positionedNodes = (0, import_react.useMemo)(() => withLayout(graph.nodes, positions, offsets), [graph.nodes, positions, offsets]);
1354
- const view = (0, import_react.useMemo)(
1742
+ const nodeDragRef = (0, import_react2.useRef)(null);
1743
+ const suppressClickRef = (0, import_react2.useRef)(false);
1744
+ const fittedRef = (0, import_react2.useRef)(false);
1745
+ const lastLocateNonceRef = (0, import_react2.useRef)(0);
1746
+ const counts = (0, import_react2.useMemo)(() => kindCounts(graph.nodes), [graph.nodes]);
1747
+ const positions = (0, import_react2.useMemo)(() => layoutPositionsOf(graph.nodes, layoutMode), [graph.nodes, layoutMode]);
1748
+ const positionedNodes = (0, import_react2.useMemo)(() => withLayout(graph.nodes, positions, offsets), [graph.nodes, positions, offsets]);
1749
+ const view = (0, import_react2.useMemo)(
1355
1750
  () => filterGraph(positionedNodes, graph.edges, {
1356
1751
  hidden,
1357
- onlyConnectedWith: onlyConnected ? focusId : null
1752
+ onlyConnectedWith: onlyConnected ? focusId : null,
1753
+ maxHops: linkRangeHops(linkRange)
1358
1754
  }),
1359
- [positionedNodes, graph.edges, hidden, onlyConnected, focusId]
1755
+ [positionedNodes, graph.edges, hidden, onlyConnected, focusId, linkRange]
1360
1756
  );
1361
1757
  const visibleNodes = view.nodes;
1362
1758
  const visibleEdges = view.edges;
1363
- const nodeById = (0, import_react.useMemo)(() => buildNodeIndex(visibleNodes), [visibleNodes]);
1364
- const positionedById = (0, import_react.useMemo)(() => buildNodeIndex(positionedNodes), [positionedNodes]);
1365
- const grid = (0, import_react.useMemo)(() => new SpatialGrid(hitNodesOf(visibleNodes)), [visibleNodes]);
1366
- const bounds = (0, import_react.useMemo)(() => graphBounds(visibleNodes), [visibleNodes]);
1367
- const curvatures = (0, import_react.useMemo)(() => edgeCurvatures(visibleEdges), [visibleEdges]);
1368
- const stageOfColumn = (0, import_react.useMemo)(() => {
1759
+ const nodeById = (0, import_react2.useMemo)(() => buildNodeIndex(visibleNodes), [visibleNodes]);
1760
+ const positionedById = (0, import_react2.useMemo)(() => buildNodeIndex(positionedNodes), [positionedNodes]);
1761
+ const grid = (0, import_react2.useMemo)(() => new SpatialGrid(hitNodesOf(visibleNodes)), [visibleNodes]);
1762
+ const bounds = (0, import_react2.useMemo)(() => graphBounds(visibleNodes), [visibleNodes]);
1763
+ const curvatures = (0, import_react2.useMemo)(() => edgeCurvatures(visibleEdges), [visibleEdges]);
1764
+ const stageOfColumn = (0, import_react2.useMemo)(() => {
1369
1765
  const map = /* @__PURE__ */ new Map();
1370
1766
  for (const column of graph.columns) map.set(column.index, column.stage ?? "");
1371
1767
  return map;
1372
1768
  }, [graph.columns]);
1373
- const apply2 = (0, import_react.useCallback)(
1769
+ const apply2 = (0, import_react2.useCallback)(
1374
1770
  (next) => {
1375
1771
  setViewport(clampPan(next, size, bounds));
1376
1772
  },
1377
1773
  [size, bounds]
1378
1774
  );
1379
- (0, import_react.useEffect)(() => {
1775
+ (0, import_react2.useEffect)(() => {
1380
1776
  const measure = () => {
1381
1777
  const rect = wrapRef.current?.getBoundingClientRect();
1382
1778
  if (!rect || rect.width === 0) return;
@@ -1387,30 +1783,30 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1387
1783
  if (observer && wrapRef.current) observer.observe(wrapRef.current);
1388
1784
  return () => observer?.disconnect();
1389
1785
  }, [height]);
1390
- (0, import_react.useEffect)(() => {
1786
+ (0, import_react2.useEffect)(() => {
1391
1787
  if (fittedRef.current) return;
1392
1788
  if (size.width === 0) return;
1393
1789
  fittedRef.current = true;
1394
1790
  setViewport(clampPan(fitToView(bounds, size), size, bounds));
1395
1791
  }, [size]);
1396
- (0, import_react.useEffect)(() => {
1792
+ (0, import_react2.useEffect)(() => {
1397
1793
  if (!fittedRef.current) return;
1398
1794
  setViewport((current) => clampPan(current, size, bounds));
1399
1795
  }, [size, bounds]);
1400
- (0, import_react.useEffect)(() => {
1796
+ (0, import_react2.useEffect)(() => {
1401
1797
  if (layoutEpoch === 0 || !fittedRef.current) return;
1402
1798
  setViewport(clampPan(fitToView(bounds, size), size, bounds));
1403
1799
  }, [layoutEpoch]);
1404
- const doFit = (0, import_react.useCallback)(() => {
1800
+ const doFit = (0, import_react2.useCallback)(() => {
1405
1801
  setViewport(clampPan(fitToView(bounds, size), size, bounds));
1406
1802
  }, [bounds, size]);
1407
- const doZoom = (0, import_react.useCallback)(
1803
+ const doZoom = (0, import_react2.useCallback)(
1408
1804
  (factor) => {
1409
1805
  apply2(zoomBy(viewport, centerOf(size), factor));
1410
1806
  },
1411
1807
  [apply2, viewport, size]
1412
1808
  );
1413
- const onWheel = (0, import_react.useCallback)(
1809
+ const onWheel = (0, import_react2.useCallback)(
1414
1810
  (event) => {
1415
1811
  event.preventDefault?.();
1416
1812
  const rect = wrapRef.current?.getBoundingClientRect();
@@ -1419,9 +1815,9 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1419
1815
  },
1420
1816
  [apply2, viewport]
1421
1817
  );
1422
- const wheelHandlerRef = (0, import_react.useRef)(onWheel);
1818
+ const wheelHandlerRef = (0, import_react2.useRef)(onWheel);
1423
1819
  wheelHandlerRef.current = onWheel;
1424
- (0, import_react.useEffect)(() => {
1820
+ (0, import_react2.useEffect)(() => {
1425
1821
  const host = wrapRef.current;
1426
1822
  if (host === null) return void 0;
1427
1823
  const listener = (event) => {
@@ -1432,12 +1828,30 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1432
1828
  host.addEventListener("wheel", listener, { passive: false });
1433
1829
  return () => host.removeEventListener("wheel", listener);
1434
1830
  }, []);
1435
- const onPointerDown = (0, import_react.useCallback)((event) => {
1831
+ const onPointerDown = (0, import_react2.useCallback)((event) => {
1832
+ const id = event.pointerId ?? 0;
1833
+ pointersRef.current.set(id, { x: event.clientX, y: event.clientY });
1834
+ if (pointersRef.current.size >= 2) {
1835
+ const [a, b] = [...pointersRef.current.values()];
1836
+ pinchPrevRef.current = { a: a ?? { x: 0, y: 0 }, b: b ?? { x: 0, y: 0 } };
1837
+ dragRef.current = { active: false, moved: false, x: 0, y: 0 };
1838
+ return;
1839
+ }
1436
1840
  suppressClickRef.current = false;
1437
1841
  dragRef.current = { active: true, moved: false, x: event.clientX, y: event.clientY };
1438
1842
  }, []);
1439
- const onPointerMove = (0, import_react.useCallback)(
1843
+ const onPointerMove = (0, import_react2.useCallback)(
1440
1844
  (event) => {
1845
+ const id = event.pointerId ?? 0;
1846
+ if (pointersRef.current.has(id)) pointersRef.current.set(id, { x: event.clientX, y: event.clientY });
1847
+ if (pointersRef.current.size >= 2 && pinchPrevRef.current !== null) {
1848
+ const [a, b] = [...pointersRef.current.values()];
1849
+ const next = { a: a ?? { x: 0, y: 0 }, b: b ?? { x: 0, y: 0 } };
1850
+ const prev = pinchPrevRef.current;
1851
+ setViewport((current) => clampPan(pinchViewport(current, prev, next), size, bounds));
1852
+ pinchPrevRef.current = next;
1853
+ return;
1854
+ }
1441
1855
  const nodeDrag = nodeDragRef.current;
1442
1856
  if (nodeDrag !== null) {
1443
1857
  const dx2 = event.clientX - nodeDrag.x;
@@ -1465,12 +1879,14 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1465
1879
  },
1466
1880
  [viewport.scale, size, bounds]
1467
1881
  );
1468
- const onPointerUp = (0, import_react.useCallback)(() => {
1882
+ const onPointerUp = (0, import_react2.useCallback)((event) => {
1883
+ pointersRef.current.delete(event?.pointerId ?? 0);
1884
+ if (pointersRef.current.size < 2) pinchPrevRef.current = null;
1469
1885
  if (nodeDragRef.current !== null && nodeDragRef.current.moved) suppressClickRef.current = true;
1470
1886
  nodeDragRef.current = null;
1471
1887
  dragRef.current = { active: false, moved: false, x: 0, y: 0 };
1472
1888
  }, []);
1473
- const onNodePointerDown = (0, import_react.useCallback)(
1889
+ const onNodePointerDown = (0, import_react2.useCallback)(
1474
1890
  (event, nodeId) => {
1475
1891
  event.stopPropagation();
1476
1892
  suppressClickRef.current = false;
@@ -1478,7 +1894,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1478
1894
  },
1479
1895
  []
1480
1896
  );
1481
- const onClick = (0, import_react.useCallback)(
1897
+ const onClick = (0, import_react2.useCallback)(
1482
1898
  (event) => {
1483
1899
  if (dragRef.current.moved || suppressClickRef.current) return;
1484
1900
  const rect = wrapRef.current?.getBoundingClientRect();
@@ -1492,18 +1908,18 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1492
1908
  },
1493
1909
  [grid, viewport, onFocusChange]
1494
1910
  );
1495
- const centreOfNode = (0, import_react.useCallback)(
1911
+ const centreOfNode = (0, import_react2.useCallback)(
1496
1912
  (node) => ({ x: node.x + NODE_WIDTH / 2, y: node.y + NODE_HEIGHT / 2 }),
1497
1913
  []
1498
1914
  );
1499
- const onNodeDoubleClick = (0, import_react.useCallback)(
1915
+ const onNodeDoubleClick = (0, import_react2.useCallback)(
1500
1916
  (node) => {
1501
1917
  apply2(centerOn(viewport, size, centreOfNode(node)));
1502
1918
  onFocusChange(node.id);
1503
1919
  },
1504
1920
  [apply2, viewport, size, centreOfNode, onFocusChange]
1505
1921
  );
1506
- const locateNode = (0, import_react.useCallback)(
1922
+ const locateNode = (0, import_react2.useCallback)(
1507
1923
  (nodeId) => {
1508
1924
  const node = positionedById.get(nodeId);
1509
1925
  if (!node) return;
@@ -1514,10 +1930,11 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1514
1930
  },
1515
1931
  [apply2, viewport, size, positionedById, centreOfNode, onFocusChange]
1516
1932
  );
1517
- (0, import_react.useEffect)(() => {
1933
+ (0, import_react2.useEffect)(() => {
1518
1934
  setMatchIndex(0);
1935
+ setShowAllResults(false);
1519
1936
  }, [query]);
1520
- (0, import_react.useEffect)(() => {
1937
+ (0, import_react2.useEffect)(() => {
1521
1938
  if (locateRequest === null) return;
1522
1939
  if (locateRequest.nonce === lastLocateNonceRef.current) return;
1523
1940
  lastLocateNonceRef.current = locateRequest.nonce;
@@ -1525,7 +1942,75 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1525
1942
  if (!node) return;
1526
1943
  setViewport(clampPan(centerOn(viewport, size, centreOfNode(node)), size, bounds));
1527
1944
  }, [locateRequest]);
1528
- const onKeyDown = (0, import_react.useCallback)(
1945
+ const highlighted = (0, import_react2.useMemo)(() => {
1946
+ if (focusId === null) return /* @__PURE__ */ new Set();
1947
+ const hops = linkRangeHops(linkRange);
1948
+ return hops === null ? traceFrom(focusId, visibleEdges, "both") : kHopNeighborhood(focusId, visibleEdges, hops);
1949
+ }, [focusId, visibleEdges, linkRange]);
1950
+ const edgeDegrees = (0, import_react2.useMemo)(() => degreeTally(visibleEdges), [visibleEdges]);
1951
+ const minimapCanvas = height <= VIEWPORT_HEIGHT_NARROW ? MINIMAP_CANVAS_NARROW : MINIMAP_CANVAS;
1952
+ const minimapProj = (0, import_react2.useMemo)(() => minimapProjection(bounds, minimapCanvas), [bounds]);
1953
+ const minimapRects = (0, import_react2.useMemo)(
1954
+ () => minimapNodeRects(visibleNodes, minimapProj, (node) => colorOf(node, colorMode, (column) => stageOfColumn.get(column))),
1955
+ [visibleNodes, minimapProj, colorMode, stageOfColumn]
1956
+ );
1957
+ const minimapView = (0, import_react2.useMemo)(
1958
+ () => minimapViewportRect(minimapProj, viewport, size),
1959
+ [minimapProj, viewport, size]
1960
+ );
1961
+ const minimapFocusRect = (0, import_react2.useMemo)(() => {
1962
+ if (focusId === null) return null;
1963
+ const rect = minimapRects.find((candidate) => candidate.id === focusId);
1964
+ return rect === void 0 ? null : { x: rect.x, y: rect.y, w: rect.w, h: rect.h };
1965
+ }, [minimapRects, focusId]);
1966
+ const navigateFromMinimap = (0, import_react2.useCallback)(
1967
+ (point) => {
1968
+ const world = minimapToWorld(minimapProj, point);
1969
+ apply2(centerOn(viewport, size, world));
1970
+ },
1971
+ [apply2, minimapProj, viewport, size]
1972
+ );
1973
+ const moveFocusByArrow = (0, import_react2.useCallback)(
1974
+ (direction) => {
1975
+ const nodes = visibleNodes.map((node2) => ({ id: node2.id, x: node2.x + NODE_WIDTH / 2, y: node2.y + NODE_HEIGHT / 2 }));
1976
+ if (nodes.length === 0) return;
1977
+ const current = focusId === null ? void 0 : positionedById.get(focusId);
1978
+ const centreWorld = {
1979
+ x: (size.width / 2 - viewport.tx) / viewport.scale,
1980
+ y: (size.height / 2 - viewport.ty) / viewport.scale
1981
+ };
1982
+ const from = current ? { x: current.x + NODE_WIDTH / 2, y: current.y + NODE_HEIGHT / 2 } : centreWorld;
1983
+ const targetId = directionalCandidate(from, direction, nodes);
1984
+ if (targetId === null) return;
1985
+ onFocusChange(targetId);
1986
+ const host = wrapRef.current;
1987
+ let element = null;
1988
+ if (host) {
1989
+ for (const candidate of host.querySelectorAll("[data-node-id]")) {
1990
+ if (candidate.getAttribute("data-node-id") === targetId) {
1991
+ element = candidate;
1992
+ break;
1993
+ }
1994
+ }
1995
+ }
1996
+ const focusable = element;
1997
+ focusable?.focus?.();
1998
+ const node = positionedById.get(targetId);
1999
+ if (node) {
2000
+ const centre = { x: node.x + NODE_WIDTH / 2, y: node.y + NODE_HEIGHT / 2 };
2001
+ const margin = NODE_WIDTH * viewport.scale / 2;
2002
+ if (!isWorldPointVisible(viewport, size, centre, margin)) apply2(centerOn(viewport, size, centre));
2003
+ }
2004
+ },
2005
+ [focusId, positionedById, visibleNodes, onFocusChange, apply2, viewport, size]
2006
+ );
2007
+ const allMatches = (0, import_react2.useMemo)(() => matchNodes(visibleNodes, query), [visibleNodes, query]);
2008
+ const search = (0, import_react2.useMemo)(
2009
+ () => searchSummary(allMatches, showAllResults ? Number.POSITIVE_INFINITY : SEARCH_RESULTS_INITIAL, matchIndex),
2010
+ [allMatches, showAllResults, matchIndex]
2011
+ );
2012
+ const matches = search.visible;
2013
+ const onKeyDown = (0, import_react2.useCallback)(
1529
2014
  (event) => {
1530
2015
  if (event.key === "Escape") {
1531
2016
  event.preventDefault?.();
@@ -1549,39 +2034,40 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1549
2034
  if (event.key === "0") {
1550
2035
  event.preventDefault?.();
1551
2036
  doFit();
2037
+ return;
2038
+ }
2039
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "ArrowUp" || event.key === "ArrowDown") {
2040
+ event.preventDefault?.();
2041
+ moveFocusByArrow(event.key.slice(6).toLowerCase());
1552
2042
  }
1553
2043
  },
1554
- [doZoom, doFit, onFocusChange]
2044
+ [doZoom, doFit, onFocusChange, moveFocusByArrow]
1555
2045
  );
1556
- const highlighted = (0, import_react.useMemo)(() => {
1557
- if (focusId === null) return /* @__PURE__ */ new Set();
1558
- return traceFrom(focusId, visibleEdges, "both");
1559
- }, [focusId, visibleEdges]);
1560
- const matches = (0, import_react.useMemo)(() => matchNodes(visibleNodes, query), [visibleNodes, query]);
1561
- const locateMatchNext = (0, import_react.useCallback)(() => {
1562
- if (matches.length === 0) return;
1563
- const next = (matchIndex + 1) % matches.length;
2046
+ const locateMatchNext = (0, import_react2.useCallback)(() => {
2047
+ const all = search.all;
2048
+ if (all.length === 0) return;
2049
+ const next = (search.cycleIndex + 1) % all.length;
1564
2050
  setMatchIndex(next);
1565
- const node = matches[next];
2051
+ const node = all[next];
1566
2052
  if (!node) return;
1567
2053
  apply2(centerOn(viewport, size, centreOfNode(node)));
1568
2054
  onFocusChange(node.id);
1569
- }, [matches, matchIndex, apply2, viewport, size, centreOfNode, onFocusChange]);
1570
- const matchIds = (0, import_react.useMemo)(() => new Set(matches.map((node) => node.id)), [matches]);
2055
+ }, [search, apply2, viewport, size, centreOfNode, onFocusChange]);
2056
+ const matchIds = (0, import_react2.useMemo)(() => new Set(search.all.map((node) => node.id)), [search.all]);
1571
2057
  const focusNode = focusId === null ? void 0 : nodeById.get(focusId);
1572
- const focusDegree = (0, import_react.useMemo)(() => focusId === null ? { in: 0, out: 0 } : degreeOf(focusId, visibleEdges), [focusId, visibleEdges]);
1573
- const focusNeighbors = (0, import_react.useMemo)(
2058
+ const focusDegree = (0, import_react2.useMemo)(() => focusId === null ? { in: 0, out: 0 } : degreeOf(focusId, visibleEdges), [focusId, visibleEdges]);
2059
+ const focusNeighbors = (0, import_react2.useMemo)(
1574
2060
  () => focusId === null ? { upstream: [], downstream: [] } : neighborsOf(focusId, visibleEdges, nodeById),
1575
2061
  [focusId, visibleEdges, nodeById]
1576
2062
  );
1577
- const labelOf = (0, import_react.useCallback)(
2063
+ const labelOf = (0, import_react2.useCallback)(
1578
2064
  (id) => {
1579
2065
  const node = nodeById.get(id);
1580
2066
  return node ? { label: node.label, tone: node.tone, detail: node.detail } : { label: id, tone: "neutral" };
1581
2067
  },
1582
2068
  [nodeById]
1583
2069
  );
1584
- const selectedEdgeDetail = (0, import_react.useMemo)(() => {
2070
+ const selectedEdgeDetail = (0, import_react2.useMemo)(() => {
1585
2071
  if (selectedEdgeId === null) return null;
1586
2072
  const edge = visibleEdges.find((e) => e.id === selectedEdgeId);
1587
2073
  if (!edge) return null;
@@ -1623,8 +2109,12 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1623
2109
  query,
1624
2110
  onQuery: setQuery,
1625
2111
  matches,
2112
+ matchTotal: search.total,
2113
+ matchOmitted: search.omitted,
2114
+ matchOrdinal: search.cycleIndex + 1,
2115
+ currentMatchId: search.all[search.cycleIndex]?.id ?? null,
2116
+ onToggleResults: () => setShowAllResults((current) => !current),
1626
2117
  onLocate: locateNode,
1627
- matchIndex,
1628
2118
  onMatchNext: locateMatchNext,
1629
2119
  counts,
1630
2120
  hidden,
@@ -1637,7 +2127,11 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1637
2127
  }),
1638
2128
  onlyConnected,
1639
2129
  onToggleConnected: () => setOnlyConnected((current) => !current),
1640
- connectedAvailable: focusId !== null
2130
+ connectedAvailable: focusId !== null,
2131
+ linkRange,
2132
+ onLinkRange: setLinkRange,
2133
+ minimapVisible,
2134
+ onToggleMinimap: () => setMinimapVisible((current) => !current)
1641
2135
  }
1642
2136
  ),
1643
2137
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "rg-graph-body", children: [
@@ -1657,6 +2151,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1657
2151
  tabIndex: 0,
1658
2152
  role: "application",
1659
2153
  "aria-label": t("graph.title"),
2154
+ "aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight + - 0 Escape Enter",
1660
2155
  children: [
1661
2156
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "100%", height: "100%", role: "presentation", children: [
1662
2157
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("defs", { children: [
@@ -1678,6 +2173,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1678
2173
  const hoveredEdge = hoverEdgeId === edge.id;
1679
2174
  const selectedEdge = selectedEdgeId === edge.id;
1680
2175
  const geometry = edgeGeometry(from, to, curvatures[index] ?? 0);
2176
+ const baseWidth = edgeWidthOf(edgeDegrees, edge);
1681
2177
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("g", { children: [
1682
2178
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1683
2179
  "path",
@@ -1699,7 +2195,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1699
2195
  d: geometry.path,
1700
2196
  fill: "none",
1701
2197
  stroke: selectedEdge || hoveredEdge || active ? "var(--dsw-alias-brand-primary)" : edgeColor(edge),
1702
- strokeWidth: selectedEdge ? 2.6 : hoveredEdge ? 2.2 : active ? 2 : 1.2,
2198
+ strokeWidth: selectedEdge ? EDGE_WIDTH_MAX + 0.8 : hoveredEdge ? baseWidth + 1 : active ? baseWidth + 0.6 : baseWidth,
1703
2199
  strokeOpacity: focusId === null && selectedEdgeId === null ? 0.9 : selectedEdge || hoveredEdge || active ? 1 : 0.22,
1704
2200
  markerEnd: selectedEdge || hoveredEdge || active ? "url(#rg-arrow-active)" : "url(#rg-arrow)"
1705
2201
  }
@@ -1717,6 +2213,7 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1717
2213
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1718
2214
  "g",
1719
2215
  {
2216
+ "data-node-id": node.id,
1720
2217
  style: {
1721
2218
  transform: `translate(${node.x}px, ${node.y}px)`,
1722
2219
  transition: dragged ? "none" : void 0
@@ -1792,7 +2289,36 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1792
2289
  })
1793
2290
  ] })
1794
2291
  ] }),
1795
- tooltip && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GraphTooltip, { node: tooltip.node, degree: degreeOf(tooltip.node.id, visibleEdges), x: tooltip.x, y: tooltip.y, containerWidth: size.width })
2292
+ tooltip && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GraphTooltip, { node: tooltip.node, degree: degreeOf(tooltip.node.id, visibleEdges), x: tooltip.x, y: tooltip.y, containerWidth: size.width }),
2293
+ minimapVisible && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "rg-minimap-wrap", children: [
2294
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2295
+ GraphMinimap,
2296
+ {
2297
+ width: minimapCanvas.width,
2298
+ height: minimapCanvas.height,
2299
+ rects: minimapRects,
2300
+ view: minimapView,
2301
+ focusRect: minimapFocusRect,
2302
+ onNavigate: navigateFromMinimap
2303
+ }
2304
+ ),
2305
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "rg-sr-only", children: t("graph.minimapHint") })
2306
+ ] }),
2307
+ visibleNodes.length === 0 && (hidden.size > 0 || onlyConnected) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "rg-graph-filtered-empty", role: "status", children: [
2308
+ t("graph.filteredEmpty"),
2309
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2310
+ "button",
2311
+ {
2312
+ type: "button",
2313
+ className: "rg-link",
2314
+ onClick: () => {
2315
+ setHidden(/* @__PURE__ */ new Set());
2316
+ setOnlyConnected(false);
2317
+ },
2318
+ children: t("graph.filteredEmptyReset")
2319
+ }
2320
+ )
2321
+ ] })
1796
2322
  ]
1797
2323
  }
1798
2324
  ),
@@ -1822,13 +2348,17 @@ function GuardGraph({ graph, height = VIEWPORT_HEIGHT_WIDE, focusId, onFocusChan
1822
2348
  ": ",
1823
2349
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: selectedLabel })
1824
2350
  ] }),
1825
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "rg-graph-hint", children: t("graph.hint") })
2351
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "rg-graph-hint", children: [
2352
+ t("graph.hint"),
2353
+ " \xB7 ",
2354
+ t("graph.arrowHint")
2355
+ ] })
1826
2356
  ] })
1827
2357
  ] });
1828
2358
  }
1829
2359
 
1830
2360
  // src/client/PanelCards.tsx
1831
- var import_react2 = require("react");
2361
+ var import_react3 = require("react");
1832
2362
 
1833
2363
  // src/client/panel-model.ts
1834
2364
  var STAGE_ORDER = ["idle", "monitoring", "crashed", "deciding", "stabilizing", "recovered"];
@@ -2105,7 +2635,7 @@ function Card({
2105
2635
  children,
2106
2636
  hint
2107
2637
  }) {
2108
- const [enlarged, setEnlarged] = (0, import_react2.useState)(false);
2638
+ const [enlarged, setEnlarged] = (0, import_react3.useState)(false);
2109
2639
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2110
2640
  "article",
2111
2641
  {
@@ -2228,9 +2758,14 @@ function StabilityRing({ score }) {
2228
2758
  }
2229
2759
  );
2230
2760
  }
2761
+ var TRANSITIONS_INITIAL = 8;
2231
2762
  function LifecycleBody({ snapshot }) {
2232
2763
  const rail = stageRail(snapshot.stage, snapshot.transitions);
2233
2764
  const verdict = snapshot.lastRecoveryVerdict;
2765
+ const [showAllTransitions, setShowAllTransitions] = (0, import_react3.useState)(false);
2766
+ const transitionsIndexed = snapshot.transitions.map((transition, index) => ({ transition, index }));
2767
+ const visibleTransitions = showAllTransitions ? transitionsIndexed : transitionsIndexed.slice(-TRANSITIONS_INITIAL);
2768
+ const omittedTransitions = transitionsIndexed.length - visibleTransitions.length;
2234
2769
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2235
2770
  verdict !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2236
2771
  "p",
@@ -2261,11 +2796,19 @@ function LifecycleBody({ snapshot }) {
2261
2796
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { children: t("state.restored") }),
2262
2797
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: snapshot.restored.length })
2263
2798
  ] }),
2264
- snapshot.transitions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("state.noTransitions") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ol", { className: "rg-transitions", children: snapshot.transitions.slice(-8).map((transition, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "rg-transition", children: [
2265
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rg-badge rg-badge-${transition.to}`, children: stageLabelOf(transition.to) }),
2266
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rg-transition-reason", title: transition.reason, children: transition.reason }),
2267
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("time", { className: "rg-transition-time", children: formatClock(transition.at) })
2268
- ] }, `${transition.at}-${index}`)) })
2799
+ snapshot.transitions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("state.noTransitions") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2800
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ol", { className: "rg-transitions", children: visibleTransitions.map(({ transition, index }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "rg-transition", children: [
2801
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: `rg-badge rg-badge-${transition.to}`, children: stageLabelOf(transition.to) }),
2802
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "rg-transition-reason", title: transition.reason, children: transition.reason }),
2803
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("time", { className: "rg-transition-time", children: formatClock(transition.at) })
2804
+ ] }, `${transition.at}-${index}`)) }),
2805
+ omittedTransitions > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "rg-link rg-risks-expand", onClick: () => setShowAllTransitions(true), children: t("state.moreTransitions", { count: omittedTransitions }) }),
2806
+ showAllTransitions && snapshot.transitions.length > TRANSITIONS_INITIAL && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", className: "rg-link", onClick: () => setShowAllTransitions(false), children: [
2807
+ t("state.fewerTransitions"),
2808
+ " \xB7 ",
2809
+ snapshot.transitions.length
2810
+ ] })
2811
+ ] })
2269
2812
  ] });
2270
2813
  }
2271
2814
  function MetricsBody({ snapshot }) {
@@ -2283,7 +2826,7 @@ function RisksBody({
2283
2826
  }) {
2284
2827
  if (snapshot.risks.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("risks.empty") });
2285
2828
  const INITIAL_VISIBLE = 15;
2286
- const [showAllRisks, setShowAllRisks] = (0, import_react2.useState)(false);
2829
+ const [showAllRisks, setShowAllRisks] = (0, import_react3.useState)(false);
2287
2830
  const visibleRisks = showAllRisks ? snapshot.risks : snapshot.risks.slice(0, INITIAL_VISIBLE);
2288
2831
  const hiddenCount = snapshot.risks.length - visibleRisks.length;
2289
2832
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
@@ -2316,6 +2859,7 @@ function BackupPolicyBody({ snapshot }) {
2316
2859
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("backupPolicy.hint") })
2317
2860
  ] });
2318
2861
  }
2862
+ var CAPABILITY_INITIAL = 8;
2319
2863
  function CapabilityBody({
2320
2864
  snapshot,
2321
2865
  graph,
@@ -2323,8 +2867,10 @@ function CapabilityBody({
2323
2867
  onSelect
2324
2868
  }) {
2325
2869
  const capability = snapshot.capability;
2326
- const [expanded, setExpanded] = (0, import_react2.useState)(false);
2327
- const rows = capabilityRows(graph, expanded ? 200 : 8);
2870
+ const [expanded, setExpanded] = (0, import_react3.useState)(false);
2871
+ const allRows = capabilityRows(graph, Number.POSITIVE_INFINITY);
2872
+ const rows = expanded ? allRows : allRows.slice(0, CAPABILITY_INITIAL);
2873
+ const omittedRows = allRows.length - rows.length;
2328
2874
  const exposedCount = graph ? graph.nodes.filter((node) => node.kind === "capability" && (node.weight ?? 0) > 0).length : capability.exposed;
2329
2875
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2330
2876
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dl", { className: "rg-dl", children: [
@@ -2382,7 +2928,12 @@ function CapabilityBody({
2382
2928
  row.id
2383
2929
  )) })
2384
2930
  ] }),
2385
- capabilityRows(graph, 200).length > 8 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "rg-button rg-button-small", onClick: () => setExpanded((current) => !current), "aria-expanded": expanded, children: expanded ? t("capabilities.collapse") : t("capabilities.expand", { count: capabilityRows(graph, 200).length }) })
2931
+ omittedRows > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "rg-button rg-button-small", onClick: () => setExpanded(true), "aria-expanded": expanded, children: t("capabilities.expand", { count: allRows.length }) }),
2932
+ expanded && allRows.length > CAPABILITY_INITIAL && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("button", { type: "button", className: "rg-button rg-button-small", onClick: () => setExpanded(false), "aria-expanded": expanded, children: [
2933
+ t("capabilities.collapse"),
2934
+ " \xB7 ",
2935
+ allRows.length
2936
+ ] })
2386
2937
  ] }),
2387
2938
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "rg-card-subtitle", children: t("capabilities.gaps") }),
2388
2939
  capability.gaps.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("capabilities.noGaps") }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("ul", { className: "rg-gaps", children: capability.gaps.map((gap, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("li", { className: "rg-gap", children: [
@@ -2481,7 +3032,7 @@ function PartitionRow({
2481
3032
  }
2482
3033
  var EVENTS_INITIAL = 12;
2483
3034
  function EventsBody({ events }) {
2484
- const [showAll, setShowAll] = (0, import_react2.useState)(false);
3035
+ const [showAll, setShowAll] = (0, import_react3.useState)(false);
2485
3036
  if (events.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-empty", children: t("panel.emptyHint") });
2486
3037
  const ordered = [...events].reverse();
2487
3038
  const visible = showAll ? ordered : ordered.slice(0, EVENTS_INITIAL);
@@ -2518,7 +3069,7 @@ function ArchivesCard({
2518
3069
  onArchive,
2519
3070
  busy
2520
3071
  }) {
2521
- const [draft, setDraft] = (0, import_react2.useState)(reason);
3072
+ const [draft, setDraft] = (0, import_react3.useState)(reason);
2522
3073
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("article", { className: "rg-card", "data-card-id": "archives", children: [
2523
3074
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: "rg-card-title", children: t("sections.archives") }),
2524
3075
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "rg-card-note", children: t("archives.explain") }),
@@ -2564,9 +3115,14 @@ function archiveEntriesOf(payload) {
2564
3115
  }
2565
3116
 
2566
3117
  // src/client/InsightCards.tsx
3118
+ var import_react4 = require("react");
2567
3119
  var import_jsx_runtime4 = require("react/jsx-runtime");
3120
+ var STATIONARY_VISIBLE = 4;
2568
3121
  function MarkovBody({ snapshot }) {
3122
+ const [showAllStationary, setShowAllStationary] = (0, import_react4.useState)(false);
2569
3123
  const view = markovView(snapshot);
3124
+ const stationaryVisible = showAllStationary ? view.stationary : view.stationary.slice(0, STATIONARY_VISIBLE);
3125
+ const stationaryOmitted = view.stationary.length - stationaryVisible.length;
2570
3126
  if (!view.available) {
2571
3127
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "rg-empty", children: t("markov.empty") });
2572
3128
  }
@@ -2592,12 +3148,25 @@ function MarkovBody({ snapshot }) {
2592
3148
  ] }, row.stage)) }),
2593
3149
  view.stationary.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rg-markov-stationary", children: [
2594
3150
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h4", { className: "rg-subhead", children: t("markov.stationary") }),
2595
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "rg-chip-row", role: "list", children: view.stationary.slice(0, 4).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rg-chip", role: "listitem", title: `${entry.stage} ${entry.percent}%`, children: [
2596
- stageLabelOf(entry.stage, entry.stage),
2597
- " ",
2598
- entry.percent,
2599
- "%"
2600
- ] }, entry.stage)) })
3151
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "rg-chip-row", role: "list", children: [
3152
+ stationaryVisible.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "rg-chip", role: "listitem", title: `${entry.stage} ${entry.percent}%`, children: [
3153
+ stageLabelOf(entry.stage, entry.stage),
3154
+ " ",
3155
+ entry.percent,
3156
+ "%"
3157
+ ] }, entry.stage)),
3158
+ stationaryOmitted > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3159
+ "button",
3160
+ {
3161
+ type: "button",
3162
+ className: "rg-chip rg-chip-more",
3163
+ onClick: () => setShowAllStationary(true),
3164
+ "aria-label": t("markov.stationaryMore", { count: stationaryOmitted }),
3165
+ children: t("markov.stationaryMore", { count: stationaryOmitted })
3166
+ }
3167
+ )
3168
+ ] }),
3169
+ showAllStationary && view.stationary.length > STATIONARY_VISIBLE && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "rg-link", onClick: () => setShowAllStationary(false), children: t("markov.stationaryAll", { count: view.stationary.length }) })
2601
3170
  ] })
2602
3171
  ] });
2603
3172
  }
@@ -2647,21 +3216,22 @@ function saveCollapsed(cards) {
2647
3216
  }
2648
3217
  }
2649
3218
  function GuardPanel(props) {
2650
- const [snapshot, setSnapshot] = (0, import_react3.useState)(null);
2651
- const [graph, setGraph] = (0, import_react3.useState)(null);
2652
- const [archives, setArchives] = (0, import_react3.useState)(null);
2653
- const [failure, setFailure] = (0, import_react3.useState)(null);
2654
- const [busy, setBusy] = (0, import_react3.useState)(false);
2655
- const [polling, setPolling] = (0, import_react3.useState)(true);
2656
- const [collapsed, setCollapsed] = (0, import_react3.useState)(() => loadCollapsed());
2657
- const [form, setForm] = (0, import_react3.useState)("wide");
2658
- const [selectedNodeId, setSelectedNodeId] = (0, import_react3.useState)(null);
2659
- const [locateRequest, setLocateRequest] = (0, import_react3.useState)(null);
2660
- const [requestedKey, setRequestedKey] = (0, import_react3.useState)(null);
2661
- const [partitionMismatch, setPartitionMismatch] = (0, import_react3.useState)(null);
2662
- const rootRef = (0, import_react3.useRef)(null);
2663
- const mounted = (0, import_react3.useRef)(true);
2664
- const load = (0, import_react3.useCallback)(
3219
+ const [snapshot, setSnapshot] = (0, import_react5.useState)(null);
3220
+ const [graph, setGraph] = (0, import_react5.useState)(null);
3221
+ const [archives, setArchives] = (0, import_react5.useState)(null);
3222
+ const [failure, setFailure] = (0, import_react5.useState)(null);
3223
+ const [busy, setBusy] = (0, import_react5.useState)(false);
3224
+ const [polling, setPolling] = (0, import_react5.useState)(true);
3225
+ const [collapsed, setCollapsed] = (0, import_react5.useState)(() => loadCollapsed());
3226
+ const [form, setForm] = (0, import_react5.useState)("wide");
3227
+ const [selectedNodeId, setSelectedNodeId] = (0, import_react5.useState)(null);
3228
+ const [locateRequest, setLocateRequest] = (0, import_react5.useState)(null);
3229
+ const [requestedKey, setRequestedKey] = (0, import_react5.useState)(null);
3230
+ const [partitionMismatch, setPartitionMismatch] = (0, import_react5.useState)(null);
3231
+ const [conflictNotice, setConflictNotice] = (0, import_react5.useState)(false);
3232
+ const rootRef = (0, import_react5.useRef)(null);
3233
+ const mounted = (0, import_react5.useRef)(true);
3234
+ const load = (0, import_react5.useCallback)(
2665
3235
  async (partitionKey) => {
2666
3236
  const [snapshotResult, graphResult, archivesResult] = await Promise.all([
2667
3237
  props.fetchSnapshot(partitionKey ?? void 0),
@@ -2685,7 +3255,7 @@ function GuardPanel(props) {
2685
3255
  },
2686
3256
  [props.fetchSnapshot, props.fetchGraph, props.fetchArchives]
2687
3257
  );
2688
- (0, import_react3.useEffect)(() => {
3258
+ (0, import_react5.useEffect)(() => {
2689
3259
  mounted.current = true;
2690
3260
  void load(requestedKey);
2691
3261
  if (!polling) {
@@ -2699,7 +3269,7 @@ function GuardPanel(props) {
2699
3269
  clearInterval(timer);
2700
3270
  };
2701
3271
  }, [load, polling, requestedKey]);
2702
- (0, import_react3.useEffect)(() => {
3272
+ (0, import_react5.useEffect)(() => {
2703
3273
  const measure = () => {
2704
3274
  const width = rootRef.current?.getBoundingClientRect().width ?? 0;
2705
3275
  if (width > 0) setForm(panelForm(width));
@@ -2709,20 +3279,30 @@ function GuardPanel(props) {
2709
3279
  if (observer && rootRef.current) observer.observe(rootRef.current);
2710
3280
  return () => observer?.disconnect();
2711
3281
  }, []);
2712
- const runAction = (0, import_react3.useCallback)(
3282
+ const runAction = (0, import_react5.useCallback)(
2713
3283
  async (action, payload = {}) => {
2714
3284
  setBusy(true);
2715
3285
  try {
2716
- const result = await props.postAction(action, payload);
2717
- if (!result.ok) setFailure(result.reason);
3286
+ const inspectingOther = requestedKey !== null;
3287
+ const body = !inspectingOther && snapshot?.revision ? { ...payload, expectedRevision: snapshot.revision } : payload;
3288
+ const result = await props.postAction(action, body);
3289
+ if (!result.ok) {
3290
+ if (result.conflict === "stale-revision") setConflictNotice(true);
3291
+ else {
3292
+ setConflictNotice(false);
3293
+ setFailure(result.reason);
3294
+ }
3295
+ } else {
3296
+ setConflictNotice(false);
3297
+ }
2718
3298
  await load(requestedKey);
2719
3299
  } finally {
2720
3300
  if (mounted.current) setBusy(false);
2721
3301
  }
2722
3302
  },
2723
- [props.postAction, load, requestedKey]
3303
+ [props.postAction, load, requestedKey, snapshot?.revision]
2724
3304
  );
2725
- const toggleCollapse = (0, import_react3.useCallback)((card) => {
3305
+ const toggleCollapse = (0, import_react5.useCallback)((card) => {
2726
3306
  setCollapsed((current) => {
2727
3307
  const next = new Set(current);
2728
3308
  if (next.has(card)) next.delete(card);
@@ -2731,32 +3311,32 @@ function GuardPanel(props) {
2731
3311
  return next;
2732
3312
  });
2733
3313
  }, []);
2734
- const onGraphFocus = (0, import_react3.useCallback)((id) => {
3314
+ const onGraphFocus = (0, import_react5.useCallback)((id) => {
2735
3315
  setSelectedNodeId(id);
2736
3316
  }, []);
2737
- const locateInGraph = (0, import_react3.useCallback)((id) => {
3317
+ const locateInGraph = (0, import_react5.useCallback)((id) => {
2738
3318
  setSelectedNodeId(id);
2739
3319
  if (id !== null) setLocateRequest({ id, nonce: Date.now() });
2740
3320
  }, []);
2741
3321
  const currentPartition = snapshot?.partitions.find((partition) => partition.key === snapshot.projectKey);
2742
- const partitionState = (0, import_react3.useMemo)(
3322
+ const partitionState = (0, import_react5.useMemo)(
2743
3323
  () => snapshot === null ? null : partitionView(snapshot, requestedKey ?? snapshot.projectKey),
2744
3324
  [snapshot, requestedKey]
2745
3325
  );
2746
3326
  const graphHeight = form === "narrow" ? VIEWPORT_HEIGHT_NARROW : VIEWPORT_HEIGHT_WIDE;
2747
- const selectedLabel = (0, import_react3.useMemo)(() => {
3327
+ const selectedLabel = (0, import_react5.useMemo)(() => {
2748
3328
  if (selectedNodeId === null || graph === null) return null;
2749
3329
  return graph.nodes.find((node) => node.id === selectedNodeId)?.label ?? null;
2750
3330
  }, [selectedNodeId, graph]);
2751
3331
  const unavailable = failure !== null && snapshot === null;
2752
3332
  const loading = snapshot === null;
2753
- const [nowTick, setNowTick] = (0, import_react3.useState)(() => Date.now());
2754
- (0, import_react3.useEffect)(() => {
3333
+ const [nowTick, setNowTick] = (0, import_react5.useState)(() => Date.now());
3334
+ (0, import_react5.useEffect)(() => {
2755
3335
  if (polling) return;
2756
3336
  const timer = setInterval(() => setNowTick(Date.now()), 6e4);
2757
3337
  return () => clearInterval(timer);
2758
3338
  }, [polling]);
2759
- const staleMinutes = (0, import_react3.useMemo)(() => {
3339
+ const staleMinutes = (0, import_react5.useMemo)(() => {
2760
3340
  if (polling || snapshot === null) return 0;
2761
3341
  return Math.max(0, Math.round((nowTick - Date.parse(snapshot.at)) / 6e4));
2762
3342
  }, [polling, snapshot, nowTick]);
@@ -2804,6 +3384,11 @@ function GuardPanel(props) {
2804
3384
  )
2805
3385
  ] })
2806
3386
  ] }),
3387
+ conflictNotice && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "rg-notice", role: "status", children: [
3388
+ t("panel.conflictNotice"),
3389
+ " ",
3390
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "rg-link", onClick: () => setConflictNotice(false), children: t("panel.conflictDismiss") })
3391
+ ] }),
2807
3392
  partitionMismatch !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "rg-notice", role: "status", children: [
2808
3393
  t("partitions.mismatch", {
2809
3394
  requested: partitionMismatch.requested.slice(0, 8),
@@ -3000,11 +3585,11 @@ function GuardPanel(props) {
3000
3585
  }
3001
3586
 
3002
3587
  // src/client/GuardPanelIcon.ts
3003
- var import_react4 = require("react");
3588
+ var import_react6 = require("react");
3004
3589
  function GuardPanelIcon(props) {
3005
3590
  const size = typeof props.size === "number" && props.size > 0 ? props.size : 20;
3006
3591
  const active = props.active === true;
3007
- return (0, import_react4.createElement)(
3592
+ return (0, import_react6.createElement)(
3008
3593
  "svg",
3009
3594
  {
3010
3595
  width: size,
@@ -3015,9 +3600,9 @@ function GuardPanelIcon(props) {
3015
3600
  "aria-label": t("panel.title"),
3016
3601
  "aria-hidden": active ? void 0 : "true"
3017
3602
  },
3018
- (0, import_react4.createElement)("title", { key: "title" }, t("panel.title")),
3603
+ (0, import_react6.createElement)("title", { key: "title" }, t("panel.title")),
3019
3604
  // 盾牌轮廓:守护的隐喻。
3020
- (0, import_react4.createElement)("path", {
3605
+ (0, import_react6.createElement)("path", {
3021
3606
  key: "shield",
3022
3607
  d: "M12 2.5 4.5 5.2v6.1c0 4.6 3.1 8.9 7.5 10.2 4.4-1.3 7.5-5.6 7.5-10.2V5.2L12 2.5Z",
3023
3608
  stroke: active ? "var(--dsw-alias-brand-primary)" : "currentColor",
@@ -3027,7 +3612,7 @@ function GuardPanelIcon(props) {
3027
3612
  fillOpacity: active ? 0.14 : 0
3028
3613
  }),
3029
3614
  // 心跳线:崩溃检测的隐喻。
3030
- (0, import_react4.createElement)("path", {
3615
+ (0, import_react6.createElement)("path", {
3031
3616
  key: "pulse",
3032
3617
  d: "M6.8 12h2.6l1.5-3.4 2 6.2 1.6-2.8h2.7",
3033
3618
  stroke: active ? "var(--dsw-alias-brand-primary)" : "currentColor",
@@ -3058,7 +3643,21 @@ async function fetchJson(url, init) {
3058
3643
  headers: { accept: "application/json", ...init?.headers ?? {} }
3059
3644
  });
3060
3645
  if (!response.ok) {
3061
- return { ok: false, reason: `HTTP ${response.status}` };
3646
+ let detail = null;
3647
+ try {
3648
+ const parsed = await response.json();
3649
+ if (typeof parsed === "object" && parsed !== null) detail = parsed;
3650
+ } catch {
3651
+ detail = null;
3652
+ }
3653
+ const reason = typeof detail?.reason === "string" && detail.reason.length > 0 ? detail.reason : `HTTP ${response.status}`;
3654
+ return {
3655
+ ok: false,
3656
+ reason,
3657
+ status: response.status,
3658
+ ...typeof detail?.conflict === "string" ? { conflict: detail.conflict } : {},
3659
+ ...typeof detail?.current === "string" ? { current: detail.current } : {}
3660
+ };
3062
3661
  }
3063
3662
  const payload = await response.json();
3064
3663
  if (typeof payload === "object" && payload !== null && payload.available === false) {
@@ -3155,12 +3754,12 @@ function integratePanel(ctx) {
3155
3754
  try {
3156
3755
  const panelRegistration = api.register(
3157
3756
  { name: "main", key: PANEL_ID, order: 20, label: () => t("panel.title"), locale: NAMESPACE },
3158
- () => (0, import_react5.createElement)(GuardPanel, { fetchSnapshot, fetchGraph, fetchArchives, postAction })
3757
+ () => (0, import_react7.createElement)(GuardPanel, { fetchSnapshot, fetchGraph, fetchArchives, postAction })
3159
3758
  );
3160
3759
  if (typeof panelRegistration === "function") yield panelRegistration;
3161
3760
  const iconRegistration = api.register(
3162
3761
  { name: "sidebar.panellist", id: PANEL_ID, order: 20, label: () => t("panel.title"), locale: NAMESPACE },
3163
- () => (0, import_react5.createElement)(GuardPanelIcon)
3762
+ () => (0, import_react7.createElement)(GuardPanelIcon)
3164
3763
  );
3165
3764
  if (typeof iconRegistration === "function") yield iconRegistration;
3166
3765
  telemetry.registered = true;
@@ -3190,7 +3789,7 @@ function integratePanel(ctx) {
3190
3789
  try {
3191
3790
  const iconRegistration = api.register(
3192
3791
  { name: "sidebar.panellist", id: PANEL_ID, order: 20, label: () => t("panel.title"), locale: NAMESPACE },
3193
- () => (0, import_react5.createElement)(GuardPanelIcon)
3792
+ () => (0, import_react7.createElement)(GuardPanelIcon)
3194
3793
  );
3195
3794
  telemetry.registered = true;
3196
3795
  telemetry.error = null;
@@ -3233,30 +3832,108 @@ var styles_default = "/**\n * \u7BA1\u7406\u9762\u677F\u7684\u6837\u5F0F\u3002\n
3233
3832
  // src/client/styles.ts
3234
3833
  var STYLE_ELEMENT_ID = "dsh-recency-guard-styles";
3235
3834
  var PANEL_CSS = styles_default;
3835
+ var GRAPH_CSS = `
3836
+ /* ---------- \u5C0F\u5730\u56FE\uFF08Overview + \u7F29\u7565\u5BFC\u822A\uFF09 ---------- */
3837
+ .rg-minimap-wrap {
3838
+ position: absolute;
3839
+ right: 10px;
3840
+ bottom: 10px;
3841
+ /* \u538B\u5728\u300C\u6EE4\u7A7A\u63D0\u793A\u300D\u4E4B\u4E0A\uFF1A\u90A3\u5757\u63D0\u793A\u662F inset:0 \u7684\u6574\u9762\u8986\u76D6\u5C42\uFF0C\u82E5\u4E0D\u7ED9\u5B83\u66F4\u9AD8
3842
+ \u5C42\u7EA7\uFF0C\u56FE\u88AB\u6EE4\u7A7A\u65F6\u7528\u6237\u6070\u597D\u6700\u9700\u8981\u7528\u7684\u590D\u4F4D/\u5207\u6362\u5165\u53E3\u4F1A\u88AB\u906E\u4F4F\u3002 */
3843
+ z-index: 6;
3844
+ display: flex;
3845
+ flex-direction: column;
3846
+ gap: 2px;
3847
+ padding: 4px;
3848
+ border: 1px solid var(--dsw-alias-border-l2);
3849
+ border-radius: var(--dsw-radius-sm, 8px);
3850
+ background: var(--dsw-alias-bg-layer-1);
3851
+ /* \u534A\u900F\u660E\uFF1A\u5C0F\u5730\u56FE\u662F\u53C2\u7167\u7269\uFF0C\u4E0D\u80FD\u6321\u4F4F\u5B83\u5E95\u4E0B\u7684\u8FB9\u3002 */
3852
+ opacity: 0.92;
3853
+ }
3854
+
3855
+ .rg-minimap {
3856
+ display: block;
3857
+ cursor: crosshair;
3858
+ touch-action: none;
3859
+ border-radius: var(--dsw-radius-xs, 4px);
3860
+ background: var(--dsw-alias-bg-layer-2);
3861
+ }
3862
+
3863
+ /* \u89C6\u53E3\u6846\uFF1A\u5168\u89C8\u6001\u6362\u6210\u865A\u7EBF \u2014\u2014 \u300C\u6846\u94FA\u6EE1\u300D\u4E0E\u300C\u6846\u5728\u5C40\u90E8\u300D\u5FC5\u987B\u80FD\u4E00\u773C\u5206\u8FA8\uFF0C
3864
+ \u5426\u5219\u7528\u6237\u5206\u4E0D\u6E05\u300C\u6211\u5DF2\u7ECF\u770B\u5168\u4E86\u300D\u548C\u300C\u63A7\u4EF6\u51FA\u9519\u4E86\u300D\u3002 */
3865
+ .rg-minimap-view-all {
3866
+ stroke-dasharray: 3 3;
3867
+ }
3868
+
3869
+ /* ---------- \u641C\u7D22\u7ED3\u679C\u300C\u7701\u7565 N \u6761\u300D\u884C ---------- */
3870
+ /* \u5C55\u5F00\u5165\u53E3\u4E0E\u7ED3\u679C\u884C\u4E4B\u95F4\u5FC5\u987B\u770B\u5F97\u51FA\u5206\u754C\uFF1A\u5426\u5219\u5B83\u770B\u8D77\u6765\u50CF\u7B2C 9 \u6761\u7ED3\u679C\uFF0C
3871
+ \u7528\u6237\u4F1A\u53BB\u70B9\u4E00\u4E2A\u4E0D\u662F\u8282\u70B9\u7684\u6309\u94AE\u3002 */
3872
+ .rg-search-omitted {
3873
+ border-top: 1px solid var(--dsw-alias-border-l1);
3874
+ margin-top: 2px;
3875
+ padding-top: 2px;
3876
+ }
3877
+
3878
+ /* ---------- \u8FC7\u6EE4\u6EE4\u7A7A\u7684\u8BDA\u5B9E\u63D0\u793A ---------- */
3879
+ .rg-graph-filtered-empty {
3880
+ position: absolute;
3881
+ inset: 0;
3882
+ display: flex;
3883
+ align-items: center;
3884
+ justify-content: center;
3885
+ gap: 8px;
3886
+ flex-wrap: wrap;
3887
+ padding: 0 16px;
3888
+ text-align: center;
3889
+ font-size: var(--dsw-font-xs-13, 13px);
3890
+ color: var(--dsw-alias-label-secondary);
3891
+ background: var(--dsw-alias-bg-layer-2);
3892
+ pointer-events: auto;
3893
+ }
3894
+
3895
+ /* ---------- \u4EC5\u8BFB\u5C4F\u53EF\u89C1\uFF08\u9F20\u6807\u6377\u5F84\u5FC5\u987B\u53E6\u6709\u7B49\u4EF7\u5165\u53E3\uFF09 ---------- */
3896
+ .rg-sr-only {
3897
+ position: absolute;
3898
+ width: 1px;
3899
+ height: 1px;
3900
+ margin: -1px;
3901
+ padding: 0;
3902
+ overflow: hidden;
3903
+ clip-path: inset(50%);
3904
+ white-space: nowrap;
3905
+ border: 0;
3906
+ }
3907
+ `;
3908
+ var GRAPH_STYLE_ELEMENT_ID = "dsh-recency-guard-graph-styles";
3236
3909
  function installStyles(ctx) {
3237
3910
  const effect = ctx.effect;
3238
3911
  if (typeof effect !== "function") {
3239
- applyStyle();
3912
+ applyStyle(STYLE_ELEMENT_ID, PANEL_CSS);
3913
+ applyStyle(GRAPH_STYLE_ELEMENT_ID, GRAPH_CSS);
3240
3914
  return;
3241
3915
  }
3242
3916
  effect(
3243
3917
  () => {
3244
- const element = applyStyle();
3918
+ const elements = [
3919
+ applyStyle(STYLE_ELEMENT_ID, PANEL_CSS),
3920
+ applyStyle(GRAPH_STYLE_ELEMENT_ID, GRAPH_CSS)
3921
+ ];
3245
3922
  return () => {
3246
- element?.remove();
3923
+ for (const element of elements) element?.remove();
3247
3924
  };
3248
3925
  },
3249
3926
  "recency-guard: styles"
3250
3927
  );
3251
3928
  }
3252
- function applyStyle() {
3929
+ function applyStyle(id, text) {
3253
3930
  const doc = globalThis.document;
3254
3931
  if (!doc || typeof doc.createElement !== "function") return null;
3255
- const existing = doc.getElementById(STYLE_ELEMENT_ID);
3932
+ const existing = doc.getElementById(id);
3256
3933
  if (existing) return null;
3257
3934
  const style = doc.createElement("style");
3258
- style.id = STYLE_ELEMENT_ID;
3259
- style.textContent = PANEL_CSS;
3935
+ style.id = id;
3936
+ style.textContent = text;
3260
3937
  const parent = doc.head ?? doc.body;
3261
3938
  if (!parent) return null;
3262
3939
  parent.appendChild(style);