import React__default, { Children, useEffect } from 'react';
import { u as useDataListContext } from './DataListContext-es.js';
import { u as useDataListLayoutContext } from './DataListLayoutContext-es.js';
import { D as DataListItemActionsOverflow } from './DataListItemActionsOverflow-es.js';
import { G as Glimmer } from './Glimmer-es.js';

var styles = {"hidden":"CwWlXTKCPUg-","spinning":"JD9H0C1ehv0-"};

function DataListLayoutActions() {
    const { itemActionComponent, loadingState } = useDataListContext();
    const { setHasInLayoutActions } = useDataListLayoutContext();
    const { children: actionsChildren } = (itemActionComponent === null || itemActionComponent === void 0 ? void 0 : itemActionComponent.props) || {};
    const actions = Children.toArray(actionsChildren);
    const hasActions = actions.length > 0;
    useEffect(() => {
        setHasInLayoutActions(hasActions);
        return () => {
            setHasInLayoutActions(false);
        };
    }, []);
    if (loadingState === "initial") {
        return React__default.createElement(Glimmer, { shape: "square", size: "large" });
    }
    if (!hasActions)
        return null;
    return (React__default.createElement(DataListLayoutActionsWrapper, null,
        React__default.createElement(DataListItemActionsOverflow, { actions: actions })));
}
function DataListLayoutActionsWrapper({ children }) {
    const { isInLayoutProvider } = useDataListLayoutContext();
    if (isInLayoutProvider)
        return React__default.createElement(React__default.Fragment, null, children);
    return React__default.createElement("div", { className: styles.hidden }, children);
}

export { DataListLayoutActions as D };
