import { defineComponent, ref, computed, withCtx, createTextVNode, toDisplayString, unref, isRef, createSlots, createVNode, openBlock, createBlock, createCommentVNode, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate, ssrRenderAttr } from 'vue/server-renderer';
import debounce from 'lodash/debounce.js';
import { v as useFetch, s as useState, b as VBtn } from './server.mjs';
import { V as VCard, a as VCardTitle } from './VCard-CJXaLaw7.mjs';
import { V as VCardText } from './VCardText-D-diyBaj.mjs';
import { V as VAlert } from './VAlert-BaT0SM-1.mjs';
import { V as VTextField } from './VTextField-Cxy8Koxy.mjs';
import { V as VCardActions } from './VCardActions-BYFaScU5.mjs';
import { V as VSpacer } from './VSpacer-ClGQoN2i.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 './createSimpleFunctional-eaVhl3I5.mjs';
import './VAvatar-oghuaLjs.mjs';
import './autofocus-DtAziIxK.mjs';
import './index-1z1zC4K2.mjs';
import './form-B9qqVmvI.mjs';
import './animation-Ilk0LvxU.mjs';
import './forwardRefs-C3iWxc5z.mjs';

const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "FollowMe",
  __ssrInlineRender: true,
  props: { isDialog: { type: Boolean, default: false } },
  emits: ["close"],
  setup(__props) {
    const instance_hostname = ref("");
    const proceed = ref(false);
    const instance = ref({ title: "", thumbnail: "" });
    const loading = ref(false);
    const { data: stats } = useFetch(
      "/api/ap_actors/stats",
      "$lK_x30xEy1"
      /* nuxt-injected */
    );
    const settings = useState("settings");
    const link = computed(() => `https://${instance_hostname.value}/authorize_interaction?uri=${settings.value.instance_name}@${settings.value.hostname}`);
    const getInstanceInfo = debounce(() => {
      if (!instance_hostname.value) {
        return;
      }
      loading.value = true;
      const instance_url = `https://${instance_hostname.value}/api/v1/instance`;
      $fetch(instance_url).then((ret) => {
        instance.value = ret;
        proceed.value = true;
        loading.value = false;
      }).catch((_e) => {
        instance.value = {};
        proceed.value = false;
        loading.value = false;
      });
    }, 300);
    return (_ctx, _push, _parent, _attrs) => {
      _push(ssrRenderComponent(VCard, _attrs, {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VCardTitle, { class: "bg-primary" }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(`${ssrInterpolate(_ctx.$t("common.follow_me_title"))}`);
                } else {
                  return [
                    createTextVNode(toDisplayString(_ctx.$t("common.follow_me_title")), 1)
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            _push2(ssrRenderComponent(VCardText, null, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VAlert, {
                    class: "mb-4",
                    type: "info",
                    border: "start",
                    icon: "mdi-information"
                  }, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`${ssrInterpolate(_ctx.$t("admin.stats", unref(stats)))}`);
                      } else {
                        return [
                          createTextVNode(toDisplayString(_ctx.$t("admin.stats", unref(stats))), 1)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(`<p${_scopeId2}>${_ctx.$t("event.follow_me_description", { title: unref(settings).title, account: `@${unref(settings).instance_name}@${unref(settings).hostname}` }) ?? ""}</p>`);
                  _push3(ssrRenderComponent(VTextField, {
                    modelValue: unref(instance_hostname),
                    "onUpdate:modelValue": [($event) => isRef(instance_hostname) ? instance_hostname.value = $event : null, unref(getInstanceInfo)],
                    rules: [_ctx.$valid.required("common.url")],
                    loading: unref(loading),
                    label: _ctx.$t("common.url")
                  }, createSlots({
                    append: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`<p${_scopeId3}><img class="instance_thumb"${ssrRenderAttr("src", unref(instance).thumbnail)}${_scopeId3}> ${ssrInterpolate(unref(instance).title)}</p>`);
                      } else {
                        return [
                          createVNode("p", null, [
                            createVNode("img", {
                              class: "instance_thumb",
                              src: unref(instance).thumbnail
                            }, null, 8, ["src"]),
                            createTextVNode(" " + toDisplayString(unref(instance).title), 1)
                          ])
                        ];
                      }
                    }),
                    _: 2
                  }, [
                    !__props.isDialog ? {
                      name: "prepend",
                      fn: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(ssrRenderComponent(VBtn, {
                            variant: "text",
                            disabled: !unref(proceed),
                            href: unref(link),
                            target: "_blank",
                            loading: unref(loading),
                            color: "primary"
                          }, {
                            default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                              if (_push5) {
                                _push5(`${ssrInterpolate(_ctx.$t("common.follow"))}`);
                              } else {
                                return [
                                  createTextVNode(toDisplayString(_ctx.$t("common.follow")), 1)
                                ];
                              }
                            }),
                            _: 1
                          }, _parent4, _scopeId3));
                        } else {
                          return [
                            createVNode(VBtn, {
                              variant: "text",
                              disabled: !unref(proceed),
                              href: unref(link),
                              target: "_blank",
                              loading: unref(loading),
                              color: "primary"
                            }, {
                              default: withCtx(() => [
                                createTextVNode(toDisplayString(_ctx.$t("common.follow")), 1)
                              ]),
                              _: 1
                            }, 8, ["disabled", "href", "loading"])
                          ];
                        }
                      }),
                      key: "0"
                    } : void 0
                  ]), _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VAlert, {
                      class: "mb-4",
                      type: "info",
                      border: "start",
                      icon: "mdi-information"
                    }, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(_ctx.$t("admin.stats", unref(stats))), 1)
                      ]),
                      _: 1
                    }),
                    createVNode("p", {
                      innerHTML: _ctx.$t("event.follow_me_description", { title: unref(settings).title, account: `@${unref(settings).instance_name}@${unref(settings).hostname}` })
                    }, null, 8, ["innerHTML"]),
                    createVNode(VTextField, {
                      modelValue: unref(instance_hostname),
                      "onUpdate:modelValue": [($event) => isRef(instance_hostname) ? instance_hostname.value = $event : null, unref(getInstanceInfo)],
                      rules: [_ctx.$valid.required("common.url")],
                      loading: unref(loading),
                      label: _ctx.$t("common.url")
                    }, createSlots({
                      append: withCtx(() => [
                        createVNode("p", null, [
                          createVNode("img", {
                            class: "instance_thumb",
                            src: unref(instance).thumbnail
                          }, null, 8, ["src"]),
                          createTextVNode(" " + toDisplayString(unref(instance).title), 1)
                        ])
                      ]),
                      _: 2
                    }, [
                      !__props.isDialog ? {
                        name: "prepend",
                        fn: withCtx(() => [
                          createVNode(VBtn, {
                            variant: "text",
                            disabled: !unref(proceed),
                            href: unref(link),
                            target: "_blank",
                            loading: unref(loading),
                            color: "primary"
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("common.follow")), 1)
                            ]),
                            _: 1
                          }, 8, ["disabled", "href", "loading"])
                        ]),
                        key: "0"
                      } : void 0
                    ]), 1032, ["modelValue", "onUpdate:modelValue", "rules", "loading", "label"])
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
            if (__props.isDialog) {
              _push2(ssrRenderComponent(VCardActions, null, {
                default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                  if (_push3) {
                    _push3(ssrRenderComponent(VBtn, {
                      variant: "outlined",
                      color: "info",
                      onClick: ($event) => _ctx.$copyToClipboard(`@${unref(settings).instance_name}@${unref(settings).hostname}`)
                    }, {
                      default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(`${ssrInterpolate(_ctx.$t("common.copy"))} @${ssrInterpolate(unref(settings).instance_name)}@${ssrInterpolate(unref(settings).hostname)}`);
                        } else {
                          return [
                            createTextVNode(toDisplayString(_ctx.$t("common.copy")) + " @" + toDisplayString(unref(settings).instance_name) + "@" + toDisplayString(unref(settings).hostname), 1)
                          ];
                        }
                      }),
                      _: 1
                    }, _parent3, _scopeId2));
                    _push3(ssrRenderComponent(VSpacer, null, null, _parent3, _scopeId2));
                    if (__props.isDialog) {
                      _push3(ssrRenderComponent(VBtn, {
                        variant: "outlined",
                        color: "warning",
                        onClick: ($event) => _ctx.$emit("close")
                      }, {
                        default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                          if (_push4) {
                            _push4(`${ssrInterpolate(_ctx.$t("common.cancel"))}`);
                          } else {
                            return [
                              createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                            ];
                          }
                        }),
                        _: 1
                      }, _parent3, _scopeId2));
                    } else {
                      _push3(`<!---->`);
                    }
                    _push3(ssrRenderComponent(VBtn, {
                      disabled: !unref(proceed),
                      variant: "outlined",
                      href: unref(link),
                      target: "_blank",
                      loading: unref(loading),
                      color: "primary"
                    }, {
                      default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                        if (_push4) {
                          _push4(`${ssrInterpolate(_ctx.$t("common.follow"))}`);
                        } else {
                          return [
                            createTextVNode(toDisplayString(_ctx.$t("common.follow")), 1)
                          ];
                        }
                      }),
                      _: 1
                    }, _parent3, _scopeId2));
                  } else {
                    return [
                      createVNode(VBtn, {
                        variant: "outlined",
                        color: "info",
                        onClick: ($event) => _ctx.$copyToClipboard(`@${unref(settings).instance_name}@${unref(settings).hostname}`)
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.copy")) + " @" + toDisplayString(unref(settings).instance_name) + "@" + toDisplayString(unref(settings).hostname), 1)
                        ]),
                        _: 1
                      }, 8, ["onClick"]),
                      createVNode(VSpacer),
                      __props.isDialog ? (openBlock(), createBlock(VBtn, {
                        key: 0,
                        variant: "outlined",
                        color: "warning",
                        onClick: ($event) => _ctx.$emit("close")
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                        ]),
                        _: 1
                      }, 8, ["onClick"])) : createCommentVNode("", true),
                      createVNode(VBtn, {
                        disabled: !unref(proceed),
                        variant: "outlined",
                        href: unref(link),
                        target: "_blank",
                        loading: unref(loading),
                        color: "primary"
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.follow")), 1)
                        ]),
                        _: 1
                      }, 8, ["disabled", "href", "loading"])
                    ];
                  }
                }),
                _: 1
              }, _parent2, _scopeId));
            } else {
              _push2(`<!---->`);
            }
          } else {
            return [
              createVNode(VCardTitle, { class: "bg-primary" }, {
                default: withCtx(() => [
                  createTextVNode(toDisplayString(_ctx.$t("common.follow_me_title")), 1)
                ]),
                _: 1
              }),
              createVNode(VCardText, null, {
                default: withCtx(() => [
                  createVNode(VAlert, {
                    class: "mb-4",
                    type: "info",
                    border: "start",
                    icon: "mdi-information"
                  }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(_ctx.$t("admin.stats", unref(stats))), 1)
                    ]),
                    _: 1
                  }),
                  createVNode("p", {
                    innerHTML: _ctx.$t("event.follow_me_description", { title: unref(settings).title, account: `@${unref(settings).instance_name}@${unref(settings).hostname}` })
                  }, null, 8, ["innerHTML"]),
                  createVNode(VTextField, {
                    modelValue: unref(instance_hostname),
                    "onUpdate:modelValue": [($event) => isRef(instance_hostname) ? instance_hostname.value = $event : null, unref(getInstanceInfo)],
                    rules: [_ctx.$valid.required("common.url")],
                    loading: unref(loading),
                    label: _ctx.$t("common.url")
                  }, createSlots({
                    append: withCtx(() => [
                      createVNode("p", null, [
                        createVNode("img", {
                          class: "instance_thumb",
                          src: unref(instance).thumbnail
                        }, null, 8, ["src"]),
                        createTextVNode(" " + toDisplayString(unref(instance).title), 1)
                      ])
                    ]),
                    _: 2
                  }, [
                    !__props.isDialog ? {
                      name: "prepend",
                      fn: withCtx(() => [
                        createVNode(VBtn, {
                          variant: "text",
                          disabled: !unref(proceed),
                          href: unref(link),
                          target: "_blank",
                          loading: unref(loading),
                          color: "primary"
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(_ctx.$t("common.follow")), 1)
                          ]),
                          _: 1
                        }, 8, ["disabled", "href", "loading"])
                      ]),
                      key: "0"
                    } : void 0
                  ]), 1032, ["modelValue", "onUpdate:modelValue", "rules", "loading", "label"])
                ]),
                _: 1
              }),
              __props.isDialog ? (openBlock(), createBlock(VCardActions, { key: 0 }, {
                default: withCtx(() => [
                  createVNode(VBtn, {
                    variant: "outlined",
                    color: "info",
                    onClick: ($event) => _ctx.$copyToClipboard(`@${unref(settings).instance_name}@${unref(settings).hostname}`)
                  }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(_ctx.$t("common.copy")) + " @" + toDisplayString(unref(settings).instance_name) + "@" + toDisplayString(unref(settings).hostname), 1)
                    ]),
                    _: 1
                  }, 8, ["onClick"]),
                  createVNode(VSpacer),
                  __props.isDialog ? (openBlock(), createBlock(VBtn, {
                    key: 0,
                    variant: "outlined",
                    color: "warning",
                    onClick: ($event) => _ctx.$emit("close")
                  }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                    ]),
                    _: 1
                  }, 8, ["onClick"])) : createCommentVNode("", true),
                  createVNode(VBtn, {
                    disabled: !unref(proceed),
                    variant: "outlined",
                    href: unref(link),
                    target: "_blank",
                    loading: unref(loading),
                    color: "primary"
                  }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(_ctx.$t("common.follow")), 1)
                    ]),
                    _: 1
                  }, 8, ["disabled", "href", "loading"])
                ]),
                _: 1
              })) : 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("components/FollowMe.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const __nuxt_component_1 = Object.assign(_sfc_main, { __name: "FollowMe" });

export { __nuxt_component_1 as default };
