"use client"; import { useMemo, useState } from "react"; import { ClipboardCopyIcon } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Textarea } from "@/components/ui/textarea"; import { briefingEntryHasContent, briefingToDiarySqf, briefingToStructuredTextSqf, type BriefingSqfEntry, } from "@/lib/intelligence/briefingSqf"; type ExportMode = "script" | "text"; interface BriefingSqfExportProps { entries: BriefingSqfEntry[]; missionName?: string | null; /** "all" is the header button; "entry" is the icon button on one card. */ scope?: "all" | "entry"; } export function BriefingSqfExport({ entries, missionName, scope = "all" }: BriefingSqfExportProps) { const [mode, setMode] = useState("script"); const exportable = useMemo(() => entries.filter(briefingEntryHasContent), [entries]); const preview = useMemo( () => mode === "script" ? briefingToDiarySqf(exportable, { missionName }) : briefingToStructuredTextSqf(exportable), [exportable, missionName, mode], ); const disabled = exportable.length === 0; const count = exportable.length; const copy = async () => { try { await navigator.clipboard.writeText(preview); toast.success(`Copied ${count} briefing ${count === 1 ? "section" : "sections"} as SQF.`, { description: mode === "script" ? "Paste into the debug console or an init script." : "Structured Text bodies for your own diary or hint code.", }); } catch { toast.error("Clipboard access was blocked by the browser."); } }; return ( {scope === "entry" ? ( ) : ( )} Export briefing to SQF {count} {count === 1 ? "section" : "sections"} {missionName ? ` from "${missionName}"` : ""}. Bold, color, headings, lists, and quotes are preserved where Arma 3 Structured Text supports them. setMode(value as ExportMode)}> Diary script Structured text