import "choerodon-ui/pro/lib/button/style";
import _Button from "choerodon-ui/pro/lib/button";
import "choerodon-ui/lib/tooltip/style";
import _Tooltip from "choerodon-ui/lib/tooltip";
import "choerodon-ui/pro/lib/icon/style";
import _Icon from "choerodon-ui/pro/lib/icon";

/* eslint-disable import/no-anonymous-default-export */
import React, { Fragment } from 'react';
import map from 'lodash/map';
import { useClusterMainStore } from "../../../../stores";
import { useClusterContentStore } from "../../stores";
import "./index.less";
export default (function (_ref) {
  var name = _ref.name,
      errorMessage = _ref.errorMessage,
      describe = _ref.describe,
      _ref$buttonData = _ref.buttonData,
      buttonData = _ref$buttonData === void 0 ? [] : _ref$buttonData,
      status = _ref.status,
      className = _ref.className,
      progress = _ref.progress;

  var _useClusterMainStore = useClusterMainStore(),
      prefixCls = _useClusterMainStore.prefixCls;

  var _useClusterContentSto = useClusterContentStore(),
      formatMessage = _useClusterContentSto.formatMessage;

  function getStatus() {
    var color = 'rgba(0, 0, 0, 0.36)';
    var message = '';

    switch (status) {
      case 'uninstalled':
        color = 'rgba(0, 0, 0, 0.36)';
        message = formatMessage({
          id: 'not_installed'
        });
        break;

      case 'available':
        color = '#00bfa5';
        message = formatMessage({
          id: 'available'
        });
        break;

      case 'processing':
        color = '#4d90fe';
        message = formatMessage({
          id: 'operating'
        });
        break;

      case 'disabled':
        color = '#f44336';
        message = formatMessage({
          id: 'unavailable'
        });
        break;

      default:
    }

    return /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-card-wrap-content-status"),
      style: {
        borderColor: color,
        color: color
      }
    }, message);
  }

  return /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-card-wrap ").concat(className)
  }, /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-card-wrap-title")
  }, /*#__PURE__*/React.createElement("span", null, name), errorMessage && /*#__PURE__*/React.createElement(_Tooltip, {
    placement: "top",
    title: errorMessage
  }, /*#__PURE__*/React.createElement(_Icon, {
    type: "error",
    className: "".concat(prefixCls, "-card-wrap-title-icon")
  }))), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-card-wrap-content")
  }, getStatus(), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-card-wrap-content-text")
  }, progress || describe)), /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-card-wrap-footer")
  }, map(buttonData, function (_ref2, index) {
    var text = _ref2.text,
        onClick = _ref2.onClick,
        loading = _ref2.loading,
        disabled = _ref2.disabled,
        popoverContent = _ref2.popoverContent;
    return /*#__PURE__*/React.createElement(_Tooltip, {
      placement: "bottom",
      title: popoverContent,
      arrowPointAtCenter: true,
      overlayClassName: "".concat(prefixCls, "-card-wrap-footer-popover"),
      key: index
    }, /*#__PURE__*/React.createElement(_Button, {
      className: "".concat(prefixCls, "-card-wrap-footer-button"),
      onClick: onClick,
      loading: loading,
      disabled: disabled,
      funcType: "flat"
    }, text));
  })));
});