import { useActiveEntities } from "../../store/active-entities.js";
import { useLayout } from "../../hooks/useLayout.js";
import { useSidebar } from "../../hooks/useSidebar.js";
import { useWorkspace } from "../../store/store.js";
import { importCurlCommand } from "../../libs/importers/curl.js";
import ViewLayout_default from "../../components/ViewLayout/ViewLayout.vue.js";
import ViewLayoutContent_default from "../../components/ViewLayout/ViewLayoutContent.vue.js";
import RequestSection_default from "./RequestSection/RequestSection.vue.js";
import EmptyState_default from "../../components/EmptyState.vue.js";
import ResponseSection_default from "./ResponseSection/ResponseSection.vue.js";
import RequestSubpageHeader_default from "./RequestSubpageHeader.vue.js";
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, isRef, normalizeClass, openBlock, unref, withCtx } from "vue";
//#region src/views/Request/Request.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "flex h-full" };
var _hoisted_2 = {
	key: 0,
	class: "flex h-full flex-1 flex-col"
};
var Request_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "Request",
	props: {
		invalidParams: {},
		selectedSecuritySchemeUids: {},
		requestResult: {}
	},
	emits: ["newTab"],
	setup(__props) {
		const { events } = useWorkspace();
		const { isSidebarOpen } = useSidebar();
		const workspaceContext = useWorkspace();
		const { layout } = useLayout();
		const { activeCollection, activeExample, activeRequest, activeWorkspace, activeServer, activeEnvVariables, activeEnvironment, activeWorkspaceRequests } = useActiveEntities();
		const { modalState, requestHistory } = workspaceContext;
		const activeHistoryEntry = computed(() => [...requestHistory].reverse().find((r) => r.request.uid === activeExample.value?.uid));
		function handleCurlImport(curl) {
			events.commandPalette.emit({
				commandName: "Import from cURL",
				metaData: {
					parsedCurl: importCurlCommand(curl),
					collectionUid: activeCollection.value?.uid
				}
			});
		}
		return (_ctx, _cache) => {
			return unref(activeCollection) && unref(activeWorkspace) ? (openBlock(), createElementBlock("div", {
				key: 0,
				class: normalizeClass(["bg-b-1 relative z-0 flex h-full flex-1 flex-col overflow-hidden pt-0", { "!mr-0 !mb-0 !border-0": unref(layout) === "modal" }])
			}, [createElementVNode("div", _hoisted_1, [unref(activeRequest) ? (openBlock(), createElementBlock("div", _hoisted_2, [createVNode(RequestSubpageHeader_default, {
				modelValue: unref(isSidebarOpen),
				"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(isSidebarOpen) ? isSidebarOpen.value = $event : null),
				collection: unref(activeCollection),
				envVariables: unref(activeEnvVariables),
				environment: unref(activeEnvironment),
				operation: unref(activeRequest),
				server: unref(activeServer),
				workspace: unref(activeWorkspace),
				onHideModal: _cache[1] || (_cache[1] = () => unref(modalState).hide()),
				onImportCurl: handleCurlImport
			}, null, 8, [
				"modelValue",
				"collection",
				"envVariables",
				"environment",
				"operation",
				"server",
				"workspace"
			]), createVNode(ViewLayout_default, null, {
				default: withCtx(() => [unref(activeExample) ? (openBlock(), createBlock(ViewLayoutContent_default, {
					key: 0,
					class: normalizeClass(["flex-1", [unref(isSidebarOpen) ? "sidebar-active-hide-layout" : ""]])
				}, {
					default: withCtx(() => [createVNode(RequestSection_default, {
						collection: unref(activeCollection),
						envVariables: unref(activeEnvVariables),
						environment: unref(activeEnvironment),
						example: unref(activeExample),
						invalidParams: __props.invalidParams,
						operation: unref(activeRequest),
						selectedSecuritySchemeUids: __props.selectedSecuritySchemeUids,
						server: unref(activeServer),
						workspace: unref(activeWorkspace)
					}, null, 8, [
						"collection",
						"envVariables",
						"environment",
						"example",
						"invalidParams",
						"operation",
						"selectedSecuritySchemeUids",
						"server",
						"workspace"
					]), createVNode(ResponseSection_default, {
						collection: unref(activeCollection),
						numWorkspaceRequests: unref(activeWorkspaceRequests).length,
						operation: unref(activeRequest),
						requestResult: __props.requestResult,
						response: activeHistoryEntry.value?.response,
						workspace: unref(activeWorkspace)
					}, null, 8, [
						"collection",
						"numWorkspaceRequests",
						"operation",
						"requestResult",
						"response",
						"workspace"
					])]),
					_: 1
				}, 8, ["class"])) : createCommentVNode("", true)]),
				_: 1
			})])) : (openBlock(), createBlock(EmptyState_default, { key: 1 }))])], 2)) : (openBlock(), createBlock(EmptyState_default, { key: 1 }));
		};
	}
});
//#endregion
export { Request_vue_vue_type_script_setup_true_lang_default as default };

//# sourceMappingURL=Request.vue.script.js.map