"use strict";

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

var _lodash = _interopRequireDefault(require("lodash.merge"));

var _isEmptyObj = require("../../utils/isEmptyObj");

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

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

const resolvePropsToStyle = (styledSystemProps, theme, platform, debug, currentBreakpoint, strictMode, getResponsiveStyles, INTERNAL_themeStyle, stateProps) => {
  let flattenInternalThemeProps = INTERNAL_themeStyle;
  let fontSize;

  if (Array.isArray(flattenInternalThemeProps)) {
    var _flattenInternalTheme;

    flattenInternalThemeProps = flattenInternalThemeProps.flat();
    fontSize = (_flattenInternalTheme = flattenInternalThemeProps[0]) === null || _flattenInternalTheme === void 0 ? void 0 : _flattenInternalTheme.fontSize;
  } else {
    var _flattenInternalTheme2;

    fontSize = (_flattenInternalTheme2 = flattenInternalThemeProps) === null || _flattenInternalTheme2 === void 0 ? void 0 : _flattenInternalTheme2.fontSize;
  }

  const modifiedStyledSytemProps = {
    fontSize,
    ...styledSystemProps
  };
  const {
    unResolvedProps,
    styleFromProps,
    restDefaultProps,
    dataSet
  } = (0, _styledSystem.getStyleAndFilteredProps)({
    styledSystemProps: modifiedStyledSytemProps,
    theme,
    debug,
    currentBreakpoint,
    strictMode,
    getResponsiveStyles,
    platform
  });
  const {
    unResolvedProps: stateUnResolvedProps,
    styleFromProps: inlineStyleFromProps,
    restDefaultProps: stateRestDefaultProps,
    dataSet: stateDataSet
  } = (0, _styledSystem.getStyleAndFilteredProps)({
    styledSystemProps: stateProps,
    theme,
    debug,
    currentBreakpoint,
    strictMode,
    getResponsiveStyles,
    platform
  });

  const mergedStyle = _lodash.default.apply({}, [_lodash.default.apply({}, INTERNAL_themeStyle), styleFromProps, _lodash.default.apply({}, stateProps === null || stateProps === void 0 ? void 0 : stateProps.INTERNAL_themeStyle), inlineStyleFromProps]);

  return {
    style: mergedStyle,
    styleFromProps,
    unResolvedProps: (0, _lodash.default)(unResolvedProps, stateUnResolvedProps),
    restDefaultProps: (0, _lodash.default)(restDefaultProps, stateRestDefaultProps),
    dataSet: !(0, _isEmptyObj.isEmptyObj)(stateDataSet) ? stateDataSet : dataSet
  };
};

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