import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { modalActions } from "../modalContext";
import { create } from "../modalHelper";
import { useCallback } from "react";
import { useModal } from "../useModal";
import { Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "../../dialog";
import Button from "../../button";
import { cn } from "../../utils/css";
import { Divider } from "../../divider";
export const AlertDialog = create((props)=>{
    const { title, message, closeable = true } = props;
    const { visible, hide, resolve, reject, onOpenChange } = useModal();
    const onOk = useCallback(()=>{
        hide();
    }, [
        props.onOk
    ]);
    return /*#__PURE__*/ _jsx(Dialog, {
        open: visible,
        onOpenChange: onOpenChange,
        children: /*#__PURE__*/ _jsxs(DialogContent, {
            className: "orderly-modal-alert",
            closable: closeable,
            maxWidth: "xs",
            onCloseAutoFocus: (e)=>e.preventDefault(),
            onOpenAutoFocus: (e)=>e.preventDefault(),
            children: [
                /*#__PURE__*/ _jsx(DialogHeader, {
                    className: cn("after:orderly-hidden orderly-items-center", closeable && "orderly-items-start"),
                    children: /*#__PURE__*/ _jsx(DialogTitle, {
                        children: title
                    })
                }),
                /*#__PURE__*/ _jsx(Divider, {
                    className: "orderly-mx-5 orderly-bg-white/[0.12]"
                }),
                /*#__PURE__*/ _jsx(DialogBody, {
                    className: "orderly-py-[20px]",
                    children: message
                }),
                /*#__PURE__*/ _jsx(DialogFooter, {
                    className: "orderly-flex orderly-justify-center",
                    children: /*#__PURE__*/ _jsx(Button, {
                        onClick: onOk,
                        className: "orderly-w-full orderly-text-xs orderly-text-base-contrast orderly-font-bold desktop:orderly-text-xs",
                        children: "OK"
                    })
                })
            ]
        })
    });
});
export const alert = (props)=>{
    return modalActions.show(AlertDialog, props);
};

//# sourceMappingURL=alert.js.map