"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Link = void 0;

var _react = _interopRequireDefault(require("react"));

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _link = require("./link.proptypes");

var _link2 = require("./link.css-rules");

var _typography = require("../../../mixins/typography");

var _focus = require("../../../mixins/focus");

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var ActualLink = _styledComponents["default"].a.withConfig({
  displayName: "ActualLink",
  componentId: "sc-77ysca-0"
})(["font-size:", ";outline:none;&&&{color:", ";text-decoration:underline;", " ", "{border-radius:3px;box-shadow:", " ", ",", ";}}"], _link2.getLinkFontSize, _link2.getLinkColor, (0, _focus.getBaseFocusState)({
  hoverTransition: false,
  activeTransition: false
}), _focus.FOCUS_VISIBLE_SELECTOR, (0, _focus.focusedBorderShadow)({
  inset: false
}), _focus.focusedBorderColor, _focus.focusedBoxShadow);

var ButtonLink = _styledComponents["default"].button.attrs(function (_ref) {
  var _ref$type = _ref.type,
      type = _ref$type === void 0 ? 'button' : _ref$type;
  return {
    type: type,
    fontSize: 'f1'
  };
}).withConfig({
  displayName: "ButtonLink",
  componentId: "sc-77ysca-1"
})(["border:none;background:inherit;outline:none;padding:0;font-family:", ";font-weight:", ";font-size:", ";&&&{color:", ";text-decoration:underline;", " ", "{border-radius:3px;box-shadow:", " ", ",", ";}}"], _typography.getFontFamily, _typography.getFontWeight, _typography.getFontSize, _link2.getLinkColor, (0, _focus.getBaseFocusState)({
  hoverTransition: false,
  activeTransition: false
}), _focus.FOCUS_VISIBLE_SELECTOR, (0, _focus.focusedBorderShadow)({
  inset: false
}), _focus.focusedBorderColor, _focus.focusedBoxShadow);

var Link = function Link(_ref2) {
  var href = _ref2.href,
      target = _ref2.target,
      onClick = _ref2.onClick,
      type = _ref2.type,
      props = _objectWithoutProperties(_ref2, ["href", "target", "onClick", "type"]);

  return onClick == null ? _react["default"].createElement(ActualLink, _extends({
    href: href,
    target: target
  }, props)) : _react["default"].createElement(ButtonLink, _extends({
    onClick: onClick,
    type: type
  }, props));
};

exports.Link = Link;
Link.displayName = 'Link';
Link.propTypes = _link.linkPropTypes;