"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const react_1 = require("react");
const useBlockingActions_1 = require("../../hooks/useBlockingActions");
const useLogic = ({ actions }) => {
    const processedActions = (0, react_1.useMemo)(() => {
        if (!actions?.length) {
            return actions;
        }
        const hasMobilePrimary = actions.some((action) => !action.nested && action.isMobilePrimary);
        if (hasMobilePrimary) {
            return actions;
        }
        return actions.map((action, index) => {
            if (index === 0 && !action.nested) {
                return { ...action, isMobilePrimary: true };
            }
            return action;
        });
    }, [actions]);
    const { isDisabled, onActionClick } = (0, useBlockingActions_1.useBlockingActions)(processedActions);
    return {
        processedActions,
        isDisabled,
        onActionClick,
    };
};
exports.useLogic = useLogic;
