// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

import { useContext } from 'react';
import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import { intentIconMap } from '../intentIconMap';
import Action from '../Action';
import Icon from '../Icon';
import OnDarkContext from '../OnDarkContext';
import { jsx as _jsx } from "react/jsx-runtime";
const toIcon = (icon, intent) => {
  if (icon === false) {
    return undefined;
  }
  if ((icon === true || !icon) && intent) {
    icon = intentIconMap[intent];
  }
  return Icon.create(icon, intent ? {
    name: intentIconMap[intent]
  } : undefined);
};

/**
 * `Status` component is used for indicating state of an object or the system.
 * @since 0.0.68
 */
const Status = _ref => {
  let {
    baseClassName = `${CLS_PREFIX}status`,
    className,
    children,
    icon,
    intent,
    progress,
    compact,
    flip,
    outerProps = {},
    ...props
  } = _ref;
  if (intent === 'muted') {
    intent = 'inactive';
  }
  return /*#__PURE__*/_jsx(Action, {
    component: "span",
    icon: compact ? undefined : toIcon(icon, intent),
    className: classNames(baseClassName, {
      [`${baseClassName}--${intent}`]: intent && !progress,
      [`${baseClassName}--on-dark`]: useContext(OnDarkContext)
    }, className),
    outerProps: {
      ...outerProps,
      className: classNames({
        [`${baseClassName}--compact`]: compact,
        [`${baseClassName}--flip`]: flip
      }, outerProps.className)
    },
    progress: progress,
    ...props,
    children: children
  });
};
export default Status;