"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PresetList = exports.cnGptDialogPresetList = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const uikit_1 = require("@gravity-ui/uikit");
const classname_1 = require("../../../../classname.js");
const dialog_1 = require("../../../../i18n/gpt/dialog/index.js");
const constants_1 = require("../constants.js");
const useGptHotKeys_1 = require("../hooks/useGptHotKeys.js");
const usePresetList_1 = require("../hooks/usePresetList.js");
require("./Presetlist.css");
exports.cnGptDialogPresetList = (0, classname_1.cn)('gpt-dialog-preset-list');
const PresetItem = ({ preset, onPresetClick, disablePromptPresets, hotKey, }) => {
    (0, useGptHotKeys_1.useGptHotKeys)(hotKey, () => {
        onPresetClick(preset.data);
    }, { enableOnFormTags: true, enableOnContentEditable: true });
    return ((0, jsx_runtime_1.jsx)(uikit_1.ActionTooltip, { title: preset.display, hotkey: hotKey, children: (0, jsx_runtime_1.jsx)(uikit_1.Button, { className: (0, exports.cnGptDialogPresetList)('preset'), view: "normal", size: "m", disabled: disablePromptPresets, onClick: () => onPresetClick(preset.data), children: preset.display }) }));
};
const PresetList = ({ disablePromptPresets, promptPresets, onPresetClick, }) => {
    const { presetsContainerRef, visiblePresets, hiddenPresets, showMoreButton, measured } = (0, usePresetList_1.usePresetList)({
        promptPresets,
        onPresetClick,
    });
    return ((0, jsx_runtime_1.jsxs)("div", { className: (0, exports.cnGptDialogPresetList)({ measured }), ref: presetsContainerRef, children: [visiblePresets.map((preset, index) => ((0, jsx_runtime_1.jsx)(PresetItem, { preset: preset, hotKey: preset.hotKey || constants_1.gptHotKeys.presetsKey(String(index + 1)), disablePromptPresets: disablePromptPresets, onPresetClick: onPresetClick }, preset.display))), showMoreButton && ((0, jsx_runtime_1.jsx)(uikit_1.DropdownMenu, { switcherWrapperClassName: (0, exports.cnGptDialogPresetList)('more-button-wrapper'), switcher: (0, jsx_runtime_1.jsx)(uikit_1.Button, { className: (0, exports.cnGptDialogPresetList)('more-button'), view: "normal", size: "m", children: (0, dialog_1.i18n)('more') }), items: hiddenPresets }))] }));
};
exports.PresetList = PresetList;
//# sourceMappingURL=PresetList.js.map
