import { defineComponent as k, ref as i, computed as d, createBlock as V, openBlock as x, withCtx as t, createVNode as u, createTextVNode as B, unref as p } from "vue";
import { ScalarButton as D } from "@scalar/components";
import { LibraryIcon as N } from "@scalar/icons/library";
import { useRouter as S } from "vue-router";
import w from "../../../../components/IconSelector.vue.js";
import C from "./CommandActionForm.vue.js";
import $ from "./CommandActionInput.vue.js";
const y = {}, A = /* @__PURE__ */ k({
  ...y,
  __name: "CommandPaletteOpenApiDocument",
  props: {
    workspaceStore: {},
    eventBus: {}
  },
  emits: ["close", "back"],
  setup(l, { emit: f }) {
    const c = f, v = S(), m = i(""), o = d(() => m.value.trim()), a = i("interface-content-folder"), s = d(() => !o.value || l.workspaceStore.workspace.documents[o.value] !== void 0), b = () => {
      s.value || (l.eventBus.emit("document:create:empty-document", {
        name: o.value,
        icon: a.value,
        callback: (n) => {
          n && v.push({
            name: "document.overview",
            params: {
              documentSlug: o.value
            }
          });
        }
      }), c("close"));
    }, _ = (n) => {
      c("back", n);
    };
    return (n, e) => (x(), V(C, {
      disabled: s.value,
      onSubmit: b
    }, {
      options: t(() => [
        u(w, {
          modelValue: a.value,
          "onUpdate:modelValue": e[1] || (e[1] = (r) => a.value = r),
          placement: "bottom-start"
        }, {
          default: t(() => [
            u(p(D), {
              class: "aspect-square h-auto px-0",
              variant: "outlined"
            }, {
              default: t(() => [
                u(p(N), {
                  class: "text-c-2 size-4 stroke-[1.75]",
                  src: a.value
                }, null, 8, ["src"])
              ]),
              _: 1
            })
          ]),
          _: 1
        }, 8, ["modelValue"])
      ]),
      submit: t(() => [...e[2] || (e[2] = [
        B("Create Document", -1)
      ])]),
      default: t(() => [
        u($, {
          modelValue: m.value,
          "onUpdate:modelValue": e[0] || (e[0] = (r) => m.value = r),
          label: "Document Name",
          placeholder: "Document Name",
          onDelete: _
        }, null, 8, ["modelValue"])
      ]),
      _: 1
    }, 8, ["disabled"]));
  }
});
export {
  A as default
};
