import _isNil from "ramda/src/isNil";
import React from 'react';
import styled from 'styled-components';
import { TextWrapper } from './TextWrapper';
import { SORT_ORDER_NONE } from '../../shared/constants';
import { SortIcon } from './SortIcon';
import { SortButton } from './SortButton';
import { Flexbox } from '../../../..';
import { CellInlineContainer } from '../../shared';
var StyledFlexboxContainer = styled(Flexbox).withConfig({
  displayName: "HeaderContent__StyledFlexboxContainer",
  componentId: "sc-139a6jz-0"
})(["justify-content:inherit;"]);
export var HeaderContent = function HeaderContent(_ref) {
  var sortable = _ref.sortable,
    sortOrder = _ref.sortOrder,
    onSortClick = _ref.onSortClick,
    children = _ref.children;
  if (!sortable || sortOrder === null) {
    return React.createElement(TextWrapper, {
      sorted: false
    }, children);
  }
  return React.createElement(SortButton, {
    onClick: onSortClick
  }, React.createElement(StyledFlexboxContainer, {
    container: true
  }, React.createElement(CellInlineContainer, {
    item: true
  }, React.createElement(TextWrapper, {
    sorted: !_isNil(sortOrder) && sortOrder !== SORT_ORDER_NONE
  }, children)), React.createElement(Flexbox, {
    item: true
  }, React.createElement(SortIcon, {
    sortOrder: sortOrder
  }))));
};