/**
 * AI Compliance SDK - TypeScript Interfaces
 *
 * Comprehensive type definitions for the SDK's state management,
 * checkpoint system, and all compliance-related data structures.
 */

// =============================================================================
// ENUMS
// =============================================================================

export type SubscriptionTier = 'FREE' | 'STARTER' | 'PROFESSIONAL' | 'ENTERPRISE'

export type SDKPhase = 1 | 2

// =============================================================================
// SDK PACKAGES (NEU)
// =============================================================================

export type SDKPackageId = 'vorbereitung' | 'analyse' | 'dokumentation' | 'rechtliche-texte' | 'betrieb'

export type CustomerType = 'new' | 'existing'

// =============================================================================
// COMPANY PROFILE (Business Context - collected before use cases)
// =============================================================================

export type BusinessModel = 'B2B' | 'B2C' | 'B2B_B2C'

export type OfferingType =
  | 'app_mobile'           // Mobile App
  | 'app_web'              // Web Application
  | 'website'              // Website/Landing Pages
  | 'webshop'              // E-Commerce
  | 'hardware'             // Hardware sales
  | 'software_saas'        // SaaS/Software products
  | 'software_onpremise'   // On-Premise Software
  | 'services_consulting'  // Consulting/Professional Services
  | 'services_agency'      // Agency Services
  | 'internal_only'        // Internal applications only

export type TargetMarket =
  | 'germany_only'         // Only Germany
  | 'dach'                 // Germany, Austria, Switzerland
  | 'eu'                   // European Union
  | 'ewr'                  // European Economic Area (EU + Iceland, Liechtenstein, Norway)
  | 'eu_uk'                // EU + United Kingdom
  | 'worldwide'            // Global operations

export type CompanySize = 'micro' | 'small' | 'medium' | 'large' | 'enterprise'

export type LegalForm =
  | 'einzelunternehmen'    // Sole proprietorship
  | 'gbr'                  // GbR
  | 'ohg'                  // OHG
  | 'kg'                   // KG
  | 'gmbh'                 // GmbH
  | 'ug'                   // UG (haftungsbeschränkt)
  | 'ag'                   // AG
  | 'gmbh_co_kg'           // GmbH & Co. KG
  | 'ev'                   // e.V. (Verein)
  | 'stiftung'             // Foundation
  | 'other'                // Other

export interface CompanyProfile {
  // Basic Info
  companyName: string
  legalForm: LegalForm
  industry: string              // Free text or NACE code
  foundedYear: number | null

  // Business Model
  businessModel: BusinessModel
  offerings: OfferingType[]

  // Size & Scope
  companySize: CompanySize
  employeeCount: string         // Range: "1-9", "10-49", "50-249", "250-999", "1000+"
  annualRevenue: string         // Range: "< 2 Mio", "2-10 Mio", "10-50 Mio", "> 50 Mio"

  // Locations
  headquartersCountry: string   // ISO country code, e.g., "DE"
  headquartersCity: string
  hasInternationalLocations: boolean
  internationalCountries: string[]  // ISO country codes

  // Target Markets & Legal Scope
  targetMarkets: TargetMarket[]
  primaryJurisdiction: string   // Which law primarily applies: "DE", "AT", "CH", etc.

  // Data Processing Role
  isDataController: boolean     // Verantwortlicher (Art. 4 Nr. 7 DSGVO)
  isDataProcessor: boolean      // Auftragsverarbeiter (Art. 4 Nr. 8 DSGVO)

  // AI Usage
  usesAI: boolean
  aiUseCases: string[]          // Brief descriptions

  // Contact Persons
  dpoName: string | null        // Data Protection Officer
  dpoEmail: string | null
  legalContactName: string | null
  legalContactEmail: string | null

  // Completion Status
  isComplete: boolean
  completedAt: Date | null
}

export const COMPANY_SIZE_LABELS: Record<CompanySize, string> = {
  micro: 'Kleinstunternehmen (< 10 MA)',
  small: 'Kleinunternehmen (10-49 MA)',
  medium: 'Mittelstand (50-249 MA)',
  large: 'Großunternehmen (250-999 MA)',
  enterprise: 'Konzern (1000+ MA)',
}

export const BUSINESS_MODEL_LABELS: Record<BusinessModel, string> = {
  B2B: 'B2B (Geschäftskunden)',
  B2C: 'B2C (Privatkunden)',
  B2B_B2C: 'B2B und B2C',
}

export const OFFERING_TYPE_LABELS: Record<OfferingType, { label: string; description: string }> = {
  app_mobile: { label: 'Mobile App', description: 'iOS/Android Anwendungen' },
  app_web: { label: 'Web-Anwendung', description: 'Browser-basierte Software' },
  website: { label: 'Website', description: 'Informationsseiten, Landing Pages' },
  webshop: { label: 'Online-Shop', description: 'E-Commerce, Produktverkauf' },
  hardware: { label: 'Hardware-Verkauf', description: 'Physische Produkte' },
  software_saas: { label: 'SaaS/Cloud', description: 'Software as a Service' },
  software_onpremise: { label: 'On-Premise Software', description: 'Lokale Installation' },
  services_consulting: { label: 'Beratung', description: 'Consulting, Professional Services' },
  services_agency: { label: 'Agentur', description: 'Marketing, Design, Entwicklung' },
  internal_only: { label: 'Nur intern', description: 'Interne Unternehmensanwendungen' },
}

export const TARGET_MARKET_LABELS: Record<TargetMarket, { label: string; description: string; regulations: string[] }> = {
  germany_only: {
    label: 'Nur Deutschland',
    description: 'Verkauf nur in Deutschland',
    regulations: ['DSGVO', 'BDSG', 'TTDSG', 'AI Act'],
  },
  dach: {
    label: 'DACH-Region',
    description: 'Deutschland, Österreich, Schweiz',
    regulations: ['DSGVO', 'BDSG', 'DSG (AT)', 'DSG (CH)', 'AI Act'],
  },
  eu: {
    label: 'Europäische Union',
    description: 'Alle EU-Mitgliedsstaaten',
    regulations: ['DSGVO', 'AI Act', 'NIS2', 'DMA/DSA'],
  },
  ewr: {
    label: 'EWR',
    description: 'EU + Island, Liechtenstein, Norwegen',
    regulations: ['DSGVO', 'AI Act', 'NIS2', 'EWR-Sonderregelungen'],
  },
  eu_uk: {
    label: 'EU + Großbritannien',
    description: 'EU plus Vereinigtes Königreich',
    regulations: ['DSGVO', 'UK GDPR', 'AI Act', 'UK AI Framework'],
  },
  worldwide: {
    label: 'Weltweit',
    description: 'Globaler Verkauf/Betrieb',
    regulations: ['DSGVO', 'CCPA', 'LGPD', 'POPIA', 'und weitere...'],
  },
}

