import type { Core, EdgeCollection, EdgeSingular, NodeSingular } from 'cytoscape'; import type { ElkPlacement } from './elk-layout.js'; import type { VisualLayoutPositions, VisualLayoutRoutes } from '../adapters/visual/protocol-contract.js'; export interface Point { readonly x: number; readonly y: number; } /** * Every property a route sets. Cleared by name, never by a bare * `removeStyle()`: `applyFilter` hides elements through a `display` bypass, * and a bare clear would un-hide every filtered edge along with the route. */ export declare const ROUTE_STYLE_PROPERTIES: readonly ['curve-style', 'edge-distances', 'source-endpoint', 'target-endpoint', 'segment-weights', 'segment-distances', 'source-text-offset']; /** * The cytoscape style for one route (pure). `points` runs source to target in * absolute coordinates, ELK's start and end points included; the two node * centres are where the endpoints' offsets are measured from. `labelAt` is * the label's arc position from the source end, and 0 when there is no label - * the text itself is the stylesheet's, so a label toggle repaints without * touching a single bypass. */ export declare function routeStyle(points: readonly Point[], sourceCentre: Point, targetCentre: Point, labelAt: number | null): Record; /** * Whether a node still sits where ELK put it. A leaf is compared to its * placed centre; a container is placed when every leaf inside it is, since * its own box is derived from theirs. A saved position or a drag breaks the * equality, and an edge with a moved end is not drawn on a route computed * for the end's old place. */ export declare function placedByElk(node: NodeSingular, placement: ElkPlacement): boolean; /** * Draws every route in the placement whose edge is present and eligible, and * returns how many it drew. Eligibility is the caller's: the canvas passes * "both ends still where ELK put them". */ export declare function applyEdgeRoutes(cy: Core, placement: ElkPlacement, eligible: (edge: EdgeSingular) => boolean): number; /** Gives the edges back to the stylesheet's own drawing. */ export declare function clearEdgeRoutes(edges: EdgeCollection): void; /** * The routes currently drawn, keyed by relationship id, in the shape the * layout sidecar keeps (ADR 0147). Only routed edges appear: an edge a moved * endpoint handed back to the stylesheet has no route worth saving, which is * exactly what lets a saved layout keep every other edge's route. */ export declare function buildRouteMap(edges: EdgeCollection): VisualLayoutRoutes; /** * Draws the routes a saved layout kept, on every edge that is not already * routed and whose two ends still sit where the saved positions say. The * saved positions are the placement those routes were computed for, so the * same eligibility ELK's own routes get applies verbatim; an end the reader * has since moved leaves its edges on the stylesheet's straight line. */ export declare function applySavedRoutes(cy: Core, routes: VisualLayoutRoutes, positions: VisualLayoutPositions): number; /** * A drag moves one end of every edge on the dragged node, and the routes those * edges carried were computed for where the node was. The node's ancestors * lose theirs too - a moved member resizes the box around it, and an edge * ending on that box's border ends somewhere else now - and so do its * descendants, which moved with it. Bound to `dragfree`, not `position`: a * fold translates the whole graph through `position`, and a route survives a * translation intact. */ export declare function registerRouteInvalidation(cy: Core): () => void;