import { defineComponent, computed, createBlock, openBlock, unref, createSlots, withCtx, createElementVNode, createCommentVNode, createElementBlock, createVNode, Fragment, toDisplayString, withModifiers, normalizeClass, createTextVNode } from "vue";
import { OperationCodeSample } from "@scalar/api-client/v2/blocks/operation-code-sample";
import { ScalarErrorBoundary, ScalarIconButton, ScalarMarkdown } from "@scalar/components";
import { ScalarIconPlay, ScalarIconCopy, ScalarIconWebhooksLogo } from "@scalar/icons";
import { isOperationDeprecated, getOperationStability, getOperationStabilityColor } from "@scalar/oas-utils/helpers";
import { useClipboard } from "@scalar/use-hooks/useClipboard";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
import OperationPath from "../../../components/OperationPath.vue.js";
import _sfc_main$4 from "../components/callbacks/Callbacks.vue.js";
import _sfc_main$2 from "../components/OperationParameters.vue.js";
import _sfc_main$3 from "../components/OperationResponses.vue.js";
import _sfc_main$1 from "../../specification-extension/SpecificationExtension.vue2.js";
import { getXKeysFromObject } from "../../specification-extension/helpers.js";
import SectionAccordion from "../../../components/Section/SectionAccordion.vue.js";
import ExampleResponses from "../../example-responses/ExampleResponses.vue.js";
import LinkList from "../../../components/LinkList/LinkList.vue.js";
import _sfc_main$5 from "../../external-docs/ExternalDocs.vue.js";
import _sfc_main$6 from "../../x-badges/XBadges.vue.js";
import TestRequestButton from "../../test-request-button/TestRequestButton.vue.js";
import _sfc_main$7 from "../../../components/HttpMethod/HttpMethod.vue.js";
import _sfc_main$8 from "../../../components/Anchor/Anchor.vue.js";
import Badge from "../../../components/Badge/Badge.vue.js";
const _hoisted_1 = { class: "operation-title" };
const _hoisted_2 = { class: "operation-details" };
const _hoisted_3 = { class: "endpoint-label" };
const _hoisted_4 = { class: "endpoint-label-path" };
const _hoisted_5 = { class: "endpoint-label-name" };
const _hoisted_6 = {
  key: 1,
  class: "font-code text-sm"
};
const _hoisted_7 = { class: "endpoint-content" };
const _hoisted_8 = { class: "operation-details-card" };
const _hoisted_9 = {
  key: 0,
  class: "operation-details-card-item"
};
const _hoisted_10 = { class: "operation-details-card-item" };
const _hoisted_11 = { class: "operation-details-card-item" };
const _hoisted_12 = {
  key: 1,
  class: "operation-details-card-item"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "ClassicLayout",
  props: {
    id: {},
    method: {},
    options: {},
    path: {},
    clientOptions: {},
    isCollapsed: { type: Boolean },
    isWebhook: { type: Boolean },
    selectedClient: {},
    eventBus: {},
    operation: {},
    selectedServer: {},
    selectedSecuritySchemes: {}
  },
  setup(__props) {
    const operationTitle = computed(() => __props.operation.summary || __props.path || "");
    const operationExtensions = computed(() => getXKeysFromObject(__props.operation));
    const { copyToClipboard } = useClipboard();
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(SectionAccordion), {
        id: _ctx.id,
        "aria-label": operationTitle.value,
        class: "reference-endpoint",
        modelValue: !_ctx.isCollapsed,
        transparent: "",
        "onUpdate:modelValue": _cache[2] || (_cache[2] = (value) => _ctx.eventBus?.emit("toggle:nav-item", { id: _ctx.id, open: value }))
      }, createSlots({
        title: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            createElementVNode("div", _hoisted_2, [
              createVNode(unref(_sfc_main$7), {
                class: "endpoint-type",
                method: _ctx.method,
                short: ""
              }, null, 8, ["method"]),
              createVNode(unref(_sfc_main$8), {
                class: "endpoint-anchor",
                onCopyAnchorUrl: _cache[0] || (_cache[0] = () => _ctx.eventBus?.emit("copy-url:nav-item", { id: _ctx.id }))
              }, {
                default: withCtx(() => [
                  createElementVNode("h3", _hoisted_3, [
                    createElementVNode("div", _hoisted_4, [
                      createVNode(OperationPath, {
                        deprecated: unref(isOperationDeprecated)(_ctx.operation),
                        path: _ctx.path
                      }, null, 8, ["deprecated", "path"])
                    ]),
                    createElementVNode("div", _hoisted_5, toDisplayString(operationTitle.value), 1),
                    unref(getOperationStability)(_ctx.operation) ? (openBlock(), createBlock(unref(Badge), {
                      key: 0,
                      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: 1,
                      class: "font-code text-green flex w-fit items-center justify-center gap-1"
                    }, {
                      default: withCtx(() => [
                        createVNode(unref(ScalarIconWebhooksLogo), { weight: "bold" }),
                        _cache[3] || (_cache[3] = createTextVNode("Webhook ", -1))
                      ]),
                      _: 1
                    })) : createCommentVNode("", true),
                    createVNode(unref(_sfc_main$6), {
                      badges: _ctx.operation["x-badges"],
                      position: "before"
                    }, null, 8, ["badges"])
                  ])
                ]),
                _: 1
              })
            ])
          ])
        ]),
        actions: withCtx(({ active }) => [
          createVNode(unref(_sfc_main$6), {
            badges: _ctx.operation["x-badges"],
            position: "after"
          }, null, 8, ["badges"]),
          !_ctx.options.hideTestRequestButton ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
            active && !_ctx.isWebhook ? (openBlock(), createBlock(unref(TestRequestButton), {
              key: 0,
              id: _ctx.id,
              eventBus: _ctx.eventBus,
              method: _ctx.method,
              path: _ctx.path
            }, null, 8, ["id", "eventBus", "method", "path"])) : (openBlock(), createBlock(unref(ScalarIconPlay), {
              key: 1,
              class: "endpoint-try-hint size-4.5"
            }))
          ], 64)) : createCommentVNode("", true),
          _ctx.options.showOperationId && _ctx.operation.operationId ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(_ctx.operation.operationId), 1)) : createCommentVNode("", true),
          createVNode(unref(ScalarIconButton), {
            class: "endpoint-copy p-0.5",
            icon: unref(ScalarIconCopy),
            label: "Copy endpoint URL",
            size: "xs",
            variant: "ghost",
            onClick: _cache[1] || (_cache[1] = withModifiers(($event) => unref(copyToClipboard)(_ctx.path), ["stop"]))
          }, null, 8, ["icon"])
        ]),
        default: withCtx(() => [
          createElementVNode("div", _hoisted_7, [
            createElementVNode("div", _hoisted_8, [
              Object.keys(operationExtensions.value).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_9, [
                createVNode(_sfc_main$1, { value: operationExtensions.value }, null, 8, ["value"])
              ])) : createCommentVNode("", true),
              createElementVNode("div", _hoisted_10, [
                createVNode(_sfc_main$2, {
                  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, ["eventBus", "options", "parameters", "requestBody"])
              ]),
              createElementVNode("div", _hoisted_11, [
                createVNode(_sfc_main$3, {
                  eventBus: _ctx.eventBus,
                  options: _ctx.options,
                  responses: _ctx.operation.responses
                }, null, 8, ["eventBus", "options", "responses"])
              ]),
              _ctx.operation?.callbacks ? (openBlock(), createElementBlock("div", _hoisted_12, [
                createVNode(_sfc_main$4, {
                  callbacks: _ctx.operation.callbacks,
                  eventBus: _ctx.eventBus,
                  options: _ctx.options,
                  path: _ctx.path
                }, null, 8, ["callbacks", "eventBus", "options", "path"])
              ])) : createCommentVNode("", true)
            ]),
            _ctx.operation.responses ? (openBlock(), createBlock(unref(ExampleResponses), {
              key: 0,
              class: "operation-example-card",
              responses: _ctx.operation.responses
            }, null, 8, ["responses"])) : createCommentVNode("", true),
            createElementVNode("div", null, [
              _ctx.operation.externalDocs ? (openBlock(), createBlock(unref(LinkList), { key: 0 }, {
                default: withCtx(() => [
                  createVNode(unref(_sfc_main$5), {
                    value: _ctx.operation.externalDocs
                  }, null, 8, ["value"])
                ]),
                _: 1
              })) : createCommentVNode("", true),
              createVNode(unref(ScalarErrorBoundary), null, {
                default: withCtx(() => [
                  createVNode(unref(OperationCodeSample), {
                    class: "operation-example-card",
                    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
                  }, null, 8, ["clientOptions", "eventBus", "isWebhook", "method", "operation", "path", "securitySchemes", "selectedClient", "selectedServer"])
                ]),
                _: 1
              })
            ])
          ])
        ]),
        _: 2
      }, [
        _ctx.operation.description ? {
          name: "description",
          fn: withCtx(() => [
            createVNode(unref(ScalarMarkdown), {
              anchorPrefix: _ctx.id,
              "aria-label": "Operation Description",
              role: "group",
              transformType: "heading",
              value: _ctx.operation.description,
              withAnchors: "",
              withImages: ""
            }, null, 8, ["anchorPrefix", "value"])
          ]),
          key: "0"
        } : void 0
      ]), 1032, ["id", "aria-label", "modelValue"]);
    };
  }
});
export {
  _sfc_main as default
};
