import { init_esm_shims, __name } from './CWKWODSW.js';
import { isString } from 'es-toolkit';

// src/utils/finder.ts
init_esm_shims();
var findToolByName = /* @__PURE__ */ __name(({ tools }, toolName) => {
  const tool = tools.find((tool2) => tool2.name === toolName);
  if (!tool) {
    throw new Error(`Tool '${toolName}' not found`);
  }
  return tool;
}, "findToolByName");
var getImageName = /* @__PURE__ */ __name((basename) => `${basename}-tooling`, "getImageName");
var getToolDefaultVersion = /* @__PURE__ */ __name((context, toolName) => {
  const combination = context.versionCombinations[0];
  if (!combination) {
    return null;
  }
  const version = findToolVersionsForCombination(context, combination)[toolName];
  if (!version) {
    console.warn(`No default version found for tool '${toolName}' in matrix`);
    return null;
  }
  return version;
}, "getToolDefaultVersion");
var findToolVersionsForCombination = /* @__PURE__ */ __name(({ images }, combination) => Object.fromEntries(Object.entries(combination.images).map(([tool, imageId]) => {
  const version = images[imageId].versions[tool];
  if (!version) {
    throw new Error(`Tool ${tool} not found in Docker image: ${imageId}`);
  }
  return [
    tool,
    version
  ];
})), "findToolVersionsForCombination");
var getToolSupportedVersions = /* @__PURE__ */ __name((context, toolName) => [
  ...new Set(context.versionCombinations.map((combination) => findToolVersionsForCombination(context, combination)[toolName]).filter(isString))
].sort(), "getToolSupportedVersions");

export { findToolByName, findToolVersionsForCombination, getImageName, getToolDefaultVersion, getToolSupportedVersions };
//# sourceMappingURL=3XEUJAQB.js.map
//# sourceMappingURL=3XEUJAQB.js.map