import { defineComponent as b, computed as n, openBlock as f, createElementBlock as v, createVNode as i, unref as a, withCtx as h, createElementVNode as c, toDisplayString as x, createCommentVNode as V } from "vue";
import { ScalarListbox as g, ScalarIcon as d } from "@scalar/components";
const w = {
  key: 0,
  class: "document-selector -mb-1 p-3 pb-0"
}, S = {
  class: "group/dropdown-label hover:bg-b-2 text-c-2 py-1.75 pl-1.75 flex w-full cursor-pointer items-center rounded border",
  tabindex: "0"
}, k = { class: "text-c-1 overflow-hidden truncate text-ellipsis text-sm font-medium" }, N = /* @__PURE__ */ b({
  __name: "DocumentSelector",
  props: {
    options: {},
    modelValue: {}
  },
  emits: ["update:modelValue"],
  setup(l, { emit: m }) {
    const u = m, p = n(() => {
      var e;
      return l.options && ((e = l.options) == null ? void 0 : e.length) > 1;
    }), r = n(
      () => {
        var e;
        return ((e = l.options) == null ? void 0 : e.map((o, t) => ({
          id: String(t),
          // Get the display text for the selected option
          label: o.title || o.slug || `API #${t + 1}`
        }))) || [];
      }
    ), s = n({
      get: () => r.value.find(({ id: e }) => e === String(l.modelValue)),
      set: (e) => u("update:modelValue", Number(e.id))
    });
    return (e, o) => p.value ? (f(), v("div", w, [
      i(a(g), {
        modelValue: s.value,
        "onUpdate:modelValue": o[0] || (o[0] = (t) => s.value = t),
        options: r.value,
        resize: ""
      }, {
        default: h(() => {
          var t;
          return [
            c("div", S, [
              i(a(d), {
                class: "mr-1.25 min-w-4",
                icon: "Versions",
                size: "sm",
                thickness: "2"
              }),
              c("span", k, x(((t = s.value) == null ? void 0 : t.label) || "Select API"), 1),
              i(a(d), {
                class: "group-hover/dropdown-label:text-c-1 ml-auto mr-2",
                icon: "ChevronDown",
                size: "sm",
                thickness: "2"
              })
            ])
          ];
        }),
        _: 1
      }, 8, ["modelValue", "options"])
    ])) : V("", !0);
  }
});
export {
  N as default
};
