/**
 * Collector Registry
 * Phase 8: Panel-to-collector integrity
 */
import { collectPosture } from '../collectors/collector_posture.js';
import { collectNetwork } from '../collectors/collector_network.js';
import { collectResources } from '../collectors/collector_resources.js';
import { collectAssets } from '../collectors/collector_assets.js';
import { collectCapabilities } from '../collectors/collector_capabilities.js';
import { collectFeed } from '../collectors/collector_feed.js';
import { collectGeo } from '../collectors/collector_geo.js';
/**
 * Collector registry - single source of truth
 * Maps panel IDs to collector functions
 */
export const collectorRegistry = {
    posture: collectPosture,
    network: collectNetwork,
    resources: collectResources,
    assets: collectAssets,
    capabilities: collectCapabilities,
    feed: collectFeed,
    geo: collectGeo,
};
/**
 * Panel-to-collector mapping
 * Every panel must reference a valid collector key
 */
export const panelToCollectorMap = {
    POSTURE: 'posture',
    RESOURCES: 'resources',
    ASSETS: 'assets',
    FEED: 'feed',
    NETWORK: 'network',
    CAPABILITIES: 'capabilities',
    // GEO INTEL uses 'geo' collector
    'GEO INTEL': 'geo',
};
/**
 * Validate that all hub panels reference valid collectors
 */
export function validatePanelCollectorIntegrity(panelIds, throwOnError = false) {
    const errors = [];
    panelIds.forEach(panelId => {
        const collectorKey = panelToCollectorMap[panelId];
        if (!collectorKey) {
            errors.push(`Panel "${panelId}" has no collector mapping`);
            return;
        }
        if (!collectorRegistry[collectorKey]) {
            errors.push(`Panel "${panelId}" references missing collector "${collectorKey}"`);
        }
    });
    if (errors.length > 0 && throwOnError) {
        throw new Error(`Panel-collector integrity check failed:\n${errors.join('\n')}`);
    }
    return {
        valid: errors.length === 0,
        errors,
    };
}
/**
 * Get collector function for a panel
 */
export function getCollectorForPanel(panelId) {
    const collectorKey = panelToCollectorMap[panelId];
    if (!collectorKey) {
        return null;
    }
    const collector = collectorRegistry[collectorKey];
    if (!collector) {
        return null;
    }
    return collector;
}
//# sourceMappingURL=collectorRegistry.js.map