import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { FullSizeOutlineMd } from '../../../icons/FullSizeOutlineMd';
import { MinimizeOutlineMd } from '../../../icons/MinimizeOutlineMd';
import { forwardRefWithGeneric } from '../../forwardRefWithGeneric';
import { Tooltip } from '../../Tooltip';
import { MainActions } from './MainActions';
import { PageActionSkeleton } from './PageActionSkeleton';
import { SecondaryActions } from './SecondaryActions';
import { SecondaryVisibleActions } from './SecondaryVisibleActions';
import { ActionWrapper, CollapsedActionsWrapper, FocusModeButton, MainActionsWrapper, SecondaryVisibleWrapper, Wrapper, } from './styles';
import { useLogic } from './useLogic';
const PageActionsInner = (props, ref) => {
    const { secondary, secondaryVisible, main, className, isLoading, size = 'medium', spacing = 2, } = props;
    const { disabledAction, buttonClassnames, isFocusedMode, handleClick, tooltipTitle, collapsedActions, classnames, } = useLogic(props);
    if (isLoading) {
        return (_jsx(Wrapper, { children: _jsx(PageActionSkeleton, { size: size }) }));
    }
    return (_jsx(Wrapper, { className: className, ref: ref, children: _jsxs(ActionWrapper, { "$spacing": spacing, children: [_jsx(Tooltip, { title: tooltipTitle, enterDelay: 400, enterNextDelay: 400, placement: "bottom-end", children: _jsx(FocusModeButton, { className: buttonClassnames, variant: "outlined", onClick: handleClick, "aria-label": tooltipTitle, color: "grey", children: isFocusedMode ? _jsx(MinimizeOutlineMd, {}) : _jsx(FullSizeOutlineMd, {}) }) }), _jsx(MainActionsWrapper, { "$spacing": spacing, className: classnames, children: _jsx(MainActions, { isDisabled: disabledAction, actions: main, size: size, spacing: spacing }) }), (secondaryVisible || secondary) && (_jsxs(SecondaryVisibleWrapper, { "$spacing": spacing, className: classnames, children: [secondaryVisible && (_jsx(SecondaryVisibleActions, { actions: secondaryVisible, size: size })), secondary && (_jsx(SecondaryActions, { isDisabled: disabledAction, actions: secondary, size: size }))] })), collapsedActions.length > 0 && (_jsx(CollapsedActionsWrapper, { className: classnames, children: _jsx(SecondaryActions, { isDisabled: disabledAction, actions: collapsedActions, size: size }) }))] }) }));
};
export const PageActions = forwardRefWithGeneric(PageActionsInner);
