/**
 * DatePicker family type definitions
 * @countermeasure/web-components/form/date-picker
 */

export interface DatePickerConfig {
  /** Container element (or selector) the picker is mounted into. */
  container: HTMLElement | string
  /** Currently selected date. */
  value?: Date | null
  /**
   * Display format. Use `'YYYY-MM-DD'` for ISO output, otherwise locale-formatted.
   * @default 'YYYY-MM-DD'
   */
  format?: string
  /**
   * Placeholder text shown when no date is selected.
   * @default 'Select date...'
   */
  placeholder?: string
  /** Earliest selectable date (inclusive). */
  minDate?: Date
  /** Latest selectable date (inclusive). */
  maxDate?: Date
  /** Disable specific dates via array or predicate. */
  disabledDates?: Date[] | ((date: Date) => boolean)
  /**
   * First day of the week (0 = Sunday, 1 = Monday).
   * @default 0
   */
  weekStart?: 0 | 1
  /** Locale for date formatting (defaults to navigator.language) */
  locale?: string
  /** Additional CSS class names. */
  className?: string
  /** Called whenever the selected date changes. */
  onChange?: (date: Date | null) => void
}

export interface DateRangePreset {
  /** Display label for the preset (e.g. `'Last 7 days'`). */
  label: string
  /** Returns a `[start, end]` tuple computed at click time. */
  getRange: () => [Date, Date]
}

export interface DateRangePickerConfig {
  /** Container element (or selector) the picker is mounted into. */
  container: HTMLElement | string
  /** Currently selected start date. */
  startDate?: Date | null
  /** Currently selected end date. */
  endDate?: Date | null
  /**
   * Display format. Use `'YYYY-MM-DD'` for ISO output, otherwise locale-formatted.
   * @default 'YYYY-MM-DD'
   */
  format?: string
  /**
   * Quick-select preset list. Defaults to common ranges (last 7/30/90 days, YTD, etc.).
   */
  presets?: DateRangePreset[]
  /** Earliest selectable date (inclusive). */
  minDate?: Date
  /** Latest selectable date (inclusive). */
  maxDate?: Date
  /** Locale for date formatting (defaults to navigator.language) */
  locale?: string
  /** Additional CSS class names. */
  className?: string
  /** Called whenever the selected range changes. */
  onChange?: (start: Date | null, end: Date | null) => void
}

export interface TimePickerConfig {
  /** Container element (or selector) the picker is mounted into. */
  container: HTMLElement | string
  /**
   * Initial time value. Seconds default to 0 if omitted.
   */
  value?: { hours: number; minutes: number; seconds?: number }
  /**
   * Use 24-hour clock instead of 12-hour with AM/PM.
   * @default false
   */
  use24Hour?: boolean
  /**
   * Show the seconds column.
   * @default false
   */
  showSeconds?: boolean
  /** Additional CSS class names. */
  className?: string
  /** Called whenever the time value changes. */
  onChange?: (time: { hours: number; minutes: number; seconds: number }) => void
}
