"use client";

import { Switch } from "@/components/ui/switch";

export type ConfirmableSwitchProps = {
  checked: boolean;
  disabled?: boolean;
  confirmBusy?: boolean;
  "aria-label": string;
  onCheckedChange: (checked: boolean) => void;
};

/**
 * Controlled switch for flows that confirm before applying state.
 * Disables interaction while a confirm dialog is in progress.
 */
export function ConfirmableSwitch({
  checked,
  disabled,
  confirmBusy,
  "aria-label": ariaLabel,
  onCheckedChange,
}: ConfirmableSwitchProps) {
  return (
    <Switch
      checked={checked}
      disabled={disabled || confirmBusy}
      aria-label={ariaLabel}
      onCheckedChange={onCheckedChange}
    />
  );
}
