import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BmmBcIzD.js";
import { n as useFileDialog } from "./hooks-BvZxH4XB.js";
import { C as getDefaultHeaders, S as getExampleFromSchema, a as getClients, c as findClient, i as getCustomCodeSamples, n as generateCodeSnippet, r as getSecrets, w as getExample, x as filterGlobalCookie, y as isParamDisabled } from "./operation-code-sample-ZUTueV3v.js";
import { t as getResolvedUrl } from "./get-resolved-url-BUCwrBzc.js";
import { t as SectionFilter_default } from "./SectionFilter-hrtoRLwj.js";
import { t as ViewLayoutSection_default } from "./ViewLayoutSection-mUqKbQry.js";
import { t as CodeInput_default } from "./code-input-iq-moLxi.js";
import { a as DataTableCheckbox_default, i as DataTableHeader_default, n as DataTableRow_default, o as DataTableCell_default, s as DataTable_default } from "./data-table-PL7e8NRO.js";
import { t as CollapsibleSection_default } from "./layout-BWiL7dfb.js";
import { n as AuthSelector_default } from "./scalar-auth-selector-block-DI3DLag9.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, normalizeClass, openBlock, ref, renderList, resolveDynamicComponent, toDisplayString, toHandlers, unref, useId, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
import { ScalarButton, ScalarCodeBlock, ScalarCombobox, ScalarErrorBoundary, ScalarIcon, ScalarIconButton, ScalarListbox, ScalarMarkdown, ScalarPopover, ScalarTooltip } from "@scalar/components";
import { ScalarIconCaretDown, ScalarIconGlobe, ScalarIconInfo, ScalarIconTrash, ScalarIconWarning } from "@scalar/icons";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { isObject } from "@scalar/helpers/object/is-object";
import { unpackProxyObject } from "@scalar/workspace-store/helpers/unpack-proxy";
import { canMethodHaveBody } from "@scalar/helpers/http/can-method-have-body";
import { resolve } from "@scalar/workspace-store/resolve";
import { REGEX } from "@scalar/helpers/regex/regex-helpers";
import { CONTENT_TYPES } from "@scalar/helpers/consts/content-types";
import { objectEntries } from "@scalar/helpers/object/object-entries";
import { isObjectSchema } from "@scalar/workspace-store/schemas/v3.1/strict/type-guards";
//#region src/v2/blocks/operation-block/helpers/get-selected-body-content-type.ts
/**
* Returns the selected body content type for the given request body and exampleKey.
* Priority:
*   1. requestBody?.['x-scalar-selected-content-type']?.[exampleKey] (if set)
*   2. First key in requestBody?.content (if available)
*   3. null (if none available)
*/
var getSelectedBodyContentType = (requestBody, exampleKey = "default") => {
	return requestBody?.["x-scalar-selected-content-type"]?.[exampleKey] ?? Object.keys(requestBody?.content ?? {})[0] ?? null;
};
//#endregion
//#region src/v2/blocks/request-block/helpers/get-request-body-example.ts
/**
* Basically getExample + we generate an example from the schema if no example is found
*/
var getExampleFromBody = (requestBody, contentType, exampleKey) => {
	const content = requestBody.content?.[contentType];
	const example = getExample(requestBody, exampleKey, contentType);
	if (example) return example;
	const schema = getResolvedRef(content?.schema);
	if (!schema) return null;
	const schemaExample = getExampleFromSchema(schema, { mode: "write" });
	if (!schemaExample) return null;
	return { value: schemaExample };
};
//#endregion
//#region src/v2/blocks/request-block/helpers/files.ts
/**
* Extract file name from an input
*/
var getFileName = (input) => {
	if (input instanceof File) return input.name;
};
//#endregion
//#region src/v2/blocks/request-block/helpers/validate-parameter.ts
/**
* Checks if the value of a example parameter is the expected type or format
*/
var validateParameter = (schema, value) => {
	if (!schema || !("type" in schema) || typeof value !== "string") return { ok: true };
	if (schema.type === "integer" || schema.type === "number") {
		const numberValue = Number(value);
		if (isNaN(numberValue)) return {
			ok: false,
			message: "Value must be a number (e.g., 42.5)"
		};
		if (schema.type === "integer" && !Number.isInteger(numberValue)) return {
			ok: false,
			message: "Value must be a whole number (e.g., 42)"
		};
		if (schema.minimum !== void 0 && numberValue < schema.minimum) return {
			ok: false,
			message: `Value must be ${schema.minimum} or greater`
		};
		if (schema.maximum !== void 0 && numberValue > schema.maximum) return {
			ok: false,
			message: `Value must be ${schema.maximum} or less`
		};
	}
	if (schema.type === "string" && schema.format) {
		if (schema.format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value ?? "")) return {
			ok: false,
			message: "Please enter a valid date in YYYY-MM-DD format (e.g., 2024-03-20)"
		};
		if (schema.format === "date-time" && !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(value ?? "")) return {
			ok: false,
			message: "Please enter a valid date and time in RFC 3339 format (e.g., 2024-03-20T13:45:30Z)"
		};
		if (schema.format === "email" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value ?? "")) return {
			ok: false,
			message: "Please enter a valid email address (e.g., user@example.com)"
		};
		if (schema.format === "uri" && !/^[a-zA-Z][a-zA-Z0-9+.-]*:.+$/.test(value ?? "")) return {
			ok: false,
			message: "Please enter a valid URI (e.g., https://example.com)"
		};
	}
	return { ok: true };
};
//#endregion
//#region src/v2/blocks/request-block/components/RequestTableTooltip.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$5 = ["aria-label", "role"];
var _hoisted_2$5 = { class: "w-content text-xxs text-c-1 grid min-w-48 gap-1.5 rounded px-1.5 pt-2 pb-1.5 leading-none" };
var _hoisted_3$2 = {
	key: 0,
	class: "text-error-1"
};
var _hoisted_4$1 = {
	key: 1,
	class: "schema text-c-2 flex items-center"
};
var _hoisted_5$1 = { key: 0 };
var _hoisted_6 = { key: 1 };
var _hoisted_7 = { key: 2 };
var _hoisted_8 = { key: 3 };
var _hoisted_9 = { key: 4 };
//#endregion
//#region src/v2/blocks/request-block/components/RequestTableTooltip.vue
var RequestTableTooltip_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestTableTooltip",
	props: {
		schema: {},
		value: {},
		description: {}
	},
	setup(__props) {
		const invalidParameterMessage = computed(() => validateParameter(__props.schema, __props.value));
		const isInvalid = computed(() => invalidParameterMessage.value.ok === false);
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(ScalarPopover), {
				offset: 4,
				placement: "left",
				teleport: ""
			}, {
				popover: withCtx(() => [createElementVNode("div", _hoisted_2$5, [invalidParameterMessage.value.ok === false ? (openBlock(), createElementBlock("div", _hoisted_3$2, toDisplayString(invalidParameterMessage.value.message), 1)) : __props.schema && ("type" in __props.schema || "format" in __props.schema || "minimum" in __props.schema || "maximum" in __props.schema || "default" in __props.schema) ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
					"type" in __props.schema ? (openBlock(), createElementBlock("span", _hoisted_5$1, toDisplayString(__props.schema.type), 1)) : createCommentVNode("", true),
					"format" in __props.schema ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(__props.schema.format), 1)) : createCommentVNode("", true),
					"minimum" in __props.schema ? (openBlock(), createElementBlock("span", _hoisted_7, "min: " + toDisplayString(__props.schema.minimum), 1)) : createCommentVNode("", true),
					"maximum" in __props.schema ? (openBlock(), createElementBlock("span", _hoisted_8, "max: " + toDisplayString(__props.schema.maximum), 1)) : createCommentVNode("", true),
					"default" in __props.schema ? (openBlock(), createElementBlock("span", _hoisted_9, "default: " + toDisplayString(__props.schema.default), 1)) : createCommentVNode("", true)
				])) : createCommentVNode("", true), __props.description && !isInvalid.value ? (openBlock(), createBlock(unref(ScalarMarkdown), {
					key: 2,
					class: "max-w-[16rem]",
					value: __props.description
				}, null, 8, ["value"])) : createCommentVNode("", true)])]),
				default: withCtx(() => [createElementVNode("button", {
					"aria-label": isInvalid.value ? "Input is invalid" : "More Information",
					class: "text-c-2 hover:text-c-1 hover:bg-b-2 rounded p-1",
					role: isInvalid.value ? "alert" : "none",
					type: "button"
				}, [isInvalid.value ? (openBlock(), createBlock(unref(ScalarIconWarning), {
					key: 0,
					class: "text-orange size-3.5 brightness-90 hover:brightness-75"
				})) : (openBlock(), createBlock(unref(ScalarIconInfo), {
					key: 1,
					class: "text-c-2 hover:text-c-1 size-3.5"
				}))], 8, _hoisted_1$5)]),
				_: 1
			});
		};
	}
}), [["__scopeId", "data-v-f2ab7aa3"]]);
//#endregion
//#region src/v2/blocks/request-block/components/RequestTableRow.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$4 = { class: "text-c-2 filemask flex w-full max-w-[100%] items-center justify-center overflow-hidden p-1" };
var _hoisted_2$4 = {
	key: 1,
	class: "p-0.5"
};
//#endregion
//#region src/v2/blocks/request-block/components/RequestTableRow.vue
var RequestTableRow_default = /* @__PURE__ */ defineComponent({
	__name: "RequestTableRow",
	props: {
		data: {},
		hasCheckboxDisabled: { type: Boolean },
		invalidParams: {},
		label: {},
		environment: {},
		showUploadButton: { type: Boolean }
	},
	emits: [
		"upsertRow",
		"deleteRow",
		"uploadFile",
		"removeFile",
		"navigate"
	],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		/**
		* Track local state for the row
		*
		* Now this is required because of the way we get default values from the schema.
		* If we have a default value in data.value, then we update isDisabled to true. We lose the default value since now
		* we have an example where value: ''. This is why we need to track the local state and update all of the params at the
		* same time.
		*/
		const name = ref(__props.data.name ?? "");
		const value = ref(unpackProxyObject(__props.data.value) ?? "");
		const isDisabled = ref(__props.data.isDisabled ?? false);
		watch(() => __props.data.name, (newName) => name.value = newName ?? "");
		watch(() => __props.data.value, (newValue) => value.value = unpackProxyObject(newValue) ?? "");
		watch(() => __props.data.isDisabled, (newIsDisabled) => isDisabled.value = newIsDisabled ?? false);
		/** Check if the value is a File instance */
		const isFile = computed(() => value.value instanceof File);
		/** Display value handles File instances and shows filename instead */
		const displayValue = computed(() => (isFile.value ? getFileName(value.value) : value.value) ?? "");
		const defaultValue = computed(() => __props.data.schema?.default);
		/** See if we can extract enum values from the schema */
		const enumValue = computed(() => {
			if (!__props.data.schema) return [];
			if (__props.data.schema.enum) return __props.data.schema.enum.map((item) => String(item));
			if ("items" in __props.data.schema) {
				const resolved = resolve.schema(__props.data.schema.items);
				if (resolved?.enum) return resolved.enum.map((item) => String(item));
			}
			return [];
		});
		const minimumValue = computed(() => __props.data.schema && "minimum" in __props.data.schema ? __props.data.schema.minimum : void 0);
		const maximumValue = computed(() => __props.data.schema && "maximum" in __props.data.schema ? __props.data.schema.maximum : void 0);
		const typeValue = computed(() => __props.data.schema && "type" in __props.data.schema ? __props.data.schema.type : void 0);
		const validationResult = computed(() => validateParameter(__props.data.schema, value.value));
		/** Handle row updates while preserving existing properties */
		const handleUpdateRow = (payload) => {
			if (payload.name !== void 0) name.value = payload.name;
			if (payload.value !== void 0) value.value = payload.value;
			isDisabled.value = payload.isDisabled ?? false;
			emit("upsertRow", {
				name: name.value,
				value: value.value,
				isDisabled: isDisabled.value
			});
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(DataTableRow_default), {
				id: __props.data.name,
				class: normalizeClass({
					alert: validationResult.value.ok === false,
					error: validationResult.value.ok === false && __props.invalidParams?.has(__props.data.name)
				})
			}, {
				default: withCtx(() => [
					createVNode(unref(DataTableCheckbox_default), {
						class: "!border-r",
						disabled: __props.hasCheckboxDisabled ?? false,
						modelValue: !isDisabled.value,
						"onUpdate:modelValue": _cache[0] || (_cache[0] = (v) => handleUpdateRow({ isDisabled: !v }))
					}, null, 8, ["disabled", "modelValue"]),
					createVNode(unref(DataTableCell_default), null, {
						default: withCtx(() => [createVNode(unref(CodeInput_default), {
							"aria-label": `${__props.label} Key`,
							disableCloseBrackets: "",
							disabled: __props.data.isReadonly,
							disableEnter: "",
							disableTabIndent: "",
							environment: __props.environment,
							lineWrapping: "",
							modelValue: name.value,
							placeholder: "Key",
							required: Boolean(__props.data.isRequired),
							onSelectVariable: _cache[1] || (_cache[1] = (v) => handleUpdateRow({ name: v })),
							"onUpdate:modelValue": _cache[2] || (_cache[2] = (v) => handleUpdateRow({ name: v }))
						}, null, 8, [
							"aria-label",
							"disabled",
							"environment",
							"modelValue",
							"required"
						])]),
						_: 1
					}),
					createVNode(unref(DataTableCell_default), null, {
						default: withCtx(() => [createVNode(unref(CodeInput_default), {
							"aria-label": `${__props.label} Value`,
							class: "pr-6 group-hover:pr-10 group-has-[.cm-focused]:pr-10",
							default: defaultValue.value,
							disableCloseBrackets: "",
							disabled: __props.data.isReadonly,
							disableEnter: "",
							disableTabIndent: "",
							enum: enumValue.value,
							environment: __props.environment,
							examples: __props.data.schema?.examples?.map((example) => String(example)) ?? [],
							linethrough: __props.data.isOverridden,
							lineWrapping: "",
							max: maximumValue.value,
							min: minimumValue.value,
							modelValue: displayValue.value,
							placeholder: "Value",
							type: typeValue.value,
							"onUpdate:modelValue": _cache[5] || (_cache[5] = (v) => handleUpdateRow({ value: v }))
						}, {
							icon: withCtx(() => [
								Boolean(__props.data.name || value.value) && !__props.data.isRequired && __props.data.isReadonly !== true ? (openBlock(), createBlock(unref(ScalarButton), {
									key: 0,
									class: "text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 hidden h-fit rounded p-1 group-hover:flex group-has-[.cm-focused]:flex",
									size: "sm",
									variant: "ghost",
									onClick: _cache[3] || (_cache[3] = ($event) => emit("deleteRow"))
								}, {
									default: withCtx(() => [createVNode(unref(ScalarIconTrash), { class: "size-3.5" })]),
									_: 1
								})) : createCommentVNode("", true),
								__props.data.globalRoute !== void 0 ? (openBlock(), createBlock(unref(ScalarIconButton), {
									key: 1,
									class: "text-c-2 hover:text-c-1 hover:bg-b-2 z-context -mr-0.5 h-fit",
									icon: unref(ScalarIconGlobe),
									label: "Global cookies are shared across the whole workspace. Click to navigate.",
									size: "xs",
									tooltip: "top",
									variant: "ghost",
									onClick: _cache[4] || (_cache[4] = ($event) => emit("navigate", __props.data.globalRoute))
								}, null, 8, ["icon"])) : createCommentVNode("", true),
								__props.data.isReadonly ? (openBlock(), createBlock(RequestTableTooltip_default, {
									key: 2,
									description: "This is a readonly property and you can not modify it! If you want to change it you have to override it or disable it using the checkbox",
									value: null
								})) : __props.data.schema ? (openBlock(), createBlock(RequestTableTooltip_default, {
									key: 3,
									description: __props.data.description,
									schema: __props.data.schema,
									value: value.value
								}, null, 8, [
									"description",
									"schema",
									"value"
								])) : createCommentVNode("", true)
							]),
							_: 1
						}, 8, [
							"aria-label",
							"default",
							"disabled",
							"enum",
							"environment",
							"examples",
							"linethrough",
							"max",
							"min",
							"modelValue",
							"type"
						])]),
						_: 1
					}),
					__props.showUploadButton ? (openBlock(), createBlock(unref(DataTableCell_default), {
						key: 0,
						class: "group/upload flex items-center justify-center whitespace-nowrap"
					}, {
						default: withCtx(() => [isFile.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("div", _hoisted_1$4, [createElementVNode("span", null, toDisplayString(displayValue.value), 1)]), createElementVNode("button", {
							class: "bg-b-2 centered-x centered-y absolute hidden w-[calc(100%_-_8px)] rounded p-0.5 text-center text-xs font-medium group-hover/upload:block",
							type: "button",
							onClick: _cache[6] || (_cache[6] = ($event) => emit("removeFile"))
						}, " Delete ")], 64)) : (openBlock(), createElementBlock("div", _hoisted_2$4, [createVNode(unref(ScalarButton), {
							class: "bg-b-2 hover:bg-b-3 text-c-2 h-fit border-0 py-px shadow-none",
							size: "sm",
							variant: "outlined",
							onClick: _cache[7] || (_cache[7] = ($event) => emit("uploadFile"))
						}, {
							default: withCtx(() => [_cache[8] || (_cache[8] = createElementVNode("span", null, "Select File", -1)), createVNode(unref(ScalarIcon), {
								class: "ml-1",
								icon: "Upload",
								size: "xs",
								thickness: "2.5"
							})]),
							_: 1
						})]))]),
						_: 1
					})) : createCommentVNode("", true)
				]),
				_: 1
			}, 8, ["id", "class"]);
		};
	}
});
//#endregion
//#region src/v2/blocks/request-block/components/RequestTable.vue
var RequestTable_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestTable",
	props: {
		data: {},
		hasCheckboxDisabled: { type: Boolean },
		invalidParams: {},
		label: {},
		showUploadButton: { type: Boolean },
		showAddRowPlaceholder: {
			type: Boolean,
			default: true
		},
		environment: {}
	},
	emits: [
		"upsertRow",
		"deleteRow",
		"uploadFile",
		"removeFile",
		"navigate"
	],
	setup(__props, { emit: __emit }) {
		/**
		* Make this component more generic that can be used also for the operation body
		*/
		const emit = __emit;
		const columns = computed(() => {
			if (__props.showUploadButton) return [
				"36px",
				"",
				"",
				"auto"
			];
			return [
				"36px",
				"",
				""
			];
		});
		/** Add the last empty row (for ui purposes only) */
		const displayData = computed(() => {
			if (!__props.showAddRowPlaceholder) return __props.data;
			const last = __props.data.at(-1);
			if (!last || last.name !== "" || last.value !== "") return [...__props.data, {
				name: "",
				value: "",
				isDisabled: true
			}];
			return __props.data;
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(DataTable_default), {
				class: "group/table flex-1",
				columns: columns.value
			}, {
				default: withCtx(() => [createVNode(unref(DataTableRow_default), { class: "sr-only !block" }, {
					default: withCtx(() => [
						createVNode(unref(DataTableHeader_default), null, {
							default: withCtx(() => [createTextVNode(toDisplayString(__props.label) + " Enabled", 1)]),
							_: 1
						}),
						createVNode(unref(DataTableHeader_default), null, {
							default: withCtx(() => [createTextVNode(toDisplayString(__props.label) + " Key", 1)]),
							_: 1
						}),
						createVNode(unref(DataTableHeader_default), null, {
							default: withCtx(() => [createTextVNode(toDisplayString(__props.label) + " Value", 1)]),
							_: 1
						})
					]),
					_: 1
				}), (openBlock(true), createElementBlock(Fragment, null, renderList(displayData.value, (row, index) => {
					return openBlock(), createBlock(RequestTableRow_default, {
						key: index,
						data: row,
						environment: __props.environment,
						hasCheckboxDisabled: __props.hasCheckboxDisabled,
						invalidParams: __props.invalidParams,
						label: __props.label,
						showUploadButton: __props.showUploadButton,
						onDeleteRow: ($event) => emit("deleteRow", index),
						onNavigate: _cache[0] || (_cache[0] = (route) => emit("navigate", route)),
						onRemoveFile: ($event) => emit("removeFile", index),
						onUploadFile: ($event) => emit("uploadFile", index),
						onUpsertRow: (payload) => emit("upsertRow", index, payload)
					}, null, 8, [
						"data",
						"environment",
						"hasCheckboxDisabled",
						"invalidParams",
						"label",
						"showUploadButton",
						"onDeleteRow",
						"onRemoveFile",
						"onUploadFile",
						"onUpsertRow"
					]);
				}), 128))]),
				_: 1
			}, 8, ["columns"]);
		};
	}
}), [["__scopeId", "data-v-36811e28"]]);
//#endregion
//#region src/v2/blocks/request-block/helpers/get-form-body-rows.ts
/** Build the table rows for the form data, optionally enriched with schema (e.g. enum) per property */
var getFormBodyRows = (example, contentType, formBodySchema) => {
	if (!example?.value || contentType !== "multipart/form-data" && contentType !== "application/x-www-form-urlencoded") return [];
	const schemaWithProperties = formBodySchema && isObjectSchema(formBodySchema) ? formBodySchema : void 0;
	const requiredSet = schemaWithProperties ? new Set(schemaWithProperties.required ?? []) : void 0;
	const mapRow = ({ name, value, isDisabled = false }) => {
		const row = {
			name,
			value,
			isDisabled
		};
		if (!schemaWithProperties || !name) return row;
		const propSchema = resolve.schema(schemaWithProperties.properties?.[name]);
		row.schema = propSchema;
		row.description = propSchema?.description;
		row.isRequired = requiredSet?.has(name);
		row.isDisabled = isDisabled;
		return row;
	};
	if (Array.isArray(example.value)) return example.value.map((exampleValue) => {
		if (isObject(exampleValue)) return mapRow({
			name: String(exampleValue.name),
			value: exampleValue.value instanceof File ? exampleValue.value : String(exampleValue.value),
			isDisabled: Boolean(exampleValue.isDisabled)
		});
		return {
			name: "",
			value: exampleValue,
			isDisabled: false
		};
	});
	if (typeof example.value === "object" && example.value) return objectEntries(example.value).map(([key, value]) => mapRow({
		name: String(key),
		value
	}));
	return [];
};
//#endregion
//#region src/v2/blocks/request-block/components/RequestBodyForm.vue
var RequestBodyForm_default = /* @__PURE__ */ defineComponent({
	__name: "RequestBodyForm",
	props: {
		example: {},
		bodySchema: {},
		selectedContentType: {},
		environment: {}
	},
	emits: ["update:formValue"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		/** Local state for form body rows */
		const localFormBodyRows = ref([]);
		/** Sync the local form body rows with the example and schema */
		watch(() => [
			__props.example,
			__props.bodySchema,
			__props.selectedContentType
		], ([newExample, schema, contentType]) => {
			localFormBodyRows.value = getFormBodyRows(newExample, contentType, schema);
		}, { immediate: true });
		const handleUpdateFormValue = (rows) => {
			emit("update:formValue", rows.map((row) => ({
				name: row.name,
				value: row.value,
				isDisabled: row.isDisabled ?? false
			})));
		};
		/** Update a row in the table, combines with the previous data so we emit a whole row */
		const handleUpsertRow = (index, payload) => {
			if (index >= localFormBodyRows.value.length) {
				localFormBodyRows.value = [...localFormBodyRows.value, {
					name: "",
					value: "",
					...payload,
					isDisabled: false
				}];
				handleUpdateFormValue(localFormBodyRows.value);
				return;
			}
			localFormBodyRows.value = localFormBodyRows.value.map((row, i) => i === index ? {
				...row,
				...payload
			} : row);
			handleUpdateFormValue(localFormBodyRows.value);
		};
		/** Delete a row from the table */
		const handleDeleteRow = (index) => {
			localFormBodyRows.value = localFormBodyRows.value.filter((_, i) => i !== index);
			handleUpdateFormValue(localFormBodyRows.value);
		};
		/** Handle file upload for a specific row index */
		const handleFileUpload = (index) => {
			const { open } = useFileDialog({
				onChange: (files) => {
					const file = files?.[0];
					if (file) {
						const currentRow = localFormBodyRows.value[index];
						handleUpsertRow(index, {
							name: currentRow?.name || file.name,
							value: file
						});
					}
				},
				multiple: false,
				accept: "*/*"
			});
			open();
		};
		return (_ctx, _cache) => {
			return __props.selectedContentType === "multipart/form-data" ? (openBlock(), createBlock(RequestTable_default, {
				key: 0,
				data: localFormBodyRows.value,
				environment: __props.environment,
				showUploadButton: "",
				onDeleteRow: handleDeleteRow,
				onRemoveFile: _cache[0] || (_cache[0] = (index) => handleUpsertRow(index, { value: void 0 })),
				onUploadFile: handleFileUpload,
				onUpsertRow: handleUpsertRow
			}, null, 8, ["data", "environment"])) : (openBlock(), createBlock(RequestTable_default, {
				key: 1,
				data: localFormBodyRows.value,
				environment: __props.environment,
				onDeleteRow: handleDeleteRow,
				onUpsertRow: handleUpsertRow
			}, null, 8, ["data", "environment"]));
		};
	}
});
//#endregion
//#region src/v2/blocks/request-block/components/RequestBody.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$3 = {
	key: 0,
	class: "text-c-3 flex min-h-10 w-full items-center justify-center border-t p-2 text-sm"
};
var _hoisted_2$3 = {
	key: 1,
	class: "flex items-center justify-center overflow-hidden border-t p-1.5"
};
var _hoisted_3$1 = { class: "text-c-2 w-full max-w-full overflow-hidden rounded border px-1.5 py-1 text-xs whitespace-nowrap" };
//#endregion
//#region src/v2/blocks/request-block/components/RequestBody.vue
var RequestBody_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestBody",
	props: {
		requestBody: {},
		exampleKey: {},
		title: {},
		environment: {}
	},
	emits: [
		"update:contentType",
		"update:value",
		"update:formValue"
	],
	setup(__props, { emit: __emit }) {
		const emits = __emit;
		const contentTypeToLanguageMap = {
			"application/json": "json",
			"application/xml": "xml",
			"application/yaml": "yaml"
		};
		/** Selected content type with default */
		const selectedContentType = computed(() => getSelectedBodyContentType(__props.requestBody, __props.exampleKey) ?? "none");
		/** Convert content types to options for the dropdown */
		const contentTypeOptions = objectEntries(CONTENT_TYPES).map(([id, label]) => ({
			id,
			label
		}));
		const selectedContentTypeModel = computed({
			get: () => {
				return contentTypeOptions.find((it) => it.id === selectedContentType.value) ?? contentTypeOptions.at(-1);
			},
			set: (v) => {
				emits("update:contentType", { value: v.id });
			}
		});
		function handleFileUpload(callback) {
			const { open } = useFileDialog({
				onChange: (files) => {
					const file = files?.[0];
					if (file) callback(file);
				},
				multiple: false,
				accept: "*/*"
			});
			open();
		}
		/** Dereferenced example */
		const example = computed(() => __props.requestBody && getExampleFromBody(__props.requestBody, selectedContentType.value, __props.exampleKey));
		/** Convert the example value to a string for the code editor */
		const bodyValue = computed(() => {
			if (!example.value) return "";
			const value = example.value.value;
			if (typeof value === "string") return value;
			return JSON.stringify(value, null, 2);
		});
		/** Resolved schema for the request body */
		const bodySchema = computed(() => {
			return resolve.schema(__props.requestBody?.content?.[selectedContentType.value]?.schema);
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(CollapsibleSection_default), null, {
				title: withCtx(() => [createTextVNode(toDisplayString(__props.title), 1)]),
				default: withCtx(() => [createVNode(unref(DataTable_default), {
					columns: [""],
					presentational: ""
				}, {
					default: withCtx(() => [createVNode(unref(DataTableHeader_default), { class: "relative col-span-full flex h-8 cursor-pointer items-center justify-between border-r-0 !p-0" }, {
						default: withCtx(() => [createVNode(unref(ScalarListbox), {
							modelValue: selectedContentTypeModel.value,
							"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedContentTypeModel.value = $event),
							options: unref(contentTypeOptions),
							teleport: ""
						}, {
							default: withCtx(() => [createVNode(unref(ScalarButton), {
								class: "text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-3 font-normal",
								fullWidth: "",
								variant: "ghost"
							}, {
								default: withCtx(() => [createElementVNode("span", null, toDisplayString(unref(CONTENT_TYPES)[selectedContentType.value] ?? selectedContentType.value), 1), createVNode(unref(ScalarIcon), {
									icon: "ChevronDown",
									size: "md"
								})]),
								_: 1
							})]),
							_: 1
						}, 8, ["modelValue", "options"])]),
						_: 1
					}), createVNode(unref(DataTableRow_default), null, {
						default: withCtx(() => [selectedContentType.value === "none" ? (openBlock(), createElementBlock("div", _hoisted_1$3, [..._cache[5] || (_cache[5] = [createElementVNode("span", null, "No Body", -1)])])) : selectedContentType.value === "application/octet-stream" ? (openBlock(), createElementBlock("div", _hoisted_2$3, [unref(getFileName)(unref(unpackProxyObject)(example.value?.value)) !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createElementVNode("span", _hoisted_3$1, toDisplayString(unref(getFileName)(unref(unpackProxyObject)(example.value?.value))), 1), createVNode(unref(ScalarButton), {
							class: "bg-b-2 hover:bg-b-3 text-c-2 ml-1 border-0 shadow-none",
							size: "sm",
							variant: "outlined",
							onClick: _cache[1] || (_cache[1] = ($event) => emits("update:value", {
								payload: void 0,
								contentType: selectedContentType.value
							}))
						}, {
							default: withCtx(() => [..._cache[6] || (_cache[6] = [createTextVNode(" Delete ", -1)])]),
							_: 1
						})], 64)) : (openBlock(), createBlock(unref(ScalarButton), {
							key: 1,
							class: "bg-b-2 hover:bg-b-3 text-c-2 border-0 shadow-none",
							size: "sm",
							variant: "outlined",
							onClick: _cache[2] || (_cache[2] = () => handleFileUpload((file) => emits("update:value", {
								payload: file,
								contentType: selectedContentType.value
							})))
						}, {
							default: withCtx(() => [_cache[7] || (_cache[7] = createElementVNode("span", null, "Select File", -1)), createVNode(unref(ScalarIcon), {
								class: "ml-1",
								icon: "Upload",
								size: "xs",
								thickness: "2.5"
							})]),
							_: 1
						}))])) : selectedContentType.value === "multipart/form-data" || selectedContentType.value === "application/x-www-form-urlencoded" ? (openBlock(), createBlock(RequestBodyForm_default, {
							key: 2,
							bodySchema: bodySchema.value,
							environment: __props.environment,
							example: example.value,
							selectedContentType: selectedContentType.value,
							"onUpdate:formValue": _cache[3] || (_cache[3] = (payload) => emits("update:formValue", {
								payload,
								contentType: selectedContentType.value
							}))
						}, null, 8, [
							"bodySchema",
							"environment",
							"example",
							"selectedContentType"
						])) : (openBlock(), createBlock(unref(CodeInput_default), {
							key: 3,
							class: "border-t px-3",
							content: "",
							environment: __props.environment,
							language: contentTypeToLanguageMap[selectedContentType.value] ?? "plaintext",
							lineNumbers: "",
							lint: "",
							modelValue: bodyValue.value,
							"onUpdate:modelValue": _cache[4] || (_cache[4] = (value) => emits("update:value", {
								payload: value,
								contentType: selectedContentType.value
							}))
						}, null, 8, [
							"environment",
							"language",
							"modelValue"
						]))]),
						_: 1
					})]),
					_: 1
				})]),
				_: 1
			});
		};
	}
}), [["__scopeId", "data-v-0fdec6da"]]);
//#endregion
//#region src/v2/blocks/request-block/components/RequestCodeSnippet.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$2 = { class: "flex flex-1" };
var _hoisted_2$2 = { class: "overflow-hidden" };
//#endregion
//#region src/v2/blocks/request-block/components/RequestCodeSnippet.vue
var RequestCodeSnippet_default = /* @__PURE__ */ defineComponent({
	__name: "RequestCodeSnippet",
	props: {
		integration: {},
		clientOptions: {},
		selectedClient: {},
		selectedServer: { default: null },
		selectedContentType: {},
		selectedExample: {},
		eventBus: {},
		securitySchemes: {},
		method: {},
		path: {},
		operation: {},
		fallback: { type: Boolean },
		generateLabel: { type: Function },
		isWebhook: { type: Boolean },
		globalCookies: {}
	},
	setup(__props) {
		/** Grab any custom code samples from the operation */
		const customCodeSamples = computed(() => getCustomCodeSamples(__props.operation));
		/** Merge custom code samples with the client options */
		const clients = computed(() => getClients(customCodeSamples.value, __props.clientOptions));
		/**
		* The locally selected client which would include code samples from this operation only
		* Must be local state because it contains custom code samples from this operation only
		*/
		const localSelectedClient = ref(findClient(clients.value, __props.selectedClient));
		/** If the globally selected client changes we can update the local one */
		watch(() => __props.selectedClient, (newClient) => {
			const client = findClient(clients.value, newClient);
			if (client) localSelectedClient.value = client;
		});
		/** Block secrets from being shown in the code block */
		const secretCredentials = computed(() => getSecrets(__props.securitySchemes ?? []));
		/** Handle client change */
		const handleClientChange = (option) => {
			localSelectedClient.value = option;
			if (option && !option.id.startsWith("custom")) __props.eventBus.emit("workspace:update:selected-client", option.id);
		};
		/** Generate the code snippet for the selected example */
		const generatedCode = computed(() => generateCodeSnippet({
			clientId: localSelectedClient.value?.id,
			customCodeSamples: customCodeSamples.value,
			operation: __props.operation,
			method: __props.method,
			path: __props.path,
			contentType: __props.selectedContentType,
			server: __props.selectedServer,
			securitySchemes: __props.securitySchemes,
			example: __props.selectedExample,
			globalCookies: __props.globalCookies,
			includeDefaultHeaders: __props.integration === "client"
		}));
		/** Check if there are any clients available (built-in or custom code samples) */
		const hasClients = computed(() => clients.value.some((group) => group.options.length > 0));
		return (_ctx, _cache) => {
			return withDirectives((openBlock(), createBlock(unref(CollapsibleSection_default), {
				class: "group/preview w-full border-t",
				defaultOpen: false
			}, {
				title: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode("Code Snippet", -1)])]),
				actions: withCtx(() => [createElementVNode("div", _hoisted_1$2, [createVNode(unref(ScalarCombobox), {
					modelValue: localSelectedClient.value,
					options: clients.value,
					placement: "bottom-end",
					"onUpdate:modelValue": _cache[0] || (_cache[0] = (ev) => handleClientChange(ev))
				}, {
					default: withCtx(({ open }) => [createVNode(unref(ScalarButton), {
						class: "text-c-2 hover:text-c-1 flex h-full w-fit gap-1.5 px-0.5 py-0 text-base font-normal",
						"data-testid": "client-picker",
						variant: "ghost"
					}, {
						default: withCtx(() => [createTextVNode(toDisplayString(localSelectedClient.value?.title) + " ", 1), createVNode(unref(ScalarIconCaretDown), {
							class: normalizeClass(["mt-0.25 size-3 transition-transform duration-100", open && "rotate-180"]),
							weight: "bold"
						}, null, 8, ["class"])]),
						_: 2
					}, 1024)]),
					_: 1
				}, 8, ["modelValue", "options"])])]),
				default: withCtx(() => [createVNode(unref(ScalarErrorBoundary), null, {
					default: withCtx(() => [createVNode(unref(DataTable_default), {
						columns: [""],
						presentational: ""
					}, {
						default: withCtx(() => [createVNode(unref(DataTableRow_default), null, {
							default: withCtx(() => [createElementVNode("div", _hoisted_2$2, [createVNode(unref(ScalarCodeBlock), {
								class: "text-base",
								content: generatedCode.value,
								hideCredentials: secretCredentials.value,
								lang: localSelectedClient.value?.lang ?? "plaintext",
								lineNumbers: ""
							}, null, 8, [
								"content",
								"hideCredentials",
								"lang"
							])])]),
							_: 1
						})]),
						_: 1
					})]),
					_: 1
				})]),
				_: 1
			}, 512)), [[vShow, hasClients.value]]);
		};
	}
});
//#endregion
//#region src/v2/blocks/request-block/components/RequestParams.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$1 = { class: "text-c-2 request-meta-buttons flex whitespace-nowrap opacity-0 group-hover/params:opacity-100 has-[:focus-visible]:opacity-100" };
var _hoisted_2$1 = { class: "sr-only" };
//#endregion
//#region src/v2/blocks/request-block/components/RequestParams.vue
var RequestParams_default = /* @__PURE__ */ defineComponent({
	__name: "RequestParams",
	props: {
		rows: {},
		exampleKey: {},
		title: {},
		label: {},
		invalidParams: {},
		globalRoute: {},
		showAddRowPlaceholder: {
			type: Boolean,
			default: true
		},
		environment: {},
		eventBus: {}
	},
	emits: [
		"upsert",
		"delete",
		"deleteAll"
	],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const showTooltip = computed(() => __props.rows.length > 1);
		/** Needed for type guard */
		const handleUpserRow = (index, payload) => {
			const { value, ...rest } = payload;
			if (value instanceof File) return;
			emit("upsert", index, {
				...rest,
				value: value ?? ""
			});
		};
		return (_ctx, _cache) => {
			return openBlock(), createBlock(unref(CollapsibleSection_default), {
				class: "group/params",
				itemCount: __props.rows.length
			}, {
				title: withCtx(() => [createTextVNode(toDisplayString(__props.title), 1)]),
				actions: withCtx(() => [createElementVNode("div", _hoisted_1$1, [showTooltip.value ? (openBlock(), createBlock(unref(ScalarTooltip), {
					key: 0,
					content: "Clear optional parameters",
					placement: "left"
				}, {
					default: withCtx(() => [createVNode(unref(ScalarButton), {
						class: "pr-0.75 pl-1 transition-none",
						size: "sm",
						variant: "ghost",
						onClick: _cache[0] || (_cache[0] = withModifiers(($event) => emit("deleteAll"), ["stop"]))
					}, {
						default: withCtx(() => [_cache[3] || (_cache[3] = createTextVNode(" Clear ", -1)), createElementVNode("span", _hoisted_2$1, "All " + toDisplayString(__props.title), 1)]),
						_: 1
					})]),
					_: 1
				})) : createCommentVNode("", true)])]),
				default: withCtx(() => [createVNode(RequestTable_default, {
					class: "flex-1",
					columns: [
						"32px",
						"",
						""
					],
					data: __props.rows,
					environment: __props.environment,
					exampleKey: __props.exampleKey,
					globalRoute: __props.globalRoute,
					invalidParams: __props.invalidParams,
					label: __props.label,
					showAddRowPlaceholder: __props.showAddRowPlaceholder,
					onDeleteRow: _cache[1] || (_cache[1] = (index) => emit("delete", { index })),
					onNavigate: _cache[2] || (_cache[2] = (route) => __props.eventBus.emit("ui:navigate", route)),
					onUpsertRow: handleUpserRow
				}, null, 8, [
					"data",
					"environment",
					"exampleKey",
					"globalRoute",
					"invalidParams",
					"label",
					"showAddRowPlaceholder"
				])]),
				_: 1
			}, 8, ["itemCount"]);
		};
	}
});
//#endregion
//#region src/v2/blocks/request-block/helpers/create-parameter-handlers.ts
/** Create parameter event handlers for a given type */
var createParameterHandlers = (type, eventBus, meta, { context, defaultParameters = 0, globalParameters = 0 }) => {
	const offset = defaultParameters + globalParameters;
	return {
		delete: (payload) => {
			const originalParameter = context[payload.index]?.originalParameter;
			if (!originalParameter) return;
			eventBus.emit("operation:delete:parameter", {
				originalParameter,
				meta
			}, { skipUnpackProxy: true });
		},
		deleteAll: () => eventBus.emit("operation:delete-all:parameters", {
			type,
			meta
		}),
		upsert: (index, payload) => {
			const row = context[index];
			if (index < defaultParameters + globalParameters) {
				const extraParameterType = index < defaultParameters ? "default" : "global";
				return eventBus.emit("operation:update:extra-parameters", {
					type: extraParameterType,
					in: type,
					meta: {
						...meta,
						name: row?.name?.toLowerCase?.() ?? "NON_VALID"
					},
					payload: { isDisabled: payload.isDisabled ?? false }
				});
			}
			if (index >= offset) return eventBus.emit("operation:upsert:parameter", {
				type,
				payload,
				originalParameter: row?.originalParameter ?? null,
				meta
			}, {
				skipUnpackProxy: true,
				debounceKey: `update:parameter-${type}-${index - offset}`
			});
		}
	};
};
//#endregion
//#region src/v2/blocks/request-block/helpers/get-parameter-content.ts
/**
* Extract content value from parameter object
*
* Parameters MUST only have one specified content key
*/
var getParameterContentValue = (parameter) => {
	if ("content" in parameter && parameter.content) {
		const keys = Object.keys(parameter.content);
		if (keys.length !== 1) return;
		return parameter.content[keys[0]];
	}
};
//#endregion
//#region src/v2/blocks/request-block/helpers/get-parameter-schema.ts
/**
* Extract the schema from the parameter object
*/
var getParameterSchema = (parameter) => {
	if ("schema" in parameter && parameter.schema) return getResolvedRef(parameter.schema);
	return getResolvedRef(getParameterContentValue(parameter)?.schema);
};
//#endregion
//#region src/v2/blocks/request-block/helpers/group-by.ts
/**
* Group together array objects by a specific key
*/
var groupBy = (arr, key, transform) => {
	return arr.reduce((acc, obj) => {
		const transformedItem = transform ? transform(obj) : obj;
		(acc[obj[key]] ??= []).push(transformedItem);
		return acc;
	}, {});
};
//#endregion
//#region src/v2/blocks/request-block/RequestBlock.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "group pointer-events-none flex flex-1 items-center gap-1 lg:pr-24" };
var _hoisted_2 = ["for"];
var _hoisted_3 = [
	"id",
	"placeholder",
	"value"
];
var _hoisted_4 = {
	key: 2,
	class: "text-c-1 flex h-8 items-center"
};
var _hoisted_5 = ["id", "role"];
//#endregion
//#region src/v2/blocks/request-block/RequestBlock.vue
var RequestBlock_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "RequestBlock",
	props: {
		authMeta: { default: () => ({ type: "document" }) },
		clientOptions: {},
		environment: {},
		eventBus: {},
		exampleKey: {},
		globalCookies: {},
		layout: {},
		method: {},
		operation: {},
		path: {},
		plugins: {},
		proxyUrl: {},
		securityRequirements: {},
		securitySchemes: {},
		selectedClient: {},
		selectedSecurity: {},
		selectedSecuritySchemes: {},
		server: {}
	},
	setup(__props) {
		/** Operation metadata used across event emissions */
		const meta = computed(() => ({
			method: __props.method,
			path: __props.path,
			exampleKey: __props.exampleKey
		}));
		/** Parameters grouped by type (path, query, header, cookie) */
		const sections = computed(() => groupBy(__props.operation.parameters?.map((param) => getResolvedRef(param)) ?? [], "in", (param) => {
			const example = getExample(param, __props.exampleKey, void 0);
			return {
				name: param.name,
				value: example?.value ?? "",
				description: param.description,
				schema: getParameterSchema(param),
				isRequired: param.required,
				isDisabled: isParamDisabled(param, example),
				originalParameter: param
			};
		}));
		const headersMap = computed(() => groupBy(sections.value.header?.map((it) => ({
			...it,
			name: it.name.toLowerCase()
		})) ?? [], "name"));
		const autoGeneratedHeaders = computed(() => getDefaultHeaders({
			method: __props.method,
			operation: __props.operation,
			exampleKey: __props.exampleKey
		}));
		const defaultHeaders = computed(() => {
			const disableParameters = __props.operation["x-scalar-disable-parameters"]?.["default-headers"]?.[__props.exampleKey] ?? {};
			return autoGeneratedHeaders.value.map((it) => {
				const realHeader = headersMap.value[it.name.toLowerCase()]?.[0];
				return {
					name: it.name,
					value: it.defaultValue,
					schema: void 0,
					isOverridden: realHeader && !realHeader?.isDisabled,
					isReadonly: true,
					isDisabled: disableParameters[it.name.toLowerCase()] ?? false
				};
			});
		});
		const headers = computed(() => [...defaultHeaders.value, ...sections.value.header ?? []]);
		const defaultCookies = computed(() => {
			const resolvedUrl = getResolvedUrl({
				environment: __props.environment,
				server: __props.server,
				path: __props.path,
				pathVariables: {}
			});
			const disabledGlobalCookies = __props.operation["x-scalar-disable-parameters"]?.["global-cookies"]?.[__props.exampleKey] ?? {};
			return __props.globalCookies?.filter((cookie) => filterGlobalCookie({
				cookie,
				url: resolvedUrl,
				disabledGlobalCookies: {}
			})).map((it) => ({
				name: it.name,
				value: it.value,
				globalRoute: it.location === "document" ? {
					page: "document",
					path: "cookies"
				} : {
					page: "workspace",
					path: "cookies"
				},
				isReadonly: true,
				isDisabled: disabledGlobalCookies[it.name.toLowerCase()] ?? false
			})) ?? [];
		});
		const cookies = computed(() => [...defaultCookies.value ?? [], ...sections.value.cookie ?? []]);
		/** Currently selected filter for the request sections */
		const selectedFilter = ref("All");
		/** Available operation sections */
		const OPERATION_SECTIONS = [
			"Auth",
			"Variables",
			"Cookies",
			"Headers",
			"Query",
			"Body"
		];
		/**
		* Pre-generated stable IDs for all possible filter sections.
		* These are created once at setup time to avoid regenerating IDs on re-render.
		*/
		const sectionIds = {
			All: useId(),
			Auth: useId(),
			Variables: useId(),
			Cookies: useId(),
			Headers: useId(),
			Query: useId(),
			Body: useId()
		};
		/** Filters available based on operation state */
		const filters = computed(() => {
			const availableFilters = new Set(["All", ...OPERATION_SECTIONS]);
			if (!sections.value.path?.length) availableFilters.delete("Variables");
			if (!canMethodHaveBody(__props.method)) availableFilters.delete("Body");
			if (isAuthHidden.value) availableFilters.delete("Auth");
			return [...availableFilters];
		});
		/**
		* Map available filters to their pre-generated stable IDs.
		* Only includes IDs for filters that are currently available.
		*/
		const filterIds = computed(() => Object.fromEntries(filters.value.map((section) => [section, sectionIds[section]])));
		/**
		* Hide auth selector in readonly mode when no security schemes are defined.
		* This keeps the UI clean when there are no authentication options available.
		*/
		const isAuthHidden = computed(() => __props.layout === "modal" && !Object.keys(__props.securitySchemes ?? {}).length);
		/**
		* Keep auth available for unauthenticated operations, but collapse it by default
		* in readonly modal layouts unless a requirement or manual selection exists.
		*/
		const isAuthDefaultOpen = computed(() => __props.layout !== "modal" || Boolean(__props.securityRequirements?.length || __props.selectedSecurity.selectedSchemes.length));
		/** Get a sensible placeholder for the request name input */
		const requestNamePlaceholder = computed(() => {
			if (__props.operation.summary) return __props.operation.summary;
			return __props.path.replace(REGEX.PROTOCOL, "") || "Request Name";
		});
		/** Check if the section should be shown based on the selected filter */
		const isSectionVisible = (section) => {
			return selectedFilter.value === "All" || selectedFilter.value === section;
		};
		/**
		* Reset filter to 'All' if Body filter is selected but method changes to one that cannot have a body.
		* This prevents showing an empty Body section when switching methods.
		*/
		watch(() => __props.method, (newMethod) => {
			if (selectedFilter.value === "Body" && !canMethodHaveBody(newMethod)) selectedFilter.value = "All";
		});
		/** Handle operation summary updates */
		const handleSummaryUpdate = (event) => {
			const summary = event.target.value;
			__props.eventBus.emit("operation:update:meta", {
				meta: meta.value,
				payload: { summary: summary.trim() }
			});
		};
		/** Parameter handlers */
		const parameterHandlers = computed(() => ({
			path: createParameterHandlers("path", __props.eventBus, meta.value, { context: sections.value.path ?? [] }),
			cookie: createParameterHandlers("cookie", __props.eventBus, meta.value, {
				context: cookies.value ?? [],
				globalParameters: defaultCookies.value.length
			}),
			header: createParameterHandlers("header", __props.eventBus, meta.value, {
				context: headers.value,
				defaultParameters: defaultHeaders.value.length
			}),
			query: createParameterHandlers("query", __props.eventBus, meta.value, { context: sections.value.query ?? [] })
		}));
		/** Handle request body content type update */
		const handleUpdateContentType = (payload) => __props.eventBus.emit("operation:update:requestBody:contentType", {
			payload: { contentType: payload.value },
			meta: meta.value
		});
		/** Handle request body value update */
		const handleUpdateBodyValue = ({ payload, contentType }) => {
			const debounceKey = typeof payload === "string" ? `update:requestBody:value-${contentType}` : void 0;
			__props.eventBus.emit("operation:update:requestBody:value", {
				payload,
				contentType,
				meta: meta.value
			}, { debounceKey });
		};
		/** Handle request body value update */
		const handleUpdateBodyFormValue = ({ payload, contentType }) => {
			const debounceKey = `update:requestBody:${contentType}-form-value`;
			__props.eventBus.emit("operation:update:requestBody:formValue", {
				payload: payload.map((row) => unpackProxyObject(row, { depth: 1 })),
				contentType,
				meta: meta.value
			}, { debounceKey });
		};
		const labelRequestNameId = useId();
		/** Allow updating the operation extensions for the plugins */
		const updateOperationExtension = (payload) => __props.eventBus.emit("operation:update:extension", {
			payload,
			meta: meta.value
		});
		return (_ctx, _cache) => {
			return openBlock(), createBlock(ViewLayoutSection_default, { "aria-label": `Request: ${__props.operation.summary}` }, {
				title: withCtx(() => [createElementVNode("div", _hoisted_1, [__props.layout !== "modal" ? (openBlock(), createElementBlock("label", {
					key: 0,
					class: "pointer-events-auto absolute top-0 left-0 h-full w-full cursor-text opacity-0",
					for: unref(labelRequestNameId)
				}, null, 8, _hoisted_2)) : createCommentVNode("", true), __props.layout !== "modal" ? (openBlock(), createElementBlock("input", {
					key: 1,
					id: unref(labelRequestNameId),
					class: "text-c-1 group-hover-input pointer-events-auto relative z-10 -ml-0.5 h-8 w-full rounded pl-1.25 has-[:focus-visible]:outline md:-ml-1.25",
					placeholder: requestNamePlaceholder.value,
					value: __props.operation.summary,
					onBlur: handleSummaryUpdate
				}, null, 40, _hoisted_3)) : (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(__props.operation.summary), 1))]), createVNode(SectionFilter_default, {
					modelValue: selectedFilter.value,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedFilter.value = $event),
					filterIds: filterIds.value,
					filters: filters.value
				}, null, 8, [
					"modelValue",
					"filterIds",
					"filters"
				])]),
				default: withCtx(() => [createElementVNode("div", {
					id: filterIds.value.All,
					class: "request-section-content custom-scroll relative flex flex-1 flex-col",
					role: selectedFilter.value === "All" ? "tabpanel" : "none"
				}, [
					withDirectives(createVNode(unref(AuthSelector_default), {
						id: filterIds.value.Auth,
						createAnySecurityScheme: __props.layout !== "modal",
						defaultOpen: isAuthDefaultOpen.value,
						environment: __props.environment,
						eventBus: __props.eventBus,
						meta: __props.authMeta,
						proxyUrl: __props.proxyUrl,
						securityRequirements: __props.securityRequirements,
						securitySchemes: __props.securitySchemes,
						selectedSecurity: __props.selectedSecurity,
						selectedSecuritySchemes: __props.selectedSecuritySchemes,
						server: __props.server,
						title: "Authentication"
					}, null, 8, [
						"id",
						"createAnySecurityScheme",
						"defaultOpen",
						"environment",
						"eventBus",
						"meta",
						"proxyUrl",
						"securityRequirements",
						"securitySchemes",
						"selectedSecurity",
						"selectedSecuritySchemes",
						"server"
					]), [[vShow, isSectionVisible("Auth") && !isAuthHidden.value]]),
					withDirectives(createVNode(RequestParams_default, mergeProps({
						id: filterIds.value.Variables,
						environment: __props.environment,
						eventBus: __props.eventBus,
						exampleKey: __props.exampleKey,
						rows: sections.value.path ?? [],
						showAddRowPlaceholder: false,
						title: "Variables"
					}, toHandlers(parameterHandlers.value.path)), null, 16, [
						"id",
						"environment",
						"eventBus",
						"exampleKey",
						"rows"
					]), [[vShow, isSectionVisible("Variables") && sections.value.path?.length]]),
					withDirectives(createVNode(RequestParams_default, mergeProps({
						id: filterIds.value.Cookies,
						environment: __props.environment,
						eventBus: __props.eventBus,
						exampleKey: __props.exampleKey,
						rows: cookies.value ?? [],
						showAddRowPlaceholder: true,
						title: "Cookies"
					}, toHandlers(parameterHandlers.value.cookie)), null, 16, [
						"id",
						"environment",
						"eventBus",
						"exampleKey",
						"rows"
					]), [[vShow, isSectionVisible("Cookies")]]),
					withDirectives(createVNode(RequestParams_default, mergeProps({
						id: filterIds.value.Headers,
						environment: __props.environment,
						eventBus: __props.eventBus,
						exampleKey: __props.exampleKey,
						rows: headers.value ?? [],
						title: "Headers"
					}, toHandlers(parameterHandlers.value.header)), null, 16, [
						"id",
						"environment",
						"eventBus",
						"exampleKey",
						"rows"
					]), [[vShow, isSectionVisible("Headers")]]),
					withDirectives(createVNode(RequestParams_default, mergeProps({
						id: filterIds.value.Query,
						environment: __props.environment,
						eventBus: __props.eventBus,
						exampleKey: __props.exampleKey,
						rows: sections.value.query ?? [],
						title: "Query Parameters"
					}, toHandlers(parameterHandlers.value.query)), null, 16, [
						"id",
						"environment",
						"eventBus",
						"exampleKey",
						"rows"
					]), [[vShow, isSectionVisible("Query")]]),
					withDirectives(createVNode(RequestBody_default, {
						id: filterIds.value.Body,
						environment: __props.environment,
						exampleKey: __props.exampleKey,
						requestBody: unref(getResolvedRef)(__props.operation.requestBody),
						title: "Request Body",
						"onUpdate:contentType": handleUpdateContentType,
						"onUpdate:formValue": handleUpdateBodyFormValue,
						"onUpdate:value": handleUpdateBodyValue
					}, null, 8, [
						"id",
						"environment",
						"exampleKey",
						"requestBody"
					]), [[vShow, isSectionVisible("Body") && unref(canMethodHaveBody)(__props.method)]]),
					(openBlock(true), createElementBlock(Fragment, null, renderList(__props.plugins, (plugin, index) => {
						return openBlock(), createBlock(unref(ScalarErrorBoundary), { key: index }, {
							default: withCtx(() => [plugin?.components?.request ? withDirectives((openBlock(), createBlock(resolveDynamicComponent(plugin.components.request.component), mergeProps({
								key: 0,
								operation: __props.operation
							}, { ref_for: true }, plugin.components.request.additionalProps, { "onOperation:update:extension": updateOperationExtension }), null, 16, ["operation"])), [[vShow, selectedFilter.value === "All"]]) : createCommentVNode("", true)]),
							_: 2
						}, 1024);
					}), 128)),
					_cache[1] || (_cache[1] = createElementVNode("div", { class: "flex grow" }, null, -1)),
					withDirectives(createVNode(RequestCodeSnippet_default, {
						clientOptions: __props.clientOptions,
						eventBus: __props.eventBus,
						globalCookies: __props.globalCookies,
						integration: "client",
						method: __props.method,
						operation: __props.operation,
						path: __props.path,
						securitySchemes: __props.selectedSecuritySchemes,
						selectedClient: __props.selectedClient,
						selectedContentType: unref(getResolvedRef)(__props.operation.requestBody)?.["x-scalar-selected-content-type"]?.[__props.exampleKey],
						selectedServer: __props.server ?? void 0
					}, null, 8, [
						"clientOptions",
						"eventBus",
						"globalCookies",
						"method",
						"operation",
						"path",
						"securitySchemes",
						"selectedClient",
						"selectedContentType",
						"selectedServer"
					]), [[vShow, selectedFilter.value === "All"]])
				], 8, _hoisted_5)]),
				_: 1
			}, 8, ["aria-label"]);
		};
	}
}), [["__scopeId", "data-v-98af86fe"]]);
//#endregion
export { getExampleFromBody as n, getSelectedBodyContentType as r, RequestBlock_default as t };

//# sourceMappingURL=request-block-DwsGy64Q.js.map