/**
 * Check values against an allow list and/or block list.
 * Returns null if all values pass, or an error message string if any are rejected.
 * Comparison is case-insensitive and whitespace-trimmed.
 */
export function checkAllowBlockList(values, allowList, blockList) {
    if (allowList.length === 0 && blockList.length === 0)
        return null;
    const normalize = (s) => s.toLowerCase().trim();
    const normalizedAllow = allowList.map(normalize);
    const normalizedBlock = blockList.map(normalize);
    for (const v of values) {
        const nv = normalize(v);
        if (nv === "")
            continue;
        if (normalizedBlock.length > 0 && normalizedBlock.includes(nv)) {
            return `"${v}" is in the blockList.`;
        }
        if (normalizedAllow.length > 0 && !normalizedAllow.includes(nv)) {
            return `"${v}" is not in the allowList.`;
        }
    }
    return null;
}
/**
 * Check that a path starts with one of the allowed prefixes.
 * Returns null if allowed, or an error message string if rejected.
 */
export function checkAllowedPaths(targetPath, allowedPaths) {
    if (allowedPaths.length === 0)
        return null;
    for (const prefix of allowedPaths) {
        if (targetPath.startsWith(prefix))
            return null;
    }
    return `Path "${targetPath}" is not under any of the allowed paths: ${allowedPaths.join(", ")}.`;
}
