import 'core-js/modules/es.object.assign.js';
import { __rest } from '../../../_virtual/_tslib.js';
import { jsx } from 'react/jsx-runtime';
import { useTheme, Button as Button$1, CircularProgress } from '@mui/material';
import { ButtonColors } from '../../styles/designTokens/button.js';

const Button = _a => {
  var _b, _c, _d;
  var {
      to,
      children,
      color = 'primary',
      variant = 'contained',
      loading = false,
      disabled = false,
      selected = false,
      component
    } = _a,
    props = __rest(_a, ["to", "children", "color", "variant", "loading", "disabled", "selected", "component"]);
  const theme = useTheme();
  const variantStyle = ButtonColors(theme)[variant];
  const selectedStyle = variantStyle.hover;
  return jsx(Button$1, Object.assign({
    to: to,
    role: to && 'link',
    disabled: loading || disabled,
    startIcon: loading && jsx(CircularProgress, {
      size: 20,
      color: "inherit"
    }),
    color: color,
    component: component,
    variant: variant,
    style: Object.assign({}, selected && {
      color: (_b = selectedStyle === null || selectedStyle === void 0 ? void 0 : selectedStyle.color) === null || _b === void 0 ? void 0 : _b[color],
      background: (_c = selectedStyle === null || selectedStyle === void 0 ? void 0 : selectedStyle.background) === null || _c === void 0 ? void 0 : _c[color],
      borderColor: (_d = selectedStyle === null || selectedStyle === void 0 ? void 0 : selectedStyle.borderColor) === null || _d === void 0 ? void 0 : _d[color]
    })
  }, props, {
    children: children
  }));
};

export { Button, Button as default };
