/** * WHMCS Normalization Utilities (domain-internal) */ /** * Normalize status using provided status map. * Generic helper for consistent status mapping. */ export function normalizeStatus( status: string | null | undefined, statusMap: Record, defaultStatus: T ): T { if (!status) return defaultStatus; const mapped = statusMap[status.trim().toLowerCase()]; return mapped ?? defaultStatus; } /** * Normalize billing cycle using provided cycle map. * Generic helper for consistent cycle mapping. */ export function normalizeCycle( cycle: string | null | undefined, cycleMap: Record, defaultCycle: T ): T { if (!cycle) return defaultCycle; const normalized = cycle .trim() .toLowerCase() .replace(/[_\s-]+/g, " "); return cycleMap[normalized] ?? defaultCycle; }