// SDK Coverage Limitations - be honest about what we can/cannot help with
export interface SDKCoverageAssessment {
  isFullyCovered: boolean
  coveredRegulations: string[]
  partiallyCoveredRegulations: string[]
  notCoveredRegulations: string[]
  requiresLegalCounsel: boolean
  reasons: string[]
  recommendations: string[]
}

export interface SDKPackage {
  id: SDKPackageId
  order: number
  name: string
  nameShort: string
  description: string
  icon: string
  result: string
}

export const SDK_PACKAGES: SDKPackage[] = [
  {
    id: 'vorbereitung',
    order: 1,
    name: 'Vorbereitung',
    nameShort: 'Vorbereitung',
    description: 'Grundlagen erfassen, Ausgangssituation verstehen',
    icon: '🎯',
    result: 'Klares Verständnis, welche Regulierungen greifen',
  },
  {
    id: 'analyse',
    order: 2,
    name: 'Analyse',
    nameShort: 'Analyse',
    description: 'Risiken erkennen, Anforderungen ableiten',
    icon: '🔍',
    result: 'Vollständige Risikobewertung, Audit-Ready',
  },
  {
    id: 'dokumentation',
    order: 3,
    name: 'Dokumentation',
    nameShort: 'Doku',
    description: 'Rechtliche Pflichtnachweise erstellen',
    icon: '📋',
    result: 'DSFA, TOMs, VVT, Löschkonzept',
  },
  {
    id: 'rechtliche-texte',
    order: 4,
    name: 'Rechtliche Texte',
    nameShort: 'Legal',
    description: 'Kundenfähige Dokumente generieren',
    icon: '📝',
    result: 'AGB, DSI, Nutzungsbedingungen, Cookie-Banner (Code)',
  },
  {
    id: 'betrieb',
    order: 5,
    name: 'Betrieb',
    nameShort: 'Betrieb',
    description: 'Laufender Compliance-Betrieb',
    icon: '⚙️',
    result: 'DSR-Portal, Eskalationsprozesse, Vendor-Management',
  },
]

export type CheckpointType = 'REQUIRED' | 'RECOMMENDED' | 'OPTIONAL'

export type ReviewerType = 'NONE' | 'TEAM_LEAD' | 'DSB' | 'LEGAL'

export type ValidationSeverity = 'ERROR' | 'WARNING' | 'INFO'

export type RiskSeverity = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'

export type RiskLikelihood = 1 | 2 | 3 | 4 | 5

export type RiskImpact = 1 | 2 | 3 | 4 | 5

export type ImplementationStatus = 'NOT_IMPLEMENTED' | 'PARTIAL' | 'IMPLEMENTED'

export type RequirementStatus = 'NOT_STARTED' | 'IN_PROGRESS' | 'IMPLEMENTED' | 'VERIFIED'

export type ControlType = 'TECHNICAL' | 'ORGANIZATIONAL' | 'PHYSICAL'

export type EvidenceType = 'DOCUMENT' | 'SCREENSHOT' | 'LOG' | 'CERTIFICATE' | 'AUDIT_REPORT'

export type RiskStatus = 'IDENTIFIED' | 'ASSESSED' | 'MITIGATED' | 'ACCEPTED' | 'CLOSED'

export type MitigationType = 'AVOID' | 'TRANSFER' | 'MITIGATE' | 'ACCEPT'

export type AIActRiskCategory = 'MINIMAL' | 'LIMITED' | 'HIGH' | 'UNACCEPTABLE'

export type DSFAStatus = 'DRAFT' | 'IN_REVIEW' | 'APPROVED' | 'REJECTED'

export type ScreeningStatus = 'PENDING' | 'RUNNING' | 'COMPLETED' | 'FAILED'

export type SecurityIssueSeverity = 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW'

export type SecurityIssueStatus = 'OPEN' | 'IN_PROGRESS' | 'RESOLVED' | 'ACCEPTED'

export type CookieBannerStyle = 'BANNER' | 'MODAL' | 'FLOATING'

export type CookieBannerPosition = 'TOP' | 'BOTTOM' | 'CENTER'

export type CookieBannerTheme = 'LIGHT' | 'DARK' | 'CUSTOM'

export type CommandType = 'ACTION' | 'NAVIGATION' | 'SEARCH' | 'GENERATE' | 'HELP'

// =============================================================================
// SDK FLOW & NAVIGATION
// =============================================================================

export interface SDKStep {
  id: string
  phase: SDKPhase
  package: SDKPackageId
  order: number
  name: string
  nameShort: string
  description: string
  url: string
  checkpointId: string
  prerequisiteSteps: string[]
  isOptional: boolean
}

