import { useFilterContext } from '../FilterContext';
import { useCollectionContext } from '../CollectionContext';
import { useEffect, useState } from 'react';
import { FilterValueTotalState } from '../../state';
export function useFilterValueTotalState({ value, ...params }) {
    const filter = useFilterContext();
    const collection = useCollectionContext();
    const [state] = useState(() => new FilterValueTotalState({
        filter,
        value,
        collection,
        ...params,
    }));
    useEffect(() => state.init(), []);
    useEffect(() => {
        if (value !== state.value) {
            state.refresh(value);
        }
    }, [value]);
    return state;
}
//# sourceMappingURL=useFilterValueTotalState.js.map