import path from "node:path";
import fs from "node:fs";

//#region src/security/scan-paths.ts
function isPathInside(basePath, candidatePath) {
	const base = path.resolve(basePath);
	const candidate = path.resolve(candidatePath);
	const rel = path.relative(base, candidate);
	return rel === "" || !rel.startsWith(`..${path.sep}`) && rel !== ".." && !path.isAbsolute(rel);
}
function safeRealpathSync(filePath) {
	try {
		return fs.realpathSync(filePath);
	} catch {
		return null;
	}
}
function isPathInsideWithRealpath(basePath, candidatePath, opts) {
	if (!isPathInside(basePath, candidatePath)) return false;
	const baseReal = safeRealpathSync(basePath);
	const candidateReal = safeRealpathSync(candidatePath);
	if (!baseReal || !candidateReal) return opts?.requireRealpath !== true;
	return isPathInside(baseReal, candidateReal);
}
function extensionUsesSkippedScannerPath(entry) {
	return entry.split(/[\\/]+/).filter(Boolean).some((segment) => segment === "node_modules" || segment.startsWith(".") && segment !== "." && segment !== "..");
}

//#endregion
//#region src/compat/legacy-names.ts
const PROJECT_NAME = "gensparx";
const LEGACY_PROJECT_NAMES = [];
const MANIFEST_KEY = PROJECT_NAME;
const LEGACY_MANIFEST_KEYS = LEGACY_PROJECT_NAMES;
const LEGACY_PLUGIN_MANIFEST_FILENAMES = [];
const LEGACY_CANVAS_API_GLOBAL_NAMES = ["gensparxA2UI"];

//#endregion
export { extensionUsesSkippedScannerPath as a, MANIFEST_KEY as i, LEGACY_MANIFEST_KEYS as n, isPathInside as o, LEGACY_PLUGIN_MANIFEST_FILENAMES as r, isPathInsideWithRealpath as s, LEGACY_CANVAS_API_GLOBAL_NAMES as t };