import { type ViewCamera, type ViewCameraLimits } from "../../style/view-camera.js"; /** One step of a workflow or flow: a card on the canvas. */ export interface FlowNode { /** Stable id, unique within the editor. */ id: string; /** The card's title. */ label: string; /** A muted second line under the title. */ description?: string; /** Top-left corner in content units. */ x: number; y: number; } /** A directed connection from one node's output port to another node's input port. */ export interface FlowEdge { /** Stable id, unique within the editor. */ id: string; from: string; to: string; /** Text drawn at the middle of the edge, such as its condition. */ label?: string; /** Draw the edge dashed: a path that returns work upstream. */ rework?: boolean; } /** An entry in the palette: a kind of node the user can add. */ export interface FlowPaletteItem { id: string; label: string; /** Refuse adding this kind, for example when the graph already has one. */ disabled?: boolean; } /** What is selected: a node or an edge, by id. */ export type FlowSelection = { kind: "node"; id: string; } | { kind: "edge"; id: string; }; /** Card size in content units. */ export declare const FLOW_NODE_WIDTH = 176; export declare const FLOW_NODE_HEIGHT = 64; /** The snapping grid, and one arrow-key move. */ export declare const FLOW_GRID = 24; /** The visible port dot's radius, and the larger touch radius around it. */ export declare const FLOW_PORT_RADIUS = 6; export declare const FLOW_PORT_HIT_RADIUS = 18; /** Zoom range: a quarter size to double size. */ export declare const FLOW_CAMERA_LIMITS: ViewCameraLimits; /** Wheel travel that doubles the zoom. */ export declare const FLOW_WHEEL_PX_PER_DOUBLING = 480; /** One zoom control press. */ export declare const FLOW_ZOOM_STEP = 1.25; /** Space kept around the graph when the view fits it. */ export declare const FLOW_FIT_PADDING = 48; /** A point in content units. */ export interface FlowPoint { x: number; y: number; } /** Round a point to the grid. */ export declare function snapFlowPoint(point: FlowPoint, grid?: number): FlowPoint; /** Where a node's output port (right edge, middle) and input port (left edge, middle) sit. */ export declare function flowPorts(node: FlowNode): { out: FlowPoint; in: FlowPoint; }; /** A drawn edge: its SVG path, where its label sits, and its arrowhead's tip and direction. */ export interface FlowEdgeGeometry { d: string; label: FlowPoint; tip: FlowPoint; /** The direction the arrow points, in radians. */ angle: number; /** The cubic's start, two handles and end, for hit testing. */ curve: readonly [FlowPoint, FlowPoint, FlowPoint, FlowPoint]; } /** * The path from one port to another. A forward edge is an S-curve whose handles reach out * horizontally; an edge that runs backward (to a node at or left of its source) loops below * both cards so it never cuts through them; an edge to its own node loops over the card. */ export declare function flowEdgeGeometry(from: FlowNode, to: FlowNode | FlowPoint): FlowEdgeGeometry; /** The width of an edge's label capsule, from its text (11 px mono glyphs plus padding). */ export declare function flowEdgeLabelWidth(label: string): number; /** The label capsule's height. */ export declare const FLOW_EDGE_LABEL_HEIGHT = 18; /** * The edge under a content point, or null: its label capsule, or within `tolerance` of its * curve (sampled as 32 chords). Later edges draw over earlier ones. Edges whose ends are * missing are skipped, as they are not drawn. */ export declare function flowEdgeAt(nodes: readonly FlowNode[], edges: readonly FlowEdge[], point: FlowPoint, tolerance: number): FlowEdge | null; /** The topmost node under a content point, or null. Later nodes draw over earlier ones. */ export declare function flowNodeAt(nodes: readonly FlowNode[], point: FlowPoint): FlowNode | null; /** * The bounding box of the graph, or null when it has no nodes: every card, and every drawn * edge's curve (sampled), so a backward edge's loop below the cards or a self loop above one * is inside it. */ export declare function flowBounds(nodes: readonly FlowNode[], edges?: readonly FlowEdge[]): { x: number; y: number; width: number; height: number; } | null; /** * The camera that shows the whole graph centred in a viewport, never enlarged past zoom 1 (a * small graph keeps its true size) and held to the zoom range. */ export declare function fitFlowCamera(nodes: readonly FlowNode[], edges: readonly FlowEdge[], width: number, height: number, padding?: number): ViewCamera; /** The arrow-key move of a focused node, one grid step, or null for any other key. */ export declare function flowKeyMove(node: FlowNode, key: string, grid?: number): FlowPoint | null; /** A free spot for a new node: the given point, nudged down a grid step past any card there. */ export declare function flowFreeSpot(nodes: readonly FlowNode[], point: FlowPoint, grid?: number): FlowPoint; /** Whether an edge between these nodes may be added: both exist, and it is not a duplicate. */ export declare function flowCanConnect(nodes: readonly FlowNode[], edges: readonly FlowEdge[], from: string, to: string): boolean; //# sourceMappingURL=flow-editor.logic.d.ts.map