import { Loader2, Upload, X } from "lucide-react"; import { useState } from "react"; import { createPortal } from "react-dom"; import { api, errorMessage } from "../api"; import { Alert } from "../components/ui"; import { useI18n } from "../i18n"; // Real Telegram sticker/emoji packs are created with at least one item, so // this form collects the title/short name plus a single starting file — // exactly like CreateStickerSet's domain-level requirement. More stickers // get added afterward from the pack's own preview modal. export function CreateStickerSetModal({ kind, onClose, onCreated }: { kind: "stickers" | "emoji"; onClose: () => void; onCreated: () => void }) { const { t } = useI18n(); const noun = kind === "emoji" ? "emoji" : "sticker"; const [title, setTitle] = useState(""); const [shortName, setShortName] = useState(""); const [emoji, setEmoji] = useState(""); const [file, setFile] = useState(null); const [reason, setReason] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState(""); async function submit() { if (!title.trim() || !shortName.trim() || !emoji.trim() || !file) { setError(t("stickers.createFieldsRequired", { noun })); return; } if (!reason.trim()) { setError(t("action.reasonRequired")); return; } setBusy(true); setError(""); try { const form = new FormData(); form.set("metadata", JSON.stringify({ command_id: "", reason: reason.trim(), confirm: true, title: title.trim(), short_name: shortName.trim().toLowerCase(), kind, emoji: emoji.trim() })); form.set("file", file, file.name); await api.createStickerSet(form); onCreated(); onClose(); } catch (err) { setError(errorMessage(err)); } finally { setBusy(false); } } return createPortal(
{t("stickers.createEyebrow")}

{t("stickers.createTitle", { noun })}

{error && {error}}
, document.body ); }