"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.usePresetList = void 0;
const react_1 = require("react");
const PresetList_1 = require("../PresetList/PresetList.js");
const useOverflowingHorizontalItems_1 = require("./useOverflowingHorizontalItems.js");
const usePresetList = ({ promptPresets, onPresetClick, }) => {
    const presetsContainerRef = (0, react_1.useRef)(null);
    const { visibleItems, hiddenItems, measured } = (0, useOverflowingHorizontalItems_1.useOverflowingHorizontalItems)({
        containerRef: presetsContainerRef,
        items: promptPresets,
        itemSelector: `.${(0, PresetList_1.cnGptDialogPresetList)('preset')}`,
        moreButtonSelector: `.${(0, PresetList_1.cnGptDialogPresetList)('more-button-wrapper')}`,
        marginBetweenItems: 8,
    });
    const hiddenPresets = (0, react_1.useMemo)(() => {
        const items = [];
        for (const item of hiddenItems) {
            items.push({
                text: item.display,
                action: () => onPresetClick(item.data),
                items: [],
            });
        }
        return items;
    }, [onPresetClick, hiddenItems]);
    const showMoreButton = !measured || hiddenPresets.length > 0;
    return {
        measured,
        showMoreButton,
        presetsContainerRef,
        visiblePresets: visibleItems,
        hiddenPresets,
    };
};
exports.usePresetList = usePresetList;
//# sourceMappingURL=usePresetList.js.map
