import { t as __exportAll } from "./rolldown-runtime-Cbj13DAv.js";
import { a as resolveCanonicalConfigPath, c as resolveDefaultConfigCandidates, d as resolveIsNixMode, f as resolveLegacyStateDirs, g as resolveStateDir, h as resolveOAuthPath, i as isNixMode, l as resolveGatewayLockDir, m as resolveOAuthDir, n as DEFAULT_GATEWAY_PORT, o as resolveConfigPath, p as resolveNewStateDir, r as STATE_DIR, s as resolveConfigPathCandidate, t as CONFIG_PATH, u as resolveGatewayPort } from "./paths-CutK9mvd.js";
import { O as applyLegacyMigrations, S as unsetConfigOverride, b as resetConfigOverrides, l as validateConfigObjectWithPlugins, r as loadConfig, v as applyConfigOverrides, x as setConfigOverride, y as getConfigOverrides } from "./io-CD_zuK0D.js";

//#region src/config/legacy-migrate.ts
function migrateLegacyConfig(raw) {
	const { next, changes } = applyLegacyMigrations(raw);
	if (!next) return {
		config: null,
		changes: []
	};
	const validated = validateConfigObjectWithPlugins(next);
	if (!validated.ok) {
		changes.push("Migration applied, but config still invalid; fix remaining issues manually.");
		return {
			config: null,
			changes
		};
	}
	return {
		config: validated.config,
		changes
	};
}

//#endregion
//#region src/config/config.ts
var config_exports = /* @__PURE__ */ __exportAll({
	CONFIG_PATH: () => CONFIG_PATH,
	DEFAULT_GATEWAY_PORT: () => DEFAULT_GATEWAY_PORT,
	STATE_DIR: () => STATE_DIR,
	applyConfigOverrides: () => applyConfigOverrides,
	getConfigOverrides: () => getConfigOverrides,
	isNixMode: () => isNixMode,
	loadConfig: () => loadConfig,
	resetConfigOverrides: () => resetConfigOverrides,
	resolveCanonicalConfigPath: () => resolveCanonicalConfigPath,
	resolveConfigPath: () => resolveConfigPath,
	resolveConfigPathCandidate: () => resolveConfigPathCandidate,
	resolveDefaultConfigCandidates: () => resolveDefaultConfigCandidates,
	resolveGatewayLockDir: () => resolveGatewayLockDir,
	resolveGatewayPort: () => resolveGatewayPort,
	resolveIsNixMode: () => resolveIsNixMode,
	resolveLegacyStateDirs: () => resolveLegacyStateDirs,
	resolveNewStateDir: () => resolveNewStateDir,
	resolveOAuthDir: () => resolveOAuthDir,
	resolveOAuthPath: () => resolveOAuthPath,
	resolveStateDir: () => resolveStateDir,
	setConfigOverride: () => setConfigOverride,
	unsetConfigOverride: () => unsetConfigOverride
});

//#endregion
export { migrateLegacyConfig as n, config_exports as t };