function useTheme() {
	var _React$useState = React.useState(function () {
			var saved = localStorage.getItem("theme");
			if (saved) return saved;
			return window.matchMedia("(prefers-color-scheme: dark)").matches
				? "dark"
				: "light";
		}),
		_React$useState2 = _slicedToArray(_React$useState, 2),
		theme = _React$useState2[0],
		setTheme = _React$useState2[1];

	React.useEffect(
		function () {
			document.documentElement.setAttribute("data-theme", theme);
			localStorage.setItem("theme", theme);
		},
		[theme],
	);

	var toggleTheme = React.useCallback(function () {
		setTheme(function (prev) {
			var next = prev === "dark" ? "light" : "dark";
			return next;
		});
	}, []);

	return {
		theme: theme,
		toggleTheme: toggleTheme,
	};
}
