/**
 * Evaluation criteria builder for judge assessments.
 *
 * Provides utilities for creating structured evaluation criteria
 * based on simulation prompts and complexity levels.
 */
/**
 * Builds evaluation criteria from a simulation prompt.
 *
 * Analyzes the prompt structure and content to generate
 * appropriate evaluation criteria for the judge.
 *
 * @param prompt - Simulation prompt object
 * @returns Structured evaluation criteria
 */
export function buildCriteriaFromPrompt(prompt) {
    const criteria = {
        functionalRequirements: [],
        uiRequirements: [],
        dataRequirements: [],
        performanceRequirements: [],
        customCriteria: [],
    };
    // Combine all prompt text for analysis
    const fullText = [prompt.name, prompt.description, ...prompt.prompts]
        .join(" ")
        .toLowerCase();
    // Extract functional requirements
    criteria.functionalRequirements = extractFunctionalRequirements(fullText, prompt.complexity);
    // Extract UI requirements
    criteria.uiRequirements = extractUIRequirements(fullText, prompt.complexity);
    // Extract data requirements
    criteria.dataRequirements = extractDataRequirements(fullText, prompt.complexity);
    // Add performance requirements based on complexity
    if (prompt.complexity === "high" || prompt.complexity === "medium") {
        criteria.performanceRequirements = extractPerformanceRequirements(prompt.complexity);
    }
    // Add custom criteria based on specific prompt patterns
    criteria.customCriteria = extractCustomCriteria(prompt);
    return criteria;
}
/**
 * Extracts functional requirements from prompt text.
 *
 * @param text - Combined prompt text
 * @param complexity - Task complexity
 * @returns Array of functional requirements
 */
function extractFunctionalRequirements(text, complexity) {
    const requirements = [];
    // CRUD operations
    if (text.includes("create") || text.includes("add") || text.includes("new")) {
        requirements.push("Ability to create new records with proper validation");
    }
    if (text.includes("read") ||
        text.includes("view") ||
        text.includes("display")) {
        requirements.push("Ability to view and read existing data");
    }
    if (text.includes("update") ||
        text.includes("edit") ||
        text.includes("modify")) {
        requirements.push("Ability to update existing records");
    }
    if (text.includes("delete") || text.includes("remove")) {
        requirements.push("Ability to delete records with confirmation");
    }
    // Search and filter
    if (text.includes("search") || text.includes("find")) {
        requirements.push("Search functionality works correctly");
    }
    if (text.includes("filter") || text.includes("sort")) {
        requirements.push("Filter and sort capabilities function properly");
    }
    // Forms and validation
    if (text.includes("form") || text.includes("input")) {
        requirements.push("Forms include appropriate validation");
        requirements.push("Error messages are clear and helpful");
    }
    // Authentication
    if (text.includes("auth") ||
        text.includes("login") ||
        text.includes("user")) {
        requirements.push("Authentication flow works correctly");
        requirements.push("User sessions are properly managed");
    }
    // Workflow
    if (text.includes("workflow") ||
        text.includes("process") ||
        text.includes("step")) {
        requirements.push("Multi-step workflows progress correctly");
        requirements.push("State is maintained between steps");
    }
    // Data operations
    if (text.includes("import") || text.includes("export")) {
        requirements.push("Data import/export functionality works");
    }
    if (text.includes("report") || text.includes("analytics")) {
        requirements.push("Reports display accurate data");
        requirements.push("Analytics calculations are correct");
    }
    // Notifications
    if (text.includes("notify") ||
        text.includes("alert") ||
        text.includes("email")) {
        requirements.push("Notifications are triggered appropriately");
    }
    // Add complexity-based requirements
    if (complexity === "high") {
        requirements.push("Complex business logic is correctly implemented");
        requirements.push("Edge cases are properly handled");
    }
    // Ensure minimum requirements
    if (requirements.length === 0) {
        requirements.push("Core functionality works as described");
        requirements.push("Application completes primary use case");
    }
    return requirements;
}
/**
 * Extracts UI/UX requirements from prompt text.
 *
 * @param text - Combined prompt text
 * @param complexity - Task complexity
 * @returns Array of UI requirements
 */
