import { defineComponent, computed, useId, createBlock, openBlock, unref, withCtx, createVNode, createElementVNode, createCommentVNode, createTextVNode, toDisplayString, normalizeClass, createSlots } from "vue";
import { OperationCodeSample } from "@scalar/api-client/v2/blocks/operation-code-sample";
import { ScalarMarkdown, ScalarErrorBoundary } from "@scalar/components";
import { ScalarIconWebhooksLogo } from "@scalar/icons";
import { getOperationStability, getOperationStabilityColor, isOperationDeprecated } from "@scalar/oas-utils/helpers";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
import OperationPath from "../../../components/OperationPath.vue.js";
import _sfc_main$6 from "../components/callbacks/Callbacks.vue.js";
import _sfc_main$4 from "../components/OperationParameters.vue.js";
import _sfc_main$5 from "../components/OperationResponses.vue.js";
import _sfc_main$3 from "../../specification-extension/SpecificationExtension.vue2.js";
import { getXKeysFromObject } from "../../specification-extension/helpers.js";
import Section from "../../../components/Section/Section.vue.js";
import SectionContent from "../../../components/Section/SectionContent.vue.js";
import Badge from "../../../components/Badge/Badge.vue.js";
import _sfc_main$1 from "../../x-badges/XBadges.vue.js";
import SectionHeader from "../../../components/Section/SectionHeader.vue.js";
import _sfc_main$2 from "../../../components/Anchor/Anchor.vue.js";
import SectionHeaderTag from "../../../components/Section/SectionHeaderTag.vue.js";
import SectionColumns from "../../../components/Section/SectionColumns.vue.js";
import SectionColumn from "../../../components/Section/SectionColumn.vue.js";
import LinkList from "../../../components/LinkList/LinkList.vue.js";
import _sfc_main$7 from "../../external-docs/ExternalDocs.vue.js";
import TestRequestButton from "../../test-request-button/TestRequestButton.vue.js";
import ExampleResponses from "../../example-responses/ExampleResponses.vue.js";
const _hoisted_1 = { class: "flex flex-row justify-between gap-1" };
const _hoisted_2 = { class: "flex gap-1" };
const _hoisted_3 = { class: "flex gap-1" };
const _hoisted_4 = { class: "operation-details" };
const _hoisted_5 = { class: "examples" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "ModernLayout",
  props: {
    id: {},
    method: {},
    options: {},
    path: {},
    clientOptions: {},
    isWebhook: { type: Boolean },
    selectedClient: {},
    eventBus: {},
    operation: {},
    selectedServer: {},
    selectedSecuritySchemes: {}
  },
  setup(__props) {
    const operationTitle = computed(() => __props.operation.summary || __props.path || "");
    const labelId = useId();
    const operationExtensions = computed(() => getXKeysFromObject(__props.operation));
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Section), {
        id: _ctx.id,
        "aria-labelledby": unref(labelId),
        label: operationTitle.value,
        tabindex: "-1",
        onIntersecting: _cache[1] || (_cache[1] = () => _ctx.eventBus?.emit("intersecting:nav-item", { id: _ctx.id }))
      }, {
        default: withCtx(() => [
          createVNode(unref(SectionContent), null, {
            default: withCtx(() => [
              createElementVNode("div", _hoisted_1, [
                createElementVNode("div", _hoisted_2, [
                  _ctx.options?.showOperationId && _ctx.operation.operationId ? (openBlock(), createBlock(unref(Badge), { key: 0 }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(_ctx.operation.operationId), 1)
                    ]),
                    _: 1
                  })) : createCommentVNode("", true),
                  unref(getOperationStability)(_ctx.operation) ? (openBlock(), createBlock(unref(Badge), {
                    key: 1,
                    class: normalizeClass(["capitalize", unref(getOperationStabilityColor)(_ctx.operation)])
                  }, {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(unref(getOperationStability)(_ctx.operation)), 1)
                    ]),
                    _: 1
                  }, 8, ["class"])) : createCommentVNode("", true),
                  _ctx.isWebhook ? (openBlock(), createBlock(unref(Badge), {
                    key: 2,
                    class: "font-code text-green flex w-fit items-center justify-center gap-1"
                  }, {
                    default: withCtx(() => [
                      createVNode(unref(ScalarIconWebhooksLogo), { weight: "bold" }),
                      _cache[2] || (_cache[2] = createTextVNode("Webhook ", -1))
                    ]),
                    _: 1
                  })) : createCommentVNode("", true),
                  createVNode(unref(_sfc_main$1), {
                    badges: _ctx.operation["x-badges"],
                    position: "before"
                  }, null, 8, ["badges"])
                ]),
                createElementVNode("div", _hoisted_3, [
                  createVNode(unref(_sfc_main$1), {
                    badges: _ctx.operation["x-badges"],
                    position: "after"
                  }, null, 8, ["badges"])
                ])
              ]),
              createElementVNode("div", {
                class: normalizeClass(unref(isOperationDeprecated)(_ctx.operation) ? "deprecated" : "")
              }, [
                createVNode(unref(SectionHeader), null, {
                  default: withCtx(() => [
                    createVNode(unref(_sfc_main$2), {
                      onCopyAnchorUrl: _cache[0] || (_cache[0] = () => _ctx.eventBus?.emit("copy-url:nav-item", { id: _ctx.id }))
                    }, {
                      default: withCtx(() => [
                        createVNode(unref(SectionHeaderTag), {
                          id: unref(labelId),
                          level: 3
                        }, {
                          default: withCtx(() => [
                            createTextVNode(toDisplayString(operationTitle.value), 1)
                          ]),
                          _: 1
                        }, 8, ["id"])
                      ]),
                      _: 1
                    })
                  ]),
                  _: 1
                })
              ], 2),
              createVNode(unref(SectionColumns), null, {
                default: withCtx(() => [
                  createVNode(unref(SectionColumn), null, {
                    default: withCtx(() => [
                      createElementVNode("div", _hoisted_4, [
                        createVNode(_sfc_main$3, { value: operationExtensions.value }, null, 8, ["value"]),
                        createVNode(unref(ScalarMarkdown), {
                          anchorPrefix: _ctx.id,
                          "aria-label": "Operation Description",
                          role: "group",
                          transformType: "heading",
                          value: _ctx.operation.description,
                          withAnchors: "",
                          withImages: ""
                        }, null, 8, ["anchorPrefix", "value"]),
                        createVNode(_sfc_main$4, {
                          breadcrumb: [_ctx.id],
                          eventBus: _ctx.eventBus,
                          options: _ctx.options,
                          parameters: (
                            // These have been resolved in the Operation.vue component
                            _ctx.operation.parameters
                          ),
                          requestBody: unref(getResolvedRef)(_ctx.operation.requestBody)
                        }, null, 8, ["breadcrumb", "eventBus", "options", "parameters", "requestBody"]),
                        createVNode(_sfc_main$5, {
                          breadcrumb: [_ctx.id],
                          collapsableItems: !_ctx.options.expandAllResponses,
                          eventBus: _ctx.eventBus,
                          options: _ctx.options,
                          responses: _ctx.operation.responses
                        }, null, 8, ["breadcrumb", "collapsableItems", "eventBus", "options", "responses"]),
                        createVNode(unref(ScalarErrorBoundary), null, {
                          default: withCtx(() => [
                            _ctx.operation.callbacks ? (openBlock(), createBlock(_sfc_main$6, {
                              key: 0,
                              callbacks: _ctx.operation.callbacks,
                              class: "mt-6",
                              eventBus: _ctx.eventBus,
                              options: _ctx.options,
                              path: _ctx.path
                            }, null, 8, ["callbacks", "eventBus", "options", "path"])) : createCommentVNode("", true)
                          ]),
                          _: 1
                        })
                      ])
                    ]),
                    _: 1
                  }),
                  createVNode(unref(SectionColumn), null, {
                    default: withCtx(() => [
                      createElementVNode("div", _hoisted_5, [
                        _ctx.operation.externalDocs ? (openBlock(), createBlock(unref(LinkList), { key: 0 }, {
                          default: withCtx(() => [
                            createVNode(unref(_sfc_main$7), {
                              value: _ctx.operation.externalDocs
                            }, null, 8, ["value"])
                          ]),
                          _: 1
                        })) : createCommentVNode("", true),
                        createVNode(unref(ScalarErrorBoundary), null, {
                          default: withCtx(() => [
                            createVNode(unref(OperationCodeSample), {
                              clientOptions: _ctx.clientOptions,
                              eventBus: _ctx.eventBus,
                              fallback: "",
                              isWebhook: _ctx.isWebhook,
                              method: _ctx.method,
                              operation: _ctx.operation,
                              path: _ctx.path,
                              securitySchemes: _ctx.selectedSecuritySchemes,
                              selectedClient: _ctx.selectedClient,
                              selectedServer: _ctx.selectedServer
                            }, createSlots({
                              header: withCtx(() => [
                                createVNode(OperationPath, {
                                  class: "font-code text-c-2 [&_em]:text-c-1 [&_em]:not-italic",
                                  deprecated: _ctx.operation?.deprecated,
                                  path: _ctx.path
                                }, null, 8, ["deprecated", "path"])
                              ]),
                              _: 2
                            }, [
                              !_ctx.isWebhook ? {
                                name: "footer",
                                fn: withCtx(() => [
                                  !_ctx.options.hideTestRequestButton ? (openBlock(), createBlock(unref(TestRequestButton), {
                                    key: 0,
                                    id: _ctx.id,
                                    eventBus: _ctx.eventBus,
                                    method: _ctx.method,
                                    path: _ctx.path
                                  }, null, 8, ["id", "eventBus", "method", "path"])) : createCommentVNode("", true)
                                ]),
                                key: "0"
                              } : void 0
                            ]), 1032, ["clientOptions", "eventBus", "isWebhook", "method", "operation", "path", "securitySchemes", "selectedClient", "selectedServer"])
                          ]),
                          _: 1
                        }),
                        createVNode(unref(ScalarErrorBoundary), null, {
                          default: withCtx(() => [
                            _ctx.operation.responses ? (openBlock(), createBlock(unref(ExampleResponses), {
                              key: 0,
                              responses: _ctx.operation.responses,
                              style: { "margin-top": "12px" }
                            }, null, 8, ["responses"])) : createCommentVNode("", true)
                          ]),
                          _: 1
                        })
                      ])
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["id", "aria-labelledby", "label"]);
    };
  }
});
export {
  _sfc_main as default
};
