import { _ as __nuxt_component_2 } from './nuxt-link-DENluCKo.mjs';
import { _ as _sfc_main$1 } from './Img-C7RhygJ-.mjs';
import { withDirectives, createVNode, normalizeStyle, normalizeClass, defineComponent, computed, mergeProps, withCtx, unref, openBlock, createBlock, createCommentVNode, toDisplayString, createTextVNode, Fragment, renderList, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrRenderClass, ssrInterpolate, ssrRenderAttr, ssrRenderList } from 'vue/server-renderer';
import { u as useTime } from './useTime-ByXQWA_w.mjs';
import { a3 as genericComponent, b1 as useDimension, bg as useProxiedModel, bh as useRender, aS as propsFactory, aE as makeTagProps, at as makeDimensionProps, ar as makeComponentProps, l as VIcon } from './server.mjs';
import { I as Intersect, M as MaybeTransition, m as makeTransitionProps, V as VAvatar, a as VImg } from './VAvatar-DZc9zgUD.mjs';
import { V as VCardText } from './VCardText-KkYigSmQ.mjs';
import { V as VChip } from './VChip-BLze6MCM.mjs';

const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "Card",
  __ssrInlineRender: true,
  props: {
    event: {},
    lazy: { type: Boolean, default: false },
    hideThumbs: { type: Boolean, default: false }
  },
  setup(__props) {
    const time = useTime();
    const isPast = computed(() => {
      const now = /* @__PURE__ */ new Date();
      if (__props.event.end_datetime) {
        return new Date(__props.event.end_datetime * 1e3) < now;
      } else {
        return new Date((3 * 60 * 60 + __props.event.start_datetime) * 1e3) < now;
      }
    });
    const isCancelled = computed(() => __props.event.status === "EventCancelled");
    return (_ctx, _push, _parent, _attrs) => {
      const _component_nuxt_link = __nuxt_component_2;
      const _component_CoreImg = _sfc_main$1;
      _push(`<article${ssrRenderAttrs(mergeProps({
        class: "h-event event-card",
        itemscope: "",
        itemtype: "https://schema.org/Event"
      }, _attrs))}>`);
      _push(ssrRenderComponent(_component_nuxt_link, {
        to: `/event/${__props.event.slug || __props.event.id}`,
        itemprop: "url"
      }, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            if (!__props.hideThumbs) {
              _push2(ssrRenderComponent(_component_CoreImg, {
                event: __props.event,
                thumb: "",
                lazy: __props.lazy
              }, null, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
            if (__props.event.parentId) {
              _push2(ssrRenderComponent(VIcon, {
                class: "float-right mr-1",
                color: "success",
                icon: "mdi-repeat"
              }, null, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
            if (unref(isPast)) {
              _push2(ssrRenderComponent(VIcon, {
                class: "float-right mr-1",
                color: "warning",
                icon: "mdi-timer-sand"
              }, null, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
            _push2(`<h3 itemprop="name" class="${ssrRenderClass([unref(isCancelled) && "text-decoration-line-through", "event-title"])}"${_scopeId}>${ssrInterpolate(__props.event.title)}</h3>`);
          } else {
            return [
              !__props.hideThumbs ? (openBlock(), createBlock(_component_CoreImg, {
                key: 0,
                event: __props.event,
                thumb: "",
                lazy: __props.lazy
              }, null, 8, ["event", "lazy"])) : createCommentVNode("", true),
              __props.event.parentId ? (openBlock(), createBlock(VIcon, {
                key: 1,
                class: "float-right mr-1",
                color: "success",
                icon: "mdi-repeat"
              })) : createCommentVNode("", true),
              unref(isPast) ? (openBlock(), createBlock(VIcon, {
                key: 2,
                class: "float-right mr-1",
                color: "warning",
                icon: "mdi-timer-sand"
              })) : createCommentVNode("", true),
              createVNode("h3", {
                class: ["event-title", unref(isCancelled) && "text-decoration-line-through"],
                itemprop: "name"
              }, toDisplayString(__props.event.title), 3)
            ];
          }
        }),
        _: 1
      }, _parent));
      if (__props.event?.ap_user?.image) {
        _push(ssrRenderComponent(VAvatar, {
          size: "small",
          class: "position-absolute top-0 right-0 ma-2 pointer-ev-none"
        }, {
          default: withCtx((_, _push2, _parent2, _scopeId) => {
            if (_push2) {
              _push2(ssrRenderComponent(VImg, {
                src: __props.event.ap_user.image,
                alt: __props.event.ap_user.name
              }, null, _parent2, _scopeId));
            } else {
              return [
                createVNode(VImg, {
                  src: __props.event.ap_user.image,
                  alt: __props.event.ap_user.name
                }, null, 8, ["src", "alt"])
              ];
            }
          }),
          _: 1
        }, _parent));
      } else {
        _push(`<!---->`);
      }
      _push(ssrRenderComponent(VCardText, { class: "pt-0 pb-3" }, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<div class="d-flex ga-2 align-center mb-1"${_scopeId}>`);
            _push2(ssrRenderComponent(VIcon, { icon: "mdi-calendar" }, null, _parent2, _scopeId));
            _push2(`<time class="dt-start text-body-2 text-md-body-1"${ssrRenderAttr("datetime", unref(time).unixFormat(__props.event.start_datetime, "yyyy-MM-dd HH:mm"))} itemprop="startDate"${ssrRenderAttr("content", unref(time).unixFormat(__props.event.start_datetime, "yyyy-MM-dd'T'HH:mm"))}${_scopeId}>${ssrInterpolate(unref(time).when(__props.event))}</time>`);
            if (__props.event.end_datetime) {
              _push2(`<time class="d-none dt-end" itemprop="endDate"${ssrRenderAttr("content", unref(time).unixFormat(__props.event.end_datetime, "yyyy-MM-dd'T'HH:mm"))}${_scopeId}>${ssrInterpolate(unref(time).unixFormat(__props.event.end_datetime))}</time>`);
            } else {
              _push2(`<!---->`);
            }
            _push2(`</div><div class="d-flex ga-2 align-center"${_scopeId}>`);
            _push2(ssrRenderComponent(VIcon, { icon: "mdi-map-marker" }, null, _parent2, _scopeId));
            _push2(ssrRenderComponent(_component_nuxt_link, {
              class: "place p-location text-body-2 text-md-body-1",
              to: `/place/${__props.event?.place?.id}/${encodeURIComponent(__props.event.place.name)}`,
              itemprop: "location",
              itemscope: "",
              itemtype: "https://schema.org/Place"
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(`<span itemprop="name"${_scopeId2}>${ssrInterpolate(__props.event.place.name)}</span>`);
                } else {
                  return [
                    createVNode("span", { itemprop: "name" }, toDisplayString(__props.event.place.name), 1)
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            _push2(`<div class="d-none" itemprop="address"${_scopeId}>${ssrInterpolate(__props.event.place.address)}</div></div>`);
            if (__props.event?.tags?.length) {
              _push2(`<div class="d-flex flex-wrap ga-1 mt-3"${_scopeId}><!--[-->`);
              ssrRenderList(__props.event?.tags?.slice(0, 6), (tag) => {
                _push2(ssrRenderComponent(VChip, {
                  key: tag,
                  size: "small",
                  label: "",
                  to: `/tag/${encodeURIComponent(tag)}`,
                  variant: "outlined",
                  color: "primary"
                }, {
                  default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                    if (_push3) {
                      _push3(`${ssrInterpolate(tag)}`);
                    } else {
                      return [
                        createTextVNode(toDisplayString(tag), 1)
                      ];
                    }
                  }),
                  _: 2
                }, _parent2, _scopeId));
              });
              _push2(`<!--]--></div>`);
            } else {
              _push2(`<!---->`);
            }
          } else {
            return [
              createVNode("div", { class: "d-flex ga-2 align-center mb-1" }, [
                createVNode(VIcon, { icon: "mdi-calendar" }),
                createVNode("time", {
                  class: "dt-start text-body-2 text-md-body-1",
                  datetime: unref(time).unixFormat(__props.event.start_datetime, "yyyy-MM-dd HH:mm"),
                  itemprop: "startDate",
                  content: unref(time).unixFormat(__props.event.start_datetime, "yyyy-MM-dd'T'HH:mm")
                }, toDisplayString(unref(time).when(__props.event)), 9, ["datetime", "content"]),
                __props.event.end_datetime ? (openBlock(), createBlock("time", {
                  key: 0,
                  class: "d-none dt-end",
                  itemprop: "endDate",
                  content: unref(time).unixFormat(__props.event.end_datetime, "yyyy-MM-dd'T'HH:mm")
                }, toDisplayString(unref(time).unixFormat(__props.event.end_datetime)), 9, ["content"])) : createCommentVNode("", true)
              ]),
              createVNode("div", { class: "d-flex ga-2 align-center" }, [
                createVNode(VIcon, { icon: "mdi-map-marker" }),
                createVNode(_component_nuxt_link, {
                  class: "place p-location text-body-2 text-md-body-1",
                  to: `/place/${__props.event?.place?.id}/${encodeURIComponent(__props.event.place.name)}`,
                  itemprop: "location",
                  itemscope: "",
                  itemtype: "https://schema.org/Place"
                }, {
                  default: withCtx(() => [
                    createVNode("span", { itemprop: "name" }, toDisplayString(__props.event.place.name), 1)
                  ]),
                  _: 1
                }, 8, ["to"]),
                createVNode("div", {
                  class: "d-none",
                  itemprop: "address"
                }, toDisplayString(__props.event.place.address), 1)
              ]),
              __props.event?.tags?.length ? (openBlock(), createBlock("div", {
                key: 0,
                class: "d-flex flex-wrap ga-1 mt-3"
              }, [
                (openBlock(true), createBlock(Fragment, null, renderList(__props.event?.tags?.slice(0, 6), (tag) => {
                  return openBlock(), createBlock(VChip, {
                    key: tag,
                    size: "small",
                    label: "",
                    to: `/tag/${encodeURIComponent(tag)}`,
                    variant: "outlined",
                    color: "primary"
                  }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(tag), 1)
                    ]),
                    _: 2
                  }, 1032, ["to"]);
                }), 128))
              ])) : createCommentVNode("", true)
            ];
          }
        }),
        _: 1
      }, _parent));
      _push(`</article>`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/Event/Card.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const __nuxt_component_1 = Object.assign(_sfc_main, { __name: "EventCard" });
const makeVLazyProps = propsFactory({
  modelValue: Boolean,
  options: {
    type: Object,
    // For more information on types, navigate to:
    // https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
    default: () => ({
      root: void 0,
      rootMargin: void 0,
      threshold: void 0
    })
  },
  ...makeComponentProps(),
  ...makeDimensionProps(),
  ...makeTagProps(),
  ...makeTransitionProps({
    transition: "fade-transition"
  })
}, "VLazy");
const VLazy = genericComponent()({
  name: "VLazy",
  directives: {
    vIntersect: Intersect
  },
  props: makeVLazyProps(),
  emits: {
    "update:modelValue": (value) => true
  },
  setup(props, _ref) {
    let {
      slots
    } = _ref;
    const {
      dimensionStyles
    } = useDimension(props);
    const isActive = useProxiedModel(props, "modelValue");
    function onIntersect(isIntersecting) {
      if (isActive.value) return;
      isActive.value = isIntersecting;
    }
    useRender(() => withDirectives(createVNode(props.tag, {
      "class": normalizeClass(["v-lazy", props.class]),
      "style": normalizeStyle([dimensionStyles.value, props.style])
    }, {
      default: () => [isActive.value && createVNode(MaybeTransition, {
        "transition": props.transition,
        "appear": true
      }, {
        default: () => [slots.default?.()]
      })]
    }), [[Intersect, {
      handler: onIntersect,
      options: props.options
    }, null]]));
    return {};
  }
});

export { VLazy as V, __nuxt_component_1 as _ };
