/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Pure selection logic for the Schematic renderer — the marquee hit * collection (#159), and the link or the net under a point (#1403): the links' * R-tree, which a pointer's hover, a tap and a drop search, so what they cost * is what is near the point, never every link. React-free and DOM-free so every * rule the interaction layer relies on is unit-testable in a `node` * environment (see `selection.test.ts`), mirroring the `camera.ts` / * `paint.ts` split. * * @packageDocumentation */ import RBush from "rbush"; import type { NetLeg } from "../edits.js"; import { type DrawnItem, type DrawnLink, type DrawnNet } from "./drawn"; import { type EdgeGeometry } from "./routes"; /** An axis-aligned world-space box over an item, as stored in the culling R-tree. */ export interface ItemBox { minX: number; minY: number; maxX: number; maxY: number; item: DrawnItem; } /** Shared empty key set (stable identity — never churns memos / paint dedup). */ export declare const EMPTY_STRING_SET: ReadonlySet; /** * Collect the items a marquee region selects: an R-tree sweep, then a * CENTER-in-region test (the index boxes are padded for culling, so bare * overlap would over-select), skipping locked items and narrowed-out items * drawn dimmed (context, not targets). Layer-hidden items never reach the tree. * * @param tree - the world-space culling R-tree over the working item set * @param region - the swept world rectangle * @param lockedKeys - keys in a locked layer (non-selectable) * @param excludedKeys - narrowed-out keys drawn dimmed (non-selectable) * @returns the selected item keys */ export declare function marqueeHits(tree: RBush, region: { minX: number; minY: number; maxX: number; maxY: number; }, lockedKeys: ReadonlySet, excludedKeys: ReadonlySet): Set; /** A link's or a net's world box in the links' R-tree, by its id. */ export interface LinkBox { minX: number; minY: number; maxX: number; maxY: number; id: string; } /** The links' and the nets' R-tree, and how far past a box its link's drawn route reaches, at most. */ export interface LinkIndex { /** Each link's and net's world box: the centres of the items it joins drawn, and its bends. */ readonly tree: RBush; /** How far past its box a link's route takes the pointer, at most: its lane, half its weight and the hit reach (px). */ readonly reach: number; } /** * The links' R-tree (#1403): each link's world box over the centres of the * items it joins drawn and its bends, and each net's over its bus as well * (`netBox`: a bar standing off its side, past every member) — its route runs * inside it, but for its lane and its weight, which the search reaches past * ({@link LinkIndex}'s `reach`). A link on a hidden layer, or one an item it * joins isn't drawn for, is left out, as the painter leaves it out. * * @param links - The links * @param nets - The nets * @param centers - Each item drawn's centre, by its id * @param hidden - What a hidden layer holds, by id * @param lanes - The links' lanes (`parallelLanes`) * @returns The index */ export declare function linkIndex(links: readonly DrawnLink[], nets: readonly DrawnNet[], centers: ReadonlyMap, hidden: ReadonlySet, lanes: ReadonlyMap): LinkIndex; /** * The link or the net under a point, and the net's leg it is on (#1403): of * those whose boxes the R-tree holds near the point, the nearest whose drawn * route — each run to its head's tip — the point lies within its weight and the * hit reach of; a net's trunk and bars are the whole net, a leg its leg. Only * those near the point have their routes asked. * * @param index - The links' R-tree * @param routeOf - A link's or a net's drawing, by its id, as the painter draws it * @param world - The point, in world units * @param screen - The point, in the canvas's px * @param ppu - The camera's px a world unit * @param takes - Whether a link, or a net's leg, takes the point: none locked, none the narrowing leaves out * @returns The link or the net, and its leg; `undefined` for none */ export declare function linkAt(index: LinkIndex, routeOf: (id: string) => EdgeGeometry | undefined, world: { x: number; y: number; }, screen: { x: number; y: number; }, ppu: number, takes: (id: string, leg: NetLeg | null) => boolean): { key: string; leg: NetLeg | null; } | undefined; //# sourceMappingURL=selection.d.ts.map