"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "ALIGNMENT_VALUES", {
  enumerable: true,
  get: function get() {
    return _FlexConsts.ALIGNMENT_VALUES;
  }
});
Object.defineProperty(exports, "DIRECTION", {
  enumerable: true,
  get: function get() {
    return _FlexConsts.DIRECTION;
  }
});
Object.defineProperty(exports, "FLEX_VALUES", {
  enumerable: true,
  get: function get() {
    return _FlexConsts.FLEX_VALUES;
  }
});
Object.defineProperty(exports, "GAP_VALUES", {
  enumerable: true,
  get: function get() {
    return _FlexConsts.GAP_VALUES;
  }
});
Object.defineProperty(exports, "JUSTIFY_VALUES", {
  enumerable: true,
  get: function get() {
    return _FlexConsts.JUSTIFY_VALUES;
  }
});
Object.defineProperty(exports, "MARGINS", {
  enumerable: true,
  get: function get() {
    return _FlexConsts.MARGINS;
  }
});
exports.default = void 0;

var React = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _FlexConsts = require("./FlexConsts");

var _responsiveProps = require("../utils/responsive-props");

var _excluded = ["as", "fullWidth", "fullHeight", "noShrink", "inlineFlex", "alignItems", "alignContent", "justifyContent", "wrap", "wrapReverse", "alignSelf", "direction", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight", "gap", "children", "className", "flex"];

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _extends() { _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; }; return _extends.apply(this, arguments); }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

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; }

var Flex = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var _props$as = props.as,
      Container = _props$as === void 0 ? 'div' : _props$as,
      fullWidth = props.fullWidth,
      fullHeight = props.fullHeight,
      noShrink = props.noShrink,
      inlineFlex = props.inlineFlex,
      alignItems = props.alignItems,
      alignContent = props.alignContent,
      justifyContent = props.justifyContent,
      wrap = props.wrap,
      wrapReverse = props.wrapReverse,
      alignSelf = props.alignSelf,
      direction = props.direction,
      margin = props.margin,
      marginTop = props.marginTop,
      marginBottom = props.marginBottom,
      marginLeft = props.marginLeft,
      marginRight = props.marginRight,
      gap = props.gap,
      children = props.children,
      className = props.className,
      flex = props.flex,
      otherProps = _objectWithoutProperties(props, _excluded);

  var flexClass = _classnames.default.apply(void 0, ['sg-flex'].concat(_toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue === true ? "sg-flex--full-width" : "sg-flex--auto-width";
  }, fullWidth)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue === true ? "sg-flex--full-height" : "sg-flex--auto-height";
  }, fullHeight)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue === true ? "sg-flex--no-shrink" : "sg-flex--shrink-1";
  }, noShrink)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue === true ? "sg-flex--inline" : "sg-flex--flex";
  }, inlineFlex)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (direction) {
    if (direction === _FlexConsts.DIRECTION.COLUMN) {
      return 'sg-flex--column';
    } else if (direction === _FlexConsts.DIRECTION.COLUMN_REVERSE) {
      return 'sg-flex--column-reverse';
    } else if (direction === _FlexConsts.DIRECTION.ROW) {
      return 'sg-flex--row';
    } else if (direction === _FlexConsts.DIRECTION.ROW_REVERSE) {
      return 'sg-flex--row-reverse';
    } else {
      return 'sg-flex--row';
    }
  }, direction)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue === true ? "sg-flex--inline" : "sg-flex--flex";
  }, inlineFlex)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--justify-content-".concat(propValue);
  }, justifyContent)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--align-items-".concat(propValue);
  }, alignItems)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--align-content-".concat(propValue);
  }, alignContent)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--align-self-".concat(propValue);
  }, alignSelf)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue ? 'sg-flex--wrap' : 'sg-flex--nowrap';
  }, wrap)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return propValue ? 'sg-flex--wrap-reverse' : 'sg-flex--nowrap';
  }, wrapReverse)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--margin-".concat(propValue);
  }, margin)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--margin-top-".concat(propValue);
  }, marginTop)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--margin-right-".concat(propValue);
  }, marginRight)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--margin-bottom-".concat(propValue);
  }, marginBottom)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--margin-left-".concat(propValue);
  }, marginLeft)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--gap-".concat(propValue);
  }, gap)), _toConsumableArray((0, _responsiveProps.generateResponsiveClassNames)(function (propValue) {
    return "sg-flex--flex-".concat(propValue);
  }, flex)), [className]));

  return (
    /*#__PURE__*/
    // @ts-expect-error ts migration
    React.createElement(Container, _extends({}, otherProps, {
      className: flexClass,
      ref: ref
    }), children)
  );
});
Flex.displayName = 'Flex';
var _default = Flex;
exports.default = _default;