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