var _excluded = ["type"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }
import React from "react";
import { MenuItem } from "@blueprintjs/core";
import tgUseLocalStorageState from "tg-use-local-storage-state";
var useAnnotationLimits = function useAnnotationLimits() {
  return tgUseLocalStorageState("annotationLimits", {
    defaultValue: {
      features: 50,
      parts: 50,
      primers: 50,
      warnings: 50,
      assemblyPieces: 50,
      lineageAnnotations: 50,
      cutsites: 100
    }
  });
};
export default useAnnotationLimits;
export function LimitAnnotations(_ref) {
  var type = _ref.type,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _useAnnotationLimits = useAnnotationLimits(),
    _useAnnotationLimits$ = _useAnnotationLimits[0],
    limits = _useAnnotationLimits$ === void 0 ? {} : _useAnnotationLimits$,
    setLimits = _useAnnotationLimits[1];
  return /*#__PURE__*/React.createElement(MenuItem, _extends({
    icon: "blank",
    shouldDismissPopover: false
  }, rest), [50, 100, 200, 400].map(function (n) {
    return /*#__PURE__*/React.createElement(MenuItem, {
      shouldDismissPopover: false,
      icon: (!limits[type] ? n === 50 //if this hasn't been set yet, default it here
      : limits[type] === n) ? "small-tick" : "blank",
      key: n,
      text: n,
      onClick: function onClick() {
        var _extends2;
        return setLimits(_extends({}, limits, (_extends2 = {}, _extends2[type] = n, _extends2)));
      }
    });
  }));
}