import { PromptInputProps } from '../interfaces'; /** Returns the Selection from the element's owning window, supporting iframe contexts. */ export declare function getOwnerSelection(element: Node): Selection | null; /** Logical lengths for each token type, used for cursor position calculations. */ export declare const TOKEN_LENGTHS: { readonly REFERENCE: 1; readonly LINE_BREAK: 1; readonly trigger: (filterText: string) => number; readonly text: (content: string) => number; }; /** Calculates the logical cursor position after a given token index. */ export declare function calculateTokenPosition(tokens: readonly PromptInputProps.InputToken[], upToIndex: number): number; /** Calculates the total logical length of all tokens. */ export declare function calculateTotalTokenLength(tokens: readonly PromptInputProps.InputToken[]): number; /** A resolved position within the DOM: a node and an offset into it. */ interface DOMLocation { node: Node; offset: number; } /** * Manages caret positioning within a contentEditable element. * Translates between logical token positions and DOM Range/Selection API. */ export declare class CaretController { private element; private state; constructor(element: HTMLElement); private get ownerDoc(); /** * Creates a DOM Range from resolved start/end locations and applies it to the given selection. * Returns the created Range for further use (e.g. scroll-into-view checks). */ applyRange(ownerDocument: Document, selection: Selection, startLocation: DOMLocation, endLocation?: DOMLocation): Range; /** Returns the logical length of a DOM node based on its token type. */ private getNodeLength; /** Returns the current logical caret position from the DOM selection. */ getPosition(): number; /** Finds the trigger element at the current caret position, if any. */ findActiveTrigger(): HTMLElement | null; /** * Sets the caret to a logical position, or creates a selection range if end is provided. * Handles smart positioning around atomic reference tokens and scrolls into view. * @param start logical start position * @param end optional logical end position for range selection */ setPosition(start: number, end?: number): void; /** Captures the current caret/selection state for later restoration. */ capture(): void; /** Returns the captured caret start position, or null if no valid capture exists. */ getSavedPosition(): number | null; /** Restores the caret to the previously captured state. */ restore(offset?: number): void; /** Overrides the captured state so the next restore() positions to a calculated location. * Currently used only in tests — consider removing if no production use case emerges. */ setCapturedPosition(start: number, end?: number): void; /** Selects all content in the element. */ selectAll(): void; /** Positions the caret at the end of a text node. */ positionAfterText(textNode: Text): void; /** Moves the caret forward by a logical offset. */ moveForward(offset: number): void; /** Moves the caret backward by a logical offset, clamped to 0. */ moveBackward(offset: number): void; private calculatePositionFromRange; private findDOMLocation; /** Resolves a DOM location for a specific child node at the given offset within a paragraph. */ private resolveChildLocation; private findLocationInParagraph; private countParagraphContent; private countUpToCursor; } export {};