import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper-BmmBcIzD.js";
import { i as useEditor, t as useJsonPointerLinkSupport } from "./editor-BZ_J0eze.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, nextTick, normalizeClass, onBeforeUnmount, onMounted, openBlock, ref, renderList, shallowRef, toDisplayString, toValue, unref, watch, withCtx } from "vue";
import { ScalarButton, ScalarHotkey, ScalarLoading, ScalarToggle, useLoadingState } from "@scalar/components";
import { ScalarIconArrowsIn, ScalarIconArrowsOut, ScalarIconCaretDown, ScalarIconCaretRight, ScalarIconWarning, ScalarIconXCircle } from "@scalar/icons";
import { isMap, isPair, isScalar, isSeq, parse, parseDocument, stringify } from "yaml";
import { isObject } from "@scalar/helpers/object/is-object";
import { isHttpMethod } from "@scalar/helpers/http/is-http-method";
import * as monaco$1 from "monaco-editor";
import { debounce } from "@scalar/helpers/general/debounce";
import * as monaco from "monaco-editor/esm/vs/editor/editor.api.js";
import { configureMonacoYaml } from "monaco-yaml";
//#region src/v2/features/editor/helpers/json/json-ast.ts
/**
* Traverses the AST of a JSON document to find the node at the provided JsonPath.
* Returns undefined if the path does not exist in the AST.
*
* @param node - The root AST node to begin traversal from.
* @param path - The path to traverse within the AST, as an array of keys/indices.
* @returns The AST node at the specified path, or undefined if not found.
*/
var getJsonAstNodeAtPath = (node, path) => {
	let current = node;
	for (const segment of path) {
		if (!current) return;
		if (current.type === "object") {
			const key = String(segment);
			current = current.properties.find((p) => p.keyNode.value === key)?.valueNode;
			continue;
		}
		if (current.type === "array") {
			const index = typeof segment === "number" ? segment : Number.parseInt(String(segment), 10);
			if (!Number.isFinite(index) || index < 0 || index >= current.items.length) return;
			current = current.items[index];
			continue;
		}
		return;
	}
	return current;
};
//#endregion
//#region src/v2/features/editor/helpers/json/get-json-ast-node-from-path.ts
/**
* Retrieves a JSON AST node from a Monaco editor model at the specified JSON path.
*
* Utilizes Monaco's JSON worker to parse the document and returns the AST node
* located at the given path, or null if not found.
*
* @param model - The Monaco editor text model representing the JSON document.
* @param path - The JSON path to locate the AST node.
* @returns A promise resolving to the AST node at the path, or null if not found.
*/
var getJsonAstNodeFromPath = async (model, path) => {
	const jsonDocument = await (await (await monaco$1.languages.json.getWorker())(model.uri)).parseJSONDocument(model.uri.toString());
	if (!jsonDocument?.root) return null;
	return getJsonAstNodeAtPath(jsonDocument.root, path) ?? null;
};
var openapi_3_1_schema_default = {
	$id: "https://spec.openapis.org/oas/3.1/schema/2025-11-23",
	$schema: "https://json-schema.org/draft/2020-12/schema",
	description: "The description of OpenAPI v3.1.x Documents without Schema Object validation",
	type: "object",
	properties: {
		"openapi": {
			"type": "string",
			"pattern": "^3\\.1\\.\\d+(-.+)?$"
		},
		"info": { "$ref": "#/$defs/info" },
		"jsonSchemaDialect": {
			"type": "string",
			"format": "uri-reference",
			"default": "https://spec.openapis.org/oas/3.1/dialect/2024-11-10"
		},
		"servers": {
			"type": "array",
			"items": { "$ref": "#/$defs/server" },
			"default": [{ "url": "/" }]
		},
		"paths": { "$ref": "#/$defs/paths" },
		"webhooks": {
			"type": "object",
			"additionalProperties": { "$ref": "#/$defs/path-item" }
		},
		"components": { "$ref": "#/$defs/components" },
		"security": {
			"type": "array",
			"items": { "$ref": "#/$defs/security-requirement" }
		},
		"tags": {
			"type": "array",
			"items": { "$ref": "#/$defs/tag" }
		},
		"externalDocs": { "$ref": "#/$defs/external-documentation" }
	},
	required: ["openapi", "info"],
	anyOf: [
		{ "required": ["paths"] },
		{ "required": ["components"] },
		{ "required": ["webhooks"] }
	],
	$ref: "#/$defs/specification-extensions",
	unevaluatedProperties: false,
	$defs: /* @__PURE__ */ JSON.parse("{\"info\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#info-object\",\"type\":\"object\",\"properties\":{\"title\":{\"type\":\"string\"},\"summary\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"termsOfService\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"contact\":{\"$ref\":\"#/$defs/contact\"},\"license\":{\"$ref\":\"#/$defs/license\"},\"version\":{\"type\":\"string\"}},\"required\":[\"title\",\"version\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"contact\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#contact-object\",\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"url\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"email\":{\"type\":\"string\",\"format\":\"email\"}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"license\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#license-object\",\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"identifier\":{\"type\":\"string\"},\"url\":{\"type\":\"string\",\"format\":\"uri-reference\"}},\"required\":[\"name\"],\"dependentSchemas\":{\"identifier\":{\"not\":{\"required\":[\"url\"]}}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"server\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#server-object\",\"type\":\"object\",\"properties\":{\"url\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"variables\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/server-variable\"}}},\"required\":[\"url\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"server-variable\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#server-variable-object\",\"type\":\"object\",\"properties\":{\"enum\":{\"type\":\"array\",\"items\":{\"type\":\"string\"},\"minItems\":1},\"default\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"}},\"required\":[\"default\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"components\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#components-object\",\"type\":\"object\",\"properties\":{\"schemas\":{\"type\":\"object\",\"additionalProperties\":{\"$dynamicRef\":\"#meta\"}},\"responses\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/response-or-reference\"}},\"parameters\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/parameter-or-reference\"}},\"examples\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/example-or-reference\"}},\"requestBodies\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/request-body-or-reference\"}},\"headers\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/header-or-reference\"}},\"securitySchemes\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/security-scheme-or-reference\"}},\"links\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/link-or-reference\"}},\"callbacks\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/callbacks-or-reference\"}},\"pathItems\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/path-item\"}}},\"patternProperties\":{\"^(?:schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems)$\":{\"$comment\":\"Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected\",\"propertyNames\":{\"pattern\":\"^[a-zA-Z0-9._-]+$\"}}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"paths\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#paths-object\",\"type\":\"object\",\"patternProperties\":{\"^/\":{\"$ref\":\"#/$defs/path-item\"},\"^x-\":true},\"additionalProperties\":false},\"path-item\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#path-item-object\",\"type\":\"object\",\"properties\":{\"$ref\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"summary\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"servers\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/$defs/server\"}},\"parameters\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/$defs/parameter-or-reference\"}},\"get\":{\"$ref\":\"#/$defs/operation\"},\"put\":{\"$ref\":\"#/$defs/operation\"},\"post\":{\"$ref\":\"#/$defs/operation\"},\"delete\":{\"$ref\":\"#/$defs/operation\"},\"options\":{\"$ref\":\"#/$defs/operation\"},\"head\":{\"$ref\":\"#/$defs/operation\"},\"patch\":{\"$ref\":\"#/$defs/operation\"},\"trace\":{\"$ref\":\"#/$defs/operation\"}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"operation\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#operation-object\",\"type\":\"object\",\"properties\":{\"tags\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"summary\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"externalDocs\":{\"$ref\":\"#/$defs/external-documentation\"},\"operationId\":{\"type\":\"string\"},\"parameters\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/$defs/parameter-or-reference\"}},\"requestBody\":{\"$ref\":\"#/$defs/request-body-or-reference\"},\"responses\":{\"$ref\":\"#/$defs/responses\"},\"callbacks\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/callbacks-or-reference\"}},\"deprecated\":{\"default\":false,\"type\":\"boolean\"},\"security\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/$defs/security-requirement\"}},\"servers\":{\"type\":\"array\",\"items\":{\"$ref\":\"#/$defs/server\"}}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"external-documentation\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#external-documentation-object\",\"type\":\"object\",\"properties\":{\"description\":{\"type\":\"string\"},\"url\":{\"type\":\"string\",\"format\":\"uri-reference\"}},\"required\":[\"url\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"parameter\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#parameter-object\",\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"in\":{\"enum\":[\"query\",\"header\",\"path\",\"cookie\"]},\"description\":{\"type\":\"string\"},\"required\":{\"default\":false,\"type\":\"boolean\"},\"deprecated\":{\"default\":false,\"type\":\"boolean\"},\"schema\":{\"$dynamicRef\":\"#meta\"},\"content\":{\"$ref\":\"#/$defs/content\",\"minProperties\":1,\"maxProperties\":1}},\"required\":[\"name\",\"in\"],\"oneOf\":[{\"required\":[\"schema\"]},{\"required\":[\"content\"]}],\"if\":{\"properties\":{\"in\":{\"const\":\"query\"}}},\"then\":{\"properties\":{\"allowEmptyValue\":{\"default\":false,\"type\":\"boolean\"}}},\"dependentSchemas\":{\"schema\":{\"properties\":{\"style\":{\"type\":\"string\"},\"explode\":{\"type\":\"boolean\"}},\"allOf\":[{\"$ref\":\"#/$defs/examples\"},{\"$ref\":\"#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path\"},{\"$ref\":\"#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header\"},{\"$ref\":\"#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query\"},{\"$ref\":\"#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie\"}],\"$defs\":{\"styles-for-path\":{\"if\":{\"properties\":{\"in\":{\"const\":\"path\"}}},\"then\":{\"properties\":{\"name\":{\"pattern\":\"^[^{}]+$\"},\"style\":{\"default\":\"simple\",\"enum\":[\"matrix\",\"label\",\"simple\"]},\"required\":{\"const\":true},\"explode\":{\"default\":false}},\"required\":[\"required\"]}},\"styles-for-header\":{\"if\":{\"properties\":{\"in\":{\"const\":\"header\"}}},\"then\":{\"properties\":{\"style\":{\"default\":\"simple\",\"const\":\"simple\"},\"explode\":{\"default\":false}}}},\"styles-for-query\":{\"if\":{\"properties\":{\"in\":{\"const\":\"query\"}}},\"then\":{\"properties\":{\"style\":{\"default\":\"form\",\"enum\":[\"form\",\"spaceDelimited\",\"pipeDelimited\",\"deepObject\"]},\"allowReserved\":{\"default\":false,\"type\":\"boolean\"}},\"$ref\":\"#/$defs/explode-for-form\"}},\"styles-for-cookie\":{\"if\":{\"properties\":{\"in\":{\"const\":\"cookie\"}}},\"then\":{\"properties\":{\"style\":{\"default\":\"form\",\"const\":\"form\"}},\"$ref\":\"#/$defs/explode-for-form\"}}}}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"parameter-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/parameter\"}},\"request-body\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#request-body-object\",\"type\":\"object\",\"properties\":{\"description\":{\"type\":\"string\"},\"content\":{\"$ref\":\"#/$defs/content\"},\"required\":{\"default\":false,\"type\":\"boolean\"}},\"required\":[\"content\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"request-body-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/request-body\"}},\"content\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#fixed-fields-10\",\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/media-type\"},\"propertyNames\":{\"format\":\"media-range\"}},\"media-type\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#media-type-object\",\"type\":\"object\",\"properties\":{\"schema\":{\"$dynamicRef\":\"#meta\"},\"encoding\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/encoding\"}}},\"allOf\":[{\"$ref\":\"#/$defs/specification-extensions\"},{\"$ref\":\"#/$defs/examples\"}],\"unevaluatedProperties\":false},\"encoding\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#encoding-object\",\"type\":\"object\",\"properties\":{\"contentType\":{\"type\":\"string\",\"format\":\"media-range\"},\"headers\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/header-or-reference\"}},\"style\":{\"enum\":[\"form\",\"spaceDelimited\",\"pipeDelimited\",\"deepObject\"]},\"explode\":{\"type\":\"boolean\"},\"allowReserved\":{\"type\":\"boolean\"}},\"dependentSchemas\":{\"style\":{\"properties\":{\"allowReserved\":{\"default\":false}},\"$ref\":\"#/$defs/explode-for-form\"},\"explode\":{\"properties\":{\"style\":{\"default\":\"form\"},\"allowReserved\":{\"default\":false}}},\"allowReserved\":{\"properties\":{\"style\":{\"default\":\"form\"}},\"$ref\":\"#/$defs/explode-for-form\"}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"responses\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#responses-object\",\"type\":\"object\",\"properties\":{\"default\":{\"$ref\":\"#/$defs/response-or-reference\"}},\"patternProperties\":{\"^[1-5](?:[0-9]{2}|XX)$\":{\"$ref\":\"#/$defs/response-or-reference\"}},\"minProperties\":1,\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false,\"if\":{\"$comment\":\"either default, or at least one response code property must exist\",\"patternProperties\":{\"^[1-5](?:[0-9]{2}|XX)$\":false}},\"then\":{\"required\":[\"default\"]}},\"response\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#response-object\",\"type\":\"object\",\"properties\":{\"description\":{\"type\":\"string\"},\"headers\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/header-or-reference\"}},\"content\":{\"$ref\":\"#/$defs/content\"},\"links\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/link-or-reference\"}}},\"required\":[\"description\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"response-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/response\"}},\"callbacks\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#callback-object\",\"type\":\"object\",\"$ref\":\"#/$defs/specification-extensions\",\"additionalProperties\":{\"$ref\":\"#/$defs/path-item\"}},\"callbacks-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/callbacks\"}},\"example\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#example-object\",\"type\":\"object\",\"properties\":{\"summary\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"value\":true,\"externalValue\":{\"type\":\"string\",\"format\":\"uri-reference\"}},\"not\":{\"required\":[\"value\",\"externalValue\"]},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"example-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/example\"}},\"link\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#link-object\",\"type\":\"object\",\"properties\":{\"operationRef\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"operationId\":{\"type\":\"string\"},\"parameters\":{\"$ref\":\"#/$defs/map-of-strings\"},\"requestBody\":true,\"description\":{\"type\":\"string\"},\"server\":{\"$ref\":\"#/$defs/server\"}},\"oneOf\":[{\"required\":[\"operationRef\"]},{\"required\":[\"operationId\"]}],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"link-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/link\"}},\"header\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#header-object\",\"type\":\"object\",\"properties\":{\"description\":{\"type\":\"string\"},\"required\":{\"default\":false,\"type\":\"boolean\"},\"deprecated\":{\"default\":false,\"type\":\"boolean\"},\"schema\":{\"$dynamicRef\":\"#meta\"},\"content\":{\"$ref\":\"#/$defs/content\",\"minProperties\":1,\"maxProperties\":1}},\"oneOf\":[{\"required\":[\"schema\"]},{\"required\":[\"content\"]}],\"dependentSchemas\":{\"schema\":{\"properties\":{\"style\":{\"default\":\"simple\",\"const\":\"simple\"},\"explode\":{\"default\":false,\"type\":\"boolean\"}},\"$ref\":\"#/$defs/examples\"}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"header-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/header\"}},\"tag\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#tag-object\",\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"},\"externalDocs\":{\"$ref\":\"#/$defs/external-documentation\"}},\"required\":[\"name\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"reference\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#reference-object\",\"type\":\"object\",\"properties\":{\"$ref\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"summary\":{\"type\":\"string\"},\"description\":{\"type\":\"string\"}}},\"schema\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#schema-object\",\"$dynamicAnchor\":\"meta\",\"type\":[\"object\",\"boolean\"]},\"security-scheme\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#security-scheme-object\",\"type\":\"object\",\"properties\":{\"type\":{\"enum\":[\"apiKey\",\"http\",\"mutualTLS\",\"oauth2\",\"openIdConnect\"]},\"description\":{\"type\":\"string\"}},\"required\":[\"type\"],\"allOf\":[{\"$ref\":\"#/$defs/specification-extensions\"},{\"$ref\":\"#/$defs/security-scheme/$defs/type-apikey\"},{\"$ref\":\"#/$defs/security-scheme/$defs/type-http\"},{\"$ref\":\"#/$defs/security-scheme/$defs/type-http-bearer\"},{\"$ref\":\"#/$defs/security-scheme/$defs/type-oauth2\"},{\"$ref\":\"#/$defs/security-scheme/$defs/type-oidc\"}],\"unevaluatedProperties\":false,\"$defs\":{\"type-apikey\":{\"if\":{\"properties\":{\"type\":{\"const\":\"apiKey\"}}},\"then\":{\"properties\":{\"name\":{\"type\":\"string\"},\"in\":{\"enum\":[\"query\",\"header\",\"cookie\"]}},\"required\":[\"name\",\"in\"]}},\"type-http\":{\"if\":{\"properties\":{\"type\":{\"const\":\"http\"}}},\"then\":{\"properties\":{\"scheme\":{\"type\":\"string\"}},\"required\":[\"scheme\"]}},\"type-http-bearer\":{\"if\":{\"properties\":{\"type\":{\"const\":\"http\"},\"scheme\":{\"type\":\"string\",\"pattern\":\"^[Bb][Ee][Aa][Rr][Ee][Rr]$\"}},\"required\":[\"type\",\"scheme\"]},\"then\":{\"properties\":{\"bearerFormat\":{\"type\":\"string\"}}}},\"type-oauth2\":{\"if\":{\"properties\":{\"type\":{\"const\":\"oauth2\"}}},\"then\":{\"properties\":{\"flows\":{\"$ref\":\"#/$defs/oauth-flows\"}},\"required\":[\"flows\"]}},\"type-oidc\":{\"if\":{\"properties\":{\"type\":{\"const\":\"openIdConnect\"}}},\"then\":{\"properties\":{\"openIdConnectUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"}},\"required\":[\"openIdConnectUrl\"]}}}},\"security-scheme-or-reference\":{\"if\":{\"type\":\"object\",\"required\":[\"$ref\"]},\"then\":{\"$ref\":\"#/$defs/reference\"},\"else\":{\"$ref\":\"#/$defs/security-scheme\"}},\"oauth-flows\":{\"type\":\"object\",\"properties\":{\"implicit\":{\"$ref\":\"#/$defs/oauth-flows/$defs/implicit\"},\"password\":{\"$ref\":\"#/$defs/oauth-flows/$defs/password\"},\"clientCredentials\":{\"$ref\":\"#/$defs/oauth-flows/$defs/client-credentials\"},\"authorizationCode\":{\"$ref\":\"#/$defs/oauth-flows/$defs/authorization-code\"}},\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false,\"$defs\":{\"implicit\":{\"type\":\"object\",\"properties\":{\"authorizationUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"refreshUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"scopes\":{\"$ref\":\"#/$defs/map-of-strings\"}},\"required\":[\"authorizationUrl\",\"scopes\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"password\":{\"type\":\"object\",\"properties\":{\"tokenUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"refreshUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"scopes\":{\"$ref\":\"#/$defs/map-of-strings\"}},\"required\":[\"tokenUrl\",\"scopes\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"client-credentials\":{\"type\":\"object\",\"properties\":{\"tokenUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"refreshUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"scopes\":{\"$ref\":\"#/$defs/map-of-strings\"}},\"required\":[\"tokenUrl\",\"scopes\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false},\"authorization-code\":{\"type\":\"object\",\"properties\":{\"authorizationUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"tokenUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"refreshUrl\":{\"type\":\"string\",\"format\":\"uri-reference\"},\"scopes\":{\"$ref\":\"#/$defs/map-of-strings\"}},\"required\":[\"authorizationUrl\",\"tokenUrl\",\"scopes\"],\"$ref\":\"#/$defs/specification-extensions\",\"unevaluatedProperties\":false}}},\"security-requirement\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#security-requirement-object\",\"type\":\"object\",\"additionalProperties\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"specification-extensions\":{\"$comment\":\"https://spec.openapis.org/oas/v3.1#specification-extensions\",\"patternProperties\":{\"^x-\":true}},\"examples\":{\"properties\":{\"example\":true,\"examples\":{\"type\":\"object\",\"additionalProperties\":{\"$ref\":\"#/$defs/example-or-reference\"}}},\"not\":{\"required\":[\"example\",\"examples\"]}},\"map-of-strings\":{\"type\":\"object\",\"additionalProperties\":{\"type\":\"string\"}},\"explode-for-form\":{\"$comment\":\"for encoding objects, and query and cookie parameters, style=form is the default\",\"if\":{\"properties\":{\"style\":{\"const\":\"form\"}}},\"then\":{\"properties\":{\"explode\":{\"default\":true}}},\"else\":{\"properties\":{\"explode\":{\"default\":false}}}}}")
};
//#endregion
//#region src/v2/features/editor/helpers/configure-language-support.ts
var OPENAPI_JSON_SCHEMA_URI = "inmemory://model/scalar/openapi-json-schema";
/**
* Configures JSON language support for the given model URI
*
* @param globPattern - The glob pattern to match the files to configure language support for
*/
var configureJson = (globPattern) => {
	const defaults = monaco.languages.json.jsonDefaults;
	const current = defaults.diagnosticsOptions;
	const schemas = [...(current.schemas ?? []).filter((s) => s.uri !== OPENAPI_JSON_SCHEMA_URI), {
		uri: OPENAPI_JSON_SCHEMA_URI,
		fileMatch: [globPattern],
		schema: openapi_3_1_schema_default
	}];
	defaults.setDiagnosticsOptions({
		...current,
		validate: true,
		enableSchemaRequest: false,
		schemas
	});
};
/**
* Configures YAML language support for the given model URI
*
* @param globPattern - The glob pattern to match the files to configure language support for
*/
var configureYaml = (globPattern) => {
	configureMonacoYaml(monaco, {
		enableSchemaRequest: false,
		validate: true,
		format: true,
		completion: true,
		hover: true,
		schemas: [{
			fileMatch: [globPattern],
			schema: openapi_3_1_schema_default,
			uri: OPENAPI_JSON_SCHEMA_URI
		}]
	});
};
//#endregion
//#region src/v2/features/editor/helpers/json/create-json-model.ts
/**
* Creates a JSON Monaco editor model with enhanced language support.
*
* @param value - The initial JSON content for the model.
* @returns An object containing the Monaco model and a function to get a range from a JSON path.
*
* The returned `getRangeFromPath` function asynchronously finds the AST node for a JSON path,
* converts its offset and length to a Monaco Range, or returns null if not found.
*/
var createJsonModel = (value) => {
	const model = monaco$1.editor.createModel(value ?? "", "json");
	configureJson(model.uri.toString());
	return {
		model,
		getRangeFromPath: async (path) => {
			const node = await getJsonAstNodeFromPath(model, path);
			if (!node) return null;
			const start = model.getPositionAt(node.offset);
			const end = model.getPositionAt(node.offset + node.length);
			return new monaco$1.Range(start.lineNumber, start.column, end.lineNumber, end.column);
		}
	};
};
//#endregion
//#region src/v2/features/editor/helpers/yaml/get-yaml-node-range-from-path.ts
var isValidYamlRange = (range) => Array.isArray(range) && typeof range[0] === "number" && typeof range[1] === "number";
var safeParseDocument = (yamlText) => {
	try {
		return parseDocument(yamlText);
	} catch {
		return null;
	}
};
/**
* Finds the byte range (offset) in the YAML text corresponding to a JSON path.
* Given a YAML string and a path (array of segments), parses the document and walks
* down the tree to find the target node or key, returning its start and end offsets.
* Will prefer to highlight the "key" part for map entries, to avoid highlighting the value which
* might be offset due to block structure.
*
* @param yamlText The YAML string
* @param path An array representing the path to traverse
* @returns The byte offsets in the YAML string of the node (or null if not found)
*/
var getYamlNodeRangeFromPath = (yamlText, path) => {
	const doc = safeParseDocument(yamlText);
	if (!doc) return null;
	let current = doc.contents;
	let lastPair = null;
	for (const segment of path) {
		if (isMap(current)) {
			const key = String(segment);
			const pair = current.items.find((p) => {
				if (!isPair(p)) return false;
				const pairKey = p.key;
				return isScalar(pairKey) ? String(pairKey.value) === key : String(pairKey) === key;
			});
			if (!pair || !isPair(pair)) return null;
			lastPair = pair;
			current = pair.value;
			continue;
		}
		if (isSeq(current)) {
			const index = typeof segment === "number" ? segment : Number.parseInt(String(segment), 10);
			if (!Number.isFinite(index) || index < 0 || index >= current.items.length) return null;
			lastPair = null;
			current = current.items[index];
			continue;
		}
		return null;
	}
	if (lastPair && isPair(lastPair)) {
		const keyRange = lastPair.key?.range;
		const valueRange = lastPair.value?.range;
		if (!isValidYamlRange(keyRange)) return null;
		const startOffset = Math.max(0, keyRange[0]);
		return {
			startOffset,
			endOffset: isValidYamlRange(valueRange) ? Math.max(startOffset, valueRange[1]) : Math.max(startOffset, keyRange[1])
		};
	}
	const nodeRange = current?.range;
	if (!isValidYamlRange(nodeRange)) return null;
	const startOffset = Math.max(0, nodeRange[0]);
	return {
		startOffset,
		endOffset: Math.max(startOffset, nodeRange[1])
	};
};
//#endregion
//#region src/v2/features/editor/helpers/yaml/create-yaml-model.ts
/**
* Creates a YAML model for use in the Monaco editor.
*
* @param value - The initial YAML string value for the model.
* @returns An object containing the Monaco model and a method to get a range from a YAML path.
*
* The created model is configured for YAML language support.
* The `getRangeFromPath` method returns a Monaco Range object indicating the text range
* that corresponds to a given path in the YAML document, or null if the path is not found.
*/
var createYamlModel = (value) => {
	const model = monaco$1.editor.createModel(value ?? "", "yaml");
	configureYaml(model.uri.toString());
	return {
		model,
		getRangeFromPath: (path) => {
			const range = getYamlNodeRangeFromPath(model.getValue(), path);
			if (!range) return null;
			const start = model.getPositionAt(range.startOffset);
			const end = model.getPositionAt(range.endOffset);
			return new monaco$1.Range(start.lineNumber, start.column, end.lineNumber, end.column);
		}
	};
};
//#endregion
//#region src/v2/features/editor/hooks/use-editor-markers.ts
var useEditorMarkers = (editorRef) => {
	const markers = ref([]);
	let dispose = null;
	const retryTimeouts = [];
	const updateMarkers = () => {
		const resource = toValue(editorRef)?.getModel()?.uri;
		if (!resource) {
			markers.value = [];
			return;
		}
		markers.value = monaco.editor.getModelMarkers({}).filter((marker) => marker.resource.toString() === resource.toString());
	};
	const scheduleMarkerReads = () => {
		retryTimeouts.push(setTimeout(updateMarkers, 0), setTimeout(updateMarkers, 80), setTimeout(updateMarkers, 220));
	};
	onMounted(() => {
		dispose = monaco.editor.onDidChangeMarkers(() => {
			scheduleMarkerReads();
		});
		scheduleMarkerReads();
	});
	onBeforeUnmount(() => {
		dispose?.dispose();
		retryTimeouts.forEach((timeout) => clearTimeout(timeout));
	});
	watch(() => toValue(editorRef)?.getModel()?.uri?.toString(), () => {
		scheduleMarkerReads();
	}, { immediate: true });
	return { markers };
};
//#endregion
//#region src/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$2 = { class: "pointer-events-none absolute right-2 bottom-2 left-2 z-10" };
var _hoisted_2$2 = { class: "bg-b-1 shadow-border pointer-events-auto flex flex-col overflow-hidden rounded-lg text-[11px]" };
var _hoisted_3$2 = { class: "flex items-center gap-3" };
var _hoisted_4$2 = {
	class: "text-c-danger flex items-center gap-1",
	title: "Errors"
};
var _hoisted_5$2 = {
	class: "text-c-alert flex items-center gap-1",
	title: "Warnings"
};
var _hoisted_6$1 = { class: "text-c-3" };
var _hoisted_7$1 = {
	key: 0,
	class: "max-h-28 overflow-auto border-t"
};
var _hoisted_8$1 = ["onClick"];
var _hoisted_9$1 = { class: "min-w-0 flex-1" };
var _hoisted_10$1 = { class: "text-c-1 block truncate" };
var _hoisted_11$1 = { class: "text-c-3 block whitespace-nowrap" };
var _hoisted_12 = {
	key: 1,
	class: "text-c-3 border-t px-2.5 py-2"
};
//#endregion
//#region src/v2/features/collection/components/Editor/components/EditorDiagnosticsPanel.vue
var EditorDiagnosticsPanel_default = /* @__PURE__ */ defineComponent({
	__name: "EditorDiagnosticsPanel",
	props: {
		expanded: { type: Boolean },
		diagnosticCounts: {},
		visibleDiagnostics: {}
	},
	emits: ["toggle", "focusDiagnostic"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const getMarkerDotClass = (severity) => severity === monaco.MarkerSeverity.Error ? "bg-c-danger" : "bg-c-alert";
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$2, [createElementVNode("div", _hoisted_2$2, [createElementVNode("button", {
				class: "bg-b-2/30 hover:bg-b-2/50 flex items-center justify-between px-2.5 py-2 text-left",
				type: "button",
				onClick: _cache[0] || (_cache[0] = ($event) => emit("toggle"))
			}, [createElementVNode("span", _hoisted_3$2, [
				_cache[1] || (_cache[1] = createElementVNode("span", { class: "text-c-2 font-medium" }, "Problems", -1)),
				createElementVNode("span", _hoisted_4$2, [createVNode(unref(ScalarIconXCircle), { class: "size-3" }), createElementVNode("span", null, toDisplayString(__props.diagnosticCounts.errors), 1)]),
				createElementVNode("span", _hoisted_5$2, [createVNode(unref(ScalarIconWarning), { class: "size-3" }), createElementVNode("span", null, toDisplayString(__props.diagnosticCounts.warnings), 1)])
			]), createElementVNode("span", _hoisted_6$1, [__props.expanded ? (openBlock(), createBlock(unref(ScalarIconCaretDown), {
				key: 0,
				class: "size-3"
			})) : (openBlock(), createBlock(unref(ScalarIconCaretRight), {
				key: 1,
				class: "size-3"
			}))])]), __props.expanded ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [__props.visibleDiagnostics.length ? (openBlock(), createElementBlock("div", _hoisted_7$1, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.visibleDiagnostics, (marker, index) => {
				return openBlock(), createElementBlock("button", {
					key: `${marker.owner}-${marker.startLineNumber}-${marker.startColumn}-${index}`,
					class: "hover:bg-b-2/40 flex w-full items-start gap-2 px-2.5 py-2 text-left",
					type: "button",
					onClick: ($event) => emit("focusDiagnostic", marker)
				}, [createElementVNode("span", { class: normalizeClass(["mt-0.5 size-1.5 shrink-0 rounded-full", getMarkerDotClass(marker.severity)]) }, null, 2), createElementVNode("span", _hoisted_9$1, [createElementVNode("span", _hoisted_10$1, toDisplayString(marker.message), 1), createElementVNode("span", _hoisted_11$1, " Ln " + toDisplayString(marker.startLineNumber) + ", Col " + toDisplayString(marker.startColumn), 1)])], 8, _hoisted_8$1);
			}), 128))])) : (openBlock(), createElementBlock("div", _hoisted_12, " Errors and warnings from the JSON/YAML language workers will show up here. "))], 64)) : createCommentVNode("", true)])]);
		};
	}
});
//#endregion
//#region src/v2/features/collection/components/Editor/components/EditorSavePanel.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1$1 = { class: "bg-b-1 pointer-events-auto flex flex-col items-stretch overflow-hidden rounded-lg border shadow-sm" };
var _hoisted_2$1 = { class: "flex items-center gap-2 px-2 py-1.5" };
var _hoisted_3$1 = { class: "min-w-[48px]" };
var _hoisted_4$1 = {
	key: 1,
	class: "text-c-3 flex h-6 items-center justify-center rounded px-2 text-[11px] whitespace-nowrap"
};
var _hoisted_5$1 = {
	key: 0,
	class: "bg-b-2/40 flex items-center gap-2 border-t px-2 py-1 text-[11px]"
};
//#endregion
//#region src/v2/features/collection/components/Editor/components/EditorSavePanel.vue
var EditorSavePanel_default = /* @__PURE__ */ defineComponent({
	__name: "EditorSavePanel",
	props: {
		isAutoSaveEnabled: { type: Boolean },
		isDirty: { type: Boolean },
		saveLoader: {}
	},
	emits: ["update:isAutoSaveEnabled", "saveNow"],
	setup(__props, { emit: __emit }) {
		const emit = __emit;
		const editorStatusText = computed(() => {
			if (!__props.isAutoSaveEnabled && __props.isDirty) return "Unsaved";
			if (!__props.saveLoader.isActive) return null;
			if (__props.saveLoader.isLoading) return "Saving…";
			if (__props.saveLoader.isInvalid) return "Save failed";
			if (__props.saveLoader.isValid) return "Saved";
			return null;
		});
		const shouldShowEditorStatus = computed(() => editorStatusText.value !== null);
		const editorStatusTone = computed(() => {
			if (!shouldShowEditorStatus.value) return null;
			if (!__props.isAutoSaveEnabled && __props.isDirty) return "warning";
			if (__props.saveLoader.isLoading) return "loading";
			if (__props.saveLoader.isInvalid) return "danger";
			if (__props.saveLoader.isValid) return "success";
			return null;
		});
		const editorStatusDotClass = computed(() => {
			switch (editorStatusTone.value) {
				case "warning": return "bg-c-alert";
				case "success": return "bg-c-accent";
				case "danger": return "bg-c-danger";
				default: return "bg-b-3";
			}
		});
		const editorStatusTextClass = computed(() => {
			switch (editorStatusTone.value) {
				case "warning": return "text-c-alert";
				case "success": return "text-c-accent";
				case "danger": return "text-c-danger";
				default: return "text-c-2";
			}
		});
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", _hoisted_1$1, [createElementVNode("div", _hoisted_2$1, [
				_cache[3] || (_cache[3] = createElementVNode("span", { class: "text-c-2 text-[11px] font-medium whitespace-nowrap" }, " Auto-save ", -1)),
				createVNode(unref(ScalarToggle), {
					modelValue: __props.isAutoSaveEnabled,
					"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => emit("update:isAutoSaveEnabled", $event))
				}, null, 8, ["modelValue"]),
				_cache[4] || (_cache[4] = createElementVNode("div", { class: "bg-b-3 mx-1 h-4 w-px" }, null, -1)),
				createElementVNode("div", _hoisted_3$1, [!__props.isAutoSaveEnabled ? (openBlock(), createBlock(unref(ScalarButton), {
					key: 0,
					disabled: !__props.isDirty || __props.saveLoader.isLoading,
					size: "xs",
					variant: "outlined",
					onClick: _cache[1] || (_cache[1] = ($event) => emit("saveNow"))
				}, {
					default: withCtx(() => [..._cache[2] || (_cache[2] = [createTextVNode(" Save ", -1)])]),
					_: 1
				}, 8, ["disabled"])) : (openBlock(), createElementBlock("div", _hoisted_4$1, " Auto "))])
			]), shouldShowEditorStatus.value ? (openBlock(), createElementBlock("div", _hoisted_5$1, [__props.saveLoader.isActive ? (openBlock(), createBlock(unref(ScalarLoading), {
				key: 0,
				class: "self-center",
				loader: __props.saveLoader,
				size: "sm"
			}, null, 8, ["loader"])) : (openBlock(), createElementBlock("span", {
				key: 1,
				class: normalizeClass(["size-1.5 rounded-full", editorStatusDotClass.value])
			}, null, 2)), createElementVNode("span", { class: normalizeClass(["whitespace-nowrap", editorStatusTextClass.value]) }, toDisplayString(editorStatusText.value), 3)])) : createCommentVNode("", true)]);
		};
	}
});
//#endregion
//#region src/v2/features/collection/components/Editor/helpers/get-diagnostic-counts.ts
/**
* This function counts the number of error and warning markers in the provided array of Monaco editor markers.
*
* @param markers - The array of Monaco editor markers to count the errors and warnings for
* @returns An object with the number of errors and warnings
*/
var getDiagnosticCounts = (markers) => {
	let errors = 0;
	let warnings = 0;
	for (const marker of markers) if (marker.severity === monaco.MarkerSeverity.Error) errors += 1;
	else if (marker.severity === monaco.MarkerSeverity.Warning) warnings += 1;
	return {
		errors,
		warnings
	};
};
//#endregion
//#region src/v2/features/collection/components/Editor/helpers/get-operation-context.ts
/**
* Returns an OperationContext if both path is provided and method is a valid HTTP method.
* Returns null otherwise.
*/
var getOperationContext = (path, method) => {
	if (!path || !isHttpMethod(method)) return null;
	return {
		path,
		method
	};
};
//#endregion
//#region src/v2/features/collection/components/Editor/helpers/get-visible-diagnostics.ts
var isVisibleDiagnostic = (marker) => marker.severity === monaco.MarkerSeverity.Error || marker.severity === monaco.MarkerSeverity.Warning;
var compareDiagnostics = (a, b) => {
	if (a.severity !== b.severity) return b.severity - a.severity;
	if (a.startLineNumber !== b.startLineNumber) return a.startLineNumber - b.startLineNumber;
	return a.startColumn - b.startColumn;
};
/**
* Returns up to `maxVisible` diagnostics from the provided markers array,
* filtering to only errors and warnings, sorted by severity and position in the document.
*/
var getVisibleDiagnostics = (markers, maxVisible) => [...markers].filter(isVisibleDiagnostic).sort(compareDiagnostics).slice(0, maxVisible);
//#endregion
//#region src/v2/features/collection/components/Editor/helpers/parse-editor-object.ts
var safeParseJson = (value) => {
	try {
		return JSON.parse(value);
	} catch {
		return null;
	}
};
var safeParseYaml = (value) => {
	try {
		return parse(value);
	} catch {
		return null;
	}
};
/**
* Parses the editor value string in either JSON or YAML format.
* Returns the parsed object if valid and an object, otherwise returns null.
*
* @param value - The input string to parse.
* @param language - The language of the input string, either 'json' or 'yaml'.
* @returns The parsed object if it's valid, or null.
*/
var parseEditorObject = (value, language) => {
	const parsed = language === "yaml" ? safeParseYaml(value) : safeParseJson(value);
	if (!isObject(parsed)) return null;
	return parsed;
};
//#endregion
//#region src/v2/features/collection/components/Editor/helpers/stringify-document.ts
/**
* Stringifies a JavaScript object/document into a formatted string.
* Uses YAML format if language is 'yaml', otherwise uses JSON.
*
* @param document - The JavaScript object to stringify
* @param language - Output language, expected to be either 'json' or 'yaml'
* @returns The stringified document in the specified language
*/
var stringifyDocument = (document, language) => {
	if (language === "yaml") return stringify(document, { indent: 2 });
	return JSON.stringify(document, null, 2);
};
//#endregion
//#region src/v2/features/collection/components/Editor/hooks/use-editor-state.ts
var DIAGNOSTICS_COLLAPSED_BOTTOM_PADDING = 46;
var DIAGNOSTICS_EXPANDED_BOTTOM_PADDING = 155;
var useEditorState = () => {
	const isAutoSaveEnabled = ref(false);
	const isDirty = ref(false);
	const editorLanguage = ref("json");
	const isDiagnosticsPaneExpanded = ref(false);
	const isEditorMaximized = ref(false);
	const isYamlMode = computed(() => editorLanguage.value === "yaml");
	const editorBottomPadding = computed(() => isDiagnosticsPaneExpanded.value ? DIAGNOSTICS_EXPANDED_BOTTOM_PADDING : DIAGNOSTICS_COLLAPSED_BOTTOM_PADDING);
	const editorRootClass = computed(() => isEditorMaximized.value ? "fixed inset-0 z-50 h-screen w-screen border bg-b-1 p-3 mac:pt-12" : "");
	const getLanguageToggleClass = (isActive) => {
		return `rounded-none px-2 py-1 text-[11px] leading-4 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-c-accent/30 focus-visible:ring-offset-1 focus-visible:ring-offset-b-1 first:rounded-md last:rounded-md ${isActive ? "bg-b-2 text-c-1 hover:bg-b-2" : "text-c-2 hover:bg-b-2/60 hover:text-c-1"}`;
	};
	const toggleEditorMaximized = () => {
		isEditorMaximized.value = !isEditorMaximized.value;
	};
	return {
		isAutoSaveEnabled,
		isDirty,
		editorLanguage,
		isDiagnosticsPaneExpanded,
		isEditorMaximized,
		isYamlMode,
		editorBottomPadding,
		editorRootClass,
		getLanguageToggleClass,
		toggleEditorMaximized
	};
};
//#endregion
//#region src/v2/features/collection/components/Editor/Editor.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = { class: "grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-3" };
var _hoisted_2 = { class: "flex min-w-0 items-center gap-1 overflow-x-auto whitespace-nowrap" };
var _hoisted_3 = { class: "text-c-3 ml-2 text-[11px]" };
var _hoisted_4 = { class: "text-c-3 ml-2 text-[11px]" };
var _hoisted_5 = {
	"aria-label": "Editor language",
	class: "bg-b-1 shadow-border flex items-center justify-self-center overflow-hidden rounded-lg p-0.5",
	role: "tablist"
};
var _hoisted_6 = { class: "flex min-w-0 shrink-0 items-center gap-2 justify-self-end" };
var _hoisted_7 = { class: "text-c-3 ml-2 text-[11px]" };
var _hoisted_8 = { class: "text-c-3 ml-2 text-[11px]" };
var _hoisted_9 = { class: "flex min-h-0 w-full min-w-0 flex-1 rounded-lg border" };
var _hoisted_10 = { class: "pointer-events-none absolute top-2 right-2 z-10" };
var _hoisted_11 = { key: 1 };
var MAX_VISIBLE_DIAGNOSTICS = 6;
var EDITOR_PERSIST_DEBOUNCE_KEY = "editor:replace-document";
//#endregion
//#region src/v2/features/collection/components/Editor/Editor.vue
var Editor_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
	__name: "Editor",
	props: {
		documentSlug: {},
		document: {},
		eventBus: {},
		layout: {},
		path: {},
		method: {},
		exampleName: {},
		environment: {},
		securitySchemes: {},
		workspaceStore: {},
		activeWorkspace: {},
		plugins: {},
		customThemes: {},
		currentTheme: {},
		isDarkMode: { type: Boolean },
		fetchRegistryDocument: { type: Function },
		collectionType: {}
	},
	setup(__props) {
		const monacoEditorRef = ref();
		const editorApi = shallowRef();
		const saveLoader = useLoadingState();
		const { isAutoSaveEnabled, isDirty, editorLanguage, isDiagnosticsPaneExpanded, isEditorMaximized, isYamlMode, editorBottomPadding, editorRootClass, getLanguageToggleClass, toggleEditorMaximized } = useEditorState();
		const jsonModel = createJsonModel();
		const yamlModel = createYamlModel();
		const selectedLanguage = ref("json");
		const currentModel = computed(() => {
			return selectedLanguage.value === "json" ? jsonModel : yamlModel;
		});
		const { markers: diagnostics } = useEditorMarkers(computed(() => editorApi.value?.editor));
		const syncEditorBottomPadding = () => {
			editorApi.value?.editor.updateOptions({ padding: {
				top: 0,
				bottom: editorBottomPadding.value
			} });
		};
		const diagnosticCounts = computed(() => getDiagnosticCounts(diagnostics.value));
		const visibleDiagnostics = computed(() => getVisibleDiagnostics(diagnostics.value, MAX_VISIBLE_DIAGNOSTICS));
		const focusDiagnostic = (marker) => {
			const editor = editorApi.value?.editor;
			if (!editor) return;
			editor.setSelection({
				startLineNumber: marker.startLineNumber,
				startColumn: marker.startColumn,
				endLineNumber: marker.endLineNumber,
				endColumn: marker.endColumn
			});
			editor.revealPositionInCenter({
				lineNumber: marker.startLineNumber,
				column: marker.startColumn
			});
		};
		const getEditorValue = () => currentModel.value.model.getValue();
		/** Value from the editor for a specific language (use when switching to avoid reading the wrong model). */
		const getEditorValueForLanguage = (language) => (language === "json" ? jsonModel : yamlModel).model.getValue();
		const getDocumentValue = async (language) => {
			return stringifyDocument(await __props.workspaceStore.getEditableDocument(__props.documentSlug), language ?? selectedLanguage.value);
		};
		const debouncedPersist = debounce({ delay: 1500 });
		const applyProgrammaticEditorValue = (value) => {
			debouncedPersist.cleanup();
			editorApi.value?.setValue(value, true);
		};
		const loadDocumentIntoEditor = async () => {
			applyProgrammaticEditorValue(await getDocumentValue());
			isDirty.value = false;
			await focusOperation();
		};
		const formatDocument = async () => {
			await editorApi.value?.formatDocument();
		};
		const focusOperation = async () => {
			const operationContext = getOperationContext(__props.path, __props.method);
			if (!operationContext) return;
			await editorApi.value?.focusPath([
				"paths",
				operationContext.path,
				operationContext.method
			]);
		};
		const persistEditorToWorkspace = async (value) => {
			const parsed = parseEditorObject(value, editorLanguage.value);
			if (!parsed) {
				const firstError = diagnostics.value.find((m) => m.severity === monaco.MarkerSeverity.Error);
				if (firstError) focusDiagnostic(firstError);
				await saveLoader.invalidate();
				return;
			}
			saveLoader.start();
			await __props.workspaceStore.replaceDocument(__props.documentSlug, parsed);
			isDirty.value = false;
			await saveLoader.validate({ duration: 900 });
		};
		const saveNow = async () => {
			const value = getEditorValue();
			if (!value) return;
			await persistEditorToWorkspace(value);
		};
		const handleEditorChange = (value) => {
			isDirty.value = true;
			if (!isAutoSaveEnabled.value) return;
			debouncedPersist.execute(EDITOR_PERSIST_DEBOUNCE_KEY, () => persistEditorToWorkspace(value));
		};
		const focusOperationServers = async () => {
			const operationContext = getOperationContext(__props.path, __props.method);
			if (!operationContext) return;
			const value = getEditorValue();
			if (!value) return;
			const parsed = parseEditorObject(value, editorLanguage.value);
			if (!parsed || !isObject(parsed.paths)) return;
			const operationPathItem = parsed.paths[operationContext.path];
			if (!isObject(operationPathItem)) return;
			const operation = operationPathItem[operationContext.method];
			if (!isObject(operation)) return;
			operation.servers ??= [];
			editorApi.value?.setValue(stringifyDocument(parsed, editorLanguage.value));
			await editorApi.value?.focusPath([
				"paths",
				operationContext.path,
				operationContext.method,
				"servers"
			]);
		};
		useJsonPointerLinkSupport(editorApi, currentModel);
		onMounted(() => {
			editorApi.value = useEditor({
				element: monacoEditorRef.value ?? document.createElement("div"),
				onChange: handleEditorChange,
				model: currentModel,
				actions: [
					{
						id: "scalar.editor.focusOperation",
						label: "Focus Operation",
						keybindings: [monaco.KeyMod.Alt | monaco.KeyCode.KeyO],
						run: async () => {
							await focusOperation();
						}
					},
					{
						id: "scalar.editor.focusOperationServers",
						label: "Focus Operation Servers",
						keybindings: [monaco.KeyMod.Alt | monaco.KeyCode.KeyS],
						run: async () => {
							await focusOperationServers();
						}
					},
					{
						id: "scalar.editor.formatDocument",
						label: "Format Document",
						keybindings: [monaco.KeyMod.Alt | monaco.KeyMod.Shift | monaco.KeyCode.KeyF],
						run: async () => {
							await formatDocument();
						}
					}
				]
			});
			syncEditorBottomPadding();
			loadDocumentIntoEditor();
		});
		onBeforeUnmount(() => {
			debouncedPersist.cleanup();
			if (isDirty.value && isAutoSaveEnabled.value) saveNow();
			editorApi.value?.dispose?.();
			jsonModel.model.dispose();
			yamlModel.model.dispose();
		});
		watch(() => __props.documentSlug, loadDocumentIntoEditor);
		watch(() => [__props.path, __props.method], async () => {
			await focusOperation();
		});
		watch(isDiagnosticsPaneExpanded, () => {
			syncEditorBottomPadding();
		});
		watch(editorLanguage, async (nextLanguage, previousLanguage) => {
			const wasDirty = isDirty.value;
			const value = getEditorValueForLanguage(previousLanguage ?? "json");
			if (!value) {
				selectedLanguage.value = nextLanguage;
				await nextTick();
				await focusOperation();
				return;
			}
			const parsed = parseEditorObject(value, previousLanguage ?? "json");
			selectedLanguage.value = nextLanguage;
			await nextTick();
			if (parsed) {
				applyProgrammaticEditorValue(stringifyDocument(parsed, nextLanguage));
				isDirty.value = wasDirty;
			}
			await focusOperation();
		});
		watch(isAutoSaveEnabled, (isEnabled) => {
			if (!isEnabled) {
				debouncedPersist.cleanup();
				return;
			}
			if (isDirty.value) {
				const value = getEditorValue();
				if (!value) return;
				debouncedPersist.execute(EDITOR_PERSIST_DEBOUNCE_KEY, () => persistEditorToWorkspace(value));
			}
		}, { flush: "post" });
		return (_ctx, _cache) => {
			return __props.collectionType === "operation" && unref(getOperationContext)(__props.path, __props.method) !== null ? (openBlock(), createElementBlock("div", {
				key: 0,
				class: normalizeClass(["flex w-full min-w-0 flex-1 flex-col gap-2", unref(editorRootClass)])
			}, [createElementVNode("div", _hoisted_1, [
				createElementVNode("div", _hoisted_2, [
					_cache[6] || (_cache[6] = createElementVNode("span", { class: "text-c-2 text-xs font-medium whitespace-nowrap" }, " Shortcuts ", -1)),
					createVNode(unref(ScalarButton), {
						class: "whitespace-nowrap",
						size: "xs",
						variant: "ghost",
						onClick: focusOperation
					}, {
						default: withCtx(() => [_cache[4] || (_cache[4] = createElementVNode("span", null, "Operation", -1)), createElementVNode("span", _hoisted_3, [createVNode(unref(ScalarHotkey), {
							hotkey: "O",
							modifier: ["Alt"]
						})])]),
						_: 1
					}),
					createVNode(unref(ScalarButton), {
						class: "whitespace-nowrap",
						size: "xs",
						variant: "ghost",
						onClick: focusOperationServers
					}, {
						default: withCtx(() => [_cache[5] || (_cache[5] = createElementVNode("span", null, "Servers", -1)), createElementVNode("span", _hoisted_4, [createVNode(unref(ScalarHotkey), {
							hotkey: "S",
							modifier: ["Alt"]
						})])]),
						_: 1
					})
				]),
				createElementVNode("div", _hoisted_5, [createVNode(unref(ScalarButton), {
					"aria-selected": !unref(isYamlMode),
					class: normalizeClass(unref(getLanguageToggleClass)(!unref(isYamlMode))),
					role: "tab",
					size: "xs",
					type: "button",
					variant: "ghost",
					onClick: _cache[0] || (_cache[0] = ($event) => editorLanguage.value = "json")
				}, {
					default: withCtx(() => [..._cache[7] || (_cache[7] = [createTextVNode(" JSON ", -1)])]),
					_: 1
				}, 8, ["aria-selected", "class"]), createVNode(unref(ScalarButton), {
					"aria-selected": unref(isYamlMode),
					class: normalizeClass(unref(getLanguageToggleClass)(unref(isYamlMode))),
					role: "tab",
					size: "xs",
					type: "button",
					variant: "ghost",
					onClick: _cache[1] || (_cache[1] = ($event) => editorLanguage.value = "yaml")
				}, {
					default: withCtx(() => [..._cache[8] || (_cache[8] = [createTextVNode(" YAML ", -1)])]),
					_: 1
				}, 8, ["aria-selected", "class"])]),
				createElementVNode("div", _hoisted_6, [createVNode(unref(ScalarButton), {
					size: "xs",
					variant: "ghost",
					onClick: formatDocument
				}, {
					default: withCtx(() => [createElementVNode("span", null, "Format " + toDisplayString(unref(isYamlMode) ? "YAML" : "JSON"), 1), createElementVNode("span", _hoisted_7, [createVNode(unref(ScalarHotkey), {
						hotkey: "F",
						modifier: ["Alt", "Shift"]
					})])]),
					_: 1
				}), createVNode(unref(ScalarButton), {
					"aria-label": unref(isEditorMaximized) ? "Restore editor size" : "Maximize editor",
					size: "xs",
					variant: "ghost",
					onClick: unref(toggleEditorMaximized)
				}, {
					default: withCtx(() => [createElementVNode("span", null, toDisplayString(unref(isEditorMaximized) ? "Restore" : "Maximize"), 1), createElementVNode("span", _hoisted_8, [unref(isEditorMaximized) ? (openBlock(), createBlock(unref(ScalarIconArrowsIn), {
						key: 0,
						class: "size-3.5"
					})) : (openBlock(), createBlock(unref(ScalarIconArrowsOut), {
						key: 1,
						class: "size-3.5"
					}))])]),
					_: 1
				}, 8, ["aria-label", "onClick"])])
			]), createElementVNode("div", _hoisted_9, [createElementVNode("div", { class: normalizeClass(["relative w-full min-w-0 flex-1", unref(isEditorMaximized) ? "h-full min-h-0" : "h-[500px]"]) }, [
				createElementVNode("div", _hoisted_10, [createVNode(EditorSavePanel_default, {
					isAutoSaveEnabled: unref(isAutoSaveEnabled),
					isDirty: unref(isDirty),
					saveLoader: unref(saveLoader),
					onSaveNow: saveNow,
					"onUpdate:isAutoSaveEnabled": _cache[2] || (_cache[2] = ($event) => isAutoSaveEnabled.value = $event)
				}, null, 8, [
					"isAutoSaveEnabled",
					"isDirty",
					"saveLoader"
				])]),
				createVNode(EditorDiagnosticsPanel_default, {
					diagnosticCounts: diagnosticCounts.value,
					expanded: unref(isDiagnosticsPaneExpanded),
					visibleDiagnostics: visibleDiagnostics.value,
					onFocusDiagnostic: focusDiagnostic,
					onToggle: _cache[3] || (_cache[3] = ($event) => isDiagnosticsPaneExpanded.value = !unref(isDiagnosticsPaneExpanded))
				}, null, 8, [
					"diagnosticCounts",
					"expanded",
					"visibleDiagnostics"
				]),
				createElementVNode("div", {
					ref_key: "monacoEditorRef",
					ref: monacoEditorRef,
					class: "h-full w-full min-w-0 flex-1"
				}, null, 512)
			], 2)])], 2)) : (openBlock(), createElementBlock("div", _hoisted_11, "No operation context found"));
		};
	}
}), [["__scopeId", "data-v-850fff8f"]]);
//#endregion
export { createJsonModel as n, Editor_default as t };

//# sourceMappingURL=Editor-BomsGWHx.js.map