/**
 * Company profile, machine builder profile, and related label constants.
 */

import type {
  BusinessModel,
  OfferingType,
  TargetMarket,
  CompanySize,
  LegalForm,
  MachineProductType,
  AIIntegrationType,
  HumanOversightLevel,
  CriticalSector,
} from './enums'

// =============================================================================
// PROJECT INFO (Multi-Projekt-Architektur)
// =============================================================================

export interface ProjectInfo {
  id: string
  name: string
  description: string
  customerType: 'new' | 'existing'
  status: 'active' | 'archived'
  projectVersion: number
  completionPercentage: number
  createdAt: string
  updatedAt: string
}

// =============================================================================
// MACHINE BUILDER PROFILE (IACE)
// =============================================================================

export interface MachineBuilderProfile {
  // Produkt
  productTypes: MachineProductType[]
  productDescription: string
  productPride: string
  containsSoftware: boolean
  containsFirmware: boolean
  containsAI: boolean
  aiIntegrationType: AIIntegrationType[]

  // Sicherheit
  hasSafetyFunction: boolean
  safetyFunctionDescription: string
  autonomousBehavior: boolean
  humanOversightLevel: HumanOversightLevel

  // Konnektivitaet
  isNetworked: boolean
  hasRemoteAccess: boolean
  hasOTAUpdates: boolean
  updateMechanism: string

  // Markt & Kunden
  exportMarkets: string[]
  criticalSectorClients: boolean
  criticalSectors: CriticalSector[]
  oemClients: boolean

  // CE
  ceMarkingRequired: boolean
  existingCEProcess: boolean
  hasRiskAssessment: boolean
}

// =============================================================================
// COMPANY PROFILE
// =============================================================================

export interface CompanyProfile {
  // Basic Info
  companyName: string
  legalForm: LegalForm
  industry: string[]
  industryOther: string
  foundedYear: number | null

  // Business Model
  businessModel: BusinessModel
  offerings: OfferingType[]
  offeringUrls: Partial<Record<string, string>>

  // Size & Scope
  companySize: CompanySize
  employeeCount: string
  annualRevenue: string

  // Locations
  headquartersCountry: string
  headquartersCountryOther: string
  headquartersStreet: string
  headquartersZip: string
  headquartersCity: string
  headquartersState: string
  hasInternationalLocations: boolean
  internationalCountries: string[]

  // Target Markets & Legal Scope
  targetMarkets: TargetMarket[]
  primaryJurisdiction: string

  // Data Processing Role
  isDataController: boolean
  isDataProcessor: boolean

  // Contact Persons
  dpoName: string | null
  dpoEmail: string | null
  legalContactName: string | null
  legalContactEmail: string | null

  // Machine Builder (IACE)
  machineBuilder?: MachineBuilderProfile

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

// =============================================================================
// LABEL CONSTANTS
// =============================================================================

export const MACHINE_PRODUCT_TYPE_LABELS: Record<MachineProductType, string> = {
  test_stand: 'Pruefstand',
  robot_cell: 'Roboterzelle',
  special_machine: 'Sondermaschine',
  production_line: 'Produktionslinie',
  other: 'Sonstige',
}

export const AI_INTEGRATION_TYPE_LABELS: Record<AIIntegrationType, string> = {
  vision: 'Bildverarbeitung / Machine Vision',
  predictive_maintenance: 'Predictive Maintenance',
  quality_control: 'Qualitaetskontrolle',
  robot_control: 'Robotersteuerung',
  process_optimization: 'Prozessoptimierung',
  other: 'Sonstige',
}

export const HUMAN_OVERSIGHT_LABELS: Record<HumanOversightLevel, string> = {
  full: 'Vollstaendig (Mensch entscheidet immer)',
  partial: 'Teilweise (Mensch ueberwacht)',
  minimal: 'Minimal (Mensch greift nur bei Stoerung ein)',
  none: 'Keine (vollautonomer Betrieb)',
}

export const CRITICAL_SECTOR_LABELS: Record<CriticalSector, string> = {
  energy: 'Energie',
  water: 'Wasser',
  transport: 'Transport / Verkehr',
  health: 'Gesundheit',
  pharma: 'Pharma',
  automotive: 'Automotive',
  defense: 'Verteidigung',
}

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

export const BUSINESS_MODEL_LABELS: Record<BusinessModel, { short: string; description: string }> = {
  B2B: { short: 'B2B', description: 'Verkauf an Gesch\u00e4ftskunden' },
  B2C: { short: 'B2C', description: 'Verkauf an Privatkunden' },
  B2B_B2C: { short: 'B2B + B2C', description: 'Verkauf an Gesch\u00e4fts- und Privatkunden' },
  B2B2C: { short: 'B2B2C', description: '\u00dcber Partner an Endkunden (z.B. Plattform, White-Label)' },
}

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: 'Physische Produkte oder Hardware-Abos verkaufen' },
  hardware: { label: 'Hardware-Verkauf', description: 'Physische Produkte' },
  software_saas: { label: 'SaaS/Cloud', description: 'Software online bereitstellen (auch wenn ueber einen Shop verkauft)' },
  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, \u00d6sterreich, Schweiz',
    regulations: ['DSGVO', 'BDSG', 'DSG (AT)', 'DSG (CH)', 'AI Act'],
  },
  eu: {
    label: 'Europ\u00e4ische 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\u00dfbritannien',
    description: 'EU plus Vereinigtes K\u00f6nigreich',
    regulations: ['DSGVO', 'UK GDPR', 'AI Act', 'UK AI Framework'],
  },
  worldwide: {
    label: 'Weltweit',
    description: 'Globaler Verkauf/Betrieb',
    regulations: ['DSGVO', 'CCPA', 'LGPD', 'POPIA', 'und weitere...'],
  },
}
