"use strict";

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

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

var _reactRouterDom = require("react-router-dom");

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

function Button(_ref) {
  var text = _ref.text,
      onClick = _ref.onClick,
      href = _ref.href,
      external = _ref.external,
      appearance = _ref.appearance,
      disabled = _ref.disabled,
      className = _ref.className,
      title = _ref.title;
  var classString = 'usa-button' + (appearance && appearance !== 'default' ? ' usa-button--' + appearance : '') + (className ? ' ' + className : '');

  if (onClick === 'submit') {
    return /*#__PURE__*/_react.default.createElement("input", {
      className: classString,
      disabled: disabled,
      type: "submit",
      value: text // Value will never actually be an element for a submit button but TS doesn't know that
      ,
      title: title
    });
  }

  onClick = typeof onClick === 'function' ? onClick : function () {};

  if (href && !external) {
    return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
      to: href,
      className: classString,
      onClick: onClick,
      title: title
    }, text);
  }

  if (href && external) {
    return /*#__PURE__*/_react.default.createElement("a", {
      href: href,
      className: classString,
      onClick: onClick,
      title: title
    }, text);
  }

  return /*#__PURE__*/_react.default.createElement("button", {
    className: classString,
    disabled: disabled,
    onClick: onClick,
    type: "button",
    title: title
  }, text);
}