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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
import React from "react";
import { compose } from "redux";
import withEditorProps from "../withEditorProps";
import { withHotkeys } from "teselagen-react-components";
import getCommands from "../commands";
import { getCommandHotkeys, getCommandHotkeyHandlers, HotkeysDialog } from "teselagen-react-components";
var CommandHotkeyHandler = /*#__PURE__*/function (_React$Component) {
  _inheritsLoose(CommandHotkeyHandler, _React$Component);
  function CommandHotkeyHandler(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    var commands = getCommands(_assertThisInitialized(_this));
    // Don't bind clipboard shortcuts (use native ones directly)
    ["cut", "copy", "paste"].forEach(function (cmdId) {
      return delete commands[cmdId];
    });
    _this.hotkeyDefs = getCommandHotkeys(commands);
    _this.handlers = getCommandHotkeyHandlers(commands);
    _this.Handler = withHotkeys(_this.hotkeyDefs, _this.handlers);
    return _this;
  }
  var _proto = CommandHotkeyHandler.prototype;
  _proto.render = function render() {
    return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(this.Handler, {
      key: "handla"
    }), /*#__PURE__*/React.createElement(HotkeysDialog, _extends({
      dialogTitle: "\u7F16\u8F91\u5668\u5FEB\u6377\u952E",
      key: "hotkeyDialog",
      hotkeySets: {
        Editor: _extends({
          "搜索文件菜单": this.props.menuSearchHotkey || "cmd+/"
        }, this.hotkeyDefs)
      }
    }, this.props.hotkeyDialogProps)));
  };
  return CommandHotkeyHandler;
}(React.Component);
export default compose(withEditorProps)(CommandHotkeyHandler);