import { useState, useCallback } from 'react';

export function useOwnerExclusions() {
  const [excludedIds, setExcludedIds] = useState(new Set());

  const toggleExclusion = useCallback((id) => {
    setExcludedIds(prev => {
      const next = new Set(prev);
      if (next.has(id)) {
        next.delete(id);
      } else {
        next.add(id);
      }
      return next;
    });
  }, []);

  const excludeAll = useCallback((ids) => {
    setExcludedIds(new Set(ids));
  }, []);

  const clearExclusions = useCallback(() => {
    setExcludedIds(new Set());
  }, []);

  const isExcluded = useCallback((id) => {
    return excludedIds.has(id);
  }, [excludedIds]);

  const getExcludedIds = useCallback(() => {
    return Array.from(excludedIds);
  }, [excludedIds]);

  return {
    excludedIds,
    toggleExclusion,
    excludeAll,
    clearExclusions,
    isExcluded,
    getExcludedIds,
    exclusionCount: excludedIds.size
  };
}
