import _objectSpread from "@babel/runtime/helpers/esm/objectSpread";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React from 'react';
import { Link } from 'react-router-dom';
import Button from '.';
/**
 * A `Button` specialized for links. Buttons with a `to`
 * are handled by react-router-dom's internal routing.
 * See [Button](#button) for full set of available props.
 */

var LinkButton = function LinkButton(props) {
  var to = props.to,
      href = props.href,
      rest = _objectWithoutProperties(props, ["to", "href"]);

  var btnProps;

  if (href) {
    // is external link
    btnProps = _objectSpread({}, rest, {
      href: href,
      target: '_blank',
      component: 'a'
    });
  } else {
    // is internal link
    btnProps = _objectSpread({}, rest, {
      to: to,
      component: Link
    });
  }

  return React.createElement(Button, btnProps);
};

LinkButton.defaultProps = {
  to: '',
  href: ''
};
export default LinkButton;