import { _ as __nuxt_component_0 } from './Card-BkfpdQZ7.mjs';
import { _ as __nuxt_component_5 } from './Input-ckU7qZlb.mjs';
import { a as __nuxt_component_1 } from './Button-Dgqz5RR8.mjs';
import { defineComponent, ref, mergeProps, withCtx, isRef, unref, createVNode, withKeys, openBlock, createBlock, toDisplayString, createCommentVNode, createTextVNode, useSSRContext } from 'vue';
import { ssrRenderAttrs, ssrRenderComponent, ssrInterpolate } from 'vue/server-renderer';
import { i as useRoute, j as useRouter } from './server.mjs';
import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs';
import 'tailwind-merge';
import './selectMenu-B2FUotwL.mjs';
import '../nitro/nitro.mjs';
import 'node:path';
import 'node:module';
import 'node:fs';
import 'node:os';
import 'dotenv';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:crypto';
import 'node:async_hooks';
import 'node:url';
import 'node:net';
import '@iconify/utils';
import 'consola';
import '@vueuse/core';
import './nuxt-link-B3UD8izG.mjs';
import './index-Dy4Tu7MB.mjs';
import '@iconify/vue';
import '@iconify/utils/lib/css/icon';
import 'perfect-debounce';
import 'vue-router';
import '../routes/renderer.mjs';
import 'vue-bundle-renderer/runtime';
import 'unhead/server';
import 'devalue';
import 'unhead/utils';
import 'unhead/plugins';

const TOKEN_KEY = "aidev-ui-token";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "login",
  __ssrInlineRender: true,
  setup(__props) {
    useRoute();
    const router = useRouter();
    const manualToken = ref("");
    const error = ref("");
    function submit() {
      const value = manualToken.value.trim();
      if (!value) {
        error.value = "Token is required";
        return;
      }
      localStorage.setItem(TOKEN_KEY, value);
      router.replace("/");
    }
    return (_ctx, _push, _parent, _attrs) => {
      const _component_UCard = __nuxt_component_0;
      const _component_UInput = __nuxt_component_5;
      const _component_UButton = __nuxt_component_1;
      _push(`<div${ssrRenderAttrs(mergeProps({ class: "login-wrap" }, _attrs))} data-v-4199ecb4>`);
      _push(ssrRenderComponent(_component_UCard, { class: "login-card" }, {
        header: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<h1 class="text-xl font-semibold" data-v-4199ecb4${_scopeId}>aidev login</h1><p class="text-sm text-gray-500" data-v-4199ecb4${_scopeId}> Paste the token printed by <code data-v-4199ecb4${_scopeId}>aidev ui</code> in your terminal. </p>`);
          } else {
            return [
              createVNode("h1", { class: "text-xl font-semibold" }, "aidev login"),
              createVNode("p", { class: "text-sm text-gray-500" }, [
                createTextVNode(" Paste the token printed by "),
                createVNode("code", null, "aidev ui"),
                createTextVNode(" in your terminal. ")
              ])
            ];
          }
        }),
        footer: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(ssrRenderComponent(_component_UButton, {
              block: "",
              disabled: !unref(manualToken),
              onClick: submit
            }, {
              default: withCtx((_2, _push3, _parent3, _scopeId2) => {
                if (_push3) {
                  _push3(` Continue `);
                } else {
                  return [
                    createTextVNode(" Continue ")
                  ];
                }
              }),
              _: 1
            }, _parent2, _scopeId));
          } else {
            return [
              createVNode(_component_UButton, {
                block: "",
                disabled: !unref(manualToken),
                onClick: submit
              }, {
                default: withCtx(() => [
                  createTextVNode(" Continue ")
                ]),
                _: 1
              }, 8, ["disabled"])
            ];
          }
        }),
        default: withCtx((_, _push2, _parent2, _scopeId) => {
          if (_push2) {
            _push2(`<div class="space-y-3" data-v-4199ecb4${_scopeId}>`);
            _push2(ssrRenderComponent(_component_UInput, {
              modelValue: unref(manualToken),
              "onUpdate:modelValue": ($event) => isRef(manualToken) ? manualToken.value = $event : null,
              placeholder: "32-byte hex token",
              autocomplete: "off",
              ui: { base: "font-mono" },
              onKeydown: submit
            }, null, _parent2, _scopeId));
            if (unref(error)) {
              _push2(`<p class="text-sm text-red-500" data-v-4199ecb4${_scopeId}>${ssrInterpolate(unref(error))}</p>`);
            } else {
              _push2(`<!---->`);
            }
            _push2(`</div>`);
          } else {
            return [
              createVNode("div", { class: "space-y-3" }, [
                createVNode(_component_UInput, {
                  modelValue: unref(manualToken),
                  "onUpdate:modelValue": ($event) => isRef(manualToken) ? manualToken.value = $event : null,
                  placeholder: "32-byte hex token",
                  autocomplete: "off",
                  ui: { base: "font-mono" },
                  onKeydown: withKeys(submit, ["enter"])
                }, null, 8, ["modelValue", "onUpdate:modelValue"]),
                unref(error) ? (openBlock(), createBlock("p", {
                  key: 0,
                  class: "text-sm text-red-500"
                }, toDisplayString(unref(error)), 1)) : createCommentVNode("", true)
              ])
            ];
          }
        }),
        _: 1
      }, _parent));
      _push(`</div>`);
    };
  }
});
const _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
  const ssrContext = useSSRContext();
  (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/login.vue");
  return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
const login = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4199ecb4"]]);

export { login as default };
//# sourceMappingURL=login-cekfLp5n.mjs.map
