import React, { useId } from 'react' import { Activity, AlertTriangle, ArrowRightLeft, Check, CheckCircle2, Cloud, Copy, FolderTree, HardDrive, Loader2, Lock, Pencil, PlugZap, Plus, RefreshCw, RotateCcw, Trash2, X, type LucideIcon, } from 'lucide-react' import { STORAGE_CATEGORIES, type StorageTestResponse } from '@trek/shared' import { useTranslation } from '../../../i18n' import { formatBytes } from '../../../utils/formatBytes' import { relativeTime } from '../../../utils/relativeTime' import ConfirmDialog from '../../shared/ConfirmDialog' import CustomSelect from '../../shared/CustomSelect' import { Tooltip } from '../../shared/Tooltip' import { NEUTRAL_TINT, fs } from '../../shared/DialogShell' import Section from '../../Settings/Section' import { SETTINGS_BUTTON, SETTINGS_BUTTON_PRIMARY, SETTINGS_ICON_BUTTON, SettingRows, SettingsHint, StatusPill, SettingsColumns } from '../../Settings/settingsKit' import BackendForm from './BackendForm' import StorageReclaimSection from './StorageReclaimSection' import { CACHE_CATEGORIES, primaryNameOf } from './storageModel' import { categoryNames, migrationPromptLine, useStoragePanel } from './useStoragePanel' /** The compact buttons of a backend row: white on a hairline, a size under the card's own. */ const ROW_BUTTON = 'inline-flex items-center gap-1.5 rounded-[10px] bg-surface-card px-2.5 py-1.5 font-medium text-content shadow-sm ring-1 ring-edge-faint hover:bg-surface-secondary disabled:cursor-default disabled:opacity-50' const ROW_BUTTON_PRIMARY = 'inline-flex items-center gap-1.5 rounded-[10px] bg-accent px-2.5 py-1.5 font-medium text-accent-text hover:opacity-90 disabled:cursor-default disabled:opacity-50' /** The icon square on the left of a row. */ const TILE = 'grid h-9 w-9 flex-none place-items-center rounded-[10px] bg-surface-tertiary text-content-muted' /** What a row says under its head line, lined up with the name rather than the tile. */ const DETAILS = 'mt-2 flex flex-col items-start gap-1.5 empty:hidden sm:ps-12' const META = 'm-0 leading-snug text-content-faint' const TYPE_ICON: Record = { local: HardDrive, s3: Cloud, mirror: Copy } function TestResult({ result, failedLabel, okLabel }: { result: StorageTestResponse | undefined failedLabel: string okLabel: string }): React.ReactElement | null { if (result === undefined) return null return (
: } > {result.ok ? okLabel : failedLabel} {result.targets.map((target) => (

{target.ok ? : } {target.name} {target.error ? ` โ€” ${target.error}` : ''}

))}
) } /** A thin bar for a running sync or move. */ function Progress({ done, total }: { done: number; total: number }): React.ReactElement { const share = total > 0 ? Math.min(100, Math.round((done / total) * 100)) : 0 return (