import { getStateName } from "../index.js";

/**
 * Utility to format names of Lt. Governor contests
 *
 * @param {Object} metadata
 * @param {Object} opts
 * @param {string} opts.format
 * @returns {string}
 */
const stateLtGovContestName = function stateLtGovContestName(metadata, opts = {}) {
  const {
    stateFips
  } = metadata;
  const {
    format = 'long'
  } = opts;

  // e.g., "NM"
  if (format === 'tiny') {
    return getStateName(stateFips, {
      format: 'abbr'
    });
  }

  // e.g., "NM Lt. Gov."
  if (format === 'short') {
    const stateName = getStateName(stateFips, {
      format: 'abbr'
    });
    return `${stateName} Lt. Gov.`;
  }

  // e.g., "New Mexico Lt. Governor"
  if (format === 'medium') {
    const stateName = getStateName(stateFips, {
      format: 'name'
    });
    return `${stateName} Lt. Governor`;
  }

  // e.g., "Lt. Governor"
  if (format === 'no-state') {
    return 'Lt. Governor';
  }

  // e.g., "Lt. Governor, New Mexico"
  const stateName = getStateName(stateFips, {
    format: 'name'
  });
  return `Lt. Governor, ${stateName}`;
};
export default stateLtGovContestName;