"use client";
import { useCallback, useRef } from "react";
import { createFuzzyRegExp } from "./fuzzy.js";
/**
 * This hook implements a few optimizations for fuzzy searching and filtering
 * together for large datasets (10,000 or more items) and was really created
 * for the autocomplete component.
 *
 * @remarks \@since 6.0.0
 */ export function useFuzzyMatch() {
    const prevQuery = useRef("");
    const fuzzyRegExp = useRef(null);
    return useCallback((options)=>{
        const { query, value } = options;
        if (!query) {
            return true;
        }
        if (!fuzzyRegExp.current || prevQuery.current !== query) {
            prevQuery.current = query;
            fuzzyRegExp.current = createFuzzyRegExp(query);
        }
        return value.length > 0 && fuzzyRegExp.current.test(value);
    }, []);
}

//# sourceMappingURL=useFuzzyMatch.js.map