"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useStyledSystemPropsResolver = void 0;

var _styledSystem = require("../theme/styled-system");

var _useTheme = require("./useTheme");

var _react = _interopRequireDefault(require("react"));

var _NativeBaseContext = require("../core/NativeBaseContext");

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

const useStyledSystemPropsResolver = ({
  style: propStyle,
  debug,
  ...props
}) => {
  const theme = (0, _useTheme.useTheme)();
  const {
    currentBreakpoint,
    config
  } = (0, _NativeBaseContext.useNativeBaseConfig)('makeStyledComponent');
  const strictMode = config.strictMode;

  const {
    style,
    restProps
  } = _react.default.useMemo(() => {
    const {
      styleSheet,
      restProps
    } = (0, _styledSystem.getStyleAndFilteredProps)({ ...props,
      theme,
      debug,
      currentBreakpoint,
      strictMode
    });

    if (propStyle) {
      return {
        style: [styleSheet.box, propStyle],
        restProps
      };
    } else {
      return {
        style: styleSheet.box,
        restProps
      };
    }
  }, [props, theme, debug, currentBreakpoint, strictMode, propStyle]);

  if (debug) {
    /* eslint-disable-next-line */
    console.log('style,resprops', currentBreakpoint);
  }

  return [style, restProps];
};

exports.useStyledSystemPropsResolver = useStyledSystemPropsResolver;
//# sourceMappingURL=useStyledSystemPropsResolver.js.map