import { create } from 'zustand';
import { useGitStore } from './gitStore';
import { useSessionFilesStore } from './sessionFilesStore';
import { useResearchStore } from './researchStore';
import { useSettingsStore } from './settingsStore';
import { useTunnelStore } from './tunnelStore';
import { useFileBrowserStore } from './fileBrowserStore';
export const useMCPStore = create((set) => ({
    isExpanded: false,
    servers: [],
    loading: new Set(),
    authUrls: new Map(),
    copilotDevice: null,
    toggleSidebar: () => {
        set((state) => {
            const newExpanded = !state.isExpanded;
            if (newExpanded) {
                useGitStore.getState().collapseSidebar();
                useSessionFilesStore.getState().collapseSidebar();
                useResearchStore.getState().collapseSidebar();
                useSettingsStore.getState().collapseSidebar();
                useTunnelStore.getState().collapseSidebar();
                useFileBrowserStore.getState().collapseSidebar();
            }
            return { isExpanded: newExpanded };
        });
    },
    expandSidebar: () => {
        useGitStore.getState().collapseSidebar();
        useSessionFilesStore.getState().collapseSidebar();
        useResearchStore.getState().collapseSidebar();
        useSettingsStore.getState().collapseSidebar();
        useTunnelStore.getState().collapseSidebar();
        useFileBrowserStore.getState().collapseSidebar();
        set({ isExpanded: true });
    },
    collapseSidebar: () => set({ isExpanded: false }),
    setServers: (servers) => set({ servers }),
    setLoading: (name, loading) => set((state) => {
        const next = new Set(state.loading);
        if (loading)
            next.add(name);
        else
            next.delete(name);
        return { loading: next };
    }),
    updateServer: (name, updates) => set((state) => ({
        servers: state.servers.map((s) => s.name === name ? { ...s, ...updates } : s),
    })),
    setAuthUrl: (name, url) => set((state) => {
        const next = new Map(state.authUrls);
        if (url)
            next.set(name, url);
        else
            next.delete(name);
        return { authUrls: next };
    }),
    setCopilotDevice: (info) => set({ copilotDevice: info }),
}));
//# sourceMappingURL=mcpStore.js.map