'use client';


const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
const require_useLocaleStorage = require('./useLocaleStorage.cjs');
const require_built = require('../@intlayer/config/dist/esm/built.cjs');
const require_IntlayerProvider = require('./IntlayerProvider.cjs');
let react = require("react");

//#region ../react-intlayer/dist/esm/client/useLocale.mjs
/**
* On the client side, hook to get the current locale and all related fields
*/
const useLocale = ({ isCookieEnabled, onLocaleChange } = {}) => {
	const { defaultLocale, locales: availableLocales } = require_built.built_default?.internationalization ?? {};
	const { locale, setLocale: setLocaleState, isCookieEnabled: isCookieEnabledContext } = (0, react.useContext)(require_IntlayerProvider.IntlayerClientContext);
	return {
		locale,
		defaultLocale,
		availableLocales,
		setLocale: (0, react.useCallback)((locale$1) => {
			if (!availableLocales?.map(String).includes(locale$1)) {
				console.error(`Locale ${locale$1} is not available`);
				return;
			}
			setLocaleState(locale$1);
			require_useLocaleStorage.setLocaleInStorage(locale$1, isCookieEnabled ?? isCookieEnabledContext ?? true);
			onLocaleChange?.(locale$1);
		}, [
			availableLocales,
			onLocaleChange,
			setLocaleState
		])
	};
};

//#endregion
exports.useLocale = useLocale;
//# sourceMappingURL=useLocale.cjs.map