import { defineComponent as B, computed as f, ref as b, openBlock as l, createElementBlock as u, createElementVNode as k, renderSlot as j, createVNode as a, unref as c, createCommentVNode as p } from "vue";
import { ScalarMarkdown as C } from "@scalar/components";
import E from "./ContentTypeSelect.vue.js";
import y from "../../../components/Content/Schema/Schema.vue.js";
const P = { key: 0 }, S = { class: "request-body-title" }, V = {
  key: 0,
  class: "request-body-description"
}, O = {
  key: 0,
  class: "request-body-schema"
}, R = {
  key: 1,
  class: "request-body-schema"
}, _ = /* @__PURE__ */ B({
  __name: "RequestBody",
  props: {
    requestBody: {},
    schemas: {}
  },
  setup(i) {
    var h;
    const v = f(
      () => {
        var e;
        return Object.keys(((e = i.requestBody) == null ? void 0 : e.content) ?? {});
      }
    ), t = b("application/json");
    (h = i.requestBody) != null && h.content && v.value.length > 0 && (t.value = v.value[0]);
    const d = f(() => {
      var r, n, q;
      const e = (q = (n = (r = i.requestBody) == null ? void 0 : r.content) == null ? void 0 : n[t.value]) == null ? void 0 : q.schema;
      if ((e == null ? void 0 : e.type) !== "object" || !e.properties)
        return null;
      const s = Object.entries(e.properties);
      if (s.length < 13)
        return null;
      const { properties: m, ...o } = e;
      return {
        visibleProperties: {
          ...o,
          properties: Object.fromEntries(s.slice(0, 12))
        },
        collapsedProperties: {
          ...o,
          properties: Object.fromEntries(s.slice(12))
        }
      };
    });
    return (e, s) => {
      var m, o, r;
      return e.requestBody ? (l(), u("div", P, [
        k("div", S, [
          j(e.$slots, "title", {}, void 0, !0),
          a(E, {
            defaultValue: t.value,
            requestBody: e.requestBody,
            onSelectContentType: s[0] || (s[0] = ({ contentType: n }) => t.value = n)
          }, null, 8, ["defaultValue", "requestBody"]),
          e.requestBody.description ? (l(), u("div", V, [
            a(c(C), {
              value: e.requestBody.description
            }, null, 8, ["value"])
          ])) : p("", !0)
        ]),
        d.value ? (l(), u("div", O, [
          a(c(y), {
            compact: "",
            name: "Request Body",
            noncollapsible: "",
            schemas: e.schemas,
            value: d.value.visibleProperties
          }, null, 8, ["schemas", "value"]),
          a(c(y), {
            additionalProperties: "",
            compact: "",
            name: "Request Body",
            schemas: e.schemas,
            value: d.value.collapsedProperties
          }, null, 8, ["schemas", "value"])
        ])) : (m = e.requestBody.content) != null && m[t.value] ? (l(), u("div", R, [
          a(c(y), {
            compact: "",
            name: "Request Body",
            noncollapsible: "",
            schemas: e.schemas,
            value: (r = (o = e.requestBody.content) == null ? void 0 : o[t.value]) == null ? void 0 : r.schema
          }, null, 8, ["schemas", "value"])
        ])) : p("", !0)
      ])) : p("", !0);
    };
  }
});
export {
  _ as default
};
