"use strict";

exports.__esModule = true;
exports.default = Actions;

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

var _styles = require("@mui/material/styles");

var _material = require("@mui/material");

var _Vote = _interopRequireDefault(require("./Vote"));

var _Comment = _interopRequireDefault(require("./Comment"));

var _Share = _interopRequireDefault(require("./Share"));

var _core = require("@selfcommunity/core");

var _feedObject = require("../../../types/feedObject");

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

const PREFIX = 'SCFeedObjectActions';
const Root = (0, _styles.styled)(_material.Grid, {
  name: PREFIX,
  slot: 'Root',
  overridesResolver: (props, styles) => styles.root
})(() => ({
  margin: '0px 0px',
  color: '#3A3A3A'
}));

function Actions(props) {
  // PROPS
  const {
    className,
    feedObjectId,
    feedObject,
    feedObjectType = _core.SCFeedObjectTypologyType.POST,
    feedObjectTemplate = _feedObject.FeedObjectTemplateType.PREVIEW,
    hideShareAction = false,
    hideCommentAction = false,
    handleExpandActivities
  } = props; // STATE

  const {
    obj,
    setObj
  } = (0, _core.useSCFetchFeedObject)({
    id: feedObjectId,
    feedObject,
    feedObjectType
  });

  if (!obj) {
    return null;
  }
  /**
   * Calculate column width
   */


  function getColumnWidth() {
    let width = 4;

    if (hideShareAction && hideCommentAction) {
      width = 12;
    } else if (hideCommentAction || hideCommentAction) {
      width = 6;
    }

    return width;
  }
  /**
   * Renders action section
   */


  const columnWidth = getColumnWidth();
  return /*#__PURE__*/_react.default.createElement(Root, {
    container: true,
    className: className
  }, /*#__PURE__*/_react.default.createElement(_material.Grid, {
    item: true,
    xs: columnWidth,
    sx: {
      textAlign: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_Vote.default, {
    feedObject: obj,
    feedObjectType: feedObjectType,
    id: feedObjectId,
    withAction: true,
    inlineAction: false
  })), !hideCommentAction && /*#__PURE__*/_react.default.createElement(_material.Grid, {
    item: true,
    xs: columnWidth,
    sx: {
      textAlign: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_Comment.default, {
    feedObject: obj,
    feedObjectType: feedObjectType,
    id: feedObjectId,
    feedObjectTemplate: feedObjectTemplate,
    withAction: true,
    onCommentAction: handleExpandActivities
  })), !hideShareAction && /*#__PURE__*/_react.default.createElement(_material.Grid, {
    item: true,
    xs: columnWidth,
    sx: {
      textAlign: 'center'
    }
  }, /*#__PURE__*/_react.default.createElement(_Share.default, {
    feedObject: obj,
    feedObjectType: feedObjectType,
    id: feedObjectId,
    withAction: true,
    inlineAction: false
  })));
}