import { ref, mergeProps, withCtx, createVNode, unref, isRef, createTextVNode, toDisplayString, openBlock, createBlock, Fragment, renderList, createCommentVNode, shallowRef, computed, normalizeStyle, normalizeClass, createElementVNode, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate, ssrRenderList } from 'vue/server-renderer';
import { u as useTime } from './useTime-ByXQWA_w.mjs';
import { u as useAuth } from './useAuth-CRQCJpA8.mjs';
import { be as useNuxtApp, b4 as useFetch, V as VBtn, a3 as genericComponent, aZ as useBackgroundColor, a_ as useBorder, b3 as useElevation, bd as useLocation, bk as useRounded, aU as provideTheme, bo as useRtl, aT as provideDefaults, bh as useRender, k as VDefaultsProvider, x as convertToUnit, aS as propsFactory, aF as makeThemeProps, aE as makeTagProps, aB as makeRoundedProps, az as makeLocationProps, av as makeElevationProps, ar as makeComponentProps, aq as makeBorderProps } from './server.mjs';
import { V as VCard } from './VCard-D86CughW.mjs';
import { V as VExpandTransition } from './index-0tjXFI7F.mjs';
import { a as VImg } from './VAvatar-DZc9zgUD.mjs';
import { V as VCardText } from './VCardText-KkYigSmQ.mjs';
import { V as VTextarea } from './VTextarea-D5gjRx3P.mjs';
import { a as VList, b as VListItem, c as VListItemSubtitle } from './VOverlay-Dlj-QQp0.mjs';
import 'luxon';
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 '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 './VCardActions-B8o0qNQf.mjs';
import './createSimpleFunctional-D4PbVxKo.mjs';
import './autofocus-BUnCw2TG.mjs';
import './form-Q_oG-_Ip.mjs';
import './animation-DMtpo1PO.mjs';
import './forwardRefs-C3iWxc5z.mjs';
import './VDivider-akc4E5rx.mjs';

