import type { ValidationRule } from '../types.js';

// Import all rules
import { requiredMetaId, requiredMetaSyntax } from './required-meta.js';
import { validSemver } from './valid-semver.js';
import { requiredGuards } from './required-guards.js';
import { blockedPatterns } from './blocked-patterns.js';
import { validPath } from './valid-path.js';
import { deprecated } from './deprecated.js';
import { emptyBlock } from './empty-block.js';
import { validParams } from './valid-params.js';
import { suspiciousUrls } from './suspicious-urls.js';
import { authorityInjection } from './authority-injection.js';
import { obfuscatedContent } from './obfuscated-content.js';
import { pathTraversal } from './path-traversal.js';
import { unicodeSecurity } from './unicode-security.js';
import { skillParams } from './skill-params.js';
import { skillDependencies } from './skill-dependencies.js';
import { skillContracts } from './skill-contracts.js';
import { syntaxVersionCompat } from './syntax-version-compat.js';
import { unknownBlockName } from './unknown-block-name.js';
import { duplicateSkills } from './duplicate-skills.js';
import { useBlockFilter } from './use-block-filter.js';
import { circularGuardRequires } from './circular-guard-requires.js';
import { validExamples } from './valid-examples.js';
import { validGuardRequires } from './valid-guard-requires.js';
import { validSkillReferences } from './valid-skill-references.js';
import { safeReferenceContent } from './safe-reference-content.js';
import { validSkillComposition } from './valid-skill-composition.js';
import { validAppendNegation } from './valid-append-negation.js';
import { validSealedProperty } from './valid-sealed-property.js';
import { policyCompliance } from './policy-compliance.js';
import { referenceIntegrity } from './reference-integrity.js';

// Re-export all rules
export { requiredMetaId, requiredMetaSyntax } from './required-meta.js';
export { validSemver, isValidSemver } from './valid-semver.js';
export { requiredGuards } from './required-guards.js';
export {
  blockedPatterns,
  BLOCKED_PATTERNS_PL,
  BLOCKED_PATTERNS_ES,
  BLOCKED_PATTERNS_DE,
  BLOCKED_PATTERNS_FR,
  BLOCKED_PATTERNS_PT,
  BLOCKED_PATTERNS_RU,
  BLOCKED_PATTERNS_ZH,
  BLOCKED_PATTERNS_IT,
  BLOCKED_PATTERNS_NL,
  BLOCKED_PATTERNS_JA,
  BLOCKED_PATTERNS_KO,
  BLOCKED_PATTERNS_AR,
  BLOCKED_PATTERNS_TR,
  BLOCKED_PATTERNS_SV,
  BLOCKED_PATTERNS_NO,
  BLOCKED_PATTERNS_DA,
  BLOCKED_PATTERNS_FI,
  BLOCKED_PATTERNS_CS,
  BLOCKED_PATTERNS_HU,
  BLOCKED_PATTERNS_UK,
  BLOCKED_PATTERNS_HI,
  BLOCKED_PATTERNS_ID,
  BLOCKED_PATTERNS_VI,
  BLOCKED_PATTERNS_TH,
  BLOCKED_PATTERNS_EL,
  BLOCKED_PATTERNS_RO,
  BLOCKED_PATTERNS_HE,
  BLOCKED_PATTERNS_ALL_LANGUAGES,
} from './blocked-patterns.js';
export { validPath, isValidPath } from './valid-path.js';
export { deprecated } from './deprecated.js';
export { emptyBlock } from './empty-block.js';
export { validParams } from './valid-params.js';
export { suspiciousUrls } from './suspicious-urls.js';
export { authorityInjection } from './authority-injection.js';
export { obfuscatedContent } from './obfuscated-content.js';
export { pathTraversal, hasPathTraversal } from './path-traversal.js';
export { unicodeSecurity } from './unicode-security.js';
export { skillParams } from './skill-params.js';
export { skillDependencies } from './skill-dependencies.js';
export { skillContracts } from './skill-contracts.js';
export { syntaxVersionCompat } from './syntax-version-compat.js';
export { unknownBlockName } from './unknown-block-name.js';
export { duplicateSkills } from './duplicate-skills.js';
export { useBlockFilter } from './use-block-filter.js';
export { circularGuardRequires } from './circular-guard-requires.js';
export { validExamples } from './valid-examples.js';
export { validGuardRequires } from './valid-guard-requires.js';
export { validSkillReferences } from './valid-skill-references.js';
export { safeReferenceContent } from './safe-reference-content.js';
export { validSkillComposition } from './valid-skill-composition.js';
export { validAppendNegation } from './valid-append-negation.js';
export { validSealedProperty } from './valid-sealed-property.js';
export { policyCompliance } from './policy-compliance.js';
export { referenceIntegrity } from './reference-integrity.js';

/**
 * All validation rules in the order they should be executed.
 */
export const allRules: ValidationRule[] = [
  // Required meta rules (PS001, PS002)
  requiredMetaId,
  requiredMetaSyntax,
  // Semver validation (PS003)
  validSemver,
  // Required guards (PS004)
  requiredGuards,
  // Blocked patterns (PS005)
  blockedPatterns,
  // Valid paths (PS006)
  validPath,
  // Deprecated features (PS007)
  deprecated,
  // Empty blocks (PS008)
  emptyBlock,
  // Valid params (PS009)
  validParams,
  // Skill params (PS015)
  skillParams,
  // Skill dependencies (PS016)
  skillDependencies,
  // Skill contracts (PS017)
  skillContracts,
  // Syntax version compatibility (PS018)
  syntaxVersionCompat,
  // Unknown block name detection (PS019)
  unknownBlockName,
  // Duplicate skill names (PS020)
  duplicateSkills,
  // @use block filter validation (PS021)
  useBlockFilter,
  // Circular guard requires (PS022)
  circularGuardRequires,
  // Valid examples (PS023)
  validExamples,
  // Valid guard requires (PS024)
  validGuardRequires,
  // Valid skill references (PS025)
  validSkillReferences,
  // Safe reference content (PS026)
  safeReferenceContent,
  // Valid skill composition (PS027)
  validSkillComposition,
  // Valid append negation (PS028)
  validAppendNegation,
  // Valid sealed property (PS029)
  validSealedProperty,
  // Policy compliance (PS030)
  policyCompliance,
  // Reference integrity (PS031)
  referenceIntegrity,
  // Security rules (PS010, PS011, PS012, PS013, PS014)
  suspiciousUrls,
  authorityInjection,
  obfuscatedContent,
  pathTraversal,
  unicodeSecurity,
];

/**
 * Get a rule by its ID.
 */
export function getRuleById(id: string): ValidationRule | undefined {
  return allRules.find((rule) => rule.id === id);
}

/**
 * Get a rule by its name.
 */
export function getRuleByName(name: string): ValidationRule | undefined {
  return allRules.find((rule) => rule.name === name);
}
