import { isNonNullable } from '../../types/type-guard';
import responsiveFormatFacade from './responsive-map-formatter/responsive-format-facade';
/**
 * Fomatter flex styles.
 *
 * @param {Nullable<ResponsiveType<FlexType>>} flex - flex
 * @param {Nullable<ResponsiveType<FlexGrowType>>} flexGrow - flex-grow
 * @param {Nullable<ResponsiveType<FlexShrinkType>>} flexShrink - flex-shrink
 * @param {Nullable<ResponsiveType<FlexBasisType>>} flexBasis - flex-basis
 * @returns {FormattedStylesType} - formatted styles
 */
export function formatFlexStyles(flex, flexGrow, flexShrink, flexBasis) {
  if (isNonNullable(flex)) {
    return { flex: `${responsiveFormatFacade.formatCustom(flex)}` };
  }
  else {
    return {
      flexGrow: isNonNullable(flexGrow)
        ? `${responsiveFormatFacade.formatCustom(flexGrow)}`
        : undefined,
      flexShrink: isNonNullable(flexShrink)
        ? `${responsiveFormatFacade.formatCustom(flexShrink)}`
        : undefined,
      flexBasis: isNonNullable(flexBasis)
        ? `${responsiveFormatFacade.formatCustom(flexBasis)}`
        : undefined,
    };
  }
}
