import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
var _excluded = ["prefixCls", "className", "separator", "children"];

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

/**
 * Breadcrumb.jsx
 *
 * @Author: zhangce
 * @Date: 18/1/23 下午2:42
 */
import React, { Children, cloneElement, isValidElement } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
/**
 * Breadcrumb
 * */

var Breadcrumb = /*#__PURE__*/function (_React$PureComponent) {
  _inherits(Breadcrumb, _React$PureComponent);

  var _super = _createSuper(Breadcrumb);

  function Breadcrumb() {
    _classCallCheck(this, Breadcrumb);

    return _super.apply(this, arguments);
  }

  _createClass(Breadcrumb, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          prefixCls = _this$props.prefixCls,
          className = _this$props.className,
          separator = _this$props.separator,
          children = _this$props.children,
          other = _objectWithoutProperties(_this$props, _excluded);

      var classes = classNames(prefixCls, className);
      var items = Children.map(children, function (item) {
        if ( /*#__PURE__*/isValidElement(item)) {
          return /*#__PURE__*/cloneElement(item, {
            separator: item.props.className || separator
          });
        }
      });
      return /*#__PURE__*/React.createElement("div", _extends({
        className: classes
      }, other), items);
    }
  }]);

  return Breadcrumb;
}(React.PureComponent);

_defineProperty(Breadcrumb, "propTypes", {
  /**
   * 类前缀
   * */
  prefixCls: PropTypes.string,

  /**
   * 分隔符
   * */
  separator: PropTypes.node
});

_defineProperty(Breadcrumb, "defaultProps", {
  prefixCls: 'ne-breadcrumb',
  separator: '/'
});

export default Breadcrumb;