"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = _default;

function _react() {
  const data = _interopRequireDefault(require("react"));

  _react = function _react() {
    return data;
  };

  return data;
}

function _fs() {
  const data = require("fs");

  _fs = function _fs() {
    return data;
  };

  return data;
}

function _path() {
  const data = require("path");

  _path = function _path() {
    return data;
  };

  return data;
}

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

function _default(theme, opts = {}) {
  const _opts$cwd = opts.cwd,
        cwd = _opts$cwd === void 0 ? process.cwd() : _opts$cwd;
  if (!theme) return {};

  if (typeof theme === 'string') {
    const themePath = (0, _path().isAbsolute)(theme) ? theme : (0, _path().resolve)(cwd, theme);

    if ((0, _fs().existsSync)(themePath)) {
      const themeConfig = require(themePath); // eslint-disable-line


      if (typeof themeConfig === 'function') {
        return themeConfig();
      } else {
        return themeConfig;
      }
    } else {
      throw new Error(`theme file don't exists`);
    }
  }

  return theme;
}