/**
 * Utility function to normalize a stateful color set with a given set of
 * states. Generally, a stateful color set can be specified in shorthand by
 * just providing a string, which will be interpreted as a color set specifying
 * only the first state as the color provided.
 *
 * ```js
 *
 * import { normalizeStatefulColorSet } from '@politico/interactive-style';
 * ```
 *
 * @param {string|Object} color
 *   The color or set of colors that are specified in this stateful color set.
 * @param {string[]} [states=['default']]
 *   The states that this statueful color set spans.
 * @returns {Object}
 *   A mapping of states onto colors. If a color is not provided for a certain
 *   state then its value is set as `undefined`.
 */
const normalizeStatefulColorSet = function normalizeStatefulColorSet(color, states = ['default']) {
  const colors = typeof color === 'string' ? {
    [states[0]]: color
  } : color || {};
  return Object.fromEntries(states.map(state => [state, colors[state]]));
};
export default normalizeStatefulColorSet;