/**
 * OCR infrastructure, image analysis helpers, fraction math, and audio transcription helpers.
 * Extracted from localFileMediaTools.ts for modularity.
 */
export declare function extractChunkedIntsFromText(text: string, opts?: {
    chunkSize?: number;
    min?: number;
    max?: number;
}): number[];
export declare function gcdInt(a: number, b: number): number;
export type Fraction = {
    n: number;
    d: number;
};
export declare function normalizeFraction(f: Fraction): Fraction;
export declare function parseFractionLoose(text: string): Fraction | null;
export declare function parseMixedNumberLoose(text: string): {
    whole: number;
    frac: Fraction;
} | null;
export declare function fractionsEqual(a: Fraction, b: Fraction): boolean;
export declare function addFractions(a: Fraction, b: Fraction): Fraction;
export declare function subFractions(a: Fraction, b: Fraction): Fraction;
export declare function mulFractions(a: Fraction, b: Fraction): Fraction;
export declare function divFractions(a: Fraction, b: Fraction): Fraction;
export declare function fractionToString(f: Fraction): string;
export declare function mixedNumberToString(whole: number, frac: Fraction): string;
export declare function getSharpOptional(): Promise<any | null>;
export declare function getTesseract(): Promise<any>;
export type OcrBBox = {
    x0: number;
    y0: number;
    x1: number;
    y1: number;
};
export type OcrWord = {
    text: string;
    confidence: number | null;
    bbox: OcrBBox | null;
};
export type OcrLine = {
    text: string;
    confidence: number | null;
    bbox: OcrBBox | null;
};
export declare function clampNumber(n: number, min: number, max: number): number;
export declare function toOcrBbox(raw: any): OcrBBox | null;
export declare function parseTesseractTsv(tsv: string): {
    words: OcrWord[];
    lines: OcrLine[];
};
export declare function withOcrWorker<T>(args: {
    lang: string;
    langPathEffective: string | null;
}, fn: (worker: any) => Promise<T>): Promise<T>;
export declare function ocrRecognizeBuffer(args: {
    buffer: Buffer;
    lang: string;
    langPathEffective: string | null;
    tessOptions?: Record<string, string>;
    output?: {
        text?: boolean;
        tsv?: boolean;
        hocr?: boolean;
        blocks?: boolean;
    };
}): Promise<{
    text: string;
    confidence: number | null;
    words: OcrWord[];
    lines: OcrLine[];
}>;
export declare function ocrRecognizeImageFile(args: {
    filePath: string;
    lang: string;
    langPathEffective: string | null;
    preprocess: boolean;
}): Promise<{
    text: string;
    confidence: number | null;
    words: OcrWord[];
    lines: OcrLine[];
    usedSharp: boolean;
}>;
export declare function ocrRecognizeImageFileWithColorMask(args: {
    filePath: string;
    color: "red" | "green";
    lang: string;
    langPathEffective: string | null;
    maxPixels?: number;
    minPrimary?: number;
    minDelta?: number;
    upscale?: number;
    blurSigma?: number;
    threshold?: number;
}): Promise<{
    text: string;
    confidence: number | null;
    usedSharp: boolean;
}>;
export declare function ocrRecognizeImageFileWithPurpleMask(args: {
    filePath: string;
    lang: string;
    langPathEffective: string | null;
    maxPixels?: number;
    minPrimary?: number;
    maxGreen?: number;
    minDelta?: number;
    upscale?: number;
    blurSigma?: number;
    threshold?: number;
}): Promise<{
    text: string;
    confidence: number | null;
    words: OcrWord[];
    lines: OcrLine[];
    usedSharp: boolean;
    upscale: number;
}>;
export type ThinBar = {
    x0: number;
    x1: number;
    y0: number;
    y1: number;
    cx: number;
    cy: number;
    len: number;
};
export declare function rectHasInk(bw: Uint8Array, width: number, height: number, rect: {
    x0: number;
    y0: number;
    x1: number;
    y1: number;
}, minCount: number): boolean;
export declare function rectInkBounds(bw: Uint8Array, width: number, height: number, rect: {
    x0: number;
    y0: number;
    x1: number;
    y1: number;
}, minCount: number): {
    x0: number;
    y0: number;
    x1: number;
    y1: number;
    count: number;
} | null;
export declare function detectThinHorizontalBarsFromBw(bw: Uint8Array, width: number, height: number, opts: {
    minRun: number;
    maxThickness?: number;
    mergeY?: number;
    overlapRatio?: number;
}): ThinBar[];
export declare function detectThinVerticalBarsFromBw(bw: Uint8Array, width: number, height: number, opts: {
    minRun: number;
    maxThickness?: number;
    mergeX?: number;
    overlapRatio?: number;
}): ThinBar[];
export declare function ocrIntegerFromImageRegion(args: {
    sharp: any;
    source: Buffer;
    left: number;
    top: number;
    width: number;
    height: number;
    threshold: number;
    thresholds?: number[];
    lang: string;
    langPathEffective: string | null;
    psms: number[];
    minValue?: number;
    maxValue?: number;
}): Promise<number | null>;
export declare function gradeFractionQuizFromImageRowBands(args: {
    sharp: any;
    filePath: string;
    lang: string;
    langPathEffective: string | null;
    bonusPoints: number;
    pointsAddSubtract: number;
    pointsMultiplyDivide: number;
    pointsImproperFraction: number;
    pointsMixedNumber: number;
}): Promise<{
    extractedQuestionCount: number;
    score: number;
    perQuestion: Array<{
        index: number;
        type: string;
        correct: boolean;
        points: number;
        studentAnswer: string | null;
        correctAnswer: string;
        debug?: any;
    }>;
} | null>;
export declare const FASTER_WHISPER_PY_SCRIPT_V1 = "# NodeBench MCP audio transcription helper (faster-whisper)\n# This file is written to a temp directory at runtime.\nimport argparse\nimport json\nimport sys\n\n\ndef main() -> None:\n    p = argparse.ArgumentParser()\n    p.add_argument(\"--path\", required=True)\n    p.add_argument(\"--model\", default=\"tiny.en\")\n    p.add_argument(\"--language\", default=\"\")\n    p.add_argument(\"--task\", default=\"transcribe\")\n    p.add_argument(\"--beam-size\", type=int, default=5)\n    p.add_argument(\"--vad-filter\", type=int, default=0)\n    p.add_argument(\"--max-chars\", type=int, default=12000)\n    p.add_argument(\"--include-segments\", type=int, default=0)\n    args = p.parse_args()\n\n    try:\n        from faster_whisper import WhisperModel\n    except Exception:\n        sys.stderr.write(\n            \"Missing python dependency: faster-whisper. Install with: pip install faster-whisper\\n\"\n        )\n        raise\n\n    model = WhisperModel(args.model, device=\"cpu\", compute_type=\"int8\")\n    segments, info = model.transcribe(\n        args.path,\n        beam_size=max(1, int(args.beam_size)),\n        language=(args.language or None),\n        task=(args.task or \"transcribe\"),\n        vad_filter=bool(int(args.vad_filter)),\n        word_timestamps=False,\n        temperature=0.0,\n    )\n\n    include_segments = bool(int(args.include_segments))\n    max_chars = max(200, int(args.max_chars))\n\n    parts = []\n    segs = []\n    char_budget = 0\n    truncated = False\n\n    for seg in segments:\n        t = str(getattr(seg, \"text\", \"\") or \"\")\n        if not t:\n            continue\n        parts.append(t)\n        if include_segments:\n            segs.append(\n                {\n                    \"start\": float(getattr(seg, \"start\", 0.0) or 0.0),\n                    \"end\": float(getattr(seg, \"end\", 0.0) or 0.0),\n                    \"text\": t,\n                }\n            )\n        char_budget += len(t)\n        if char_budget >= max_chars:\n            truncated = True\n            break\n\n    text = \"\".join(parts).strip()\n    if len(text) > max_chars:\n        text = text[:max_chars]\n        truncated = True\n\n    out = {\n        \"path\": args.path,\n        \"model\": args.model,\n        \"task\": args.task,\n        \"language\": getattr(info, \"language\", None),\n        \"languageProbability\": getattr(info, \"language_probability\", None),\n        \"durationSeconds\": getattr(info, \"duration\", None),\n        \"beamSize\": int(args.beam_size),\n        \"vadFilter\": bool(int(args.vad_filter)),\n        \"maxChars\": max_chars,\n        \"truncated\": truncated,\n        \"text\": text,\n    }\n    if include_segments:\n        out[\"segments\"] = segs\n    sys.stdout.write(json.dumps(out, ensure_ascii=False))\n\n\nif __name__ == \"__main__\":\n    main()\n";
export declare function findPythonExecutable(): string;
export declare function ensureFasterWhisperHelperScript(): Promise<string>;
