"use strict";

exports.__esModule = true;
exports.default = void 0;

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _icons = require("@material-ui/icons");

var _TipButton = _interopRequireDefault(require("subfirelib/ui/TipButton"));

var _styles = require("@material-ui/core/styles");

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

const useStyles = (0, _styles.makeStyles)(theme => ({
  buttonRow: {
    display: 'flex',
    width: '100%',
    justifyContent: 'space-around'
  },
  buttonCell: {
    textAlign: 'center'
  },
  button: {
    margin: theme.spacing(1)
  },
  rightIcon: {
    marginLeft: theme.spacing(1)
  }
}));

const ArtistActionButtons = props => {
  const {
    loadbase,
    id,
    showBackButton,
    history,
    children
  } = props;
  let {
    artistId
  } = props;
  const isAlbum = !!artistId;
  const classes = useStyles(); // console.log(id, artistId, isAlbum);

  if (!artistId) artistId = id;
  let top = '';
  let radio = '';
  let backButton = '';

  if (showBackButton && history) {
    backButton = /*#__PURE__*/_react.default.createElement("div", {
      className: classes.buttonCell
    }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
      placement: "right-end",
      title: "Go Back",
      onClick: history.goBack
    }, /*#__PURE__*/_react.default.createElement(_icons.Reply, null)));
  }

  if (loadbase !== 'directoryAction') {
    // music directory isn't fully in cache, so no name, so this doesn't work :()
    top = /*#__PURE__*/_react.default.createElement("div", {
      className: classes.buttonCell
    }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
      placement: "right-end",
      title: "Top Songs",
      onClick: () => {
        history.push(`/loading/${loadbase}/${artistId}/top`);
      }
    }, /*#__PURE__*/_react.default.createElement(_icons.ThumbUp, null)));
    radio = /*#__PURE__*/_react.default.createElement("div", {
      className: classes.buttonCell
    }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
      placement: "right-end",
      title: "Radio",
      onClick: () => {
        history.push(`/loading/${loadbase}/${artistId}/radio`);
      }
    }, /*#__PURE__*/_react.default.createElement(_icons.Radio, null)));
  }

  return /*#__PURE__*/_react.default.createElement("div", {
    className: classes.buttonRow
  }, backButton, top, !isAlbum && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.buttonCell
  }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
    placement: "right-end",
    title: "Play All",
    onClick: () => {
      history.push(`/loading/${loadbase}/${artistId}/all`);
    }
  }, /*#__PURE__*/_react.default.createElement(_icons.VideoLibrary, null))), /*#__PURE__*/_react.default.createElement("div", {
    className: classes.buttonCell
  }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
    placement: "right-end",
    title: "Shuffle",
    onClick: () => {
      history.push(`/loading/${loadbase}/${artistId}/shuffle`);
    }
  }, /*#__PURE__*/_react.default.createElement(_icons.Shuffle, null))), /*#__PURE__*/_react.default.createElement("div", {
    className: classes.buttonCell
  }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
    placement: "right-end",
    title: "Shuffle Albums",
    onClick: () => {
      history.push(`/loading/${loadbase}/${artistId}/shuffleAlbums`);
    }
  }, /*#__PURE__*/_react.default.createElement(_icons.Album, null)))), isAlbum && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.buttonCell
  }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
    placement: "right-end",
    title: "Play",
    onClick: () => {
      history.push(`/loading/albumAction/${id}/play`);
    }
  }, /*#__PURE__*/_react.default.createElement(_icons.VideoLibrary, null))), /*#__PURE__*/_react.default.createElement("div", {
    className: classes.buttonCell
  }, /*#__PURE__*/_react.default.createElement(_TipButton.default, {
    title: "Shuffle",
    onClick: () => {
      history.push(`/loading/albumAction/${id}/shuffle`);
    }
  }, /*#__PURE__*/_react.default.createElement(_icons.Shuffle, null)))), radio, children);
};

ArtistActionButtons.propTypes = {
  history: _propTypes.default.any.isRequired,
  loadbase: _propTypes.default.string.isRequired,
  id: _propTypes.default.string.isRequired,
  artistId: _propTypes.default.string,
  showBackButton: _propTypes.default.bool,
  children: _propTypes.default.any
};
var _default = ArtistActionButtons;
exports.default = _default;