import getColor from "../../../../utils/colors/getColor.js";
import { icons } from "../../ElectionIcon/index.js";
import classes from './styles.module.scss';
import useBadgeProps from './useBadgeProps';
const Badge = function Badge(props) {
  const {
    cx,
    cy,
    dotSize,
    code,
    transform
  } = props;
  const strokeSize = 1;
  const badgeProps = useBadgeProps(code);
  const iconSize = dotSize * 1.25;
  if (!badgeProps) {
    return null;
  }
  const {
    bg,
    fg,
    stroke,
    iconType
  } = badgeProps;
  const iconConfig = icons[iconType];
  const {
    icon: Icon,
    props: iconProps = {}
  } = iconConfig;
  const baseX = cx && cx - dotSize / 2;
  const baseY = cy && cy + dotSize / 2;
  return <g>
      <circle cx={baseX} cy={baseY} r={dotSize} fill={getColor(bg)} stroke={getColor(stroke)} strokeWidth={strokeSize} transform={transform} className={classes.circle} />
      <svg x={baseX} y={baseY} width={dotSize} height={dotSize} fill="blue" transform={transform} className={classes.positioner}>
        <Icon color={getColor(fg)} className={classes.inner} size={iconSize} {...iconProps} />
      </svg>
    </g>;
};
Badge.defaultProps = {
  cx: undefined,
  cy: undefined,
  transform: undefined,
  dotSize: 12
};
export default Badge;