import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import Label from '../../components/label/Label';
import LoadingIndicator from '../../components/loading-indicator/LoadingIndicator';
import ClassifiedBadge from './ClassifiedBadge';
import SecurityControls from './security-controls';
import messages from './messages';
import './Classification.scss';
var STYLE_INLINE = 'inline';
var STYLE_TOOLTIP = 'tooltip';

var Classification = function Classification(_ref) {
  var definition = _ref.definition,
      _ref$className = _ref.className,
      className = _ref$className === void 0 ? '' : _ref$className,
      controls = _ref.controls,
      controlsFormat = _ref.controlsFormat,
      isLoadingControls = _ref.isLoadingControls,
      maxAppCount = _ref.maxAppCount,
      messageStyle = _ref.messageStyle,
      name = _ref.name,
      _ref$itemName = _ref.itemName,
      itemName = _ref$itemName === void 0 ? '' : _ref$itemName,
      fillColor = _ref.fillColor,
      strokeColor = _ref.strokeColor,
      onClick = _ref.onClick;
  var isClassified = !!name;
  var hasDefinition = !!definition;
  var hasSecurityControls = !!controls;
  var isTooltipMessageEnabled = isClassified && hasDefinition && messageStyle === STYLE_TOOLTIP;
  var isInlineMessageEnabled = isClassified && hasDefinition && messageStyle === STYLE_INLINE;
  var isNotClassifiedMessageVisible = !isClassified && messageStyle === STYLE_INLINE;
  var isControlsIndicatorEnabled = isClassified && isLoadingControls && messageStyle === STYLE_INLINE;
  var isSecurityControlsEnabled = isClassified && !isLoadingControls && hasSecurityControls && messageStyle === STYLE_INLINE;
  return React.createElement("article", {
    className: "bdl-Classification ".concat(className)
  }, isClassified && React.createElement(ClassifiedBadge, {
    fillColor: fillColor,
    strokeColor: strokeColor,
    name: name,
    onClick: onClick,
    tooltipText: isTooltipMessageEnabled ? definition : undefined
  }), isInlineMessageEnabled && React.createElement(Label, {
    text: React.createElement(FormattedMessage, messages.definition)
  }, React.createElement("p", {
    className: "bdl-Classification-definition"
  }, definition)), isNotClassifiedMessageVisible && React.createElement("span", {
    className: "bdl-Classification-missingMessage"
  }, React.createElement(FormattedMessage, messages.missing)), isSecurityControlsEnabled && React.createElement(SecurityControls, {
    classificationName: name,
    controls: controls,
    controlsFormat: controlsFormat,
    definition: definition,
    itemName: itemName,
    maxAppCount: maxAppCount,
    fillColor: fillColor,
    strokeColor: strokeColor
  }), isControlsIndicatorEnabled && React.createElement(LoadingIndicator, null));
};

export { STYLE_INLINE, STYLE_TOOLTIP };
export default Classification;
//# sourceMappingURL=Classification.js.map