// @flow
import type { BreakPoints } from '../../breakpoints';
import type { HideProps } from './hide.proptypes';

export const getHideDisplay = (
  hide?: ('sm' | 'md' | 'xl') | Array<BreakPoints>,
  size: BreakPoints,
) => {
  if (typeof hide === 'string') {
    // eslint-disable-next-line no-console
    console.warn(
      'string value for hide is being deprecated. Please pass values in as an array.',
    );
    return hide === size ? 'none' : undefined;
  }

  if (hide && hide[0]) {
    return hide.includes(size) ? 'none' : undefined;
  }
};

export const getHideDisplaySm = ({ hide }: HideProps) =>
  getHideDisplay(hide, 'sm');

export const getHideDisplayMd = ({ hide }: HideProps) =>
  getHideDisplay(hide, 'md');

export const getHideDisplayLg = ({ hide }: HideProps) =>
  getHideDisplay(hide, 'lg');

export const getHideDisplayXl = ({ hide }: HideProps) =>
  getHideDisplay(hide, 'xl');

export const legacyGetHideDisplayMd = ({ hide }: HideProps) =>
  hide === 'md' ? 'none' : undefined;
