"use client";
import { useFetch } from "../internal/useFetch";
/**
 * Internal hook that fetches the total count of a resource type.
 *
 * Powers the public resource count hooks (`useAgentCount`, `useSkillCount`,
 * `useMcpServerCount`) — not exported from the public API.
 *
 * Issues a minimal `list()` call with `page: { num: 1, size: 1 }` and
 * reads only `totalCount` from the response. The single returned entry
 * is discarded — no entries state is maintained.
 *
 * Unlike {@link useResourceList} which manages full pagination state
 * (entries, page, pageSize, totalPages), this hook tracks only the
 * scalar count, resulting in fewer state updates and re-renders.
 */
export function useResourceCount(listFn, org, options) {
    const query = options?.query;
    const scope = options?.scope ?? "org";
    const { data: count, isLoading, isRefetching, error, refetch } = useFetch(org
        ? async () => {
            const params = {
                org: scope === "all" ? "" : org,
                query: query || undefined,
                excludePublic: false,
                page: { num: 1, size: 1 },
            };
            const result = await listFn(params);
            return result.totalCount;
        }
        : null, [listFn, org, query, scope], undefined);
    return { count, isLoading, isRefetching, error, refetch };
}
//# sourceMappingURL=useResourceCount.js.map