<script lang="ts">
	import './layout.css';
	import favicon from '$lib/assets/favicon.svg';
	import { PUBLIC_CONVEX_URL } from '$env/static/public';
	import { setupConvex } from 'convex-svelte';
	import { hasWebSocketSupport, setupPollingConvex } from '$lib/convex-polling.svelte';
	import { setContext } from 'svelte';

	let { children } = $props();

	const usePolling = !hasWebSocketSupport();
	setContext('convex-use-polling', usePolling);

	if (usePolling) {
		setupPollingConvex(PUBLIC_CONVEX_URL);
	} else {
		setupConvex(PUBLIC_CONVEX_URL);
	}
</script>

<svelte:head><link rel="icon" href={favicon} /></svelte:head>
{@render children()}
