'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.getChildByType = exports.filterChildrenByNotType = exports.filterChildrenByType = exports.cloneElement = undefined;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var cloneElement = exports.cloneElement = function cloneElement(element, props) {
    return typeof element === 'function' ? element(props) : _react2.default.cloneElement(element, props);
};

var filterChildrenByType = exports.filterChildrenByType = function filterChildrenByType(children, type) {
    if (!children) {
        return [];
    }

    return _react2.default.Children.toArray(children).filter(function (i) {
        return i && i.type && i.type[type];
    }) || [];
};

var filterChildrenByNotType = exports.filterChildrenByNotType = function filterChildrenByNotType(children, type) {
    if (!children) {
        return [];
    }

    return _react2.default.Children.toArray(children).filter(function (i) {
        return !i || !i.type || !i.type[type];
    }) || [];
};

var getChildByType = exports.getChildByType = function getChildByType(children, type) {
    return filterChildrenByType(children, type)[0] || null;
};