"use client";
const require_use_isomorphic_effect = require("../use-isomorphic-effect/use-isomorphic-effect.cjs");
let react = require("react");
//#region packages/@mantine/hooks/src/use-favicon/use-favicon.ts
const MIME_TYPES = {
	ico: "image/x-icon",
	png: "image/png",
	svg: "image/svg+xml",
	gif: "image/gif"
};
function useFavicon(url) {
	const link = (0, react.useRef)(null);
	require_use_isomorphic_effect.useIsomorphicEffect(() => {
		if (!url) return;
		if (!link.current) {
			document.querySelectorAll("link[rel*=\"icon\"]").forEach((element) => document.head.removeChild(element));
			const element = document.createElement("link");
			element.rel = "shortcut icon";
			link.current = element;
			document.querySelector("head").appendChild(element);
		}
		const splittedUrl = url.split(".");
		const mimeType = MIME_TYPES[splittedUrl[splittedUrl.length - 1].toLowerCase()];
		if (mimeType) link.current.setAttribute("type", mimeType);
		else link.current.removeAttribute("type");
		link.current.setAttribute("href", url);
	}, [url]);
}
//#endregion
exports.useFavicon = useFavicon;

//# sourceMappingURL=use-favicon.cjs.map