var JQueryDialogService = /** @class */ (function () {
    function JQueryDialogService() {
        $('body').append($("<div id=\"eqv-dialog-confirm\" style=\"display: none\"><p id=\"eqv-dialog-confirm-content\"></p></div>"));
        $('body').append($("<div id=\"eqv-dialog-form\" style=\"display: none\">\n                        <label for=\"name\" id=\"eqv-dialog-form-content\"></label>\n                        <input type=\"text\" name=\"name\" id=\"eqv-dialog-form-input\" class=\"text ui-widget-content ui-corner-all\" />\n                </div>"));
        this.confirmDialog = $('#eqv-dialog-confirm');
        this.promptDialog = $('#eqv-dialog-form');
        this.confirmDialog.dialog({
            dialogClass: "eqv-dialog eq-js-dialog",
            closeOnEscape: false,
            resizable: false,
            height: "auto",
            width: "auto",
            modal: true,
            autoOpen: false
        });
        this.promptDialog.dialog({
            dialogClass: "eqv-dialog eq-js-dialog",
            closeOnEscape: false,
            draggable: false,
            resizable: false,
            height: "auto",
            width: "auto",
            modal: true,
            autoOpen: false
        });
    }
    JQueryDialogService.prototype.openConfirm = function (title, content, callback) {
        var _this = this;
        this.confirmDialog.dialog('option', 'title', title);
        $('#eqv-dialog-confirm-content').text(content);
        if (callback) {
            this.setConfirmButtons(callback);
            this.confirmDialog.dialog('open');
            return;
        }
        return new Promise(function (resolve) {
            _this.setConfirmButtons(resolve);
            _this.confirmDialog.dialog('open');
        });
    };
    JQueryDialogService.prototype.setConfirmButtons = function (callback) {
        var buttons = [
            {
                text: "OK",
                click: function () {
                    callback(true);
                    $(this).dialog("close");
                }
            },
            {
                text: "Cancel",
                click: function () {
                    callback(false);
                    $(this).dialog("close");
                }
            }
        ];
        this.confirmDialog.dialog('option', 'buttons', buttons);
    };
    JQueryDialogService.prototype.openPrompt = function (title, content, defValue, callback) {
        var _this = this;
        this.promptDialog.dialog('option', 'title', title);
        $('#eqv-dialog-form-content').text(content);
        $('#eqv-dialog-form-input').val(defValue || "");
        if (callback) {
            this.setPromptButtons(callback);
            this.promptDialog.dialog('open');
            return;
        }
        return new Promise(function (resolve) {
            _this.setPromptButtons(resolve);
            _this.promptDialog.dialog('open');
        });
    };
    JQueryDialogService.prototype.setPromptButtons = function (callback) {
        var buttons = [
            {
                text: "OK",
                click: function () {
                    var result = $('#eqv-dialog-form-input').val();
                    if (result && result.replace(/\s/g, '').length > 0) {
                        callback(result);
                        $(this).dialog("close");
                    }
                }
            },
            {
                text: "Cancel",
                click: function () {
                    callback("");
                    $(this).dialog("close");
                }
            }
        ];
        this.promptDialog.dialog('option', 'buttons', buttons);
    };
    return JQueryDialogService;
}());
export { JQueryDialogService };
//# sourceMappingURL=jquery_dialog_service.js.map