function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
// eslint-disable-next-line no-unused-vars
import * as React from 'react';
import * as EditorCommands from '../EditorCommands.js';
import FontSizeCommandMenuButton from './FontSizeCommandMenuButton.js';
import FontTypeCommandMenuButton from './FontTypeCommandMenuButton.js';
import ListTypeCommandButton from './ListTypeCommandButton.js';
import Icon from './Icon.js';
var ICON_LABEL_PATTERN = /\[([A-Za-z_\d]+)\](.*)/;
export function parseLabel(input) {
  var matched = ICON_LABEL_PATTERN.exec(input);
  if (matched) {
    var _matched = _slicedToArray(matched, 3),
      // eslint-disable-next-line no-unused-vars
      all = _matched[0],
      icon = _matched[1],
      label = _matched[2];
    return {
      icon: icon ? Icon.get(icon) : null,
      title: label || null
    };
  }
  return {
    icon: null,
    title: input || null
  };
}
var CLEAR_FORMAT = EditorCommands.CLEAR_FORMAT,
  EM = EditorCommands.EM,
  HISTORY_REDO = EditorCommands.HISTORY_REDO,
  HISTORY_UNDO = EditorCommands.HISTORY_UNDO,
  HR = EditorCommands.HR,
  INDENT_LESS = EditorCommands.INDENT_LESS,
  INDENT_MORE = EditorCommands.INDENT_MORE,
  LINK_SET_URL = EditorCommands.LINK_SET_URL,
  STRIKE = EditorCommands.STRIKE,
  STRONG = EditorCommands.STRONG,
  SUPER = EditorCommands.SUPER,
  SUB = EditorCommands.SUB,
  TABLE_ADD_COLUMN_AFTER = EditorCommands.TABLE_ADD_COLUMN_AFTER,
  TABLE_ADD_COLUMN_BEFORE = EditorCommands.TABLE_ADD_COLUMN_BEFORE,
  TABLE_ADD_ROW_AFTER = EditorCommands.TABLE_ADD_ROW_AFTER,
  TABLE_ADD_ROW_BEFORE = EditorCommands.TABLE_ADD_ROW_BEFORE,
  TABLE_BORDER_COLOR = EditorCommands.TABLE_BORDER_COLOR,
  TABLE_DETAILS = EditorCommands.TABLE_DETAILS,
  TABLE_BACKGROUND_COLOR = EditorCommands.TABLE_BACKGROUND_COLOR,
  TABLE_DELETE_COLUMN = EditorCommands.TABLE_DELETE_COLUMN,
  TABLE_DELETE_ROW = EditorCommands.TABLE_DELETE_ROW,
  TABLE_DELETE_TABLE = EditorCommands.TABLE_DELETE_TABLE,
  TABLE_INSERT_TABLE = EditorCommands.TABLE_INSERT_TABLE,
  TABLE_MERGE_CELLS = EditorCommands.TABLE_MERGE_CELLS,
  TABLE_SPLIT_ROW = EditorCommands.TABLE_SPLIT_ROW,
  TABLE_TOGGLE_HEADER_CELL = EditorCommands.TABLE_TOGGLE_HEADER_CELL,
  TABLE_TOGGLE_HEADER_COLUMN = EditorCommands.TABLE_TOGGLE_HEADER_COLUMN,
  TABLE_TOGGLE_HEADER_ROW = EditorCommands.TABLE_TOGGLE_HEADER_ROW,
  TEXT_ALIGN_CENTER = EditorCommands.TEXT_ALIGN_CENTER,
  TEXT_ALIGN_JUSTIFY = EditorCommands.TEXT_ALIGN_JUSTIFY,
  TEXT_ALIGN_LEFT = EditorCommands.TEXT_ALIGN_LEFT,
  TEXT_ALIGN_RIGHT = EditorCommands.TEXT_ALIGN_RIGHT,
  TEXT_COLOR = EditorCommands.TEXT_COLOR,
  TEXT_HIGHLIGHT = EditorCommands.TEXT_HIGHLIGHT,
  TEXT_LINE_SPACINGS = EditorCommands.TEXT_LINE_SPACINGS,
  UL = EditorCommands.UL,
  UNDERLINE = EditorCommands.UNDERLINE;
export var TABLE_COMMANDS_GROUP = [{
  'Insert Table...': TABLE_INSERT_TABLE
}, {
  'Fill Color...': TABLE_BACKGROUND_COLOR,
  'Border Color....': TABLE_BORDER_COLOR
}, {
  'Insert Column Before': TABLE_ADD_COLUMN_BEFORE,
  'Insert Column After': TABLE_ADD_COLUMN_AFTER,
  'Delete Column': TABLE_DELETE_COLUMN
}, {
  'Insert Row Before': TABLE_ADD_ROW_BEFORE,
  'Insert Row After': TABLE_ADD_ROW_AFTER,
  'Delete Row': TABLE_DELETE_ROW
}, {
  'Merge Cells': TABLE_MERGE_CELLS,
  'Split Row': TABLE_SPLIT_ROW
},
// Disable these commands cause user rarely use them.
{
  'Toggle Header Column': TABLE_TOGGLE_HEADER_COLUMN,
  'Toggle Header Row': TABLE_TOGGLE_HEADER_ROW,
  'Toggle Header Cells': TABLE_TOGGLE_HEADER_CELL
}, {
  'Delete Table': TABLE_DELETE_TABLE
}, {
  'Container Dimensions': TABLE_DETAILS
}];

// [FS] IRAD-1012 2020-07-14
// Fix: Toolbar is poorly organized.

export var COMMAND_GROUPS = [{
  '[font_download] Font Type': FontTypeCommandMenuButton
}, {
  '[format_size] Text Size': FontSizeCommandMenuButton
}, {
  '[format_bold] Bold': STRONG,
  '[format_italic] Italic': EM,
  '[format_underline] Underline': UNDERLINE,
  '[format_strikethrough] Strike through': STRIKE,
  '[superscript] Superscript': SUPER,
  '[subscript] Subscript': SUB,
  '[format_color_text] Text color': TEXT_COLOR,
  '[border_color] Highlight color': TEXT_HIGHLIGHT,
  '[format_clear] Clear formats': CLEAR_FORMAT
}, {
  '[format_align_left] Left align': TEXT_ALIGN_LEFT,
  '[format_align_center] Center Align': TEXT_ALIGN_CENTER,
  '[format_align_right] Right Align': TEXT_ALIGN_RIGHT,
  '[format_align_justify] Justify': TEXT_ALIGN_JUSTIFY
}, {
  '[format_indent_increase] Indent more': INDENT_MORE,
  '[format_indent_decrease] Indent less': INDENT_LESS,
  '[format_line_spacing] Line spacing': TEXT_LINE_SPACINGS
}, {
  // [FS] IRAD-1039 2020-09-23
  // Added new command button that brings a popup
  '[format_list_numbered] Ordered list': ListTypeCommandButton,
  '[format_list_bulleted] Bulleted list': UL
}, {
  '[link] Apply link': LINK_SET_URL,
  '[grid_on] Table...': TABLE_COMMANDS_GROUP,
  '[hr] Horizontal line': HR

  // [FS][07-MAY-2020][IRAD-956]
  // '[format_quote] Block quote': BLOCKQUOTE_TOGGLE,
},
// Removed page layout icon from Editor
// {
//   '[settings_overscan] Page layout': DOC_LAYOUT,
// },
{
  '[undo] Undo': HISTORY_UNDO,
  '[redo] Redo': HISTORY_REDO
}];