import { defineComponent as T, computed as B, createElementBlock as t, createCommentVNode as l, unref as n, openBlock as d, normalizeClass as N, withModifiers as w, createElementVNode as y, createVNode as g, withCtx as D, createTextVNode as b } from "vue";
import V from "github-slugger";
import c from "../../components/Badge/Badge.vue.js";
import { useConfig as j } from "../../hooks/useConfig.js";
import { downloadEventBus as E } from "../../libs/download.js";
const $ = /* @__PURE__ */ T({
  __name: "DownloadLink",
  props: {
    title: {}
  },
  setup(v) {
    const e = j(), k = new V(), x = B(() => k.slug(v.title ?? "")), r = (a) => {
      E.emit({ id: "", filename: x.value, format: a });
    };
    return (a, o) => {
      var u, s, i, m, p, f;
      return ((u = n(e)) == null ? void 0 : u.documentDownloadType) !== "none" ? (d(), t("div", {
        key: 0,
        class: N([{
          "download-both": ((s = n(e)) == null ? void 0 : s.documentDownloadType) === "both"
        }, "download-container group"])
      }, [
        ((i = n(e)) == null ? void 0 : i.documentDownloadType) === "json" || ((m = n(e)) == null ? void 0 : m.documentDownloadType) === "both" ? (d(), t("button", {
          key: 0,
          type: "button",
          class: "download-button",
          onClick: o[0] || (o[0] = w((C) => r("json"), ["prevent"])),
          variant: "ghost"
        }, [
          o[3] || (o[3] = y("span", null, " Download OpenAPI Document ", -1)),
          g(c, { class: "extension hidden group-hover:flex" }, {
            default: D(() => o[2] || (o[2] = [
              b("json")
            ])),
            _: 1
          })
        ])) : l("", !0),
        ((p = n(e)) == null ? void 0 : p.documentDownloadType) === "yaml" || ((f = n(e)) == null ? void 0 : f.documentDownloadType) === "both" ? (d(), t("button", {
          key: 1,
          type: "button",
          class: "download-button",
          onClick: o[1] || (o[1] = w((C) => r("yaml"), ["prevent"])),
          variant: "ghost"
        }, [
          o[5] || (o[5] = y("span", null, " Download OpenAPI Document ", -1)),
          g(c, { class: "extension hidden group-hover:flex" }, {
            default: D(() => o[4] || (o[4] = [
              b("yaml")
            ])),
            _: 1
          })
        ])) : l("", !0)
      ], 2)) : l("", !0);
    };
  }
});
export {
  $ as default
};
