function coerceDisplayName(value) {
  if (typeof value === "string") return value;
  if (value == null) return "";
  return String(value);
}
function coerceDisplayNameOrNull(value) {
  if (value == null) return null;
  if (typeof value === "string") return value;
  return String(value);
}
function deriveDisplayName(firstName, lastName) {
  const first = (firstName ?? "").trim();
  const last = (lastName ?? "").trim();
  return [first, last].filter((part) => part.length > 0).join(" ").trim();
}
function isDerivedDisplayName(current, firstName, lastName) {
  const trimmed = (current ?? "").trim();
  if (trimmed.length === 0) return true;
  return trimmed === deriveDisplayName(firstName, lastName);
}
function deriveDisplayNameFromEmail(email) {
  if (typeof email !== "string") return null;
  const trimmed = email.trim();
  if (!trimmed.length) return null;
  const atIndex = trimmed.indexOf("@");
  const localPart = (atIndex >= 0 ? trimmed.slice(0, atIndex) : trimmed).trim();
  if (!localPart.length) return null;
  const segments = localPart.split(/[._\-+]+/).map((part) => part.trim()).filter((part) => part.length > 0);
  if (segments.length === 0) return null;
  return segments.map((part) => part.charAt(0).toLocaleUpperCase() + part.slice(1)).join(" ");
}
export {
  coerceDisplayName,
  coerceDisplayNameOrNull,
  deriveDisplayName,
  deriveDisplayNameFromEmail,
  isDerivedDisplayName
};
//# sourceMappingURL=displayName.js.map
