import * as React from 'react';
import { mergeProps } from '../../merge-props/index.js';
import { useAnchorPositioning } from '../../utils/useAnchorPositioning.js';
import { usePreviewCardRootContext } from '../root/PreviewCardContext.js';
export function usePreviewCardPositioner(params) {
  const {
    open,
    mounted
  } = usePreviewCardRootContext();
  const positioning = useAnchorPositioning(params);
  const getPositionerProps = React.useCallback((externalProps = {}) => {
    const hiddenStyles = {};
    if (!open) {
      hiddenStyles.pointerEvents = 'none';
    }
    return mergeProps({
      role: 'presentation',
      hidden: !mounted,
      style: {
        ...positioning.positionerStyles,
        ...hiddenStyles
      }
    }, externalProps);
  }, [open, mounted, positioning.positionerStyles]);
  return React.useMemo(() => ({
    getPositionerProps,
    ...positioning
  }), [getPositionerProps, positioning]);
}