// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import { jsx as _jsx } from "react/jsx-runtime";
const width = value => {
  let result = Math.ceil(value * 20 / 5) * 5;
  if (result % 20 === 5) {
    result += 2;
  } else if (result % 20 === 15) {
    result -= 2;
  }
  return result;
};
/**
 * `Rating` component is used for showing and collecting feedback of users' opinion in 0-5 grade scale.
 * @since 0.0.42
 */
const Rating = _ref => {
  let {
    baseClassName = `${CLS_PREFIX}rating`,
    className,
    value = 0,
    small = false,
    ...props
  } = _ref;
  return /*#__PURE__*/_jsx("div", {
    className: classNames(baseClassName, className, {
      [`${baseClassName}--static`]: true,
      [`${baseClassName}--small`]: small
    }),
    ...props,
    children: /*#__PURE__*/_jsx("div", {
      className: `${baseClassName}__rates`,
      style: {
        width: `${width(value)}%`
      }
    })
  });
};
export default Rating;