"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

exports.__esModule = true;
exports.switchTheme = exports.mergeTheme = exports.getThemeByType = void 0;

var _useWarning = _interopRequireDefault(require("../hooks/useWarning"));

var _object = require("../utils/object");

var _dark = _interopRequireDefault(require("./variants/dark"));

var _light = _interopRequireDefault(require("./variants/light"));

var _cosmic = _interopRequireDefault(require("./variants/cosmic"));

const mergeTheme = (current, custom) => {
  if (!custom) return current;

  if (typeof custom === "function") {
    const merged = custom(current);

    if (!merged || typeof merged !== "object") {
      (0, _useWarning.default)("The theme function must return object value.");
    }

    return merged;
  }

  return (0, _object.deepMergeObject)(current, custom);
};

exports.mergeTheme = mergeTheme;

const getThemeByType = type => {
  const themes = {
    light: _light.default,
    dark: _dark.default,
    cosmic: _cosmic.default
  };
  return themes[type];
};

exports.getThemeByType = getThemeByType;

const switchTheme = mergedTheme => {
  return { ...getThemeByType(mergedTheme.type),
    ...mergedTheme
  };
};

exports.switchTheme = switchTheme;