/**
 * @deprecated Use `Pills` from `@material-hu/components/design-system/Pills` instead.
 * The local `Severities` enum maps to Hugo's `type` prop — verify each variant before migrating.
 */
import { FC } from 'react';

import Chip, { ChipProps } from '@material-hu/mui/Chip';
import { alpha, useTheme } from '@material-hu/mui/styles';
import Typography, { TypographyProps } from '@material-hu/mui/Typography';

import { Severities } from './types';

export { Severities };

export type SeverityPillProps = ChipProps & {
  severity?: Severities;
  label?: string | number;
  typographyProps?: TypographyProps;
};

export const SeverityPill: FC<SeverityPillProps> = props => {
  const {
    severity = Severities.INFO,
    label = '',
    typographyProps = {},
    ...chipProps
  } = props;

  const theme = useTheme();

  const Colors = {
    [Severities.SUCCESS]: {
      backgroundColor: alpha(theme.palette.success.main, 0.12),
      color: theme.palette.success.dark,
    },
    [Severities.ERROR]: {
      backgroundColor: alpha(theme.palette.error.main, 0.12),
      color: theme.palette.error.dark,
    },
    [Severities.WARNING]: {
      backgroundColor: alpha(theme.palette.warning.main, 0.12),
      color: theme.palette.warning.dark,
    },
    [Severities.RECOMMENDED]: {
      backgroundColor: alpha('#9747FF', 0.12),
      color: '#6941C6',
    },
    [Severities.INFO]: {
      backgroundColor: alpha('#06AED4', 0.12),
      color: '#0E7090',
    },
    [Severities.ACTIVE]: {
      backgroundColor: alpha('#15B79E', 0.12),
      color: '#107569',
    },
    [Severities.INACTIVE]: {
      backgroundColor: '#11192714',
      color: '#757575',
    },
    [Severities.SIMPLE]: {
      backgroundColor: 'transparent',
      color: '#757575',
      border: `1px solid #1119271F`,
    },
  } as const;

  return (
    <Chip
      variant="filled"
      label={
        <Typography
          variant="overline"
          {...typographyProps}
        >
          {label}
        </Typography>
      }
      {...chipProps}
      sx={{
        ...Colors[severity],
        ...chipProps.sx,
      }}
    />
  );
};

export default SeverityPill;
