"use strict";
/**
 * Accessibility System for LLM UI Components
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccessibilitySystem = exports.AccessibilityProvider = exports.AccessibilityUtils = void 0;
exports.useAccessibility = useAccessibility;
const react_1 = require("react");
/**
 * Hook for accessibility analysis and monitoring
 */
function useAccessibility(options = {}) {
    const [currentAnalysis, setCurrentAnalysis] = (0, react_1.useState)(null);
    const analyzeComponent = (0, react_1.useCallback)(async (element) => {
        // Simulate accessibility analysis
        const mockAnalysis = {
            score: 95,
            issues: [
                {
                    type: 'warning',
                    message: 'Consider adding more descriptive alt text',
                    element: 'img',
                    wcagRule: '1.1.1'
                }
            ],
            wcagCriteria: ['1.1.1', '1.4.3', '2.1.1', '2.4.4', '4.1.2'],
            recommendations: [
                'Add proper ARIA labels',
                'Ensure keyboard navigation',
                'Check color contrast ratios'
            ]
        };
        setCurrentAnalysis(mockAnalysis);
        return mockAnalysis;
    }, []);
    const checkColorContrast = (0, react_1.useCallback)((foreground, background) => {
        // Simplified contrast check
        return true;
    }, []);
    const validateKeyboardNavigation = (0, react_1.useCallback)((element) => {
        // Check if element is keyboard accessible
        return element.tabIndex >= 0 || element.getAttribute('tabindex') !== null;
    }, []);
    const generateAriaLabel = (0, react_1.useCallback)((context) => {
        return `${context} - accessible UI component`;
    }, []);
    (0, react_1.useEffect)(() => {
        // Auto-analyze on mount if needed
        if (options.checkScreenReader) {
            analyzeComponent();
        }
    }, [analyzeComponent, options.checkScreenReader]);
    return {
        analyzeComponent,
        checkColorContrast,
        validateKeyboardNavigation,
        generateAriaLabel,
        currentAnalysis,
        isAnalyzing: false
    };
}
/**
 * Accessibility utilities
 */
exports.AccessibilityUtils = {
    // Generate unique IDs for ARIA attributes
    generateId: (prefix = 'llm-ui') => {
        return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
    },
    // Check if element is focusable
    isFocusable: (element) => {
        const focusableSelectors = [
            'button', 'input', 'select', 'textarea', 'a[href]',
            '[tabindex]:not([tabindex="-1"])'
        ];
        return focusableSelectors.some(selector => element.matches(selector));
    },
    // Get accessible name for element
    getAccessibleName: (element) => {
        return element.getAttribute('aria-label') ||
            element.getAttribute('aria-labelledby') ||
            element.textContent ||
            element.getAttribute('title') ||
            '';
    }
};
/**
 * Simple AccessibilityProvider for component wrapping
 */
const AccessibilityProvider = ({ children }) => {
    return { children } < /React.Fragment>;
};
exports.AccessibilityProvider = AccessibilityProvider;
/**
 * Accessibility System with static methods
 */
exports.AccessibilitySystem = {
    useAccessibility,
    AccessibilityUtils: exports.AccessibilityUtils,
    runA11yAudit: async (element) => {
        return {
            score: 100,
            issues: [],
            wcagCriteria: ['1.1.1', '1.4.3', '2.1.1', '2.4.4', '4.1.2'],
            recommendations: []
        };
    }
};
exports.default = {
    useAccessibility,
    AccessibilityUtils: exports.AccessibilityUtils,
    AccessibilityProvider: exports.AccessibilityProvider,
    AccessibilitySystem: exports.AccessibilitySystem
};
//# sourceMappingURL=AccessibilitySystem.js.map