"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_external_tools_from_download = require('../from-download.js');
const require_external_tools_bazel_asset_names = require('./asset-names.js');

//#region src/external-tools/bazel/from-download.ts
/**
* @file `bazelFromDownload()` — fetches the upstream Bazel binary and returns a
*   `ResolvedBazel` pointing at the cached executable. Bazel ships as a single
*   executable per platform (no tar/zip wrapper), so this tier uses
*   `downloadToolArchive` directly — no extraction step. The dlx downloader
*   already chmods the file to 0o755 on POSIX, so the cached path is runnable
*   as soon as it lands on disk. Returns `undefined` when Bazel doesn't publish
*   a build for the target `platformArch` (no entry in `BAZEL_ASSET_MAP`).
*   Trust-on-first-use: pass `integrity` from `external-tools.json` when
*   available. Omit on first install; the underlying call computes the SRI and
*   writes it into the dlx cache metadata so a follow-up `external-tools.json`
*   update can pin it.
*/
/**
* Resolve Bazel by downloading the upstream binary. Returns the standard
* `ResolvedBazel` shape with `source: 'download'`.
*
* @example
*   ;```typescript
*   const bazel = await bazelFromDownload({
*     version: '7.4.1',
*     platformArch: 'darwin-arm64',
*   })
*   // → { path: '/.../bazel-7.4.1-darwin-arm64', source: 'download' }
*   ```
*/
async function bazelFromDownload(opts) {
	const { downloader, integrity, platformArch, version } = opts;
	const url = require_external_tools_bazel_asset_names.getBazelDownloadUrl({
		version,
		platformArch
	});
	if (!url) return;
	const archive = await require_external_tools_from_download.downloadToolArchive({
		url,
		name: `bazel-${version}-${platformArch}`,
		integrity,
		downloader
	});
	return {
		path: archive.archivePath,
		source: "download",
		integrity: archive.integrity
	};
}

//#endregion
exports.bazelFromDownload = bazelFromDownload;