import { t as ensureAbsoluteDirectory } from "./sdk-security-runtime-s3ThUKGr.js";
import path from "node:path";
import fs from "node:fs/promises";
//#region extensions/browser/src/browser/output-directories.ts
/**
* Browser output directory helper.
*
* Creates absolute output directories while handling macOS system symlink
* aliases such as /tmp and /var safely.
*/
async function resolveSystemDirectoryAlias(dirPath) {
	for (const aliasRoot of ["/tmp", "/var"]) {
		if (dirPath !== aliasRoot && !dirPath.startsWith(`${aliasRoot}${path.sep}`)) continue;
		try {
			if (!(await fs.lstat(aliasRoot)).isSymbolicLink()) return dirPath;
			return path.join(await fs.realpath(aliasRoot), path.relative(aliasRoot, dirPath));
		} catch {
			return dirPath;
		}
	}
	return dirPath;
}
/** Ensure an absolute browser output directory exists and is safe to use. */
async function ensureOutputDirectory(dirPath) {
	const result = await ensureAbsoluteDirectory(await resolveSystemDirectoryAlias(path.resolve(dirPath)), { scopeLabel: "output directory" });
	if (!result.ok) throw result.error;
}
//#endregion
export { ensureOutputDirectory as t };
