import { defineComponent as h, ref as w, computed as o, createBlock as n, openBlock as l, unref as g, createSlots as x, withCtx as u, createElementBlock as B, createCommentVNode as r, createElementVNode as d, toDisplayString as c, createTextVNode as v, createVNode as k } from "vue";
import { getMediaTypeConfig as R } from "../helpers/media-types.js";
import { processResponseBody as T } from "../helpers/process-response-body.js";
import V from "./ResponseBodyDownload.vue.js";
import U from "./ResponseBodyInfo.vue.js";
import b from "./ResponseBodyPreview.vue.js";
import C from "./ResponseBodyRaw.vue.js";
import N from "./ResponseBodyToggle.vue.js";
import S from "../../../components/layout/CollapsibleSection.vue.js";
const _ = {
  key: 0,
  class: "bg-b-1 flex max-h-[calc(100%-32px)] flex-col overflow-hidden"
}, $ = { class: "box-content flex min-h-8 items-center justify-between border-y px-3" }, E = { class: "text-xxs font-code leading-5" }, H = /* @__PURE__ */ h({
  __name: "ResponseBody",
  props: {
    title: {},
    layout: {},
    data: {},
    headers: {}
  },
  setup(t) {
    const s = w(!0), m = o(
      () => !!(a.value?.raw && a.value.preview)
    ), f = o(() => s.value || !m.value), p = o(() => !s.value || !m.value), e = o(
      () => T({
        data: t.data,
        headers: t.headers
      })
    ), a = o(
      () => R(e.value.mimeType?.essence ?? "")
    );
    return (P, i) => (l(), n(g(S), {
      class: "max-h-content overflow-y-hidden",
      isStatic: t.layout === "reference"
    }, x({
      title: u(() => [
        v(c(t.title), 1)
      ]),
      default: u(() => [
        t.data ? (l(), B("div", _, [
          d("div", $, [
            d("span", E, c(e.value.mimeType?.essence), 1),
            m.value ? (l(), n(N, {
              key: 0,
              modelValue: s.value,
              "onUpdate:modelValue": i[0] || (i[0] = (y) => s.value = y)
            }, null, 8, ["modelValue"])) : r("", !0)
          ]),
          a.value?.raw && p.value ? (l(), n(C, {
            key: e.value.dataUrl,
            content: t.data,
            language: a.value.language
          }, null, 8, ["content", "language"])) : r("", !0),
          a.value?.preview && f.value ? (l(), n(b, {
            key: e.value.dataUrl,
            alpha: a.value.alpha,
            mode: a.value.preview,
            src: e.value.dataUrl,
            type: e.value.mimeType?.essence ?? ""
          }, null, 8, ["alpha", "mode", "src", "type"])) : r("", !0),
          !a.value?.raw && !a.value?.preview ? (l(), n(U, { key: 2 }, {
            default: u(() => [...i[1] || (i[1] = [
              v(" Binary file ", -1)
            ])]),
            _: 1
          })) : r("", !0)
        ])) : r("", !0)
      ]),
      _: 2
    }, [
      t.data && e.value.dataUrl ? {
        name: "actions",
        fn: u(() => [
          k(V, {
            filename: e.value.attachmentFilename,
            href: e.value.dataUrl,
            type: e.value.mimeType?.essence
          }, null, 8, ["filename", "href", "type"])
        ]),
        key: "0"
      } : void 0
    ]), 1032, ["isStatic"]));
  }
});
export {
  H as default
};
