import { _ as __nuxt_component_2 } from './nuxt-link-GqjpOmWr.mjs';
import { defineComponent, computed, withAsyncContext, mergeProps, withCtx, unref, createVNode, openBlock, createBlock, Fragment, renderList, createCommentVNode, toDisplayString, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrRenderList, ssrInterpolate } from 'vue/server-renderer';
import { V as VAlert } from './VAlert-BaT0SM-1.mjs';
import { V as VLazy, _ as __nuxt_component_1 } from './VLazy-7NXzod89.mjs';
import { DateTime } from 'luxon';
import { u as useTime } from './useTime-xYTJHVg1.mjs';
import { s as useState, x as useHead, v as useFetch, r as VContainer, e as VIcon } from './server.mjs';
import { u as useEvents } from './useEvents-DYRYRw2B.mjs';
import '../nitro/nitro.mjs';
import '@sequelize/core';
import 'html-to-text';
import 'zod';
import 'crypto';
import 'node:fs';
import 'sharp';
import 'path';
import 'node:stream';
import 'jsdom';
import 'dompurify';
import 'mime-types';
import 'fs';
import 'fs/promises';
import 'linkify-html';
import '@peertube/http-signature';
import 'jsonld';
import 'lodash.intersection';
import 'email-templates';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'node:events';
import 'node:buffer';
import 'node:path';
import 'vue-router';
import 'dotenv';
import 'url';
import 'bcryptjs';
import 'slugify';
import 'umzug';
import 'consola';
import '@sequelize/core/decorators-legacy';
import 'util';
import 'mitt';
import 'ical.js';
import 'node:url';
import 'fast-xml-parser';
import './createSimpleFunctional-eaVhl3I5.mjs';
import './Img-CbtP1FQx.mjs';
import './VAvatar-oghuaLjs.mjs';
import './VCardText-D-diyBaj.mjs';
import './VChip-BM5W0ePt.mjs';
import './index-1z1zC4K2.mjs';
import 'perfect-debounce';
import 'v-calendar';
import 'linkifyjs';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import './helpers-BsY9USeL.mjs';

