/** * Sichtbarkeit für history_overview_viz (sync mit backend dashboard_widget_config). * `visibility === undefined` → Verlauf-Tab: volle Gesamtübersicht (wie bisher). */ export const HISTORY_OVERVIEW_VIZ_PAGE_FULL = { chart_days: 30, show_confidence_banner: true, show_intro_blurb: true, show_area_summaries: true, show_correlation_c1_c3: true, show_drivers_c4: true, } export const HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS = { chart_days: 30, show_confidence_banner: true, show_intro_blurb: true, show_area_summaries: true, show_correlation_c1_c3: true, show_drivers_c4: true, } const BOOL_KEYS = [ 'show_confidence_banner', 'show_intro_blurb', 'show_area_summaries', 'show_correlation_c1_c3', 'show_drivers_c4', ] /** * @param {Record|null|undefined} raw */ export function normalizeHistoryOverviewVizConfig(raw) { const base = { ...HISTORY_OVERVIEW_VIZ_WIDGET_DEFAULTS } if (!raw || typeof raw !== 'object') return base for (const k of BOOL_KEYS) { if (Object.prototype.hasOwnProperty.call(raw, k)) { base[k] = raw[k] === true } } if (raw.chart_days != null) { const n = Number(raw.chart_days) if (Number.isFinite(n)) { base.chart_days = Math.min(90, Math.max(7, Math.round(n))) } } return base }