"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof3 = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "DOWN", {
  enumerable: true,
  get: function get() {
    return _consts.DOWN;
  }
});
Object.defineProperty(exports, "HEADING_KEYS", {
  enumerable: true,
  get: function get() {
    return _consts.HEADING_KEYS;
  }
});
Object.defineProperty(exports, "KEY_0", {
  enumerable: true,
  get: function get() {
    return _consts.KEY_0;
  }
});
Object.defineProperty(exports, "KEY_1", {
  enumerable: true,
  get: function get() {
    return _consts.KEY_1;
  }
});
Object.defineProperty(exports, "KEY_2", {
  enumerable: true,
  get: function get() {
    return _consts.KEY_2;
  }
});
Object.defineProperty(exports, "KEY_3", {
  enumerable: true,
  get: function get() {
    return _consts.KEY_3;
  }
});
Object.defineProperty(exports, "KEY_4", {
  enumerable: true,
  get: function get() {
    return _consts.KEY_4;
  }
});
Object.defineProperty(exports, "KEY_5", {
  enumerable: true,
  get: function get() {
    return _consts.KEY_5;
  }
});
Object.defineProperty(exports, "KEY_6", {
  enumerable: true,
  get: function get() {
    return _consts.KEY_6;
  }
});
Object.defineProperty(exports, "LEFT", {
  enumerable: true,
  get: function get() {
    return _consts.LEFT;
  }
});
Object.defineProperty(exports, "RIGHT", {
  enumerable: true,
  get: function get() {
    return _consts.RIGHT;
  }
});
exports.TooltipContentWithMultipleShortcuts = exports.ToolTipContent = void 0;
Object.defineProperty(exports, "UP", {
  enumerable: true,
  get: function get() {
    return _consts.UP;
  }
});
exports.backspace = exports.askAIQuickInsert = exports.applyYellowHighlight = exports.altPaste = exports.alignRight = exports.alignLeft = exports.alignCenter = exports.addRowBeforeVO = exports.addRowBefore = exports.addRowAfterVO = exports.addRowAfter = exports.addLink = exports.addInlineComment = exports.addColumnBeforeVO = exports.addColumnBefore = exports.addColumnAfterVO = exports.addColumnAfter = exports.addAltText = exports.activateVideoControls = void 0;
exports.bindKeymapArrayWithCommand = bindKeymapArrayWithCommand;
exports.bindKeymapWithCommand = bindKeymapWithCommand;
exports.bindKeymapWithEditorCommand = bindKeymapWithEditorCommand;
exports.find = exports.escape = exports.enter = exports.dragToMoveUp = exports.dragToMoveRight = exports.dragToMoveLeft = exports.dragToMoveDown = exports.deleteRow = exports.deleteKey = exports.deleteColumn = exports.decreaseMediaSize = exports.cut = exports.ctrlBackSpace = exports.copyLinkToBlock = exports.copy = exports.continueInRovoChat = exports.clearFormatting = void 0;
exports.findKeyMapForBrowser = findKeyMapForBrowser;
exports.findKeymapByDescription = findKeymapByDescription;
exports.findShortcutByDescription = findShortcutByDescription;
exports.findShortcutByKeymap = findShortcutByKeymap;
exports.focusToContextMenuTrigger = exports.focusTableResizer = void 0;
exports.formatShortcut = formatShortcut;
exports.forwardDelete = void 0;
exports.getAriaKeyshortcuts = getAriaKeyshortcuts;
exports.insertTaskList = exports.insertRule = exports.insertNewLine = exports.insertMention = exports.insertEmoji = exports.insertElements = exports.indentList = exports.indent = exports.increaseMediaSize = void 0;
exports.isCapsLockOnAndModifyKeyboardEvent = isCapsLockOnAndModifyKeyboardEvent;
Object.defineProperty(exports, "keymap", {
  enumerable: true,
  get: function get() {
    return _keymap.keymap;
  }
});
exports.makeKeyMapArrayWithCommon = makeKeyMapArrayWithCommon;
exports.makeKeyMapWithCommon = makeKeyMapWithCommon;
exports.makeKeymap = makeKeymap;
exports.selectColumn = exports.redoAlt = exports.redo = exports.previousCell = exports.pastePlainText = exports.paste = exports.outdentList = exports.outdent = exports.openHelp = exports.nextCell = exports.navToFloatingToolbar = exports.navToEditorToolbar = exports.moveUp = exports.moveRowUpOld = exports.moveRowUp = exports.moveRowDownOld = exports.moveRowDown = exports.moveRight = exports.moveLeft = exports.moveDown = exports.moveColumnRightOld = exports.moveColumnRight = exports.moveColumnLeftOld = exports.moveColumnLeft = void 0;
exports.toggleViewChanges = exports.toggleUnderline = exports.toggleTaskList = exports.toggleTaskItemCheckbox = exports.toggleTable = exports.toggleSuperscript = exports.toggleSubscript = exports.toggleStrikethrough = exports.toggleOrderedList = exports.toggleItalic = exports.toggleHighlightPalette = exports.toggleHeading6 = exports.toggleHeading5 = exports.toggleHeading4 = exports.toggleHeading3 = exports.toggleHeading2 = exports.toggleHeading1 = exports.toggleCodeBlock = exports.toggleCode = exports.toggleBulletList = exports.toggleBold = exports.toggleBlockQuote = exports.tab = exports.submit = exports.startColumnResizing = exports.splitListItem = exports.splitCodeBlock = exports.space = exports.showElementDragHandle = exports.shiftTab = exports.shiftEnter = exports.shiftBackspace = exports.shiftArrowUp = exports.setNormalText = exports.selectTable = exports.selectRow = void 0;
exports.tooltip = tooltip;
exports.undo = void 0;
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _react = _interopRequireWildcard(require("react"));
var _react2 = require("@emotion/react");
var _w3cKeyname = require("w3c-keyname");
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
var _editorCommands = require("../preset/editor-commands");
var _browser = require("../utils/browser");
var _consts = require("./consts");
var _keymap = require("./keymap");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof3(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
/**
 * @jsxRuntime classic
 * @jsx jsx
 */

// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766

var addAltText = exports.addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
var toggleViewChanges = exports.toggleViewChanges = makeKeyMapWithCommon('View changes', 'Mod-Alt-z');
var navToEditorToolbar = exports.navToEditorToolbar = makeKeyMapWithCommon('Navigate to editor toolbar', 'Alt-F9');
var navToFloatingToolbar = exports.navToFloatingToolbar = makeKeyMapWithCommon('Navigate to floating toolbar', 'Alt-F10');
var askAIQuickInsert = exports.askAIQuickInsert = makeKeyMapWithCommon('Ask AI', "Mod-'");
var toggleBold = exports.toggleBold = makeKeyMapWithCommon('Bold', 'Mod-b');
var toggleItalic = exports.toggleItalic = makeKeyMapWithCommon('Italic', 'Mod-i');
var toggleUnderline = exports.toggleUnderline = makeKeyMapWithCommon('Underline', 'Mod-u');
var toggleStrikethrough = exports.toggleStrikethrough = makeKeyMapWithCommon('Strikethrough', 'Mod-Shift-s');
var toggleSubscript = exports.toggleSubscript = makeKeyMapWithCommon('Subscript', 'Mod-Shift-,');
var toggleSuperscript = exports.toggleSuperscript = makeKeyMapWithCommon('Superscript', 'Mod-Shift-.');
var toggleCode = exports.toggleCode = makeKeyMapWithCommon('Code', 'Mod-Shift-m');
var pastePlainText = exports.pastePlainText = makeKeyMapWithCommon('Paste Plain Text', 'Mod-Shift-v');
var clearFormatting = exports.clearFormatting = makeKeyMapWithCommon('Clear formatting', 'Mod-\\');
var setNormalText = exports.setNormalText = makeKeyMapWithCommon('Normal text', 'Mod-Alt-0');
var toggleHeading1 = exports.toggleHeading1 = makeKeyMapWithCommon('Heading 1', 'Mod-Alt-1');
var toggleHeading2 = exports.toggleHeading2 = makeKeyMapWithCommon('Heading 2', 'Mod-Alt-2');
var toggleHeading3 = exports.toggleHeading3 = makeKeyMapWithCommon('Heading 3', 'Mod-Alt-3');
var toggleHeading4 = exports.toggleHeading4 = makeKeyMapWithCommon('Heading 4', 'Mod-Alt-4');
var toggleHeading5 = exports.toggleHeading5 = makeKeyMapWithCommon('Heading 5', 'Mod-Alt-5');
var toggleHeading6 = exports.toggleHeading6 = makeKeyMapWithCommon('Heading 6', 'Mod-Alt-6');
var toggleOrderedList = exports.toggleOrderedList = makeKeyMapWithCommon('Numbered list', 'Mod-Shift-7');
var ctrlBackSpace = exports.ctrlBackSpace = makeKeyMapWithCommon('Cmd + Backspace', 'Mod-Backspace');
var toggleBulletList = exports.toggleBulletList = makeKeyMapWithCommon('Bullet list', 'Mod-Shift-8');
var toggleBlockQuote = exports.toggleBlockQuote = makeKeyMapWithCommon('Quote', 'Mod-Shift-9');
var insertNewLine = exports.insertNewLine = makeKeyMapWithCommon('Insert new line', 'Shift-Enter');
var shiftBackspace = exports.shiftBackspace = makeKeyMapWithCommon('Shift Backspace', 'Shift-Backspace');
var splitCodeBlock = exports.splitCodeBlock = makeKeyMapWithCommon('Split code block', 'Enter');
var splitListItem = exports.splitListItem = makeKeyMapWithCommon('Split list item', 'Enter');
var insertRule = exports.insertRule = makeKeyMapWithCommon('Insert horizontal rule', 'Mod-Shift--');
var undo = exports.undo = makeKeyMapWithCommon('Undo', 'Mod-z');
var moveUp = exports.moveUp = makeKeyMapWithCommon('Move up', 'ArrowUp');
var moveDown = exports.moveDown = makeKeyMapWithCommon('Move down', 'ArrowDown');
var moveLeft = exports.moveLeft = makeKeyMapWithCommon('Move left', 'ArrowLeft');
var moveRight = exports.moveRight = makeKeyMapWithCommon('Move right', 'ArrowRight');
var indentList = exports.indentList = makeKeyMapWithCommon('Indent List', 'Tab');
var outdentList = exports.outdentList = makeKeyMapWithCommon('Outdent List', 'Shift-Tab');
var redoAlt = exports.redoAlt = makeKeyMapWithCommon('Redo', 'Mod-y');
var redo = exports.redo = makeKeymap('Redo', 'Ctrl-y', 'Mod-Shift-z');
var openHelp = exports.openHelp = makeKeyMapWithCommon('Open Help', 'Mod-/');
var addLink = exports.addLink = makeKeyMapWithCommon('Link', 'Mod-k');
var addInlineComment = exports.addInlineComment = makeKeyMapWithCommon('Annotate', 'Mod-Alt-c');
// [FEATURE FLAG: platform_editor_block_menu_v2_patch_3]
// Updated wording from "Copy link to block" to "Copy link to selection" for better UX clarity.
// The actual displayed text is conditionally shown in the UI component based on the flag.
// To clean up: This can remain as-is since it's the canonical name for the action.
var copyLinkToBlock = exports.copyLinkToBlock = makeKeyMapWithCommon('Copy link to selection', 'Mod-Alt-a');
var submit = exports.submit = makeKeyMapWithCommon('Submit Content', 'Mod-Enter');
var enter = exports.enter = makeKeyMapWithCommon('Enter', 'Enter');
var shiftEnter = exports.shiftEnter = makeKeyMapWithCommon('Shift Enter', 'Shift-Enter');
var tab = exports.tab = makeKeyMapWithCommon('Tab', 'Tab');
var indent = exports.indent = makeKeyMapWithCommon('Indent', 'Tab');
var outdent = exports.outdent = makeKeyMapWithCommon('Outdent', 'Shift-Tab');
var backspace = exports.backspace = makeKeyMapWithCommon('Backspace', 'Backspace');
var deleteKey = exports.deleteKey = makeKeyMapWithCommon('Delete', 'Delete');
var forwardDelete = exports.forwardDelete = makeKeymap('Forward Delete', '', 'Ctrl-d');
var space = exports.space = makeKeyMapWithCommon('Space', 'Space');
var escape = exports.escape = makeKeyMapWithCommon('Escape', 'Escape');
var nextCell = exports.nextCell = makeKeyMapWithCommon('Next cell', 'Tab');
var previousCell = exports.previousCell = makeKeyMapWithCommon('Previous cell', 'Shift-Tab');
var shiftArrowUp = exports.shiftArrowUp = makeKeyMapWithCommon('Shift ArrowUp', 'Shift-ArrowUp');
var shiftTab = exports.shiftTab = makeKeyMapWithCommon('Shift Tab', 'Shift-Tab');
var toggleTable = exports.toggleTable = makeKeyMapWithCommon('Table', 'Shift-Alt-t');
var focusTableResizer = exports.focusTableResizer = makeKeyMapWithCommon('Focus Table Resizer', 'Mod-Alt-Shift-r');
var addRowBefore = exports.addRowBefore = makeKeyMapWithCommon('Add Row Above', 'Ctrl-Alt-ArrowUp');
var addRowAfter = exports.addRowAfter = makeKeyMapWithCommon('Add Row Below', 'Ctrl-Alt-ArrowDown');
var addColumnAfter = exports.addColumnAfter = makeKeyMapWithCommon('Add Column After', 'Ctrl-Alt-ArrowRight');
var addColumnBefore = exports.addColumnBefore = makeKeyMapWithCommon('Add Column Before', 'Ctrl-Alt-ArrowLeft');
// The following few shortcuts that end in VO are added specifically for Voice Over users, as shortcuts that perform the same role when using Voice Over don't work because they conflict with default shortcuts in Voice Over
var addRowBeforeVO = exports.addRowBeforeVO = makeKeyMapWithCommon('Add Row Above', 'Mod-Alt-[');
var addRowAfterVO = exports.addRowAfterVO = makeKeyMapWithCommon('Add Row Below', 'Mod-Alt-]');
var addColumnAfterVO = exports.addColumnAfterVO = makeKeyMapWithCommon('Add Column After', 'Mod-Alt-=');
var addColumnBeforeVO = exports.addColumnBeforeVO = makeKeyMapWithCommon('Add Column Before', 'Mod-Alt--');

// When cleaning up editor-a11y-fy26-keyboard-move-row-column experiment
// Remove moveColumn<Left/Right>Old and moveRow<Up/Down>Old
var moveColumnLeftOld = exports.moveColumnLeftOld = makeKeyMapWithCommon('Move Column Left', 'Ctrl-Alt-Shift-ArrowLeft');
var moveColumnLeft = exports.moveColumnLeft = makeKeyMapWithCommon('Move Column Left', 'Mod-Alt-Shift--');
var moveColumnRightOld = exports.moveColumnRightOld = makeKeyMapWithCommon('Move Column Right', 'Ctrl-Alt-Shift-ArrowRight');
var moveColumnRight = exports.moveColumnRight = makeKeyMapWithCommon('Move Column Right', 'Mod-Alt-Shift-=');
var moveRowDownOld = exports.moveRowDownOld = makeKeyMapWithCommon('Move Row Down', 'Ctrl-Alt-Shift-ArrowDown');
var moveRowDown = exports.moveRowDown = makeKeyMapWithCommon('Move Row Down', 'Mod-Alt-Shift-]');
var moveRowUpOld = exports.moveRowUpOld = makeKeyMapWithCommon('Move Row Up', 'Ctrl-Alt-Shift-ArrowUp');
var moveRowUp = exports.moveRowUp = makeKeyMapWithCommon('Move Row Up', 'Mod-Alt-Shift-[');
var deleteColumn = exports.deleteColumn = makeKeyMapWithCommon('Delete Column', 'Ctrl-Backspace');
var deleteRow = exports.deleteRow = makeKeyMapWithCommon('Delete Row', 'Ctrl-Backspace');
var startColumnResizing = exports.startColumnResizing = makeKeyMapWithCommon('Activate Column Resize', 'Mod-Alt-Shift-c');
var cut = exports.cut = makeKeyMapWithCommon('Cut', 'Mod-x');
var copy = exports.copy = makeKeyMapWithCommon('Copy', 'Mod-c');
var paste = exports.paste = makeKeyMapWithCommon('Paste', 'Mod-v');
var altPaste = exports.altPaste = makeKeyMapWithCommon('Paste', 'Mod-Shift-v');
var find = exports.find = makeKeyMapWithCommon('Find', 'Mod-f');
var alignLeft = exports.alignLeft = makeKeyMapWithCommon('Align Left', 'Mod-Shift-l');
var alignCenter = exports.alignCenter = makeKeyMapWithCommon('Align Center', 'Mod-Alt-e');
var alignRight = exports.alignRight = makeKeyMapWithCommon('Align Right', 'Mod-Alt-t');
var toggleTaskItemCheckbox = exports.toggleTaskItemCheckbox = makeKeyMapWithCommon('Toggles task item', 'Mod-Alt-Enter');
var toggleTaskList = exports.toggleTaskList = makeKeyMapWithCommon('Toggle task list', 'Mod-Shift-6');
var selectRow = exports.selectRow = makeKeyMapArrayWithCommon('Select row', ['Mod-Alt-Shift-ArrowLeft', 'Mod-Alt-Shift-ArrowRight']);
var selectColumn = exports.selectColumn = makeKeyMapArrayWithCommon('Select column', ['Mod-Alt-Shift-ArrowDown', 'Mod-Alt-Shift-ArrowUp']);
var selectTable = exports.selectTable = makeKeyMapWithCommon('Select table', 'Mod-a');
var increaseMediaSize = exports.increaseMediaSize = makeKeyMapWithCommon('increase image size', 'Mod-Alt-]');
var decreaseMediaSize = exports.decreaseMediaSize = makeKeyMapWithCommon('increase image size', 'Mod-Alt-[');
var activateVideoControls = exports.activateVideoControls = makeKeyMapWithCommon('Activate controls panel on video', 'Shift-F10');
var toggleHighlightPalette = exports.toggleHighlightPalette = makeKeyMapWithCommon('Toggle Highlight Palette', 'Mod-Alt-b');
var applyYellowHighlight = exports.applyYellowHighlight = makeKeyMapWithCommon('Apply Yellow Highlight', 'Mod-Alt-y');
var focusToContextMenuTrigger = exports.focusToContextMenuTrigger = makeKeyMapWithCommon('Focus table context menu trigger', 'Shift-F10');
var dragToMoveUp = exports.dragToMoveUp = makeKeyMapWithCommon('Move node up in the document', 'Ctrl-Shift-ArrowUp');
var dragToMoveDown = exports.dragToMoveDown = makeKeyMapWithCommon('Move node down in the document', 'Ctrl-Shift-ArrowDown');
var dragToMoveLeft = exports.dragToMoveLeft = makeKeyMapWithCommon('Move node to the left column in the document', 'Ctrl-Shift-Alt-ArrowLeft');
var dragToMoveRight = exports.dragToMoveRight = makeKeyMapWithCommon('Move node to the right column in the document', 'Ctrl-Shift-Alt-ArrowRight');
var showElementDragHandle = exports.showElementDragHandle = makeKeyMapWithCommon('Show drag handle for editor element', 'Ctrl-Shift-h');
var toggleCodeBlock = exports.toggleCodeBlock = makeKeyMapWithCommon('Toggle Code Block', '```');
var insertEmoji = exports.insertEmoji = makeKeyMapWithCommon('Insert Emoji', ':');
var insertMention = exports.insertMention = makeKeyMapWithCommon('Insert Mention', '@');
var insertTaskList = exports.insertTaskList = makeKeyMapWithCommon('Insert Action Item', '[]');
var insertElements = exports.insertElements = makeKeyMapWithCommon('Insert Elements', '/');
var continueInRovoChat = exports.continueInRovoChat = makeKeyMapWithCommon('Continue in Rovo chat', 'Alt-Enter');
var arrowKeysMap = {
  // for reference: https://wincent.com/wiki/Unicode_representations_of_modifier_keys
  ARROWLEFT: "\u2190",
  ARROWRIGHT: "\u2192",
  ARROWUP: "\u2191",
  ARROWDOWN: "\u2193"
};
var tooltipShortcutStyle = (0, _react2.css)({
  borderRadius: "var(--ds-radius-xsmall, 2px)",
  backgroundColor: "var(--ds-background-inverse-subtle, #00000029)",
  padding: "0 ".concat("var(--ds-space-025, 2px)"),
  // NOTE: This might not actually do anything: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E
  label: 'tooltip-shortcut'
});
function formatShortcut(keymap) {
  var shortcut;
  var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
  if (browser.mac) {
    // for reference: https://wincent.com/wiki/Unicode_representations_of_modifier_keys
    shortcut = keymap.mac
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    .replace(/Cmd/i, "\u2318")
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    .replace(/Shift/i, "\u21E7")
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    .replace(/Ctrl/i, "\u2303")
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    .replace(/Alt/i, "\u2325")
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    .replace(/Backspace/i, "\u232B")
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    .replace(/Enter/i, "\u23CE");
  } else {
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    shortcut = keymap.windows.replace(/Backspace/i, "\u232B");
  }
  // If there are two - keys side by side preserve it's place so we can add it back
  var keys = shortcut.split('-');
  var storedEnDash = false;
  if (keys[keys.length - 1] === '' && keys[keys.length - 2] === '') {
    storedEnDash = true;
  }
  var lastKey = keys[keys.length - 1];
  if (lastKey.length === 1) {
    // capitalise single letters
    lastKey = lastKey.toUpperCase();
  }
  keys[keys.length - 1] = arrowKeysMap[lastKey.toUpperCase()] || lastKey;
  if (storedEnDash) {
    keys[keys.length - 1] = '-';
  }
  return keys.join(browser.mac ? '' : '+');
}
function tooltip(keymap, description) {
  if (keymap) {
    var shortcut = formatShortcut(keymap);
    return description ? "".concat(description, " ").concat(shortcut) : shortcut;
  }
  return;
}
var ToolTipContent = exports.ToolTipContent = /*#__PURE__*/_react.default.memo(function (_ref) {
  var description = _ref.description,
    shortcutOverride = _ref.shortcutOverride,
    keymap = _ref.keymap;
  var shortcut = shortcutOverride || keymap && formatShortcut(keymap);
  return shortcut || description ? (0, _react2.jsx)(_react.Fragment, null, description, shortcut && description && "\xA0", shortcut && (0, _react2.jsx)("span", {
    css: tooltipShortcutStyle
  }, shortcut)) : null;
});
var TooltipContentWithMultipleShortcuts = exports.TooltipContentWithMultipleShortcuts = /*#__PURE__*/_react.default.memo(function (_ref2) {
  var helpDescriptors = _ref2.helpDescriptors;
  var keymapCount = helpDescriptors.length;
  return (0, _react2.jsx)(_react.Fragment, null, helpDescriptors.map(function (descriptor, index) {
    return (
      // Ignored via go/ees005
      // eslint-disable-next-line react/no-array-index-key
      (0, _react2.jsx)(_react.Fragment, {
        key: index
      }, (0, _react2.jsx)(ToolTipContent
      // Ignored via go/ees005
      // eslint-disable-next-line react/jsx-props-no-spreading
      , descriptor), ' ', index < keymapCount - 1 && (0, _react2.jsx)("br", null))
    );
  }));
});
function findKeymapByDescription(description) {
  var matches = ALL.filter(function (keymap) {
    return keymap.description.toUpperCase() === description.toUpperCase();
  });
  return matches[0];
}
function findShortcutByDescription(description) {
  var keymap = findKeymapByDescription(description);
  if (keymap) {
    return findShortcutByKeymap(keymap);
  }
  return;
}
function findShortcutByKeymap(keymap) {
  var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
  if (browser.mac) {
    return keymap.mac;
  }
  return keymap.windows;
}
function getAriaKeyshortcuts(keymap) {
  var keyShortcuts;
  var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
  if (typeof keymap === 'string') {
    keyShortcuts = keymap;
  } else if ((0, _typeof2.default)(keymap) === 'object') {
    keyShortcuts = keymap[browser.mac ? 'mac' : 'windows'];
  }
  if (keyShortcuts) {
    return keyShortcuts.toLowerCase().split('-').filter(Boolean).map(function (modifier) {
      switch (modifier) {
        case 'cmd':
          return 'Meta';
        case 'ctrl':
          return 'Control';
        case 'alt':
          return 'Alt';
        case 'shift':
          return 'Shift';
        case 'enter':
          return 'Enter';
        case 'esc':
          return 'Esc';
        case 'tab':
          return 'Tab';
        case 'space':
          return 'Space';
        case 'backspace':
          return 'Backspace';
        case 'arrowup':
          return 'Arrow Up';
        case 'arrowdown':
          return 'Arrow Down';
        default:
          return modifier.split('').join(' ');
      }
    }).join('+');
  } else {
    return undefined;
  }
}
var ALL = [toggleOrderedList, toggleBulletList, toggleBold, toggleItalic, toggleUnderline, toggleStrikethrough, toggleSubscript, toggleSuperscript, toggleCode, setNormalText, toggleHeading1, toggleHeading2, toggleHeading3, toggleHeading4, toggleHeading5, toggleHeading6, toggleBlockQuote, insertNewLine, insertRule, splitCodeBlock, splitListItem, redo, undo, find, escape, enter, shiftEnter];
function makeKeymap(description, windows, mac, common) {
  return {
    description: description,
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    windows: windows.replace(/Mod/i, 'Ctrl'),
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    mac: mac.replace(/Mod/i, 'Cmd'),
    common: common
  };
}
function makeKeyMapWithCommon(description, common) {
  // Ignored via go/ees005
  // eslint-disable-next-line require-unicode-regexp
  var windows = common.replace(/Mod/i, 'Ctrl');
  // Ignored via go/ees005
  // eslint-disable-next-line require-unicode-regexp
  var mac = common.replace(/Mod/i, 'Cmd');
  return makeKeymap(description, windows, mac, common);
}
function makeKeyMapArrayWithCommon(description, shortcuts) {
  var keymapArray = [];
  shortcuts.forEach(function (shortcut) {
    keymapArray.push(makeKeyMapWithCommon(description, shortcut));
  });
  return keymapArray;
}
function combineWithOldCommand(cmd, oldCmd) {
  return function (state, dispatch, editorView) {
    return oldCmd(state, dispatch) || cmd(state, dispatch, editorView);
  };
}
function bindKeymapWithCommand(shortcut, cmd, keymap) {
  var oldCmd = keymap[shortcut];
  keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
}

// If there is a need to use the same command with several shortcuts
function bindKeymapArrayWithCommand(shortcutsArray, cmd, keymap) {
  shortcutsArray.forEach(function (shortcut) {
    // Ignored via go/ees005
    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
    return bindKeymapWithCommand(shortcut.common, cmd, keymap);
  });
}
function bindKeymapWithEditorCommand(shortcut, cmd, keymap) {
  bindKeymapWithCommand(shortcut, (0, _editorCommands.editorCommandToPMCommand)(cmd), keymap);
}
function findKeyMapForBrowser(keyMap) {
  if (keyMap) {
    var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
    if (browser.mac) {
      return keyMap.mac;
    }
    return keyMap.windows;
  }
  return;
}

/**
 * ED-20175: on windows OS if the capsLock is ON then it registers the key with capital case
 * which creates a command (Ctrl-B) and all the keymap bindings are in lower case (Ctrl-b).
 *
 */
function isCapsLockOnAndModifyKeyboardEvent(event) {
  var keyboardEvent = event;
  var name = (0, _w3cKeyname.keyName)(event);
  if (event.ctrlKey && event.getModifierState('CapsLock') && !event.getModifierState('Shift') && name.length === 1 &&
  // Ignored via go/ees005
  // eslint-disable-next-line require-unicode-regexp
  /^[A-Z]/.test(name)) {
    keyboardEvent = new KeyboardEvent('keydown', {
      key: _w3cKeyname.base[event.keyCode].toLowerCase(),
      code: event.code,
      ctrlKey: true
    });
  }
  return keyboardEvent;
}

// eslint-disable-next-line @atlaskit/editor/no-re-export