import { r as useWorkspace } from "./store-DpSUVhjp.js";
import { a as useLayout } from "./useSidebar-DLTwHDI-.js";
import { n as usePluginManager } from "./plugins-B52hCIyZ.js";
import { r as getMediaTypeConfig } from "./consts-CyGRb9dl.js";
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BmmBcIzD.js";
import { t as useResponseBody } from "./hooks-BvZxH4XB.js";
import { r as DataTable_default, t as DataTableRow_default } from "./DataTableRow-c3XveEUO.js";
import { t as DataTableText_default } from "./DataTable-BqbZKW3K.js";
import { t as DataTableHeader_default } from "./DataTableHeader-DJVB0jCZ.js";
import { t as ViewLayoutCollapse_default } from "./ViewLayoutCollapse-CiTb-Uml.js";
import { t as SectionFilter_default } from "./SectionFilter-hrtoRLwj.js";
import { t as ViewLayoutSection_default } from "./ViewLayoutSection-mUqKbQry.js";
import { n as httpHeaders, r as HelpfulLink_default, t as computer_default } from "./computer-D7VW3Ruy.js";
import { t as ScalarAsciiArt_default } from "./ScalarAsciiArt-BjuSnj8e.js";
import { t as EmptyState_default } from "./EmptyState-Cnm7hGW5.js";
import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, toRef, unref, useId, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
import { ScalarButton, ScalarCodeBlockCopy, ScalarErrorBoundary, ScalarHotkey, ScalarIcon, ScalarLoading, ScalarVirtualText, useLoadingState } from "@scalar/components";
import { useRoute, useRouter } from "vue-router";
import { formatJsonOrYamlString, httpStatusCodes } from "@scalar/oas-utils/helpers";
import { prettyPrintJson } from "@scalar/helpers/json/pretty-print-json";
import { useCodeMirror } from "@scalar/use-codemirror";
import prettyMilliseconds from "pretty-ms";
import prettyBytes from "pretty-bytes";
//#region src/views/Request/ResponseSection/ResponseBodyDownload.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$13 = ["download", "href"];
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyDownload.vue
var ResponseBodyDownload_default = /* @__PURE__ */ defineComponent({
	__name: "ResponseBodyDownload",
	props: {
		href: {},
		type: {},
		filename: {}
	},
	setup(__props) {
		const props = __props;
		const filenameExtension = computed(() => {
			const extension = getMediaTypeConfig(props.type ?? "")?.extension ?? ".unknown";
			return props.filename ? props.filename : `response${extension}`;
		});
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("a", {
				class: "text-c-3 text-xxs hover:bg-b-3 flex items-center gap-1 rounded px-1.5 py-0.5 no-underline",
				download: `${filenameExtension.value}`,
				href: __props.href,
				onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["stop"]))
			}, [createVNode(unref(ScalarIcon), {
				icon: "Download",
				size: "xs"
			}), _cache[1] || (_cache[1] = createElementVNode("span", null, [createElementVNode("span", null, "Download"), createElementVNode("span", { class: "sr-only" }, "Response Body")], -1))], 8, _hoisted_1$13);
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyInfo.vue
var _sfc_main = {};
var _hoisted_1$12 = { class: "flex justify-center px-2 py-3" };
var _hoisted_2$9 = { class: "text-c-3 p-2 text-sm" };
function _sfc_render(_ctx, _cache) {
	return openBlock(), createElementBlock("div", _hoisted_1$12, [createElementVNode("div", _hoisted_2$9, [renderSlot(_ctx.$slots, "default")])]);
}
var ResponseBodyInfo_default = /* @__PURE__ */ _plugin_vue_export_helper_default(_sfc_main, [["render", _sfc_render]]);
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyPreview.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$11 = ["src"];
var _hoisted_2$8 = ["src", "type"];
var _hoisted_3$4 = ["src", "type"];
var _hoisted_4$2 = ["data", "type"];
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyPreview.vue
var ResponseBodyPreview_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "ResponseBodyPreview",
	props: {
		src: {},
		type: {},
		mode: {},
		alpha: {
			type: Boolean,
			default: false
		}
	},
	setup(__props) {
		const error = ref(false);
		watch(() => __props.src, () => error.value = false);
		return (_ctx, _cache) => {
			return !error.value && __props.src ? (openBlock(), createElementBlock("div", {
				key: 0,
				class: normalizeClass(["flex justify-center overflow-auto rounded-b", { "bg-preview p-2": __props.alpha }])
			}, [__props.mode === "image" ? (openBlock(), createElementBlock("img", {
				key: 0,
				class: normalizeClass(["h-full max-w-full", { rounded: __props.alpha }]),
				src: __props.src,
				onError: _cache[0] || (_cache[0] = ($event) => error.value = true)
			}, null, 42, _hoisted_1$11)) : __props.mode === "video" ? (openBlock(), createElementBlock("video", {
				key: 1,
				autoplay: "",
				controls: "",
				width: "100%",
				onError: _cache[1] || (_cache[1] = ($event) => error.value = true)
			}, [createElementVNode("source", {
				src: __props.src,
				type: __props.type
			}, null, 8, _hoisted_2$8)], 32)) : __props.mode === "audio" ? (openBlock(), createElementBlock("audio", {
				key: 2,
				class: "my-12",
				controls: "",
				onError: _cache[2] || (_cache[2] = ($event) => error.value = true)
			}, [createElementVNode("source", {
				src: __props.src,
				type: __props.type
			}, null, 8, _hoisted_3$4)], 32)) : (openBlock(), createElementBlock("object", {
				key: 3,
				class: "aspect-[4/3] w-full",
				data: __props.src,
				type: __props.type,
				onError: _cache[3] || (_cache[3] = ($event) => error.value = true)
			}, null, 40, _hoisted_4$2))], 2)) : (openBlock(), createBlock(ResponseBodyInfo_default, { key: 1 }, {
				default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("Preview unavailable", -1)])]),
				_: 1
			}));
		};
	}
}), [["__scopeId", "data-v-0956ad2d"]]);
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyRaw.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$10 = { class: "scalar-code-block group/code-block body-raw flex min-h-0 flex-col overflow-hidden p-px outline-none has-focus-visible:outline" };
var _hoisted_2$7 = {
	class: "body-raw-scroller custom-scroll relative pr-1",
	tabindex: "0"
};
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyRaw.vue
var ResponseBodyRaw_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "ResponseBodyRaw",
	props: {
		content: {},
		language: {}
	},
	setup(__props) {
		const props = __props;
		const codeMirrorRef = ref(null);
		/** Base id for the code block */
		const id = useId();
		const { codeMirror } = useCodeMirror({
			codeMirrorRef,
			readOnly: true,
			lineNumbers: true,
			content: toRef(() => prettyPrintJson(props.content)),
			language: toRef(() => props.language),
			forceFoldGutter: true
		});
		const getCurrentContent = () => {
			return codeMirror.value?.state.doc.toString() || "";
		};
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$10, [createElementVNode("div", _hoisted_2$7, [createElementVNode("div", {
				ref_key: "codeMirrorRef",
				ref: codeMirrorRef
			}, null, 512)]), getCurrentContent() ? (openBlock(), createBlock(unref(ScalarCodeBlockCopy), {
				key: 0,
				content: getCurrentContent(),
				"aria-controls": unref(id),
				lang: __props.language,
				class: "absolute top-2 right-2"
			}, null, 8, [
				"content",
				"aria-controls",
				"lang"
			])) : createCommentVNode("", true)]);
		};
	}
}), [["__scopeId", "data-v-35bf3f39"]]);
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyToggle.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$9 = { class: "text-c-3 text-xxs -my-1 flex justify-center gap-0.5 rounded p-0.5" };
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyToggle.vue
var ResponseBodyToggle_default = /* @__PURE__ */ defineComponent({
	__name: "ResponseBodyToggle",
	props: { modelValue: { type: Boolean } },
	emits: ["update:modelValue"],
	setup(__props) {
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$9, [createElementVNode("button", {
				class: normalizeClass(["hover:bg-b-3 rounded px-1", { "bg-b-3 text-c-1 cursor-default": __props.modelValue }]),
				type: "button",
				onClick: _cache[0] || (_cache[0] = withModifiers(($event) => _ctx.$emit("update:modelValue", true), ["stop"]))
			}, " Preview ", 2), createElementVNode("button", {
				class: normalizeClass(["hover:bg-b-3 rounded px-1", { "bg-b-3 text-c-1 cursor-default": !__props.modelValue }]),
				type: "button",
				onClick: _cache[1] || (_cache[1] = withModifiers(($event) => _ctx.$emit("update:modelValue", false), ["stop"]))
			}, " Raw ", 2)]);
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseBody.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$8 = {
	key: 0,
	class: "bg-b-1 flex max-h-[calc(100%-32px)] flex-col overflow-hidden"
};
var _hoisted_2$6 = { class: "box-content flex min-h-8 items-center justify-between border-y px-3" };
var _hoisted_3$3 = { class: "text-xxs font-code leading-5" };
//#endregion
//#region src/views/Request/ResponseSection/ResponseBody.vue
var ResponseBody_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "ResponseBody",
	props: {
		title: {},
		layout: {},
		data: {},
		headers: {}
	},
	setup(__props) {
		const props = __props;
		/** Preview / Raw toggle */
		const toggle = ref(true);
		const showToggle = computed(() => !!(mediaConfig.value?.raw && mediaConfig.value.preview));
		const showPreview = computed(() => toggle.value || !showToggle.value);
		const showRaw = computed(() => !toggle.value || !showToggle.value);
		const { mimeType, attachmentFilename, dataUrl } = useResponseBody({
			data: toRef(props, "data"),
			headers: toRef(props, "headers")
		});
		const mediaConfig = computed(() => getMediaTypeConfig(mimeType.value.essence));
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutCollapse_default, {
				class: "max-h-content overflow-y-hidden",
				layout: __props.layout
			}, createSlots({
				title: withCtx(() => [createTextVNode(toDisplayString(__props.title), 1)]),
				default: withCtx(() => [__props.data ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
					createElementVNode("div", _hoisted_2$6, [createElementVNode("span", _hoisted_3$3, toDisplayString(unref(mimeType).essence), 1), showToggle.value ? (openBlock(), createBlock(ResponseBodyToggle_default, {
						key: 0,
						modelValue: toggle.value,
						"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => toggle.value = $event)
					}, null, 8, ["modelValue"])) : createCommentVNode("", true)]),
					mediaConfig.value?.raw && showRaw.value ? (openBlock(), createBlock(ResponseBodyRaw_default, {
						key: unref(dataUrl),
						content: __props.data,
						language: mediaConfig.value.language
					}, null, 8, ["content", "language"])) : createCommentVNode("", true),
					mediaConfig.value?.preview && showPreview.value ? (openBlock(), createBlock(ResponseBodyPreview_default, {
						key: unref(dataUrl),
						alpha: mediaConfig.value.alpha,
						mode: mediaConfig.value.preview,
						src: unref(dataUrl),
						type: unref(mimeType).essence
					}, null, 8, [
						"alpha",
						"mode",
						"src",
						"type"
					])) : createCommentVNode("", true),
					!mediaConfig.value?.raw && !mediaConfig.value?.preview ? (openBlock(), createBlock(ResponseBodyInfo_default, { key: 2 }, {
						default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode(" Binary file ", -1)])]),
						_: 1
					})) : createCommentVNode("", true)
				])) : createCommentVNode("", true)]),
				_: 2
			}, [__props.data && unref(dataUrl) ? {
				name: "actions",
				fn: withCtx(() => [createVNode(ResponseBodyDownload_default, {
					filename: unref(attachmentFilename),
					href: unref(dataUrl),
					type: unref(mimeType).essence
				}, null, 8, [
					"filename",
					"href",
					"type"
				])]),
				key: "0"
			} : void 0]), 1032, ["layout"]);
		};
	}
}), [["__scopeId", "data-v-8e5d8a14"]]);
//#endregion
//#region src/views/Request/ResponseSection/RequestHeaders.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$7 = {
	key: 0,
	class: "max-h-[calc(100%-32px)] overflow-y-auto"
};
var _hoisted_2$5 = {
	key: 1,
	class: "text-c-3 bg-b-1 flex min-h-12 items-center justify-center rounded border px-4 text-base"
};
//#endregion
//#region src/views/Request/ResponseSection/RequestHeaders.vue
var RequestHeaders_default = /* @__PURE__ */ defineComponent({
	__name: "RequestHeaders",
	props: { headers: {} },
	setup(__props) {
		const findHeaderInfo = (name) => {
			return httpHeaders.find((header) => header.name.toLowerCase() === name.toLowerCase());
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutCollapse_default, {
				class: "overflow-auto",
				defaultOpen: false,
				itemCount: __props.headers.length
			}, {
				title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Request Headers", -1)])]),
				default: withCtx(() => [__props.headers.length ? (openBlock(), createElementBlock("div", _hoisted_1$7, [createVNode(DataTable_default, {
					columns: ["minmax(auto, min-content)", "minmax(50%, 1fr)"],
					scroll: ""
				}, {
					default: withCtx(() => [createVNode(DataTableRow_default, { class: "sr-only !block" }, {
						default: withCtx(() => [createVNode(unref(DataTableHeader_default), null, {
							default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("Header Key", -1)])]),
							_: 1
						}), createVNode(unref(DataTableHeader_default), null, {
							default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("Header Value", -1)])]),
							_: 1
						})]),
						_: 1
					}), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.headers, (item) => {
						return openBlock(), createBlock(DataTableRow_default, {
							key: item.name,
							class: "group/row text-c-1"
						}, {
							default: withCtx(() => [createVNode(DataTableText_default, { class: "bg-b-1 sticky left-0 z-1 max-w-full group-first/row:border-t-0" }, {
								default: withCtx(() => [typeof findHeaderInfo(item.name)?.url === "string" ? (openBlock(), createBlock(HelpfulLink_default, {
									key: 0,
									class: "decoration-c-3",
									href: findHeaderInfo(item.name).url
								}, {
									default: withCtx(() => [createTextVNode(toDisplayString(item.name), 1)]),
									_: 2
								}, 1032, ["href"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(item.name), 1)], 64))]),
								_: 2
							}, 1024), createVNode(DataTableText_default, {
								class: "z-0 group-first/row:border-t-0",
								text: item.value
							}, null, 8, ["text"])]),
							_: 2
						}, 1024);
					}), 128))]),
					_: 1
				})])) : (openBlock(), createElementBlock("div", _hoisted_2$5, " No Headers "))]),
				_: 1
			}, 8, ["itemCount"]);
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyStreaming.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$6 = { class: "flex w-full items-center justify-between" };
var _hoisted_2$4 = {
	key: 0,
	class: "mr-2 flex items-center gap-2"
};
var _hoisted_3$2 = {
	key: 0,
	class: "text-red bg-b-danger sticky top-0 border-b p-2"
};
var _hoisted_4$1 = {
	key: 1,
	class: "p-2"
};
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyStreaming.vue
var ResponseBodyStreaming_default = /* @__PURE__ */ defineComponent({
	__name: "ResponseBodyStreaming",
	props: { reader: {} },
	setup(__props) {
		const loader = useLoadingState();
		const textContent = ref("");
		const errorRef = ref(null);
		const decoder = new TextDecoder();
		const contentContainer = ref(null);
		/**
		* Scrolls the content container to the bottom
		*/
		const scrollToBottom = () => {
			if (contentContainer.value) contentContainer.value.scrollTop = contentContainer.value.scrollHeight;
		};
		watch(textContent, () => {
			nextTick(scrollToBottom);
		});
		/**
		* Reads the stream and appends the content
		*/
		async function readStream() {
			try {
				while (loader.isLoading) {
					const { done, value } = await __props.reader.read();
					if (done) {
						loader.clear();
						break;
					}
					if (value) textContent.value += decoder.decode(value, { stream: true });
				}
			} catch (error) {
				console.error("Error reading stream:", error);
				loader.clear();
				errorRef.value = error;
			} finally {
				textContent.value += decoder.decode();
			}
		}
		onMounted(() => {
			loader.start();
			readStream();
			errorRef.value = null;
		});
		onBeforeUnmount(() => {
			__props.reader.cancel();
			loader.clear();
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutCollapse_default, { class: "max-h-content overflow-y-hidden" }, {
				title: withCtx(() => [createElementVNode("div", _hoisted_1$6, [_cache[1] || (_cache[1] = createElementVNode("div", null, "Body", -1)), unref(loader).isActive ? (openBlock(), createElementBlock("div", _hoisted_2$4, [createVNode(unref(ScalarLoading), {
					loader: unref(loader),
					size: "xs"
				}, null, 8, ["loader"]), _cache[0] || (_cache[0] = createElementVNode("span", { class: "text-c-2" }, " Listening… ", -1))])) : createCommentVNode("", true)])]),
				default: withCtx(() => [createElementVNode("div", {
					ref_key: "contentContainer",
					ref: contentContainer,
					class: "text-xxs font-code h-full overflow-auto leading-6 whitespace-pre-wrap"
				}, [errorRef.value ? (openBlock(), createElementBlock("div", _hoisted_3$2, toDisplayString(errorRef.value.message), 1)) : createCommentVNode("", true), textContent.value ? (openBlock(), createElementBlock("div", _hoisted_4$1, toDisplayString(textContent.value), 1)) : createCommentVNode("", true)], 512)]),
				_: 1
			});
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseBodyVirtual.vue
var ResponseBodyVirtual_default = /* @__PURE__ */ defineComponent({
	__name: "ResponseBodyVirtual",
	props: {
		content: {},
		data: {},
		headers: {}
	},
	setup(__props) {
		const props = __props;
		const textContent = computed(() => formatJsonOrYamlString(props.content));
		const { mimeType, attachmentFilename, dataUrl } = useResponseBody({
			data: toRef(props, "data"),
			headers: toRef(props, "headers")
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutCollapse_default, { class: "!max-h-100% response-body-virtual overflow-x-auto" }, createSlots({
				title: withCtx(() => [_cache[0] || (_cache[0] = createTextVNode("Body", -1))]),
				default: withCtx(() => [_cache[1] || (_cache[1] = createElementVNode("div", { class: "font-code text-xxs rounded-t border border-b-0 px-2.5 py-1.5" }, " This response body is massive! Syntax highlighting won't work here. ", -1)), createVNode(unref(ScalarVirtualText), {
					containerClass: "custom-scroll scalar-code-block border rounded-b flex flex-1 max-h-screen",
					contentClass: "language-plaintext whitespace-pre font-code text-base",
					lineHeight: 20,
					text: textContent.value
				}, null, 8, ["text"])]),
				_: 2
			}, [unref(dataUrl) ? {
				name: "actions",
				fn: withCtx(() => [createVNode(ResponseBodyDownload_default, {
					filename: unref(attachmentFilename),
					href: unref(dataUrl),
					type: unref(mimeType).essence
				}, null, 8, [
					"filename",
					"href",
					"type"
				])]),
				key: "0"
			} : void 0]), 1024);
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseCookies.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$5 = {
	key: 1,
	class: "text-c-3 bg-b-1 flex min-h-[65px] items-center justify-center border-t px-4 text-sm"
};
//#endregion
//#region src/views/Request/ResponseSection/ResponseCookies.vue
var ResponseCookies_default = /* @__PURE__ */ defineComponent({
	__name: "ResponseCookies",
	props: { cookies: {} },
	setup(__props) {
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutCollapse_default, { defaultOpen: false }, {
				title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Cookies", -1)])]),
				default: withCtx(() => [(openBlock(), createElementBlock(Fragment, { key: 0 }, [__props.cookies.length ? (openBlock(), createBlock(DataTable_default, {
					key: 0,
					class: "flex-1",
					columns: ["", ""]
				}, {
					default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.cookies, (item) => {
						return openBlock(), createBlock(DataTableRow_default, { key: item.name }, {
							default: withCtx(() => [createVNode(DataTableText_default, { text: item.name }, null, 8, ["text"]), createVNode(DataTableText_default, { text: item.value }, null, 8, ["text"])]),
							_: 2
						}, 1024);
					}), 128))]),
					_: 1
				})) : (openBlock(), createElementBlock("div", _hoisted_1$5, " No cookies "))], 64))]),
				_: 1
			});
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseEmpty.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$4 = { class: "flex-center relative flex flex-1 flex-col gap-6 p-2 capitalize" };
var _hoisted_2$3 = {
	key: 0,
	class: "scalar-version-number"
};
var _hoisted_3$1 = { class: "text-c-3 right-4 mt-auto flex w-full flex-col items-end gap-2 text-sm" };
//#endregion
//#region src/views/Request/ResponseSection/ResponseEmpty.vue
var ResponseEmpty_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "ResponseEmpty",
	props: {
		collection: {},
		operation: {},
		workspace: {},
		numWorkspaceRequests: {}
	},
	setup(__props) {
		const { events, requestMutators } = useWorkspace();
		const route = useRoute();
		const router = useRouter();
		const { layout } = useLayout();
		const addRequest = () => {
			const requestData = __props.operation.tags?.length ? { tags: __props.operation.tags[0] ? [__props.operation.tags[0]] : [] } : {};
			const newRequest = requestMutators.add(requestData, __props.collection.uid);
			if (newRequest) {
				router.push({
					name: "request",
					params: {
						workspace: __props.workspace.uid,
						request: newRequest.uid
					}
				});
				nextTick(() => {
					events.hotKeys.emit({ focusAddressBar: new KeyboardEvent("keydown", { key: "l" }) });
				});
			}
		};
		const handleHotKey = (event) => {
			if (event?.createNew && route.name === "request") addRequest();
		};
		const packageVersion = "2.38.2";
		onMounted(() => events.hotKeys.on(handleHotKey));
		onBeforeUnmount(() => events.hotKeys.off(handleHotKey));
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$4, [
				createElementVNode("div", { class: normalizeClass(["flex h-[calc(100%_-_50px)] flex-col items-center justify-center", { "hidden opacity-0": __props.numWorkspaceRequests <= 1 && unref(layout) !== "modal" }]) }, [
					unref(layout) !== "modal" ? (openBlock(), createElementBlock("div", _hoisted_2$3, [createTextVNode(" Scalar App V" + toDisplayString(unref(packageVersion)) + " Beta ", 1), _cache[3] || (_cache[3] = createElementVNode("div", { class: "mt-2" }, [createElementVNode("a", {
						href: "https://github.com/scalar/scalar/issues/2669",
						target: "_blank"
					}, " Roadmap ")], -1))])) : createCommentVNode("", true),
					_cache[4] || (_cache[4] = createElementVNode("a", {
						class: "gitbook-show scalar-version-number",
						href: "https://www.scalar.com",
						target: "_blank"
					}, " Powered By Scalar.com ", -1)),
					createVNode(ScalarAsciiArt_default, {
						art: unref(computer_default),
						class: "text-c-3"
					}, null, 8, ["art"])
				], 2),
				unref(layout) !== "modal" ? (openBlock(), createElementBlock("div", {
					key: 0,
					class: normalizeClass(["hidden h-[calc(100%_-_50px)] items-center justify-center pb-5", { "!flex opacity-100": __props.numWorkspaceRequests == 1 }])
				}, [createVNode(EmptyState_default)], 2)) : createCommentVNode("", true),
				createElementVNode("div", _hoisted_3$1, [
					unref(layout) !== "modal" ? (openBlock(), createElementBlock("button", {
						key: 0,
						class: "flex items-center gap-1.5",
						type: "button",
						onClick: _cache[0] || (_cache[0] = ($event) => unref(events).commandPalette.emit())
					}, [_cache[5] || (_cache[5] = createTextVNode(" Get Started ", -1)), createVNode(unref(ScalarHotkey), { hotkey: "k" })])) : createCommentVNode("", true),
					unref(layout) === "desktop" ? (openBlock(), createElementBlock("button", {
						key: 1,
						class: "flex items-center gap-1.5",
						type: "button",
						onClick: _cache[1] || (_cache[1] = ($event) => addRequest())
					}, [_cache[6] || (_cache[6] = createTextVNode(" New Request ", -1)), createVNode(unref(ScalarHotkey), { hotkey: "N" })])) : createCommentVNode("", true),
					createElementVNode("button", {
						class: "flex items-center gap-1.5",
						type: "button",
						onClick: _cache[2] || (_cache[2] = ($event) => unref(events).executeRequest.emit())
					}, [_cache[7] || (_cache[7] = createTextVNode(" Send Request ", -1)), createVNode(unref(ScalarHotkey), { hotkey: "↵" })])
				])
			]);
		};
	}
}), [["__scopeId", "data-v-6d2bdb61"]]);
//#endregion
//#region src/views/Request/ResponseSection/ResponseHeaders.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$3 = {
	key: 0,
	class: "max-h-[calc(100%-32px)] overflow-y-auto"
};
var _hoisted_2$2 = {
	key: 1,
	class: "text-c-3 bg-b-1 flex min-h-12 items-center justify-center rounded border px-4 text-base"
};
//#endregion
//#region src/views/Request/ResponseSection/ResponseHeaders.vue
var ResponseHeaders_default = /* @__PURE__ */ defineComponent({
	__name: "ResponseHeaders",
	props: { headers: {} },
	setup(__props) {
		const findHeaderInfo = (name) => {
			return httpHeaders.find((header) => header.name.toLowerCase() === name.toLowerCase());
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutCollapse_default, {
				class: "overflow-auto",
				defaultOpen: false,
				itemCount: __props.headers.length
			}, {
				title: withCtx(() => [..._cache[0] || (_cache[0] = [createTextVNode("Response Headers", -1)])]),
				default: withCtx(() => [__props.headers.length ? (openBlock(), createElementBlock("div", _hoisted_1$3, [createVNode(DataTable_default, {
					columns: ["minmax(auto, min-content)", "minmax(50%, 1fr)"],
					scroll: ""
				}, {
					default: withCtx(() => [createVNode(DataTableRow_default, { class: "sr-only !block" }, {
						default: withCtx(() => [createVNode(unref(DataTableHeader_default), null, {
							default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("Header Key", -1)])]),
							_: 1
						}), createVNode(unref(DataTableHeader_default), null, {
							default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode("Header Value", -1)])]),
							_: 1
						})]),
						_: 1
					}), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.headers, (item) => {
						return openBlock(), createBlock(DataTableRow_default, {
							key: item.name,
							class: "group/row text-c-1"
						}, {
							default: withCtx(() => [createVNode(DataTableText_default, { class: "bg-b-1 sticky left-0 z-1 max-w-full group-first/row:border-t-0" }, {
								default: withCtx(() => [typeof findHeaderInfo(item.name)?.url === "string" ? (openBlock(), createBlock(HelpfulLink_default, {
									key: 0,
									class: "decoration-c-3",
									href: findHeaderInfo(item.name).url
								}, {
									default: withCtx(() => [createTextVNode(toDisplayString(item.name), 1)]),
									_: 2
								}, 1032, ["href"])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(item.name), 1)], 64))]),
								_: 2
							}, 1024), createVNode(DataTableText_default, {
								class: "z-0 group-first/row:border-t-0",
								text: item.value
							}, null, 8, ["text"])]),
							_: 2
						}, 1024);
					}), 128))]),
					_: 1
				})])) : (openBlock(), createElementBlock("div", _hoisted_2$2, " No Headers "))]),
				_: 1
			}, 8, ["itemCount"]);
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseLoadingOverlay.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$2 = {
	key: 0,
	class: "bg-b-1 z-overlay absolute inset-0 flex flex-col items-center justify-center gap-6"
};
//#endregion
//#region src/views/Request/ResponseSection/ResponseLoadingOverlay.vue
var ResponseLoadingOverlay_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "ResponseLoadingOverlay",
	setup(__props) {
		const { events } = useWorkspace();
		const loader = useLoadingState();
		const timeout = ref();
		events.requestStatus.on(async (status) => {
			if (status === "start") timeout.value = setTimeout(() => loader.start(), 1e3);
			else {
				clearTimeout(timeout.value);
				timeout.value = void 0;
				await loader.clear();
			}
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(Transition, null, {
				default: withCtx(() => [unref(loader).isActive ? (openBlock(), createElementBlock("div", _hoisted_1$2, [createVNode(unref(ScalarLoading), {
					class: "text-c-3",
					loader: unref(loader),
					size: "3xl"
				}, null, 8, ["loader"]), createVNode(unref(ScalarButton), {
					variant: "ghost",
					onClick: _cache[0] || (_cache[0] = ($event) => unref(events).cancelRequest.emit())
				}, {
					default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode(" Cancel ", -1)])]),
					_: 1
				})])) : createCommentVNode("", true)]),
				_: 1
			});
		};
	}
}), [["__scopeId", "data-v-7ec8af01"]]);
//#endregion
//#region src/views/Request/ResponseSection/ResponseMetaInformation.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$1 = { class: "text-c-1 flex gap-1.5" };
var _hoisted_2$1 = { key: 0 };
var _hoisted_3 = { key: 0 };
var _hoisted_4 = { key: 1 };
//#endregion
//#region src/views/Request/ResponseSection/ResponseMetaInformation.vue
var ResponseMetaInformation_default = /* @__PURE__ */ defineComponent({
	__name: "ResponseMetaInformation",
	props: { response: {} },
	setup(__props) {
		const props = __props;
		const { events } = useWorkspace();
		const interval = ref();
		const stopwatch = ref(0);
		events.requestStatus.on((status) => {
			if (status === "start") interval.value = setInterval(() => stopwatch.value += 1e3, 1e3);
			else {
				clearInterval(interval.value);
				interval.value = void 0;
				stopwatch.value = 0;
			}
		});
		/** Size of the response */
		const getContentLength = (response) => {
			const contentLength = Number.parseInt(response.headers?.["Content-Length"] || response.headers?.["content-length"] || "0", 10);
			return contentLength ? prettyBytes(contentLength) : void 0;
		};
		/** Status text for the response */
		const statusCodeInformation = computed(() => {
			const responseStatusCode = props.response.status;
			if (!responseStatusCode) return;
			return httpStatusCodes[responseStatusCode] ?? void 0;
		});
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$1, [interval.value && stopwatch.value ? (openBlock(), createElementBlock("span", _hoisted_2$1, toDisplayString(unref(prettyMilliseconds)(stopwatch.value)), 1)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
				createElementVNode("span", null, [_cache[0] || (_cache[0] = createElementVNode("span", { class: "sr-only" }, "Response Information, Duration:", -1)), createTextVNode(" " + toDisplayString(unref(prettyMilliseconds)(__props.response.duration)), 1)]),
				getContentLength(__props.response) ? (openBlock(), createElementBlock("span", _hoisted_3, [_cache[1] || (_cache[1] = createElementVNode("span", { class: "sr-only" }, ", Size:", -1)), createTextVNode(" " + toDisplayString(getContentLength(__props.response)), 1)])) : createCommentVNode("", true),
				statusCodeInformation.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [_cache[2] || (_cache[2] = createElementVNode("span", { class: "sr-only" }, ", Status:", -1)), statusCodeInformation.value.url ? (openBlock(), createBlock(HelpfulLink_default, {
					key: 0,
					class: "flex items-center gap-1.5",
					href: statusCodeInformation.value.url
				}, {
					default: withCtx(() => [createTextVNode(toDisplayString(__props.response.status) + " " + toDisplayString(statusCodeInformation.value.name) + " ", 1), createElementVNode("span", {
						class: "block h-1.5 w-1.5 rounded-full",
						style: normalizeStyle({ backgroundColor: statusCodeInformation.value.color })
					}, null, 4)]),
					_: 1
				}, 8, ["href"])) : (openBlock(), createElementBlock("span", _hoisted_4, [createTextVNode(toDisplayString(__props.response.status) + " " + toDisplayString(statusCodeInformation.value.name) + " ", 1), createElementVNode("span", {
					class: "block h-1.5 w-1.5 rounded-full",
					style: normalizeStyle({ backgroundColor: statusCodeInformation.value.color })
				}, null, 4)]))], 64)) : createCommentVNode("", true)
			], 64))]);
		};
	}
});
//#endregion
//#region src/views/Request/ResponseSection/ResponseSection.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "flex h-8 flex-1 items-center" };
var _hoisted_2 = ["id", "role"];
var VIRTUALIZATION_THRESHOLD = 2e5;
//#endregion
//#region src/views/Request/ResponseSection/ResponseSection.vue
var ResponseSection_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "ResponseSection",
	props: {
		collection: {},
		operation: {},
		workspace: {},
		numWorkspaceRequests: {},
		response: {},
		requestResult: {}
	},
	setup(__props) {
		const responseSectionViews = usePluginManager().getViewComponents("response.section");
		const responseHeaders = computed(() => {
			const headers = __props.response?.headers;
			return headers ? Object.keys(headers).map((key) => ({
				name: key,
				value: headers[key] ?? "",
				required: false
			})) : [];
		});
		const responseCookies = computed(() => __props.response?.cookieHeaderKeys.flatMap((key) => {
			const value = __props.response?.headers?.[key];
			return value ? {
				name: key,
				value,
				required: false
			} : [];
		}) ?? []);
		const responseSections = [
			"Cookies",
			"Headers",
			"Body"
		];
		const activeFilter = ref("All");
		const filters = computed(() => ["All", ...responseSections]);
		const filterIds = computed(() => Object.fromEntries(filters.value.map((section) => [section, useId()])));
		/** Threshold for virtualizing response bodies in bytes */
		const shouldVirtualize = computed(() => {
			if (!__props.response || !("size" in __props.response)) return false;
			const contentType = __props.response.headers?.["content-type"] || __props.response.headers?.["Content-Type"];
			if (!contentType || (__props.response.size ?? 0) <= VIRTUALIZATION_THRESHOLD) return false;
			if (contentType.includes("text/html")) return false;
			return [
				"text/",
				"application/json",
				"application/ld+json",
				"application/problem+json",
				"application/vnd.api+json",
				"application/xml",
				"application/atom+xml",
				"application/rss+xml",
				"application/problem+xml",
				"application/javascript",
				"application/ecmascript",
				"application/x-yaml",
				"application/yaml",
				"application/x-httpd-php",
				"application/x-sh",
				"application/x-perl",
				"application/x-python",
				"application/x-ruby",
				"application/x-java-source",
				"application/x-www-form-urlencoded"
			].some((type) => contentType.includes(type)) && (__props.response.size ?? 0) > VIRTUALIZATION_THRESHOLD;
		});
		const requestHeaders = computed(() => __props.requestResult?.request.parameters.headers.filter((h) => h.enabled).map((h) => ({
			name: h.key,
			value: h.value,
			required: true
		})) ?? []);
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutSection_default, { "aria-label": "Response" }, {
				title: withCtx(() => [createElementVNode("div", _hoisted_1, [createElementVNode("div", {
					"aria-live": "polite",
					class: normalizeClass(["flex items-center", { "animate-response-heading": __props.response }])
				}, [_cache[1] || (_cache[1] = createElementVNode("span", { class: "response-heading pointer-events-none absolute" }, " Response ", -1)), __props.response ? (openBlock(), createBlock(ResponseMetaInformation_default, {
					key: 0,
					class: "animate-response-children",
					response: __props.response
				}, null, 8, ["response"])) : createCommentVNode("", true)], 2), createVNode(SectionFilter_default, {
					modelValue: activeFilter.value,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeFilter.value = $event),
					filterIds: filterIds.value,
					filters: filters.value
				}, null, 8, [
					"modelValue",
					"filterIds",
					"filters"
				])])]),
				default: withCtx(() => [createElementVNode("div", {
					id: filterIds.value.All,
					class: normalizeClass(["custom-scroll response-section-content relative grid h-full justify-stretch", { "content-start": __props.response }]),
					role: activeFilter.value === "All" && __props.response ? "tabpanel" : "none"
				}, [!__props.response ? (openBlock(), createBlock(ResponseEmpty_default, {
					key: 0,
					collection: __props.collection,
					operation: __props.operation,
					workspace: __props.workspace,
					numWorkspaceRequests: __props.numWorkspaceRequests
				}, null, 8, [
					"collection",
					"operation",
					"workspace",
					"numWorkspaceRequests"
				])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
					activeFilter.value === "All" || activeFilter.value === "Cookies" ? (openBlock(), createBlock(ResponseCookies_default, {
						key: 0,
						class: "response-section-content-cookies",
						id: filterIds.value.Cookies,
						cookies: responseCookies.value,
						role: activeFilter.value === "All" ? "none" : "tabpanel"
					}, null, 8, [
						"id",
						"cookies",
						"role"
					])) : createCommentVNode("", true),
					activeFilter.value === "All" || activeFilter.value === "Headers" ? (openBlock(), createBlock(RequestHeaders_default, {
						key: 1,
						class: "response-section-content-headers",
						id: filterIds.value.Headers,
						headers: requestHeaders.value,
						role: activeFilter.value === "All" ? "none" : "tabpanel"
					}, null, 8, [
						"id",
						"headers",
						"role"
					])) : createCommentVNode("", true),
					activeFilter.value === "All" || activeFilter.value === "Headers" ? (openBlock(), createBlock(ResponseHeaders_default, {
						key: 2,
						class: "response-section-content-headers",
						id: filterIds.value.Headers,
						headers: responseHeaders.value,
						role: activeFilter.value === "All" ? "none" : "tabpanel"
					}, null, 8, [
						"id",
						"headers",
						"role"
					])) : createCommentVNode("", true),
					(openBlock(true), createElementBlock(Fragment, null, renderList(unref(responseSectionViews), (view, index) => {
						return openBlock(), createBlock(unref(ScalarErrorBoundary), { key: view.title ?? index }, {
							default: withCtx(() => [withDirectives((openBlock(), createBlock(resolveDynamicComponent(view.component), mergeProps({ ref_for: true }, view.props ?? {}), null, 16)), [[vShow, activeFilter.value === "All" || activeFilter.value === view.title]])]),
							_: 2
						}, 1024);
					}), 128)),
					activeFilter.value === "All" || activeFilter.value === "Body" ? (openBlock(), createElementBlock(Fragment, { key: 3 }, ["reader" in __props.response ? (openBlock(), createBlock(ResponseBodyStreaming_default, {
						key: 0,
						class: "response-section-content-body",
						id: filterIds.value.Body,
						reader: __props.response.reader
					}, null, 8, ["id", "reader"])) : shouldVirtualize.value && typeof __props.response?.data === "string" ? (openBlock(), createBlock(ResponseBodyVirtual_default, {
						key: 1,
						id: filterIds.value.Body,
						content: __props.response.data,
						data: __props.response?.data,
						headers: responseHeaders.value,
						role: activeFilter.value === "All" ? "none" : "tabpanel"
					}, null, 8, [
						"id",
						"content",
						"data",
						"headers",
						"role"
					])) : (openBlock(), createBlock(ResponseBody_default, {
						key: 2,
						class: "response-section-content-body",
						id: filterIds.value.Body,
						layout: "client",
						active: true,
						data: __props.response?.data,
						headers: responseHeaders.value,
						role: activeFilter.value === "All" ? "none" : "tabpanel",
						title: "Body"
					}, null, 8, [
						"id",
						"data",
						"headers",
						"role"
					]))], 64)) : createCommentVNode("", true)
				], 64)), createVNode(ResponseLoadingOverlay_default)], 10, _hoisted_2)]),
				_: 1
			});
		};
	}
}), [["__scopeId", "data-v-6e4eec82"]]);
//#endregion
export { ResponseBody_default as n, ResponseSection_default as t };

//# sourceMappingURL=ResponseSection-DMJ0tw8E.js.map