//#region src/internal/constraint-helpers.ts
/**
* Determines which tool parameter keys should be filtered out of the schema
* because they will be injected from constraints.
*
* Handles parameter aliases: when a projectSlug constraint exists and the tool
* has a projectSlugOrId parameter, the alias will be applied UNLESS projectSlugOrId
* is explicitly constrained with a truthy value.
*
* @param constraints - The active constraints (org, project, region)
* @param toolInputSchema - The tool's input schema definition
* @returns Array of parameter keys that should be filtered from the schema
*
* @example
* ```typescript
* const constraints = { projectSlug: "my-project", organizationSlug: "my-org" };
* const schema = { organizationSlug: z.string(), projectSlugOrId: z.string() };
* const keys = getConstraintKeysToFilter(constraints, schema);
* // Returns: ["organizationSlug", "projectSlugOrId"]
* // projectSlugOrId is included because projectSlug constraint will map to it
* ```
*/
function getConstraintKeysToFilter(constraints, toolInputSchema) {
	return Object.entries(constraints).flatMap(([key, value]) => {
		if (!value) return [];
		const keys = [];
		if (key in toolInputSchema) keys.push(key);
		if (key === "projectSlug" && "projectSlugOrId" in toolInputSchema && !("projectSlugOrId" in constraints && constraints.projectSlugOrId)) keys.push("projectSlugOrId");
		return keys;
	});
}
/**
* Builds the constraint parameters that should be injected into tool calls.
*
* Handles parameter aliases: when a projectSlug constraint exists and the tool
* has a projectSlugOrId parameter, the constraint value will be injected as
* projectSlugOrId UNLESS projectSlugOrId is explicitly constrained with a truthy value.
*
* @param constraints - The active constraints (org, project, region)
* @param toolInputSchema - The tool's input schema definition
* @returns Object mapping parameter names to constraint values
*
* @example
* ```typescript
* const constraints = { projectSlug: "my-project", organizationSlug: "my-org" };
* const schema = { organizationSlug: z.string(), projectSlugOrId: z.string() };
* const params = getConstraintParametersToInject(constraints, schema);
* // Returns: { organizationSlug: "my-org", projectSlugOrId: "my-project" }
* // projectSlug constraint is injected as projectSlugOrId parameter
* ```
*/
function getConstraintParametersToInject(constraints, toolInputSchema) {
	return Object.fromEntries(Object.entries(constraints).flatMap(([key, value]) => {
		if (!value) return [];
		const entries = [];
		if (key in toolInputSchema) entries.push([key, value]);
		if (key === "projectSlug" && "projectSlugOrId" in toolInputSchema && !("projectSlugOrId" in constraints && constraints.projectSlugOrId)) entries.push(["projectSlugOrId", value]);
		return entries;
	}));
}

//#endregion
export { getConstraintKeysToFilter, getConstraintParametersToInject };
//# sourceMappingURL=constraint-helpers-0jgp7p3K.js.map