import { isSpacingTokenType, isBreakpointsForPrefixType, isDirectionalSpacingType, } from '../../../types/type-guard';
import { LogUtility } from '../../../utils/log';
import { Spacing } from '../../../constants/tokens/spacing';
import { ResponsiveClassStringFormatter } from './responsive-class-string-formatter';
const GAP_DIRECTION_CLASS_PARTIAL_MAP = {
  x: 'gap-col',
  y: 'gap-row',
};
/**
 * A class for format GapType with BreakpointsForPrefixType to CSS class string
 *
 * @augments ResponsiveClassStringFormatter
 */
class ResponsiveGapFormatter extends ResponsiveClassStringFormatter {
  /**
   * Given a gap value, return the corresponding CSS class name
   *
   * @param {GapType} input - GapType
   * @param {BreakpointsForPrefixType} [breakpoint] - Breakpoints for prefix of the class
   * @returns {string} - Css class for corresponding gap.
   */
  formatToken(input, breakpoint) {
    const prefix = isBreakpointsForPrefixType(breakpoint) ? `${breakpoint}:` : '';
    if (isSpacingTokenType(input)) {
      return `${prefix}v-gap-${input}`;
    }
    else if (isDirectionalSpacingType(input)) {
      return Object.keys(input)
        .map((direction) => {
        return `${prefix}v-${GAP_DIRECTION_CLASS_PARTIAL_MAP[direction]}-${input[direction]}`;
      })
        .join(' ');
    }
    else {
      LogUtility.warn(`The gap value ${input} is invalid, it must be a value of: `, Spacing);
      return '';
    }
  }
}
export default new ResponsiveGapFormatter();
