"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _core = require("@blueprintjs/core");
var _react = _interopRequireDefault(require("react"));
var _lodash = require("lodash");
var _pureNoFunc = _interopRequireDefault(require("../utils/pureNoFunc"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
// import { fullSequenceTranslationMenu } from "../MenuBar/viewSubmenu";
var _default = (0, _pureNoFunc["default"])(function AlignmentVisibilityTool(props) {
  return /*#__PURE__*/_react["default"].createElement(_core.Popover, {
    minimal: true,
    position: "bottom",
    content: /*#__PURE__*/_react["default"].createElement(VisibilityOptions, props),
    target: /*#__PURE__*/_react["default"].createElement(_core.Tooltip, {
      content: "Visibility Options"
    }, /*#__PURE__*/_react["default"].createElement(_core.Button, {
      className: "tg-alignment-visibility-toggle",
      small: true,
      rightIcon: "caret-down",
      intent: _core.Intent.PRIMARY,
      minimal: true,
      icon: "eye-open"
    }))
  });
});
exports["default"] = _default;
function VisibilityOptions(_ref) {
  var alignmentAnnotationVisibilityToggle = _ref.alignmentAnnotationVisibilityToggle,
    _ref$togglableAlignme = _ref.togglableAlignmentAnnotationSettings,
    togglableAlignmentAnnotationSettings = _ref$togglableAlignme === void 0 ? {} : _ref$togglableAlignme,
    annotationsWithCounts = _ref.annotationsWithCounts,
    currentPairwiseAlignmentIndex = _ref.currentPairwiseAlignmentIndex;
  var annotationCountToUse = {};
  if (currentPairwiseAlignmentIndex) {
    annotationCountToUse = annotationsWithCounts[currentPairwiseAlignmentIndex];
  } else {
    annotationCountToUse = annotationsWithCounts[0];
  }
  return /*#__PURE__*/_react["default"].createElement(_core.Menu, {
    style: {
      padding: 10
    },
    className: "alignmentAnnotationVisibilityToolInner"
  }, (0, _lodash.map)(togglableAlignmentAnnotationSettings, function (visible, annotationName) {
    return /*#__PURE__*/_react["default"].createElement(_core.MenuItem, {
      icon: visible ? "tick" : "",
      onClick: function onClick(e) {
        var _alignmentAnnotationV;
        e.stopPropagation();
        if (annotationName === "axis") {
          return alignmentAnnotationVisibilityToggle({
            axisNumbers: !visible,
            axis: !visible
          });
        }
        if (annotationName === "cdsFeatureTranslations" && !visible) {
          return alignmentAnnotationVisibilityToggle({
            cdsFeatureTranslations: !visible,
            translations: !visible
          });
        }
        alignmentAnnotationVisibilityToggle((_alignmentAnnotationV = {}, _alignmentAnnotationV[annotationName] = !visible, _alignmentAnnotationV));
      },
      text: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, (0, _lodash.startCase)(annotationName).replace("Cds", "CDS").replace("Dna", "DNA"), annotationName in annotationCountToUse ? /*#__PURE__*/_react["default"].createElement(_core.Tag, {
        round: true,
        style: {
          marginLeft: 7
        }
      }, annotationCountToUse[annotationName]) : ""),
      key: annotationName
    });
  }));
}
module.exports = exports.default;