"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useHeader = useHeader;
const react_1 = require("react");
const types_1 = require("./types.js");
function useHeader(props) {
    const { icon, title, preview, baseActions = [], handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState = 'opened', additionalActions = [], titlePosition = 'left', withIcon = true, showTitle = true, className, historyButtonRef, qa, actionQa, actionTooltipTexts, } = props;
    // Build base actions
    const baseActionsList = (0, react_1.useMemo)(() => {
        const actions = [];
        baseActions.forEach((action) => {
            if (action === types_1.HeaderAction.Folding) {
                if (handleFolding) {
                    actions.push({
                        id: action,
                        type: 'base',
                        onClick: () => {
                            const newState = foldingState === 'opened' ? 'collapsed' : 'opened';
                            handleFolding(newState);
                        },
                        foldingState,
                    });
                }
                return;
            }
            const actionMap = {
                [types_1.HeaderAction.NewChat]: handleNewChat,
                [types_1.HeaderAction.History]: handleHistoryToggle,
                [types_1.HeaderAction.Close]: handleClose,
            };
            const handler = actionMap[action];
            if (handler) {
                actions.push({
                    id: action,
                    type: 'base',
                    onClick: handler,
                });
            }
        });
        return actions;
    }, [baseActions, handleNewChat, handleHistoryToggle, handleClose, handleFolding, foldingState]);
    return {
        title,
        preview,
        icon,
        baseActions: baseActionsList,
        additionalActions,
        titlePosition,
        withIcon,
        showTitle,
        className,
        historyButtonRef,
        qa,
        actionQa,
        actionTooltipTexts,
    };
}
//# sourceMappingURL=useHeader.js.map
