"use strict";

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

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

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

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

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

/**
 *
 * @category containers
 * @component chip
 * @variations collab-ui-react
 *
 */
var Chip = function Chip(_ref) {
  var className = _ref.className,
      leftContent = _ref.leftContent,
      fileDownloadLink = _ref.fileDownloadLink,
      fileType = _ref.fileType,
      rightContent = _ref.rightContent,
      subTitle = _ref.subTitle,
      title = _ref.title,
      type = _ref.type;
  Chip.displayName = 'Chip'; // This appears to be a false positive
  // See: https://github.com/yannickcr/eslint-plugin-react/issues/1181
  // eslint-disable-next-line react/no-multi-comp

  function buildChipLeft() {
    if (type === 'file') {
      return _react.default.createElement(_.Icon, {
        name: "file-" + fileType + "_32"
      });
    }

    if (type === 'recording') {
      return _react.default.createElement(_.Icon, {
        name: "play-circle_32",
        color: "white"
      });
    }

    if (type === 'unauthorized') {
      return _react.default.createElement(_.Icon, {
        name: "warning_32"
      });
    }

    return leftContent;
  } // eslint-disable-next-line react/no-multi-comp


  function buildChipRight() {
    if (rightContent) {
      return rightContent;
    }

    if (type === 'file' && fileDownloadLink) {
      return _react.default.createElement("a", {
        className: "file-download",
        download: true,
        href: fileDownloadLink
      }, _react.default.createElement("i", {
        className: "icon icon-download_32"
      }));
    }

    return null;
  }

  var chipLeft = buildChipLeft();
  var chipRight = buildChipRight();
  return _react.default.createElement("div", {
    className: 'cui-chip' + ("" + (className && " " + className || ''))
  }, _react.default.createElement("div", {
    className: 'cui-chip-left' + ("" + (type && " " + type || ''))
  }, chipLeft), _react.default.createElement("div", {
    className: "cui-chip-center"
  }, title && _react.default.createElement("div", {
    className: "cui-chip__title lead"
  }, title), subTitle && _react.default.createElement("div", {
    className: "cui-chip__sub-title subheader"
  }, subTitle)), chipRight && _react.default.createElement("div", {
    className: "cui-chip-right"
  }, chipRight));
};

Chip.propTypes = {
  className: _propTypes.default.string,
  fileDownloadLink: _propTypes.default.string,
  fileType: _propTypes.default.oneOf(['audio', 'graph', 'image', 'locked', 'missing', 'pdf', 'spreadsheet', 'text', 'video', 'zip']),
  leftContent: _propTypes.default.node,
  rightContent: _propTypes.default.node,
  subTitle: _propTypes.default.string,
  title: _propTypes.default.string,
  type: _propTypes.default.oneOf(['file', 'recording', 'unauthorized'])
};
Chip.defaultProps = {
  className: '',
  fileDownloadLink: '',
  fileType: null,
  leftContent: null,
  rightContent: null,
  subTitle: '',
  title: null,
  type: null
};
var _default = Chip;
/**
 * @name Recording Chip
 *
 * @category containers
 * @component chip
 * @section recording
 * @js

 export default function Chip() {
   return (
     <div className="row">
       <div className="docs-example docs-example--spacing">
         <h3>
           <p><code className="small">size=(16)</code></p>
         </h3>
         <Chip type="recording" title="Webex Teams Recording" subTitle="18 min"/>
       </div>
     </div>
   );
 }

 **/

/**
 * @name File Chip
 *
 * @category containers
 * @component chip
 * @section file
 * @js

 export default function Chip() {
   return (
     <div className="row">
       <div className="docs-example docs-example--spacing">
         <h3>
           <p><code className="small">size=(16)</code></p>
         </h3>
         <Chip type="file" fileType="audio" title="Filename.mp3" subTitle="23kb"  fileDownloadLink="https://www.google.com"/>
       </div>
     </div>
   );
 }
 **/

exports.default = _default;