import { Copy } from "lucide-react"; import { useToast } from "@/context/ToastContext"; import { copyTextToClipboard } from "@/lib/clipboard"; import { cn } from "@/lib/utils"; export function gatewayEndpointUrl(endpointPath: string): string { if (typeof window === "undefined") return endpointPath; try { return new URL(endpointPath, window.location.origin).toString(); } catch { return endpointPath; } } export function CopyableGatewayUrl({ endpointPath, className, }: { endpointPath: string; className?: string; }) { const { pushToast } = useToast(); const url = gatewayEndpointUrl(endpointPath); async function copy() { try { await copyTextToClipboard(url); pushToast({ title: "Gateway URL copied", tone: "success" }); } catch { pushToast({ title: "Copy failed", body: "Clipboard access is unavailable.", tone: "error", }); } } return ( ); }