/* wp:polyfill */
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _element = require("@wordpress/element");
var _keycodes = require("@wordpress/keycodes");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

function KeyCombination({
  keyCombination,
  forceAriaLabel
}) {
  const shortcut = keyCombination.modifier ? _keycodes.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
  const ariaLabel = keyCombination.modifier ? _keycodes.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("kbd", {
    className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
    "aria-label": forceAriaLabel || ariaLabel,
    children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
      if (character === '+') {
        return /*#__PURE__*/(0, _jsxRuntime.jsx)(_element.Fragment, {
          children: character
        }, index);
      }
      return /*#__PURE__*/(0, _jsxRuntime.jsx)("kbd", {
        className: "editor-keyboard-shortcut-help-modal__shortcut-key",
        children: character
      }, index);
    })
  });
}
function Shortcut({
  description,
  keyCombination,
  aliases = [],
  ariaLabel
}) {
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "editor-keyboard-shortcut-help-modal__shortcut-description",
      children: description
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "editor-keyboard-shortcut-help-modal__shortcut-term",
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(KeyCombination, {
        keyCombination: keyCombination,
        forceAriaLabel: ariaLabel
      }), aliases.map((alias, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(KeyCombination, {
        keyCombination: alias,
        forceAriaLabel: ariaLabel
      }, index))]
    })]
  });
}
var _default = exports.default = Shortcut;
//# sourceMappingURL=shortcut.js.map