export type HapticStyle = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error' | 'selection';

const PATTERNS: Record<HapticStyle, number | number[]> = {
  light: 10,
  medium: 18,
  heavy: 26,
  success: [10, 28, 10],
  warning: [22, 30, 16],
  error: [30, 30, 30],
  selection: 12,
};

export function triggerHaptic(style: HapticStyle = 'selection'): void {
  if (typeof navigator === 'undefined' || typeof navigator.vibrate !== 'function') {
    return;
  }

  navigator.vibrate(PATTERNS[style] ?? PATTERNS.selection);
}
