import { defineComponent as k, ref as f, useId as y, computed as u, createBlock as l, openBlock as n, unref as o, withCtx as C, createCommentVNode as b, createElementBlock as S, renderSlot as v, nextTick as T } from "vue";
import I from "../../ShowMoreButton.vue.js";
import w from "./Tag.vue.js";
import B from "../../Section/SectionContainer.vue.js";
import { useSidebar as R } from "../../../hooks/useSidebar.js";
import { useNavState as N } from "../../../hooks/useNavState.js";
const M = /* @__PURE__ */ k({
  __name: "TagSection",
  props: {
    id: {},
    tag: {},
    collection: {},
    spec: {}
  },
  setup(m) {
    const a = m, p = f(), r = f(), i = y(), { collapsedSidebarItems: s } = R(), { getTagId: c } = N(), d = u(
      () => {
        var e, t;
        return ((e = a.spec.tags) == null ? void 0 : e.length) && ((t = a.spec.tags) == null ? void 0 : t.length) > 1;
      }
    ), g = u(
      () => {
        var e, t;
        return d.value || ((e = a.tag) == null ? void 0 : e.name) !== "default" || ((t = a.tag) == null ? void 0 : t.description) !== "";
      }
    );
    async function h() {
      var e, t;
      await T(), (t = (e = r.value) == null ? void 0 : e.querySelector("button")) == null || t.focus();
    }
    return (e, t) => (n(), l(o(B), {
      ref_key: "sectionContainerRef",
      ref: p,
      "aria-labelledby": o(i),
      class: "tag-section-container",
      role: "region"
    }, {
      default: C(() => [
        g.value ? (n(), l(w, {
          key: 0,
          id: e.id,
          collection: e.collection,
          headerId: o(i),
          isCollapsed: !o(s)[o(c)(e.tag)],
          tag: e.tag
        }, null, 8, ["id", "collection", "headerId", "isCollapsed", "tag"])) : b("", !0),
        !o(s)[o(c)(e.tag)] && d.value ? (n(), l(I, {
          key: 1,
          id: e.id ?? "",
          "aria-label": `Show all ${e.tag["x-displayName"] ?? e.tag.name} endpoints`,
          onClick: h
        }, null, 8, ["id", "aria-label"])) : (n(), S("div", {
          key: 2,
          ref_key: "contentsRef",
          ref: r,
          class: "contents"
        }, [
          v(e.$slots, "default", {}, void 0, !0)
        ], 512))
      ]),
      _: 3
    }, 8, ["aria-labelledby"]));
  }
});
export {
  M as default
};
