import { defineComponent as w, computed as i, ref as g, openBlock as o, createElementBlock as C, createVNode as m, unref as t, withCtx as c, createBlock as p, normalizeClass as B, createElementVNode as u, toDisplayString as E, createCommentVNode as n } from "vue";
import { Disclosure as S, DisclosureButton as b, DisclosurePanel as q } from "@headlessui/vue";
import { ScalarIcon as D, ScalarMarkdown as P } from "@scalar/components";
import V from "./ContentTypeSelect.vue.js";
import I from "./ParameterHeaders.vue.js";
import j from "../../../components/Content/Schema/SchemaProperty.vue.js";
const N = {
  key: 0,
  class: "parameter-item group/parameter-item relative"
}, T = { class: "parameter-item-name" }, _ = { class: "parameter-item-type" }, O = { class: "absolute right-0 top-2.5 opacity-0 group-focus-within/parameter-item:opacity-100 group-hover/parameter-item:opacity-100" }, A = /* @__PURE__ */ w({
  __name: "ParameterListItem",
  props: {
    parameter: {},
    showChildren: { type: Boolean, default: !1 },
    collapsableItems: { type: Boolean, default: !1 },
    withExamples: { type: Boolean, default: !0 },
    schemas: {}
  },
  setup(y) {
    const a = y, v = i(() => a.parameter.content ? Object.keys(a.parameter.content) : []), s = g(
      v.value[0]
    );
    a.parameter.content && "application/json" in a.parameter.content && (s.value = "application/json");
    const r = i(() => !!(a.collapsableItems && (a.parameter.content || a.parameter.headers))), k = i(() => a.parameter.readOnly !== !0);
    return (e, d) => k.value ? (o(), C("li", N, [
      m(t(S), null, {
        default: c(({ open: l }) => [
          r.value ? (o(), p(t(b), {
            key: 0,
            class: B(["parameter-item-trigger flex", { "parameter-item-trigger-open": l }])
          }, {
            default: c(() => [
              m(t(D), {
                class: "parameter-item-icon",
                icon: l ? "ChevronDown" : "ChevronRight",
                thickness: "1.5"
              }, null, 8, ["icon"]),
              u("span", T, E(e.parameter.name), 1),
              u("span", _, [
                e.parameter.description ? (o(), p(t(P), {
                  key: 0,
                  class: "markdown",
                  value: e.parameter.description
                }, null, 8, ["value"])) : n("", !0)
              ])
            ]),
            _: 2
          }, 1032, ["class"])) : n("", !0),
          m(t(q), {
            class: "parameter-item-container parameter-item-container-markdown",
            static: !r.value
          }, {
            default: c(() => {
              var h, f;
              return [
                e.parameter.headers ? (o(), p(I, {
                  key: 0,
                  headers: e.parameter.headers
                }, null, 8, ["headers"])) : n("", !0),
                m(t(j), {
                  is: "div",
                  compact: "",
                  description: r.value ? "" : e.parameter.description,
                  name: r.value ? "" : e.parameter.name,
                  noncollapsible: !0,
                  required: e.parameter.required,
                  schemas: e.schemas,
                  value: {
                    deprecated: e.parameter.deprecated,
                    ...e.parameter.content ? (f = (h = e.parameter.content) == null ? void 0 : h[s.value]) == null ? void 0 : f.schema : e.parameter.schema
                  },
                  withExamples: e.withExamples
                }, null, 8, ["description", "name", "required", "schemas", "value", "withExamples"])
              ];
            }),
            _: 1
          }, 8, ["static"])
        ]),
        _: 1
      }),
      u("div", O, [
        r.value && a.parameter.content ? (o(), p(V, {
          key: 0,
          class: "parameter-item-content-type",
          defaultValue: s.value,
          requestBody: a.parameter,
          onSelectContentType: d[0] || (d[0] = ({ contentType: l }) => s.value = l)
        }, null, 8, ["defaultValue", "requestBody"])) : n("", !0)
      ])
    ])) : n("", !0);
  }
});
export {
  A as default
};
