"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../../_virtual/_rolldown/runtime.js');
const require_bin_which = require('../../bin/which.js');
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path);

//#region src/external-tools/jre/from-path.ts
/**
* @file `jreFromPath()` — looks for `java` (or `java.exe`) on the system PATH
*   via socket-lib's `which`. Returns the resolved- shape object if found;
*   otherwise `undefined`. Derives `javaHome` by walking up two directories
*   from the resolved `java` path (`<javaHome>/bin/java`). That's the JDK/JRE
*   convention every distribution follows.
*/
async function jreFromPath() {
	const javaOnPath = await require_bin_which.which("java", { nothrow: true });
	/* c8 ignore start - reached only when java is NOT on PATH. */
	if (typeof javaOnPath !== "string") return;
	/* c8 ignore stop */
	return {
		javaPath: javaOnPath,
		javaHome: node_path.default.dirname(node_path.default.dirname(javaOnPath)),
		source: "path"
	};
}

//#endregion
exports.jreFromPath = jreFromPath;