"use strict";

exports.__esModule = true;
exports.default = void 0;

require("core-js/modules/web.dom.iterable");

require("core-js/modules/es6.array.iterator");

require("core-js/modules/es6.object.keys");

require("core-js/modules/es6.object.assign");

require("core-js/modules/es7.array.includes");

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _snakeCase = require("../../utils/snakeCase");

var _ = require("../..");

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

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var ChatContentItem = function ChatContentItem(props) {
  var actionNode = props.actionNode,
      aspect = props.aspect,
      className = props.className,
      content = props.content,
      fileSize = props.fileSize,
      isProtected = props.isProtected,
      loading = props.loading,
      style = props.style,
      title = props.title,
      otherProps = _objectWithoutPropertiesLoose(props, ["actionNode", "aspect", "className", "content", "fileSize", "isProtected", "loading", "style", "title"]);

  var kebabify = function kebabify(holder, aspect) {
    var cases = ['fourThree', 'sixteenNine', 'threeTwo'];
    var kebab = (0, _snakeCase.snakeCase)(aspect);

    if (holder === 'container') {
      if (cases.includes(aspect)) {
        return " cui-content__chat-" + kebab;
      }
    } else if (holder === 'inner') {
      if (cases.includes(aspect)) {
        return ' cui-content-file--full';
      } else {
        return " cui-content-file--chat-" + kebab;
      }
    }
  };

  return _react.default.createElement("div", _extends({
    className: 'cui-content__chat-inner-container' + ("" + (aspect === 'wide' && ' cui-content__chat-wide-container' || '')) + ("" + (aspect && kebabify('container', aspect) || ''))
  }, otherProps), _react.default.createElement("div", {
    className: "" + (aspect && kebabify('inner', aspect) || '') + ("" + (!aspect && ' cui-content-file--full' || '')) + ("" + (className && " " + className || '')),
    style: Object.assign({
      backgroundImage: content && "url(" + content + ")"
    }, style)
  }, loading && _react.default.createElement("div", {
    className: "" + ((content ? 'cui-content--opacity' : 'cui-content--centered') || '')
  }, _react.default.createElement(_.Spinner, null))), !loading && _react.default.createElement("div", {
    className: 'cui-content__hover' + ("" + (aspect === 'wide' && ' cui-content__hover--wide' || ''))
  }, _react.default.createElement("div", {
    className: "cui-content__hover-files"
  }, _react.default.createElement("span", {
    className: "cui-content__hover-files--file-name"
  }, title), _react.default.createElement("span", {
    className: "cui-content__hover-files--file-size"
  }, fileSize)), actionNode && !isProtected && _react.default.createElement("div", {
    className: "cui-content__hover-icons"
  }, actionNode)));
};

ChatContentItem.defaultProps = {
  actionNode: null,
  aspect: null,
  className: '',
  content: '',
  fileSize: '',
  isProtected: null,
  loading: false,
  style: null,
  title: '',
  type: ''
};
ChatContentItem.propTypes = {
  actionNode: _propTypes.default.node,
  aspect: _propTypes.default.oneOf(['oneOne', 'tall', 'threeFour', 'wide', 'fourThree', 'nineSixteen', 'sixteenNine', 'twoThree', 'threeTwo']),
  className: _propTypes.default.string,
  content: _propTypes.default.string,
  fileSize: _propTypes.default.string,
  isProtected: _propTypes.default.bool,
  loading: _propTypes.default.bool,
  style: _propTypes.default.object,
  title: _propTypes.default.string,
  type: _propTypes.default.string
};
ChatContentItem.displayName = 'ChatContentItem';
var _default = ChatContentItem;
exports.default = _default;