import { defineComponent, computed, createElementBlock, createCommentVNode, openBlock, Fragment, createBlock } from "vue";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { combineParams } from "./helpers/combine-params.js";
import { filterSelectedSecurity } from "./helpers/filter-selected-security.js";
import { getFirstServer } from "./helpers/get-first-server.js";
import ClassicLayout from "./layouts/ClassicLayout.vue.js";
import ModernLayout from "./layouts/ModernLayout.vue.js";
const __default__ = {};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  __name: "Operation",
  props: {
    id: {},
    method: {},
    options: {},
    document: {},
    path: {},
    pathValue: {},
    server: {},
    securitySchemes: {},
    clientOptions: {},
    isCollapsed: { type: Boolean },
    isWebhook: { type: Boolean },
    selectedClient: {},
    eventBus: {}
  },
  setup(__props) {
    const operation = computed(() => {
      const entity = getResolvedRef(__props.pathValue?.[__props.method]);
      if (!entity) {
        return null;
      }
      const parameters = combineParams(__props.pathValue?.parameters, entity.parameters);
      return { ...entity, parameters };
    });
    const selectedServer = computed(
      () => getFirstServer(
        // 1) Operation
        operation.value?.servers ?? null,
        // 2) Path Item
        __props.pathValue?.servers ?? null,
        // 3) Document
        __props.server
      )
    );
    const selectedSecuritySchemes = computed(
      () => filterSelectedSecurity(__props.document, operation.value, __props.securitySchemes)
    );
    return (_ctx, _cache) => {
      return operation.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
        _ctx.options.layout === "classic" ? (openBlock(), createBlock(ClassicLayout, {
          key: 0,
          id: _ctx.id,
          clientOptions: _ctx.clientOptions,
          eventBus: _ctx.eventBus,
          isCollapsed: _ctx.isCollapsed,
          isWebhook: _ctx.isWebhook,
          method: _ctx.method,
          operation: operation.value,
          options: _ctx.options,
          path: _ctx.path,
          selectedClient: _ctx.selectedClient,
          selectedSecuritySchemes: selectedSecuritySchemes.value,
          selectedServer: selectedServer.value
        }, null, 8, ["id", "clientOptions", "eventBus", "isCollapsed", "isWebhook", "method", "operation", "options", "path", "selectedClient", "selectedSecuritySchemes", "selectedServer"])) : (openBlock(), createBlock(ModernLayout, {
          key: 1,
          id: _ctx.id,
          clientOptions: _ctx.clientOptions,
          eventBus: _ctx.eventBus,
          isWebhook: _ctx.isWebhook,
          method: _ctx.method,
          operation: operation.value,
          options: _ctx.options,
          path: _ctx.path,
          selectedClient: _ctx.selectedClient,
          selectedSecuritySchemes: selectedSecuritySchemes.value,
          selectedServer: selectedServer.value
        }, null, 8, ["id", "clientOptions", "eventBus", "isWebhook", "method", "operation", "options", "path", "selectedClient", "selectedSecuritySchemes", "selectedServer"]))
      ], 64)) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
