import { create } from 'zustand'

interface UIState {
  theme: 'light' | 'dark'
  isSidebarOpen: boolean
  wsConnected: boolean

  toggleTheme: () => void
  setTheme: (theme: 'light' | 'dark') => void
  toggleSidebar: () => void
  setSidebarOpen: (isOpen: boolean) => void
  setWsConnected: (connected: boolean) => void
}

export const useUIStore = create<UIState>((set) => ({
  theme: 'light',
  isSidebarOpen: false,
  wsConnected: false,

  toggleTheme: () =>
    set((state) => ({
      theme: state.theme === 'light' ? 'dark' : 'light',
    })),
  setTheme: (theme) => set({ theme }),
  toggleSidebar: () =>
    set((state) => ({
      isSidebarOpen: !state.isSidebarOpen,
    })),
  setSidebarOpen: (isSidebarOpen) => set({ isSidebarOpen }),
  setWsConnected: (wsConnected) => set({ wsConnected }),
}))