import { _ as __nuxt_component_0 } from './TBtn-CxSZmXIk.mjs';
import { defineComponent, withAsyncContext, ref, withCtx, createTextVNode, toDisplayString, isRef, unref, openBlock, createBlock, Fragment, createVNode, createCommentVNode, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate } from 'vue/server-renderer';
import { y as useI18n, v as useFetch, z as useNuxtApp, r as VContainer } from './server.mjs';
import { u as useTime } from './useTime-xYTJHVg1.mjs';
import { V as VCard, a as VCardTitle } from './VCard-CJXaLaw7.mjs';
import { V as VCardText } from './VCardText-D-diyBaj.mjs';
import { V as VTextField } from './VTextField-Cxy8Koxy.mjs';
import { V as VDataTable } from './VDataTable-3TTn1DPD.mjs';
import './VOverlay-DatVsI3B.mjs';
import './animation-Ilk0LvxU.mjs';
import './index-1z1zC4K2.mjs';
import './VAvatar-oghuaLjs.mjs';
import './createSimpleFunctional-eaVhl3I5.mjs';
import './VDivider-D3it--C7.mjs';
import './forwardRefs-C3iWxc5z.mjs';
import '../nitro/nitro.mjs';
import 'luxon';
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-BYFaScU5.mjs';
import './autofocus-DtAziIxK.mjs';
import './form-B9qqVmvI.mjs';
import './VSelect-BX3KCscZ.mjs';
import './VMenu-eOMhQZM2.mjs';
import './VSelectionControl-zP2tQQmL.mjs';
import './VChip-BM5W0ePt.mjs';

