'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _index = require('./Item/index');

var _index2 = _interopRequireDefault(_index);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var BreadCrumb = function BreadCrumb(_ref) {
  var className = _ref.className,
      children = _ref.children,
      variant = _ref.variant,
      rest = _objectWithoutProperties(_ref, ['className', 'children', 'variant']);

  return _react2.default.createElement(
    'div',
    _extends({
      className: (className ? className + ' ' : '') + 'flive_breadcrumb_base'
    }, rest),
    _react2.default.Children.map(children, function (child, index) {
      if (_react2.default.isValidElement(child)) {
        var componentName = child.type.componentName;

        if (componentName === 'BreadCrumbItem') {
          var resultChild = _react2.default.cloneElement(child, {
            isLastChild: index === children.length - 1,
            variant: variant
          });
          return resultChild;
        }
      }
      return null;
    })
  );
};

BreadCrumb.propTypes = {
  /** @ignore */
  className: _propTypes2.default.string,
  /** @ignore */
  children: _propTypes2.default.node,
  variant: _propTypes2.default.oneOf(['white', 'night-blue'])
};

BreadCrumb.defaultProps = {
  className: undefined,
  variant: 'night-blue',
  children: null
};

BreadCrumb.Item = _index2.default;

exports.default = BreadCrumb;
module.exports = exports['default'];