import { getRegistry, getImageDirectory } from './46I6PSJ7.js';
import { findToolVersionsForCombination, getImageName } from './KWRJPB5T.js';
import { init_esm_shims, __name } from './6AHA7PAZ.js';
import { join, basename } from 'path';

// src/utils/docker.ts
init_esm_shims();
var getImageUriForTool = /* @__PURE__ */ __name(async (context, toolName, version, separator = "_") => {
  const [image] = context.versionCombinations.flatMap((combination) => {
    const imageId = combination.images[toolName];
    if (!imageId) {
      return [];
    }
    const image2 = context.images[imageId];
    return image2 && findToolVersionsForCombination(context, combination)[toolName] === version ? [
      image2
    ] : [];
  });
  if (!image) {
    throw new Error(`No version combination found for tool ${toolName} with version ${version}`);
  }
  return getImageUri(image, separator);
}, "getImageUriForTool");
var getImageUri = /* @__PURE__ */ __name(async (image, separator = "_") => join(await getRegistry(), await getImageDirectory(), `${getImageName(image.name)}:${getImageTag(image, separator)}`), "getImageUri");
var getImageTag = /* @__PURE__ */ __name(({ versions, patch }, separator = "_") => [
  ...Object.entries(versions).sort().flat(),
  ...patch ? [
    "patch",
    patch
  ] : []
].join(separator), "getImageTag");
var getVolumeName = /* @__PURE__ */ __name((volume) => {
  if (volume.type === "host") {
    return `${volume.hostPath}:${volume.containerPath}`;
  }
  const components = [
    "lz-tooling-cache",
    volume.name
  ];
  if (!volume.shared) {
    const packageName = process.env.npm_package_name;
    if (!packageName) {
      throw new Error("npm_package_name environment variable not defined");
    }
    components.push(basename(packageName));
  }
  return `${components.join("-")}:${volume.containerPath}`;
}, "getVolumeName");

export { getImageTag, getImageUri, getImageUriForTool, getVolumeName };
//# sourceMappingURL=GPDDKHCR.js.map
//# sourceMappingURL=GPDDKHCR.js.map