import { b as resolveStateDir } from "./paths-BprY_fto.js";
import { t as loadGlobalRuntimeDotEnvFiles } from "./dotenv-global-D9t1bsiT.js";
import fs from "node:fs";
import path from "node:path";
//#region src/cli/gateway-dispatch-dotenv.ts
/** Load only the env files needed before dispatching a command through the gateway. */
async function loadGatewayDispatchCliDotEnv(opts) {
	const quiet = opts?.quiet ?? true;
	const cwdEnvPath = path.join(process.cwd(), ".env");
	if (fs.existsSync(cwdEnvPath)) {
		const { loadCliDotEnv } = await import("./dotenv-C3TcPUq5.js");
		loadCliDotEnv({ quiet });
		return;
	}
	loadGlobalRuntimeDotEnvFiles({
		quiet,
		stateEnvPath: path.join(resolveStateDir(process.env), ".env")
	});
}
//#endregion
export { loadGatewayDispatchCliDotEnv };
