import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "className", "disableLink", "href"];
import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';
import Link from '../Link';
import { settings } from '../../globals/js';
var prefix = settings.prefix;

var newChild = function newChild(children, disableLink, href) {
  if (disableLink === true) {
    return /*#__PURE__*/React.createElement("span", null, children);
  } else if (typeof children === 'string' && !(href === undefined)) {
    return /*#__PURE__*/React.createElement(Link, {
      href: href
    }, children);
  } else {
    return /*#__PURE__*/React.cloneElement(React.Children.only(children), {
      className: "".concat(prefix, "--link")
    });
  }
};

var BreadcrumbItem = function BreadcrumbItem(_ref) {
  var children = _ref.children,
      className = _ref.className,
      disableLink = _ref.disableLink,
      href = _ref.href,
      other = _objectWithoutProperties(_ref, _excluded);

  var classNames = classnames("".concat(prefix, "--breadcrumb-item"), className);
  return /*#__PURE__*/React.createElement("div", _extends({
    className: classNames
  }, other), newChild(children, disableLink, href));
};

BreadcrumbItem.propTypes = {
  /**
   * The children elements, usually a link
   */
  children: PropTypes.node,

  /**
   * Specify an optional className to be added to the `BreadcrumbItem` Icon
   */
  className: PropTypes.string,

  /**
   * Specify an link for the `BreadcrumbItem`
   */
  href: PropTypes.string,

  /**
   * Specify `BreadcrumbItem` to be interactive/enabled or non-interactive/disabled
   */
  disableLink: PropTypes.bool
};
export default BreadcrumbItem;