import { theme as defaultTheme } from './../theme';
import mergeWith from 'lodash.mergewith'; // import { updateComponentThemeMap } from '../utils/styled';

function isFunction(value) {
  return typeof value === 'function';
}

function resolveComponentThemeAndUpdateMap(theme) {
  if (theme.components) {// Object.keys(theme.components).map((key?: string) => {
    //   // updateComponentThemeMap(key, theme.components[key]);
    // });
  }
}

export function extendTheme(overrides, ...restOverrides) {
  function customizer(source, override) {
    if (isFunction(source)) {
      return (...args) => {
        const sourceValue = source(...args);
        const overrideValue = isFunction(override) ? override(...args) : override;
        return mergeWith({}, sourceValue, overrideValue, customizer);
      };
    }

    return undefined;
  }

  const finalOverrides = [overrides, ...restOverrides].reduce((prevValue, currentValue) => {
    resolveComponentThemeAndUpdateMap(currentValue);
    return mergeWith({}, prevValue, currentValue, customizer);
  }, defaultTheme);
  return finalOverrides;
}
//# sourceMappingURL=extendTheme.js.map