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

import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import Icon from '../Icon';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const DEFAULT_TAG = 'span';

/**
 * `Label` component is used for showing multiple characteristics or attributes of an object.
 * @since 0.0.42
 */
const Label = _ref => {
  let {
    baseClassName = `${CLS_PREFIX}label`,
    children,
    className,
    component = DEFAULT_TAG,
    icon,
    intent = 'inactive',
    view,
    size,
    caps,
    ...props
  } = _ref;
  icon = Icon.create(icon, {
    className: `${baseClassName}__icon`,
    size: size === 'lg' ? '16' : '12'
  });
  if (caps === undefined && (!size || size === 'sm')) {
    caps = true;
  }
  let Tag = component;
  if (Tag === DEFAULT_TAG && props.onClick) {
    Tag = 'button';
  }
  const componentProps = {};
  if (Tag === 'button') {
    componentProps.type = 'button';
  }
  return /*#__PURE__*/_jsxs(Tag, {
    className: classNames(baseClassName, {
      [`${baseClassName}--${view}`]: view,
      [`${baseClassName}--${size}`]: size,
      [`${baseClassName}--${intent}`]: intent,
      [`${baseClassName}--caps`]: caps
    }, className),
    ...componentProps,
    ...props,
    children: [icon, children && /*#__PURE__*/_jsx("span", {
      className: `${baseClassName}__content`,
      children: children
    })]
  });
};
export default Label;