'use strict';
import { jsxs, jsx } from 'react/jsx-runtime';
import { onActionCallback } from './TableCustomAction.funcs.js';
import { Icon } from '../../../fd-component-toolbox/icon/Icon.js';
import { tableCustomActionTypes } from '../table-models.js';
import { Button } from '../../../fd-component-toolbox/button/Button.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function TableCustomAction({
  cellContext,
  customAction,
  onAction
}) {
  const isActionVisible = (customAction?.shouldBeShown ? customAction.shouldBeShown(cellContext) : true) && customAction.actionType !== tableCustomActionTypes.template;
  return isActionVisible && /* @__PURE__ */jsxs(Button, {
    className: "text-muted-foreground hover:text-muted-foreground flex h-7 cursor-pointer items-center gap-2 px-1.5 py-1 font-normal",
    onClick: () => onActionCallback(cellContext, customAction, onAction),
    variant: "ghost",
    children: [customAction.icon && /* @__PURE__ */jsx(Icon, {
      name: customAction.icon
    }), customAction.displayName]
  });
}
__name(TableCustomAction, "TableCustomAction");

export { TableCustomAction };
