/**
 * These options define what we hide, or shorten, depending on a results
 * table's given format, or its container's size. We also adjust the results
 * table's text size based on its container size but this is done via scss, and
 * each component that needs to do so should refer to the size prop returned by
 * the results table's context.
 */

/**
 * Our default options are to show everything, in its longest format
 * @property {string}  contestNameFormat       - The format passed to the `ContestName` component
 * @property {string}  candidateNameFormat     - The format passed to the `CandidateName` component
 * @property {string}  voteInFormat            - The format passed to the `ResultsVoteIn` component
 * @property {boolean} showVotes               - Whether to show the total votes column
 * @property {boolean} showRecountStatus       - Whether to show when a recount is complete
 * @property {boolean} showRating              - Whether to show a contest's election forecast rating
 * @property {boolean} showPolarity            - Whether to show a candidate's polarity in a parenthetical
 * @property {boolean} showContestDescription  - Whether to show a contest's description
 * @property {boolean} contestTypeFormat       - The format passed to the `ContestType` component
 * @property {boolean} disableFooter           - Whether to show the table's footer
 * @property {boolean} showBar                 - Whether to show the bar visualization on each row
*/
const defaultOptions = {
  contestNameFormat: 'long',
  candidateNameFormat: 'full',
  voteInFormat: 'full',
  showVotes: true,
  showRecountStatus: true,
  showRating: true,
  showPolarity: true,
  showContestDescription: true,
  contestTypeFormat: 'full',
  showBar: true,
  disableFooter: false
};
const defaultSizeOverrides = {
  small: {
    contestNameFormat: 'short',
    candidateNameFormat: 'short',
    voteInFormat: 'short',
    showVotes: false,
    showRecountStatus: false,
    showRating: false,
    showPolarity: false,
    contestTypeFormat: 'party-only'
  },
  medium: {
    contestNameFormat: 'medium',
    voteInFormat: 'short',
    candidateNameFormat: 'short',
    contestTypeFormat: 'party-only'
  },
  large: {
    // Show everything as defined by the format
  }
};

/**
 * Our standard format follows our defaults, but our
 * condensed and tooltip formats override certain variables
 */
const optionsByFormat = {
  standard: {
    ...defaultOptions
  },
  condensed: {
    ...defaultOptions,
    voteInFormat: 'short',
    showVotes: false,
    showRecountStatus: false,
    showRating: false,
    showPolarity: false,
    showContestDescription: false,
    showBar: false
  },
  tooltip: {
    ...defaultOptions,
    voteInFormat: 'short',
    showRecountStatus: false,
    showRating: false,
    showPolarity: false,
    showContestDescription: false,
    showBar: false
  }
};

/**
 * Since default size options end up overriding the format's default options,
 * we can fine tune some options to be resoponsive to format/size combinations here
 *
 */
const optionsBySize = {
  standard: {
    ...defaultSizeOverrides
  },
  condensed: {
    ...defaultSizeOverrides,
    medium: {
      ...defaultSizeOverrides.medium,
      candidateNameFormat: 'full' // Since we never show votes in the condensed table, we have more room for a full name
    }
  },

  tooltip: {
    ...defaultSizeOverrides,
    small: {
      ...defaultSizeOverrides.small,
      showVotes: true // We show votes here  because this is the only place we're providing county-level results, currently
    }
  }
};

export { defaultOptions, optionsBySize, optionsByFormat };