'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.extractInputs = exports.isInput = undefined;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var isInput = exports.isInput = function isInput(component) {
  if (!component) {
    return false;
  }

  var type = component.type;

  if (!type) {
    return false;
  }

  var propTypes = type.propTypes;

  if (!propTypes) {
    return false;
  }

  return 'name' in propTypes && 'value' in propTypes && 'parentPath' in propTypes && 'subpath' in propTypes;
};

var extractInputs = exports.extractInputs = function extractInputs(children) {
  var inputs = [];

  _react2.default.Children.forEach(children, function (child) {
    if (isInput(child)) {
      inputs.push(child);
    } else {
      Array.prototype.push.apply(inputs, extractInputs(child.props.children));
    }
  });

  return inputs;
};