/**
 * Zoom requires both a first and a last name. All words but the last become the firstName and
 * the last word becomes the lastName. A single-word name (no last name to split off) keeps that
 * word as both firstName and lastName — no title/salutation is ever added.
 */
export function splitZoomContactName(fullName: string): { zoomFirstName: string; zoomLastName: string } {
  const parts = (fullName ?? '').trim().split(/\s+/).filter(Boolean);
  if (parts.length > 1) {
    return { zoomFirstName: parts.slice(0, -1).join(' '), zoomLastName: parts[parts.length - 1] };
  }
  const soleName = parts[0] ?? fullName;
  return { zoomFirstName: soleName, zoomLastName: '.' };
}
