import { Box, Button, Chip, LinearProgress, Typography } from '@mui/material' import { ExternalLink, Shield, ShieldAlert } from 'lucide-react' import { FreshnessIndicator } from './FreshnessIndicator' import type { Property } from '../../domain/property' interface ProvenancePanelProps { property: Property } const SOURCE_TYPE_LABELS: Record = { ERP_IMPORT: 'ERP-Import', MANUAL_ENTRY: 'Manuelle Eingabe', IMMOSCOUT_SCRAPE: 'ImmoScout24', HOMEGATE_SCRAPE: 'Homegate', NEWHOME_SCRAPE: 'Newhome', MATCHOFFICE_SCRAPE: 'MatchOffice', MAISON_WORK_SCRAPE: 'Maison & Work', AI_SIGNAL: 'KI-Signal', PARTNER_FEED: 'Partner-Feed', UNKNOWN: 'Unbekannt', } const SOURCE_CONFIDENCE: Record = { ERP_IMPORT: 0.95, MANUAL_ENTRY: 0.90, PARTNER_FEED: 0.80, IMMOSCOUT_SCRAPE: 0.65, HOMEGATE_SCRAPE: 0.65, NEWHOME_SCRAPE: 0.60, MATCHOFFICE_SCRAPE: 0.60, MAISON_WORK_SCRAPE: 0.60, AI_SIGNAL: 0.40, UNKNOWN: 0.30, } function getSourceConfidence(sourceType: string): number { return SOURCE_CONFIDENCE[sourceType] ?? 0.50 } function provenanceColor(conf: number): string { if (conf >= 0.8) return '#1a7a4a' if (conf >= 0.6) return '#d97706' return '#c0392b' } export function ProvenancePanel({ property: p }: ProvenancePanelProps) { const sourceLabel = SOURCE_TYPE_LABELS[p.sourceType] ?? p.sourceType const sourceConf = getSourceConfidence(p.sourceType) const confPct = Math.round(sourceConf * 100) const color = provenanceColor(sourceConf) const isVerified = sourceConf >= 0.85 const VerifyIcon = isVerified ? Shield : ShieldAlert return ( {/* Source header */} {sourceLabel} {p.sourceLabel && p.sourceLabel !== sourceLabel && ( · {p.sourceLabel} )} {/* Source confidence bar */} Quell-Vertrauen {confPct}% {/* Dates */} Quellaktualisierung {p.sourceUpdatedAt ? new Date(p.sourceUpdatedAt).toLocaleDateString('de-CH') : '—'} Letzte Verifikation {p.dataQuality.lastVerifiedAt ? new Date(p.dataQuality.lastVerifiedAt).toLocaleDateString('de-CH') : '—'} {/* Freshness */} Aktualität: {/* External URL */} {p.sourceUrl && ( )} ) }