"use client" import type { WireGuardPeer } from "@/lib/data" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { ArrowDownIcon, ArrowUpIcon, CodeXmlIcon, KeyRoundIcon, Trash2Icon, } from "lucide-react" function fmtBytes(n: number | undefined): string { if (!n) return "—" if (n >= 1_000_000_000) return `${(n / 1_000_000_000).toFixed(1)} ГБ` if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)} МБ` if (n >= 1_000) return `${(n / 1_000).toFixed(0)} КБ` return `${n} Б` } function truncKey(key: string): string { if (key.length <= 20) return key return `${key.slice(0, 8)}…${key.slice(-8)}` } function peerKey(peer: WireGuardPeer, index: number): string { return peer.id ?? peer.rosId ?? peer.publicKey ?? String(index) } function WireGuardPeersDetail({ peers, onDeletePeer, onExportPeer, }: { peers: WireGuardPeer[] onDeletePeer?: (peerId: string) => void onExportPeer?: (peerId: string) => void }) { if (peers.length === 0) { return (