"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "confirm", {
    enumerable: true,
    get: function() {
        return confirm;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _simpleDialog = require("../../dialog/simpleDialog");
const _modal = require("../../modal");
const _modalHelper = require("../../modal/modalHelper");
const _modalContext = require("../../modal/modalContext");
const _dialog = require("../../dialog");
const ConfirmDialog = (0, _modalHelper.create)((props)=>{
    const { visible, hide, resolve, reject, onOpenChange } = (0, _modal.useModal)();
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_simpleDialog.SimpleDialog, {
        open: visible,
        title: props.title,
        contentClassName: props.contentClassName,
        maxWidth: props.maxWidth,
        closable: true,
        closeableSize: props.closeableSize,
        okId: props.okId,
        cancelId: props.cancelId,
        onOpenChange: (open)=>{
            if (!open) {
                reject();
            }
            onOpenChange(open);
        },
        onOk: ()=>{
            return Promise.resolve().then(()=>{
                if (typeof props.onOk === "function") {
                    return props.onOk();
                }
                return true;
            }).then((data)=>{
                resolve(data);
                hide();
            });
        },
        onCancel: typeof props.onCancel !== "undefined" ? ()=>{
            return props.onCancel?.().then((data)=>data, (reason)=>{
                reject(reason);
            }).finally(()=>hide());
        } : undefined,
        footer: props.footer,
        children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_dialog.DialogBody, {
            children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                className: "orderly-py-5 orderly-text-xs",
                children: props.content
            })
        })
    });
});
const confirm = (props)=>{
    return _modalContext.modalActions.show(ConfirmDialog, props);
};

//# sourceMappingURL=confirm.js.map