var _excluded = ["as", "alignContent", "alignItems", "alignSelf", "children", "display", "flex", "flexBasis", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "gap", "justifyContent", "margin", "marginBottom", "marginLeft", "marginRight", "marginTop", "order", "padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textAlign"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import * as React from 'react';
import { StyledBox } from './Box.styles';
// TODO remove this after we decommission the LegacyDisplay type
function getLegacyDisplayAndDirection(d) {
  if (!d) {
    return {};
  }
  var display = d;
  var direction = display.includes('flex') ? 'row' : undefined;
  if (d.includes('flex-inline') || d.includes('inline-flex')) {
    display = 'inline-flex';
  } else if (d.includes('flex')) {
    display = 'flex';
  }
  if (d.includes('column-reverse')) {
    direction = 'column-reverse';
  } else if (d.includes('column')) {
    direction = 'column';
  }
  if (d.includes('row-reverse')) {
    direction = 'row-reverse';
  } else if (d.includes('row')) {
    direction = 'row';
  }
  return {
    display: display,
    direction: direction
  };
}

/**
 * `Box` is a general layout utility for CSS properties like `display`, `text-align`,
 * flex, spacing, and layout properties.
 */
export var Box = /*#__PURE__*/React.forwardRef(function Box(_ref, ref) {
  var as = _ref.as,
    alignContent = _ref.alignContent,
    alignItems = _ref.alignItems,
    alignSelf = _ref.alignSelf,
    children = _ref.children,
    display = _ref.display,
    flex = _ref.flex,
    flexBasis = _ref.flexBasis,
    flexDirection = _ref.flexDirection,
    flexGrow = _ref.flexGrow,
    flexShrink = _ref.flexShrink,
    flexWrap = _ref.flexWrap,
    gap = _ref.gap,
    justifyContent = _ref.justifyContent,
    margin = _ref.margin,
    marginBottom = _ref.marginBottom,
    marginLeft = _ref.marginLeft,
    marginRight = _ref.marginRight,
    marginTop = _ref.marginTop,
    order = _ref.order,
    padding = _ref.padding,
    paddingBottom = _ref.paddingBottom,
    paddingLeft = _ref.paddingLeft,
    paddingRight = _ref.paddingRight,
    paddingTop = _ref.paddingTop,
    textAlign = _ref.textAlign,
    props = _objectWithoutProperties(_ref, _excluded);
  var legacyProps = getLegacyDisplayAndDirection(display);
  return /*#__PURE__*/React.createElement(StyledBox, _extends({}, props, {
    ref: ref,
    $as: as,
    $alignContent: alignContent,
    $alignItems: alignItems,
    $alignSelf: alignSelf,
    $display: legacyProps.display,
    $flex: flex,
    $flexBasis: flexBasis,
    $flexDirection: flexDirection !== null && flexDirection !== void 0 ? flexDirection : legacyProps.direction,
    $flexGrow: flexGrow,
    $flexShrink: flexShrink,
    $flexWrap: flexWrap,
    $gap: gap,
    $justifyContent: justifyContent,
    $margin: margin,
    $marginBottom: marginBottom,
    $marginLeft: marginLeft,
    $marginRight: marginRight,
    $marginTop: marginTop,
    $order: order,
    $padding: padding,
    $paddingBottom: paddingBottom,
    $paddingLeft: paddingLeft,
    $paddingRight: paddingRight,
    $paddingTop: paddingTop,
    $textAlign: textAlign
  }), children);
});
Box.displayName = 'Box';
//# sourceMappingURL=Box.js.map