import { defineComponent as h, ref as v, openBlock as n, createBlock as r, unref as i, withCtx as S, createCommentVNode as k, renderSlot as y } from "vue";
import C from "../../ShowMoreButton.vue.js";
import T from "./Endpoints.vue.js";
import { observeMutations as A } from "./mutationObserver.js";
import N from "../../Section/SectionContainer.vue.js";
import { useSidebar as w } from "../../../hooks/useSidebar.js";
import { useNavState as B } from "../../../hooks/useNavState.js";
const H = /* @__PURE__ */ h({
  __name: "Tag",
  props: {
    id: {},
    tag: {},
    spec: {}
  },
  setup(c) {
    const m = c, s = v(null), { collapsedSidebarItems: f } = w(), { getTagId: l } = B(), p = (e) => {
      var o;
      return ((o = m.spec.tags) == null ? void 0 : o.length) !== 1 || (e == null ? void 0 : e.name) !== "default" || (e == null ? void 0 : e.description) !== "";
    }, a = (e) => {
      window.location.href = `#${e}`;
    }, u = (e) => {
      A(s, (o, t) => {
        o.forEach((b) => {
          Array.from(b.addedNodes).some((d) => d instanceof HTMLElement && d.id === e) && (a(e), t.disconnect());
        });
      });
    }, g = (e) => {
      document.getElementById(e) ? a(e) : u(e);
    };
    return (e, o) => (n(), r(i(N), {
      ref_key: "sectionContainerRef",
      ref: s,
      class: "tag-section-container"
    }, {
      default: S(() => {
        var t;
        return [
          p(e.tag) ? (n(), r(T, {
            key: 0,
            id: e.id,
            tag: e.tag,
            onObserveAndNavigate: g
          }, null, 8, ["id", "tag"])) : k("", !0),
          !i(f)[i(l)(e.tag)] && ((t = e.tag.operations) == null ? void 0 : t.length) > 1 ? (n(), r(C, {
            key: 1,
            id: e.id ?? ""
          }, null, 8, ["id"])) : y(e.$slots, "default", { key: 2 }, void 0, !0)
        ];
      }),
      _: 3
    }, 512));
  }
});
export {
  H as default
};
