"use strict";
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);
var shortcuts_sheet_exports = {};
__export(shortcuts_sheet_exports, {
  ShortcutsSheet: () => ShortcutsSheet
});
module.exports = __toCommonJS(shortcuts_sheet_exports);
var import_v1 = require("./../../ricos-schema/legacy/wix/rich_content/v1/index.js");
class ShortcutsSheet {
  constructor(shortcuts, context) {
    this.ordering = {
      ShortcutsSheet_Section_General: [
        "MoveSelectionThroughElements",
        "UNDO",
        "REDO",
        "OpenShortcutsSheet",
        "SelectAll",
        "SelectTextBlocks",
        "ClearSelection"
      ],
      ShortcutsSheet_Section_ToolbarNavigation: [
        "EnterToolbar",
        "MoveSelectionToNextOption",
        "MoveSelectionToPreviousOption",
        "ApplySelection",
        "ExitToolbar"
      ],
      ShortcutsSheet_Section_Formatting: [
        "PARAGRAPH",
        `${import_v1.Node_Type.HEADING}.1`,
        `${import_v1.Node_Type.HEADING}.2`,
        `${import_v1.Node_Type.HEADING}.3`,
        `${import_v1.Node_Type.HEADING}.4`,
        `${import_v1.Node_Type.HEADING}.5`,
        `${import_v1.Node_Type.HEADING}.6`,
        "FONT_SIZE.increase",
        "FONT_SIZE.decrease",
        "INDENT.increase",
        "INDENT.decrease",
        "TextAlignment.LEFT",
        "TextAlignment.RIGHT",
        "TextAlignment.CENTER",
        "TextAlignment.JUSTIFY",
        "BOLD",
        "ITALIC",
        "UNDERLINE",
        "STRIKETHROUGH",
        "SUBSCRIPT",
        "SUPERSCRIPT",
        "ORDERED_LIST",
        "BULLETED_LIST",
        "BLOCKQUOTE",
        "LINK",
        "CODE_BLOCK",
        "PasteWithoutFormatting",
        "NewLine",
        "SoftNewLine",
        "Enter"
      ],
      ShortcutsSheet_Section_Table: [
        ["MoveToNextCellTab", "MoveToNextCellArrow"],
        ["MoveToPreviousCellTab", "MoveToPreviousCellArrow"],
        "EnterExitCell",
        ["AddNewLineShift", "AddNewLineAlt"],
        "DropLineInList",
        "SelectContentInCell",
        "SelectColumn",
        "SelectRow",
        "SelectTable",
        "AddNewColumnRow",
        "DeleteColumnRow"
      ],
      ShortcutsSheet_Section_CollapsibleList: [
        ["MoveToNextElementTab", "MoveToNextElementEnter"],
        // TODO: add SelectAllContentWithinSection
        "SelectEntireList"
      ]
    };
    this.shortcuts = shortcuts;
    this.translator = context.t;
    this.platform = context.platform;
  }
  getSections() {
    const displayData = this.shortcuts.getDisplayData(this.translator, this.platform);
    let sections = [
      "ShortcutsSheet_Section_General",
      "ShortcutsSheet_Section_ToolbarNavigation",
      "ShortcutsSheet_Section_Formatting"
    ];
    if (displayData.ShortcutsSheet_Section_Table) {
      sections = sections.concat("ShortcutsSheet_Section_Table");
    }
    return sections;
  }
  getDisplayData() {
    return this.getSections().reduce((map, sectionId) => {
      const sectionShortcuts = this.ordering[sectionId].map((id) => {
        if (Array.isArray(id)) {
          const displayDataItems = id.map((id2) => this.shortcuts.getShortcutDisplayData(id2, this.translator, this.platform)).filter((item) => item.name !== "Empty");
          if (displayDataItems.length === 0) {
            return null;
          }
          return {
            ...displayDataItems[0],
            keyCombinationText: displayDataItems.map(
              ({ keyCombinationText }) => keyCombinationText
            )
          };
        }
        const displayData = this.shortcuts.getShortcutDisplayData(
          id,
          this.translator,
          this.platform
        );
        return displayData.name !== "Empty" ? displayData : null;
      }).filter((item) => item !== null);
      return {
        ...map,
        [sectionId]: sectionShortcuts
      };
    }, {});
  }
}
//# sourceMappingURL=shortcuts-sheet.js.map
