import React from 'react';
import { mdiFile, mdiDownload } from '@mdi/js';
import { Avatar } from '@material-ui/core';
import Icon from '@mdi/react';
import ListItem from '@material-ui/core/ListItem';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
import ListItemText from '@material-ui/core/ListItemText';
import List from '@material-ui/core/List';
import { makeStyles } from '@material-ui/styles';
import { IconButton as IconButtonMaterial } from '@tecsinapse/ui-kit/build/Buttons/IconButton';
import { defaultGreyDark, defaultWhite } from '@tecsinapse/ui-kit/build/colors';

var useStyle = function useStyle(size) {
  return makeStyles(function (theme) {
    return {
      appRoot: {
        padding: 0
      },
      appItem: {
        paddingTop: size ? 0 : undefined,
        paddingBottom: size ? 0 : undefined,
        paddingLeft: theme.spacing(0.75)
      },
      appMediaName: {
        textOverflow: 'ellipsis',
        overflow: 'hidden'
      },
      appIconDownload: {
        right: 0
      }
    };
  });
};

export var ApplicationLoader = function ApplicationLoader(_ref) {
  var message = _ref.message,
      media = _ref.media;
  var classes = useStyle(media.size)();
  return React.createElement(List, {
    className: classes.appRoot
  }, React.createElement(ListItem, {
    className: classes.appItem
  }, React.createElement(ListItemAvatar, null, React.createElement(Avatar, null, React.createElement(Icon, {
    path: mdiFile,
    size: 1.0,
    color: message.own ? defaultWhite : defaultGreyDark
  }))), React.createElement(ListItemText, {
    primary: media.name,
    secondary: media.size && "".concat(media.size, " Kb"),
    className: classes.appMediaName
  }), React.createElement(ListItemSecondaryAction, {
    className: classes.appIconDownload
  }, React.createElement("a", {
    href: media.url,
    download: true
  }, React.createElement(IconButtonMaterial, {
    "aria-label": "download"
  }, React.createElement(Icon, {
    path: mdiDownload,
    size: 1.2,
    color: message.own ? defaultWhite : defaultGreyDark
  }))))));
};
export default ApplicationLoader;