import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useSeamClient } from '../../../lib/seam/use-seam-client.js';
export function useDevices(params) {
    const { client } = useSeamClient();
    const queryClient = useQueryClient();
    const { data, ...rest } = useQuery({
        enabled: client != null,
        queryKey: ['devices', 'list', params],
        queryFn: async () => {
            if (client == null)
                return [];
            return await client.devices.list(params);
        },
        onSuccess: (devices) => {
            // Prime cache for each device.
            for (const device of devices) {
                queryClient.setQueryData(['devices', 'get', { device_id: device.device_id }], device);
            }
        },
    });
    return { ...rest, devices: data };
}
//# sourceMappingURL=use-devices.js.map