/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * Candidate scoring for the register kinds (B§3.1): whole-string prefix (0) * → every typed word prefixes some word, or any word prefix (1) → initials * in order, two or more characters (2) → substring (3); ties broken by how * often the value already appears in the sheet. Only a PREFIX match ghosts * inline; a non-prefix match previews as a replacement. * * With an empty buffer nothing is armed: the strip lists what the field * ACCEPTS — the driver column ranked by what usually follows the row above, * then by sheet frequency. * * Every register column is typed in the words its cells show (#1536): a * member is found by its key, by its label and by its aliases alike. A * candidate is a member — its key, what a commit writes, and its label, what * the strip, the menu and the ghost show; a lookup's free text is its own key * and label. * * @packageDocumentation */ import { type SheetColumnMeta, type SheetRegisterIndex } from "./model.js"; import type { SheetRowValue } from "./values.js"; /** One candidate: what a commit writes — a member's key — and the words it is shown and typed in, its label (else its key). */ export interface SheetCandidate { key: string; label: string; } /** The sheet facts a candidate list reads. */ export interface CandidateContext { /** The registers. */ registers: SheetRegisterIndex; /** The resident real rows, in sheet order. */ rows: readonly SheetRowValue[]; /** The edited row's index among `rows` (`-1` for a blank row). */ rowIndex: number; /** The driver column's key, when the sheet declares one. */ driverColumn: string | undefined; /** A column's options rule (#844), evaluated for the edited row: the member keys it is offered (`undefined` = the whole register). */ allowed?: ((meta: SheetColumnMeta) => ReadonlySet | undefined) | undefined; } /** Score one label against a query (lower is better; `-1` = no match). */ export declare function scoreLabel(label: string, query: string): number; /** The labels matching `query`, best first; ties by `freq`. */ export declare function scoreCandidates(labels: readonly string[], query: string, freq?: ReadonlyMap): string[]; /** How often each String value of `column` appears in the sheet. */ export declare function columnFrequency(rows: readonly SheetRowValue[], column: string): Map; /** * The entry menu — what the field accepts with an empty buffer. The driver * column ranks by what usually follows the row above (a value that most * often came right after the previous row's driver value, over the dated * rows in sheet order), then by sheet frequency, then the rest of the * register. Every other register column offers its members in their order. */ export declare function entryCandidates(meta: SheetColumnMeta, ctx: CandidateContext): SheetCandidate[]; /** The scored candidates for a typed buffer (the entry menu when empty): the register's members, found by key, label or alias. */ export declare function candidateList(meta: SheetColumnMeta, text: string, ctx: CandidateContext): SheetCandidate[]; /** * The candidate typed text commits to: the member it names whole — by key or * alias, else by the label it shows, the first member to show it — where the * row is offered that member; else the best candidate. Two members who show * one label are told apart by a pick (the menu, the strip, ⇥), never by the * words alone. * * @param meta - The register column * @param text - What was typed * @param ctx - The sheet facts * @returns The candidate, or `undefined` where nothing matches */ export declare function candidateFor(meta: SheetColumnMeta, text: string, ctx: CandidateContext): SheetCandidate | undefined; /** Which candidate is armed: an explicit pick, else the top one once something is typed. */ export declare function armedIndex(text: string, hi: number): number; /** The armed candidate for a buffer (`undefined` with an empty buffer — entering arms nothing). */ export declare function candidateAt(meta: SheetColumnMeta, text: string, hi: number, ctx: CandidateContext): SheetCandidate | undefined; /** The inline ghost — the top prefix candidate's suffix, else `""`. */ export declare function ghostFor(text: string, candidate: string | undefined): string; /** One word of the ghost — the copilot's word-wise accept. */ export declare function ghostWord(ghost: string): string; /** A non-prefix match previews as a replacement (`→ Routing - Nesting`); `""` when the ghost covers it. */ export declare function resolveFor(text: string, candidate: string | undefined): string; //# sourceMappingURL=candidates.d.ts.map