import { useEffect, useState } from 'react'; import { Viewer, DocumentGate } 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 { shellPlugin, useShell, useShellState, useSurface } from '@embedpdf/react/shell'; import type { ShellSnapshot } from '@embedpdf/react/shell'; import { localEngine } from '@embedpdf/engine'; import './remember.css'; const engine = localEngine(); const plugins = [stagePlugin(), renderPlugin(), shellPlugin()]; // [!doc-source welcome] const welcome = async (): Promise => { const response = await fetch('https://www.embedpdf.com/pdfs/welcome.pdf'); return { kind: 'bytes', id: 'welcome', bytes: new Uint8Array(await response.arrayBuffer()) }; }; // [!/doc-source] // The browser may refuse storage, in a private window: then nothing is remembered. const loadLayout = (): ShellSnapshot | null => { try { return JSON.parse(localStorage.getItem('panels') ?? 'null') as ShellSnapshot | null; } catch { return null; } }; const saveLayout = (snapshot: ShellSnapshot) => { try { localStorage.setItem('panels', JSON.stringify(snapshot)); } catch { // Not remembered this time. } }; const TIPS = [ 'Ctrl or ⌘ and scroll to zoom', 'Pinch to zoom on a touch screen', 'Drag between pages to scroll', ]; function PanelButton({ id, label, side }: { id: string; label: string; side: 'left' | 'right' }) { const panel = useSurface(id); return ( ); } function TipsPanel() { const panel = useSurface('tips'); if (!panel.isOpen) return null; return ( ); } function NotesPanel() { const panel = useSurface('notes'); if (!panel.isOpen) return null; return (