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

import classNames from 'classnames';
import { forwardRef } from 'react';
import { CLS_PREFIX } from '../../constants';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const OFFSET = 23;
const calculate = (rect, placement) => {
  const placementTop = rect.height / 2;
  let placementLeft = 0;
  switch (placement) {
    case 'left':
      placementLeft = Math.min(OFFSET, rect.height / 2);
      break;
    case 'right':
      placementLeft = rect.width - Math.min(OFFSET, rect.height / 2);
      break;
    case 'center':
      placementLeft = rect.width / 2;
      break;
  }
  const top = rect.top + placementTop - OFFSET + window.pageYOffset;
  const left = rect.left + placementLeft - OFFSET + window.pageXOffset;
  return {
    top,
    left
  };
};
const SpotPulsar = /*#__PURE__*/forwardRef(function SpotPulsar(_ref, ref) {
  let {
    baseClassName = `${CLS_PREFIX}spot-pulsar`,
    className,
    rect,
    placement = 'center',
    ...props
  } = _ref;
  const position = calculate(rect, placement);
  return /*#__PURE__*/_jsxs("div", {
    className: classNames(baseClassName, className),
    style: {
      transform: `translate(${position.left}px, ${position.top}px)`
    },
    ...props,
    ref: ref,
    children: [/*#__PURE__*/_jsx("div", {
      className: `${baseClassName}__ring`
    }), /*#__PURE__*/_jsx("div", {
      className: `${baseClassName}__ring`
    })]
  });
});
SpotPulsar.displayName = 'SpotPulsar';
export default SpotPulsar;