/** Requested base paragraph direction. */ type BaseDirection = 'auto' | 'ltr' | 'rtl'; /** A resolved, concrete direction. */ type Direction = 'ltr' | 'rtl'; interface ShapeOptions { /** Form lam-alef ligatures (U+FEF5–U+FEFC). Default true. */ ligatures?: boolean; /** 'strip' removes Arabic diacritics (harakat, tanwīn, Quranic signs). Default 'keep'. */ tashkeel?: 'keep' | 'strip'; } interface RenderOptions extends ShapeOptions { /** Base paragraph direction. Default 'auto' (first-strong detection, P2/P3). */ direction?: BaseDirection; /** Substitute Arabic presentation forms before reordering. Default true. */ shape?: boolean; /** Replace mirrored characters (brackets etc.) on RTL runs (L4). Default true. */ mirror?: boolean; /** 'split' reorders each \n / paragraph-separator chunk separately. Default 'split'. */ paragraphs?: 'split' | 'single'; } /** Detailed result of {@link analyze}. */ interface AnalyzeResult { /** Shaped, visual-order string — what you pass to a renderer that draws left-to-right. */ text: string; /** Resolved base direction of the first paragraph. */ direction: Direction; /** * Resolved embedding level per input code point (odd = RTL). Code points * that do not survive to the output (stripped tashkeel, the alef of a * lam-alef ligature, explicit formatting characters) inherit the level of * the code point they attach to. */ levels: Uint8Array; /** visualToLogical[v] = input code point index shown at visual position v. */ visualToLogical: number[]; /** logicalToVisual[i] = visual position of input code point i, or -1 if it was removed/merged. */ logicalToVisual: Int32Array; } /** * One-call pipeline: shape Arabic letters, run the UBA, mirror brackets. * Returns the visual-order string ready for a naive left-to-right renderer. */ declare function render(text: string, options?: RenderOptions): string; /** * Like {@link render}, but also returns the resolved direction, per-code-point * embedding levels, and visual↔logical index maps (for hit testing, cursor * placement, and selection mapping). */ declare function analyze(text: string, options?: RenderOptions): AnalyzeResult; /** Arabic contextual shaping only (logical order in, logical order out). */ declare function shape(text: string, options?: ShapeOptions): string; /** UAX #9 reordering + mirroring only — no Arabic shaping. */ declare function reorder(text: string, options?: Omit): string; /** * Resolved embedding level per code point (after L1). Odd levels render RTL. */ declare function getEmbeddingLevels(text: string, options?: Pick): Uint8Array; /** First-strong direction of the text (P2/P3), or 'neutral' if no strong character. */ declare function detectDirection(text: string): Direction | 'neutral'; export { type AnalyzeResult as A, type BaseDirection as B, type Direction as D, type RenderOptions as R, type ShapeOptions as S, analyze as a, reorder as b, detectDirection as d, getEmbeddingLevels as g, render as r, shape as s };