import { Component, input, signal } from '@angular/core'; import { MatButtonToggleModule } from '@angular/material/button-toggle'; import { MatCardModule } from '@angular/material/card'; import { Loading } from '../loading'; import { DurationRow, durationMax } from './durations'; /** A screening route as one compact card: a bar per step with its median, its observations * and its quartiles, read step by step or cumulatively from the sample. A step that is not * published, or has no measurements in the period, keeps its row and says so. */ @Component({ selector: 'app-route-card', imports: [Loading, MatButtonToggleModule, MatCardModule], template: `

{{ title() }}

@if (sample().length && step().length) { Por pasos Acumulado desde la toma }
@if (loading()) { } @else { @let rows = mode() === 'sample' ? sample() : step(); @let max = scale(rows);

@if (mode() === 'sample') { Mediana de días desde la toma de la mastografía hasta cada etapa; cada medida se calcula por separado. } @else { Cada barra es la mediana de su paso, desde cero y por separado; los pasos pueden corresponder a poblaciones diferentes, por lo que las medianas no se suman. } Las marcas indican el primer y tercer cuartil. @if (max) { Escala: 0 a {{ max }} días. }

@for (row of rows; track row.label) { }
{{ mode() === 'sample' ? 'Etapa' : 'Paso' }} Mediana Observaciones Q1–Q3
{{ row.label }} @if (row.status === 'value') { } @else { {{ row.status === 'empty' ? 'Sin mediciones en el periodo' : 'Indicador no publicado' }} } {{ row.status === 'value' ? row.median + ' días' : '—' }} {{ row.observations ?? '—' }} {{ row.low === undefined || row.high === undefined ? '—' : row.low + '–' + row.high }}
}
`, styles: ` :host { display: block; margin-top: 24px; } .head { align-items: center; display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: space-between; } h3 { font-size: 18px; font-weight: 500; margin: 0; } .state { color: var(--color-text-secondary); font-size: 13px; margin: 8px 0; } table { border-collapse: collapse; font-size: 13px; width: 100%; } th { font-weight: 500; text-align: left; } th[scope='row'] { padding: 5px 0; } td, thead th:not(:first-child) { font-variant-numeric: tabular-nums; padding-left: 12px; text-align: right; white-space: nowrap; } .track { background: #eef1f3; display: block; height: 8px; margin-top: 3px; position: relative; } .bar { background: #42a77e; display: block; height: 100%; } .mark { background: #17324d; height: 14px; position: absolute; top: -3px; width: 2px; } .none { color: var(--color-text-secondary); display: block; font-size: 12px; font-weight: 400; margin-top: 3px; } `, }) export class RouteCard { readonly title = input.required(); /** The rows from the sample, and the rows step by step. */ readonly sample = input.required(); readonly step = input.required(); readonly loading = input(false); protected readonly mode = signal<'sample' | 'step'>('step'); protected readonly scale = durationMax; }