const _sfc_main$1 = {
  __name: "Announcement",
  __ssrInlineRender: true,
  props: { announcement: { type: Object, default: () => ({}) } },
  setup(__props) {
    return (_ctx, _push, _parent, _attrs) => {
      const _component_nuxt_link = __nuxt_component_2;
      _push(ssrRenderComponent(_component_nuxt_link, mergeProps({
        class: "text-decoration-none",
        to: `/announcement/${__props.announcement?.id}`
      }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VAlert, {
              class: "mt-2 mt-sm-4",
              type: "info",
              title: __props.announcement.title
            }, null, _parent2, _scopeId));
          } else {
            return [
              createVNode(VAlert, {
                class: "mt-2 mt-sm-4",
                type: "info",
                title: __props.announcement.title
              }, null, 8, ["title"])
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
};
const _sfc_setup$1 = _sfc_main$1.setup;
_sfc_main$1.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/Announcement.vue");
  return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  __ssrInlineRender: true,
  async setup(__props) {
    let __temp, __restore;
    const time = useTime();
    const settings = useState("settings");
    useHead({
      title: settings.value?.title,
      meta: [
        { name: "description", content: settings?.value.description },
        { name: "og:description", content: settings?.value.description },
        { property: "og:title", content: settings.value.title },
        { property: "og:url", content: settings.value.baseurl },
        { property: "og:image", content: settings.value.baseurl + "/logo.png" }
      ],
      link: [
        { rel: "apple-touch-icon", href: settings.value.baseurl + "/logo.png" },
        { rel: "alternate", type: "application/rss+xml", title: settings.value.title, href: settings.value.baseurl + "/feed/rss" },
        { rel: "alternate", type: "text/calendar", title: settings.value.title, href: settings.value.baseurl + "/feed/ics" },
        { rel: "search", type: "application/opensearchdescription+xml", title: settings.value.title, href: settings.value.baseurl + "/opensearch.xml" },
        { rel: "me", href: `${settings.value.baseurl}/federation/u/${settings.value.instance_name}` }
      ]
    });
    const now = time.nowUnix();
    const selectedDate = useState("selectedDate", () => void 0);
    const { events, params } = useEvents();
    const isCurrentMonth = computed(() => params.value.start === time.startMonth());
    const visibleEvents = computed(() => {
      if (params.value.query) {
        return events.value;
      }
      if (selectedDate.value) {
        const min = DateTime.fromJSDate(selectedDate?.value)?.startOf("day")?.toUnixInteger();
        const max = DateTime.fromJSDate(selectedDate?.value)?.endOf("day")?.toUnixInteger();
        return events.value?.filter((e) => e.start_datetime <= max && (e.end_datetime || e.start_datetime) >= min);
      } else if (isCurrentMonth.value) {
        return events.value?.filter((e) => {
          const max_datetime = Math.max(e.start_datetime, e?.end_datetime ?? 0);
          return e.end_datetime ? max_datetime >= now : e.start_datetime + 3 * 60 * 60 >= now;
        });
      } else {
        return events.value;
      }
    });
    const { data: announcements } = ([__temp, __restore] = withAsyncContext(() => useFetch(
      "/api/announcements",
      "$xIynyJyXPB"
      /* nuxt-injected */
    )), __temp = await __temp, __restore(), __temp);
    return (_ctx, _push, _parent, _attrs) => {
      const _component_Announcement = _sfc_main$1;
      const _component_EventCard = __nuxt_component_1;
      _push(ssrRenderComponent(VContainer, mergeProps({
        id: "home",
        class: "px-2 px-sm-6 pt-0"
      }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            if (unref(announcements)?.length) {
              _push2(`<section id="announcements" class="mt-2 mt-sm-4"${_scopeId}><!--[-->`);
              ssrRenderList(unref(announcements), (announcement) => {
                _push2(ssrRenderComponent(_component_Announcement, {
                  key: announcement.id,
                  announcement
                }, null, _parent2, _scopeId));
              });
              _push2(`<!--]--></section>`);
            } else {
              _push2(`<!---->`);
            }
            _push2(`<section class="events mt-sm-4 mt-2"${_scopeId}><!--[-->`);
            ssrRenderList(unref(visibleEvents), (event, idx) => {
              _push2(ssrRenderComponent(VLazy, {
                key: event.id,
                class: "event",
                "model-value": idx < 9,
                options: { threshold: 0.5, rootMargin: "500px" }
              }, {
                default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(ssrRenderComponent(_component_EventCard, {
                      event,
                      lazy: idx > 9,
                      "hide-thumbs": unref(settings).hide_thumbs
                    }, null, _parent3, _scopeId2));
                  } else {
                    return [
                      createVNode(_component_EventCard, {
                        event,
                        lazy: idx > 9,
                        "hide-thumbs": unref(settings).hide_thumbs
                      }, null, 8, ["event", "lazy", "hide-thumbs"])
                    ];
                  }
                }),
                _: 2
              }, _parent2, _scopeId));
            });
            _push2(`<!--]-->`);
            if (!unref(visibleEvents)?.length) {
              _push2(`<div class="d-flex flex-column align-center ga-2 my-8 my-sm-12"${_scopeId}><span class="text-h4 text-medium-emphasis"${_scopeId}>${ssrInterpolate(_ctx.$t("common.no_events_found"))}</span><span${_scopeId}>${ssrInterpolate(_ctx.$t("common.no_events_found_hint"))}</span>`);
              _push2(ssrRenderComponent(VIcon, {
                icon: "mdi-cactus",
                size: 200,
                class: "opacity-20 mt-2"
              }, null, _parent2, _scopeId));
              _push2(`</div>`);
            } else {
              _push2(`<!---->`);
            }
            _push2(`</section>`);
          } else {
            return [
              unref(announcements)?.length ? (openBlock(), createBlock("section", {
                key: 0,
                id: "announcements",
                class: "mt-2 mt-sm-4"
              }, [
                (openBlock(true), createBlock(Fragment, null, renderList(unref(announcements), (announcement) => {
                  return openBlock(), createBlock(_component_Announcement, {
                    key: announcement.id,
                    announcement
                  }, null, 8, ["announcement"]);
                }), 128))
              ])) : createCommentVNode("", true),
              createVNode("section", { class: "events mt-sm-4 mt-2" }, [
                (openBlock(true), createBlock(Fragment, null, renderList(unref(visibleEvents), (event, idx) => {
                  return openBlock(), createBlock(VLazy, {
                    key: event.id,
                    class: "event",
                    "model-value": idx < 9,
                    options: { threshold: 0.5, rootMargin: "500px" }
                  }, {
                    default: withCtx(() => [
                      createVNode(_component_EventCard, {
                        event,
                        lazy: idx > 9,
                        "hide-thumbs": unref(settings).hide_thumbs
                      }, null, 8, ["event", "lazy", "hide-thumbs"])
                    ]),
                    _: 2
                  }, 1032, ["model-value"]);
                }), 128)),
                !unref(visibleEvents)?.length ? (openBlock(), createBlock("div", {
                  key: 0,
                  class: "d-flex flex-column align-center ga-2 my-8 my-sm-12"
                }, [
                  createVNode("span", { class: "text-h4 text-medium-emphasis" }, toDisplayString(_ctx.$t("common.no_events_found")), 1),
                  createVNode("span", null, toDisplayString(_ctx.$t("common.no_events_found_hint")), 1),
                  createVNode(VIcon, {
                    icon: "mdi-cactus",
                    size: 200,
                    class: "opacity-20 mt-2"
                  })
                ])) : createCommentVNode("", true)
              ])
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/index.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
