import { jsx } from 'react/jsx-runtime';
import React__default from 'react';
import { cn } from '../../../utils/cn.js';
import { useAccordionContext } from './Accordion.js';
import { useAccordionItemContext } from './AccordionItem.js';
import { useReducedMotion, AnimatePresence, motion } from 'motion/react';
import { accordionAnimations, accordionContentAnimations } from './Accordion.animations.js';

const AccordionBody = React__default.forwardRef(({ children, className, ...rest }, ref) => {
    const { theme } = useAccordionContext();
    const { isOpen, contentId, triggerId } = useAccordionItemContext();
    const shouldReduceMotion = useReducedMotion();
    // When reduced motion is preferred, skip all animation durations
    const instantTransition = shouldReduceMotion ? { duration: 0 } : undefined;
    // Filter out conflicting props to avoid type issues
    const { onDrag, onDragEnd, onDragStart, onAnimationStart, onAnimationEnd, onTransitionEnd, onTransitionStart, ...safeProps } = rest;
    return (jsx(AnimatePresence, { initial: false, children: isOpen && (jsx(motion.div, { ref: ref, id: contentId, role: "region", "aria-labelledby": triggerId, className: theme === null || theme === void 0 ? void 0 : theme.bodyStyle, "data-state": isOpen ? "open" : "closed", "aria-hidden": !isOpen, initial: "collapsed", animate: "open", exit: "collapsed", variants: accordionAnimations, transition: instantTransition, ...safeProps, children: jsx(motion.div, { className: cn(theme === null || theme === void 0 ? void 0 : theme.bodyInnerStyle, className), variants: accordionContentAnimations, initial: "collapsed", animate: "open", exit: "collapsed", transition: instantTransition, children: children }) })) }));
});
AccordionBody.displayName = "Accordion.Body";

export { AccordionBody };
