import tierRegistryJson from '../../config/tool-tier-registry.json' with { type: 'json' };
const config = tierRegistryJson;
/**
 * SPEC-652: Manages Core/Domain/Power tier activation on top of GroupManager.
 * Core tier groups are always enabled. Domain and Power tiers start disabled
 * (lazy) and activate on demand via activateTier().
 */
export class TierManager {
    config;
    groupManager;
    constructor(groupManager) {
        this.config = config;
        this.groupManager = groupManager;
    }
    /** Disable all lazyLoad tier groups after GroupManager.init(). */
    async init() {
        for (const tier of this.config.tiers) {
            if (!tier.lazyLoad) {
                continue;
            }
            for (const groupId of tier.groups) {
                this.groupManager.disableGroup(groupId);
            }
        }
        await Promise.resolve();
    }
    /** Enable all groups belonging to the specified tier. */
    activateTier(tierId) {
        const tier = this.config.tiers.find((t) => t.id === tierId);
        if (!tier) {
            return;
        }
        for (const groupId of tier.groups) {
            this.groupManager.enableGroup(groupId);
        }
    }
    /** Get the tier definition by ID, or null if not found. */
    getTier(tierId) {
        return this.config.tiers.find((t) => t.id === tierId) ?? null;
    }
    /** Resolve which tier a given group belongs to. Returns null if not mapped. */
    getTierForGroup(groupId) {
        for (const tier of this.config.tiers) {
            if (tier.groups.includes(groupId)) {
                return tier.id;
            }
        }
        return null;
    }
    /** All tier definitions. */
    getTiers() {
        return [...this.config.tiers];
    }
}
let _tierManager = null;
export function setTierManager(tm) {
    _tierManager = tm;
}
export function getTierManager() {
    return _tierManager;
}
//# sourceMappingURL=tier-manager.js.map