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

import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import Icon, { ICON_SIZE_12, ICON_SIZE_16, ICON_SIZE_24, ICON_SIZE_32 } from '../Icon';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
/**
 * `Heading` is used as a text title (or a subtitle) to define the hierarchy and the structure of the content.
 * @since 2.3.0
 */
const Heading = _ref => {
  let {
    baseClassName = `${CLS_PREFIX}heading`,
    className,
    icon,
    children,
    component: Tag,
    level = 1,
    ...props
  } = _ref;
  if (!Tag) {
    Tag = `h${level}`;
  }
  let iconSize = ICON_SIZE_16;
  if (level === 1) {
    iconSize = ICON_SIZE_32;
  }
  if (level === 2 || level === 3) {
    iconSize = ICON_SIZE_24;
  }
  if (level === 6) {
    iconSize = ICON_SIZE_12;
  }
  return /*#__PURE__*/_jsxs(Tag, {
    className: classNames(baseClassName, {
      [`${baseClassName}--h${level}`]: level,
      [`${baseClassName}--icon`]: icon
    }, className),
    ...props,
    children: [Icon.create(icon, {
      className: `${baseClassName}__icon`,
      size: iconSize
    }), icon ? /*#__PURE__*/_jsx("span", {
      className: `${baseClassName}__text`,
      children: children
    }) : children]
  });
};
export default Heading;