var _excluded = ["isDisabled", "isVisible", "testPrefix", "id", "icon", "handleAction", "selectedRows", "table", "tooltipText", "alwaysEnabled", "disabledTooltipText"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
import React, { useRef, forwardRef } from "react";
import Action from "../../components/action";
import { mergeRefs } from "../../../../utils";
var HeaderAction = /*#__PURE__*/forwardRef(function (_ref, ref) {
  var isDisabled = _ref.isDisabled,
    isVisible = _ref.isVisible,
    testPrefix = _ref.testPrefix,
    id = _ref.id,
    icon = _ref.icon,
    _handleAction = _ref.handleAction,
    selectedRows = _ref.selectedRows,
    table = _ref.table,
    tooltipText = _ref.tooltipText,
    alwaysEnabled = _ref.alwaysEnabled,
    disabledTooltipText = _ref.disabledTooltipText,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var actionRef = useRef();
  var disabled = typeof isDisabled === "function" ? isDisabled() : isDisabled;
  var visible = typeof isVisible === "function" ? isVisible() : isVisible;
  return /*#__PURE__*/React.createElement(Action, _extends({
    ref: mergeRefs(actionRef, ref),
    testPrefix: testPrefix + "-bulk",
    key: id,
    visible: visible,
    id: id,
    icon: icon,
    handleAction: function handleAction() {
      return _handleAction(selectedRows, table);
    },
    tooltipText: tooltipText,
    disabled: !alwaysEnabled && (selectedRows == null ? void 0 : selectedRows.length) < 1 || disabled,
    background: "elementBackground",
    selectedRows: selectedRows,
    disabledTooltipText: typeof disabledTooltipText === "function" ? disabledTooltipText(selectedRows) : disabledTooltipText
  }, rest));
});
export default HeaderAction;