"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

var _classnames = _interopRequireDefault(require("classnames"));

var _avatar = _interopRequireDefault(require("../../../../../../components/avatar"));

var _tooltipText = _interopRequireDefault(require("../../../../../tooltip/tooltip-text"));

var _openData = require("../../../../../../utils/open-data");

var _constant = require("../../constant");

var _utils = require("../../utils");

require("./index.css");

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var preCls = 'titaui-user-message-msg-reply';

function Reply(props) {
  var item = props.item,
      onItemClick = props.onItemClick,
      replys = props.replys,
      handleDeleteReply = props.handleDeleteReply;

  var handleReplyClick = function handleReplyClick() {
    if (onItemClick) {
      onItemClick(false);
    }
  };

  var getDescText = function getDescText() {
    if (item.content.indexOf('@') !== -1) {
      return '@我';
    }

    if (!item.content.trim() && item.attachments.length > 0) {
      return '分享了文件';
    }

    return '回复我';
  };

  var feedText = function feedText() {
    if (!item.content.trim()) {
      return '分享了文件';
    }

    return (0, _utils.deleteText)((0, _utils.htmlToText)(item.content));
  };

  var handleReplyItemClick = function handleReplyItemClick(msgId) {
    handleDeleteReply(msgId);
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__item"), _defineProperty({}, "".concat(preCls, "__item--scroll"), replys.length >= 4)),
    onClick: function onClick() {
      return handleReplyItemClick(item.msgId);
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-photo"))
  }, /*#__PURE__*/_react["default"].createElement(_avatar["default"], {
    userId: item.user.userId,
    name: item.user.name,
    color: item.user.avatar.color,
    src: item.user.avatar.big,
    size: {
      width: 32,
      textNum: 1,
      fontSize: 12
    }
  })), /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-symbol"))
  }, "\u201C"), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-right"))
  }, /*#__PURE__*/_react["default"].createElement("a", {
    target: "_blank",
    href: "".concat(_constant.apiServer, "/").concat(_constant.userId, "/ITalentHome#more/new-share-info?id=").concat(item.feed.feedId),
    onClick: handleReplyClick,
    rel: "noreferrer"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-right-header"))
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-right-header-name"))
  }, /*#__PURE__*/_react["default"].createElement(_tooltipText["default"], {
    overlayClassName: "".concat(preCls, "__item-right-header-name-tooltip"),
    text: /*#__PURE__*/_react["default"].createElement(_openData.OpenUserName, {
      name: item.user.name,
      id: item.user.userId
    }),
    maxWidth: 100,
    mouseEnterDelay: 0.8
  })), /*#__PURE__*/_react["default"].createElement("span", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-right-header-status"))
  }, getDescText())), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-right-content"))
  }, /*#__PURE__*/_react["default"].createElement(_tooltipText["default"], {
    overlayClassName: "".concat(preCls, "__item-right-content-tooltip"),
    text: (0, _openData.parseHtmlAndTextTag)(feedText()),
    isPercent: true,
    mouseEnterDelay: 0.8
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__item-right-time"))
  }, item.createDate))));
}

var _default = Reply;
exports["default"] = _default;