import { useRef } from 'react';
import { useRerender } from '../useRerender/index.js';
const proto = Set.prototype;
export function useSet(values) {
    const setRef = useRef();
    const rerender = useRerender();
    if (!setRef.current) {
        const set = new Set(values);
        setRef.current = set;
        set.add = (...args) => {
            proto.add.apply(set, args);
            rerender();
            return set;
        };
        set.clear = (...args) => {
            proto.clear.apply(set, args);
            rerender();
        };
        set.delete = (...args) => {
            const res = proto.delete.apply(set, args);
            rerender();
            return res;
        };
    }
    return setRef.current;
}
