import { getServerContext } from "../serverContext.mjs";
import { IntlayerServerContext } from "../IntlayerServerProvider.mjs";
import { percentage } from "../../@intlayer/core/dist/esm/formatters/percentage.mjs";

//#region ../react-intlayer/dist/esm/server/format/usePercentage.mjs
/**
* React hook to provide a percentage formatter function
* based on the current application locale.
*
* This hook retrieves the active locale using {@link useLocaleBase}
* and memoizes a `createPercentage` instance for that locale.
*
* @example
* ```tsx
* const formatPercentage = usePercentage();
*
* const result = formatPercentage(0.875, { maximumFractionDigits: 1 });
* // "87.5%" (depending on locale)
* ```
*
* @returns {(value: string | number, options?: Omit<PercentageOptions, "value">) => string}
* A function that formats numbers or numeric strings into localized percentages.
*/
const usePercentage = () => {
	const locale = getServerContext(IntlayerServerContext);
	return (...args) => percentage(args[0], {
		...args[1],
		locale: args[1]?.locale ?? locale
	});
};

//#endregion
export { usePercentage };
//# sourceMappingURL=usePercentage.mjs.map