"use client"; import React, { useState, useEffect, useRef } from "react"; import { DrawIoEmbed } from "react-drawio"; import ChatPanel from "@/components/chat-panel"; import { useDiagram } from "@/contexts/diagram-context"; import { Monitor } from "lucide-react"; import { ResizablePanelGroup, ResizablePanel, ResizableHandle, } from "@/components/ui/resizable"; import type { ImperativePanelHandle } from "react-resizable-panels"; export default function Home() { const { drawioRef, handleDiagramExport } = useDiagram(); const [isMobile, setIsMobile] = useState(false); const [isChatVisible, setIsChatVisible] = useState(true); const chatPanelRef = useRef(null); useEffect(() => { const checkMobile = () => { setIsMobile(window.innerWidth < 768); }; checkMobile(); window.addEventListener("resize", checkMobile); return () => window.removeEventListener("resize", checkMobile); }, []); const toggleChatPanel = () => { const panel = chatPanelRef.current; if (panel) { if (panel.isCollapsed()) { panel.expand(); setIsChatVisible(true); } else { panel.collapse(); setIsChatVisible(false); } } }; useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { if ((event.ctrlKey || event.metaKey) && event.key === 'b') { event.preventDefault(); toggleChatPanel(); } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, []); // Show confirmation dialog when user tries to leave the page // This helps prevent accidental navigation from browser back gestures useEffect(() => { const handleBeforeUnload = (event: BeforeUnloadEvent) => { event.preventDefault(); return ''; }; window.addEventListener('beforeunload', handleBeforeUnload); return () => window.removeEventListener('beforeunload', handleBeforeUnload); }, []); return (
{/* Mobile warning overlay */} {isMobile && (

Desktop Required

This application works best on desktop or laptop devices. Please open it on a larger screen for the full experience.

)} {/* Draw.io Canvas */}
{/* Chat Panel */} setIsChatVisible(false)} onExpand={() => setIsChatVisible(true)} >
); }