const makeVToolbarTitleProps = propsFactory({
  text: String,
  ...makeComponentProps(),
  ...makeTagProps()
}, "VToolbarTitle");
const VToolbarTitle = genericComponent()({
  name: "VToolbarTitle",
  props: makeVToolbarTitleProps(),
  setup(props, _ref) {
    let {
      slots
    } = _ref;
    useRender(() => {
      const hasText = !!(slots.default || slots.text || props.text);
      return createVNode(props.tag, {
        "class": normalizeClass(["v-toolbar-title", props.class]),
        "style": normalizeStyle(props.style)
      }, {
        default: () => [hasText && createElementVNode("div", {
          "class": "v-toolbar-title__placeholder"
        }, [slots.text ? slots.text() : props.text, slots.default?.()])]
      });
    });
    return {};
  }
});
const allowedDensities = [null, "prominent", "default", "comfortable", "compact"];
const makeVToolbarProps = propsFactory({
  absolute: Boolean,
  collapse: Boolean,
  collapsePosition: {
    type: String,
    default: "start"
  },
  color: String,
  density: {
    type: String,
    default: "default",
    validator: (v) => allowedDensities.includes(v)
  },
  extended: {
    type: Boolean,
    default: null
  },
  extensionHeight: {
    type: [Number, String],
    default: 48
  },
  flat: Boolean,
  floating: Boolean,
  height: {
    type: [Number, String],
    default: 64
  },
  image: String,
  title: String,
  ...makeBorderProps(),
  ...makeComponentProps(),
  ...makeElevationProps(),
  ...makeLocationProps(),
  ...makeRoundedProps(),
  ...makeTagProps({
    tag: "header"
  }),
  ...makeThemeProps()
}, "VToolbar");
const VToolbar = genericComponent()({
  name: "VToolbar",
  props: makeVToolbarProps(),
  setup(props, _ref) {
    let {
      slots
    } = _ref;
    const {
      backgroundColorClasses,
      backgroundColorStyles
    } = useBackgroundColor(() => props.color);
    const {
      borderClasses
    } = useBorder(props);
    const {
      elevationClasses
    } = useElevation(props);
    const {
      locationStyles
    } = useLocation(props);
    const {
      roundedClasses
    } = useRounded(props);
    const {
      themeClasses
    } = provideTheme(props);
    const {
      rtlClasses
    } = useRtl();
    const isExtended = shallowRef(props.extended === null ? !!slots.extension?.() : props.extended);
    const contentHeight = computed(() => parseInt(Number(props.height) + (props.density === "prominent" ? Number(props.height) : 0) - (props.density === "comfortable" ? 8 : 0) - (props.density === "compact" ? 16 : 0), 10));
    const extensionHeight = computed(() => isExtended.value ? parseInt(Number(props.extensionHeight) + (props.density === "prominent" ? Number(props.extensionHeight) : 0) - (props.density === "comfortable" ? 4 : 0) - (props.density === "compact" ? 8 : 0), 10) : 0);
    provideDefaults({
      VBtn: {
        variant: "text"
      }
    });
    useRender(() => {
      const hasTitle = !!(props.title || slots.title);
      const hasImage = !!(slots.image || props.image);
      const extension = slots.extension?.();
      isExtended.value = props.extended === null ? !!extension : props.extended;
      return createVNode(props.tag, {
        "class": normalizeClass(["v-toolbar", `v-toolbar--collapse-${props.collapsePosition}`, {
          "v-toolbar--absolute": props.absolute,
          "v-toolbar--collapse": props.collapse,
          "v-toolbar--flat": props.flat,
          "v-toolbar--floating": props.floating,
          [`v-toolbar--density-${props.density}`]: true
        }, backgroundColorClasses.value, borderClasses.value, elevationClasses.value, roundedClasses.value, themeClasses.value, rtlClasses.value, props.class]),
        "style": normalizeStyle([backgroundColorStyles.value, locationStyles.value, props.style])
      }, {
        default: () => [hasImage && createElementVNode("div", {
          "key": "image",
          "class": "v-toolbar__image"
        }, [!slots.image ? createVNode(VImg, {
          "key": "image-img",
          "cover": true,
          "src": props.image
        }, null) : createVNode(VDefaultsProvider, {
          "key": "image-defaults",
          "disabled": !props.image,
          "defaults": {
            VImg: {
              cover: true,
              src: props.image
            }
          }
        }, slots.image)]), createVNode(VDefaultsProvider, {
          "defaults": {
            VTabs: {
              height: convertToUnit(contentHeight.value)
            }
          }
        }, {
          default: () => [createElementVNode("div", {
            "class": "v-toolbar__content",
            "style": {
              height: convertToUnit(contentHeight.value)
            }
          }, [slots.prepend && createElementVNode("div", {
            "class": "v-toolbar__prepend"
          }, [slots.prepend?.()]), hasTitle && createVNode(VToolbarTitle, {
            "key": "title",
            "text": props.title
          }, {
            text: slots.title
          }), slots.default?.(), slots.append && createElementVNode("div", {
            "class": "v-toolbar__append"
          }, [slots.append?.()])])]
        }), createVNode(VDefaultsProvider, {
          "defaults": {
            VTabs: {
              height: convertToUnit(extensionHeight.value)
            }
          }
        }, {
          default: () => [createVNode(VExpandTransition, null, {
            default: () => [isExtended.value && createElementVNode("div", {
              "class": "v-toolbar__extension",
              "style": {
                height: convertToUnit(extensionHeight.value)
              }
            }, [extension])]
          })]
        })]
      });
    });
    return {
      contentHeight,
      extensionHeight
    };
  }
});
const _sfc_main = {
  __name: "EventModeration",
  __ssrInlineRender: true,
  props: { event: { type: Object, default: () => ({}) } },
  emits: ["close"],
  setup(__props) {
    const time = useTime();
    const props = __props;
    const { isAdmin } = useAuth();
    const { $notify } = useNuxtApp();
    const message = ref("");
    const loading = ref(false);
    const { data: messages, refresh } = useFetch(
      () => `/api/events/messages/${props.event.id}`,
      "$KJgu--mXrn"
      /* nuxt-injected */
    );
    async function sendMessage(is_author_visible) {
      if (loading.value) return;
      try {
        loading.value = true;
        await $fetch(`/api/events/messages/${props.event.id}`, {
          method: "POST",
          body: { is_author_visible, message: message.value }
        });
        message.value = "";
        loading.value = false;
        refresh();
      } catch (e) {
        console.error(e);
        $notify(e);
        loading.value = false;
      }
    }
    return (_ctx, _push, _parent, _attrs) => {
      _push(ssrRenderComponent(VCard, mergeProps({ class: "eventModeration" }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VToolbar, {
              title: _ctx.$t("common.moderation")
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VBtn, {
                    icon: "mdi-chevron-right",
                    onClick: ($event) => _ctx.$emit("close", false)
                  }, null, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VBtn, {
                      icon: "mdi-chevron-right",
                      onClick: ($event) => _ctx.$emit("close", false)
                    }, null, 8, ["onClick"])
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            _push2(ssrRenderComponent(VCardText, { class: "d-flex flex-column flex-grow-1 overflow-auto" }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(`<span${_scopeId2}>${ssrInterpolate(_ctx.$t(unref(isAdmin) ? "event.message_hint" : "event.message_author_hint"))}</span>`);
                  _push3(ssrRenderComponent(VTextarea, {
                    modelValue: unref(message),
                    "onUpdate:modelValue": ($event) => isRef(message) ? message.value = $event : null,
                    label: _ctx.$t("event.message"),
                    rows: "2",
                    class: "mb-2"
                  }, null, _parent3, _scopeId2));
                  if (unref(isAdmin)) {
                    _push3(`<!--[-->`);
                    _push3(ssrRenderComponent(VBtn, {
                      class: "mb-1",
                      variant: "outlined",
                      disabled: !unref(message) || unref(loading),
                      loading: unref(loading),
                      color: "primary",
                      onClick: ($event) => sendMessage(false)
                    }, {
                      default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(`${ssrInterpolate(_ctx.$t("event.send_to_admins"))}`);
                        } else {
                          return [
                            createTextVNode(toDisplayString(_ctx.$t("event.send_to_admins")), 1)
                          ];
                        }
                      }),
                      _: 1
                    }, _parent3, _scopeId2));
                    if (!__props.event.isAnon) {
                      _push3(ssrRenderComponent(VBtn, {
                        class: "mb-1",
                        variant: "outlined",
                        disabled: !unref(message) || unref(loading),
                        loading: unref(loading),
                        color: "primary",
                        onClick: ($event) => sendMessage(true)
                      }, {
                        default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                          if (_push4) {
                            _push4(`${ssrInterpolate(_ctx.$t("event.send_to_author_too"))}`);
                          } else {
                            return [
                              createTextVNode(toDisplayString(_ctx.$t("event.send_to_author_too")), 1)
                            ];
                          }
                        }),
                        _: 1
                      }, _parent3, _scopeId2));
                    } else {
                      _push3(`<!---->`);
                    }
                    _push3(`<!--]-->`);
                  } else {
                    _push3(ssrRenderComponent(VBtn, {
                      size: "small",
                      variant: "outlined",
                      disabled: !unref(message) || unref(loading),
                      loading: unref(loading),
                      color: "primary",
                      onClick: ($event) => sendMessage(true)
                    }, {
                      default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(`send`);
                        } else {
                          return [
                            createTextVNode("send")
                          ];
                        }
                      }),
                      _: 1
                    }, _parent3, _scopeId2));
                  }
                  _push3(`<br${_scopeId2}>`);
                  _push3(ssrRenderComponent(VList, {
                    density: "compact",
                    class: "messageList"
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`<!--[-->`);
                        ssrRenderList(unref(messages), (item, index) => {
                          _push4(ssrRenderComponent(VListItem, {
                            key: index,
                            class: ["px-2", item.author],
                            title: item?.message
                          }, {
                            default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                              if (_push5) {
                                _push5(ssrRenderComponent(VListItemSubtitle, { class: "font-weight-light" }, {
                                  default: withCtx((_5, _push6, _parent6, _scopeId5) => {
                                    if (_push6) {
                                      _push6(`${ssrInterpolate(unref(time).format(item.createdAt))} / ${ssrInterpolate(item.author)}`);
                                    } else {
                                      return [
                                        createTextVNode(toDisplayString(unref(time).format(item.createdAt)) + " / " + toDisplayString(item.author), 1)
                                      ];
                                    }
                                  }),
                                  _: 2
                                }, _parent5, _scopeId4));
                              } else {
                                return [
                                  createVNode(VListItemSubtitle, { class: "font-weight-light" }, {
                                    default: withCtx(() => [
                                      createTextVNode(toDisplayString(unref(time).format(item.createdAt)) + " / " + toDisplayString(item.author), 1)
                                    ]),
                                    _: 2
                                  }, 1024)
                                ];
                              }
                            }),
                            _: 2
                          }, _parent4, _scopeId3));
                        });
                        _push4(`<!--]-->`);
                      } else {
                        return [
                          (openBlock(true), createBlock(Fragment, null, renderList(unref(messages), (item, index) => {
                            return openBlock(), createBlock(VListItem, {
                              key: index,
                              class: ["px-2", item.author],
                              title: item?.message
                            }, {
                              default: withCtx(() => [
                                createVNode(VListItemSubtitle, { class: "font-weight-light" }, {
                                  default: withCtx(() => [
                                    createTextVNode(toDisplayString(unref(time).format(item.createdAt)) + " / " + toDisplayString(item.author), 1)
                                  ]),
                                  _: 2
                                }, 1024)
                              ]),
                              _: 2
                            }, 1032, ["class", "title"]);
                          }), 128))
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode("span", null, toDisplayString(_ctx.$t(unref(isAdmin) ? "event.message_hint" : "event.message_author_hint")), 1),
                    createVNode(VTextarea, {
                      modelValue: unref(message),
                      "onUpdate:modelValue": ($event) => isRef(message) ? message.value = $event : null,
                      label: _ctx.$t("event.message"),
                      rows: "2",
                      class: "mb-2"
                    }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
                    unref(isAdmin) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                      createVNode(VBtn, {
                        class: "mb-1",
                        variant: "outlined",
                        disabled: !unref(message) || unref(loading),
                        loading: unref(loading),
                        color: "primary",
                        onClick: ($event) => sendMessage(false)
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("event.send_to_admins")), 1)
                        ]),
                        _: 1
                      }, 8, ["disabled", "loading", "onClick"]),
                      !__props.event.isAnon ? (openBlock(), createBlock(VBtn, {
                        key: 0,
                        class: "mb-1",
                        variant: "outlined",
                        disabled: !unref(message) || unref(loading),
                        loading: unref(loading),
                        color: "primary",
                        onClick: ($event) => sendMessage(true)
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("event.send_to_author_too")), 1)
                        ]),
                        _: 1
                      }, 8, ["disabled", "loading", "onClick"])) : createCommentVNode("", true)
                    ], 64)) : (openBlock(), createBlock(VBtn, {
                      key: 1,
                      size: "small",
                      variant: "outlined",
                      disabled: !unref(message) || unref(loading),
                      loading: unref(loading),
                      color: "primary",
                      onClick: ($event) => sendMessage(true)
                    }, {
                      default: withCtx(() => [
                        createTextVNode("send")
                      ]),
                      _: 1
                    }, 8, ["disabled", "loading", "onClick"])),
                    createVNode("br"),
                    createVNode(VList, {
                      density: "compact",
                      class: "messageList"
                    }, {
                      default: withCtx(() => [
                        (openBlock(true), createBlock(Fragment, null, renderList(unref(messages), (item, index) => {
                          return openBlock(), createBlock(VListItem, {
                            key: index,
                            class: ["px-2", item.author],
                            title: item?.message
                          }, {
                            default: withCtx(() => [
                              createVNode(VListItemSubtitle, { class: "font-weight-light" }, {
                                default: withCtx(() => [
                                  createTextVNode(toDisplayString(unref(time).format(item.createdAt)) + " / " + toDisplayString(item.author), 1)
                                ]),
                                _: 2
                              }, 1024)
                            ]),
                            _: 2
                          }, 1032, ["class", "title"]);
                        }), 128))
                      ]),
                      _: 1
                    })
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(VToolbar, {
                title: _ctx.$t("common.moderation")
              }, {
                default: withCtx(() => [
                  createVNode(VBtn, {
                    icon: "mdi-chevron-right",
                    onClick: ($event) => _ctx.$emit("close", false)
                  }, null, 8, ["onClick"])
                ]),
                _: 1
              }, 8, ["title"]),
              createVNode(VCardText, { class: "d-flex flex-column flex-grow-1 overflow-auto" }, {
                default: withCtx(() => [
                  createVNode("span", null, toDisplayString(_ctx.$t(unref(isAdmin) ? "event.message_hint" : "event.message_author_hint")), 1),
                  createVNode(VTextarea, {
                    modelValue: unref(message),
                    "onUpdate:modelValue": ($event) => isRef(message) ? message.value = $event : null,
                    label: _ctx.$t("event.message"),
                    rows: "2",
                    class: "mb-2"
                  }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
                  unref(isAdmin) ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                    createVNode(VBtn, {
                      class: "mb-1",
                      variant: "outlined",
                      disabled: !unref(message) || unref(loading),
                      loading: unref(loading),
                      color: "primary",
                      onClick: ($event) => sendMessage(false)
                    }, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(_ctx.$t("event.send_to_admins")), 1)
                      ]),
                      _: 1
                    }, 8, ["disabled", "loading", "onClick"]),
                    !__props.event.isAnon ? (openBlock(), createBlock(VBtn, {
                      key: 0,
                      class: "mb-1",
                      variant: "outlined",
                      disabled: !unref(message) || unref(loading),
                      loading: unref(loading),
                      color: "primary",
                      onClick: ($event) => sendMessage(true)
                    }, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(_ctx.$t("event.send_to_author_too")), 1)
                      ]),
                      _: 1
                    }, 8, ["disabled", "loading", "onClick"])) : createCommentVNode("", true)
                  ], 64)) : (openBlock(), createBlock(VBtn, {
                    key: 1,
                    size: "small",
                    variant: "outlined",
                    disabled: !unref(message) || unref(loading),
                    loading: unref(loading),
                    color: "primary",
                    onClick: ($event) => sendMessage(true)
                  }, {
                    default: withCtx(() => [
                      createTextVNode("send")
                    ]),
                    _: 1
                  }, 8, ["disabled", "loading", "onClick"])),
                  createVNode("br"),
                  createVNode(VList, {
                    density: "compact",
                    class: "messageList"
                  }, {
                    default: withCtx(() => [
                      (openBlock(true), createBlock(Fragment, null, renderList(unref(messages), (item, index) => {
                        return openBlock(), createBlock(VListItem, {
                          key: index,
                          class: ["px-2", item.author],
                          title: item?.message
                        }, {
                          default: withCtx(() => [
                            createVNode(VListItemSubtitle, { class: "font-weight-light" }, {
                              default: withCtx(() => [
                                createTextVNode(toDisplayString(unref(time).format(item.createdAt)) + " / " + toDisplayString(item.author), 1)
                              ]),
                              _: 2
                            }, 1024)
                          ]),
                          _: 2
                        }, 1032, ["class", "title"]);
                      }), 128))
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ];
          }
        }),
        _: 1
      }, _parent));
    };
  }
};
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/Event/Moderation.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
