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