import { Context } from '../context'; import { CellMatrix, Selection, SearchResult, GlobalCache } from '../types'; /** Where find/replace scans on the current sheet (workbook-wide only applies to find-all). */ export type FindSearchScope = 'allSheets' | 'thisSheet' | 'specificRange'; export type ReplaceScope = 'allSheets' | 'thisSheet'; /** * Return value of {@link searchNext}. * * @remarks * **Semver:** Older releases returned `string | null` from `searchNext` (a localized message, or `null` on success). * The object form is a **breaking change** for callers that still expect `string | null`; update them to read * {@link SearchNextResult.alertMsg} (and optionally {@link SearchNextResult.matchIndex} / * {@link SearchNextResult.matchTotal} for on-sheet scoped search UI). */ export type SearchNextResult = { /** Localized message for an alert dialog, or `null` when the next/previous hit was selected successfully. */ alertMsg: string | null; /** * 0-based index of the selected hit in the current sheet's ordered hit list when * `scope` is `thisSheet` or `specificRange` and navigation succeeded; otherwise `0`. */ matchIndex: number; /** * Size of that hit list for `thisSheet` / `specificRange`; `0` when not applicable (e.g. `allSheets`, errors, * or empty search). */ matchTotal: number; }; /** Outcome of {@link replaceAll} for UI (inline status vs. error message). */ export type ReplaceAllResult = { ok: false; message: string; } | { ok: true; replaced: number; skipped: number; }; /** Full used grid on the active sheet for find/replace on this sheet; `null` if the sheet has no cells. */ export declare function getFindRangeOnCurrentSheet(flowdata: CellMatrix): Selection[] | null; export type HyperlinkMap = Record; export interface CheckModes { regCheck?: boolean; wordCheck?: boolean; caseCheck?: boolean; /** Also search inside formula strings (cell.f) */ formulaCheck?: boolean; /** Also search sheet hyperlink address/type for the cell */ linkCheck?: boolean; } /** Skip cells in hidden rows/columns (manual hide + filter). */ export type SearchHiddenConfig = { rowhidden?: Record | null; colhidden?: Record | null; }; export declare function getSearchIndexArr(searchText: string, range: { row: number[]; column: number[]; }[], flowdata: CellMatrix, { regCheck, wordCheck, caseCheck, formulaCheck, linkCheck, }?: CheckModes, hyperlinkMap?: HyperlinkMap, hiddenConfig?: SearchHiddenConfig): { r: number; c: number; }[]; /** Use chunked async scan when the active sheet has at least this many rows. */ export declare const QUICK_SEARCH_ASYNC_ROW_THRESHOLD = 50000; export declare function getQuickSearchHiddenConfig(ctx: Context): SearchHiddenConfig; /** Display-only, case-insensitive substring find; skips hidden rows/columns. */ export declare function getQuickSearchIndexArr(ctx: Context, searchText: string, flowdata: CellMatrix): { r: number; c: number; }[]; /** Bounding grid rect for overlay (merged region or single cell). */ export declare function expandCellRectForMerge(ctx: Context, r: number, c: number): { r1: number; r2: number; c1: number; c2: number; }; export declare function shouldQuickSearchUseAsync(flowdata: CellMatrix): boolean; /** * Finds the next or previous match, updates selection and scroll, and optionally switches sheet when * `scope` is `allSheets`. * * @param specificRange - When `scope` is `specificRange`, restricts the scan to this rectangle on the active sheet. * @returns Structured result; see {@link SearchNextResult} and semver note on {@link SearchNextResult} remarks. */ export declare function searchNext(ctx: Context, searchText: string, checkModes: CheckModes, scope?: FindSearchScope, direction?: 'next' | 'prev', specificRange?: Selection): SearchNextResult; export declare function searchAll(ctx: Context, searchText: string, checkModes: CheckModes, scope?: FindSearchScope, specificRange?: Selection): SearchResult[]; export declare function onSearchDialogMoveStart(globalCache: GlobalCache, e: MouseEvent, container: HTMLDivElement): void; export declare function onSearchDialogMove(globalCache: GlobalCache, e: MouseEvent): void; export declare function onSearchDialogMoveEnd(globalCache: GlobalCache): void; export declare function replace(ctx: Context, searchText: string, replaceText: string, checkModes: CheckModes, specificRange?: Selection): any; export declare function replaceAll(ctx: Context, searchText: string, replaceText: string, checkModes: CheckModes, specificRange?: Selection): ReplaceAllResult; export declare function replaceAllScoped(ctx: Context, searchText: string, replaceText: string, checkModes: CheckModes, scope?: ReplaceScope): ReplaceAllResult; /** * Asynchronously scans `flowdata` for `searchText` in chunks, yielding * between chunks so the main thread stays responsive. * * Returns an AbortController — call `.abort()` to cancel an in-flight scan. * * @param onProgress - called with partial results after each chunk * @param onComplete - called once with the full result array when done */ export declare function getSearchIndexArrAsync(searchText: string, range: { row: number[]; column: number[]; }[], flowdata: CellMatrix, modes: CheckModes, hyperlinkMap?: HyperlinkMap, hiddenConfig?: SearchHiddenConfig, onProgress?: (partial: { r: number; c: number; }[]) => void, onComplete?: (all: { r: number; c: number; }[]) => void): AbortController; /** Chunked quick search with hidden row/column skip (same semantics as `getQuickSearchIndexArr`). */ export declare function runQuickSearchIndexArrAsync(ctx: Context, searchText: string, flowdata: CellMatrix, onProgress: (partial: { r: number; c: number; }[]) => void, onComplete: (all: { r: number; c: number; }[]) => void): AbortController; /** * Parses an A1-notation range string (e.g. "E10:H14" or "Sheet1!E10:H14") * into a `Selection` suitable for scoping find/replace. * * Returns `null` if the text is empty or cannot be parsed. * The sheet-name prefix is stripped before parsing — the active sheet is always used. */ export declare function parseRangeText(rangeText: string, ctx: Context): Selection | null;