"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
const require_paths_socket = require('../../paths/socket.js');
const require_external_tools_from_download = require('../from-download.js');
const require_external_tools_trufflehog_asset_names = require('./asset-names.js');
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path);
let node_process = require("node:process");
node_process = require_runtime.__toESM(node_process);

//#region src/external-tools/trufflehog/from-download.ts
/**
* @file `trufflehogFromDownload()` — fetches upstream TruffleHog and returns a
*   `ResolvedTrufflehog` pointing at the extracted binary. TruffleHog ships as
*   tar.gz archives per platform; the helper extracts and locates the
*   `trufflehog` (or `trufflehog.exe`) executable. Idempotent: re-running with
*   the same `{version, platformArch}` after a successful first run is a cache
*   check, no network. Trust-on-first-use: pass `integrity` from
*   `external-tools.json` when available.
*/
async function trufflehogFromDownload(opts) {
	const { cacheDir, downloader, integrity, platformArch, version } = opts;
	const url = require_external_tools_trufflehog_asset_names.getTrufflehogDownloadUrl({
		version,
		platformArch
	});
	if (!url) return;
	const extractedDir = cacheDir ?? node_path.default.join(require_paths_socket.getSocketDlxDir(), "trufflehog", version, platformArch);
	const archive = await require_external_tools_from_download.downloadAndExtractTool({
		url,
		name: `trufflehog-${version}-${platformArch}.tar.gz`,
		integrity,
		extractedDir,
		downloader
	});
	const binary = node_process.default.platform === "win32" ? "trufflehog.exe" : "trufflehog";
	return {
		path: node_path.default.join(extractedDir, binary),
		source: "download",
		integrity: archive.integrity
	};
}

//#endregion
exports.trufflehogFromDownload = trufflehogFromDownload;