import { useBooleanState } from "../../../react-utils/index.js";
export function useSearch({ state, onChange, onSearchPrev, onSearchNext, onReplaceNext, onReplaceAll, }) {
    const [isCompact, , showFullForm] = useBooleanState(true);
    const handleSearchChange = (value) => {
        onChange({ ...state, search: value });
    };
    const handleReplacementChange = (value) => {
        onChange({ ...state, replace: value });
    };
    const handleFindPrevious = () => {
        onSearchPrev(state);
    };
    const handleFindNext = () => {
        onSearchNext(state);
    };
    const handleReplace = () => {
        onReplaceNext(state);
    };
    const handleReplaceAll = () => {
        onReplaceAll(state);
    };
    const handleCaseSensitiveChange = (val) => {
        onChange({ ...state, caseSensitive: val });
    };
    const handleWholeWordChange = (val) => {
        onChange({ ...state, wholeWord: val });
    };
    return {
        isCompact,
        searchState: state,
        handlers: {
            onExpand: showFullForm,
            onSearchChange: handleSearchChange,
            onReplaceChange: handleReplacementChange,
            onWholeWordChange: handleWholeWordChange,
            onCaseSensitiveChange: handleCaseSensitiveChange,
            onFindPrevious: handleFindPrevious,
            onFindNext: handleFindNext,
            onReplace: handleReplace,
            onReplaceAll: handleReplaceAll,
        },
    };
}
//# sourceMappingURL=use-search.js.map
