import { QueryClient, QueryClientProvider } from './lib/atproto-query';
import type { Component } from 'solid-js';

import { AtProtoProvider } from '@atproto-ui/solid';
import { AuthProvider } from './lib/auth';
import { LiveEventsProvider } from './lib/live-events';
import { AppSettingsProvider } from './lib/settings';
import { AppRoutes } from './routes';

const queryClient = new QueryClient({
	defaultOptions: {
		queries: {
			retry: 1,
			staleTime: 30_000,
		},
	},
});

const App: Component = () => (
	<AtProtoProvider>
		<QueryClientProvider client={queryClient}>
			<AppSettingsProvider>
				<AuthProvider>
					<LiveEventsProvider>
						<AppRoutes />
					</LiveEventsProvider>
				</AuthProvider>
			</AppSettingsProvider>
		</QueryClientProvider>
	</AtProtoProvider>
);

export default App;
