'use client';

import * as React from 'react';
import { mergeProps } from '../../merge-props/index.js';
import { valueToPercent } from '../../utils/valueToPercent.js';
function useProgressIndicator(parameters) {
  const {
    max = 100,
    min = 0,
    value
  } = parameters;
  const percentageValue = Number.isFinite(value) && value !== null ? valueToPercent(value, min, max) : null;
  const getStyles = React.useCallback(() => {
    if (percentageValue == null) {
      return {};
    }
    return {
      insetInlineStart: 0,
      height: 'inherit',
      width: `${percentageValue}%`
    };
  }, [percentageValue]);
  const getRootProps = React.useCallback((externalProps = {}) => mergeProps({
    style: getStyles()
  }, externalProps), [getStyles]);
  return {
    getRootProps
  };
}
export { useProgressIndicator };