"use client"; import { MonitorSpeaker, Music, Pause, Play } from "@/components/icons/platform-icons"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { Slider } from "@/components/ui/slider"; import { formatBytesCompact } from "@/lib/client/format"; import type { FileReadResponse } from "@/lib/shared/contracts/files"; import { MonacoEditorPane } from "@/modules/files/components/content/file-manager-editor-pane"; import type { FileEntry } from "@/modules/files/components/file-manager-presenters"; import React, { useCallback, useEffect, useRef, useState } from "react"; import type { SetStateAction } from "react"; export type PreviewBodyProps = { fileContentErrorMessage: string; fileContentIsError: boolean; fileContentIsLoading: boolean; onChangeOpenFileDraft: (value: SetStateAction) => void; onSaveOpenFile?: () => void; openFile: { entry: FileEntry }; openFileAssetUrl: string; openFileContent: string; openFileKey: string | null; openFileLanguage: string; openFileViewer: FileReadResponse | null; }; export function PreviewBody({ fileContentErrorMessage, fileContentIsError, fileContentIsLoading, onChangeOpenFileDraft, onSaveOpenFile, openFile, openFileAssetUrl, openFileContent, openFileKey, openFileLanguage, openFileViewer, }: PreviewBodyProps) { const isViewerLoading = fileContentIsLoading || (!fileContentIsError && openFileViewer === null); if (isViewerLoading) { return (
Loading file...
); } if (fileContentIsError) { return (
{fileContentErrorMessage}
); } if (openFileViewer?.mode === "text") { return ( onChangeOpenFileDraft(value)} onSave={onSaveOpenFile} /> ); } if (openFileViewer?.mode === "image") { return (
{/* eslint-disable-next-line @next/next/no-img-element */} {openFile.entry.name}
); } if (openFileViewer?.mode === "pdf") { return (