import { applyAllowReservedToUrl } from "./apply-allow-reserved-to-url.js";
import { getEnvironmentVariables } from "./get-environment-variables.js";
import { getServerUrl } from "./get-server-url.js";
import { mergeUrls } from "@scalar/helpers/url/merge-urls";
import { replaceVariables } from "@scalar/helpers/regex/replace-variables";
//#region src/v2/blocks/operation-block/helpers/get-resolved-url.ts
/**
* Resolves and constructs the final request URL using the provided environment, server, path,
* path variables, and optional query parameters.
*
* - Environment variables and path variables are used to replace placeholders in the path string.
* - The server URL is dynamically resolved (may apply env variables).
* - urlParams are optionally appended as the query string.
*
* @param environment    The current environment containing variable values.
* @param server         The selected server object; can be null.
* @param path           The raw path string from the OpenAPI document (may contain variables).
* @param pathVariables  Map of path variable values (e.g., { petId: '5' }).
* @param urlParams      Optional query parameters as URLSearchParams.
* @returns              Fully resolved URL as a string.
*/
var getResolvedUrl = ({ environment, server, path, pathVariables, allowReservedQueryParameters, urlParams }) => {
	const environmentVariables = getEnvironmentVariables(environment);
	return applyAllowReservedToUrl(mergeUrls(getServerUrl(server, environmentVariables), replaceVariables(path, {
		...environmentVariables,
		...pathVariables
	}), urlParams), allowReservedQueryParameters ?? /* @__PURE__ */ new Set());
};
//#endregion
export { getResolvedUrl };

//# sourceMappingURL=get-resolved-url.js.map