/**
 * Local OCR/VLM Configuration
 *
 * Environment-based configuration for local GPU processing.
 * Concurrency and timeout settings for local GPU processing.
 */
/** Default maximum concurrent OCR requests for local processing */
export const OCR_MAX_CONCURRENT_DEFAULT = 2;
/** Maximum allowed concurrent OCR requests (GPU memory constraint) */
const OCR_MAX_CONCURRENT_LIMIT = 8;
/**
 * Get OCR max concurrent requests from environment.
 * Uses OCR_MAX_CONCURRENT env var, default 2, max 8.
 */
export function getOcrMaxConcurrent() {
    const raw = process.env.OCR_MAX_CONCURRENT;
    if (raw === undefined || raw === '')
        return OCR_MAX_CONCURRENT_DEFAULT;
    const parsed = parseInt(raw, 10);
    if (Number.isNaN(parsed)) {
        throw new Error(`Invalid OCR_MAX_CONCURRENT="${raw}". Must be a positive integer (1-${OCR_MAX_CONCURRENT_LIMIT}).`);
    }
    if (parsed < 1) {
        throw new Error(`OCR_MAX_CONCURRENT=${parsed} must be at least 1.`);
    }
    if (parsed > OCR_MAX_CONCURRENT_LIMIT) {
        throw new Error(`OCR_MAX_CONCURRENT=${parsed} exceeds local GPU limit of ${OCR_MAX_CONCURRENT_LIMIT}. ` +
            `Local Marker processing is GPU-bound; more than ${OCR_MAX_CONCURRENT_LIMIT} concurrent requests will cause OOM.`);
    }
    return parsed;
}
/**
 * Get VLM concurrency limit from environment.
 * Uses VLM_CONCURRENCY env var, default 2.
 */
export function getVlmConcurrency() {
    const raw = process.env.VLM_CONCURRENCY;
    if (raw === undefined || raw === '')
        return 2;
    const parsed = parseInt(raw, 10);
    if (Number.isNaN(parsed)) {
        throw new Error(`Invalid VLM_CONCURRENCY="${raw}". Must be a positive integer.`);
    }
    if (parsed < 1) {
        throw new Error('VLM_CONCURRENCY must be at least 1.');
    }
    return parsed;
}
//# sourceMappingURL=config-local.js.map