"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalizePhoneNumber = normalizePhoneNumber;
exports.validateKenyanPhone = validateKenyanPhone;
exports.formatForDisplay = formatForDisplay;
exports.formatForMpesa = formatForMpesa;
function normalizePhoneNumber(phone) {
    let cleaned = phone.replace(/[\s\-()]+/g, '');
    cleaned = cleaned.replace(/^\+/, '');
    if (cleaned.startsWith('0')) {
        cleaned = '254' + cleaned.slice(1);
    }
    else if (/^[17]\d{8}$/.test(cleaned)) {
        cleaned = '254' + cleaned;
    }
    else if (cleaned.startsWith('254') && cleaned.length === 12) {
    }
    return cleaned;
}
function validateKenyanPhone(phone) {
    const normalized = normalizePhoneNumber(phone);
    if (!/^254[17]\d{8}$/.test(normalized))
        return false;
    const prefix = normalized.slice(3, 6);
    const safaricom = /^(7[012456789]|1[01])/;
    const airtel = /^(7[34589]|10|12)/;
    return safaricom.test(prefix) || airtel.test(prefix);
}
function formatForDisplay(phone) {
    const normalized = normalizePhoneNumber(phone);
    const countryCode = normalized.slice(0, 3);
    const lastTwo = normalized.slice(-2);
    return `${countryCode}******${lastTwo}`;
}
function formatForMpesa(phone) {
    return normalizePhoneNumber(phone);
}
