// @design-system: primitives/LaunchModePicker
/**
 * LaunchModePicker — two-option segmented control for "Launch now" vs "Scheduled launch".
 *
 * Composes SegmentedControl. All keyboard / RTL / a11y handled by parent primitive.
 *
 * @example
 * ```tsx
 * <LaunchModePicker
 *   value={launchMode}
 *   onChange={setLaunchMode}
 *   nowLabel={t('launch_mode_now')}
 *   scheduledLabel={t('launch_mode_scheduled')}
 * />
 * ```
 */

'use client';

import { SegmentedControl } from '@/components/ui/primitives/SegmentedControl';

export type LaunchMode = 'now' | 'scheduled';

export interface LaunchModePickerProps {
  /** Currently selected mode. */
  value: LaunchMode;
  /** Called when the user changes the mode. */
  onChange: (v: LaunchMode) => void;
  /** Translated label for the "launch now" option. */
  nowLabel: string;
  /** Translated label for the "scheduled launch" option. */
  scheduledLabel: string;
  /** Accessible label for the radiogroup. */
  ariaLabel?: string;
  /** Additional class names applied to the container. */
  className?: string;
}

/**
 * LaunchModePicker — segmented "Launch now / Scheduled" toggle.
 *
 * a11y: inherits full radiogroup + roving-tabIndex + Arrow-key support from SegmentedControl.
 */
export function LaunchModePicker({
  value,
  onChange,
  nowLabel,
  scheduledLabel,
  ariaLabel = 'Launch mode',
  className,
}: LaunchModePickerProps) {
  return (
    <SegmentedControl
      aria-label={ariaLabel}
      value={value}
      onChange={(v) => onChange(v as LaunchMode)}
      options={[
        { value: 'now', label: nowLabel },
        { value: 'scheduled', label: scheduledLabel },
      ]}
      className={className}
    />
  );
}
