{"version":3,"sources":["../typescript/core/binding.ts","../typescript/errors/diagnostics.ts","../typescript/errors.ts","../typescript/core/assertions.ts","../typescript/core/config-normalizer.ts","../typescript/core/type-converters.ts","../typescript/extraction/batch.ts","../typescript/extraction/render.ts","../typescript/extraction/single.ts","../typescript/extraction/worker-pool.ts","../typescript/plugins/post-processors.ts","../typescript/plugins/validators.ts","../typescript/plugins/ocr-backends.ts","../typescript/registry/document-extractors.ts","../typescript/config/loader.ts","../typescript/mime/utilities.ts","../typescript/embeddings/presets.ts","../typescript/index.ts"],"sourcesContent":["/**\n * @internal Native NAPI binding interface and management.\n *\n * This module provides:\n * - NativeBinding interface defining all methods available in the compiled Rust addon\n * - getBinding() singleton getter with lazy loading\n * - loadNativeBinding() for loading the native .node module\n * - Native binding error formatting\n *\n * This is a Layer 0 module with NO dependencies on other internal modules.\n */\n\nimport { createRequire } from \"node:module\";\n\n/**\n * @internal Native NAPI binding interface for the Kreuzberg native module.\n * This interface defines the shape of methods available in the compiled native addon.\n */\nexport interface NativeBinding {\n\textractFileSync(\n\t\tfilePath: string,\n\t\tmimeType: string | null,\n\t\tconfig: Record<string, unknown> | null,\n\t): Record<string, unknown>;\n\textractFile(\n\t\tfilePath: string,\n\t\tmimeType: string | null,\n\t\tconfig: Record<string, unknown> | null,\n\t): Promise<Record<string, unknown>>;\n\textractBytesSync(data: Buffer, mimeType: string, config: Record<string, unknown> | null): Record<string, unknown>;\n\textractBytes(\n\t\tdata: Buffer,\n\t\tmimeType: string,\n\t\tconfig: Record<string, unknown> | null,\n\t): Promise<Record<string, unknown>>;\n\tbatchExtractFilesSync(paths: string[], config: Record<string, unknown> | null): Record<string, unknown>[];\n\tbatchExtractFiles(paths: string[], config: Record<string, unknown> | null): Promise<Record<string, unknown>[]>;\n\tbatchExtractBytesSync(\n\t\tdataArray: Buffer[],\n\t\tmimeTypes: string[],\n\t\tconfig: Record<string, unknown> | null,\n\t): Record<string, unknown>[];\n\tbatchExtractBytes(\n\t\tdataArray: Buffer[],\n\t\tmimeTypes: string[],\n\t\tconfig: Record<string, unknown> | null,\n\t): Promise<Record<string, unknown>[]>;\n\tregisterPostProcessor(processor: Record<string, unknown>): void;\n\tunregisterPostProcessor(name: string): void;\n\tclearPostProcessors(): void;\n\tlistPostProcessors(): string[];\n\tregisterValidator(validator: Record<string, unknown>): void;\n\tunregisterValidator(name: string): void;\n\tclearValidators(): void;\n\tlistValidators(): string[];\n\tregisterOcrBackend(backend: Record<string, unknown>): void;\n\tunregisterOcrBackend(name: string): void;\n\tclearOcrBackends(): void;\n\tlistOcrBackends(): string[];\n\tregisterDocumentExtractor(extractor: Record<string, unknown>): void;\n\tunregisterDocumentExtractor(name: string): void;\n\tclearDocumentExtractors(): void;\n\tlistDocumentExtractors(): string[];\n\tdetectMimeType(filePath: string): string;\n\tdetectMimeTypeFromBytes(data: Buffer): string;\n\tdetectMimeTypeFromPath(filePath: string, checkExists?: boolean): string;\n\tvalidateMimeType(mimeType: string): string;\n\tgetExtensionsForMime(mimeType: string): string[];\n\tlistEmbeddingPresets(): string[];\n\tgetEmbeddingPreset(name: string): Record<string, unknown> | null;\n\tgetErrorCodeName(code: number): string;\n\tgetErrorCodeDescription(code: number): string;\n\tclassifyError(errorMessage: string): Record<string, unknown>;\n\tgetLastErrorCode(): number;\n\tgetLastPanicContext(): Record<string, unknown> | null;\n\tloadExtractionConfigFromFile(filePath: string): Record<string, unknown>;\n\tdiscoverExtractionConfig(): Record<string, unknown> | null;\n\tcreateWorkerPool(size?: number): Record<string, unknown>;\n\tgetWorkerPoolStats(pool: Record<string, unknown>): Record<string, unknown>;\n\textractFileInWorker(\n\t\tpool: Record<string, unknown>,\n\t\tfilePath: string,\n\t\tmimeType: string | null,\n\t\tconfig: Record<string, unknown> | null,\n\t): Promise<Record<string, unknown>>;\n\tbatchExtractFilesInWorker(\n\t\tpool: Record<string, unknown>,\n\t\tpaths: string[],\n\t\tconfig: Record<string, unknown> | null,\n\t): Promise<Record<string, unknown>[]>;\n\tcloseWorkerPool(pool: Record<string, unknown>): Promise<void>;\n\trenderPdfPageSync(filePath: string, pageIndex: number, dpi?: number | null): Buffer;\n\trenderPdfPage(filePath: string, pageIndex: number, dpi?: number | null): Promise<Buffer>;\n\titeratePdfPagesSync(filePath: string, dpi?: number | null): Array<{ pageIndex: number; data: Buffer }>;\n\titeratePdfPages(filePath: string, dpi?: number | null): Promise<Array<{ pageIndex: number; data: Buffer }>>;\n\tpdfPageCount(filePath: string, dpi?: number | null): number;\n\tembedSync(texts: string[], config: Record<string, unknown> | null): number[][];\n\tembed(texts: string[], config: Record<string, unknown> | null): Promise<number[][]>;\n\tJsPdfPageIterator: {\n\t\tnew (\n\t\t\tfilePath: string,\n\t\t\tdpi?: number | null,\n\t\t): {\n\t\t\tnext(): { pageIndex: number; data: Buffer } | null;\n\t\t\tpageCount(): number;\n\t\t\tclose(): void;\n\t\t};\n\t};\n}\n\n/**\n * Detects whether the current runtime supports NAPI native modules.\n * Returns true for Node.js and Bun (which implements Node-API natively).\n * Bun is checked first because it also sets process.versions.node for compatibility.\n * @internal\n */\nfunction isNapiRuntime(): boolean {\n\tif (typeof process === \"undefined\") return false;\n\tif (process.versions?.[\"bun\"]) return true;\n\tif (process.versions?.node) return true;\n\treturn false;\n}\n\n/**\n * Global singleton reference to the native binding.\n * Lazy-loaded on first call to getBinding().\n * @internal\n */\nlet binding: NativeBinding | null = null;\n\n/**\n * Flag indicating whether we've attempted to load the binding.\n * Prevents repeated load attempts if initialization fails.\n * @internal\n */\nlet bindingInitialized = false;\n\n/**\n * Creates a formatted error for native binding load failures.\n * Includes helpful hints based on the error type.\n * @internal\n */\nexport function createNativeBindingError(error: unknown): Error {\n\tconst hintParts: string[] = [];\n\tlet detail = \"Unknown error while requiring native module.\";\n\n\tif (error instanceof Error) {\n\t\tdetail = error.message || error.toString();\n\t\tif (/pdfium/i.test(detail)) {\n\t\t\thintParts.push(\n\t\t\t\t\"Pdfium runtime library was not found. Ensure the bundled libpdfium (dll/dylib/so) is present next to the native module.\",\n\t\t\t);\n\t\t}\n\t\treturn new Error(\n\t\t\t[\n\t\t\t\t\"Failed to load Kreuzberg native bindings.\",\n\t\t\t\thintParts.length ? hintParts.join(\" \") : \"\",\n\t\t\t\t\"Report this error and attach the logs/stack trace for investigation.\",\n\t\t\t\t`Underlying error: ${detail}`,\n\t\t\t]\n\t\t\t\t.filter(Boolean)\n\t\t\t\t.join(\" \"),\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\n\treturn new Error(\n\t\t[\n\t\t\t\"Failed to load Kreuzberg native bindings.\",\n\t\t\t\"Report this error and attach the logs/stack trace for investigation.\",\n\t\t\t`Underlying error: ${String(error)}`,\n\t\t].join(\" \"),\n\t);\n}\n\n/**\n * Loads the native binding from the compiled .node module.\n * Validates that all required methods are present before returning.\n * @internal\n */\nexport function loadNativeBinding(): NativeBinding {\n\tlet localRequire: ((path: string) => unknown) | undefined;\n\n\t// In ESM bundled context, we must create require from import.meta.url first\n\t// This ensures we get a proper require that can load .node files\n\ttry {\n\t\tlocalRequire = createRequire(import.meta.url);\n\t} catch {\n\t\t// Fallback to global require if createRequire fails (e.g., in CJS)\n\t\tif (typeof require !== \"undefined\") {\n\t\t\tlocalRequire = require as (path: string) => unknown;\n\t\t}\n\t}\n\n\tif (!localRequire) {\n\t\tthrow new Error(\"Unable to resolve native binding loader (require not available).\");\n\t}\n\n\t// Load from package root index.js (NAPI-RS generated loader), not compiled barrel export\n\t// When bundled: From dist/index.mjs, ../index.js points to package root index.js\n\t// When unbundled: From dist/core/binding.js, ../../index.js points to package root index.js\n\t// Since we're using bundle: true, use ../index.js\n\tconst loadedModule = localRequire(\"../index.js\") as unknown;\n\n\tif (typeof loadedModule !== \"object\" || loadedModule === null) {\n\t\tthrow new Error(\n\t\t\t\"Native binding is not a valid object. \" + \"Ensure the native module is properly built and compatible.\",\n\t\t);\n\t}\n\n\tconst module = loadedModule as Record<string, unknown>;\n\n\tconst requiredMethods = [\n\t\t\"extractFileSync\",\n\t\t\"extractFile\",\n\t\t\"extractBytesSync\",\n\t\t\"extractBytes\",\n\t\t\"batchExtractFilesSync\",\n\t\t\"batchExtractFiles\",\n\t\t\"batchExtractBytesSync\",\n\t\t\"batchExtractBytes\",\n\t];\n\n\tfor (const method of requiredMethods) {\n\t\tif (typeof module[method] !== \"function\") {\n\t\t\tthrow new Error(\n\t\t\t\t`Native binding is missing required method: ${method}. ` +\n\t\t\t\t\t\"Ensure the native module is properly built and compatible.\",\n\t\t\t);\n\t\t}\n\t}\n\n\treturn module as unknown as NativeBinding;\n}\n\n/**\n * Gets the native binding, with lazy loading on first access.\n *\n * The native binding is loaded on first call and cached for subsequent calls.\n * If loading fails, the error is cached and re-thrown on every subsequent call\n * to prevent repeated load attempts.\n *\n * @returns The native binding interface\n * @throws Error if the binding cannot be loaded\n * @internal\n */\nexport function getBinding(): NativeBinding {\n\tif (bindingInitialized) {\n\t\tif (binding === null) {\n\t\t\tthrow new Error(\"Native binding was previously failed to load.\");\n\t\t}\n\t\treturn binding;\n\t}\n\n\ttry {\n\t\tif (isNapiRuntime()) {\n\t\t\tbinding = loadNativeBinding();\n\t\t\tbindingInitialized = true;\n\t\t\treturn binding;\n\t\t}\n\t} catch (error) {\n\t\tbindingInitialized = true;\n\t\tthrow createNativeBindingError(error);\n\t}\n\n\tthrow new Error(\n\t\t\"Failed to load Kreuzberg bindings. Neither NAPI (Node.js) nor WASM (browsers/Deno) bindings are available. \" +\n\t\t\t\"Make sure you have installed the @kreuzberg/node package for Node.js/Bun.\",\n\t);\n}\n\n/**\n * @internal Allows tests to provide a mocked native binding.\n */\nexport function __setBindingForTests(mock: unknown): void {\n\tbinding = mock as NativeBinding;\n\tbindingInitialized = true;\n}\n\n/**\n * @internal Resets the cached native binding for tests.\n */\nexport function __resetBindingForTests(): void {\n\tbinding = null;\n\tbindingInitialized = false;\n}\n","import { getBinding } from \"../core/binding.js\";\nimport type { PanicContext } from \"../errors.js\";\nimport type { ErrorClassification } from \"../types.js\";\n\n/**\n * Get the error code for the last FFI error.\n *\n * Returns the FFI error code as an integer. This is useful for programmatic error handling\n * and distinguishing between different types of failures in native code.\n *\n * Error codes:\n * - 0: Success (no error)\n * - 1: GenericError\n * - 2: Panic\n * - 3: InvalidArgument\n * - 4: IoError\n * - 5: ParsingError\n * - 6: OcrError\n * - 7: MissingDependency\n * - 8: Embedding\n *\n * @returns The integer error code\n *\n * @example\n * ```typescript\n * import { extractFile, getLastErrorCode, ErrorCode } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   const code = getLastErrorCode();\n *   if (code === ErrorCode.Panic) {\n *     console.error('Native code panic detected');\n *   }\n * }\n * ```\n */\nexport function getLastErrorCode(): number {\n\tconst binding = getBinding();\n\treturn binding.getLastErrorCode();\n}\n\n/**\n * Get panic context information if the last error was a panic.\n *\n * Returns detailed information about a panic in native code, or null if the last error was not a panic.\n * This provides debugging information when native code panics.\n *\n * @returns A `PanicContext` object with file, line, function, message, and timestamp_secs, or null if no panic context is available\n *\n * @example\n * ```typescript\n * import { extractFile, getLastPanicContext } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   const context = getLastPanicContext();\n *   if (context) {\n *     console.error(`Panic at ${context.file}:${context.line}`);\n *     console.error(`In function: ${context.function}`);\n *     console.error(`Message: ${context.message}`);\n *   }\n * }\n * ```\n */\nexport function getLastPanicContext(): PanicContext | null {\n\tconst binding = getBinding();\n\tconst result = binding.getLastPanicContext();\n\treturn result as unknown as PanicContext | null;\n}\n\n/**\n * Returns the human-readable name for an error code.\n *\n * Maps numeric error codes to their string names, providing a consistent way\n * to get error code names across all platforms.\n *\n * @param code - The numeric error code (0-8)\n * @returns The error code name as a string (e.g., \"validation\", \"ocr\", \"embedding\")\n *\n * @example\n * ```typescript\n * import { getErrorCodeName } from '@kreuzberg/node';\n *\n * const name = getErrorCodeName(0);  // returns \"validation\"\n * const name = getErrorCodeName(2);  // returns \"ocr\"\n * const name = getErrorCodeName(99); // returns \"unknown\"\n * ```\n */\nexport function getErrorCodeName(code: number): string {\n\tconst binding = getBinding();\n\treturn binding.getErrorCodeName(code);\n}\n\n/**\n * Returns the description for an error code.\n *\n * Retrieves user-friendly descriptions of error types from the FFI layer.\n *\n * @param code - The numeric error code (0-8)\n * @returns A brief description of the error type\n *\n * @example\n * ```typescript\n * import { getErrorCodeDescription } from '@kreuzberg/node';\n *\n * const desc = getErrorCodeDescription(0);  // returns \"Input validation error\"\n * const desc = getErrorCodeDescription(4);  // returns \"File system I/O error\"\n * const desc = getErrorCodeDescription(99); // returns \"Unknown error code\"\n * ```\n */\nexport function getErrorCodeDescription(code: number): string {\n\tconst binding = getBinding();\n\treturn binding.getErrorCodeDescription(code);\n}\n\n/**\n * Classifies an error message string into an error code category.\n *\n * This function analyzes the error message content and returns the most likely\n * error code (0-7) based on keyword patterns. Used to programmatically classify\n * errors for handling purposes.\n *\n * The classification is based on keyword matching:\n * - **Validation (0)**: Keywords like \"invalid\", \"validation\", \"schema\", \"required\"\n * - **Parsing (1)**: Keywords like \"parsing\", \"corrupted\", \"malformed\"\n * - **Ocr (2)**: Keywords like \"ocr\", \"tesseract\", \"language\", \"model\"\n * - **MissingDependency (3)**: Keywords like \"not found\", \"missing\", \"dependency\"\n * - **Io (4)**: Keywords like \"file\", \"disk\", \"read\", \"write\", \"permission\"\n * - **Plugin (5)**: Keywords like \"plugin\", \"register\", \"extension\"\n * - **UnsupportedFormat (6)**: Keywords: unsupported, format, mime\n * - **Internal (7)**: Keywords: internal, bug, panic\n * - **Embedding (8)**: Keywords: embed, embedding, vector, inference\n *\n * @param errorMessage - The error message string to classify\n * @returns An object with the classification details\n *\n * @example\n * ```typescript\n * import { classifyError } from '@kreuzberg/node';\n *\n * const result = classifyError(\"PDF file is corrupted\");\n * // Returns: { code: 1, name: \"parsing\", confidence: 0.95 }\n *\n * const result = classifyError(\"Tesseract not found\");\n * // Returns: { code: 3, name: \"missing_dependency\", confidence: 0.9 }\n * ```\n */\nexport function classifyError(errorMessage: string): ErrorClassification {\n\tconst binding = getBinding();\n\tconst result = binding.classifyError(errorMessage);\n\treturn result as unknown as ErrorClassification;\n}\n\n/**\n * Get missing dependencies information.\n *\n * Note: The native binding does not directly expose a getMissingDependencies method.\n * This function is provided for API consistency with diagnostic functionality.\n *\n * @returns Array of missing dependency names\n *\n * @throws {Error} Not implemented - use checkOcrDependencies() instead\n *\n * @deprecated Use checkOcrDependencies() or getSystemInfo() instead\n */\nexport function getMissingDependencies(): string[] {\n\tthrow new Error(\"getMissingDependencies is not directly available. Use checkOcrDependencies() instead.\");\n}\n\n/**\n * Get available OCR backends information.\n *\n * Note: The native binding does not directly expose this as a separate method.\n * Use listOcrBackends() from plugins/ocr-backends.ts instead.\n *\n * @returns Array of available OCR backend names\n *\n * @throws {Error} Not implemented - use listOcrBackends() instead\n *\n * @deprecated Use listOcrBackends() from @kreuzberg/node instead\n */\nexport function getAvailableOcrBackends(): string[] {\n\tthrow new Error(\"getAvailableOcrBackends is not directly available. Use listOcrBackends() instead.\");\n}\n\n/**\n * Check OCR dependencies.\n *\n * Note: The native binding does not directly expose dependency checking.\n * This function is provided for API consistency.\n *\n * @returns Object with OCR dependency status\n *\n * @throws {Error} Not implemented - check error codes after extraction attempts instead\n *\n * @deprecated Check error codes after extraction attempts instead\n */\nexport function checkOcrDependencies(): Record<string, unknown> {\n\tthrow new Error(\n\t\t\"checkOcrDependencies is not directly available. Check error codes after extraction attempts instead.\",\n\t);\n}\n\n/**\n * Get system information.\n *\n * Note: The native binding does not directly expose system information.\n * This function is provided for API consistency.\n *\n * @returns Object with system information\n *\n * @throws {Error} Not implemented\n *\n * @deprecated Not available in current API\n */\nexport function getSystemInfo(): Record<string, unknown> {\n\tthrow new Error(\"getSystemInfo is not available in the current API.\");\n}\n\n/**\n * Get diagnostic information.\n *\n * Note: The native binding does not directly expose comprehensive diagnostic information.\n * This function is provided for API consistency.\n *\n * @returns Object with diagnostic information\n *\n * @throws {Error} Not implemented\n *\n * @deprecated Not available in current API\n */\nexport function diagnosticInfo(): Record<string, unknown> {\n\tthrow new Error(\"diagnosticInfo is not available in the current API.\");\n}\n","/**\n * Error types for Kreuzberg document intelligence framework.\n *\n * These error classes mirror the Rust core error types and provide\n * type-safe error handling for TypeScript consumers.\n *\n * ## Error Hierarchy\n *\n * ```\n * Error (JavaScript built-in)\n *   └── KreuzbergError (base class)\n *       ├── ValidationError\n *       ├── ParsingError\n *       ├── OcrError\n *       ├── CacheError\n *       ├── ImageProcessingError\n *       ├── PluginError\n *       ├── MissingDependencyError\n *       └── ... (other error types)\n * ```\n *\n * @module errors\n */\n\n/**\n * FFI error codes matching kreuzberg-ffi C library error types.\n *\n * @example\n * ```typescript\n * import { ErrorCode, getLastErrorCode } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   const code = getLastErrorCode();\n *   if (code === ErrorCode.Panic) {\n *     console.error('A panic occurred in the native library');\n *   }\n * }\n * ```\n */\nexport enum ErrorCode {\n\t/**\n\t * No error (success)\n\t */\n\tSuccess = 0,\n\t/**\n\t * Generic error\n\t */\n\tGenericError = 1,\n\t/**\n\t * Panic occurred in native code\n\t */\n\tPanic = 2,\n\t/**\n\t * Invalid argument provided\n\t */\n\tInvalidArgument = 3,\n\t/**\n\t * I/O error (file system, network, etc.)\n\t */\n\tIoError = 4,\n\t/**\n\t * Error parsing document content\n\t */\n\tParsingError = 5,\n\t/**\n\t * Error in OCR processing\n\t */\n\tOcrError = 6,\n\t/**\n\t * Required system dependency is missing\n\t */\n\tMissingDependency = 7,\n\t/**\n\t * Error during embedding generation\n\t */\n\tEmbedding = 8,\n}\n\n/**\n * Context information for panics in native code.\n *\n * Contains file location, line number, function name, panic message,\n * and timestamp for debugging native library issues.\n *\n * @example\n * ```typescript\n * import { KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   if (error instanceof KreuzbergError && error.panicContext) {\n *     console.error('Panic occurred:');\n *     console.error(`File: ${error.panicContext.file}`);\n *     console.error(`Line: ${error.panicContext.line}`);\n *     console.error(`Function: ${error.panicContext.function}`);\n *     console.error(`Message: ${error.panicContext.message}`);\n *   }\n * }\n * ```\n */\nexport interface PanicContext {\n\t/**\n\t * Source file where panic occurred\n\t */\n\tfile: string;\n\t/**\n\t * Line number in source file\n\t */\n\tline: number;\n\t/**\n\t * Function name where panic occurred\n\t */\n\tfunction: string;\n\t/**\n\t * Panic message\n\t */\n\tmessage: string;\n\t/**\n\t * Unix timestamp (seconds since epoch)\n\t */\n\ttimestamp_secs: number;\n}\n\n/**\n * Base error class for all Kreuzberg errors.\n *\n * All error types thrown by Kreuzberg extend this class, allowing\n * consumers to catch all Kreuzberg-specific errors with a single catch block.\n *\n * @example\n * ```typescript\n * import { extractFile, KreuzbergError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   if (error instanceof KreuzbergError) {\n *     console.error('Kreuzberg error:', error.message);\n *     if (error.panicContext) {\n *       console.error('Panic at:', error.panicContext.file + ':' + error.panicContext.line);\n *     }\n *   } else {\n *     throw error; // Re-throw non-Kreuzberg errors\n *   }\n * }\n * ```\n */\nexport class KreuzbergError extends Error {\n\t/**\n\t * Panic context if error was caused by a panic in native code.\n\t * Will be null for non-panic errors.\n\t */\n\tpublic readonly panicContext: PanicContext | null;\n\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message);\n\t\tthis.name = \"KreuzbergError\";\n\t\tthis.panicContext = panicContext ?? null;\n\t\tObject.setPrototypeOf(this, KreuzbergError.prototype);\n\t}\n\n\ttoJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when document validation fails.\n *\n * Validation errors occur when a document doesn't meet specified criteria,\n * such as minimum content length, required metadata fields, or quality thresholds.\n *\n * @example\n * ```typescript\n * import { extractFile, ValidationError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   if (error instanceof ValidationError) {\n *     console.error('Document validation failed:', error.message);\n *   }\n * }\n * ```\n */\nexport class ValidationError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ValidationError\";\n\t\tObject.setPrototypeOf(this, ValidationError.prototype);\n\t}\n}\n\n/**\n * Error thrown when document parsing fails.\n *\n * Parsing errors occur when a document is corrupted, malformed, or cannot\n * be processed by the extraction engine. This includes issues like:\n * - Corrupted PDF files\n * - Invalid XML/JSON syntax\n * - Unsupported file format versions\n * - Encrypted documents without valid passwords\n *\n * @example\n * ```typescript\n * import { extractFile, ParsingError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('corrupted.pdf');\n * } catch (error) {\n *   if (error instanceof ParsingError) {\n *     console.error('Failed to parse document:', error.message);\n *   }\n * }\n * ```\n */\nexport class ParsingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ParsingError\";\n\t\tObject.setPrototypeOf(this, ParsingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when OCR processing fails.\n *\n * OCR errors occur during optical character recognition, such as:\n * - OCR backend initialization failures\n * - Image preprocessing errors\n * - Language model loading issues\n * - OCR engine crashes\n *\n * @example\n * ```typescript\n * import { extractFile, OcrError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('scanned.pdf', null, {\n *     ocr: { backend: 'tesseract', language: 'eng' }\n *   });\n * } catch (error) {\n *   if (error instanceof OcrError) {\n *     console.error('OCR processing failed:', error.message);\n *   }\n * }\n * ```\n */\nexport class OcrError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"OcrError\";\n\t\tObject.setPrototypeOf(this, OcrError.prototype);\n\t}\n}\n\n/**\n * Error thrown when cache operations fail.\n *\n * Cache errors are typically non-fatal and occur during caching operations, such as:\n * - Cache directory creation failures\n * - Disk write errors\n * - Cache entry corruption\n * - Insufficient disk space\n *\n * These errors are usually logged but don't prevent extraction from completing.\n *\n * @example\n * ```typescript\n * import { extractFile, CacheError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf', null, {\n *     useCache: true\n *   });\n * } catch (error) {\n *   if (error instanceof CacheError) {\n *     console.warn('Cache operation failed, continuing without cache:', error.message);\n *   }\n * }\n * ```\n */\nexport class CacheError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"CacheError\";\n\t\tObject.setPrototypeOf(this, CacheError.prototype);\n\t}\n}\n\n/**\n * Error thrown when image processing operations fail.\n *\n * Image processing errors occur during image manipulation, such as:\n * - Image decoding failures\n * - Unsupported image formats\n * - Image resizing/scaling errors\n * - DPI adjustment failures\n * - Color space conversion issues\n *\n * @example\n * ```typescript\n * import { extractFile, ImageProcessingError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf', null, {\n *     images: {\n *       extractImages: true,\n *       targetDpi: 300\n *     }\n *   });\n * } catch (error) {\n *   if (error instanceof ImageProcessingError) {\n *     console.error('Image processing failed:', error.message);\n *   }\n * }\n * ```\n */\nexport class ImageProcessingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"ImageProcessingError\";\n\t\tObject.setPrototypeOf(this, ImageProcessingError.prototype);\n\t}\n}\n\n/**\n * Error thrown when a plugin operation fails.\n *\n * Plugin errors occur in custom plugins (postprocessors, validators, OCR backends), such as:\n * - Plugin initialization failures\n * - Plugin processing errors\n * - Plugin crashes or timeouts\n * - Invalid plugin configuration\n *\n * The error message includes the plugin name to help identify which plugin failed.\n *\n * @example\n * ```typescript\n * import { extractFile, PluginError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   if (error instanceof PluginError) {\n *     console.error(`Plugin '${error.pluginName}' failed:`, error.message);\n *   }\n * }\n * ```\n */\nexport class PluginError extends KreuzbergError {\n\t/**\n\t * Name of the plugin that threw the error.\n\t */\n\tpublic readonly pluginName: string;\n\n\tconstructor(message: string, pluginName: string, panicContext?: PanicContext | null) {\n\t\tsuper(`Plugin error in '${pluginName}': ${message}`, panicContext);\n\t\tthis.name = \"PluginError\";\n\t\tthis.pluginName = pluginName;\n\t\tObject.setPrototypeOf(this, PluginError.prototype);\n\t}\n\n\toverride toJSON() {\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tmessage: this.message,\n\t\t\tpluginName: this.pluginName,\n\t\t\tpanicContext: this.panicContext,\n\t\t\tstack: this.stack,\n\t\t};\n\t}\n}\n\n/**\n * Error thrown when a required system dependency is missing.\n *\n * Missing dependency errors occur when external tools or libraries are not available, such as:\n * - Tesseract OCR (for OCR processing)\n * - ImageMagick (for image processing)\n * - Poppler (for PDF rendering)\n *\n * @example\n * ```typescript\n * import { extractFile, MissingDependencyError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await extractFile('document.pdf');\n * } catch (error) {\n *   if (error instanceof MissingDependencyError) {\n *     console.error('Missing dependency:', error.message);\n *     console.log('Please install Tesseract OCR for image processing');\n *   }\n * }\n * ```\n */\nexport class MissingDependencyError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"MissingDependencyError\";\n\t\tObject.setPrototypeOf(this, MissingDependencyError.prototype);\n\t}\n}\n\n/**\n * Error thrown when text embedding generation fails.\n *\n * Embedding errors occur during vector generation, such as:\n * - Model loading failures\n * - Inference engine errors\n * - Invalid input text for the selected model\n * - Resource exhaustion during batch processing\n *\n * @example\n * ```typescript\n * import { embed, EmbeddingError } from '@kreuzberg/node';\n *\n * try {\n *   const result = await embed(['hello world']);\n * } catch (error) {\n *   if (error instanceof EmbeddingError) {\n *     console.error('Embedding generation failed:', error.message);\n *   }\n * }\n * ```\n */\nexport class EmbeddingError extends KreuzbergError {\n\tconstructor(message: string, panicContext?: PanicContext | null) {\n\t\tsuper(message, panicContext);\n\t\tthis.name = \"EmbeddingError\";\n\t\tObject.setPrototypeOf(this, EmbeddingError.prototype);\n\t}\n}\n","/**\n * @internal Type assertion utilities.\n *\n * This module provides assertion functions for validating types at runtime.\n * These are pure utility functions with no dependencies on other internal modules.\n *\n * This is a Layer 0 module.\n */\n\n/**\n * Asserts that a value is a Uint8Array and returns it.\n * Throws a TypeError if the value is not a Uint8Array.\n *\n * @param value The value to validate\n * @param name The name of the parameter (used in error messages)\n * @returns The validated Uint8Array\n * @throws TypeError if value is not a Uint8Array\n * @internal\n */\nexport function assertUint8Array(value: unknown, name: string): Uint8Array {\n\tif (!(value instanceof Uint8Array)) {\n\t\tthrow new TypeError(`${name} must be a Uint8Array`);\n\t}\n\treturn value;\n}\n\n/**\n * Asserts that a value is an array of Uint8Arrays and returns it.\n * Throws a TypeError if the value is not an array or contains non-Uint8Array elements.\n *\n * @param values The value to validate\n * @param name The name of the parameter (used in error messages)\n * @returns The validated array of Uint8Arrays\n * @throws TypeError if values is not an array or contains non-Uint8Array elements\n * @internal\n */\nexport function assertUint8ArrayList(values: unknown, name: string): Uint8Array[] {\n\tif (!Array.isArray(values)) {\n\t\tthrow new TypeError(`${name} must be an array of Uint8Array`);\n\t}\n\n\tconst array = values as unknown[];\n\treturn array.map((value, index) => {\n\t\ttry {\n\t\t\treturn assertUint8Array(value, `${name}[${index}]`);\n\t\t} catch {\n\t\t\tthrow new TypeError(`${name}[${index}] must be a Uint8Array`);\n\t\t}\n\t});\n}\n\n/**\n * Assertion that should never be reached - helps with type narrowing in exhaustive checks.\n * If this function is called, it indicates a logic error in the program.\n *\n * @param value The value that should have been handled by exhaustive checks\n * @throws Error Always throws with a message about the unreachable code\n * @internal\n */\nexport function assertUnreachable(value: never): never {\n\tthrow new Error(`This code should be unreachable, but got: ${JSON.stringify(value)}`);\n}\n\n/**\n * Assertion that should never be reached - helps with type narrowing in exhaustive checks.\n * Alias for assertUnreachable - use this when you want a more semantic name.\n *\n * @param value The value that should have been handled by exhaustive checks\n * @throws Error Always throws with a message about the unreachable code\n * @internal\n */\nexport function assertNever(value: never): never {\n\tthrow new Error(`Expected code to be unreachable but got: ${JSON.stringify(value)}`);\n}\n","/**\n * Configuration normalization utilities for converting TypeScript config types\n * to native binding format.\n *\n * This module handles transformation of all extraction configuration options\n * from user-friendly TypeScript types to the format expected by the native\n * Rust binding.\n *\n * @internal This module is part of the core infrastructure layer (Layer 1).\n */\n\nimport type {\n\tChunkingConfig,\n\tExtractionConfig,\n\tHtmlConversionOptions,\n\tHtmlPreprocessingOptions,\n\tImageExtractionConfig,\n\tKeywordConfig,\n\tLanguageDetectionConfig,\n\tLayoutDetectionConfig,\n\tOcrConfig,\n\tPageExtractionConfig,\n\tPdfConfig,\n\tPostProcessorConfig,\n\tTesseractConfig,\n\tTokenReductionConfig,\n} from \"../types.js\";\n\n/**\n * Native extraction config type used internally for native binding calls.\n * @internal\n */\ntype NativeExtractionConfig = Record<string, unknown>;\n\n/**\n * Selectively set a property on the target object if the value is defined.\n * Used to avoid explicitly setting undefined values in config objects.\n *\n * @param target - Target object to set property on\n * @param key - Property key\n * @param value - Value to set (if defined)\n * @internal\n */\nfunction setIfDefined<T>(target: NativeExtractionConfig, key: string, value: T | undefined): void {\n\tif (value !== undefined) {\n\t\ttarget[key] = value;\n\t}\n}\n\n/**\n * Normalize Tesseract OCR configuration.\n *\n * @param config - Tesseract configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeTesseractConfig(config?: TesseractConfig) {\n\tif (!config) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"psm\", config.psm);\n\tsetIfDefined(normalized, \"enableTableDetection\", config.enableTableDetection);\n\tsetIfDefined(normalized, \"tesseditCharWhitelist\", config.tesseditCharWhitelist);\n\treturn normalized;\n}\n\n/**\n * Normalize OCR backend configuration.\n *\n * @param ocr - OCR configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeOcrConfig(ocr?: OcrConfig): NativeExtractionConfig | undefined {\n\tif (!ocr) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {\n\t\tbackend: ocr.backend,\n\t};\n\tsetIfDefined(normalized, \"language\", ocr.language);\n\n\tconst tesseract = normalizeTesseractConfig(ocr.tesseractConfig);\n\tif (tesseract) {\n\t\tsetIfDefined(normalized, \"tesseractConfig\", tesseract);\n\t}\n\n\tsetIfDefined(normalized, \"paddleOcrConfig\", ocr.paddleOcrConfig);\n\tsetIfDefined(normalized, \"elementConfig\", ocr.elementConfig);\n\n\treturn normalized;\n}\n\n/**\n * Normalize chunking configuration.\n *\n * @param chunking - Chunking configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeChunkingConfig(chunking?: ChunkingConfig): NativeExtractionConfig | undefined {\n\tif (!chunking) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"maxChars\", chunking.maxChars);\n\tsetIfDefined(normalized, \"maxOverlap\", chunking.maxOverlap);\n\tsetIfDefined(normalized, \"preset\", chunking.preset);\n\tsetIfDefined(normalized, \"embedding\", chunking.embedding);\n\tsetIfDefined(normalized, \"enabled\", chunking.enabled);\n\tsetIfDefined(normalized, \"sizingType\", chunking.sizingType);\n\tsetIfDefined(normalized, \"sizingModel\", chunking.sizingModel);\n\tsetIfDefined(normalized, \"sizingCacheDir\", chunking.sizingCacheDir);\n\treturn normalized;\n}\n\n/**\n * Normalize image extraction configuration.\n *\n * @param images - Image extraction configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeImageExtractionConfig(images?: ImageExtractionConfig): NativeExtractionConfig | undefined {\n\tif (!images) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"extractImages\", images.extractImages);\n\tsetIfDefined(normalized, \"targetDpi\", images.targetDpi);\n\tsetIfDefined(normalized, \"maxImageDimension\", images.maxImageDimension);\n\tsetIfDefined(normalized, \"autoAdjustDpi\", images.autoAdjustDpi);\n\tsetIfDefined(normalized, \"minDpi\", images.minDpi);\n\tsetIfDefined(normalized, \"maxDpi\", images.maxDpi);\n\treturn normalized;\n}\n\n/**\n * Normalize PDF-specific configuration.\n *\n * @param pdf - PDF configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizePdfConfig(pdf?: PdfConfig): NativeExtractionConfig | undefined {\n\tif (!pdf) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"extractImages\", pdf.extractImages);\n\tsetIfDefined(normalized, \"passwords\", pdf.passwords);\n\tsetIfDefined(normalized, \"extractMetadata\", pdf.extractMetadata);\n\tsetIfDefined(normalized, \"hierarchy\", pdf.hierarchy);\n\tsetIfDefined(normalized, \"extractAnnotations\", pdf.extractAnnotations);\n\tsetIfDefined(normalized, \"topMarginFraction\", pdf.topMarginFraction);\n\tsetIfDefined(normalized, \"bottomMarginFraction\", pdf.bottomMarginFraction);\n\treturn normalized;\n}\n\n/**\n * Normalize token reduction configuration.\n *\n * @param tokenReduction - Token reduction configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeTokenReductionConfig(tokenReduction?: TokenReductionConfig): NativeExtractionConfig | undefined {\n\tif (!tokenReduction) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"mode\", tokenReduction.mode);\n\tsetIfDefined(normalized, \"preserveImportantWords\", tokenReduction.preserveImportantWords);\n\treturn normalized;\n}\n\n/**\n * Normalize language detection configuration.\n *\n * @param languageDetection - Language detection configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeLanguageDetectionConfig(\n\tlanguageDetection?: LanguageDetectionConfig,\n): NativeExtractionConfig | undefined {\n\tif (!languageDetection) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"enabled\", languageDetection.enabled);\n\tsetIfDefined(normalized, \"minConfidence\", languageDetection.minConfidence);\n\tsetIfDefined(normalized, \"detectMultiple\", languageDetection.detectMultiple);\n\treturn normalized;\n}\n\n/**\n * Normalize post-processor configuration.\n *\n * @param postprocessor - Post-processor configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizePostProcessorConfig(postprocessor?: PostProcessorConfig): NativeExtractionConfig | undefined {\n\tif (!postprocessor) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"enabled\", postprocessor.enabled);\n\tsetIfDefined(normalized, \"enabledProcessors\", postprocessor.enabledProcessors);\n\tsetIfDefined(normalized, \"disabledProcessors\", postprocessor.disabledProcessors);\n\treturn normalized;\n}\n\n/**\n * Normalize HTML preprocessing options.\n *\n * @param options - HTML preprocessing options\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeHtmlPreprocessing(options?: HtmlPreprocessingOptions): NativeExtractionConfig | undefined {\n\tif (!options) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"enabled\", options.enabled);\n\tsetIfDefined(normalized, \"preset\", options.preset);\n\tsetIfDefined(normalized, \"removeNavigation\", options.removeNavigation);\n\tsetIfDefined(normalized, \"removeForms\", options.removeForms);\n\treturn normalized;\n}\n\n/**\n * Normalize HTML conversion options.\n * Includes nested preprocessing configuration.\n *\n * @param options - HTML conversion options\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeHtmlOptions(options?: HtmlConversionOptions): NativeExtractionConfig | undefined {\n\tif (!options) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"headingStyle\", options.headingStyle);\n\tsetIfDefined(normalized, \"listIndentType\", options.listIndentType);\n\tsetIfDefined(normalized, \"listIndentWidth\", options.listIndentWidth);\n\tsetIfDefined(normalized, \"bullets\", options.bullets);\n\tsetIfDefined(normalized, \"strongEmSymbol\", options.strongEmSymbol);\n\tsetIfDefined(normalized, \"escapeAsterisks\", options.escapeAsterisks);\n\tsetIfDefined(normalized, \"escapeUnderscores\", options.escapeUnderscores);\n\tsetIfDefined(normalized, \"escapeMisc\", options.escapeMisc);\n\tsetIfDefined(normalized, \"escapeAscii\", options.escapeAscii);\n\tsetIfDefined(normalized, \"codeLanguage\", options.codeLanguage);\n\tsetIfDefined(normalized, \"autolinks\", options.autolinks);\n\tsetIfDefined(normalized, \"defaultTitle\", options.defaultTitle);\n\tsetIfDefined(normalized, \"brInTables\", options.brInTables);\n\tsetIfDefined(normalized, \"hocrSpatialTables\", options.hocrSpatialTables);\n\tsetIfDefined(normalized, \"highlightStyle\", options.highlightStyle);\n\tsetIfDefined(normalized, \"extractMetadata\", options.extractMetadata);\n\tsetIfDefined(normalized, \"whitespaceMode\", options.whitespaceMode);\n\tsetIfDefined(normalized, \"stripNewlines\", options.stripNewlines);\n\tsetIfDefined(normalized, \"wrap\", options.wrap);\n\tsetIfDefined(normalized, \"wrapWidth\", options.wrapWidth);\n\tsetIfDefined(normalized, \"convertAsInline\", options.convertAsInline);\n\tsetIfDefined(normalized, \"subSymbol\", options.subSymbol);\n\tsetIfDefined(normalized, \"supSymbol\", options.supSymbol);\n\tsetIfDefined(normalized, \"newlineStyle\", options.newlineStyle);\n\tsetIfDefined(normalized, \"codeBlockStyle\", options.codeBlockStyle);\n\tsetIfDefined(normalized, \"keepInlineImagesIn\", options.keepInlineImagesIn);\n\tsetIfDefined(normalized, \"encoding\", options.encoding);\n\tsetIfDefined(normalized, \"debug\", options.debug);\n\tsetIfDefined(normalized, \"stripTags\", options.stripTags);\n\tsetIfDefined(normalized, \"preserveTags\", options.preserveTags);\n\n\tconst preprocessing = normalizeHtmlPreprocessing(options.preprocessing);\n\tsetIfDefined(normalized, \"preprocessing\", preprocessing);\n\n\treturn normalized;\n}\n\n/**\n * Normalize keyword extraction configuration.\n *\n * @param config - Keyword configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizeKeywordConfig(config?: KeywordConfig): NativeExtractionConfig | undefined {\n\tif (!config) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"algorithm\", config.algorithm);\n\tsetIfDefined(normalized, \"maxKeywords\", config.maxKeywords);\n\tsetIfDefined(normalized, \"minScore\", config.minScore);\n\tsetIfDefined(normalized, \"ngramRange\", config.ngramRange);\n\tsetIfDefined(normalized, \"language\", config.language);\n\tsetIfDefined(normalized, \"yakeParams\", config.yakeParams);\n\tsetIfDefined(normalized, \"rakeParams\", config.rakeParams);\n\treturn normalized;\n}\n\n/**\n * Normalize page extraction configuration.\n *\n * @param pages - Page extraction configuration\n * @returns Normalized config object or undefined\n * @internal\n */\nfunction normalizePageConfig(pages?: PageExtractionConfig): NativeExtractionConfig | undefined {\n\tif (!pages) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"extractPages\", pages.extractPages);\n\tsetIfDefined(normalized, \"insertPageMarkers\", pages.insertPageMarkers);\n\tsetIfDefined(normalized, \"markerFormat\", pages.markerFormat);\n\treturn normalized;\n}\n\n/**\n * Master orchestrator for normalizing the complete extraction configuration.\n * Calls all specific normalizers and aggregates results into a single config object\n * suitable for passing to the native binding.\n *\n * @param config - Complete extraction configuration\n * @returns Normalized config object or null if input is null\n * @internal\n */\nfunction normalizeExtractionConfig(config: ExtractionConfig | null): NativeExtractionConfig | null {\n\tif (!config) {\n\t\treturn null;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"useCache\", config.useCache);\n\tsetIfDefined(normalized, \"enableQualityProcessing\", config.enableQualityProcessing);\n\tsetIfDefined(normalized, \"forceOcr\", config.forceOcr);\n\tsetIfDefined(normalized, \"includeDocumentStructure\", config.includeDocumentStructure);\n\tsetIfDefined(normalized, \"maxConcurrentExtractions\", config.maxConcurrentExtractions);\n\n\tconst ocr = normalizeOcrConfig(config.ocr);\n\tsetIfDefined(normalized, \"ocr\", ocr);\n\n\tconst chunking = normalizeChunkingConfig(config.chunking);\n\tsetIfDefined(normalized, \"chunking\", chunking);\n\n\tconst images = normalizeImageExtractionConfig(config.images);\n\tsetIfDefined(normalized, \"images\", images);\n\n\tconst pdf = normalizePdfConfig(config.pdfOptions);\n\tsetIfDefined(normalized, \"pdfOptions\", pdf);\n\n\tconst tokenReduction = normalizeTokenReductionConfig(config.tokenReduction);\n\tsetIfDefined(normalized, \"tokenReduction\", tokenReduction);\n\n\tconst languageDetection = normalizeLanguageDetectionConfig(config.languageDetection);\n\tsetIfDefined(normalized, \"languageDetection\", languageDetection);\n\n\tconst postprocessor = normalizePostProcessorConfig(config.postprocessor);\n\tsetIfDefined(normalized, \"postprocessor\", postprocessor);\n\n\tconst keywords = normalizeKeywordConfig(config.keywords);\n\tsetIfDefined(normalized, \"keywords\", keywords);\n\n\tconst pages = normalizePageConfig(config.pages);\n\tsetIfDefined(normalized, \"pages\", pages);\n\n\tconst htmlOptions = normalizeHtmlOptions(config.htmlOptions);\n\tsetIfDefined(normalized, \"htmlOptions\", htmlOptions);\n\n\tconst layout = normalizeLayoutDetectionConfig(config.layout);\n\tsetIfDefined(normalized, \"layout\", layout);\n\n\tsetIfDefined(normalized, \"outputFormat\", config.outputFormat);\n\tsetIfDefined(normalized, \"resultFormat\", config.resultFormat);\n\n\treturn normalized;\n}\n\n/**\n * Normalize layout detection configuration.\n */\nfunction normalizeLayoutDetectionConfig(config?: LayoutDetectionConfig): NativeExtractionConfig | undefined {\n\tif (!config) {\n\t\treturn undefined;\n\t}\n\n\tconst normalized: NativeExtractionConfig = {};\n\tsetIfDefined(normalized, \"preset\", config.preset);\n\tsetIfDefined(normalized, \"confidenceThreshold\", config.confidenceThreshold);\n\tsetIfDefined(normalized, \"applyHeuristics\", config.applyHeuristics);\n\tsetIfDefined(normalized, \"tableModel\", config.tableModel);\n\treturn normalized;\n}\n\n/**\n * Export public normalization functions for use by extraction modules.\n */\nexport {\n\tnormalizeChunkingConfig,\n\tnormalizeExtractionConfig,\n\tnormalizeHtmlOptions,\n\tnormalizeHtmlPreprocessing,\n\tnormalizeImageExtractionConfig,\n\tnormalizeKeywordConfig,\n\tnormalizeLanguageDetectionConfig,\n\tnormalizeLayoutDetectionConfig,\n\tnormalizeOcrConfig,\n\tnormalizePageConfig,\n\tnormalizePdfConfig,\n\tnormalizePostProcessorConfig,\n\tnormalizeTesseractConfig,\n\tnormalizeTokenReductionConfig,\n\tsetIfDefined,\n};\n","/**\n * Type conversion utilities for transforming native binding results to TypeScript types.\n *\n * This module handles conversion from raw native binding objects to strongly-typed\n * TypeScript structures, including metadata parsing and fallback value handling.\n *\n * @internal This module is part of the core infrastructure layer (Layer 1).\n */\n\nimport type {\n\tBoundingBox,\n\tChunk,\n\tElement,\n\tElementType,\n\tExtractedImage,\n\tExtractionResult,\n\tPageContent,\n\tTable,\n} from \"../types.js\";\n\n/**\n * Parse metadata JSON string to a record object.\n * Returns an empty object if parsing fails or input is not a string.\n *\n * @param metadataStr - JSON string to parse\n * @returns Parsed metadata object or empty record\n * @internal\n */\nfunction parseMetadata(metadataStr: string): Record<string, unknown> {\n\ttry {\n\t\tconst parsed = JSON.parse(metadataStr) as unknown;\n\t\tif (typeof parsed === \"object\" && parsed !== null) {\n\t\t\treturn parsed as Record<string, unknown>;\n\t\t}\n\t\treturn {};\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n/**\n * Ensure a value is a Uint8Array, converting from Buffer or Array if needed.\n * Returns an empty Uint8Array if conversion fails.\n *\n * @param value - Value to convert\n * @returns Uint8Array instance\n * @internal\n */\nfunction ensureUint8Array(value: unknown): Uint8Array {\n\tif (value instanceof Uint8Array) {\n\t\treturn value;\n\t}\n\tif (typeof Buffer !== \"undefined\" && value instanceof Buffer) {\n\t\treturn new Uint8Array(value);\n\t}\n\tif (Array.isArray(value)) {\n\t\treturn new Uint8Array(value);\n\t}\n\treturn new Uint8Array();\n}\n\n/**\n * Convert raw chunk object from native binding to typed Chunk.\n *\n * @param rawChunk - Raw chunk object from native binding\n * @returns Typed Chunk object\n * @internal\n */\nfunction convertChunk(rawChunk: unknown): Chunk {\n\tif (!rawChunk || typeof rawChunk !== \"object\") {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tchunkType: null,\n\t\t\tmetadata: {\n\t\t\t\tbyteStart: 0,\n\t\t\t\tbyteEnd: 0,\n\t\t\t\ttokenCount: null,\n\t\t\t\tchunkIndex: 0,\n\t\t\t\ttotalChunks: 0,\n\t\t\t},\n\t\t\tembedding: null,\n\t\t};\n\t}\n\n\tconst chunk = rawChunk as Record<string, unknown>;\n\tconst metadata = (chunk[\"metadata\"] as Record<string, unknown>) ?? {};\n\treturn {\n\t\tcontent: (chunk[\"content\"] as string) ?? \"\",\n\t\tchunkType: ((chunk[\"chunk_type\"] ?? chunk[\"chunkType\"]) as string | null) ?? null,\n\t\tembedding: (chunk[\"embedding\"] as number[] | null) ?? null,\n\t\tmetadata: {\n\t\t\tbyteStart: ((metadata[\"byte_start\"] ?? metadata[\"charStart\"]) as number) ?? 0,\n\t\t\tbyteEnd: ((metadata[\"byte_end\"] ?? metadata[\"charEnd\"]) as number) ?? 0,\n\t\t\ttokenCount: ((metadata[\"token_count\"] ?? metadata[\"tokenCount\"]) as number | null) ?? null,\n\t\t\tchunkIndex: ((metadata[\"chunk_index\"] ?? metadata[\"chunkIndex\"]) as number) ?? 0,\n\t\t\ttotalChunks: ((metadata[\"total_chunks\"] ?? metadata[\"totalChunks\"]) as number) ?? 0,\n\t\t\tfirstPage: ((metadata[\"first_page\"] ?? metadata[\"firstPage\"]) as number | null) ?? null,\n\t\t\tlastPage: ((metadata[\"last_page\"] ?? metadata[\"lastPage\"]) as number | null) ?? null,\n\t\t\theadingContext: (() => {\n\t\t\t\tconst hc = (metadata[\"heading_context\"] ?? metadata[\"headingContext\"]) as\n\t\t\t\t\t| Record<string, unknown>\n\t\t\t\t\t| null\n\t\t\t\t\t| undefined;\n\t\t\t\tif (!hc) return null;\n\t\t\t\tconst headings = hc[\"headings\"];\n\t\t\t\tif (!Array.isArray(headings)) return null;\n\t\t\t\treturn {\n\t\t\t\t\theadings: headings.map((h: unknown) => {\n\t\t\t\t\t\tconst heading = h as Record<string, unknown>;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tlevel: (heading[\"level\"] as number) ?? 0,\n\t\t\t\t\t\t\ttext: (heading[\"text\"] as string) ?? \"\",\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t};\n\t\t\t})(),\n\t\t},\n\t};\n}\n\n/**\n * Convert raw element object from native binding to typed Element.\n *\n * @param rawElement - Raw element object from native binding\n * @returns Typed Element object\n * @internal\n */\nfunction convertElement(rawElement: unknown): Element {\n\tif (!rawElement || typeof rawElement !== \"object\") {\n\t\treturn {\n\t\t\telementId: \"\",\n\t\t\telementType: \"narrative_text\",\n\t\t\ttext: \"\",\n\t\t\tmetadata: {},\n\t\t};\n\t}\n\n\tconst element = rawElement as Record<string, unknown>;\n\tconst elementMetadata = (element[\"metadata\"] as Record<string, unknown>) ?? {};\n\n\treturn {\n\t\telementId: (element[\"element_id\"] ?? element[\"elementId\"] ?? \"\") as string,\n\t\telementType: (element[\"element_type\"] ?? element[\"elementType\"] ?? \"narrative_text\") as ElementType,\n\t\ttext: (element[\"text\"] as string) ?? \"\",\n\t\tmetadata: {\n\t\t\tpageNumber: ((elementMetadata[\"page_number\"] ?? elementMetadata[\"pageNumber\"]) as number | null) ?? null,\n\t\t\tfilename: (elementMetadata[\"filename\"] as string | null) ?? null,\n\t\t\tcoordinates: elementMetadata[\"coordinates\"] ? (elementMetadata[\"coordinates\"] as BoundingBox) : null,\n\t\t\telementIndex: ((elementMetadata[\"element_index\"] ?? elementMetadata[\"elementIndex\"]) as number | null) ?? null,\n\t\t\tadditional: (elementMetadata[\"additional\"] as Record<string, string>) ?? {},\n\t\t},\n\t};\n}\n\n/**\n * Convert raw image object from native binding to typed ExtractedImage.\n *\n * @param rawImage - Raw image object from native binding\n * @returns Typed ExtractedImage object\n * @internal\n */\nfunction convertImage(rawImage: unknown): ExtractedImage {\n\tif (!rawImage || typeof rawImage !== \"object\") {\n\t\treturn {\n\t\t\tdata: new Uint8Array(),\n\t\t\tformat: \"unknown\",\n\t\t\timageIndex: 0,\n\t\t\tpageNumber: null,\n\t\t\twidth: null,\n\t\t\theight: null,\n\t\t\tcolorspace: null,\n\t\t\tbitsPerComponent: null,\n\t\t\tisMask: false,\n\t\t\tdescription: null,\n\t\t\tocrResult: null,\n\t\t};\n\t}\n\n\tconst image = rawImage as Record<string, unknown>;\n\treturn {\n\t\tdata: ensureUint8Array(image[\"data\"]),\n\t\tformat: (image[\"format\"] as string) ?? \"unknown\",\n\t\timageIndex: (image[\"imageIndex\"] as number) ?? 0,\n\t\tpageNumber: (image[\"pageNumber\"] as number | null) ?? null,\n\t\twidth: (image[\"width\"] as number | null) ?? null,\n\t\theight: (image[\"height\"] as number | null) ?? null,\n\t\tcolorspace: (image[\"colorspace\"] as string | null) ?? null,\n\t\tbitsPerComponent: (image[\"bitsPerComponent\"] as number | null) ?? null,\n\t\tisMask: (image[\"isMask\"] as boolean) ?? false,\n\t\tdescription: (image[\"description\"] as string | null) ?? null,\n\t\tocrResult: image[\"ocrResult\"] ? convertResult(image[\"ocrResult\"]) : null,\n\t};\n}\n\n/**\n * Convert raw page object from native binding to typed PageContent.\n *\n * @param rawPage - Raw page object from native binding\n * @returns Typed PageContent object\n * @internal\n */\nfunction convertPageContent(rawPage: unknown): PageContent {\n\tif (!rawPage || typeof rawPage !== \"object\") {\n\t\treturn {\n\t\t\tpageNumber: 0,\n\t\t\tcontent: \"\",\n\t\t\ttables: [],\n\t\t\timages: [],\n\t\t};\n\t}\n\n\tconst page = rawPage as Record<string, unknown>;\n\treturn {\n\t\tpageNumber: (page[\"pageNumber\"] as number) ?? 0,\n\t\tcontent: (page[\"content\"] as string) ?? \"\",\n\t\ttables: Array.isArray(page[\"tables\"]) ? (page[\"tables\"] as Table[]) : [],\n\t\timages: Array.isArray(page[\"images\"]) ? (page[\"images\"] as unknown[]).map((image) => convertImage(image)) : [],\n\t\tisBlank: (page[\"isBlank\"] as boolean | null | undefined) ?? null,\n\t};\n}\n\n/**\n * Convert raw result object from native binding to typed ExtractionResult.\n * Handles metadata parsing, array conversions, and nested structure conversion.\n *\n * @param rawResult - Raw result object from native binding\n * @returns Typed ExtractionResult object\n * @internal\n */\nfunction convertResult(rawResult: unknown): ExtractionResult {\n\tif (!rawResult || typeof rawResult !== \"object\") {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tmimeType: \"application/octet-stream\",\n\t\t\tmetadata: {},\n\t\t\ttables: [],\n\t\t\tdetectedLanguages: null,\n\t\t\tchunks: null,\n\t\t\timages: null,\n\t\t\telements: null,\n\t\t\tpages: null,\n\t\t\tdocument: null,\n\t\t};\n\t}\n\n\tconst result = rawResult as Record<string, unknown>;\n\tconst metadata = result[\"metadata\"];\n\tconst metadataValue =\n\t\ttypeof metadata === \"string\" ? parseMetadata(metadata) : ((metadata as Record<string, unknown>) ?? {});\n\n\tconst returnObj: ExtractionResult = {\n\t\tcontent: (result[\"content\"] as string) ?? \"\",\n\t\tmimeType: (result[\"mimeType\"] as string) ?? \"application/octet-stream\",\n\t\tmetadata: metadataValue,\n\t\ttables: Array.isArray(result[\"tables\"]) ? (result[\"tables\"] as Table[]) : [],\n\t\tdetectedLanguages: Array.isArray(result[\"detectedLanguages\"]) ? (result[\"detectedLanguages\"] as string[]) : null,\n\t\tchunks: null,\n\t\timages: null,\n\t\telements: null,\n\t\tpages: null,\n\t\tdocument: (result[\"document\"] as Record<string, unknown> | null) ?? null,\n\t};\n\n\tconst chunksData = result[\"chunks\"];\n\tif (Array.isArray(chunksData)) {\n\t\treturnObj.chunks = (chunksData as unknown[]).map((chunk) => convertChunk(chunk));\n\t}\n\n\tconst imagesData = result[\"images\"];\n\tif (Array.isArray(imagesData)) {\n\t\treturnObj.images = (imagesData as unknown[]).map((image) => convertImage(image));\n\t}\n\n\tconst elementsData = result[\"elements\"];\n\tif (Array.isArray(elementsData)) {\n\t\treturnObj.elements = (elementsData as unknown[]).map((element) => convertElement(element));\n\t}\n\n\tconst pagesData = result[\"pages\"];\n\tif (Array.isArray(pagesData)) {\n\t\treturnObj.pages = (pagesData as unknown[]).map((page) => convertPageContent(page));\n\t}\n\n\tconst ocrElementsData = result[\"ocrElements\"];\n\tif (Array.isArray(ocrElementsData)) {\n\t\treturnObj.ocrElements = ocrElementsData as import(\"../types.js\").OcrElement[];\n\t}\n\n\tconst extractedKeywordsData = result[\"extractedKeywords\"];\n\tif (Array.isArray(extractedKeywordsData)) {\n\t\treturnObj.extractedKeywords = extractedKeywordsData as import(\"../types.js\").ExtractedKeyword[];\n\t}\n\n\tconst qualityScoreData = result[\"qualityScore\"];\n\tif (typeof qualityScoreData === \"number\") {\n\t\treturnObj.qualityScore = qualityScoreData;\n\t}\n\n\tconst processingWarningsData = result[\"processingWarnings\"];\n\tif (Array.isArray(processingWarningsData)) {\n\t\treturnObj.processingWarnings = processingWarningsData as Array<{ source: string; message: string }>;\n\t}\n\n\tconst annotationsData = result[\"annotations\"];\n\tif (Array.isArray(annotationsData)) {\n\t\treturnObj.annotations = annotationsData as import(\"../types.js\").PdfAnnotation[];\n\t}\n\n\treturn returnObj;\n}\n\n/**\n * Export public conversion functions for use by extraction modules.\n */\nexport {\n\tconvertChunk,\n\tconvertElement,\n\tconvertImage,\n\tconvertPageContent,\n\tconvertResult,\n\tensureUint8Array,\n\tparseMetadata,\n};\n","/**\n * Batch extraction APIs for processing multiple documents.\n *\n * This module provides synchronous and asynchronous functions for extracting content\n * from multiple files or byte arrays in parallel. Batch operations offer better\n * performance and memory management compared to calling single extraction functions\n * in a loop.\n *\n * **Benefits of Batch Processing**:\n * - Parallel processing in Rust for maximum performance\n * - Optimized memory usage across all extractions\n * - More reliable for large-scale document processing\n *\n * @internal This module is part of Layer 2 (extraction APIs).\n */\n\nimport { assertUint8ArrayList } from \"../core/assertions.js\";\nimport { getBinding } from \"../core/binding.js\";\nimport { normalizeExtractionConfig } from \"../core/config-normalizer.js\";\nimport { convertResult } from \"../core/type-converters.js\";\nimport type { ExtractionConfig, ExtractionResult } from \"../types.js\";\n\n/**\n * Extract content from multiple files in parallel (synchronous).\n *\n * **Recommended for**: Processing multiple documents efficiently with better\n * performance and memory management compared to individual `extractFileSync()` calls.\n *\n * **Benefits**:\n * - Parallel processing in Rust for maximum performance\n * - Optimized memory usage across all extractions\n * - More reliable for batch document processing\n *\n * @param paths - List of file paths to extract (absolute or relative paths)\n * @param config - Extraction configuration object. If null, uses default extraction settings.\n * @returns Array of ExtractionResults (one per file, in same order as input)\n * @throws {Error} If any file cannot be read or parsed\n * @throws {ParsingError} When any document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When any extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { batchExtractFilesSync } from '@kreuzberg/node';\n *\n * const files = ['doc1.pdf', 'doc2.docx', 'doc3.xlsx'];\n * const results = batchExtractFilesSync(files);\n *\n * results.forEach((result, i) => {\n *   console.log(`File ${files[i]}: ${result.content.substring(0, 100)}...`);\n * });\n * ```\n */\nexport function batchExtractFilesSync(paths: string[], config: ExtractionConfig | null = null): ExtractionResult[] {\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResults = getBinding().batchExtractFilesSync(paths, normalizedConfig);\n\treturn rawResults.map(convertResult);\n}\n\n/**\n * Extract content from multiple files in parallel (asynchronous).\n *\n * **Recommended for**: Processing multiple documents efficiently with better\n * performance and memory management compared to individual `extractFile()` calls.\n *\n * **Benefits**:\n * - Parallel processing in Rust for maximum performance\n * - Optimized memory usage across all extractions\n * - More reliable for batch document processing\n *\n * @param paths - List of file paths to extract (absolute or relative paths)\n * @param config - Extraction configuration object. If null, uses default extraction settings.\n * @returns Promise resolving to array of ExtractionResults (one per file, in same order as input)\n * @throws {Error} If any file cannot be read or parsed\n * @throws {ParsingError} When any document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When any extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { batchExtractFiles } from '@kreuzberg/node';\n *\n * const files = ['invoice1.pdf', 'invoice2.pdf', 'invoice3.pdf'];\n * const results = await batchExtractFiles(files, {\n *   ocr: { backend: 'tesseract', language: 'eng' }\n * });\n *\n * // Process all results\n * const totalAmount = results\n *   .map(r => extractAmount(r.content))\n *   .reduce((a, b) => a + b, 0);\n * ```\n */\nexport async function batchExtractFiles(\n\tpaths: string[],\n\tconfig: ExtractionConfig | null = null,\n): Promise<ExtractionResult[]> {\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResults = await getBinding().batchExtractFiles(paths, normalizedConfig);\n\treturn rawResults.map(convertResult);\n}\n\n/**\n * Extract content from multiple byte arrays in parallel (synchronous).\n *\n * **Recommended for**: Processing multiple documents from memory efficiently with better\n * performance and memory management compared to individual `extractBytesSync()` calls.\n *\n * **Benefits**:\n * - Parallel processing in Rust for maximum performance\n * - Optimized memory usage across all extractions\n * - More reliable for batch document processing\n *\n * @param dataList - List of file contents as Uint8Arrays (must be same length as mimeTypes)\n * @param mimeTypes - List of MIME types (one per data item, required for accurate format detection)\n * @param config - Extraction configuration object. If null, uses default extraction settings.\n * @returns Array of ExtractionResults (one per data item, in same order as input)\n * @throws {TypeError} When dataList contains non-Uint8Array items or length mismatch with mimeTypes\n * @throws {Error} If any data cannot be read or parsed\n * @throws {ParsingError} When any document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When any extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { batchExtractBytesSync } from '@kreuzberg/node';\n * import { readFileSync } from 'fs';\n *\n * const files = ['doc1.pdf', 'doc2.docx', 'doc3.xlsx'];\n * const dataList = files.map(f => readFileSync(f));\n * const mimeTypes = ['application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];\n *\n * const results = batchExtractBytesSync(dataList, mimeTypes);\n * results.forEach((result, i) => {\n *   console.log(`File ${files[i]}: ${result.content.substring(0, 100)}...`);\n * });\n * ```\n */\nexport function batchExtractBytesSync(\n\tdataList: Uint8Array[],\n\tmimeTypes: string[],\n\tconfig: ExtractionConfig | null = null,\n): ExtractionResult[] {\n\tconst buffers = assertUint8ArrayList(dataList, \"dataList\").map((data) => Buffer.from(data));\n\n\tif (buffers.length !== mimeTypes.length) {\n\t\tthrow new TypeError(\"dataList and mimeTypes must have the same length\");\n\t}\n\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResults = getBinding().batchExtractBytesSync(buffers, mimeTypes, normalizedConfig);\n\treturn rawResults.map(convertResult);\n}\n\n/**\n * Extract content from multiple byte arrays in parallel (asynchronous).\n *\n * **Recommended for**: Processing multiple documents from memory efficiently with better\n * performance and memory management compared to individual `extractBytes()` calls.\n *\n * **Benefits**:\n * - Parallel processing in Rust for maximum performance\n * - Optimized memory usage across all extractions\n * - More reliable for batch document processing\n *\n * @param dataList - List of file contents as Uint8Arrays (must be same length as mimeTypes)\n * @param mimeTypes - List of MIME types (one per data item, required for accurate format detection)\n * @param config - Extraction configuration object. If null, uses default extraction settings.\n * @returns Promise resolving to array of ExtractionResults (one per data item, in same order as input)\n * @throws {TypeError} When dataList contains non-Uint8Array items or length mismatch with mimeTypes\n * @throws {Error} If any data cannot be read or parsed\n * @throws {ParsingError} When any document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When any extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { batchExtractBytes } from '@kreuzberg/node';\n * import { readFile } from 'fs/promises';\n *\n * const files = ['invoice1.pdf', 'invoice2.pdf', 'invoice3.pdf'];\n * const dataList = await Promise.all(files.map(f => readFile(f)));\n * const mimeTypes = files.map(() => 'application/pdf');\n *\n * const results = await batchExtractBytes(dataList, mimeTypes, {\n *   ocr: { backend: 'tesseract', language: 'eng' }\n * });\n *\n * // Process all results\n * const totalAmount = results\n *   .map(r => extractAmount(r.content))\n *   .reduce((a, b) => a + b, 0);\n * ```\n */\nexport async function batchExtractBytes(\n\tdataList: Uint8Array[],\n\tmimeTypes: string[],\n\tconfig: ExtractionConfig | null = null,\n): Promise<ExtractionResult[]> {\n\tconst buffers = assertUint8ArrayList(dataList, \"dataList\").map((data) => Buffer.from(data));\n\n\tif (buffers.length !== mimeTypes.length) {\n\t\tthrow new TypeError(\"dataList and mimeTypes must have the same length\");\n\t}\n\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResults = await getBinding().batchExtractBytes(buffers, mimeTypes, normalizedConfig);\n\treturn rawResults.map(convertResult);\n}\n","/**\n * PDF page rendering functions.\n *\n * Render individual PDF pages or iterate over all pages as PNG images.\n */\n\nimport { getBinding } from \"../core/binding.js\";\n\n/**\n * Render a single PDF page to a PNG buffer (synchronous).\n *\n * @param filePath - Path to the PDF file\n * @param pageIndex - Zero-based page index\n * @param options - Optional settings\n * @param options.dpi - DPI for rendering (default 150)\n * @returns Buffer containing PNG image data\n */\nexport function renderPdfPageSync(filePath: string, pageIndex: number, options?: { dpi?: number }): Buffer {\n\treturn getBinding().renderPdfPageSync(filePath, pageIndex, options?.dpi ?? null);\n}\n\n/**\n * Render a single PDF page to a PNG buffer (asynchronous).\n *\n * @param filePath - Path to the PDF file\n * @param pageIndex - Zero-based page index\n * @param options - Optional settings\n * @param options.dpi - DPI for rendering (default 150)\n * @returns Promise resolving to a Buffer containing PNG image data\n */\nexport async function renderPdfPage(filePath: string, pageIndex: number, options?: { dpi?: number }): Promise<Buffer> {\n\treturn getBinding().renderPdfPage(filePath, pageIndex, options?.dpi ?? null);\n}\n\n/** A rendered PDF page with its index and PNG data. */\nexport interface PdfPageResult {\n\tpageIndex: number;\n\tdata: Buffer;\n}\n\n/**\n * Collect all PDF pages as PNG images (synchronous).\n *\n * @param filePath - Path to the PDF file\n * @param options - Optional settings\n * @param options.dpi - DPI for rendering (default 150)\n * @returns Array of PdfPageResult objects\n */\nexport function iteratePdfPagesSync(filePath: string, options?: { dpi?: number }): PdfPageResult[] {\n\treturn getBinding().iteratePdfPagesSync(filePath, options?.dpi ?? null);\n}\n\n/**\n * Collect all PDF pages as PNG images (asynchronous).\n *\n * @param filePath - Path to the PDF file\n * @param options - Optional settings\n * @param options.dpi - DPI for rendering (default 150)\n * @returns Promise resolving to an array of PdfPageResult objects\n */\nexport async function iteratePdfPages(filePath: string, options?: { dpi?: number }): Promise<PdfPageResult[]> {\n\treturn getBinding().iteratePdfPages(filePath, options?.dpi ?? null);\n}\n\n/**\n * Get the number of pages in a PDF file.\n *\n * @param filePath - Path to the PDF file\n * @returns Number of pages\n */\nexport function pdfPageCount(filePath: string): number {\n\treturn getBinding().pdfPageCount(filePath);\n}\n\n/**\n * Lazy PDF page iterator. Renders one page at a time via `.next()`.\n * Call `.close()` when done to free native resources.\n *\n * @example\n * ```typescript\n * const iter = new PdfPageIterator(\"doc.pdf\", { dpi: 150 });\n * let result;\n * while ((result = iter.next()) !== null) {\n *     const { pageIndex, data } = result;\n *     // process page...\n * }\n * iter.close();\n * ```\n */\nexport class PdfPageIterator {\n\tprivate inner: { next(): PdfPageResult | null; pageCount(): number; close(): void };\n\n\tconstructor(filePath: string, options?: { dpi?: number }) {\n\t\tconst Ctor = getBinding().JsPdfPageIterator;\n\t\tthis.inner = new Ctor(filePath, options?.dpi ?? null);\n\t}\n\n\t/** Advance and return the next page, or null when exhausted. */\n\tnext(): PdfPageResult | null {\n\t\treturn this.inner.next();\n\t}\n\n\t/** Total number of pages in the PDF. */\n\tpageCount(): number {\n\t\treturn this.inner.pageCount();\n\t}\n\n\t/** Free native resources. Safe to call multiple times. */\n\tclose(): void {\n\t\tthis.inner.close();\n\t}\n}\n","/**\n * Single-document extraction APIs.\n *\n * This module provides synchronous and asynchronous functions for extracting content\n * from a single file or byte array. These are convenience wrappers around the native\n * binding that handle config normalization and result conversion.\n *\n * **Usage Note**: For processing multiple files, prefer batch extraction functions\n * (`batchExtractFiles`, `batchExtractFilesSync`) which provide better performance\n * and memory management.\n *\n * @internal This module is part of Layer 2 (extraction APIs).\n */\n\nimport { readFileSync } from \"node:fs\";\nimport { assertUint8Array } from \"../core/assertions.js\";\nimport { getBinding } from \"../core/binding.js\";\nimport { normalizeExtractionConfig } from \"../core/config-normalizer.js\";\nimport { convertResult } from \"../core/type-converters.js\";\nimport type { ExtractionConfig, ExtractionResult } from \"../types.js\";\n\n/**\n * Extract content from a single file (synchronous).\n *\n * **Usage Note**: For processing multiple files, prefer `batchExtractFilesSync()` which\n * provides better performance and memory management.\n *\n * @param filePath - Path to the file to extract (string). Can be absolute or relative.\n * @param mimeTypeOrConfig - Optional MIME type hint or extraction configuration.\n *   If a string, treated as MIME type. If an object, treated as ExtractionConfig.\n *   If null, MIME type is auto-detected from file extension or content.\n * @param maybeConfig - Extraction configuration object. If null, uses default extraction settings.\n *   Only used if second parameter is a MIME type string.\n * @returns ExtractionResult containing extracted content, metadata, tables, and optional chunks/images\n * @throws {Error} If file doesn't exist, cannot be accessed, or cannot be read\n * @throws {ParsingError} When document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { extractFileSync } from '@kreuzberg/node';\n *\n * // Basic usage\n * const result = extractFileSync('document.pdf');\n * console.log(result.content);\n *\n * // With explicit MIME type\n * const result2 = extractFileSync('document.pdf', 'application/pdf');\n *\n * // With configuration\n * const result3 = extractFileSync('document.pdf', {\n *   chunking: {\n *     maxChars: 1000,\n *     maxOverlap: 200,\n *   },\n * });\n * ```\n */\nexport function extractFileSync(\n\tfilePath: string,\n\tmimeTypeOrConfig?: string | null | ExtractionConfig,\n\tmaybeConfig?: ExtractionConfig | null,\n): ExtractionResult {\n\tlet mimeType: string | null = null;\n\tlet config: ExtractionConfig | null = null;\n\n\tif (typeof mimeTypeOrConfig === \"string\") {\n\t\tmimeType = mimeTypeOrConfig;\n\t\tconfig = maybeConfig ?? null;\n\t} else if (mimeTypeOrConfig !== null && typeof mimeTypeOrConfig === \"object\") {\n\t\tconfig = mimeTypeOrConfig;\n\t\tmimeType = null;\n\t} else {\n\t\tconfig = maybeConfig ?? null;\n\t\tmimeType = null;\n\t}\n\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResult = getBinding().extractFileSync(filePath, mimeType, normalizedConfig);\n\treturn convertResult(rawResult);\n}\n\n/**\n * Extract content from a single file (asynchronous).\n *\n * **Usage Note**: For processing multiple files, prefer `batchExtractFiles()` which\n * provides better performance and memory management.\n *\n * @param filePath - Path to the file to extract (string). Can be absolute or relative.\n * @param mimeTypeOrConfig - Optional MIME type hint or extraction configuration.\n *   If a string, treated as MIME type. If an object, treated as ExtractionConfig.\n *   If null, MIME type is auto-detected from file extension or content.\n * @param maybeConfig - Extraction configuration object. If null, uses default extraction settings.\n *   Only used if second parameter is a MIME type string.\n * @returns Promise<ExtractionResult> containing extracted content, metadata, tables, and optional chunks/images\n * @throws {Error} If file doesn't exist, cannot be accessed, or cannot be read\n * @throws {ParsingError} When document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { extractFile } from '@kreuzberg/node';\n *\n * // Basic usage\n * const result = await extractFile('document.pdf');\n * console.log(result.content);\n *\n * // With chunking enabled\n * const config = {\n *   chunking: {\n *     maxChars: 1000,\n *     maxOverlap: 200,\n *   },\n * };\n * const result2 = await extractFile('long_document.pdf', null, config);\n * console.log(result2.chunks); // Array of text chunks\n * ```\n */\nexport async function extractFile(\n\tfilePath: string,\n\tmimeTypeOrConfig?: string | null | ExtractionConfig,\n\tmaybeConfig?: ExtractionConfig | null,\n): Promise<ExtractionResult> {\n\tlet mimeType: string | null = null;\n\tlet config: ExtractionConfig | null = null;\n\n\tif (typeof mimeTypeOrConfig === \"string\") {\n\t\tmimeType = mimeTypeOrConfig;\n\t\tconfig = maybeConfig ?? null;\n\t} else if (mimeTypeOrConfig !== null && typeof mimeTypeOrConfig === \"object\") {\n\t\tconfig = mimeTypeOrConfig;\n\t\tmimeType = null;\n\t} else {\n\t\tconfig = maybeConfig ?? null;\n\t\tmimeType = null;\n\t}\n\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResult = await getBinding().extractFile(filePath, mimeType, normalizedConfig);\n\treturn convertResult(rawResult);\n}\n\n/**\n * Extract content from raw bytes (synchronous).\n *\n * **Usage Note**: For processing multiple byte arrays, prefer `batchExtractBytesSync()`\n * which provides better performance and memory management.\n *\n * @param data - File content as Uint8Array (Buffer will be converted)\n * @param mimeType - MIME type of the data (required for accurate format detection). Must be a valid MIME type string.\n * @param config - Extraction configuration object. If null, uses default extraction settings.\n * @returns ExtractionResult containing extracted content, metadata, tables, and optional chunks/images\n * @throws {TypeError} When data is not a valid Uint8Array\n * @throws {Error} When file cannot be read or parsed\n * @throws {ParsingError} When document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { extractBytesSync } from '@kreuzberg/node';\n * import { readFileSync } from 'fs';\n *\n * const data = readFileSync('document.pdf');\n * const result = extractBytesSync(data, 'application/pdf');\n * console.log(result.content);\n * ```\n */\nexport function extractBytesSync(\n\tdataOrPath: Uint8Array | string,\n\tmimeType: string,\n\tconfig: ExtractionConfig | null = null,\n): ExtractionResult {\n\tlet data: Uint8Array;\n\tif (typeof dataOrPath === \"string\") {\n\t\tdata = readFileSync(dataOrPath);\n\t} else {\n\t\tdata = dataOrPath;\n\t}\n\n\tconst validated = assertUint8Array(data, \"data\");\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResult = getBinding().extractBytesSync(Buffer.from(validated), mimeType, normalizedConfig);\n\treturn convertResult(rawResult);\n}\n\n/**\n * Extract content from raw bytes (asynchronous).\n *\n * **Usage Note**: For processing multiple byte arrays, prefer `batchExtractBytes()`\n * which provides better performance and memory management.\n *\n * @param data - File content as Uint8Array (Buffer will be converted)\n * @param mimeType - MIME type of the data (required for accurate format detection). Must be a valid MIME type string.\n * @param config - Extraction configuration object. If null, uses default extraction settings.\n * @returns Promise<ExtractionResult> containing extracted content, metadata, tables, and optional chunks/images\n * @throws {TypeError} When data is not a valid Uint8Array\n * @throws {Error} When file cannot be read or parsed\n * @throws {ParsingError} When document format is invalid or corrupted\n * @throws {OcrError} When OCR processing fails (if OCR is enabled)\n * @throws {ValidationError} When extraction result fails validation (if validators registered)\n * @throws {KreuzbergError} For other extraction-related failures\n *\n * @example\n * ```typescript\n * import { extractBytes } from '@kreuzberg/node';\n * import { readFile } from 'fs/promises';\n *\n * const data = await readFile('document.pdf');\n * const result = await extractBytes(data, 'application/pdf');\n * console.log(result.content);\n * ```\n */\nexport async function extractBytes(\n\tdataOrPath: Uint8Array | string,\n\tmimeType: string,\n\tconfig: ExtractionConfig | null = null,\n): Promise<ExtractionResult> {\n\tlet data: Uint8Array;\n\tif (typeof dataOrPath === \"string\") {\n\t\tdata = readFileSync(dataOrPath);\n\t} else {\n\t\tdata = dataOrPath;\n\t}\n\n\tconst validated = assertUint8Array(data, \"data\");\n\tif (process.env[\"KREUZBERG_DEBUG_OCR\"] === \"1\") {\n\t\tconsole.log(\"[TypeScript] Debug input header:\", Array.from(validated.slice(0, 8)));\n\t}\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst rawResult = await getBinding().extractBytes(Buffer.from(validated), mimeType, normalizedConfig);\n\treturn convertResult(rawResult);\n}\n","/**\n * Worker pool management for concurrent document extraction.\n *\n * This module provides utilities for creating and managing worker pools that enable\n * concurrent extraction of documents using Node.js worker threads. Worker pools allow\n * multiple extraction operations to run in parallel with configurable pool sizes.\n *\n * **Usage Pattern**:\n * 1. Create a pool with `createWorkerPool(size)`\n * 2. Submit tasks with `extractFileInWorker()` or `batchExtractFilesInWorker()`\n * 3. Close the pool with `closeWorkerPool()` when done\n *\n * @internal This module is part of Layer 2 (extraction APIs).\n */\n\nimport { getBinding } from \"../core/binding.js\";\nimport { normalizeExtractionConfig } from \"../core/config-normalizer.js\";\nimport { convertResult } from \"../core/type-converters.js\";\nimport type { ExtractionConfig, ExtractionResult, WorkerPool, WorkerPoolStats } from \"../types.js\";\n\n/**\n * Create a new worker pool for concurrent extraction operations.\n *\n * Creates a pool of worker threads that can process extraction tasks concurrently.\n * The pool manages a queue of pending tasks and distributes them across available workers.\n *\n * @param size - Optional number of workers in the pool. If not specified, defaults to the number of CPU cores.\n * @returns WorkerPool instance that can be used with extraction functions\n *\n * @example\n * ```typescript\n * import { createWorkerPool } from '@kreuzberg/node';\n *\n * // Create pool with default size (number of CPU cores)\n * const pool = createWorkerPool();\n *\n * // Create pool with 4 workers\n * const pool4 = createWorkerPool(4);\n * ```\n */\nexport function createWorkerPool(size?: number): WorkerPool {\n\tconst binding = getBinding();\n\tconst rawPool = binding.createWorkerPool(size);\n\treturn rawPool as unknown as WorkerPool;\n}\n\n/**\n * Get statistics about a worker pool.\n *\n * Returns information about the pool's current state, including the number of active workers,\n * queued tasks, and total processed tasks.\n *\n * @param pool - The worker pool instance\n * @returns WorkerPoolStats with pool information\n *\n * @example\n * ```typescript\n * import { createWorkerPool, getWorkerPoolStats } from '@kreuzberg/node';\n *\n * const pool = createWorkerPool(4);\n * const stats = getWorkerPoolStats(pool);\n *\n * console.log(`Pool size: ${stats.size}`);\n * console.log(`Active workers: ${stats.activeWorkers}`);\n * console.log(`Queued tasks: ${stats.queuedTasks}`);\n * ```\n */\nexport function getWorkerPoolStats(pool: WorkerPool): WorkerPoolStats {\n\tconst binding = getBinding();\n\tconst rawStats = binding.getWorkerPoolStats(pool as unknown as Record<string, unknown>);\n\treturn rawStats as unknown as WorkerPoolStats;\n}\n\n/**\n * Extract content from a single file using a worker pool (asynchronous).\n *\n * Submits an extraction task to the worker pool. The task is executed by one of the\n * available workers in the background, allowing other tasks to be processed concurrently.\n *\n * @param pool - The worker pool instance\n * @param filePath - Path to the file to extract\n * @param mimeTypeOrConfig - Optional MIME type or extraction configuration.\n *   If a string, treated as MIME type. If an object, treated as ExtractionConfig.\n *   If null, MIME type is auto-detected from file extension or content.\n * @param maybeConfig - Extraction configuration object. If null, uses default extraction settings.\n *   Only used if second parameter is a MIME type string.\n * @returns Promise<ExtractionResult> containing extracted content and metadata\n *\n * @throws {Error} If the file cannot be read or extraction fails\n *\n * @example\n * ```typescript\n * import { createWorkerPool, extractFileInWorker, closeWorkerPool } from '@kreuzberg/node';\n *\n * const pool = createWorkerPool(4);\n *\n * try {\n *   const files = ['doc1.pdf', 'doc2.docx', 'doc3.xlsx'];\n *   const results = await Promise.all(\n *     files.map(f => extractFileInWorker(pool, f))\n *   );\n *\n *   results.forEach((r, i) => {\n *     console.log(`${files[i]}: ${r.content.substring(0, 100)}...`);\n *   });\n * } finally {\n *   await closeWorkerPool(pool);\n * }\n * ```\n */\nexport async function extractFileInWorker(\n\tpool: WorkerPool,\n\tfilePath: string,\n\tmimeTypeOrConfig?: string | null | ExtractionConfig,\n\tmaybeConfig?: ExtractionConfig | null,\n): Promise<ExtractionResult> {\n\tlet mimeType: string | null = null;\n\tlet config: ExtractionConfig | null = null;\n\n\tif (typeof mimeTypeOrConfig === \"string\") {\n\t\tmimeType = mimeTypeOrConfig;\n\t\tconfig = maybeConfig ?? null;\n\t} else if (mimeTypeOrConfig !== null && typeof mimeTypeOrConfig === \"object\") {\n\t\tconfig = mimeTypeOrConfig;\n\t\tmimeType = null;\n\t} else {\n\t\tconfig = maybeConfig ?? null;\n\t\tmimeType = null;\n\t}\n\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst binding = getBinding();\n\tconst rawResult = await binding.extractFileInWorker(\n\t\tpool as unknown as Record<string, unknown>,\n\t\tfilePath,\n\t\tmimeType,\n\t\tnormalizedConfig,\n\t);\n\treturn convertResult(rawResult);\n}\n\n/**\n * Extract content from multiple files in parallel using a worker pool (asynchronous).\n *\n * Submits multiple extraction tasks to the worker pool for concurrent processing.\n * This is more efficient than using `extractFileInWorker` multiple times sequentially.\n *\n * @param pool - The worker pool instance\n * @param paths - Array of file paths to extract\n * @param config - Extraction configuration object (applies to all files). If null, uses default extraction settings.\n * @returns Promise<ExtractionResult[]> array of results (one per file, in same order)\n *\n * @throws {Error} If any file cannot be read or extraction fails\n *\n * @example\n * ```typescript\n * import { createWorkerPool, batchExtractFilesInWorker, closeWorkerPool } from '@kreuzberg/node';\n *\n * const pool = createWorkerPool(4);\n *\n * try {\n *   const files = ['invoice1.pdf', 'invoice2.pdf', 'invoice3.pdf'];\n *   const results = await batchExtractFilesInWorker(pool, files, {\n *     ocr: { backend: 'tesseract', language: 'eng' }\n *   });\n *\n *   const total = results.reduce((sum, r) => sum + extractAmount(r.content), 0);\n *   console.log(`Total: $${total}`);\n * } finally {\n *   await closeWorkerPool(pool);\n * }\n * ```\n */\nexport async function batchExtractFilesInWorker(\n\tpool: WorkerPool,\n\tpaths: string[],\n\tconfig: ExtractionConfig | null = null,\n): Promise<ExtractionResult[]> {\n\tconst normalizedConfig = normalizeExtractionConfig(config);\n\tconst binding = getBinding();\n\tconst rawResults = await binding.batchExtractFilesInWorker(\n\t\tpool as unknown as Record<string, unknown>,\n\t\tpaths,\n\t\tnormalizedConfig,\n\t);\n\treturn rawResults.map(convertResult);\n}\n\n/**\n * Close a worker pool and shut down all worker threads.\n *\n * Should be called when the pool is no longer needed to clean up resources\n * and gracefully shut down worker threads. Any pending tasks will be cancelled.\n *\n * @param pool - The worker pool instance to close\n * @returns Promise that resolves when the pool is fully closed\n *\n * @throws {Error} If pool shutdown fails\n *\n * @example\n * ```typescript\n * import { createWorkerPool, extractFileInWorker, closeWorkerPool } from '@kreuzberg/node';\n *\n * const pool = createWorkerPool(4);\n *\n * try {\n *   const result = await extractFileInWorker(pool, 'document.pdf');\n *   console.log(result.content);\n * } finally {\n *   // Clean up the pool\n *   await closeWorkerPool(pool);\n * }\n * ```\n */\nexport async function closeWorkerPool(pool: WorkerPool): Promise<void> {\n\tconst binding = getBinding();\n\tawait binding.closeWorkerPool(pool as unknown as Record<string, unknown>);\n}\n","import { getBinding } from \"../core/binding.js\";\nimport type { Chunk, ExtractedImage, ExtractionResult, PostProcessorProtocol, Table } from \"../types.js\";\n\n/**\n * Register a custom post-processor.\n *\n * Post-processors allow you to hook into the extraction pipeline and transform\n * the extraction results. They run after the core extraction is complete.\n *\n * Post-processors are async and can modify extraction results before they are\n * returned to the caller.\n *\n * @param processor - Post-processor implementing PostProcessorProtocol\n *\n * @example\n * ```typescript\n * import { registerPostProcessor, extractFile } from '@kreuzberg/node';\n *\n * class CustomProcessor {\n *   name() {\n *     return 'custom_processor';\n *   }\n *   processingStage() {\n *     return 'post';\n *   }\n *   async process(result) {\n *     // Add custom metadata\n *     result.metadata.customField = 'custom_value';\n *     return result;\n *   }\n * }\n *\n * // Use async extraction (required for custom processors)\n * const result = await extractFile('document.pdf');\n * console.log(result.metadata.customField); // 'custom_value'\n * ```\n */\nexport function registerPostProcessor(processor: PostProcessorProtocol): void {\n\tconst binding = getBinding();\n\n\tconst wrappedProcessor = {\n\t\tname: typeof processor.name === \"function\" ? processor.name() : processor.name,\n\t\tprocessingStage:\n\t\t\ttypeof processor.processingStage === \"function\" ? processor.processingStage() : processor.processingStage,\n\t\tasync process(...args: unknown[]): Promise<string> {\n\t\t\tconst wrappedValue = args[0] as unknown[];\n\t\t\tconst jsonString = wrappedValue[0] as string;\n\n\t\t\tconst wireResult = JSON.parse(jsonString) as {\n\t\t\t\tcontent: string;\n\t\t\t\tmime_type: string;\n\t\t\t\tmetadata: string | Record<string, unknown>;\n\t\t\t\ttables?: unknown[];\n\t\t\t\tdetected_languages?: string[];\n\t\t\t\tchunks?: unknown[];\n\t\t\t\timages?: unknown[];\n\t\t\t};\n\n\t\t\tconst result: ExtractionResult = {\n\t\t\t\tcontent: wireResult.content,\n\t\t\t\tmimeType: wireResult.mime_type,\n\t\t\t\tmetadata: typeof wireResult.metadata === \"string\" ? JSON.parse(wireResult.metadata) : wireResult.metadata,\n\t\t\t\ttables: (wireResult.tables || []) as Table[],\n\t\t\t\tdetectedLanguages: wireResult.detected_languages ?? null,\n\t\t\t\tchunks: (wireResult.chunks as Chunk[] | null | undefined) ?? null,\n\t\t\t\timages: (wireResult.images as ExtractedImage[] | null | undefined) ?? null,\n\t\t\t};\n\n\t\t\tconst updated = await processor.process(result);\n\n\t\t\tconst wireUpdated = {\n\t\t\t\tcontent: updated.content,\n\t\t\t\tmime_type: updated.mimeType,\n\t\t\t\tmetadata: updated.metadata,\n\t\t\t\ttables: updated.tables,\n\t\t\t\tdetected_languages: updated.detectedLanguages,\n\t\t\t\tchunks: updated.chunks,\n\t\t\t\timages: updated.images,\n\t\t\t};\n\n\t\t\treturn JSON.stringify(wireUpdated);\n\t\t},\n\t};\n\n\tObject.defineProperty(wrappedProcessor, \"__original\", {\n\t\tvalue: processor,\n\t\tenumerable: false,\n\t});\n\n\tconst stage = processor.processingStage?.() ?? \"middle\";\n\tObject.defineProperty(wrappedProcessor, \"__stage\", {\n\t\tvalue: stage,\n\t\tenumerable: false,\n\t});\n\n\tbinding.registerPostProcessor(wrappedProcessor);\n}\n\n/**\n * Unregister a postprocessor by name.\n *\n * Removes a previously registered postprocessor from the registry.\n * If the processor doesn't exist, this is a no-op (does not throw).\n *\n * @param name - Name of the processor to unregister (case-sensitive)\n *\n * @example\n * ```typescript\n * import { unregisterPostProcessor } from '@kreuzberg/node';\n *\n * unregisterPostProcessor('my_processor');\n * ```\n */\nexport function unregisterPostProcessor(name: string): void {\n\tconst binding = getBinding();\n\tbinding.unregisterPostProcessor(name);\n}\n\n/**\n * Clear all registered postprocessors.\n *\n * Removes all postprocessors from the registry. Useful for test cleanup or resetting state.\n * If no postprocessors are registered, this is a no-op.\n *\n * @example\n * ```typescript\n * import { clearPostProcessors } from '@kreuzberg/node';\n *\n * clearPostProcessors();\n * ```\n */\nexport function clearPostProcessors(): void {\n\tconst binding = getBinding();\n\tbinding.clearPostProcessors();\n}\n\n/**\n * List all registered post-processors.\n *\n * Returns the names of all currently registered post-processors (both built-in and custom).\n *\n * @returns Array of post-processor names (empty array if none registered)\n *\n * @example\n * ```typescript\n * import { listPostProcessors } from '@kreuzberg/node';\n *\n * const names = listPostProcessors();\n * console.log('Registered post-processors:', names);\n * ```\n */\nexport function listPostProcessors(): string[] {\n\tconst binding = getBinding();\n\treturn binding.listPostProcessors();\n}\n\n/**\n * Get a registered post-processor by name.\n *\n * Retrieves information about a specific post-processor from the registry.\n *\n * @param name - Name of the post-processor to retrieve\n * @returns The post-processor if found, null otherwise\n *\n * @example\n * ```typescript\n * import { getPostProcessor } from '@kreuzberg/node';\n *\n * const processor = getPostProcessor('my_processor');\n * if (processor) {\n *   console.log('Processor found:', processor.name);\n * }\n * ```\n */\nexport function getPostProcessor(name: string): unknown {\n\t// Note: This function is not directly exposed by the native binding\n\t// It's a helper function that uses listPostProcessors to check if a processor exists\n\tconst processors = listPostProcessors();\n\treturn processors.includes(name) ? { name } : null;\n}\n","import { getBinding } from \"../core/binding.js\";\nimport type { ExtractionResult, ValidatorProtocol } from \"../types.js\";\n\n/**\n * Register a custom validator.\n *\n * Validators check extraction results for quality, completeness, or correctness.\n * Unlike post-processors, validator errors **fail fast** - if a validator throws an error,\n * the extraction fails immediately.\n *\n * Validators are async and run after post-processors in the extraction pipeline.\n *\n * @param validator - Validator implementing ValidatorProtocol\n *\n * @example\n * ```typescript\n * import { registerValidator, extractFile } from '@kreuzberg/node';\n *\n * class MinLengthValidator {\n *   name() {\n *     return 'min_length_validator';\n *   }\n *\n *   priority() {\n *     return 100;\n *   }\n *\n *   async validate(result) {\n *     if (result.content.length < 10) {\n *       throw new Error('Content too short');\n *     }\n *   }\n * }\n *\n * registerValidator(new MinLengthValidator());\n * ```\n */\nexport function registerValidator(validator: ValidatorProtocol): void {\n\tconst binding = getBinding();\n\n\tconst wrappedValidator = {\n\t\tname: typeof validator.name === \"function\" ? validator.name() : validator.name,\n\t\tpriority: typeof validator.priority === \"function\" ? validator.priority() : validator.priority,\n\t\tasync validate(...args: unknown[]): Promise<string> {\n\t\t\tconst jsonString = args[0] as string;\n\n\t\t\tif (!jsonString || jsonString === \"undefined\") {\n\t\t\t\tthrow new Error(\"Validator received invalid JSON string\");\n\t\t\t}\n\n\t\t\tconst wireResult = JSON.parse(jsonString);\n\t\t\tconst result: ExtractionResult = {\n\t\t\t\tcontent: wireResult.content,\n\t\t\t\tmimeType: wireResult.mime_type,\n\t\t\t\tmetadata: typeof wireResult.metadata === \"string\" ? JSON.parse(wireResult.metadata) : wireResult.metadata,\n\t\t\t\ttables: wireResult.tables || [],\n\t\t\t\tdetectedLanguages: wireResult.detected_languages,\n\t\t\t\tchunks: wireResult.chunks,\n\t\t\t\timages: wireResult.images ?? null,\n\t\t\t};\n\n\t\t\tawait Promise.resolve(validator.validate(result));\n\t\t\treturn \"\";\n\t\t},\n\t};\n\n\tbinding.registerValidator(wrappedValidator);\n}\n\n/**\n * Unregister a validator by name.\n *\n * Removes a previously registered validator from the global registry.\n * If the validator doesn't exist, this is a no-op (does not throw).\n *\n * @param name - Validator name to unregister (case-sensitive)\n *\n * @example\n * ```typescript\n * import { unregisterValidator } from '@kreuzberg/node';\n *\n * unregisterValidator('min_length_validator');\n * ```\n */\nexport function unregisterValidator(name: string): void {\n\tconst binding = getBinding();\n\tbinding.unregisterValidator(name);\n}\n\n/**\n * Clear all registered validators.\n *\n * Removes all validators from the global registry. Useful for test cleanup\n * or resetting state.\n *\n * @example\n * ```typescript\n * import { clearValidators } from '@kreuzberg/node';\n *\n * clearValidators();\n * ```\n */\nexport function clearValidators(): void {\n\tconst binding = getBinding();\n\tbinding.clearValidators();\n}\n\n/**\n * List all registered validators.\n *\n * Returns the names of all currently registered validators (both built-in and custom).\n *\n * @returns Array of validator names (empty array if none registered)\n *\n * @example\n * ```typescript\n * import { listValidators } from '@kreuzberg/node';\n *\n * const names = listValidators();\n * console.log('Registered validators:', names);\n * ```\n */\nexport function listValidators(): string[] {\n\tconst binding = getBinding();\n\treturn binding.listValidators();\n}\n\n/**\n * Get a registered validator by name.\n *\n * Retrieves information about a specific validator from the registry.\n *\n * @param name - Name of the validator to retrieve\n * @returns The validator if found, null otherwise\n *\n * @example\n * ```typescript\n * import { getValidator } from '@kreuzberg/node';\n *\n * const validator = getValidator('min_length_validator');\n * if (validator) {\n *   console.log('Validator found:', validator.name);\n * }\n * ```\n */\nexport function getValidator(name: string): unknown {\n\t// Note: This function is not directly exposed by the native binding\n\t// It's a helper function that uses listValidators to check if a validator exists\n\tconst validators = listValidators();\n\treturn validators.includes(name) ? { name } : null;\n}\n","import { getBinding } from \"../core/binding.js\";\nimport type { OcrBackendProtocol } from \"../types.js\";\n\n/**\n * Type definitions for OCR payload handling\n */\ntype OcrProcessPayload = Buffer | string;\ntype OcrProcessTuple = [OcrProcessPayload, string];\ntype NestedOcrProcessTuple = [OcrProcessTuple];\n\n/**\n * Type guard for OCR process tuple\n */\nfunction isOcrProcessTuple(value: unknown): value is OcrProcessTuple {\n\treturn (\n\t\tArray.isArray(value) &&\n\t\tvalue.length === 2 &&\n\t\ttypeof value[1] === \"string\" &&\n\t\t(typeof value[0] === \"string\" || Buffer.isBuffer(value[0]) || value[0] instanceof Uint8Array)\n\t);\n}\n\n/**\n * Type guard for nested OCR process tuple\n */\nfunction isNestedOcrProcessTuple(value: unknown): value is NestedOcrProcessTuple {\n\treturn Array.isArray(value) && value.length === 1 && isOcrProcessTuple(value[0]);\n}\n\n/**\n * Describes an OCR payload for debugging\n */\nfunction describePayload(value: OcrProcessPayload) {\n\tif (typeof value === \"string\") {\n\t\treturn { ctor: \"String\", length: value.length };\n\t}\n\n\treturn { ctor: value.constructor?.name ?? \"Buffer\", length: value.length };\n}\n\n/**\n * Register a custom OCR backend.\n *\n * This function registers a JavaScript OCR backend that will be used by Kreuzberg's\n * extraction pipeline when OCR is enabled. The backend must implement the\n * {@link OcrBackendProtocol} interface.\n *\n * ## Usage\n *\n * 1. Create a class implementing {@link OcrBackendProtocol}\n * 2. Call `initialize()` on your backend instance (if needed)\n * 3. Register the backend with `registerOcrBackend()`\n * 4. Use the backend name in extraction config\n *\n * ## Thread Safety\n *\n * The registered backend must be thread-safe as it may be called concurrently\n * from multiple Rust async tasks. Ensure your implementation handles concurrent\n * calls properly.\n *\n * @param backend - OcrBackendProtocol implementation with name(), supportedLanguages(), and processImage()\n * @throws {Error} If backend is missing required methods (name, supportedLanguages, or processImage)\n * @throws {Error} If backend name is empty string or contains invalid characters\n * @throws {Error} If a backend with the same name is already registered\n * @throws {Error} If registration fails due to FFI issues\n *\n * @example\n * ```typescript\n * import { extractFile } from '@kreuzberg/node';\n *\n * // PaddleOCR is built into the native Rust core - just use the backend name\n * const result = await extractFile('scanned.pdf', null, {\n *   ocr: { backend: 'paddle-ocr', language: 'en' }\n * });\n * console.log(result.content);\n * ```\n *\n * @example\n * ```typescript\n * import { registerOcrBackend } from '@kreuzberg/node';\n *\n * class MyOcrBackend {\n *   name() {\n *     return 'my-ocr';\n *   }\n *\n *   supportedLanguages(): string[] {\n *     return ['en', 'de', 'fr'];\n *   }\n *\n *   async processImage(imageBytes: Uint8Array, language: string) {\n *     const text = await myCustomOcrEngine(imageBytes, language);\n *     return {\n *       content: text,\n *       mime_type: 'text/plain',\n *       metadata: { confidence: 0.95, language },\n *       tables: []\n *     };\n *   }\n * }\n *\n * registerOcrBackend(new MyOcrBackend());\n * ```\n */\nexport function registerOcrBackend(backend: OcrBackendProtocol): void {\n\tconst binding = getBinding();\n\n\tconst wrappedBackend = {\n\t\tname: typeof backend.name === \"function\" ? backend.name() : backend.name,\n\t\tsupportedLanguages:\n\t\t\ttypeof backend.supportedLanguages === \"function\"\n\t\t\t\t? backend.supportedLanguages()\n\t\t\t\t: (backend.supportedLanguages ?? [\"en\"]),\n\t\tasync processImage(\n\t\t\t...processArgs: [OcrProcessPayload | OcrProcessTuple | NestedOcrProcessTuple, string?]\n\t\t): Promise<string> {\n\t\t\tconst [imagePayload, maybeLanguage] = processArgs;\n\t\t\tif (process.env[\"KREUZBERG_DEBUG_OCR\"] === \"1\") {\n\t\t\t\tconsole.log(\"[registerOcrBackend] JS arguments\", { length: processArgs.length });\n\t\t\t\tconsole.log(\"[registerOcrBackend] Raw args\", {\n\t\t\t\t\timagePayloadType: Array.isArray(imagePayload) ? \"tuple\" : typeof imagePayload,\n\t\t\t\t\tmaybeLanguageType: typeof maybeLanguage,\n\t\t\t\t\tmetadata: Array.isArray(imagePayload) ? { tupleLength: imagePayload.length } : describePayload(imagePayload),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet rawBytes: OcrProcessPayload;\n\t\t\tlet language = maybeLanguage;\n\n\t\t\tif (isNestedOcrProcessTuple(imagePayload)) {\n\t\t\t\t[rawBytes, language] = imagePayload[0];\n\t\t\t} else if (isOcrProcessTuple(imagePayload)) {\n\t\t\t\t[rawBytes, language] = imagePayload;\n\t\t\t} else {\n\t\t\t\trawBytes = imagePayload;\n\t\t\t}\n\n\t\t\tif (typeof language !== \"string\") {\n\t\t\t\tthrow new Error(\"OCR backend did not receive a language parameter\");\n\t\t\t}\n\n\t\t\tif (process.env[\"KREUZBERG_DEBUG_OCR\"] === \"1\") {\n\t\t\t\tconst length = typeof rawBytes === \"string\" ? rawBytes.length : rawBytes.length;\n\t\t\t\tconsole.log(\n\t\t\t\t\t\"[registerOcrBackend] Received payload\",\n\t\t\t\t\tArray.isArray(imagePayload) ? \"tuple\" : typeof rawBytes,\n\t\t\t\t\t\"ctor\",\n\t\t\t\t\tdescribePayload(rawBytes).ctor,\n\t\t\t\t\t\"length\",\n\t\t\t\t\tlength,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst buffer = typeof rawBytes === \"string\" ? Buffer.from(rawBytes, \"base64\") : Buffer.from(rawBytes);\n\t\t\tconst result = await backend.processImage(new Uint8Array(buffer), language);\n\n\t\t\treturn JSON.stringify(result);\n\t\t},\n\t};\n\n\tbinding.registerOcrBackend(wrappedBackend);\n}\n\n/**\n * List all registered OCR backends.\n *\n * Returns an array of names of all currently registered OCR backends,\n * including built-in backends like \"tesseract\".\n *\n * @returns Array of OCR backend names (empty array if none registered)\n *\n * @example\n * ```typescript\n * import { listOcrBackends } from '@kreuzberg/node';\n *\n * const backends = listOcrBackends();\n * console.log(backends); // ['tesseract', 'my-custom-backend', ...]\n * ```\n */\nexport function listOcrBackends(): string[] {\n\tconst binding = getBinding();\n\treturn binding.listOcrBackends();\n}\n\n/**\n * Unregister an OCR backend by name.\n *\n * Removes the specified OCR backend from the registry. If the backend doesn't exist,\n * this operation is a no-op (does not throw an error).\n *\n * @param name - Name of the OCR backend to unregister\n *\n * @example\n * ```typescript\n * import { unregisterOcrBackend } from '@kreuzberg/node';\n *\n * // Unregister a custom backend\n * unregisterOcrBackend('my-custom-ocr');\n * ```\n */\nexport function unregisterOcrBackend(name: string): void {\n\tconst binding = getBinding();\n\tbinding.unregisterOcrBackend(name);\n}\n\n/**\n * Clear all registered OCR backends.\n *\n * Removes all OCR backends from the registry, including built-in backends.\n * Use with caution as this will make OCR functionality unavailable until\n * backends are re-registered. If no backends are registered, this is a no-op.\n *\n * @example\n * ```typescript\n * import { clearOcrBackends } from '@kreuzberg/node';\n *\n * clearOcrBackends();\n * ```\n */\nexport function clearOcrBackends(): void {\n\tconst binding = getBinding();\n\tbinding.clearOcrBackends();\n}\n\n/**\n * Get a registered OCR backend by name.\n *\n * Retrieves information about a specific OCR backend from the registry.\n *\n * @param name - Name of the OCR backend to retrieve\n * @returns The backend if found, null otherwise\n *\n * @example\n * ```typescript\n * import { getOcrBackend } from '@kreuzberg/node';\n *\n * const backend = getOcrBackend('tesseract');\n * if (backend) {\n *   console.log('Backend found:', backend.name);\n * }\n * ```\n */\nexport function getOcrBackend(name: string): unknown {\n\t// Note: This function is not directly exposed by the native binding\n\t// It's a helper function that uses listOcrBackends to check if a backend exists\n\tconst backends = listOcrBackends();\n\treturn backends.includes(name) ? { name } : null;\n}\n","import { getBinding } from \"../core/binding.js\";\n\n/**\n * List all registered document extractors.\n *\n * Returns an array of names of all currently registered document extractors,\n * including built-in extractors for PDF, Office documents, images, etc.\n *\n * @returns Array of document extractor names (empty array if none registered)\n *\n * @example\n * ```typescript\n * import { listDocumentExtractors } from '@kreuzberg/node';\n *\n * const extractors = listDocumentExtractors();\n * console.log(extractors); // ['pdf', 'docx', 'xlsx', 'custom-extractor', ...]\n * ```\n */\nexport function listDocumentExtractors(): string[] {\n\tconst binding = getBinding();\n\treturn binding.listDocumentExtractors();\n}\n\n/**\n * Unregister a document extractor by name.\n *\n * Removes the specified document extractor from the registry. If the extractor\n * doesn't exist, this operation is a no-op (does not throw an error).\n *\n * @param name - Name of the document extractor to unregister\n *\n * @example\n * ```typescript\n * import { unregisterDocumentExtractor } from '@kreuzberg/node';\n *\n * // Unregister a custom extractor\n * unregisterDocumentExtractor('MyCustomExtractor');\n * ```\n */\nexport function unregisterDocumentExtractor(name: string): void {\n\tconst binding = getBinding();\n\tbinding.unregisterDocumentExtractor(name);\n}\n\n/**\n * Clear all registered document extractors.\n *\n * Removes all document extractors from the registry, including built-in extractors.\n * Use with caution as this will make document extraction unavailable until\n * extractors are re-registered.\n *\n * @example\n * ```typescript\n * import { clearDocumentExtractors } from '@kreuzberg/node';\n *\n * clearDocumentExtractors();\n * ```\n */\nexport function clearDocumentExtractors(): void {\n\tconst binding = getBinding();\n\tbinding.clearDocumentExtractors();\n}\n\n/**\n * Get a registered document extractor by name.\n *\n * Retrieves information about a specific document extractor from the registry.\n *\n * @param name - Name of the document extractor to retrieve\n * @returns The extractor if found, null otherwise\n *\n * @example\n * ```typescript\n * import { getDocumentExtractor } from '@kreuzberg/node';\n *\n * const extractor = getDocumentExtractor('pdf');\n * if (extractor) {\n *   console.log('Extractor found:', extractor.name);\n * }\n * ```\n */\nexport function getDocumentExtractor(name: string): unknown {\n\t// Note: This function is not directly exposed by the native binding\n\t// It's a helper function that uses listDocumentExtractors to check if an extractor exists\n\tconst extractors = listDocumentExtractors();\n\treturn extractors.includes(name) ? { name } : null;\n}\n\n/**\n * Register a custom document extractor.\n *\n * Note: The native binding does not expose a registerDocumentExtractor method.\n * Document extractors are typically registered at the Rust level or through\n * configuration. This function is provided for consistency with the API.\n *\n * @param _name - Name of the document extractor (not used - for API consistency)\n * @throws {Error} Not implemented - document extractors cannot be registered from TypeScript\n *\n * @example\n * ```typescript\n * // Document extractors are typically defined in Rust or configuration\n * // This function is not available in the current API\n * ```\n */\nexport function registerDocumentExtractor(_name: string): void {\n\tthrow new Error(\n\t\t\"registerDocumentExtractor is not available. Document extractors must be registered at the Rust level.\",\n\t);\n}\n","import { getBinding } from \"../core/binding.js\";\nimport type { ExtractionConfig as ExtractionConfigType } from \"../types.js\";\n\n/**\n * ExtractionConfig namespace with static methods for loading configuration from files.\n *\n * Provides factory methods to load extraction configuration from TOML, YAML, or JSON files,\n * or to discover configuration files in the current directory tree.\n *\n * For creating configurations programmatically, use plain TypeScript objects instead:\n *\n * @example\n * ```typescript\n * import { ExtractionConfig, extractFile } from '@kreuzberg/node';\n *\n * // Load configuration from file\n * const config1 = ExtractionConfig.fromFile('config.toml');\n *\n * // Or create with plain object\n * const config2 = {\n *   chunking: { maxChars: 2048 },\n *   ocr: { backend: 'tesseract', language: 'eng' }\n * };\n *\n * // Use with extraction\n * const result = await extractFile('document.pdf', null, config2);\n * ```\n */\nexport const ExtractionConfig = {\n\t/**\n\t * Load extraction configuration from a file.\n\t *\n\t * Automatically detects the file format based on extension:\n\t * - `.toml` - TOML format\n\t * - `.yaml` - YAML format\n\t * - `.json` - JSON format\n\t *\n\t * @param filePath - Path to the configuration file (absolute or relative)\n\t * @returns ExtractionConfig object loaded from the file\n\t *\n\t * @throws {Error} If file does not exist or is not accessible\n\t * @throws {Error} If file content is not valid TOML/YAML/JSON\n\t * @throws {Error} If configuration structure is invalid\n\t * @throws {Error} If file extension is not supported\n\t *\n\t * @example\n\t * ```typescript\n\t * import { ExtractionConfig } from '@kreuzberg/node';\n\t *\n\t * // Load from TOML file\n\t * const config1 = ExtractionConfig.fromFile('kreuzberg.toml');\n\t *\n\t * // Load from YAML file\n\t * const config2 = ExtractionConfig.fromFile('./config.yaml');\n\t *\n\t * // Load from JSON file\n\t * const config3 = ExtractionConfig.fromFile('./config.json');\n\t * ```\n\t */\n\tfromFile(filePath: string): ExtractionConfigType {\n\t\tconst binding = getBinding();\n\t\treturn binding.loadExtractionConfigFromFile(filePath);\n\t},\n\n\t/**\n\t * Discover and load configuration from current or parent directories.\n\t *\n\t * Searches for a `kreuzberg.toml` file starting from the current working directory\n\t * and traversing up the directory tree. Returns the first configuration file found.\n\t *\n\t * @returns ExtractionConfig object if found, or null if no configuration file exists\n\t *\n\t * @example\n\t * ```typescript\n\t * import { ExtractionConfig } from '@kreuzberg/node';\n\t *\n\t * // Try to find config in current or parent directories\n\t * const config = ExtractionConfig.discover();\n\t * if (config) {\n\t *   console.log('Found configuration');\n\t *   // Use config for extraction\n\t * } else {\n\t *   console.log('No configuration file found, using defaults');\n\t * }\n\t * ```\n\t */\n\tdiscover(): ExtractionConfigType | null {\n\t\tconst binding = getBinding();\n\t\treturn binding.discoverExtractionConfig();\n\t},\n};\n\n/**\n * Load extraction configuration from a file.\n *\n * @param filePath - Path to the configuration file\n * @returns ExtractionConfig object loaded from the file\n *\n * @deprecated Use ExtractionConfig.fromFile() instead\n */\nexport function loadConfigFile(filePath: string): ExtractionConfigType {\n\treturn ExtractionConfig.fromFile(filePath);\n}\n\n/**\n * Load extraction configuration from a specified path.\n *\n * @param path - Path to the configuration file or directory\n * @returns ExtractionConfig object or null\n *\n * @deprecated Use ExtractionConfig.fromFile() or ExtractionConfig.discover() instead\n */\nexport function loadConfigFromPath(path: string): ExtractionConfigType | null {\n\ttry {\n\t\treturn ExtractionConfig.fromFile(path);\n\t} catch {\n\t\treturn ExtractionConfig.discover();\n\t}\n}\n","import { getBinding } from \"../core/binding.js\";\n\n/**\n * Detect MIME type from raw bytes.\n *\n * Uses content inspection (magic bytes) to determine MIME type.\n * This is more accurate than extension-based detection but requires\n * reading the file content.\n *\n * @param bytes - Raw file content as Buffer\n * @returns The detected MIME type string\n *\n * @throws {Error} If MIME type cannot be determined from content\n *\n * @example\n * ```typescript\n * import { detectMimeType } from '@kreuzberg/node';\n * import * as fs from 'fs';\n *\n * // Read file content\n * const content = fs.readFileSync('document.pdf');\n *\n * // Detect MIME type from bytes\n * const mimeType = detectMimeType(content);\n * console.log(mimeType); // 'application/pdf'\n * ```\n */\nexport function detectMimeType(bytes: Buffer): string {\n\tconst binding = getBinding();\n\treturn binding.detectMimeTypeFromBytes(bytes);\n}\n\n/**\n * Detect MIME type from a file path.\n *\n * Determines the MIME type based on the file extension in the provided path.\n * By default, checks if the file exists; can be disabled with checkExists parameter.\n *\n * @param filePath - The file path to detect MIME type from (e.g., 'document.pdf')\n * @param checkExists - Whether to verify the file exists (default: true)\n * @returns The detected MIME type as a string (e.g., 'application/pdf')\n *\n * @throws {Error} If MIME type cannot be determined from the file extension,\n * or if checkExists is true and the file does not exist\n *\n * @example\n * ```typescript\n * import { detectMimeTypeFromPath } from '@kreuzberg/node';\n *\n * // Detect MIME type from existing file\n * const mimeType = detectMimeTypeFromPath('/path/to/document.pdf');\n * console.log(mimeType); // 'application/pdf'\n *\n * // Detect without checking file existence\n * const mimeType2 = detectMimeTypeFromPath('document.docx', false);\n * console.log(mimeType2); // 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n * ```\n */\nexport function detectMimeTypeFromPath(filePath: string, checkExists?: boolean): string {\n\tconst binding = getBinding();\n\treturn binding.detectMimeTypeFromPath(filePath, checkExists);\n}\n\n/**\n * Validate that a MIME type is supported by Kreuzberg.\n *\n * Checks if a MIME type is in the list of supported formats. Note that any\n * `image/*` MIME type is automatically considered valid.\n *\n * @param mimeType - The MIME type to validate (string)\n * @returns The validated MIME type (may be normalized)\n *\n * @throws {Error} If the MIME type is not supported\n *\n * @example\n * ```typescript\n * import { validateMimeType } from '@kreuzberg/node';\n *\n * // Validate supported type\n * const validated = validateMimeType('application/pdf');\n * console.log(validated); // 'application/pdf'\n *\n * // Validate custom image type\n * const validated2 = validateMimeType('image/custom-format');\n * console.log(validated2); // 'image/custom-format' (any image/* is valid)\n *\n * // Validate unsupported type (throws error)\n * try {\n *   validateMimeType('video/mp4');\n * } catch (err) {\n *   console.error(err); // Error: Unsupported format: video/mp4\n * }\n * ```\n */\nexport function validateMimeType(mimeType: string): string {\n\tconst binding = getBinding();\n\treturn binding.validateMimeType(mimeType);\n}\n\n/**\n * Get file extensions for a given MIME type.\n *\n * Returns an array of file extensions commonly associated with the specified\n * MIME type. For example, 'application/pdf' returns ['pdf'].\n *\n * @param mimeType - The MIME type to look up (e.g., 'application/pdf', 'image/jpeg')\n * @returns Array of file extensions (without leading dots)\n *\n * @throws {Error} If the MIME type is not recognized or supported\n *\n * @example\n * ```typescript\n * import { getExtensionsForMime } from '@kreuzberg/node';\n *\n * // Get extensions for PDF\n * const pdfExts = getExtensionsForMime('application/pdf');\n * console.log(pdfExts); // ['pdf']\n *\n * // Get extensions for JPEG\n * const jpegExts = getExtensionsForMime('image/jpeg');\n * console.log(jpegExts); // ['jpg', 'jpeg']\n * ```\n */\nexport function getExtensionsForMime(mimeType: string): string[] {\n\tconst binding = getBinding();\n\treturn binding.getExtensionsForMime(mimeType);\n}\n\n/**\n * Detect MIME type synchronously from raw bytes.\n *\n * Synchronous version of detectMimeType().\n * Uses content inspection (magic bytes) to determine MIME type.\n *\n * @param bytes - Raw file content as Buffer\n * @returns The detected MIME type string\n *\n * @throws {Error} If MIME type cannot be determined from content\n *\n * @deprecated This is an alias for detectMimeType() which is already synchronous\n *\n * @example\n * ```typescript\n * import { detectMimeTypeSync } from '@kreuzberg/node';\n * import * as fs from 'fs';\n *\n * const content = fs.readFileSync('document.pdf');\n * const mimeType = detectMimeTypeSync(content);\n * ```\n */\nexport function detectMimeTypeSync(bytes: Buffer): string {\n\treturn detectMimeType(bytes);\n}\n\n/**\n * Get MIME type from bytes synchronously.\n *\n * Synchronous version for getting MIME type from raw bytes.\n *\n * @param bytes - Raw file content as Buffer\n * @returns The detected MIME type string\n *\n * @throws {Error} If MIME type cannot be determined\n *\n * @deprecated Use detectMimeType() instead\n */\nexport function getMimeTypeFromBytes(bytes: Buffer): string {\n\treturn detectMimeType(bytes);\n}\n\n/**\n * Get MIME type from bytes synchronously.\n *\n * @param bytes - Raw file content as Buffer\n * @returns The detected MIME type string\n *\n * @throws {Error} If MIME type cannot be determined\n *\n * @deprecated Use detectMimeType() instead\n */\nexport function getMimeTypeFromBytesSync(bytes: Buffer): string {\n\treturn detectMimeType(bytes);\n}\n","import { getBinding } from \"../core/binding.js\";\nimport type { EmbeddingConfig } from \"../types.js\";\n\n/**\n * Embedding preset configuration.\n *\n * Contains all settings for a specific embedding model preset.\n */\nexport interface EmbeddingPreset {\n\t/** Name of the preset (e.g., \"fast\", \"balanced\", \"quality\", \"multilingual\") */\n\tname: string;\n\t/** Recommended chunk size in characters */\n\tchunkSize: number;\n\t/** Recommended overlap in characters */\n\toverlap: number;\n\t/** Model identifier (e.g., \"AllMiniLML6V2Q\", \"BGEBaseENV15\") */\n\tmodelName: string;\n\t/** Embedding vector dimensions */\n\tdimensions: number;\n\t/** Human-readable description of the preset */\n\tdescription: string;\n}\n\n/**\n * Get all available embedding presets.\n *\n * Returns an array of names of all available embedding model presets.\n *\n * @returns Array of preset names (e.g., [\"fast\", \"balanced\", \"quality\", \"multilingual\"])\n *\n * @example\n * ```typescript\n * import { listEmbeddingPresets } from '@kreuzberg/node';\n *\n * const presets = listEmbeddingPresets();\n * console.log('Available presets:', presets);\n * ```\n */\nexport function listEmbeddingPresets(): string[] {\n\tconst binding = getBinding();\n\treturn binding.listEmbeddingPresets();\n}\n\n/**\n * Get embedding preset configuration by name.\n *\n * Retrieves the configuration for a specific embedding model preset.\n * Returns null if the preset doesn't exist.\n *\n * @param name - Name of the preset (e.g., \"balanced\", \"fast\", \"quality\")\n * @returns EmbeddingPreset configuration if found, null otherwise\n *\n * @example\n * ```typescript\n * import { getEmbeddingPreset } from '@kreuzberg/node';\n *\n * const preset = getEmbeddingPreset('balanced');\n * if (preset) {\n *   console.log(`Model: ${preset.modelName}, Dims: ${preset.dimensions}`);\n *   // Model: BGEBaseENV15, Dims: 768\n * }\n * ```\n */\nexport function getEmbeddingPreset(name: string): EmbeddingPreset | null {\n\tconst binding = getBinding();\n\tconst result = binding.getEmbeddingPreset(name);\n\treturn result as unknown as EmbeddingPreset | null;\n}\n\n/**\n * Set embedding preset configuration.\n *\n * Note: The native binding does not expose a setEmbeddingPreset method.\n * Embedding presets are typically configured at the Rust level or through\n * configuration. This function is provided for API consistency.\n *\n * @param _name - Name of the preset (not used - for API consistency)\n * @param _preset - Preset configuration (not used - for API consistency)\n * @throws {Error} Not implemented - embedding presets cannot be set from TypeScript\n *\n * @example\n * ```typescript\n * // Embedding presets are typically defined in Rust or configuration\n * // This function is not available in the current API\n * ```\n */\nexport function setEmbeddingPreset(_name: string, _preset: EmbeddingPreset): void {\n\tthrow new Error(\"setEmbeddingPreset is not available. Embedding presets must be configured at the Rust level.\");\n}\n\n/**\n * Generate vector embeddings for a list of texts (synchronous).\n *\n * Requires the `embeddings` feature to be enabled (ONNX Runtime must be available).\n * Returns one float32 array per input text. An empty input returns an empty array.\n *\n * @param texts - Array of strings to embed\n * @param config - Optional embedding configuration (model preset, batch size, normalization)\n * @returns Array of float32 arrays (one embedding vector per input text)\n *\n * @throws {Error} If ONNX Runtime is not available or the model cannot be loaded\n *\n * @example\n * ```typescript\n * import { embedSync } from '@kreuzberg/node';\n *\n * const embeddings = embedSync(['Hello, world!'], { model: { type: 'preset', name: 'balanced' } });\n * console.log(embeddings.length); // 1\n * console.log(embeddings[0].length); // 768\n * ```\n */\nexport function embedSync(texts: string[], config?: EmbeddingConfig): number[][] {\n\tconst binding = getBinding();\n\treturn binding.embedSync(texts, (config ?? null) as Record<string, unknown> | null);\n}\n\n/**\n * Generate vector embeddings for a list of texts (asynchronous).\n *\n * Requires the `embeddings` feature to be enabled (ONNX Runtime must be available).\n * Returns one float32 array per input text. An empty input returns an empty array.\n *\n * @param texts - Array of strings to embed\n * @param config - Optional embedding configuration (model preset, batch size, normalization)\n * @returns Promise resolving to an array of float32 arrays (one embedding vector per input text)\n *\n * @throws {Error} If ONNX Runtime is not available or the model cannot be loaded\n *\n * @example\n * ```typescript\n * import { embed } from '@kreuzberg/node';\n *\n * const embeddings = await embed(['Hello, world!'], { model: { type: 'preset', name: 'balanced' } });\n * console.log(embeddings.length); // 1\n * console.log(embeddings[0].length); // 768\n * ```\n */\nexport async function embed(texts: string[], config?: EmbeddingConfig): Promise<number[][]> {\n\tconst binding = getBinding();\n\treturn binding.embed(texts, (config ?? null) as Record<string, unknown> | null);\n}\n","/**\n * Kreuzberg - Multi-language document intelligence framework.\n *\n * This is a TypeScript SDK around a high-performance Rust core.\n * All extraction logic, chunking, quality processing, and language detection\n * are implemented in Rust for maximum performance.\n *\n * ## Module Organization\n *\n * The SDK is organized into logical domains:\n * - **Extraction**: Single and batch document extraction with worker pool support\n * - **Types**: Core type definitions and interfaces\n * - **Errors**: Error classes and diagnostic utilities\n * - **Plugins**: Custom post-processors, validators, and OCR backends\n * - **Registry**: Plugin and document extractor management\n * - **Config**: Configuration loading and management\n * - **MIME**: MIME type detection and validation\n * - **Embeddings**: Embedding model presets\n *\n * ## API Usage Recommendations\n *\n * **For processing multiple documents**, prefer batch APIs:\n * - Use `batchExtractFiles()` / `batchExtractFilesSync()` for multiple files\n * - Use `batchExtractBytes()` / `batchExtractBytesSync()` for multiple byte arrays\n * - Use worker pool APIs for high-concurrency scenarios\n *\n * **Batch APIs provide**:\n * - Better performance (parallel processing in Rust)\n * - More reliable memory management\n * - Recommended for all multi-document workflows\n *\n * **Single extraction APIs** (`extractFile`, `extractBytes`) are suitable for:\n * - One-off document processing\n * - Interactive applications processing documents on-demand\n * - Avoid calling these in tight loops - use batch APIs instead\n *\n * ## Supported Formats\n *\n * - **Documents**: PDF, DOCX, PPTX, XLSX, DOC, PPT\n * - **Text**: Markdown, Plain Text, XML\n * - **Web**: HTML (converted to Markdown)\n * - **Data**: JSON, YAML, TOML\n * - **Email**: EML, MSG\n * - **Images**: PNG, JPEG, TIFF (with OCR support)\n *\n * @example\n * ```typescript\n * import { extractFile, batchExtractFiles } from '@kreuzberg/node';\n *\n * // Single file extraction\n * const result = await extractFile('document.pdf');\n * console.log(result.content);\n *\n * // Multiple files (recommended approach)\n * const files = ['doc1.pdf', 'doc2.docx', 'doc3.xlsx'];\n * const results = await batchExtractFiles(files);\n * results.forEach(r => console.log(r.content));\n * ```\n *\n * @module @kreuzberg/node\n */\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type {\n\tChunk,\n\tChunkingConfig,\n\tErrorClassification,\n\tExtractedImage,\n\tExtractionConfig,\n\tExtractionResult,\n\tHtmlConversionOptions,\n\tHtmlOutputConfig,\n\tHtmlPreprocessingOptions,\n\tImageExtractionConfig,\n\tKeywordConfig,\n\tLanguageDetectionConfig,\n\tOcrBackendProtocol,\n\tOcrConfig,\n\tPageContent,\n\tPageExtractionConfig,\n\tPdfConfig,\n\tPostProcessorConfig,\n\tPostProcessorProtocol,\n\tTable,\n\tTesseractConfig,\n\tTokenReductionConfig,\n\tValidatorProtocol,\n\tWorkerPool,\n\tWorkerPoolStats,\n} from \"./types.js\";\n\n// ============================================================================\n// Errors and Error Handling\n// ============================================================================\n\nexport {\n\tclassifyError,\n\tgetErrorCodeDescription,\n\tgetErrorCodeName,\n\tgetLastErrorCode,\n\tgetLastPanicContext,\n} from \"./errors/diagnostics.js\";\nexport type { PanicContext } from \"./errors.js\";\nexport {\n\tCacheError,\n\tEmbeddingError,\n\tErrorCode,\n\tImageProcessingError,\n\tKreuzbergError,\n\tMissingDependencyError,\n\tOcrError,\n\tParsingError,\n\tPluginError,\n\tValidationError,\n} from \"./errors.js\";\n\n// ============================================================================\n// Core Extraction APIs\n// ============================================================================\n\nexport {\n\tbatchExtractBytes,\n\tbatchExtractBytesSync,\n\tbatchExtractFiles,\n\tbatchExtractFilesSync,\n} from \"./extraction/batch.js\";\nexport type { PdfPageResult } from \"./extraction/render.js\";\nexport {\n\titeratePdfPages,\n\titeratePdfPagesSync,\n\tPdfPageIterator,\n\tpdfPageCount,\n\trenderPdfPage,\n\trenderPdfPageSync,\n} from \"./extraction/render.js\";\nexport {\n\textractBytes,\n\textractBytesSync,\n\textractFile,\n\textractFileSync,\n} from \"./extraction/single.js\";\n\n// ============================================================================\n// Worker Pool APIs\n// ============================================================================\n\nexport {\n\tbatchExtractFilesInWorker,\n\tcloseWorkerPool,\n\tcreateWorkerPool,\n\textractFileInWorker,\n\tgetWorkerPoolStats,\n} from \"./extraction/worker-pool.js\";\n\n// ============================================================================\n// Plugin System: Post-Processors\n// ============================================================================\n\nexport {\n\tclearPostProcessors,\n\tlistPostProcessors,\n\tregisterPostProcessor,\n\tunregisterPostProcessor,\n} from \"./plugins/post-processors.js\";\n\n// ============================================================================\n// Plugin System: Validators\n// ============================================================================\n\nexport {\n\tclearValidators,\n\tlistValidators,\n\tregisterValidator,\n\tunregisterValidator,\n} from \"./plugins/validators.js\";\n\n// ============================================================================\n// Plugin System: OCR Backends\n// ============================================================================\n\nexport {\n\tclearOcrBackends,\n\tlistOcrBackends,\n\tregisterOcrBackend,\n\tunregisterOcrBackend,\n} from \"./plugins/ocr-backends.js\";\n\n// ============================================================================\n// Registry: Document Extractors\n// ============================================================================\n\nexport {\n\tclearDocumentExtractors,\n\tlistDocumentExtractors,\n\tunregisterDocumentExtractor,\n} from \"./registry/document-extractors.js\";\n\n// ============================================================================\n// Configuration\n// ============================================================================\n\nexport * from \"./config/loader.js\";\n\n// ============================================================================\n// MIME Type Utilities\n// ============================================================================\n\nexport {\n\tdetectMimeType,\n\tdetectMimeTypeFromPath,\n\tgetExtensionsForMime,\n\tvalidateMimeType,\n} from \"./mime/utilities.js\";\n\n// ============================================================================\n// Embeddings\n// ============================================================================\n\nexport type { EmbeddingConfig, EmbeddingModelType } from \"./types.js\";\nexport type { EmbeddingPreset } from \"./embeddings/presets.js\";\nexport {\n\tembed,\n\tembedSync,\n\tgetEmbeddingPreset,\n\tlistEmbeddingPresets,\n} from \"./embeddings/presets.js\";\n\n// ============================================================================\n// Version\n// ============================================================================\n\nexport const __version__ = \"4.9.9\";\n\n// ============================================================================\n// Test Utilities\n// ============================================================================\n\nexport { __resetBindingForTests, __setBindingForTests } from \"./core/binding.js\";\n"],"mappings":";;;;;;;;AAYA,SAAS,qBAAqB;AAwG9B,SAAS,gBAAyB;AACjC,MAAI,OAAO,YAAY,YAAa,QAAO;AAC3C,MAAI,QAAQ,WAAW,KAAK,EAAG,QAAO;AACtC,MAAI,QAAQ,UAAU,KAAM,QAAO;AACnC,SAAO;AACR;AAOA,IAAI,UAAgC;AAOpC,IAAI,qBAAqB;AAOlB,SAAS,yBAAyB,OAAuB;AAC/D,QAAM,YAAsB,CAAC;AAC7B,MAAI,SAAS;AAEb,MAAI,iBAAiB,OAAO;AAC3B,aAAS,MAAM,WAAW,MAAM,SAAS;AACzC,QAAI,UAAU,KAAK,MAAM,GAAG;AAC3B,gBAAU;AAAA,QACT;AAAA,MACD;AAAA,IACD;AACA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