import type { Theme } from '@mui/material';
import { autocompleteClasses, inputAdornmentClasses } from '@mui/material';
import type { Components } from '@mui/material/styles';

import { SIZE_MEDIUM } from '@/mui/constants';

export default function MuiInputAdornment(theme: Theme): Components['MuiInputAdornment'] {
  return {
    defaultProps: {
      size: SIZE_MEDIUM,
    },
    styleOverrides: {
      root: {
        height: '0.01em',
        '&:empty': {
          display: 'none',
        },
        marginLeft: 0,
        marginRight: theme.spacing(-3),
        alignSelf: 'flex-start',

        [`.${autocompleteClasses.endAdornment}`]: {
          position: 'static !important',
        },

        [`.${inputAdornmentClasses.root}`]: {
          position: 'static !important',
        },
      },
      positionStart: {
        marginTop: '0 !important',
        marginRight: theme.spacing(-3),
      },
    },
  };
}
