const componentByCapability = {
    'button': 'Button', 'text-field': 'TextField', 'text-area': 'TextArea', 'select': 'Select',
    'multi-select': 'MultiSelect', 'checkbox': 'Checkbox', 'date-field': 'DateField',
    'number-field': 'NumberField', 'dialog': 'Dialog', 'status-tag': 'StatusTag',
    'inline-message': 'InlineMessage', 'paginator': 'Paginator', 'tabs': 'Tabs', 'data-grid': 'DataGrid'
};
export function evaluateUiAdapterCompatibility(adapter, requiredCapabilities, requireProductionEligible = false) {
    const issues = [];
    if (adapter.descriptor.contractVersion !== '4.0') {
        issues.push({ code: 'CONTRACT_VERSION', severity: 'ERROR', detail: `Expected 4.0, got ${adapter.descriptor.contractVersion}` });
    }
    for (const capability of requiredCapabilities) {
        if (!adapter.descriptor.capabilities.has(capability)) {
            issues.push({ code: 'MISSING_CAPABILITY', severity: 'ERROR', detail: capability });
            continue;
        }
        const component = adapter.components[componentByCapability[capability]];
        if (!component)
            issues.push({ code: 'MISSING_COMPONENT', severity: 'ERROR', detail: capability });
    }
    if (requireProductionEligible && !adapter.descriptor.productionEligible) {
        issues.push({ code: 'PRODUCTION_INELIGIBLE', severity: 'ERROR', detail: adapter.descriptor.id });
    }
    return { adapterId: adapter.descriptor.id, contractVersion: adapter.descriptor.contractVersion, compatible: !issues.some(x => x.severity === 'ERROR'), issues };
}
export function assertUiAdapterCompatibility(report) {
    if (!report.compatible)
        throw new Error(`UI adapter ${report.adapterId} is incompatible: ${report.issues.map(x => `${x.code}:${x.detail}`).join(', ')}`);
}
