import { deepMerge } from '../utils';
import createColor from './createColor';
import createTransition from './createTransition';
import createSize from './createSize';
import shadows from './createShadow';
import createBreakpoint, { defaultBreakpoints } from './createBreakpoint';
import createTypographies from './createTypography';

function createTheme(theme) {
  const {
    colors: colorsInput = {},
    sizes: sizesInput = {},
    transitions: transitionsInput = {},
    shadows: shadowsInput,
    breakpoints: breakpointsInput = defaultBreakpoints,
    typographies: typographiesInput = {}
  } = theme;
  const colors = createColor(colorsInput);
  const transitions = createTransition(transitionsInput);
  const sizes = createSize(sizesInput);
  const breakpoints = createBreakpoint(breakpointsInput);
  const typographies = createTypographies(typographiesInput);
  return {
    shadows: shadowsInput || shadows,
    ...deepMerge(theme, {
      colors,
      sizes,
      transitions,
      breakpoints,
      typographies
    })
  };
}

export default createTheme;