import _extends from "@babel/runtime/helpers/extends";
import React, { useEffect } from 'react';
import { ElementName, IconType } from '../../../../../constants';
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
import { BaseBadgeElement, toBadgeProps } from '../common';
const CommentCountElement = props => {
  var _context$commentCount;
  const context = useFlexibleUiContext();
  const data = context ? toBadgeProps((_context$commentCount = context.commentCount) === null || _context$commentCount === void 0 ? void 0 : _context$commentCount.toString()) : null;
  const {
    onRender,
    ...restProps
  } = props || {};
  useEffect(() => {
    onRender === null || onRender === void 0 ? void 0 : onRender(!!data);
  }, [data, onRender]);
  return data ? /*#__PURE__*/React.createElement(BaseBadgeElement, _extends({
    icon: IconType.Comment
  }, data, restProps, {
    name: ElementName.CommentCount
  })) : null;
};
export default CommentCountElement;