function extractUIRequirements(text, complexity) {
    const requirements = [];
    // Basic UI requirements
    requirements.push("Interface is clean and organized");
    requirements.push("Navigation is intuitive");
    // Specific UI elements
    if (text.includes("table") || text.includes("grid")) {
        requirements.push("Tables/grids display data clearly");
        requirements.push("Column headers are descriptive");
    }
    if (text.includes("chart") ||
        text.includes("graph") ||
        text.includes("visual")) {
        requirements.push("Data visualizations are clear and accurate");
    }
    if (text.includes("modal") || text.includes("dialog")) {
        requirements.push("Modals/dialogs work correctly");
    }
    if (text.includes("tab") || text.includes("accordion")) {
        requirements.push("Tab/accordion navigation works properly");
    }
    // Responsive design
    if (text.includes("responsive") || text.includes("mobile")) {
        requirements.push("UI is responsive to different screen sizes");
    }
    // Accessibility
    if (complexity === "high") {
        requirements.push("UI elements have proper labels for accessibility");
    }
    // Feedback
    requirements.push("User actions provide appropriate feedback");
    if (text.includes("loading") || text.includes("spinner")) {
        requirements.push("Loading states are shown during operations");
    }
    // Error handling
    requirements.push("Error states are clearly communicated");
    return requirements;
}
/**
 * Extracts data integration requirements from prompt text.
 *
 * @param text - Combined prompt text
 * @param complexity - Task complexity
 * @returns Array of data requirements
 */
function extractDataRequirements(text, complexity) {
    const requirements = [];
    // API integrations
    if (text.includes("api") ||
        text.includes("rest") ||
        text.includes("graphql")) {
        requirements.push("API integrations function correctly");
        requirements.push("API errors are handled gracefully");
    }
    // Database
    if (text.includes("database") ||
        text.includes("sql") ||
        text.includes("query")) {
        requirements.push("Database operations complete successfully");
        requirements.push("Data persistence works correctly");
    }
    // Specific integrations
    if (text.includes("salesforce")) {
        requirements.push("Salesforce integration retrieves and updates data correctly");
    }
    if (text.includes("slack")) {
        requirements.push("Slack messages are sent successfully");
    }
    if (text.includes("jira")) {
        requirements.push("Jira tickets are created/updated correctly");
    }
    if (text.includes("servicenow")) {
        requirements.push("ServiceNow integration functions properly");
    }
    if (text.includes("stripe") || text.includes("payment")) {
        requirements.push("Payment processing works correctly");
    }
    // Data validation
    requirements.push("Data validation prevents invalid inputs");
    if (complexity === "high" || complexity === "medium") {
        requirements.push("Data relationships are properly maintained");
        requirements.push("Concurrent data operations are handled safely");
    }
    // Default requirement
    if (requirements.length === 1) {
        requirements.push("Data is displayed and stored correctly");
    }
    return requirements;
}
/**
 * Extracts performance requirements based on complexity.
 *
 * @param complexity - Task complexity
 * @returns Array of performance requirements
 */
function extractPerformanceRequirements(complexity) {
    const requirements = [];
    switch (complexity) {
        case "high":
            requirements.push("Application loads within 3 seconds");
            requirements.push("UI interactions respond within 200ms");
            requirements.push("Large datasets are handled efficiently");
            requirements.push("No memory leaks during extended use");
            break;
        case "medium":
            requirements.push("Application loads within 5 seconds");
            requirements.push("Common operations complete quickly");
            break;
        case "low":
            // No specific performance requirements for low complexity
            break;
    }
    return requirements;
}
/**
 * Extracts custom criteria based on specific prompt patterns.
 *
 * @param prompt - Simulation prompt
 * @returns Array of custom criteria
 */
function extractCustomCriteria(prompt) {
    const criteria = [];
    // Add criteria based on specific prompt IDs or patterns
    if (prompt.id.includes("multi-step")) {
        criteria.push("All workflow steps complete in correct order");
    }
    if (prompt.id.includes("realtime")) {
        criteria.push("Real-time updates work correctly");
    }
    if (prompt.id.includes("batch")) {
        criteria.push("Batch operations process all items correctly");
    }
    // Add criteria based on prompt count
    if (prompt.prompts.length > 2) {
        criteria.push("Multi-prompt instructions are fully implemented");
        criteria.push("Later prompts build on earlier functionality");
    }
    return criteria;
}
/**
 * Creates minimal criteria for basic testing.
 *
 * Used when specific criteria cannot be extracted.
 *
 * @returns Minimal evaluation criteria
 */
export function createMinimalCriteria() {
    return {
        functionalRequirements: [
            "Application loads without errors",
            "Primary functionality works as intended",
        ],
        uiRequirements: ["Interface is usable", "User can complete basic tasks"],
        dataRequirements: ["Data operations complete successfully"],
    };
}
//# sourceMappingURL=evaluation-criteria.js.map