'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// packages/ui/src/internal/providers/UIProviders.tsx
/**
 * @fileoverview UIProviders component
 * @description Provides wrapper to basic UI components
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
import { TooltipProvider, Toaster, Dialog } from '@donotdev/components';
import { useOverlayStore } from '@donotdev/core';
import DnDevErrorBoundary from '../common/DnDevErrorBoundary';
import GlobalErrorFallback from '../common/GlobalErrorFallback';
function UIGlobalErrorFallback(props) {
    return _jsx(GlobalErrorFallback, { ...props });
}
/**
 * Provides a wrapper to basic UI components
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
export function UIProviders({ children }) {
    return (_jsx(DnDevErrorBoundary, { level: "app", fallback: UIGlobalErrorFallback, children: _jsxs(TooltipProvider, { children: [children, _jsx(Toaster, {}), _jsx(ModalDialog, {})] }) }));
}
/**
 * ModalDialog - Renders modal dialog using store directly
 * Moved from ModalContext to avoid redundant context wrapper
 *
 * @version 0.0.1
 * @since 0.0.1
 * @author AMBROISE PARK Consulting
 */
function ModalDialog() {
    const isOpen = useOverlayStore((state) => state.isOpen);
    const content = useOverlayStore((state) => state.content);
    const closeModal = useOverlayStore((state) => state.closeModal);
    return (_jsx(Dialog, { open: isOpen, onOpenChange: (open) => {
            if (!open)
                closeModal();
        }, children: content }));
}
