import { defineComponent, resolveComponent, createElementBlock, openBlock, Fragment, renderList, createBlock, withCtx, createCommentVNode, unref, createVNode } from "vue";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
import _sfc_main$5 from "../Models/Model.vue.js";
import _sfc_main$4 from "../Models/ModelTag.vue.js";
import _sfc_main$1 from "../../Lazy/Lazy.vue.js";
import SectionContainer from "../../Section/SectionContainer.vue.js";
import _sfc_main$2 from "../../../features/Operation/Operation.vue.js";
import _sfc_main$3 from "../Tags/Tag.vue.js";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "TraversedEntry",
  props: {
    level: { default: 0 },
    entries: {},
    document: {},
    clientOptions: {},
    options: {},
    selectedServer: {},
    securitySchemes: {},
    selectedClient: {},
    expandedItems: {},
    eventBus: {}
  },
  setup(__props) {
    const isTagGroup = (entry) => entry["type"] === "tag" && entry.isGroup === true;
    const isTag = (entry) => entry["type"] === "tag" && !isTagGroup(entry) && entry.id !== "models";
    const isOperation = (entry) => entry["type"] === "operation";
    const isWebhook = (entry) => entry["type"] === "webhook";
    const isModelsTag = (entry) => entry["type"] === "models";
    const isModel = (entry) => entry["type"] === "model";
    function getPathValue(entry) {
      return isWebhook(entry) ? __props.document.webhooks?.[entry.name] : __props.document.paths?.[entry.path];
    }
    return (_ctx, _cache) => {
      const _component_TraversedEntry = resolveComponent("TraversedEntry", true);
      return openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.entries, (entry) => {
        return openBlock(), createBlock(_sfc_main$1, {
          id: entry.id,
          key: `${entry.id}-${_ctx.options.layout}`
        }, {
          default: withCtx(() => [
            isOperation(entry) || isWebhook(entry) ? (openBlock(), createBlock(unref(SectionContainer), {
              key: 0,
              omit: _ctx.level !== 0
            }, {
              default: withCtx(() => [
                createVNode(unref(_sfc_main$2), {
                  id: entry.id,
                  clientOptions: _ctx.clientOptions,
                  document: _ctx.document,
                  eventBus: _ctx.eventBus,
                  isCollapsed: !_ctx.expandedItems[entry.id],
                  isWebhook: isWebhook(entry),
                  method: entry.method,
                  options: _ctx.options,
                  path: isWebhook(entry) ? entry.name : entry.path,
                  pathValue: getPathValue(entry),
                  securitySchemes: _ctx.securitySchemes,
                  selectedClient: _ctx.selectedClient,
                  server: _ctx.selectedServer
                }, null, 8, ["id", "clientOptions", "document", "eventBus", "isCollapsed", "isWebhook", "method", "options", "path", "pathValue", "securitySchemes", "selectedClient", "server"])
              ]),
              _: 2
            }, 1032, ["omit"])) : isTag(entry) ? (openBlock(), createBlock(unref(_sfc_main$3), {
              key: 1,
              eventBus: _ctx.eventBus,
              isCollapsed: !_ctx.expandedItems[entry.id],
              isLoading: false,
              layout: _ctx.options.layout,
              moreThanOneTag: _ctx.entries.filter(isTag).length > 1,
              tag: entry
            }, {
              default: withCtx(() => [
                "children" in entry && entry.children?.length ? (openBlock(), createBlock(_component_TraversedEntry, {
                  key: 0,
                  clientOptions: _ctx.clientOptions,
                  document: _ctx.document,
                  entries: entry.children,
                  eventBus: _ctx.eventBus,
                  expandedItems: _ctx.expandedItems,
                  level: _ctx.level + 1,
                  options: _ctx.options,
                  securitySchemes: _ctx.securitySchemes,
                  selectedClient: _ctx.selectedClient,
                  selectedServer: _ctx.selectedServer
                }, null, 8, ["clientOptions", "document", "entries", "eventBus", "expandedItems", "level", "options", "securitySchemes", "selectedClient", "selectedServer"])) : createCommentVNode("", true)
              ]),
              _: 2
            }, 1032, ["eventBus", "isCollapsed", "layout", "moreThanOneTag", "tag"])) : isTagGroup(entry) ? (openBlock(), createBlock(_component_TraversedEntry, {
              key: 2,
              clientOptions: _ctx.clientOptions,
              document: _ctx.document,
              entries: entry.children || [],
              eventBus: _ctx.eventBus,
              expandedItems: _ctx.expandedItems,
              level: _ctx.level + 1,
              options: _ctx.options,
              securitySchemes: _ctx.securitySchemes,
              selectedClient: _ctx.selectedClient,
              selectedServer: _ctx.selectedServer
            }, null, 8, ["clientOptions", "document", "entries", "eventBus", "expandedItems", "level", "options", "securitySchemes", "selectedClient", "selectedServer"])) : isModelsTag(entry) && _ctx.document.components?.schemas ? (openBlock(), createBlock(_sfc_main$4, {
              key: 3,
              id: entry.id,
              eventBus: _ctx.eventBus,
              isCollapsed: !_ctx.expandedItems[entry.id],
              layout: _ctx.options.layout
            }, {
              default: withCtx(() => [
                createVNode(_component_TraversedEntry, {
                  clientOptions: _ctx.clientOptions,
                  document: _ctx.document,
                  entries: entry.children || [],
                  eventBus: _ctx.eventBus,
                  expandedItems: _ctx.expandedItems,
                  level: _ctx.level + 1,
                  options: _ctx.options,
                  securitySchemes: _ctx.securitySchemes,
                  selectedClient: _ctx.selectedClient,
                  selectedServer: _ctx.selectedServer
                }, null, 8, ["clientOptions", "document", "entries", "eventBus", "expandedItems", "level", "options", "securitySchemes", "selectedClient", "selectedServer"])
              ]),
              _: 2
            }, 1032, ["id", "eventBus", "isCollapsed", "layout"])) : isModel(entry) && _ctx.document.components?.schemas?.[entry.name] ? (openBlock(), createBlock(_sfc_main$5, {
              key: 4,
              id: entry.id,
              eventBus: _ctx.eventBus,
              isCollapsed: !_ctx.expandedItems[entry.id],
              name: entry.name,
              options: _ctx.options,
              schema: unref(getResolvedRef)(_ctx.document.components.schemas[entry.name])
            }, null, 8, ["id", "eventBus", "isCollapsed", "name", "options", "schema"])) : createCommentVNode("", true)
          ]),
          _: 2
        }, 1032, ["id"]);
      }), 128);
    };
  }
});
export {
  _sfc_main as default
};
