import { extractRequestMethod } from "./postman-request-tree.js";
import { extractPathFromUrl, normalizePath } from "@scalar/postman-to-openapi";
import { HTTP_METHODS } from "@scalar/helpers/http/http-methods";
//#region src/v2/features/command-palette/helpers/get-merge-key.ts
/**
* Extracts all path + method merge keys from an OpenAPI document.
* Returns a Set of merge keys in the format: `${method}\0${path}`
*/
var getOpenApiMergeKeys = (document) => {
	const keys = /* @__PURE__ */ new Set();
	if (!document.paths) return keys;
	for (const [path, pathItem] of Object.entries(document.paths)) {
		if (!pathItem) continue;
		for (const method of HTTP_METHODS) if (method in pathItem && pathItem[method]) {
			const mergeKey = `${method}\0${path}`;
			keys.add(mergeKey);
		}
	}
	return keys;
};
/**
* Resolves merge key and server usage for a Postman collection item that has a `request` field.
*/
var getPostmanMergeKeys = (item) => {
	if (!item || typeof item !== "object" || !("request" in item)) return;
	const request = item.request;
	return `${extractRequestMethod(request).toLowerCase()}\0${normalizePath(extractPathFromUrl(typeof request === "string" ? request : typeof request.url === "string" ? request.url : request.url?.raw ?? ""))}`;
};
//#endregion
export { getOpenApiMergeKeys, getPostmanMergeKeys };

//# sourceMappingURL=get-merge-key.js.map