"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getHeaderColumnsActions = getHeaderColumnsActions;
var _faDownLong = require("@fortawesome/free-solid-svg-icons/faDownLong");
var _faUpLong = require("@fortawesome/free-solid-svg-icons/faUpLong");
var _faThumbtack = require("@fortawesome/free-solid-svg-icons/faThumbtack");
var _types = require("../types");
function getHeaderColumnsActions({
  isPinned,
  canSort,
  canPin,
  isPinDisabled,
  limitSorting,
  customActions,
  localizationText
}) {
  const sortActions = [];
  if (canSort) {
    if (limitSorting !== _types.SORTING.ASC) {
      sortActions.push({
        key: _types.SORTING.DESC,
        title: localizationText.sortDescendingText,
        testId: 'sort-desc',
        icon: _faDownLong.faDownLong
      });
    }
    if (limitSorting !== _types.SORTING.DESC) {
      sortActions.push({
        key: _types.SORTING.ASC,
        title: localizationText.sortAscendingText,
        testId: 'sort-asc',
        icon: _faUpLong.faUpLong
      });
    }
  }
  const pinAction = isPinned ? {
    key: _types.ACTIONS.UNPIN,
    title: localizationText.unPinText,
    testId: 'unpin-column',
    icon: _faThumbtack.faThumbtack
  } : {
    key: _types.ACTIONS.PIN,
    title: localizationText.pinText,
    testId: 'pin-column',
    icon: _faThumbtack.faThumbtack,
    disabled: isPinDisabled,
    tooltipText: isPinDisabled ? localizationText.disabledPinText : null
  };
  const pinActions = canPin ? [pinAction] : [];
  const defaultActions = [...pinActions, ...sortActions];
  const standardSection = defaultActions.length ? {
    key: 'standard-actions',
    subOptions: defaultActions
  } : null;
  const customSection = customActions.length ? {
    key: 'custom actions',
    subOptions: customActions
  } : null;
  return [standardSection, customSection].filter(item => !!item);
}