import wn from '../../../../../node_modules/preact/compat/dist/compat.module.mjs';
import { IconButtonMenu } from './IconButtonMenu.mjs';
import styled from '../../../../../node_modules/@mui/material/styles/styled.mjs';
import { useCallback as T } from '../../../../../node_modules/preact/hooks/dist/hooks.module.mjs';
import MoreVert from '../../../../../node_modules/@mui/icons-material/esm/MoreVert.mjs';

const StyledDiv = styled('div')({
    display: 'flex',
    width: '100%',
    justifyContent: 'center'
});
const ActionMenu = ({ actions, item, idPrefix })=>{
    return /*#__PURE__*/ wn.createElement(IconButtonMenu, {
        actions: actions,
        item: item,
        idPrefix: idPrefix,
        icon: /*#__PURE__*/ wn.createElement(MoreVert, {
            fontSize: "large"
        })
    });
};
const useActionMenu = ({ actions, idPrefix, getId })=>{
    const getItemActionProps = T((item)=>{
        const hasVisibleActions = actions.some(({ isVisible = true })=>typeof isVisible === 'function' ? isVisible(item) : isVisible);
        if (!hasVisibleActions) {
            return {};
        }
        return {
            customAction: /*#__PURE__*/ wn.createElement(StyledDiv, null, /*#__PURE__*/ wn.createElement(ActionMenu, {
                actions: actions,
                item: item,
                idPrefix: `${idPrefix}-action-menu-${getId(item)}`
            }))
        };
    }, [
        actions,
        getId,
        idPrefix
    ]);
    return {
        getItemActionProps
    };
};

export { ActionMenu, useActionMenu };
//# sourceMappingURL=ActionMenu.mjs.map
