import { Direction } from './algorithm.js'; export type { Direction, BidiResult } from './algorithm.js'; export type { BidiClass } from './char-types.js'; export { computeBidi, reorderVisual } from './algorithm.js'; export { bidiClass } from './char-types.js'; /** The result of {@link analyzeString}: per-code-point embedding levels for a string plus its paragraph base level. */ export interface StringBidi { /** * Embedding level per *code point* (not per UTF-16 unit). Index aligns with * `[...string]` iteration order. */ readonly levels: ReadonlyArray; /** The string's code points, in logical order (parallel to `levels`). */ readonly codePoints: ReadonlyArray; /** The resolved paragraph embedding level (0 = LTR, 1 = RTL). */ readonly paragraphLevel: number; } /** * Run the UAX #9 algorithm over a string, returning per-code-point embedding * levels and the paragraph base level. Iterates by code point so surrogate pairs * stay intact and the result indices align with `[...text]`. * * @param text The paragraph text. * @param dir The base direction; `'auto'` (the default) derives it from the * first strong character (P2/P3). * @returns The {@link StringBidi} levels for `text`. */ export declare function analyzeString(text: string, dir?: Direction): StringBidi; /** * Whether a string contains any character that could trigger RTL reordering * (`R` or `AL` strong types, or Arabic/Hebrew presentation forms). Used as a fast * gate so pure-LTR paragraphs skip the BiDi machinery entirely. * * @param text The string to scan. * @returns `true` if any code point falls in the Hebrew/Arabic/Syriac/Thaana/NKo * or Arabic presentation-form ranges. */ export declare function hasBidiCharacters(text: string): boolean; /** * Reverse a string by code point (so surrogate pairs stay intact). Used to emit * an RTL run's glyphs in visual (right-to-left) order, since our glyph placement * advances left-to-right. * * @param text The string to reverse. * @returns `text` with its code points in reverse order. */ export declare function reverseByCodePoint(text: string): string; /** * Given the embedding levels for a contiguous array of *tokens* (each token * carrying a single resolved level), return the visual order as a permutation of * token indices. A thin token-granularity wrapper over {@link reorderVisual} (L2). * * @param tokenLevels One resolved embedding level per token, in logical order. * @returns The visual order as a permutation where `result[k]` is the logical token index. */ export declare function reorderTokens(tokenLevels: ReadonlyArray): Array; export { segmentLevels } from './segments.js'; export type { BidiSegment } from './segments.js';