import { traverseDescription as S } from "./traverse-description.js";
import { traversePaths as u } from "./traverse-paths.js";
import { traverseSchemas as M } from "./traverse-schemas.js";
import { traverseTags as b } from "./traverse-tags.js";
import { traverseWebhooks as k } from "./traverse-webhooks.js";
const x = (e, { config: a, getHeadingId: v, getOperationId: c, getWebhookId: i, getModelId: n, getTagId: f }) => {
  var h, l, m;
  const r = /* @__PURE__ */ new Map(), t = new Map(
    ((h = e.tags) == null ? void 0 : h.map((s) => [s.name ?? "Untitled Tag", { tag: s, entries: [] }])) ?? []
  );
  u(e, t, r, c);
  const o = S((l = e.info) == null ? void 0 : l.description, r, v), p = k(e, t, r, i), g = b(e, t, r, {
    getTagId: f,
    tagsSorter: a.value.tagsSorter,
    operationsSorter: a.value.operationsSorter
  });
  if (o.push(...g), p.length && o.push({
    id: i(),
    isWebhooks: !0,
    title: "Webhooks",
    children: p
  }), !a.value.hideModels && ((m = e.components) != null && m.schemas)) {
    const s = M(e, t, r, n);
    s.length && o.push({
      id: n(),
      title: "Models",
      children: s
    });
  }
  return { entries: o, titles: r };
};
export {
  x as traverseDocument
};
