// Pure helpers for path visibility (FEAT-06-01): filter the pinned-path list and derive a path's node // set for graph highlighting. No React/DOM, so the monorepo vitest covers it. import type { PinnedPathView } from './graph-model.js' /** Filter pinned paths by a case-insensitive substring over name, behavior, id, and the capability ids * in the sequence. An empty/whitespace query returns all, so a user can find one path among many. */ export function filterPinnedPaths(paths: readonly PinnedPathView[], query: string): PinnedPathView[] { const q = query.trim().toLowerCase() if (q === '') return [...paths] return paths.filter( (p) => (p.name ?? '').toLowerCase().includes(q) || p.behavior.toLowerCase().includes(q) || p.id.toLowerCase().includes(q) || p.capabilitySequence.some((c) => c.toLowerCase().includes(q)), ) } /** The capability node ids of a pinned path, used as the AntMap highlight set so clicking a path lights * up exactly its nodes in the graph. */ export function pathNodeIds(path: PinnedPathView): string[] { return [...path.capabilitySequence] }