import { Viewer, DocumentGate, saveFile } from '@embedpdf/react/runtime';
import type { OpenInput } from '@embedpdf/react/runtime';
import { Stage, stagePlugin } from '@embedpdf/react/stage';
import { RenderLayer, renderPlugin } from '@embedpdf/react/render';
import {
attachmentPlugin,
displayNameOf,
useAttachment,
useAttachmentState,
} from '@embedpdf/react/attachment';
import type { AttachedFile } from '@embedpdf/react/attachment';
import { cloudEngine } from '@cloudpdf/engine';
import './files.css';
const engine = cloudEngine();
const plugins = [stagePlugin(), renderPlugin(), attachmentPlugin()];
const welcome: OpenInput = { kind: 'grant', grant: 'shr_gvpJcG1ULUMon19C0D1wODSY' };
/** A file's size, as people read it. */
const sizeOf = (bytes: number | null) =>
bytes === null ? '' : bytes < 1024 ? `${bytes} B` : `${(bytes / 1024).toFixed(1)} KB`;
// The files the document carries: attach some, save one, remove one.
function Files() {
const attachment = useAttachment();
const { files, canCreate, canDownload } = useAttachmentState();
const save = async (file: AttachedFile) => {
const { bytes, name, mimeType } = await attachment.download(file);
saveFile(bytes, name, mimeType ?? undefined);
};
return (
);
}
export default function App() {
return (