import { useEffect, useState, type ReactNode } from "react"; import { Loader2, X } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { cn } from "@/lib/utils"; import { useT, type Key } from "@/i18n"; import { asUiError, api } from "@/lib/api"; import { realmRegistry, useRegistryStatus } from "@/lib/registry"; import { asControlError, control, type ControlStatus } from "@/lib/control"; import { isListed, stateTone, type PublishRealm } from "@/lib/publishRealms"; const LANGUAGES = ["en", "ru", "de", "fr", "es", "zh", "pt", "pl", "uk"]; function Modal({ title, onClose, children }: { title: string; onClose: () => void; children: ReactNode }) { const t = useT(); useEffect(() => { const onKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; window.addEventListener("keydown", onKey); return () => window.removeEventListener("keydown", onKey); }, [onClose]); return (
{ if (e.target === e.currentTarget) onClose(); }}>

{title}

{children}
); } /** The name, description, language and region of a listing; the fields are the same for one realm and for all of them. */ function ListingFields({ idPrefix, name, setName, description, setDescription, language, setLanguage, region, setRegion, hideName }: { idPrefix: string; name: string; setName: (v: string) => void; description: string; setDescription: (v: string) => void; language: string; setLanguage: (v: string) => void; region: string; setRegion: (v: string) => void; hideName?: boolean; }) { const t = useT(); return <> {!hideName && <> setName(e.target.value)} className="mt-1 w-full rounded-md border border-line bg-card px-3 py-2" /> }