var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// packages/keyboard-shortcuts/src/store/selectors.js
var selectors_exports = {};
__export(selectors_exports, {
  getAllShortcutKeyCombinations: () => getAllShortcutKeyCombinations,
  getAllShortcutRawKeyCombinations: () => getAllShortcutRawKeyCombinations,
  getCategoryShortcuts: () => getCategoryShortcuts,
  getShortcutAliases: () => getShortcutAliases,
  getShortcutDescription: () => getShortcutDescription,
  getShortcutKeyCombination: () => getShortcutKeyCombination,
  getShortcutRepresentation: () => getShortcutRepresentation
});
module.exports = __toCommonJS(selectors_exports);
var import_data = require("@wordpress/data");
var import_keycodes = require("@wordpress/keycodes");
var EMPTY_ARRAY = [];
var FORMATTING_METHODS = {
  display: import_keycodes.displayShortcut,
  raw: import_keycodes.rawShortcut,
  ariaLabel: import_keycodes.shortcutAriaLabel
};
function getKeyCombinationRepresentation(shortcut, representation) {
  if (!shortcut) {
    return null;
  }
  return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](
    shortcut.character
  ) : shortcut.character;
}
function getShortcutKeyCombination(state, name) {
  return state[name] ? state[name].keyCombination : null;
}
function getShortcutRepresentation(state, name, representation = "display") {
  const shortcut = getShortcutKeyCombination(state, name);
  return getKeyCombinationRepresentation(shortcut, representation);
}
function getShortcutDescription(state, name) {
  return state[name] ? state[name].description : null;
}
function getShortcutAliases(state, name) {
  return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
}
var getAllShortcutKeyCombinations = (0, import_data.createSelector)(
  (state, name) => {
    return [
      getShortcutKeyCombination(state, name),
      ...getShortcutAliases(state, name)
    ].filter(Boolean);
  },
  (state, name) => [state[name]]
);
var getAllShortcutRawKeyCombinations = (0, import_data.createSelector)(
  (state, name) => {
    return getAllShortcutKeyCombinations(state, name).map(
      (combination) => getKeyCombinationRepresentation(combination, "raw")
    );
  },
  (state, name) => [state[name]]
);
var getCategoryShortcuts = (0, import_data.createSelector)(
  (state, categoryName) => {
    return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
  },
  (state) => [state]
);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getAllShortcutKeyCombinations,
  getAllShortcutRawKeyCombinations,
  getCategoryShortcuts,
  getShortcutAliases,
  getShortcutDescription,
  getShortcutKeyCombination,
  getShortcutRepresentation
});
//# sourceMappingURL=selectors.cjs.map
