/*! © 2026 Yahoo, Inc. UDS Tailwind and Purger v0.0.0-development */
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
let node_fs = require("node:fs");
node_fs = require_runtime.__toESM(node_fs);
let node_path = require("node:path");
node_path = require_runtime.__toESM(node_path);

//#region src/utils/entryPoints.ts
const ALLOWED_ENTRY_FILE_EXTENSIONS = [".tsx"];
const DEFAULT_ENTRY = "./src";
const getAllowedEntryFileGlobPatterns = (prefix = "**/*") => ALLOWED_ENTRY_FILE_EXTENSIONS.map((extension) => `${prefix}${extension}`);
const hasAllowedEntryFileExtension = (entryPath) => ALLOWED_ENTRY_FILE_EXTENSIONS.includes(node_path.default.extname(entryPath));
const stripAllowedEntryFileExtension = (entryPath) => {
	const extension = ALLOWED_ENTRY_FILE_EXTENSIONS.find((candidate) => entryPath.endsWith(candidate));
	return extension ? entryPath.slice(0, -extension.length) : entryPath;
};
const formatAllowedEntryFileExtensions = () => ALLOWED_ENTRY_FILE_EXTENSIONS.join(", ");
const createUnsupportedEntryExtensionError = (entryPath) => /* @__PURE__ */ new Error(`Unsupported entry file extension for ${entryPath}. File entries must use one of: ${formatAllowedEntryFileExtensions()}.`);
const createMissingEntryPathError = (entryPath) => /* @__PURE__ */ new Error(`Entry path not found: ${entryPath}.`);
const isExistingDirectory = (entryPath) => {
	if (!node_fs.default.existsSync(entryPath)) return false;
	return node_fs.default.statSync(entryPath).isDirectory();
};
const toAbsoluteEntryPath = (entryPath, workspaceDir) => node_path.default.isAbsolute(entryPath) ? entryPath : node_path.default.join(workspaceDir, entryPath);
const resolveEntryPath = (entryPath, workspaceDir) => {
	const absolutePath = toAbsoluteEntryPath(entryPath, workspaceDir);
	if (node_fs.default.existsSync(absolutePath)) {
		const stats = node_fs.default.statSync(absolutePath);
		if (stats.isDirectory()) return {
			originalPath: entryPath,
			absolutePath,
			kind: "directory",
			watchDirectory: absolutePath
		};
		if (stats.isFile()) {
			if (!hasAllowedEntryFileExtension(absolutePath)) throw createUnsupportedEntryExtensionError(entryPath);
			return {
				originalPath: entryPath,
				absolutePath,
				kind: "file",
				watchDirectory: node_path.default.dirname(absolutePath),
				fileName: node_path.default.basename(absolutePath)
			};
		}
	}
	if (node_path.default.extname(entryPath) && isExistingDirectory(node_path.default.dirname(absolutePath)) && !hasAllowedEntryFileExtension(entryPath)) throw createUnsupportedEntryExtensionError(entryPath);
	throw createMissingEntryPathError(entryPath);
};
const normalizeEntryPaths = (entry, defaultEntry = DEFAULT_ENTRY) => {
	const normalized = (Array.isArray(entry) ? entry : [entry]).filter((value) => typeof value === "string" && value.trim().length > 0);
	return normalized.length > 0 ? [...new Set(normalized)] : [defaultEntry];
};
const formatEntryValue = (entry) => Array.isArray(entry) ? `[${entry.map((value) => `'${value}'`).join(", ")}]` : `'${entry}'`;
const resolveEntryPaths = (entry, workspaceDir, defaultEntry = DEFAULT_ENTRY) => normalizeEntryPaths(entry, defaultEntry).map((entryPath) => resolveEntryPath(entryPath, workspaceDir));

//#endregion
exports.DEFAULT_ENTRY = DEFAULT_ENTRY;
exports.formatEntryValue = formatEntryValue;
exports.getAllowedEntryFileGlobPatterns = getAllowedEntryFileGlobPatterns;
exports.hasAllowedEntryFileExtension = hasAllowedEntryFileExtension;
exports.resolveEntryPaths = resolveEntryPaths;
exports.stripAllowedEntryFileExtension = stripAllowedEntryFileExtension;