import "choerodon-ui/lib/tooltip/style";
import _Tooltip from "choerodon-ui/lib/tooltip";
import "choerodon-ui/lib/icon/style";
import _Icon from "choerodon-ui/lib/icon";
import React, { Fragment } from 'react';
import { FormattedMessage } from 'react-intl';
import MouseOverWrapper from "../MouseOverWrapper";
import "./AppName.less";
/**
 * 带icon的应用名称
 * @param { 应用名称，显示应用前icon，本组织or应用市场 } props
 */

export default function AppName(props) {
  var name = props.name,
      showIcon = props.showIcon,
      self = props.self,
      width = props.width,
      isInstance = props.isInstance,
      hoverName = props.hoverName;
  var icon;
  var type;

  if (isInstance) {
    icon = self;

    if (self === 'share') {
      type = 'share';
    } else if (self === 'application_market') {
      type = 'market';
    } else {
      type = 'project';
    }
  } else {
    icon = self ? 'widgets' : 'apps';
    type = self ? 'project' : 'market';
  }

  return /*#__PURE__*/React.createElement(Fragment, null, showIcon ? /*#__PURE__*/React.createElement(_Tooltip, {
    title: /*#__PURE__*/React.createElement(FormattedMessage, {
      id: type
    })
  }, /*#__PURE__*/React.createElement(_Icon, {
    type: icon,
    className: "c7ncd-app-icon"
  })) : null, hoverName ? /*#__PURE__*/React.createElement(MouseOverWrapper, {
    className: "c7ncd-app-text",
    width: width
  }, name) : /*#__PURE__*/React.createElement(MouseOverWrapper, {
    className: "c7ncd-app-text",
    text: name,
    width: width
  }, name));
}