learning_ai_clock/web/src/lib/urgency.ts
2026-03-04 20:01:34 -08:00

103 lines
3.1 KiB
TypeScript

// ── Urgency System ─────────────────────────────────────────────
// 5 levels mapping to notification style, sound, vibration, visual intensity, snooze behavior
export type UrgencyLevel = 'critical' | 'important' | 'standard' | 'gentle' | 'passive';
export interface UrgencyConfig {
level: UrgencyLevel;
label: string;
color: string;
bgColor: string;
borderColor: string;
notificationStyle: 'persistent' | 'prominent' | 'default' | 'subtle' | 'badge';
soundEnabled: boolean;
vibrationPattern: number[]; // ms on/off pattern
visualIntensity: number; // 0-1
autoSnoozeMinutes: number | null; // null = no auto-snooze
requireConfirmToDismiss: boolean;
fullScreenOverlay: boolean;
}
export const URGENCY_CONFIGS: Record<UrgencyLevel, UrgencyConfig> = {
critical: {
level: 'critical',
label: 'Critical',
color: 'var(--cm-critical)',
bgColor: 'var(--cm-critical-15)',
borderColor: 'var(--cm-critical-40)',
notificationStyle: 'persistent',
soundEnabled: true,
vibrationPattern: [200, 100, 200, 100, 400],
visualIntensity: 1.0,
autoSnoozeMinutes: null,
requireConfirmToDismiss: true,
fullScreenOverlay: true,
},
important: {
level: 'important',
label: 'Important',
color: 'var(--cm-important)',
bgColor: 'var(--cm-important-15)',
borderColor: 'var(--cm-important-40)',
notificationStyle: 'prominent',
soundEnabled: true,
vibrationPattern: [200, 100, 200],
visualIntensity: 0.8,
autoSnoozeMinutes: 10,
requireConfirmToDismiss: false,
fullScreenOverlay: false,
},
standard: {
level: 'standard',
label: 'Standard',
color: 'var(--cm-standard)',
bgColor: 'var(--cm-standard-15)',
borderColor: 'var(--cm-standard-40)',
notificationStyle: 'default',
soundEnabled: true,
vibrationPattern: [200],
visualIntensity: 0.6,
autoSnoozeMinutes: 5,
requireConfirmToDismiss: false,
fullScreenOverlay: false,
},
gentle: {
level: 'gentle',
label: 'Gentle',
color: 'var(--cm-gentle)',
bgColor: 'var(--cm-gentle-15)',
borderColor: 'var(--cm-gentle-40)',
notificationStyle: 'subtle',
soundEnabled: true,
vibrationPattern: [100],
visualIntensity: 0.3,
autoSnoozeMinutes: 5,
requireConfirmToDismiss: false,
fullScreenOverlay: false,
},
passive: {
level: 'passive',
label: 'Passive',
color: 'var(--cm-passive)',
bgColor: 'var(--cm-passive-10)',
borderColor: 'var(--cm-passive-20)',
notificationStyle: 'badge',
soundEnabled: false,
vibrationPattern: [],
visualIntensity: 0.1,
autoSnoozeMinutes: null,
requireConfirmToDismiss: false,
fullScreenOverlay: false,
},
};
export const URGENCY_ORDER: UrgencyLevel[] = ['critical', 'important', 'standard', 'gentle', 'passive'];
export function getUrgencyConfig(level: UrgencyLevel): UrgencyConfig {
return URGENCY_CONFIGS[level];
}
export function getUrgencyIndex(level: UrgencyLevel): number {
return URGENCY_ORDER.indexOf(level);
}