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); }
import { Icon, Menu } from "@blueprintjs/core";
import React from "react";
import { createCommandMenu } from "teselagen-react-components";
import viewSubmenu from "../MenuBar/viewSubmenu";
import getCommands from "../commands";
import ToolbarItem from "./ToolbarItem";
import { connectToEditor } from "../withEditorProps";
import withEditorProps from "../withEditorProps";
export default connectToEditor(function (_ref) {
  var _ref$toolBar = _ref.toolBar,
    toolBar = _ref$toolBar === void 0 ? {} : _ref$toolBar;
  return {
    isOpen: toolBar.openItem === "visibilityTool"
  };
})(function (_ref2) {
  var toolbarItemProps = _ref2.toolbarItemProps,
    isOpen = _ref2.isOpen;
  return /*#__PURE__*/React.createElement(ToolbarItem, _extends({
    Icon: /*#__PURE__*/React.createElement(Icon, {
      icon: "eye-open"
    }),
    onIconClick: "toggleDropdown",
    Dropdown: VisibilityOptions,
    noDropdownIcon: true,
    toggled: isOpen,
    tooltip: isOpen ? "隐藏可见性选项" : "显示可见性选项"
  }, toolbarItemProps));
});
var VisibilityOptions = withEditorProps(function (props) {
  return /*#__PURE__*/React.createElement(Menu, null, createCommandMenu(viewSubmenu, getCommands({
    props: props
  }), {
    useTicks: true,
    omitIcons: true
  }));
});