import React, { createElement as _createElement } from 'react';
import classnames from 'classnames';
import { faChevronRight } from '@fortawesome/free-solid-svg-icons/faChevronRight';
import { FontAwesomeIcon } from '../font-awesome-icon';
import { TruncateWithTooltip } from '../truncate-with-tooltip';
import { TOOLTIP_DELAY_TYPES, TOOLTIP_PLACEMENT_TYPES } from '../tooltip';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
const DropdownItemTitle = ({
  option,
  isMultiLevelHandler = false
}) => {
  const {
    iconClass,
    icon,
    title,
    subtext,
    testId,
    tooltipPlacement,
    tooltipText,
    tooltipDocsLink,
    tooltipTestId,
    key
  } = option;
  const props = {
    tooltipText,
    tooltipPlacement: tooltipPlacement || TOOLTIP_PLACEMENT_TYPES.RIGHT,
    tooltipDelayType: TOOLTIP_DELAY_TYPES.SLOW,
    tooltipDocsLink,
    tooltipTestId
  };
  const itemTitle = /*#__PURE__*/_jsx("div", {
    "test-id": testId ? `menu-item-title-${testId}` : '',
    children: /*#__PURE__*/_jsxs("span", {
      className: classnames('drop-item-title-content', {
        'with-multilevel-handler': isMultiLevelHandler
      }),
      children: [icon && /*#__PURE__*/_jsx(FontAwesomeIcon, {
        icon: icon,
        className: "drop-icon"
      }), iconClass && /*#__PURE__*/_jsx("i", {
        className: `drop-icon ${iconClass}`
      }), title, isMultiLevelHandler && /*#__PURE__*/_jsx(FontAwesomeIcon, {
        icon: faChevronRight,
        className: "multilevel-handler"
      })]
    })
  });
  const itemSubText = /*#__PURE__*/_jsx("div", {
    "test-id": testId ? `menu-item-subtext-${testId}` : '',
    children: /*#__PURE__*/_jsx("span", {
      className: "menu-item-subtext",
      children: subtext
    })
  });
  const withTruncatableText = /*#__PURE__*/_jsxs(_Fragment, {
    children: [/*#__PURE__*/_createElement(TruncateWithTooltip, {
      ...props,
      key: key
    }, itemTitle), subtext && /*#__PURE__*/_createElement(TruncateWithTooltip, {
      ...props,
      tooltipTestId: `${tooltipTestId}-subtext`,
      key: `${key}-subtext`
    }, itemSubText)]
  });
  return /*#__PURE__*/_jsx("div", {
    className: classnames('drop-item-content-wrap', {
      'has-icon': icon || iconClass
    }),
    children: !!tooltipText ? /*#__PURE__*/_jsxs(_Fragment, {
      children: [itemTitle, subtext && itemSubText]
    }) : withTruncatableText
  });
};
export default DropdownItemTitle;