function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import { getColor } from "../../../theme";
var borderMap = {
  all: function all(_ref) {
    var size = _ref.size,
      type = _ref.type,
      color = _ref.color;
    return "\n    border: " + size + " " + type + " " + color + ";\n  ";
  },
  horizontal: function horizontal(_ref2) {
    var size = _ref2.size,
      type = _ref2.type,
      color = _ref2.color;
    return "\n    border-top: " + size + " " + type + " " + color + ";\n    border-bottom: " + size + " " + type + " " + color + ";\n  ";
  },
  vertical: function vertical(_ref3) {
    var size = _ref3.size,
      type = _ref3.type,
      color = _ref3.color;
    return "\n    border-left: " + size + " " + type + " " + color + ";\n    border-right: " + size + " " + type + " " + color + ";\n  ";
  },
  top: function top(_ref4) {
    var size = _ref4.size,
      type = _ref4.type,
      color = _ref4.color;
    return "\n    border-top: " + size + " " + type + " " + color + ";\n  ";
  },
  right: function right(_ref5) {
    var size = _ref5.size,
      type = _ref5.type,
      color = _ref5.color;
    return "\n    border-right: " + size + " " + type + " " + color + ";\n  ";
  },
  bottom: function bottom(_ref6) {
    var size = _ref6.size,
      type = _ref6.type,
      color = _ref6.color;
    return "\n    border-bottom: " + size + " " + type + " " + color + ";\n  ";
  },
  left: function left(_ref7) {
    var size = _ref7.size,
      type = _ref7.type,
      color = _ref7.color;
    return "\n    border-left: " + size + " " + type + " " + color + ";\n  ";
  }
};
var getDefaults = function getDefaults(theme) {
  return {
    color: getColor("border")({
      theme: theme
    }),
    size: "1px",
    side: "all",
    type: "solid"
  };
};
export default (function (_ref8) {
  var theme = _ref8.theme,
    border = _ref8.border;
  if (border === undefined) {
    return "";
  }
  if (border === true) {
    return borderMap.all(getDefaults(theme));
  }
  if (border in borderMap) {
    return borderMap[border](getDefaults(theme));
  }
  if (typeof border === "string" || Array.isArray(border)) {
    return borderMap.all(_extends({}, getDefaults(theme), {
      color: getColor(border || "border")({
        theme: theme
      })
    }));
  }
  if (typeof border !== "object") {
    return "";
  }
  var side = border.side,
    color = border.color;
  if (Array.isArray(side)) {
    return side.reduce(function (acc, s) {
      if (s in borderMap) {
        return acc + borderMap[s](_extends({}, getDefaults(theme), border, {
          color: getColor(color || "border")({
            theme: theme
          })
        }));
      }
      return acc;
    }, "");
  }
  return side in borderMap && borderMap[side](_extends({}, getDefaults(theme), border, {
    color: getColor(color || "border")({
      theme: theme
    })
  }));
});