import { NEVER, of } from 'rxjs'; import { inject } from '@angular/core'; import { IndicadoresMemory } from './indicadores-memory'; import { Indicador } from './indicadores.models'; import { emptyAvailability, IndicadoresPeriodos } from './indicadores-periodos'; import { IndicadoresKpiQueries } from './indicadores-kpi-queries'; // Consumer suites start after initialization and isolate availability HTTP. // Initial-period suites exercise the real shared search and domain memory. export const periodAvailabilityProvider = { provide: IndicadoresPeriodos, useFactory: () => { const memory = inject(IndicadoresMemory); for (const domain of ['tea', 'cacu', 'cama'] as const) memory.finishInitialKpiPresentation(domain); return { dominio: (_domain: unknown, catalog: Indicador[]) => { const state = emptyAvailability('ready'); for (const tipo of ['semestre', 'mes'] as const) { state.options[tipo] = [2024, 2025, 2026].flatMap(year => (tipo === 'semestre' ? ['S1', 'S2'] : Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, '0'))).map(unit => year + '-' + unit)); } for (const item of catalog) state.byIndicator[item.id] = item.tipos_periodo.flatMap(tipo => state.options[tipo].map(periodo => ({ tipo, periodo }))); return of(state); } }; }, }; // Figure/search/visibility suites also isolate their HTTP from the KPI panels, // which every domain (TEA included) now renders. KPI suites use the real queries. export const kpiQueriesProvider = { provide: IndicadoresKpiQueries, useValue: { datos: () => NEVER } };