'use strict';

var _2NTYK3VO_cjs = require('./2NTYK3VO.cjs');
var _5GPMTH2I_cjs = require('./5GPMTH2I.cjs');
var _24WEKBY3_cjs = require('./24WEKBY3.cjs');
var path = require('path');

// src/utils/docker.ts
_24WEKBY3_cjs.init_cjs_shims();
var getImageUriForTool = /* @__PURE__ */ _24WEKBY3_cjs.__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 && _5GPMTH2I_cjs.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__ */ _24WEKBY3_cjs.__name(async (image, separator = "_") => path.join(await _2NTYK3VO_cjs.getRegistry(), await _2NTYK3VO_cjs.getImageDirectory(), `${_5GPMTH2I_cjs.getImageName(image.name)}:${getImageTag(image, separator)}`), "getImageUri");
var getImageTag = /* @__PURE__ */ _24WEKBY3_cjs.__name(({ versions, patch }, separator = "_") => [
  ...Object.entries(versions).sort().flat(),
  ...patch ? [
    "patch",
    patch
  ] : []
].join(separator), "getImageTag");
var getVolumeName = /* @__PURE__ */ _24WEKBY3_cjs.__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(path.basename(packageName));
  }
  return `${components.join("-")}:${volume.containerPath}`;
}, "getVolumeName");

exports.getImageTag = getImageTag;
exports.getImageUri = getImageUri;
exports.getImageUriForTool = getImageUriForTool;
exports.getVolumeName = getVolumeName;
//# sourceMappingURL=533SFXIE.cjs.map
//# sourceMappingURL=533SFXIE.cjs.map