import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["sx", "order", "grow", "flexGrow", "shrink", "flexShrink", "basis", "flexBasis", "flex", "alignSelf"];

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

/* eslint-disable react/forbid-prop-types */
import React from "react";
import PropTypes from "prop-types";
import Box from "../Box";
var Item = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var sx = props.sx,
      order = props.order,
      grow = props.grow,
      flexGrow = props.flexGrow,
      shrink = props.shrink,
      flexShrink = props.flexShrink,
      basis = props.basis,
      flexBasis = props.flexBasis,
      flex = props.flex,
      alignSelf = props.alignSelf,
      boxProps = _objectWithoutProperties(props, _excluded);

  var styles = _objectSpread({
    flexGrow: grow !== null && grow !== void 0 ? grow : flexGrow,
    flexShrink: shrink !== null && shrink !== void 0 ? shrink : flexShrink,
    flexBasis: basis !== null && basis !== void 0 ? basis : flexBasis,
    order: order,
    flex: flex,
    alignSelf: alignSelf
  }, sx);

  return /*#__PURE__*/React.createElement(Box, _extends({
    sx: styles,
    ref: ref
  }, boxProps));
});
var aligns = ["auto", "flex-start", "flex-end", "center", "baseline", "stretch"];

var validateStyleSystemProp = function validateStyleSystemProp(validation) {
  return PropTypes.oneOfType([validation, PropTypes.arrayOf(PropTypes.oneOfType([validation, PropTypes.instanceOf(null)]))]);
};

Item.propTypes = {
  order: validateStyleSystemProp(PropTypes.number),
  grow: validateStyleSystemProp(PropTypes.number),
  flexGrow: validateStyleSystemProp(PropTypes.number),
  shrink: validateStyleSystemProp(PropTypes.number),
  flexShrink: validateStyleSystemProp(PropTypes.number),
  basis: validateStyleSystemProp(PropTypes.number),
  flexBasis: validateStyleSystemProp(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
  flex: validateStyleSystemProp(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
  alignSelf: validateStyleSystemProp(PropTypes.oneOf(aligns)),
  sx: PropTypes.object,
  component: PropTypes.elementType
};

if (process.env.NODE_ENV !== "production") {
  Item.displayName = "CssFlex.Item";
}

export default Item;