import { defineComponent, mergeProps, withCtx, unref, createTextVNode, toDisplayString, createVNode, useSSRContext } from 'vue';
import { ssrRenderComponent, ssrInterpolate, ssrRenderAttr } from 'vue/server-renderer';
import { B as useUserSession, s as useState, t as useRoute$2, x as useHead, b as VBtn } from './server.mjs';
import { V as VForm } from './VForm--N0YDif_.mjs';
import { V as VCard, a as VCardTitle } from './VCard-CJXaLaw7.mjs';
import { V as VCardText } from './VCardText-D-diyBaj.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 './form-B9qqVmvI.mjs';
import './forwardRefs-C3iWxc5z.mjs';
import './createSimpleFunctional-eaVhl3I5.mjs';
import './VAvatar-oghuaLjs.mjs';

const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "authorize",
  __ssrInlineRender: true,
  setup(__props) {
    const { user } = useUserSession();
    const settings = useState("settings");
    const route = useRoute$2();
    const { transactionID, client, scope, redirect_uri } = route.query;
    useHead(() => {
      return { title: `${settings.value.title} - Authorize` };
    });
    return (_ctx, _push, _parent, _attrs) => {
      _push(ssrRenderComponent(VForm, mergeProps({
        class: "d-flex justify-space-around",
        method: "post",
        action: "/oauth/authorize"
      }, _attrs), {
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(VCard, {
              class: "mt-5",
              "max-width": "600px"
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(ssrRenderComponent(VCardTitle, null, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`${ssrInterpolate(unref(settings).title)} - ${ssrInterpolate(_ctx.$t("common.authorize"))}`);
                      } else {
                        return [
                          createTextVNode(toDisplayString(unref(settings).title) + " - " + toDisplayString(_ctx.$t("common.authorize")), 1)
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(ssrRenderComponent(VCardText, null, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(`<h2${_scopeId3}>${ssrInterpolate(unref(user)?.email)}</h2><input name="transaction_id"${ssrRenderAttr("value", unref(transactionID))} type="hidden"${_scopeId3}><div${_scopeId3}><span${_scopeId3}>${_ctx.$t("oauth.authorization_request", { app: unref(client), instance_name: unref(settings).title }) ?? ""}</span><ul class="mb-2"${_scopeId3}><li${_scopeId3}>${ssrInterpolate(_ctx.$t(`oauth.scopes.${unref(scope)}`))}</li></ul><span${_scopeId3}>${_ctx.$t("oauth.redirected_to", { url: unref(redirect_uri) }) ?? ""}</span></div>`);
                      } else {
                        return [
                          createVNode("h2", null, toDisplayString(unref(user)?.email), 1),
                          createVNode("input", {
                            name: "transaction_id",
                            value: unref(transactionID),
                            type: "hidden"
                          }, null, 8, ["value"]),
                          createVNode("div", null, [
                            createVNode("span", {
                              innerHTML: _ctx.$t("oauth.authorization_request", { app: unref(client), instance_name: unref(settings).title })
                            }, null, 8, ["innerHTML"]),
                            createVNode("ul", { class: "mb-2" }, [
                              createVNode("li", null, toDisplayString(_ctx.$t(`oauth.scopes.${unref(scope)}`)), 1)
                            ]),
                            createVNode("span", {
                              innerHTML: _ctx.$t("oauth.redirected_to", { url: unref(redirect_uri) })
                            }, null, 8, ["innerHTML"])
                          ])
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                  _push3(ssrRenderComponent(VCardActions, null, {
                    default: withCtx((_3, _push4, _parent4, _scopeId3) => {
                      if (_push4) {
                        _push4(ssrRenderComponent(VSpacer, null, null, _parent4, _scopeId3));
                        _push4(ssrRenderComponent(VBtn, {
                          color: "error",
                          to: "/",
                          variant: "outlined"
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(`${ssrInterpolate(_ctx.$t("common.cancel"))}`);
                            } else {
                              return [
                                createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                        _push4(ssrRenderComponent(VBtn, {
                          type: "submit",
                          color: "success",
                          variant: "outlined"
                        }, {
                          default: withCtx((_4, _push5, _parent5, _scopeId4) => {
                            if (_push5) {
                              _push5(`${ssrInterpolate(_ctx.$t("common.authorize"))}`);
                            } else {
                              return [
                                createTextVNode(toDisplayString(_ctx.$t("common.authorize")), 1)
                              ];
                            }
                          }),
                          _: 1
                        }, _parent4, _scopeId3));
                      } else {
                        return [
                          createVNode(VSpacer),
                          createVNode(VBtn, {
                            color: "error",
                            to: "/",
                            variant: "outlined"
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                            ]),
                            _: 1
                          }),
                          createVNode(VBtn, {
                            type: "submit",
                            color: "success",
                            variant: "outlined"
                          }, {
                            default: withCtx(() => [
                              createTextVNode(toDisplayString(_ctx.$t("common.authorize")), 1)
                            ]),
                            _: 1
                          })
                        ];
                      }
                    }),
                    _: 1
                  }, _parent3, _scopeId2));
                } else {
                  return [
                    createVNode(VCardTitle, null, {
                      default: withCtx(() => [
                        createTextVNode(toDisplayString(unref(settings).title) + " - " + toDisplayString(_ctx.$t("common.authorize")), 1)
                      ]),
                      _: 1
                    }),
                    createVNode(VCardText, null, {
                      default: withCtx(() => [
                        createVNode("h2", null, toDisplayString(unref(user)?.email), 1),
                        createVNode("input", {
                          name: "transaction_id",
                          value: unref(transactionID),
                          type: "hidden"
                        }, null, 8, ["value"]),
                        createVNode("div", null, [
                          createVNode("span", {
                            innerHTML: _ctx.$t("oauth.authorization_request", { app: unref(client), instance_name: unref(settings).title })
                          }, null, 8, ["innerHTML"]),
                          createVNode("ul", { class: "mb-2" }, [
                            createVNode("li", null, toDisplayString(_ctx.$t(`oauth.scopes.${unref(scope)}`)), 1)
                          ]),
                          createVNode("span", {
                            innerHTML: _ctx.$t("oauth.redirected_to", { url: unref(redirect_uri) })
                          }, null, 8, ["innerHTML"])
                        ])
                      ]),
                      _: 1
                    }),
                    createVNode(VCardActions, null, {
                      default: withCtx(() => [
                        createVNode(VSpacer),
                        createVNode(VBtn, {
                          color: "error",
                          to: "/",
                          variant: "outlined"
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                          ]),
                          _: 1
                        }),
                        createVNode(VBtn, {
                          type: "submit",
                          color: "success",
                          variant: "outlined"
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(_ctx.$t("common.authorize")), 1)
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(VCard, {
                class: "mt-5",
                "max-width": "600px"
              }, {
                default: withCtx(() => [
                  createVNode(VCardTitle, null, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(unref(settings).title) + " - " + toDisplayString(_ctx.$t("common.authorize")), 1)
                    ]),
                    _: 1
                  }),
                  createVNode(VCardText, null, {
                    default: withCtx(() => [
                      createVNode("h2", null, toDisplayString(unref(user)?.email), 1),
                      createVNode("input", {
                        name: "transaction_id",
                        value: unref(transactionID),
                        type: "hidden"
                      }, null, 8, ["value"]),
                      createVNode("div", null, [
                        createVNode("span", {
                          innerHTML: _ctx.$t("oauth.authorization_request", { app: unref(client), instance_name: unref(settings).title })
                        }, null, 8, ["innerHTML"]),
                        createVNode("ul", { class: "mb-2" }, [
                          createVNode("li", null, toDisplayString(_ctx.$t(`oauth.scopes.${unref(scope)}`)), 1)
                        ]),
                        createVNode("span", {
                          innerHTML: _ctx.$t("oauth.redirected_to", { url: unref(redirect_uri) })
                        }, null, 8, ["innerHTML"])
                      ])
                    ]),
                    _: 1
                  }),
                  createVNode(VCardActions, null, {
                    default: withCtx(() => [
                      createVNode(VSpacer),
                      createVNode(VBtn, {
                        color: "error",
                        to: "/",
                        variant: "outlined"
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.cancel")), 1)
                        ]),
                        _: 1
                      }),
                      createVNode(VBtn, {
                        type: "submit",
                        color: "success",
                        variant: "outlined"
                      }, {
                        default: withCtx(() => [
                          createTextVNode(toDisplayString(_ctx.$t("common.authorize")), 1)
                        ]),
                        _: 1
                      })
                    ]),
                    _: 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/authorize.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};

export { _sfc_main as default };
