/**
 * Catalog Registry — Reference Catalogs (Legal Bases, Frameworks, Enforcement)
 */

import type { CatalogId, CatalogMeta } from '../types'
import { EU_BASE_FRAMEWORKS, NATIONAL_FRAMEWORKS } from '../../dsfa/eu-legal-frameworks'
import { GDPR_ENFORCEMENT_CASES } from '../../dsfa/gdpr-enforcement-cases'
import { LEGAL_BASIS_INFO, STANDARD_RETENTION_PERIODS } from '../../vendor-compliance/catalog/legal-basis'

export const REFERENCE_CATALOG_META: Partial<Record<CatalogId, CatalogMeta>> = {
  'legal-bases': {
    id: 'legal-bases',
    name: 'Rechtsgrundlagen',
    description: 'DSGVO Art. 6 und Art. 9 Rechtsgrundlagen',
    module: 'reference',
    icon: 'Scale',
    systemCount: LEGAL_BASIS_INFO.length,
    allowCustom: false,
    idField: 'type',
    nameField: 'name',
    descriptionField: 'description',
    categoryField: 'article',
    fields: [
      { key: 'type', label: 'Typ', type: 'text', required: true },
      { key: 'article', label: 'Artikel', type: 'text', required: true },
      { key: 'name', label: 'Name', type: 'text', required: true },
      { key: 'description', label: 'Beschreibung', type: 'textarea', required: true },
      { key: 'isSpecialCategory', label: 'Besondere Kategorie (Art. 9)', type: 'boolean', required: false },
    ],
    searchableFields: ['type', 'article', 'name', 'description'],
  },

  'retention-periods': {
    id: 'retention-periods',
    name: 'Aufbewahrungsfristen',
    description: 'Gesetzliche Standard-Aufbewahrungsfristen',
    module: 'reference',
    icon: 'Timer',
    systemCount: STANDARD_RETENTION_PERIODS.length,
    allowCustom: false,
    idField: 'id',
    nameField: 'name',
    descriptionField: 'description',
    fields: [
      { key: 'id', label: 'ID', type: 'text', required: true },
      { key: 'name', label: 'Name', type: 'text', required: true },
      { key: 'legalBasis', label: 'Rechtsgrundlage', type: 'text', required: true },
      { key: 'description', label: 'Beschreibung', type: 'textarea', required: true },
    ],
    searchableFields: ['id', 'name', 'legalBasis', 'description'],
  },

  'eu-legal-frameworks': {
    id: 'eu-legal-frameworks',
    name: 'EU-Rechtsrahmen',
    description: 'EU-weite Datenschutzgesetze und -verordnungen',
    module: 'reference',
    icon: 'Landmark',
    systemCount: EU_BASE_FRAMEWORKS.length,
    allowCustom: false,
    idField: 'id',
    nameField: 'name',
    descriptionField: 'description',
    categoryField: 'type',
    fields: [
      { key: 'id', label: 'ID', type: 'text', required: true },
      { key: 'name', label: 'Name', type: 'text', required: true },
      { key: 'fullName', label: 'Vollstaendiger Name', type: 'text', required: true },
      { key: 'type', label: 'Typ', type: 'text', required: true },
      { key: 'description', label: 'Beschreibung', type: 'textarea', required: true },
    ],
    searchableFields: ['id', 'name', 'fullName', 'description', 'type'],
  },

  'national-legal-frameworks': {
    id: 'national-legal-frameworks',
    name: 'Nationale Rechtsrahmen',
    description: 'Nationale Datenschutzgesetze der EU/EWR-Staaten',
    module: 'reference',
    icon: 'Flag',
    systemCount: NATIONAL_FRAMEWORKS.length,
    allowCustom: false,
    idField: 'id',
    nameField: 'name',
    descriptionField: 'description',
    categoryField: 'countryCode',
    fields: [
      { key: 'id', label: 'ID', type: 'text', required: true },
      { key: 'name', label: 'Name', type: 'text', required: true },
      { key: 'countryCode', label: 'Land', type: 'text', required: true },
      { key: 'type', label: 'Typ', type: 'text', required: true },
      { key: 'description', label: 'Beschreibung', type: 'textarea', required: true },
    ],
    searchableFields: ['id', 'name', 'countryCode', 'description', 'type'],
  },

  'gdpr-enforcement-cases': {
    id: 'gdpr-enforcement-cases',
    name: 'DSGVO-Bussgeldentscheidungen',
    description: 'Relevante Bussgeldentscheidungen als Referenz',
    module: 'reference',
    icon: 'Gavel',
    systemCount: GDPR_ENFORCEMENT_CASES.length,
    allowCustom: false,
    idField: 'id',
    nameField: 'company',
    descriptionField: 'description',
    categoryField: 'country',
    fields: [
      { key: 'id', label: 'ID', type: 'text', required: true },
      { key: 'company', label: 'Unternehmen', type: 'text', required: true },
      { key: 'country', label: 'Land', type: 'text', required: true },
      { key: 'year', label: 'Jahr', type: 'number', required: true },
      { key: 'fineOriginal', label: 'Bussgeld (EUR)', type: 'number', required: true },
      { key: 'description', label: 'Beschreibung', type: 'textarea', required: true },
    ],
    searchableFields: ['id', 'company', 'country', 'description'],
  },
}

export const REFERENCE_SYSTEM_ENTRIES: Partial<Record<CatalogId, Record<string, unknown>[]>> = {
  'legal-bases': LEGAL_BASIS_INFO as unknown as Record<string, unknown>[],
  'retention-periods': STANDARD_RETENTION_PERIODS as unknown as Record<string, unknown>[],
  'eu-legal-frameworks': EU_BASE_FRAMEWORKS as unknown as Record<string, unknown>[],
  'national-legal-frameworks': NATIONAL_FRAMEWORKS as unknown as Record<string, unknown>[],
  'gdpr-enforcement-cases': GDPR_ENFORCEMENT_CASES as unknown as Record<string, unknown>[],
}
