import { u as useTime } from './useTime-xYTJHVg1.mjs';
import { s as useState, t as useRoute$2, v as useFetch } from './server.mjs';
import { computed } from 'vue';
import { u as useAttributesFromEvents } from './helpers-BsY9USeL.mjs';

const useEvents = () => {
  const time = useTime();
  const settings = useState("settings");
  const route = useRoute$2();
  const params = useState("params", () => ({
    show_recurrent: settings.value.recurrent_event_visible,
    start: time.startMonth(time.currentYear(), time.currentMonth()),
    query: route.query?.query
  }));
  const { data: events, pending, refresh } = useFetch(
    "/api/events",
    { query: params, dedupe: "defer" },
    "$BJ5cMdaLtK"
    /* nuxt-injected */
  );
  const attributes = computed(() => useAttributesFromEvents(events?.value ?? []));
  return { params, events, attributes, refresh, pending };
};

export { useEvents as u };
