import { CheckIcon, DownloadIcon, RefreshCwIcon, RotateCwIcon } from "lucide-react"; import type { AnimationEventHandler } from "react"; import { cn } from "../../lib/utils"; const DOWNLOAD_PROGRESS_RADIUS = 14; const DOWNLOAD_PROGRESS_CIRCUMFERENCE = 2 * Math.PI * DOWNLOAD_PROGRESS_RADIUS; export type DesktopUpdateStatusIconState = | "idle" | "checking" | "available" | "downloading" | "downloaded"; function normalizeDesktopUpdateDownloadPercent(percent: number | null): number { if (percent === null || !Number.isFinite(percent)) return 0; return Math.min(100, Math.max(0, percent)); } export function shouldShowDesktopUpdateCheckIcon({ isAnimationLatched, isChecking, prefersReducedMotion, }: { readonly isAnimationLatched: boolean; readonly isChecking: boolean; readonly prefersReducedMotion: boolean; }): boolean { return isChecking || (isAnimationLatched && !prefersReducedMotion); } export function shouldContinueDesktopUpdateCheckAnimation({ isChecking, prefersReducedMotion, }: { readonly isChecking: boolean; readonly prefersReducedMotion: boolean; }): boolean { return isChecking && !prefersReducedMotion; } function DesktopUpdateAvailableIcon() { return ( ); } function DesktopUpdateDownloadingIcon({ percent }: { readonly percent: number | null }) { const normalizedPercent = normalizeDesktopUpdateDownloadPercent(percent); const progressOffset = DOWNLOAD_PROGRESS_CIRCUMFERENCE * (1 - normalizedPercent / 100); return ( ); } function DesktopUpdateDownloadedIcon() { return ( ); } export function DesktopUpdateStatusIcon({ downloadPercent, isCheckAnimating, onCheckAnimationIteration, status, }: { readonly downloadPercent?: number | null; readonly isCheckAnimating?: boolean; readonly onCheckAnimationIteration?: AnimationEventHandler; readonly status: DesktopUpdateStatusIconState; }) { if (status === "available") return ; if (status === "downloading") { return ; } if (status === "downloaded") return ; return ( ); }