"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    AlertDialog: function() {
        return AlertDialog;
    },
    alert: function() {
        return alert;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _modalContext = require("../modalContext");
const _modalHelper = require("../modalHelper");
const _react = require("react");
const _useModal = require("../useModal");
const _dialog = require("../../dialog");
const _button = /*#__PURE__*/ _interop_require_default(require("../../button"));
const _css = require("../../utils/css");
const _divider = require("../../divider");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const AlertDialog = (0, _modalHelper.create)((props)=>{
    const { title, message, closeable = true } = props;
    const { visible, hide, resolve, reject, onOpenChange } = (0, _useModal.useModal)();
    const onOk = (0, _react.useCallback)(()=>{
        hide();
    }, [
        props.onOk
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_dialog.Dialog, {
        open: visible,
        onOpenChange: onOpenChange,
        children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_dialog.DialogContent, {
            className: "orderly-modal-alert",
            closable: closeable,
            maxWidth: "xs",
            onCloseAutoFocus: (e)=>e.preventDefault(),
            onOpenAutoFocus: (e)=>e.preventDefault(),
            children: [
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_dialog.DialogHeader, {
                    className: (0, _css.cn)("after:orderly-hidden orderly-items-center", closeable && "orderly-items-start"),
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dialog.DialogTitle, {
                        children: title
                    })
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_divider.Divider, {
                    className: "orderly-mx-5 orderly-bg-white/[0.12]"
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_dialog.DialogBody, {
                    className: "orderly-py-[20px]",
                    children: message
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)(_dialog.DialogFooter, {
                    className: "orderly-flex orderly-justify-center",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_button.default, {
                        onClick: onOk,
                        className: "orderly-w-full orderly-text-xs orderly-text-base-contrast orderly-font-bold desktop:orderly-text-xs",
                        children: "OK"
                    })
                })
            ]
        })
    });
});
const alert = (props)=>{
    return _modalContext.modalActions.show(AlertDialog, props);
};

//# sourceMappingURL=alert.js.map