'use strict';

var RVRC4KBY_cjs = require('./RVRC4KBY.cjs');
var _4BP4CCPZ_cjs = require('./4BP4CCPZ.cjs');
var KHVGLVR5_cjs = require('./KHVGLVR5.cjs');
var path = require('path');
var process = require('process');

// src/utils/docker.ts
KHVGLVR5_cjs.init_cjs_shims();
var getImageUriForTool = /* @__PURE__ */ KHVGLVR5_cjs.__name(async (context, toolName, version) => {
  const [image] = context.versionCombinations.flatMap((combination) => {
    const imageId = combination.images[toolName];
    if (!imageId) {
      return [];
    }
    const image2 = context.images[imageId];
    return image2 && _4BP4CCPZ_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);
}, "getImageUriForTool");
var getImageUri = /* @__PURE__ */ KHVGLVR5_cjs.__name(async (image) => path.join(await RVRC4KBY_cjs.getRegistry(), await RVRC4KBY_cjs.getImageDirectory(), `${_4BP4CCPZ_cjs.getImageName(image.name)}:${getImageTag(image)}`), "getImageUri");
var getImageTag = /* @__PURE__ */ KHVGLVR5_cjs.__name(({ versions, patch }) => [
  ...Object.entries(versions).sort().flat(),
  ...patch ? [
    "patch",
    patch
  ] : []
].join("-"), "getImageTag");
var qualifyVolumeName = /* @__PURE__ */ KHVGLVR5_cjs.__name((volume) => {
  if (volume.type !== "isolate") {
    return volume;
  }
  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 {
    ...volume,
    name: components.join("-")
  };
}, "qualifyVolumeName");

exports.getImageTag = getImageTag;
exports.getImageUri = getImageUri;
exports.getImageUriForTool = getImageUriForTool;
exports.qualifyVolumeName = qualifyVolumeName;
//# sourceMappingURL=S6PEV2YJ.cjs.map
//# sourceMappingURL=S6PEV2YJ.cjs.map