import { jsxs, jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { c as cn } from './utils-DdHUxIdC.js';
import { DialogHeader as DialogHeader$1, DialogDescription, DialogFooter as DialogFooter$1, DialogTitle as DialogTitle$1, Dialog as Dialog$1, DialogContent } from './primitives/Dialog.js';

const SIZE_CLASS_MAP = {
    small: "sm:max-w-sm",
    medium: "sm:max-w-md",
    large: "sm:max-w-lg",
    fullScreen: "h-screen w-screen max-w-none rounded-none sm:max-w-none",
};

const DialogHeader = forwardRef(({ children, className, description, dataTestid, ...otherProps }, ref) => (jsxs(DialogHeader$1, { ref: ref, className: cn(className), "data-testid": dataTestid ?? "dialog-header", ...otherProps, children: [children, description && jsx(DialogDescription, { children: description })] })));
DialogHeader.displayName = "Dialog.Header";
const DialogBody = forwardRef(({ children, className, dataTestid, ...otherProps }, ref) => (jsx("div", { ref: ref, "data-slot": "dialog-body", "data-testid": dataTestid ?? "dialog-body", className: cn("text-sm text-foreground", className), ...otherProps, children: children })));
DialogBody.displayName = "Dialog.Body";
const DialogFooter = forwardRef(({ children, className, dataTestid, ...otherProps }, ref) => (jsx(DialogFooter$1, { ref: ref, className: cn(className), "data-testid": dataTestid ?? "dialog-footer", ...otherProps, children: children })));
DialogFooter.displayName = "Dialog.Footer";
const DialogTitle = forwardRef(({ children, className, ...otherProps }, ref) => (jsx(DialogTitle$1, { ref: ref, className: cn("text-2xl font-semibold", className), ...otherProps, children: children })));
DialogTitle.displayName = "Dialog.Title";
const Dialog = forwardRef(({ size = "medium", isOpen = false, onClose = () => { }, children, className, closeOnEsc = true, closeButton = true, backdropClassName, closeOnOutsideClick = true, initialFocusRef, finalFocusRef, blockScrollOnMount = true, forceRender = false, modal: modalProp, defaultOpen, 
// Radix content handlers — intercept and merge
onOpenAutoFocus: onOpenAutoFocusProp, onCloseAutoFocus: onCloseAutoFocusProp, ...otherContentProps }, ref) => {
    const handleOpenChange = (open) => {
        if (!open)
            onClose();
    };
    const handleInteractOutside = (e) => {
        if (!closeOnOutsideClick)
            e.preventDefault();
    };
    const handleEscapeKeyDown = (e) => {
        if (!closeOnEsc)
            e.preventDefault();
    };
    const handleOpenAutoFocus = (e) => {
        if (initialFocusRef?.current) {
            e.preventDefault();
            initialFocusRef.current.focus();
        }
        onOpenAutoFocusProp?.(e);
    };
    const handleCloseAutoFocus = (e) => {
        if (finalFocusRef?.current) {
            e.preventDefault();
            finalFocusRef.current.focus();
        }
        onCloseAutoFocusProp?.(e);
    };
    // `modal` prop takes precedence; fall back to blockScrollOnMount
    const resolvedModal = modalProp ?? blockScrollOnMount;
    return (jsx(Dialog$1, { open: isOpen, onOpenChange: handleOpenChange, modal: resolvedModal, defaultOpen: defaultOpen, children: jsx(DialogContent, { ref: ref, "aria-modal": true, showCloseButton: closeButton, forceMount: forceRender || undefined, overlayClassName: backdropClassName, onInteractOutside: handleInteractOutside, onEscapeKeyDown: handleEscapeKeyDown, onOpenAutoFocus: handleOpenAutoFocus, onCloseAutoFocus: handleCloseAutoFocus, className: cn(SIZE_CLASS_MAP[size], className), "data-testid": "dialog-wrapper", ...otherContentProps, children: children }) }));
});
Dialog.displayName = "Dialog";
Dialog.Header = DialogHeader;
Dialog.Body = DialogBody;
Dialog.Footer = DialogFooter;
Dialog.Title = DialogTitle;

export { Dialog as D };
//# sourceMappingURL=Dialog-BURSzxaP.js.map
