"use client" import React, { createContext, useContext, useState, useRef } from 'react'; import { ImperativePanelHandle } from "react-resizable-panels"; interface PreviewContextType { isPreviewCollapsed: boolean; setIsPreviewCollapsed: React.Dispatch>; previewURL: string; setPreviewURL: React.Dispatch>; previewPanelRef: React.RefObject; } const PreviewContext = createContext(undefined); export const PreviewProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => { const [isPreviewCollapsed, setIsPreviewCollapsed] = useState(true); const [previewURL, setPreviewURL] = useState(""); const previewPanelRef = useRef(null); return ( {children} ); }; export const usePreview = () => { const context = useContext(PreviewContext); if (context === undefined) { throw new Error('usePreview must be used within a PreviewProvider'); } return context; };