import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useSeamClient } from '../../../../lib/seam/use-seam-client.js';
export function useDeviceModels(params) {
    const { client: seam } = useSeamClient();
    const queryClient = useQueryClient();
    const { data, ...rest } = useQuery({
        enabled: seam != null,
        queryKey: ['internal', 'device_models', 'list', params],
        queryFn: async () => {
            if (seam == null)
                return [];
            const { data: { device_models: deviceModels }, } = await seam.client.get('/internal/devicedb/v1/device_models/list', { params });
            return deviceModels;
        },
        onSuccess: (deviceModels) => {
            for (const deviceModel of deviceModels) {
                queryClient.setQueryData([
                    'internal',
                    'device_models',
                    'get',
                    { device_model_id: deviceModel.device_model_id },
                ], deviceModel);
            }
        },
    });
    return {
        ...rest,
        // @ts-expect-error: Upstream mismatch between type and route type.
        deviceModels: data,
    };
}
//# sourceMappingURL=use-device-models.js.map