import { coerceValue } from "@scalar/workspace-store/schemas/typebox-coerce";
import { xScalarEnvironmentSchema } from "@scalar/workspace-store/schemas/extensions/document/x-scalar-environments";
//#region src/v2/helpers/get-active-environment.ts
var getActiveEnvironment = (workspace, document) => {
	if (workspace === null) return coerceValue(xScalarEnvironmentSchema, {});
	const activeEnv = workspace.workspace["x-scalar-active-environment"];
	if (!activeEnv) return coerceValue(xScalarEnvironmentSchema, {});
	const workspaceEnv = workspace.workspace["x-scalar-environments"]?.[activeEnv] ?? { variables: [] };
	const documentEnv = document?.["x-scalar-environments"]?.[activeEnv] ?? { variables: [] };
	return coerceValue(xScalarEnvironmentSchema, {
		...workspaceEnv,
		...documentEnv,
		variables: [...workspaceEnv.variables, ...documentEnv.variables]
	});
};
//#endregion
export { getActiveEnvironment };

//# sourceMappingURL=get-active-environment.js.map