import { isDirectionalMarginType, isBreakpointsForPrefixType, isMarginValueType, } from '../../../types/type-guard';
import { LogUtility } from '../../../utils/log';
import { Spacing } from '../../../constants/tokens/spacing';
import { ResponsiveClassStringFormatter } from './responsive-class-string-formatter';
const MARGIN_DIRECTION_CLASS_PARTIAL_MAP = {
  top: 'mt',
  bottom: 'mb',
  left: 'ml',
  right: 'mr',
  x: 'mx',
  y: 'my',
};
/**
 * A class for format MarginType with BreakpointsForPrefixType to CSS class string
 *
 * @deprecated Please use the `ResponsiveMarginStyleFormatter` instead.
 * @augments ResponsiveClassStringFormatter
 */
class ResponsiveMarginFormatter extends ResponsiveClassStringFormatter {
  /**
   * Given a margin type, return a string of CSS classes that can be used to apply the margin to an element
   *
   * @param {MarginType} input - MarginType
   * @param {BreakpointsForPrefixType} [breakpoint] - Breakpoints for prefix of the class
   * @returns {string} - A string of CSS classes.
   */
  formatToken(input, breakpoint) {
    const prefix = isBreakpointsForPrefixType(breakpoint) ? `${breakpoint}:` : '';
    if (isMarginValueType(input)) {
      return `${prefix}v-m-${input}`;
    }
    else if (isDirectionalMarginType(input)) {
      return Object.keys(input)
        .map((direction) => {
        return `${prefix}v-${MARGIN_DIRECTION_CLASS_PARTIAL_MAP[direction]}-${input[direction]}`;
      })
        .join(' ');
    }
    else {
      LogUtility.warn(`The margin value ${input} is invalid, it must be a value of: `, Spacing);
      return '';
    }
  }
}
export default new ResponsiveMarginFormatter();
