'use client';


const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.cjs');
const require_IntlayerProvider = require('../IntlayerProvider.cjs');
const require_relativeTime = require('../../@intlayer/core/dist/esm/formatters/relativeTime.cjs');
let react = require("react");

//#region ../react-intlayer/dist/esm/client/format/useRelativeTime.mjs
/**
* Client-side React hook for accessing a localized relative time formatter.
*
* This hook:
* - Reads the current locale from {@link useLocaleBase}.
* - Creates a new relative time formatter with {@link createRelativeTime}.
* - Returns a function that can format time differences into localized strings.
*
* Example:
* ```tsx
* const relativeTime = useRelativeTime();
* const formatted = relativeTime(new Date("2024-08-01"), new Date());
* // e.g., "2 weeks ago"
* ```
*
* @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function
*          bound to the current client locale.
*/
const useRelativeTime = () => {
	const { locale } = (0, react.useContext)(require_IntlayerProvider.IntlayerClientContext);
	return (0, react.useCallback)((...args) => require_relativeTime.relativeTime(args[0], args[1], {
		...args[2],
		locale: args[2]?.locale ?? locale
	}), [locale]);
};

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