import type{LyraAnchor,TextSelectRect}from'../components/viewers/document-viewer/anchors.js';export interface TextQuoteLimits{ /** Maximum UTF-16 code units retained in one normalized searchable corpus. */ maxCorpusCodeUnits:number; /** Maximum text nodes/items visited while building one corpus. */ maxNodes:number; /** Maximum DOM nodes/direct item children traversed while locating those text nodes. */ maxTraversalNodes:number; /** Maximum UTF-16 code units inspected from any single text node/item. */ maxNodeCodeUnits:number; /** Maximum source UTF-16 code units inspected while normalizing one corpus. */ maxNormalizationWorkCodeUnits:number; /** Maximum UTF-16 code units accepted in one query/quote/context string. */ maxQueryCodeUnits:number; /** Maximum occurrence offsets retained for one query. */ maxMatches:number; /** Maximum corpus code units folded/scanned in one logical search or paint pass. */ maxSearchWorkCodeUnits:number; /** Maximum distinct occurrence lists cached by one content/locale index. */ maxCacheEntries:number;} /** Resource ceilings shared by text-quote anchors and DOM-text viewer search. Counts are UTF-16 * code units because DOM Range offsets and String#indexOf use that coordinate space. */ export declare const TEXT_QUOTE_LIMITS:Readonly; /** NFC-normalizes, strips soft hyphens, collapses every whitespace run to one ASCII space, and * trims. The single normalization used for a whole standalone string -- an anchor's `quote`/ * `prefix`/`suffix`, or a fully-selected Range's text. Building a scope's own per-node corpus uses * a related, non-trimming variant internally (see `normalizeSegment`) so inter-node spacing survives. */ export declare function normalizeQuoteText(s:string):string; /** One DOM text node's contribution to a `TextQuoteScope`. `rawOffsetRuns` stores sparse pairs of * `[normalizedOffset, rawOffset]` only where the otherwise-identity mapping changes (collapsed * whitespace or removed soft hyphens). Ordinary text therefore retains no per-character map. */ interface TextQuoteSegment{node:Text;normalizedStart:number;normalizedLength:number;rawOffsetRuns:Uint32Array; /** Canonically changed graphemes as packed `[normalizedStart, normalizedEnd, rawStart, rawEnd]`. */ rawClusterRuns?:Uint32Array; /** Raw node length at scope construction, used to fail closed after stale DOM mutations. */ rawLength?:number; /** Exact raw node value and parent at scope construction, used to reject same-length edits and * detach/reparent operations without rebuilding the whole corpus during Range materialization. */ rawText?:string;parentNode?:Node|null;previousSibling?:Node|null;nextSibling?:Node|null;} /** A bounded searchable corpus with a sparse offset map back to DOM positions. `truncated=true` * means later source content was not indexed, so a retained match count is only a lower bound. */ export interface TextQuoteScope{text:string;segments:TextQuoteSegment[];truncated:boolean; /** Sparse mapping from whole-scope NFC offsets back to the per-segment normalized coordinate. */ globalNormalization?:TextOffsetMapping;}interface TextOffsetMapping{text:string; /** Packed `[sourceStart, sourceEnd, mappedStart, mappedEnd]` entries. */ expansions:Uint32Array;} /** Builds a scope by walking `root`'s text nodes in document order (skipping * script/style/template/noscript), concatenating each node's normalized text. Callers pass their * *content* element (e.g. markdown's `[part="content"]`) so toolbar chrome never enters the corpus. */ export declare function scopeFromElement(root:Element,limitOverrides?:Partial):TextQuoteScope; /** Builds a scope from ordered text-layer items joined in reading order. Normalizes each item's * authoritative `text` and maps offsets into its explicit direct `node`, or into `element`'s first * text child when `node` is omitted. `joinBefore=false` preserves contiguous nested text within * one peer text run; otherwise a word-space is synthesized unless the boundary continues one * Unicode grapheme. An item with no usable text node is skipped. */ export declare function scopeFromItems(items:{text:string;element:Element;node?:Text;joinBefore?:boolean;}[],limitOverrides?:Partial):TextQuoteScope;export interface TextQuoteMatch{start:number;end:number;} /** Compact occurrence collection. Match boundaries are retained as packed Uint32 pairs and only * materialized as short-lived objects when a caller asks for/iterates a particular match. */ export interface TextQuoteMatches extends Iterable{readonly packedOffsets:Uint32Array;readonly length:number; /** `false` means `length` is a known lower bound because a corpus/match/query/work ceiling hit. */ readonly matchCountExact:boolean; /** Whether the retained corpus was scanned to its end (separate from scope truncation). */ readonly scanComplete:boolean;at(index:number):TextQuoteMatch|undefined;} /** An exact, allocation-light empty occurrence collection for viewer state initialization/reset. */ export declare function emptyTextQuoteMatches():TextQuoteMatches;export interface TextQuoteWorkBudget{remainingCodeUnits:number;} /** Reusable per-content/per-locale occurrence index. Cached queries allocate packed offsets; a * caller supplies a fresh work budget for each logical operation so one paint pass cannot turn * N distinct highlights into N full-corpus scans. */ export declare class TextQuoteIndex{readonly locale?:string|undefined;private readonly limits;private readonly occurrenceCache;private foldedScope?;private _scanCount;private _scope;constructor(scope:TextQuoteScope,locale?:string|undefined,limitOverrides?:Partial);get scope():TextQuoteScope; /** Rebinds offset-to-node materialization after a structurally different but semantically * identical DOM paint, preserving the folded corpus and occurrence cache. */ rebindScope(scope:TextQuoteScope):boolean;get scanCount():number;createWorkBudget(maxCodeUnits?:number):TextQuoteWorkBudget;private consumeWork;private boundedQuery;private foldedFor;private cache;private occurrences;search(query:string,budget?:TextQuoteWorkBudget):TextQuoteMatches;resolve(anchor:{quote:string;prefix?:string;suffix?:string;},budget?:TextQuoteWorkBudget):TextQuoteMatch|null;}export declare function createTextQuoteIndex(scope:TextQuoteScope,locale?:string,limitOverrides?:Partial):TextQuoteIndex; /** Resolves within the bounded scope/index. Quotes after a truncated corpus prefix or beyond an * occurrence/work ceiling are intentionally unresolved rather than allocating without limit. */ export declare function resolveTextQuote(scope:TextQuoteScope,anchor:{quote:string;prefix?:string;suffix?:string;},locale?:string):Range|null; /** Every retained occurrence of `query` in `scope`, packed as offsets. `matchCountExact=false` * makes corpus/match/query/work truncation explicit to search-event callers. */ export declare function findTextQuoteMatches(scope:TextQuoteScope,query:string,locale?:string,limitOverrides?:Partial):TextQuoteMatches; /** Materializes one `TextQuoteMatch` into a live `Range`, or null if the scope no longer covers * those offsets (the document changed since the match was found). */ export declare function rangeFromTextQuoteMatch(scope:TextQuoteScope,match:TextQuoteMatch):Range|null; /** Materializes a bounded synchronous batch after validating the scope exactly once. Match * access happens before provenance validation, so a hostile getter that mutates the DOM makes the * entire batch fail closed. The returned array preserves the admitted input positions with nulls * for malformed/unmappable matches; inputs beyond the retained-match ceiling are not inspected. */ export declare function rangesFromTextQuoteMatches(scope:TextQuoteScope,matches:readonly(TextQuoteMatch|null|undefined)[]):Array;export declare function findTextQuoteRanges(scope:TextQuoteScope,query:string,locale?:string):Range[]; /** Returns normalized selection text without ever materializing the range's unbounded full * `toString()` value. The public ceiling is the same one quote anchors and viewer queries accept. */ export declare function boundedSelectionText(range:Range,maxCodeUnits?:number):string;export declare const TEXT_SELECTION_RECT_LIMIT=1000; /** Copies at most the hard rect ceiling instead of retaining an unbounded `DOMRectList`. */ export declare function boundedSelectionRects(range:Range,maxRects?:number):readonly TextSelectRect[];export declare function buildQuoteAnchor(range:Range,scope:TextQuoteScope):LyraAnchor;export{};