export const SDK_STEPS: SDKStep[] = [
  // =============================================================================
  // PAKET 1: VORBEREITUNG (Foundation)
  // =============================================================================
  {
    id: 'company-profile',
    phase: 1,
    package: 'vorbereitung',
    order: 1,
    name: 'Unternehmensprofil',
    nameShort: 'Profil',
    description: 'Geschäftsmodell, Größe und Zielmärkte erfassen',
    url: '/sdk/company-profile',
    checkpointId: 'CP-PROF',
    prerequisiteSteps: [],
    isOptional: false,
  },
  {
    id: 'use-case-assessment',
    phase: 1,
    package: 'vorbereitung',
    order: 2,
    name: 'Anwendungsfall-Erfassung',
    nameShort: 'Anwendung',
    description: 'AI-Anwendungsfälle strukturiert dokumentieren',
    url: '/sdk/advisory-board',
    checkpointId: 'CP-UC',
    prerequisiteSteps: ['company-profile'],
    isOptional: false,
  },
  {
    id: 'import',
    phase: 1,
    package: 'vorbereitung',
    order: 3,
    name: 'Dokument-Import',
    nameShort: 'Import',
    description: 'Bestehende Dokumente hochladen (Bestandskunden)',
    url: '/sdk/import',
    checkpointId: 'CP-IMP',
    prerequisiteSteps: ['use-case-assessment'],
    isOptional: true, // Nur für Bestandskunden
  },
  {
    id: 'screening',
    phase: 1,
    package: 'vorbereitung',
    order: 4,
    name: 'System Screening',
    nameShort: 'Screening',
    description: 'SBOM + Security Check',
    url: '/sdk/screening',
    checkpointId: 'CP-SCAN',
    prerequisiteSteps: ['use-case-assessment'],
    isOptional: false,
  },
  {
    id: 'modules',
    phase: 1,
    package: 'vorbereitung',
    order: 5,
    name: 'Compliance Modules',
    nameShort: 'Module',
    description: 'Abgleich welche Regulierungen gelten',
    url: '/sdk/modules',
    checkpointId: 'CP-MOD',
    prerequisiteSteps: ['screening'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 2: ANALYSE (Assessment)
  // =============================================================================
  {
    id: 'requirements',
    phase: 1,
    package: 'analyse',
    order: 1,
    name: 'Requirements',
    nameShort: 'Anforderungen',
    description: 'Prüfaspekte aus Regulierungen ableiten',
    url: '/sdk/requirements',
    checkpointId: 'CP-REQ',
    prerequisiteSteps: ['modules'],
    isOptional: false,
  },
  {
    id: 'controls',
    phase: 1,
    package: 'analyse',
    order: 2,
    name: 'Controls',
    nameShort: 'Controls',
    description: 'Erforderliche Maßnahmen ermitteln',
    url: '/sdk/controls',
    checkpointId: 'CP-CTRL',
    prerequisiteSteps: ['requirements'],
    isOptional: false,
  },
  {
    id: 'evidence',
    phase: 1,
    package: 'analyse',
    order: 3,
    name: 'Evidence',
    nameShort: 'Nachweise',
    description: 'Nachweise dokumentieren',
    url: '/sdk/evidence',
    checkpointId: 'CP-EVI',
    prerequisiteSteps: ['controls'],
    isOptional: false,
  },
  {
    id: 'risks',
    phase: 1,
    package: 'analyse',
    order: 4,
    name: 'Risk Matrix',
    nameShort: 'Risiken',
    description: 'Risikobewertung & Residual Risk',
    url: '/sdk/risks',
    checkpointId: 'CP-RISK',
    prerequisiteSteps: ['evidence'],
    isOptional: false,
  },
  {
    id: 'ai-act',
    phase: 1,
    package: 'analyse',
    order: 5,
    name: 'AI Act Klassifizierung',
    nameShort: 'AI Act',
    description: 'Risikostufe nach EU AI Act',
    url: '/sdk/ai-act',
    checkpointId: 'CP-AI',
    prerequisiteSteps: ['risks'],
    isOptional: false,
  },
  {
    id: 'audit-checklist',
    phase: 1,
    package: 'analyse',
    order: 6,
    name: 'Audit Checklist',
    nameShort: 'Checklist',
    description: 'Prüfliste generieren',
    url: '/sdk/audit-checklist',
    checkpointId: 'CP-CHK',
    prerequisiteSteps: ['ai-act'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 3: DOKUMENTATION (Compliance Docs)
  // =============================================================================
  {
    id: 'obligations',
    phase: 2,
    package: 'dokumentation',
    order: 1,
    name: 'Pflichtenübersicht',
    nameShort: 'Pflichten',
    description: 'NIS2, DSGVO, AI Act Pflichten',
    url: '/sdk/obligations',
    checkpointId: 'CP-OBL',
    prerequisiteSteps: ['audit-checklist'],
    isOptional: false,
  },
  {
    id: 'dsfa',
    phase: 2,
    package: 'dokumentation',
    order: 2,
    name: 'DSFA',
    nameShort: 'DSFA',
    description: 'Datenschutz-Folgenabschätzung',
    url: '/sdk/dsfa',
    checkpointId: 'CP-DSFA',
    prerequisiteSteps: ['obligations'],
    isOptional: true, // Only if dsfa_recommended
  },
  {
    id: 'tom',
    phase: 2,
    package: 'dokumentation',
    order: 3,
    name: 'TOMs',
    nameShort: 'TOMs',
    description: 'Technische & Org. Maßnahmen',
    url: '/sdk/tom',
    checkpointId: 'CP-TOM',
    prerequisiteSteps: ['dsfa'],
    isOptional: false,
  },
  {
    id: 'loeschfristen',
    phase: 2,
    package: 'dokumentation',
    order: 4,
    name: 'Löschfristen',
    nameShort: 'Löschfristen',
    description: 'Aufbewahrungsrichtlinien',
    url: '/sdk/loeschfristen',
    checkpointId: 'CP-RET',
    prerequisiteSteps: ['tom'],
    isOptional: false,
  },
  {
    id: 'vvt',
    phase: 2,
    package: 'dokumentation',
    order: 5,
    name: 'Verarbeitungsverzeichnis',
    nameShort: 'VVT',
    description: 'Art. 30 DSGVO Dokumentation',
    url: '/sdk/vvt',
    checkpointId: 'CP-VVT',
    prerequisiteSteps: ['loeschfristen'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 4: RECHTLICHE TEXTE (Legal Outputs)
  // =============================================================================
  {
    id: 'einwilligungen',
    phase: 2,
    package: 'rechtliche-texte',
    order: 1,
    name: 'Einwilligungen',
    nameShort: 'Einwilligungen',
    description: 'Datenpunktkatalog & DSI-Generator',
    url: '/sdk/einwilligungen',
    checkpointId: 'CP-CONS',
    prerequisiteSteps: ['vvt'],
    isOptional: false,
  },
  {
    id: 'consent',
    phase: 2,
    package: 'rechtliche-texte',
    order: 2,
    name: 'Rechtliche Vorlagen',
    nameShort: 'Vorlagen',
    description: 'AGB, Datenschutz, Nutzungsbedingungen',
    url: '/sdk/consent',
    checkpointId: 'CP-DOC',
    prerequisiteSteps: ['einwilligungen'],
    isOptional: false,
  },
  {
    id: 'cookie-banner',
    phase: 2,
    package: 'rechtliche-texte',
    order: 3,
    name: 'Cookie Banner',
    nameShort: 'Cookies',
    description: 'Cookie-Consent Generator',
    url: '/sdk/cookie-banner',
    checkpointId: 'CP-COOK',
    prerequisiteSteps: ['consent'],
    isOptional: false,
  },

  // =============================================================================
  // PAKET 5: BETRIEB (Operations)
  // =============================================================================
  {
    id: 'dsr',
    phase: 2,
    package: 'betrieb',
    order: 1,
    name: 'DSR Portal',
    nameShort: 'DSR',
    description: 'Betroffenenrechte-Portal',
    url: '/sdk/dsr',
    checkpointId: 'CP-DSR',
    prerequisiteSteps: ['cookie-banner'],
    isOptional: false,
  },
  {
    id: 'escalations',
    phase: 2,
    package: 'betrieb',
    order: 2,
    name: 'Escalations',
    nameShort: 'Eskalationen',
    description: 'Management-Workflows',
    url: '/sdk/escalations',
    checkpointId: 'CP-ESC',
    prerequisiteSteps: ['dsr'],
    isOptional: false,
  },
  {
    id: 'vendor-compliance',
    phase: 2,
    package: 'betrieb',
    order: 3,
    name: 'Vendor Compliance',
    nameShort: 'Vendor',
    description: 'Dienstleister-Management',
    url: '/sdk/vendor-compliance',
    checkpointId: 'CP-VEND',
    prerequisiteSteps: ['escalations'],
    isOptional: false,
  },
]

// =============================================================================
// CHECKPOINT SYSTEM
// =============================================================================

export interface ValidationRule {
  id: string
  field: string
  condition: 'NOT_EMPTY' | 'MIN_COUNT' | 'MIN_VALUE' | 'CUSTOM' | 'REGEX'
  value?: number | string
  message: string
  severity: ValidationSeverity
}

export interface ValidationError {
  ruleId: string
  field: string
  message: string
  severity: ValidationSeverity
}

export interface Checkpoint {
  id: string
  step: string
  name: string
  type: CheckpointType
  validation: ValidationRule[]
  blocksProgress: boolean
  requiresReview: ReviewerType
  autoValidate: boolean
}

export interface CheckpointStatus {
  checkpointId: string
  passed: boolean
  validatedAt: Date | null
  validatedBy: string | null
  errors: ValidationError[]
  warnings: ValidationError[]
  overrideReason?: string
  overriddenBy?: string
  overriddenAt?: Date
}

// =============================================================================
// USE CASE ASSESSMENT
// =============================================================================

export interface UseCaseStep {
  id: string
  name: string
  completed: boolean
  data: Record<string, unknown>
}

export interface AssessmentResult {
  riskLevel: RiskSeverity
  applicableRegulations: string[]
  recommendedControls: string[]
  dsfaRequired: boolean
  aiActClassification: string
}

export interface UseCaseAssessment {
  id: string
  name: string
  description: string
  category: string
  stepsCompleted: number
  steps: UseCaseStep[]
  assessmentResult: AssessmentResult | null
  createdAt: Date
  updatedAt: Date
}

// =============================================================================
// SCREENING & SECURITY
// =============================================================================

export interface Vulnerability {
  id: string
  cve: string
  severity: SecurityIssueSeverity
  title: string
  description: string
  cvss: number | null
  fixedIn: string | null
}

export interface SBOMComponent {
  name: string
  version: string
  type: 'library' | 'framework' | 'application' | 'container'
  purl: string
  licenses: string[]
  vulnerabilities: Vulnerability[]
}

export interface SBOMDependency {
  from: string
  to: string
}

export interface SBOM {
  format: 'CycloneDX' | 'SPDX'
  version: string
  components: SBOMComponent[]
  dependencies: SBOMDependency[]
  generatedAt: Date
}

export interface SecurityScanResult {
  totalIssues: number
  critical: number
  high: number
  medium: number
  low: number
  issues: SecurityIssue[]
}

export interface SecurityIssue {
  id: string
  severity: SecurityIssueSeverity
  title: string
  description: string
  cve: string | null
  cvss: number | null
  affectedComponent: string
  remediation: string
  status: SecurityIssueStatus
}

export interface ScreeningResult {
  id: string
  status: ScreeningStatus
  startedAt: Date
  completedAt: Date | null
  sbom: SBOM | null
  securityScan: SecurityScanResult | null
  error: string | null
}

export interface BacklogItem {
  id: string
  title: string
  description: string
  severity: SecurityIssueSeverity
  securityIssueId: string
  status: 'OPEN' | 'IN_PROGRESS' | 'DONE'
  assignee: string | null
  dueDate: Date | null
  createdAt: Date
}

// =============================================================================
// COMPLIANCE
// =============================================================================

export interface ServiceModule {
  id: string
  name: string
  description: string
  regulations: string[]
  criticality: RiskSeverity
  processesPersonalData: boolean
  hasAIComponents: boolean
}

export interface Requirement {
  id: string
  regulation: string
  article: string
  title: string
  description: string
  criticality: RiskSeverity
  applicableModules: string[]
  status: RequirementStatus
  controls: string[]
}

export interface Control {
  id: string
  name: string
  description: string
  type: ControlType
  category: string
  implementationStatus: ImplementationStatus
  effectiveness: RiskSeverity
  evidence: string[]
  owner: string | null
  dueDate: Date | null
}

export interface Evidence {
  id: string
  controlId: string
  type: EvidenceType
  name: string
  description: string
  fileUrl: string | null
  validFrom: Date
  validUntil: Date | null
  uploadedBy: string
  uploadedAt: Date
}

export interface ChecklistItem {
  id: string
  requirementId: string
  title: string
  description: string
  status: 'PENDING' | 'PASSED' | 'FAILED' | 'NOT_APPLICABLE'
  notes: string
  verifiedBy: string | null
  verifiedAt: Date | null
}

// =============================================================================
// RISK MANAGEMENT
// =============================================================================

export interface RiskMitigation {
  id: string
  description: string
  type: MitigationType
  status: 'PLANNED' | 'IN_PROGRESS' | 'COMPLETED'
  effectiveness: number // 0-100
  controlId: string | null
}

export interface Risk {
  id: string
  title: string
  description: string
  category: string
  likelihood: RiskLikelihood
  impact: RiskImpact
  severity: RiskSeverity
  inherentRiskScore: number
  residualRiskScore: number
  status: RiskStatus
  mitigation: RiskMitigation[]
  owner: string | null
  relatedControls: string[]
  relatedRequirements: string[]
}

// =============================================================================
// AI ACT & OBLIGATIONS
// =============================================================================

export interface AIActObligation {
  id: string
  article: string
  title: string
  description: string
  deadline: Date | null
  status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED'
}

export interface AIActResult {
  riskCategory: AIActRiskCategory
  systemType: string
  obligations: AIActObligation[]
  assessmentDate: Date
  assessedBy: string
  justification: string
}

export interface Obligation {
  id: string
  regulation: string
  article: string
  title: string
  description: string
  deadline: Date | null
  penalty: string | null
  status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED'
  responsible: string | null
}

// =============================================================================
// DSFA
// =============================================================================

export interface DSFASection {
  id: string
  title: string
  content: string
  status: 'DRAFT' | 'COMPLETED'
  order: number
}

export interface DSFAApproval {
  id: string
  approver: string
  role: string
  status: 'PENDING' | 'APPROVED' | 'REJECTED'
  comment: string | null
  approvedAt: Date | null
}

export interface DSFA {
  id: string
  status: DSFAStatus
  version: number
  sections: DSFASection[]
  approvals: DSFAApproval[]
  createdAt: Date
  updatedAt: Date
}

// =============================================================================
// TOMs & RETENTION
// =============================================================================

export interface TOM {
  id: string
  category: string
  name: string
  description: string
  type: 'TECHNICAL' | 'ORGANIZATIONAL'
  implementationStatus: ImplementationStatus
  priority: RiskSeverity
  responsiblePerson: string | null
  implementationDate: Date | null
  reviewDate: Date | null
  evidence: string[]
}

export interface RetentionPolicy {
  id: string
  dataCategory: string
  description: string
  legalBasis: string
  retentionPeriod: string
  deletionMethod: string
  exceptions: string[]
}

// =============================================================================
// VVT (Processing Register)
// =============================================================================

export interface ProcessingActivity {
  id: string
  name: string
  purpose: string
  legalBasis: string
  dataCategories: string[]
  dataSubjects: string[]
  recipients: string[]
  thirdCountryTransfers: boolean
  retentionPeriod: string
  technicalMeasures: string[]
  organizationalMeasures: string[]
}

// =============================================================================
// LEGAL DOCUMENTS
// =============================================================================

export interface LegalDocument {
  id: string
  type: 'AGB' | 'PRIVACY_POLICY' | 'TERMS_OF_USE' | 'IMPRINT' | 'COOKIE_POLICY'
  title: string
  content: string
  version: string
  status: 'DRAFT' | 'PUBLISHED' | 'ARCHIVED'
  publishedAt: Date | null
  createdAt: Date
  updatedAt: Date
}

// =============================================================================
// COOKIE BANNER
// =============================================================================

export interface Cookie {
  id: string
  name: string
  provider: string
  purpose: string
  expiry: string
  type: 'NECESSARY' | 'FUNCTIONAL' | 'ANALYTICS' | 'MARKETING'
}

export interface CookieCategory {
  id: string
  name: string
  description: string
  required: boolean
  cookies: Cookie[]
}

export interface CookieBannerTexts {
  title: string
  description: string
  acceptAll: string
  rejectAll: string
  settings: string
  save: string
}

export interface CookieBannerGeneratedCode {
  html: string
  css: string
  js: string
}

export interface CookieBannerConfig {
  id: string
  style: CookieBannerStyle
  position: CookieBannerPosition
  theme: CookieBannerTheme
  texts: CookieBannerTexts
  categories: CookieCategory[]
  generatedCode: CookieBannerGeneratedCode | null
}

// =============================================================================
// CONSENT & DSR
// =============================================================================

export interface ConsentRecord {
  id: string
  userId: string
  documentId: string
  documentVersion: string
  consentType: string
  granted: boolean
  grantedAt: Date
  revokedAt: Date | null
  ipAddress: string | null
  userAgent: string | null
}

export interface DSRRequest {
  id: string
  type: 'ACCESS' | 'RECTIFICATION' | 'ERASURE' | 'PORTABILITY' | 'RESTRICTION' | 'OBJECTION'
  status: 'RECEIVED' | 'VERIFIED' | 'PROCESSING' | 'COMPLETED' | 'REJECTED'
  requesterEmail: string
  requesterName: string
  requestedAt: Date
  dueDate: Date
  completedAt: Date | null
  notes: string
}

export interface DSRConfig {
  id: string
  enabled: boolean
  portalUrl: string
  emailTemplates: Record<string, string>
  automatedResponses: boolean
  verificationRequired: boolean
}

// =============================================================================
// IMPORTED DOCUMENTS (für Bestandskunden)
// =============================================================================

export type ImportedDocumentType =
  | 'DSFA'
  | 'TOM'
  | 'VVT'
  | 'AGB'
  | 'PRIVACY_POLICY'
  | 'COOKIE_POLICY'
  | 'RISK_ASSESSMENT'
  | 'AUDIT_REPORT'
  | 'OTHER'

export interface ImportedDocument {
  id: string
  name: string
  type: ImportedDocumentType
  fileUrl: string
  uploadedAt: Date
  analyzedAt: Date | null
  analysisResult: DocumentAnalysisResult | null
}

export interface DocumentAnalysisResult {
  detectedType: ImportedDocumentType
  confidence: number
  extractedEntities: string[]
  gaps: GapItem[]
  recommendations: string[]
}

export interface GapItem {
  id: string
  category: string
  description: string
  severity: RiskSeverity
  regulation: string
  requiredAction: string
  relatedStepId: string | null
}

export interface GapAnalysis {
  id: string
  createdAt: Date
  totalGaps: number
  criticalGaps: number
  highGaps: number
  mediumGaps: number
  lowGaps: number
  gaps: GapItem[]
  recommendedPackages: SDKPackageId[]
}

// =============================================================================
// ESCALATIONS
// =============================================================================

export interface EscalationWorkflow {
  id: string
  name: string
  description: string
  triggerConditions: string[]
  steps: EscalationStep[]
  enabled: boolean
}

export interface EscalationStep {
  id: string
  order: number
  action: string
  assignee: string
  timeLimit: string // ISO 8601 Duration
  escalateOnTimeout: boolean
}

// =============================================================================
// COMMAND BAR
// =============================================================================

export interface CommandSuggestion {
  id: string
  type: CommandType
  label: string
  description: string
  shortcut?: string
  icon?: string
  action: () => void | Promise<void>
  relevanceScore: number
}

export interface CommandHistory {
  id: string
  query: string
  type: CommandType
  timestamp: Date
  success: boolean
}

// =============================================================================
// USER PREFERENCES
// =============================================================================

export interface UserPreferences {
  language: 'de' | 'en'
  theme: 'light' | 'dark' | 'system'
  compactMode: boolean
  showHints: boolean
  autoSave: boolean
  autoValidate: boolean
  allowParallelWork: boolean // Erlaubt Navigation zu allen Schritten ohne Voraussetzungen
}

// =============================================================================
// SDK STATE
// =============================================================================

export interface SDKState {
  // Metadata
  version: string
  lastModified: Date

  // Tenant & User
  tenantId: string
  userId: string
  subscription: SubscriptionTier

  // Customer Type (new vs existing)
  customerType: CustomerType | null

  // Company Profile (collected before use cases)
  companyProfile: CompanyProfile | null

  // Progress
  currentPhase: SDKPhase
  currentStep: string
  completedSteps: string[]
  checkpoints: Record<string, CheckpointStatus>

  // Imported Documents (for existing customers)
  importedDocuments: ImportedDocument[]
  gapAnalysis: GapAnalysis | null

  // Phase 1 Data
  useCases: UseCaseAssessment[]
  activeUseCase: string | null
  screening: ScreeningResult | null
  modules: ServiceModule[]
  requirements: Requirement[]
  controls: Control[]
  evidence: Evidence[]
  checklist: ChecklistItem[]
  risks: Risk[]

  // Phase 2 Data
  aiActClassification: AIActResult | null
  obligations: Obligation[]
  dsfa: DSFA | null
  toms: TOM[]
  retentionPolicies: RetentionPolicy[]
  vvt: ProcessingActivity[]
  documents: LegalDocument[]
  cookieBanner: CookieBannerConfig | null
  consents: ConsentRecord[]
  dsrConfig: DSRConfig | null
  escalationWorkflows: EscalationWorkflow[]

  // Security
  sbom: SBOM | null
  securityIssues: SecurityIssue[]
  securityBacklog: BacklogItem[]

  // UI State
  commandBarHistory: CommandHistory[]
  recentSearches: string[]
  preferences: UserPreferences
}

// =============================================================================
// SDK ACTIONS
// =============================================================================

export type SDKAction =
  | { type: 'SET_STATE'; payload: Partial<SDKState> }
  | { type: 'SET_CURRENT_STEP'; payload: string }
  | { type: 'COMPLETE_STEP'; payload: string }
  | { type: 'SET_CHECKPOINT_STATUS'; payload: { id: string; status: CheckpointStatus } }
  | { type: 'SET_CUSTOMER_TYPE'; payload: CustomerType }
  | { type: 'SET_COMPANY_PROFILE'; payload: CompanyProfile }
  | { type: 'UPDATE_COMPANY_PROFILE'; payload: Partial<CompanyProfile> }
  | { type: 'ADD_IMPORTED_DOCUMENT'; payload: ImportedDocument }
  | { type: 'UPDATE_IMPORTED_DOCUMENT'; payload: { id: string; data: Partial<ImportedDocument> } }
  | { type: 'DELETE_IMPORTED_DOCUMENT'; payload: string }
  | { type: 'SET_GAP_ANALYSIS'; payload: GapAnalysis }
  | { type: 'ADD_USE_CASE'; payload: UseCaseAssessment }
  | { type: 'UPDATE_USE_CASE'; payload: { id: string; data: Partial<UseCaseAssessment> } }
  | { type: 'DELETE_USE_CASE'; payload: string }
  | { type: 'SET_ACTIVE_USE_CASE'; payload: string | null }
  | { type: 'SET_SCREENING'; payload: ScreeningResult }
  | { type: 'ADD_MODULE'; payload: ServiceModule }
  | { type: 'UPDATE_MODULE'; payload: { id: string; data: Partial<ServiceModule> } }
  | { type: 'ADD_REQUIREMENT'; payload: Requirement }
  | { type: 'UPDATE_REQUIREMENT'; payload: { id: string; data: Partial<Requirement> } }
  | { type: 'ADD_CONTROL'; payload: Control }
  | { type: 'UPDATE_CONTROL'; payload: { id: string; data: Partial<Control> } }
  | { type: 'ADD_EVIDENCE'; payload: Evidence }
  | { type: 'UPDATE_EVIDENCE'; payload: { id: string; data: Partial<Evidence> } }
  | { type: 'DELETE_EVIDENCE'; payload: string }
  | { type: 'ADD_RISK'; payload: Risk }
  | { type: 'UPDATE_RISK'; payload: { id: string; data: Partial<Risk> } }
  | { type: 'DELETE_RISK'; payload: string }
  | { type: 'SET_AI_ACT_RESULT'; payload: AIActResult }
  | { type: 'ADD_OBLIGATION'; payload: Obligation }
  | { type: 'UPDATE_OBLIGATION'; payload: { id: string; data: Partial<Obligation> } }
  | { type: 'SET_DSFA'; payload: DSFA }
  | { type: 'ADD_TOM'; payload: TOM }
  | { type: 'UPDATE_TOM'; payload: { id: string; data: Partial<TOM> } }
  | { type: 'ADD_RETENTION_POLICY'; payload: RetentionPolicy }
  | { type: 'UPDATE_RETENTION_POLICY'; payload: { id: string; data: Partial<RetentionPolicy> } }
  | { type: 'ADD_PROCESSING_ACTIVITY'; payload: ProcessingActivity }
  | { type: 'UPDATE_PROCESSING_ACTIVITY'; payload: { id: string; data: Partial<ProcessingActivity> } }
  | { type: 'ADD_DOCUMENT'; payload: LegalDocument }
  | { type: 'UPDATE_DOCUMENT'; payload: { id: string; data: Partial<LegalDocument> } }
  | { type: 'SET_COOKIE_BANNER'; payload: CookieBannerConfig }
  | { type: 'SET_DSR_CONFIG'; payload: DSRConfig }
  | { type: 'ADD_ESCALATION_WORKFLOW'; payload: EscalationWorkflow }
  | { type: 'UPDATE_ESCALATION_WORKFLOW'; payload: { id: string; data: Partial<EscalationWorkflow> } }
  | { type: 'ADD_SECURITY_ISSUE'; payload: SecurityIssue }
  | { type: 'UPDATE_SECURITY_ISSUE'; payload: { id: string; data: Partial<SecurityIssue> } }
  | { type: 'ADD_BACKLOG_ITEM'; payload: BacklogItem }
  | { type: 'UPDATE_BACKLOG_ITEM'; payload: { id: string; data: Partial<BacklogItem> } }
  | { type: 'ADD_COMMAND_HISTORY'; payload: CommandHistory }
  | { type: 'SET_PREFERENCES'; payload: Partial<UserPreferences> }
  | { type: 'RESET_STATE' }

// =============================================================================
// HELPER FUNCTIONS
// =============================================================================

export function getStepById(stepId: string): SDKStep | undefined {
  return SDK_STEPS.find(s => s.id === stepId)
}

export function getStepByUrl(url: string): SDKStep | undefined {
  return SDK_STEPS.find(s => s.url === url)
}

export function getStepsForPhase(phase: SDKPhase): SDKStep[] {
  return SDK_STEPS.filter(s => s.phase === phase).sort((a, b) => a.order - b.order)
}

export function getNextStep(currentStepId: string): SDKStep | undefined {
  const currentStep = getStepById(currentStepId)
  if (!currentStep) return undefined

  const stepsInPhase = getStepsForPhase(currentStep.phase)
  const currentIndex = stepsInPhase.findIndex(s => s.id === currentStepId)

  if (currentIndex < stepsInPhase.length - 1) {
    return stepsInPhase[currentIndex + 1]
  }

  // Move to next phase
  if (currentStep.phase === 1) {
    return getStepsForPhase(2)[0]
  }

  return undefined
}

export function getPreviousStep(currentStepId: string): SDKStep | undefined {
  const currentStep = getStepById(currentStepId)
  if (!currentStep) return undefined

  const stepsInPhase = getStepsForPhase(currentStep.phase)
  const currentIndex = stepsInPhase.findIndex(s => s.id === currentStepId)

  if (currentIndex > 0) {
    return stepsInPhase[currentIndex - 1]
  }

  // Move to previous phase
  if (currentStep.phase === 2) {
    const phase1Steps = getStepsForPhase(1)
    return phase1Steps[phase1Steps.length - 1]
  }

  return undefined
}

export function calculateRiskScore(likelihood: RiskLikelihood, impact: RiskImpact): number {
  return likelihood * impact
}

export function getRiskSeverityFromScore(score: number): RiskSeverity {
  if (score >= 20) return 'CRITICAL'
  if (score >= 12) return 'HIGH'
  if (score >= 6) return 'MEDIUM'
  return 'LOW'
}

export function calculateResidualRisk(risk: Risk): number {
  const inherentScore = calculateRiskScore(risk.likelihood, risk.impact)
  const totalEffectiveness = risk.mitigation
    .filter(m => m.status === 'COMPLETED')
    .reduce((sum, m) => sum + m.effectiveness, 0)

  const effectivenessMultiplier = Math.min(totalEffectiveness, 100) / 100
  return Math.max(1, Math.round(inherentScore * (1 - effectivenessMultiplier)))
}

export function getCompletionPercentage(state: SDKState): number {
  const totalSteps = SDK_STEPS.length
  const completedSteps = state.completedSteps.length
  return Math.round((completedSteps / totalSteps) * 100)
}

export function getPhaseCompletionPercentage(state: SDKState, phase: SDKPhase): number {
  const phaseSteps = getStepsForPhase(phase)
  const completedPhaseSteps = phaseSteps.filter(s => state.completedSteps.includes(s.id))
  return Math.round((completedPhaseSteps.length / phaseSteps.length) * 100)
}

// =============================================================================
// PACKAGE HELPER FUNCTIONS
// =============================================================================

export function getPackageById(packageId: SDKPackageId): SDKPackage | undefined {
  return SDK_PACKAGES.find(p => p.id === packageId)
}

export function getStepsForPackage(packageId: SDKPackageId): SDKStep[] {
  return SDK_STEPS.filter(s => s.package === packageId).sort((a, b) => a.order - b.order)
}

export function getPackageCompletionPercentage(state: SDKState, packageId: SDKPackageId): number {
  const packageSteps = getStepsForPackage(packageId)
  if (packageSteps.length === 0) return 0
  const completedPackageSteps = packageSteps.filter(s => state.completedSteps.includes(s.id))
  return Math.round((completedPackageSteps.length / packageSteps.length) * 100)
}

export function getCurrentPackage(currentStepId: string): SDKPackage | undefined {
  const step = getStepById(currentStepId)
  if (!step) return undefined
  return getPackageById(step.package)
}

export function getNextPackageStep(currentStepId: string): SDKStep | undefined {
  const currentStep = getStepById(currentStepId)
  if (!currentStep) return undefined

  const packageSteps = getStepsForPackage(currentStep.package)
  const currentIndex = packageSteps.findIndex(s => s.id === currentStepId)

  // Next step in same package
  if (currentIndex < packageSteps.length - 1) {
    return packageSteps[currentIndex + 1]
  }

  // Move to next package
  const currentPackage = getPackageById(currentStep.package)
  if (!currentPackage) return undefined

  const nextPackage = SDK_PACKAGES.find(p => p.order === currentPackage.order + 1)
  if (!nextPackage) return undefined

  const nextPackageSteps = getStepsForPackage(nextPackage.id)
  return nextPackageSteps[0]
}

export function isPackageUnlocked(state: SDKState, packageId: SDKPackageId): boolean {
  if (state.preferences?.allowParallelWork) return true

  const currentPackage = getPackageById(packageId)
  if (!currentPackage) return false

  // First package is always unlocked
  if (currentPackage.order === 1) return true

  // Previous package must be completed
  const prevPackage = SDK_PACKAGES.find(p => p.order === currentPackage.order - 1)
  if (!prevPackage) return true

  return getPackageCompletionPercentage(state, prevPackage.id) === 100
}

export function getVisibleStepsForCustomerType(customerType: CustomerType): SDKStep[] {
  return SDK_STEPS.filter(step => {
    // Import step is only for existing customers
    if (step.id === 'import') {
      return customerType === 'existing'
    }
    return true
  })
}


// =============================================================================
// DOCUMENT GENERATOR TYPES (Legal Templates RAG)
// =============================================================================

/**
 * License types for legal templates with compliance metadata
 */
export type LicenseType =
  | 'public_domain'   // §5 UrhG German official works
  | 'cc0'             // CC0 1.0 Universal
  | 'unlicense'       // Unlicense (public domain)
  | 'mit'             // MIT License
  | 'cc_by_4'         // CC BY 4.0 International
  | 'reuse_notice'    // EU reuse notice (source required)

/**
 * Template types available for document generation
 */
export type TemplateType =
  | 'privacy_policy'
  | 'terms_of_service'
  | 'agb'
  | 'cookie_banner'
  | 'cookie_policy'
  | 'impressum'
  | 'widerruf'
  | 'dpa'
  | 'sla'
  | 'nda'
  | 'cloud_service_agreement'
  | 'data_usage_clause'
  | 'acceptable_use'
  | 'community_guidelines'
  | 'copyright_policy'
  | 'clause'

/**
 * Jurisdiction codes for legal documents
 */
export type Jurisdiction = 'DE' | 'AT' | 'CH' | 'EU' | 'US' | 'INTL'

/**
 * A single legal template search result from RAG
 */
export interface LegalTemplateResult {
  id: string
  score: number
  text: string
  documentTitle: string | null
  templateType: TemplateType | null
  clauseCategory: string | null
  language: 'de' | 'en'
  jurisdiction: Jurisdiction | null

  // License information
  licenseId: LicenseType | null
  licenseName: string | null
  licenseUrl: string | null
  attributionRequired: boolean
  attributionText: string | null

  // Source information
  sourceName: string | null
  sourceUrl: string | null
  sourceRepo: string | null
  placeholders: string[]

  // Document characteristics
  isCompleteDocument: boolean
  isModular: boolean
  requiresCustomization: boolean

  // Usage rights
  outputAllowed: boolean
  modificationAllowed: boolean
  distortionProhibited: boolean
}

/**
 * Reference to a template used in document generation (for attribution)
 */
export interface TemplateReference {
  templateId: string
  sourceName: string
  sourceUrl: string
  licenseId: LicenseType
  licenseName: string
  attributionRequired: boolean
  attributionText: string | null
  usedAt: string  // ISO timestamp
}

/**
 * A generated document with attribution tracking
 */
export interface GeneratedDocument {
  id: string
  documentType: TemplateType
  title: string
  content: string
  language: 'de' | 'en'
  jurisdiction: Jurisdiction

  // Templates and sources used
  usedTemplates: TemplateReference[]

  // Generated attribution footer
  attributionFooter: string

  // Customization
  placeholderValues: Record<string, string>
  customizations: DocumentCustomization[]

  // Metadata
  generatedAt: string
  generatedBy: string
  version: number
}

/**
 * A customization applied to a generated document
 */
export interface DocumentCustomization {
  type: 'add_section' | 'modify_section' | 'remove_section' | 'replace_placeholder'
  section: string | null
  originalText: string | null
  newText: string | null
  reason: string | null
  appliedAt: string
}

/**
 * State for the document generator feature
 */
export interface DocumentGeneratorState {
  // Search state
  searchQuery: string
  searchResults: LegalTemplateResult[]
  selectedTemplates: string[]  // Template IDs

  // Current document being generated
  currentDocumentType: TemplateType | null
  currentLanguage: 'de' | 'en'
  currentJurisdiction: Jurisdiction

  // Editor state
  editorContent: string
  editorMode: 'preview' | 'edit'
  unsavedChanges: boolean

  // Placeholder values
  placeholderValues: Record<string, string>

  // Generated documents history
  generatedDocuments: GeneratedDocument[]

  // UI state
  isGenerating: boolean
  isSearching: boolean
  lastError: string | null
}

/**
 * Search request for legal templates
 */
export interface TemplateSearchRequest {
  query: string
  templateType?: TemplateType
  licenseTypes?: LicenseType[]
  language?: 'de' | 'en'
  jurisdiction?: Jurisdiction
  attributionRequired?: boolean
  limit?: number
}

/**
 * Document generation request
 */
export interface DocumentGenerationRequest {
  documentType: TemplateType
  language: 'de' | 'en'
  jurisdiction: Jurisdiction
  templateIds: string[]  // Selected template IDs to use
  placeholderValues: Record<string, string>
  companyProfile?: Partial<CompanyProfile>  // For auto-filling placeholders
  additionalContext?: string
}

/**
 * Source configuration for legal templates
 */
export interface TemplateSource {
  name: string
  description: string
  licenseType: LicenseType
  licenseName: string
  templateTypes: TemplateType[]
  languages: ('de' | 'en')[]
  jurisdiction: Jurisdiction
  repoUrl: string | null
  webUrl: string | null
  priority: number
  enabled: boolean
  attributionRequired: boolean
}

/**
 * Status of template ingestion
 */
export interface TemplateIngestionStatus {
  running: boolean
  lastRun: string | null
  currentSource: string | null
  results: Record<string, SourceIngestionResult>
}

/**
 * Result of ingesting a single source
 */
export interface SourceIngestionResult {
  status: 'pending' | 'running' | 'completed' | 'failed'
  documentsFound: number
  chunksIndexed: number
  errors: string[]
}

/**
 * Statistics for the legal templates collection
 */
export interface TemplateCollectionStats {
  collection: string
  vectorsCount: number
  pointsCount: number
  status: string
  templateTypes: Record<TemplateType, number>
  languages: Record<string, number>
  licenses: Record<LicenseType, number>
}

/**
 * Default placeholder values commonly used in legal documents
 */
export const DEFAULT_PLACEHOLDERS: Record<string, string> = {
  '[COMPANY_NAME]': '',
  '[FIRMENNAME]': '',
  '[ADDRESS]': '',
  '[ADRESSE]': '',
  '[EMAIL]': '',
  '[PHONE]': '',
  '[TELEFON]': '',
  '[WEBSITE]': '',
  '[LEGAL_REPRESENTATIVE]': '',
  '[GESCHAEFTSFUEHRER]': '',
  '[REGISTER_COURT]': '',
  '[REGISTERGERICHT]': '',
  '[REGISTER_NUMBER]': '',
  '[REGISTERNUMMER]': '',
  '[VAT_ID]': '',
  '[UST_ID]': '',
  '[DPO_NAME]': '',
  '[DSB_NAME]': '',
  '[DPO_EMAIL]': '',
  '[DSB_EMAIL]': '',
}

/**
 * Template type labels for display
 */
export const TEMPLATE_TYPE_LABELS: Record<TemplateType, string> = {
  privacy_policy: 'Datenschutzerklärung',
  terms_of_service: 'Nutzungsbedingungen',
  agb: 'Allgemeine Geschäftsbedingungen',
  cookie_banner: 'Cookie-Banner',
  cookie_policy: 'Cookie-Richtlinie',
  impressum: 'Impressum',
  widerruf: 'Widerrufsbelehrung',
  dpa: 'Auftragsverarbeitungsvertrag',
  sla: 'Service Level Agreement',
  nda: 'Geheimhaltungsvereinbarung',
  cloud_service_agreement: 'Cloud-Dienstleistungsvertrag',
  data_usage_clause: 'Datennutzungsklausel',
  acceptable_use: 'Acceptable Use Policy',
  community_guidelines: 'Community-Richtlinien',
  copyright_policy: 'Urheberrechtsrichtlinie',
  clause: 'Vertragsklausel',
}

/**
 * License type labels for display
 */
export const LICENSE_TYPE_LABELS: Record<LicenseType, string> = {
  public_domain: 'Public Domain (§5 UrhG)',
  cc0: 'CC0 1.0 Universal',
  unlicense: 'Unlicense',
  mit: 'MIT License',
  cc_by_4: 'CC BY 4.0 International',
  reuse_notice: 'EU Reuse Notice',
}

/**
 * Jurisdiction labels for display
 */
export const JURISDICTION_LABELS: Record<Jurisdiction, string> = {
  DE: 'Deutschland',
  AT: 'Österreich',
  CH: 'Schweiz',
  EU: 'Europäische Union',
  US: 'United States',
  INTL: 'International',
}
