/** Normalise Ethiopian local phone (09…/07…) to E.164; pass email through unchanged. */ export function normaliseIdentifier(raw: string): string { const v = raw.trim(); const digits = v.replace(/\D/g, ""); if (digits.length >= 9 && (v.startsWith("0") || v.startsWith("+251"))) { const local = digits.startsWith("251") ? digits.slice(3) : digits.replace(/^0/, ""); return `+251${local}`; } return v.toLowerCase(); } /** Mask all but the first 7 chars of an E.164 phone for display. */ export const maskPhone = (p: string) => p.length > 4 ? `${p.slice(0, 7)}${"*".repeat(Math.max(0, p.length - 7))}` : p; /** Mask the local part of an email for display (j***e@example.com). */ export const maskEmail = (email: string) => { const [local, domain] = email.split("@"); if (!local || !domain) return email; if (local.length <= 2) return `${local[0] ?? ""}***@${domain}`; return `${local[0]}***${local[local.length - 1]}@${domain}`; };