const POSTCODE_RE = /^([1-9][0-9]{3})\s?([A-Za-z]{2})$/;
// Per PostNL spec these letter combinations are never issued.
const FORBIDDEN_LETTER_PAIRS = new Set(['SA', 'SD', 'SS']);
/**
 * Normalize a Dutch postcode to the canonical `1234AB` form.
 * Returns `null` when the input does not match the expected pattern
 * or uses a forbidden letter pair.
 */
export function normalizePostcode(input) {
    if (typeof input !== 'string')
        return null;
    const m = POSTCODE_RE.exec(input.trim());
    if (!m)
        return null;
    const letters = m[2].toUpperCase();
    if (FORBIDDEN_LETTER_PAIRS.has(letters))
        return null;
    return `${m[1]}${letters}`;
}
/** Cheap synchronous format check. Does not verify the postcode exists. */
export function isValidPostcodeFormat(input) {
    return normalizePostcode(input) !== null;
}
/**
 * Parse a huisnummer input into a positive integer. Accepts numbers or
 * numeric strings (trimmed). Returns `null` for anything else.
 */
export function parseHuisnummer(input) {
    if (typeof input === 'number' && Number.isInteger(input) && input > 0) {
        return input;
    }
    if (typeof input === 'string') {
        const t = input.trim();
        if (/^[0-9]+$/.test(t)) {
            const n = Number.parseInt(t, 10);
            if (n > 0)
                return n;
        }
    }
    return null;
}
//# sourceMappingURL=format.js.map