"use client";
const require_is_mantine_color_scheme = require("./is-mantine-color-scheme.cjs");
//#region packages/@mantine/core/src/core/MantineProvider/color-scheme-managers/local-storage-manager.ts
function localStorageColorSchemeManager({ key = "mantine-color-scheme-value" } = {}) {
	let handleStorageEvent;
	return {
		get: (defaultValue) => {
			if (typeof window === "undefined") return defaultValue;
			try {
				const storedColorScheme = window.localStorage.getItem(key);
				return require_is_mantine_color_scheme.isMantineColorScheme(storedColorScheme) ? storedColorScheme : defaultValue;
			} catch {
				return defaultValue;
			}
		},
		set: (value) => {
			try {
				window.localStorage.setItem(key, value);
			} catch (error) {
				console.warn("[@mantine/core] Local storage color scheme manager was unable to save color scheme.", error);
			}
		},
		subscribe: (onUpdate) => {
			handleStorageEvent = (event) => {
				if (event.storageArea === window.localStorage && event.key === key) require_is_mantine_color_scheme.isMantineColorScheme(event.newValue) && onUpdate(event.newValue);
			};
			window.addEventListener("storage", handleStorageEvent);
		},
		unsubscribe: () => {
			window.removeEventListener("storage", handleStorageEvent);
		},
		clear: () => {
			window.localStorage.removeItem(key);
		}
	};
}
//#endregion
exports.localStorageColorSchemeManager = localStorageColorSchemeManager;

//# sourceMappingURL=local-storage-manager.cjs.map