1import type { FilePreviewKind } from "@t3tools/shared/filePreview";
2
3/** The available preview and selected body must agree, including source-only draft files. */
4export function attachmentDocumentPresentation(input: {
5 kind: FilePreviewKind;
6 hasTable: boolean;
7 hasEnvironment: boolean;
8 rendered: boolean;
9}) {
10 const renderedMode = input.hasTable
11 ? "table"
12 : input.kind === "markdown" && input.hasEnvironment
13 ? "markdown"
14 : input.kind === "html"
15 ? "html"
16 : null;
17 return {
18 renderedMode,
19 activeMode: input.rendered && renderedMode !== null ? renderedMode : "source",
20 } as const;
21}