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