import _extends from "@babel/runtime/helpers/extends";
// Copyright 1999-2020. Plesk International GmbH. All rights reserved.
import React, { useContext } from 'react';
import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import OnDarkContext from '../OnDarkContext';

/**
 * `Text` component is used for displaying inline text. For text blocks use [Paragraph](#!/Paragraph).
 * @since 1.1.0
 */
const Text = ({
  baseClassName = "".concat(CLS_PREFIX, "text"),
  className,
  children,
  component: Tag,
  intent,
  fontSize,
  bold = false,
  italic = false,
  mark = false,
  truncate = false,
  nowrap = false,
  ...props
}) => {
  if (!Tag) {
    Tag = mark ? 'mark' : 'span';
  }

  const onDark = useContext(OnDarkContext);
  return /*#__PURE__*/React.createElement(Tag, _extends({
    className: classNames(baseClassName, {
      ["".concat(baseClassName, "--").concat(intent)]: intent,
      ["".concat(baseClassName, "--").concat(fontSize)]: fontSize,
      ["".concat(baseClassName, "--bold")]: bold,
      ["".concat(baseClassName, "--italic")]: italic,
      ["".concat(baseClassName, "--truncate")]: truncate,
      ["".concat(baseClassName, "--nowrap")]: nowrap,
      ["".concat(baseClassName, "--mark")]: mark,
      ["".concat(baseClassName, "--on-dark")]: onDark
    }, className)
  }, props), children);
};

export default Text;