"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _classnames = _interopRequireDefault(require("classnames"));
var _constants = require("../../constants");
var _Icon = _interopRequireDefault(require("../Icon"));
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

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 = `${_constants.CLS_PREFIX}label`,
    children,
    className,
    component = DEFAULT_TAG,
    icon,
    intent = 'inactive',
    view,
    size,
    caps,
    ...props
  } = _ref;
  icon = _Icon.default.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__*/(0, _jsxRuntime.jsxs)(Tag, {
    className: (0, _classnames.default)(baseClassName, {
      [`${baseClassName}--${view}`]: view,
      [`${baseClassName}--${size}`]: size,
      [`${baseClassName}--${intent}`]: intent,
      [`${baseClassName}--caps`]: caps
    }, className),
    ...componentProps,
    ...props,
    children: [icon, children && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: `${baseClassName}__content`,
      children: children
    })]
  });
};
var _default = exports.default = Label;