import { PreparationSummary, type Preparation, } from '@/components/private-investment-preparation'; import { Link } from '@inertiajs/react'; type Snapshot = { preparation?: Preparation | null; context_revision: number; path?: { definition_version: number; steps: Array<{ code: string; title: string; applicability: string; reason: string; state: string; context_review_required?: boolean; }>; }; zone?: { title: string; href: string; version: number | string; fields?: Record; analysis?: { conditions?: Array<{ id: string; label: string; knowledge: string; source_reference?: string; valid_from?: string; valid_until?: string; }>; source?: { title: string; url: string; diploma?: string; article?: string; valid_from?: string; valid_until?: string; } | null; }; } | null; fields?: Record; }; export function InvestmentContextAssessment({ raw, contextId, }: { raw: unknown; contextId?: string | null; }) { let snapshot: Snapshot | null = null; try { const value = JSON.parse(String(raw ?? '')); if (value.version === 1) snapshot = value; } catch { /* Missing context remains explicit. */ } if (!snapshot) return null; const fields = snapshot.fields ?? {}; const zone = snapshot.zone; const steps = (snapshot.path?.steps ?? []).filter(step => !!step.title?.trim()); if (!zone && !fields.investor_origin && !fields.tax_residency_country && !snapshot.preparation?.enabled) return null; const regime = zone?.fields?.investment_regime ?? fields.investment_regime; const names: Record = { zee: 'ZEE', zfi: 'ZFI', industrial_park: 'Parque industrial', }; return (

Condições do investimento

{(fields.investor_origin || fields.tax_residency_country) &&

Origem do investidor:{' '} {{ national: 'nacional', foreign: 'estrangeiro', mixed: 'misto', }[fields.investor_origin] ?? 'informação em falta'} . Residência fiscal declarada:{' '} {fields.tax_residency_country || 'Por preencher'}.

} {zone ? ( <>

Potencialmente aplicável — análise específica de{' '} {names[regime ?? ''] ?? 'zona seleccionada'}. {' '} {zone.title} · consultar condições .

A selecção identifica a referência consultada; não confirma o reconhecimento da entidade, actividade autorizada, licença ou acesso a benefícios. Consulte as condições documentadas na ficha e reúna a autorização ou evidência correspondente no dossier.

{zone.analysis?.source && (

Fundamento cadastrado:{' '} {zone.analysis.source.diploma || zone.analysis.source.title}{' '} {zone.analysis.source.article} . Período cadastrado:{' '} {zone.analysis.source.valid_from || 'início por indicar'}{' '} a{' '} {zone.analysis.source.valid_until || 'sem termo indicado'} . A cobertura do investimento exige correspondência com estas condições.

)} {zone.analysis?.conditions?.length ? (
    {zone.analysis.conditions.map((condition) => (
  • {condition.label}:{' '} {condition.knowledge === 'documented' ? 'condição documentada; cumprimento pelo investimento por confirmar' : condition.knowledge === 'disputed' ? 'condição com informação divergente' : 'informação em falta'} .{' '} {condition.source_reference && ( <> Fundamento:{' '} {condition.source_reference}. )}{' '} {condition.valid_from && ( <>Desde {condition.valid_from}. )}{' '} {condition.valid_until && ( <>Até {condition.valid_until}. )}
  • ))}
) : (

Condições específicas: informação estruturada em falta nesta referência. A ficha e os documentos continuam consultáveis; não se presume cumprimento.

)}

Os benefícios desta zona ainda não estão disponíveis no simulador. O cenário geral disponível não inclui benefícios especiais nem apuramento fiscal final.

) : null} {!!steps.length && (
Etapas a preparar
    {steps.map((step) => (
  • {step.title}:{' '} {step.context_review_required ? 'informação alterada; rever fundamento' : step.applicability === 'not_needed_for_preparation' ? 'não aplicável à preparação declarada' : step.applicability === 'undetermined' ? 'informação em falta' : ['completed', 'approved'].includes( step.state, ) ? 'preparação confirmada no percurso; não é decisão fiscal' : 'potencialmente aplicável'} . {step.reason}
  • ))}
)} {snapshot.preparation?.enabled && ( )} {contextId && ( Rever dados do investimento )}
); }