const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "my_events",
  __ssrInlineRender: true,
  async setup(__props) {
    let __temp, __restore;
    const { t } = useI18n();
    const { data: events, refresh } = ([__temp, __restore] = withAsyncContext(() => useFetch(
      "/api/events/mine",
      "$AlXDDttVAD"
      /* nuxt-injected */
    )), __temp = await __temp, __restore(), __temp);
    const { $confirm, $notify } = useNuxtApp();
    const time = useTime();
    const search = ref("");
    const headers = [
      { value: "title", title: t("common.title") },
      { value: "place.name", title: t("common.place") },
      { value: "start_datetime", title: t("common.when") },
      { value: "actions", title: t("common.actions"), align: "end", sortable: false, width: 250 }
    ];
    async function toggle(event) {
      const id = event.id;
      try {
        await $fetch(`/api/events/${id}/toggle`, { method: "PUT" });
        refresh();
      } catch (e) {
        console.error(e);
      }
    }
    async function remove(event, parent) {
      const ret = await $confirm(`event.remove_${parent ? "recurrent_" : ""}confirmation`, { event: event.title });
      if (!ret) {
        return;
      }
      await $fetch(`/api/events/${event.id}`, { method: "DELETE" });
      refresh();
      $notify("admin.event_remove_ok");
    }
    return (_ctx, _push, _parent, _attrs) => {
      const _component_t_btn = __nuxt_component_0;
      _push(ssrRenderComponent(VContainer, _attrs, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VCard, null, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VCardTitle, null, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`${ssrInterpolate(_ctx.$t("common.my_events"))}`);
                      } else {
                        return [
                          createTextVNode(toDisplayString(_ctx.$t("common.my_events")), 1)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(ssrRenderComponent(VCardText, { class: "pa-1 pa-md-3" }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(ssrRenderComponent(VTextField, {
                          modelValue: unref(search),
                          "onUpdate:modelValue": ($event) => isRef(search) ? search.value = $event : null,
                          label: _ctx.$t("common.search")
                        }, null, _parent4, _scopeId3));
                        if (unref(events)) {
                          _push4(ssrRenderComponent(VDataTable, {
                            items: unref(events),
                            "hide-default-footer": unref(events)?.length < 10,
                            density: "compact",
                            search: unref(search),
                            headers
                          }, {
                            "item.start_datetime": withCtx(({ item }, _push5, _parent5, _scopeId4) => {
                              if (_push5) {
                                if (!item.recurrent) {
                                  _push5(`<span${_scopeId4}>${ssrInterpolate(unref(time).when(item))}</span>`);
                                } else {
                                  _push5(`<!---->`);
                                }
                              } else {
                                return [
                                  !item.recurrent ? (openBlock(), createBlock("span", { key: 0 }, toDisplayString(unref(time).when(item)), 1)) : createCommentVNode("", true)
                                ];
                              }
                            }),
                            "item.actions": withCtx(({ item }, _push5, _parent5, _scopeId4) => {
                              if (_push5) {
                                if (!item.recurrent) {
                                  _push5(`<!--[-->`);
                                  if (!item.is_visible) {
                                    _push5(ssrRenderComponent(_component_t_btn, {
                                      color: "success",
                                      tooltip: "common.confirm",
                                      icon: "mdi-eye",
                                      onClick: ($event) => toggle(item)
                                    }, null, _parent5, _scopeId4));
                                  } else if (!item.parentId) {
                                    _push5(ssrRenderComponent(_component_t_btn, {
                                      color: "info",
                                      tooltip: "common.hide",
                                      icon: "mdi-eye-off",
                                      onClick: ($event) => toggle(item)
                                    }, null, _parent5, _scopeId4));
                                  } else {
                                    _push5(ssrRenderComponent(_component_t_btn, {
                                      color: "info",
                                      tooltip: "common.skip",
                                      icon: "mdi-debug-step-over",
                                      onClick: ($event) => toggle(item)
                                    }, null, _parent5, _scopeId4));
                                  }
                                  _push5(ssrRenderComponent(_component_t_btn, {
                                    to: `/event/${item.slug || item.id}`,
                                    tooltip: "common.preview",
                                    icon: "mdi-arrow-right"
                                  }, null, _parent5, _scopeId4));
                                  _push5(`<!--]-->`);
                                } else {
                                  _push5(`<!--[-->`);
                                  if (!item.is_visible) {
                                    _push5(ssrRenderComponent(_component_t_btn, {
                                      color: "success",
                                      tooltip: "common.start",
                                      icon: "mdi-play",
                                      onClick: ($event) => toggle(item)
                                    }, null, _parent5, _scopeId4));
                                  } else {
                                    _push5(ssrRenderComponent(_component_t_btn, {
                                      color: "info",
                                      tooltip: "common.pause",
                                      icon: "mdi-pause",
                                      onClick: ($event) => toggle(item)
                                    }, null, _parent5, _scopeId4));
                                  }
                                  _push5(`<!--]-->`);
                                }
                                _push5(ssrRenderComponent(_component_t_btn, {
                                  to: `/add/${item.id}`,
                                  color: "yellow",
                                  tooltip: "common.edit",
                                  icon: "mdi-pencil"
                                }, null, _parent5, _scopeId4));
                                _push5(ssrRenderComponent(_component_t_btn, {
                                  color: "error",
                                  tooltip: "common.delete",
                                  icon: item.recurrent ? "mdi-delete-forever" : "mdi-delete",
                                  onClick: ($event) => remove(item, item.recurrent)
                                }, null, _parent5, _scopeId4));
                              } else {
                                return [
                                  !item.recurrent ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                                    !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                                      key: 0,
                                      color: "success",
                                      tooltip: "common.confirm",
                                      icon: "mdi-eye",
                                      onClick: ($event) => toggle(item)
                                    }, null, 8, ["onClick"])) : !item.parentId ? (openBlock(), createBlock(_component_t_btn, {
                                      key: 1,
                                      color: "info",
                                      tooltip: "common.hide",
                                      icon: "mdi-eye-off",
                                      onClick: ($event) => toggle(item)
                                    }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                                      key: 2,
                                      color: "info",
                                      tooltip: "common.skip",
                                      icon: "mdi-debug-step-over",
                                      onClick: ($event) => toggle(item)
                                    }, null, 8, ["onClick"])),
                                    createVNode(_component_t_btn, {
                                      to: `/event/${item.slug || item.id}`,
                                      tooltip: "common.preview",
                                      icon: "mdi-arrow-right"
                                    }, null, 8, ["to"])
                                  ], 64)) : (openBlock(), createBlock(Fragment, { key: 1 }, [
                                    !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                                      key: 0,
                                      color: "success",
                                      tooltip: "common.start",
                                      icon: "mdi-play",
                                      onClick: ($event) => toggle(item)
                                    }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                                      key: 1,
                                      color: "info",
                                      tooltip: "common.pause",
                                      icon: "mdi-pause",
                                      onClick: ($event) => toggle(item)
                                    }, null, 8, ["onClick"]))
                                  ], 64)),
                                  createVNode(_component_t_btn, {
                                    to: `/add/${item.id}`,
                                    color: "yellow",
                                    tooltip: "common.edit",
                                    icon: "mdi-pencil"
                                  }, null, 8, ["to"]),
                                  createVNode(_component_t_btn, {
                                    color: "error",
                                    tooltip: "common.delete",
                                    icon: item.recurrent ? "mdi-delete-forever" : "mdi-delete",
                                    onClick: ($event) => remove(item, item.recurrent)
                                  }, null, 8, ["icon", "onClick"])
                                ];
                              }
                            }),
                            _: 1
                          }, _parent4, _scopeId3));
                        } else {
                          _push4(`<!---->`);
                        }
                      } else {
                        return [
                          createVNode(VTextField, {
                            modelValue: unref(search),
                            "onUpdate:modelValue": ($event) => isRef(search) ? search.value = $event : null,
                            label: _ctx.$t("common.search")
                          }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
                          unref(events) ? (openBlock(), createBlock(VDataTable, {
                            key: 0,
                            items: unref(events),
                            "hide-default-footer": unref(events)?.length < 10,
                            density: "compact",
                            search: unref(search),
                            headers
                          }, {
                            "item.start_datetime": withCtx(({ item }) => [
                              !item.recurrent ? (openBlock(), createBlock("span", { key: 0 }, toDisplayString(unref(time).when(item)), 1)) : createCommentVNode("", true)
                            ]),
                            "item.actions": withCtx(({ item }) => [
                              !item.recurrent ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                                !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                                  key: 0,
                                  color: "success",
                                  tooltip: "common.confirm",
                                  icon: "mdi-eye",
                                  onClick: ($event) => toggle(item)
                                }, null, 8, ["onClick"])) : !item.parentId ? (openBlock(), createBlock(_component_t_btn, {
                                  key: 1,
                                  color: "info",
                                  tooltip: "common.hide",
                                  icon: "mdi-eye-off",
                                  onClick: ($event) => toggle(item)
                                }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                                  key: 2,
                                  color: "info",
                                  tooltip: "common.skip",
                                  icon: "mdi-debug-step-over",
                                  onClick: ($event) => toggle(item)
                                }, null, 8, ["onClick"])),
                                createVNode(_component_t_btn, {
                                  to: `/event/${item.slug || item.id}`,
                                  tooltip: "common.preview",
                                  icon: "mdi-arrow-right"
                                }, null, 8, ["to"])
                              ], 64)) : (openBlock(), createBlock(Fragment, { key: 1 }, [
                                !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                                  key: 0,
                                  color: "success",
                                  tooltip: "common.start",
                                  icon: "mdi-play",
                                  onClick: ($event) => toggle(item)
                                }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                                  key: 1,
                                  color: "info",
                                  tooltip: "common.pause",
                                  icon: "mdi-pause",
                                  onClick: ($event) => toggle(item)
                                }, null, 8, ["onClick"]))
                              ], 64)),
                              createVNode(_component_t_btn, {
                                to: `/add/${item.id}`,
                                color: "yellow",
                                tooltip: "common.edit",
                                icon: "mdi-pencil"
                              }, null, 8, ["to"]),
                              createVNode(_component_t_btn, {
                                color: "error",
                                tooltip: "common.delete",
                                icon: item.recurrent ? "mdi-delete-forever" : "mdi-delete",
                                onClick: ($event) => remove(item, item.recurrent)
                              }, null, 8, ["icon", "onClick"])
                            ]),
                            _: 1
                          }, 8, ["items", "hide-default-footer", "search"])) : createCommentVNode("", true)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VCardTitle, null, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(_ctx.$t("common.my_events")), 1)
                      ]),
                      _: 1
                    }),
                    createVNode(VCardText, { class: "pa-1 pa-md-3" }, {
                      default: withCtx(() => [
                        createVNode(VTextField, {
                          modelValue: unref(search),
                          "onUpdate:modelValue": ($event) => isRef(search) ? search.value = $event : null,
                          label: _ctx.$t("common.search")
                        }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
                        unref(events) ? (openBlock(), createBlock(VDataTable, {
                          key: 0,
                          items: unref(events),
                          "hide-default-footer": unref(events)?.length < 10,
                          density: "compact",
                          search: unref(search),
                          headers
                        }, {
                          "item.start_datetime": withCtx(({ item }) => [
                            !item.recurrent ? (openBlock(), createBlock("span", { key: 0 }, toDisplayString(unref(time).when(item)), 1)) : createCommentVNode("", true)
                          ]),
                          "item.actions": withCtx(({ item }) => [
                            !item.recurrent ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                              !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                                key: 0,
                                color: "success",
                                tooltip: "common.confirm",
                                icon: "mdi-eye",
                                onClick: ($event) => toggle(item)
                              }, null, 8, ["onClick"])) : !item.parentId ? (openBlock(), createBlock(_component_t_btn, {
                                key: 1,
                                color: "info",
                                tooltip: "common.hide",
                                icon: "mdi-eye-off",
                                onClick: ($event) => toggle(item)
                              }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                                key: 2,
                                color: "info",
                                tooltip: "common.skip",
                                icon: "mdi-debug-step-over",
                                onClick: ($event) => toggle(item)
                              }, null, 8, ["onClick"])),
                              createVNode(_component_t_btn, {
                                to: `/event/${item.slug || item.id}`,
                                tooltip: "common.preview",
                                icon: "mdi-arrow-right"
                              }, null, 8, ["to"])
                            ], 64)) : (openBlock(), createBlock(Fragment, { key: 1 }, [
                              !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                                key: 0,
                                color: "success",
                                tooltip: "common.start",
                                icon: "mdi-play",
                                onClick: ($event) => toggle(item)
                              }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                                key: 1,
                                color: "info",
                                tooltip: "common.pause",
                                icon: "mdi-pause",
                                onClick: ($event) => toggle(item)
                              }, null, 8, ["onClick"]))
                            ], 64)),
                            createVNode(_component_t_btn, {
                              to: `/add/${item.id}`,
                              color: "yellow",
                              tooltip: "common.edit",
                              icon: "mdi-pencil"
                            }, null, 8, ["to"]),
                            createVNode(_component_t_btn, {
                              color: "error",
                              tooltip: "common.delete",
                              icon: item.recurrent ? "mdi-delete-forever" : "mdi-delete",
                              onClick: ($event) => remove(item, item.recurrent)
                            }, null, 8, ["icon", "onClick"])
                          ]),
                          _: 1
                        }, 8, ["items", "hide-default-footer", "search"])) : createCommentVNode("", true)
                      ]),
                      _: 1
                    })
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(VCard, null, {
                default: withCtx(() => [
                  createVNode(VCardTitle, null, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(_ctx.$t("common.my_events")), 1)
                    ]),
                    _: 1
                  }),
                  createVNode(VCardText, { class: "pa-1 pa-md-3" }, {
                    default: withCtx(() => [
                      createVNode(VTextField, {
                        modelValue: unref(search),
                        "onUpdate:modelValue": ($event) => isRef(search) ? search.value = $event : null,
                        label: _ctx.$t("common.search")
                      }, null, 8, ["modelValue", "onUpdate:modelValue", "label"]),
                      unref(events) ? (openBlock(), createBlock(VDataTable, {
                        key: 0,
                        items: unref(events),
                        "hide-default-footer": unref(events)?.length < 10,
                        density: "compact",
                        search: unref(search),
                        headers
                      }, {
                        "item.start_datetime": withCtx(({ item }) => [
                          !item.recurrent ? (openBlock(), createBlock("span", { key: 0 }, toDisplayString(unref(time).when(item)), 1)) : createCommentVNode("", true)
                        ]),
                        "item.actions": withCtx(({ item }) => [
                          !item.recurrent ? (openBlock(), createBlock(Fragment, { key: 0 }, [
                            !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                              key: 0,
                              color: "success",
                              tooltip: "common.confirm",
                              icon: "mdi-eye",
                              onClick: ($event) => toggle(item)
                            }, null, 8, ["onClick"])) : !item.parentId ? (openBlock(), createBlock(_component_t_btn, {
                              key: 1,
                              color: "info",
                              tooltip: "common.hide",
                              icon: "mdi-eye-off",
                              onClick: ($event) => toggle(item)
                            }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                              key: 2,
                              color: "info",
                              tooltip: "common.skip",
                              icon: "mdi-debug-step-over",
                              onClick: ($event) => toggle(item)
                            }, null, 8, ["onClick"])),
                            createVNode(_component_t_btn, {
                              to: `/event/${item.slug || item.id}`,
                              tooltip: "common.preview",
                              icon: "mdi-arrow-right"
                            }, null, 8, ["to"])
                          ], 64)) : (openBlock(), createBlock(Fragment, { key: 1 }, [
                            !item.is_visible ? (openBlock(), createBlock(_component_t_btn, {
                              key: 0,
                              color: "success",
                              tooltip: "common.start",
                              icon: "mdi-play",
                              onClick: ($event) => toggle(item)
                            }, null, 8, ["onClick"])) : (openBlock(), createBlock(_component_t_btn, {
                              key: 1,
                              color: "info",
                              tooltip: "common.pause",
                              icon: "mdi-pause",
                              onClick: ($event) => toggle(item)
                            }, null, 8, ["onClick"]))
                          ], 64)),
                          createVNode(_component_t_btn, {
                            to: `/add/${item.id}`,
                            color: "yellow",
                            tooltip: "common.edit",
                            icon: "mdi-pencil"
                          }, null, 8, ["to"]),
                          createVNode(_component_t_btn, {
                            color: "error",
                            tooltip: "common.delete",
                            icon: item.recurrent ? "mdi-delete-forever" : "mdi-delete",
                            onClick: ($event) => remove(item, item.recurrent)
                          }, null, 8, ["icon", "onClick"])
                        ]),
                        _: 1
                      }, 8, ["items", "hide-default-footer", "search"])) : createCommentVNode("", true)
                    ]),
                    _: 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("pages/my_events.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
