import { isSpacingTokenType, isDirectionalSpacingType } from '../../../types/type-guard';
import { LogUtility } from '../../../utils/log';
import { Spacing } from '../../../constants/tokens/spacing';
import { ResponsiveCSSTextFormatter } from './responsive-css-text-formatter';
const PADDING_DIRECTION_STYLE_MAP = {
  top: ['padding-top'],
  bottom: ['padding-bottom'],
  left: ['padding-left'],
  right: ['padding-right'],
  x: ['padding-left', 'padding-right'],
  y: ['padding-top', 'padding-bottom'],
};
/**
 * Get the padding style content.
 */
class ResponsivePaddingStyleFormatter extends ResponsiveCSSTextFormatter {
  /**
   * Given a padding type, return the corresponding string of CSS text.
   *
   * @param {PaddingType} input - PaddingType
   * @returns {string} - CSS text.
   */
  formatToken(input) {
    if (isSpacingTokenType(input)) {
      return `padding:${Spacing[input]}px`;
    }
    else if (isDirectionalSpacingType(input)) {
      return Object.keys(input)
        .map((direction) => {
        return PADDING_DIRECTION_STYLE_MAP[direction]
          .map((item) => {
          return `${item}:${Spacing[input[direction]]}px`;
        })
          .join(';');
      })
        .join(';');
    }
    else {
      LogUtility.warn(`The padding value ${input} is invalid, it must be a value of: `, Spacing);
      return '';
    }
  }
}
export default new ResponsivePaddingStyleFormatter();
