import { __assign, __extends, __rest } from "tslib";
import React, { Component } from 'react';
import classnames from 'classnames';
import { Dialog } from '@alicloud/console-components';
var IotDialog = /** @class */ (function (_super) {
    __extends(IotDialog, _super);
    function IotDialog(props) {
        var _this = _super.call(this, props) || this;
        _this.getContentAlign = function (key) {
            switch (key) {
                case 'left':
                    return 'tl tl';
                case 'right':
                    return 'tr tr';
                default:
                    return _this.props.align;
            }
        };
        _this.handleOnClose = function (trigger, event) {
            if (_this.props.isQuick) {
                _this.setState({ visible: false });
                _this.props.onClose && _this.props.onClose(trigger, event);
            }
            else {
                _this.props.onClose && _this.props.onClose(trigger, event);
            }
        };
        _this.handleOnOK = function (event) {
            if (_this.props.isQuick) {
                _this.setState({ visible: false });
                _this.props.onOk && _this.props.onOk(event);
            }
            else {
                _this.props.onOk && _this.props.onOk(event);
            }
        };
        _this.handleOnCancel = function (event) {
            if (_this.props.isQuick) {
                _this.setState({ visible: false });
                _this.props.onCancel && _this.props.onCancel(event);
            }
            else {
                _this.props.onCancel && _this.props.onCancel(event);
            }
        };
        _this.state = {
            visible: true
        };
        return _this;
    }
    IotDialog.prototype.render = function () {
        var _a = this.props, isQuick = _a.isQuick, onOk = _a.onOk, onCancel = _a.onCancel, onClose = _a.onClose, visible = _a.visible, content = _a.content, children = _a.children, className = _a.className, contentAlign = _a.contentAlign, isNest = _a.isNest, config = __rest(_a, ["isQuick", "onOk", "onCancel", "onClose", "visible", "content", "children", "className", "contentAlign", "isNest"]);
        var alignClassname = contentAlign !== 'center' && 'lp-normal-dialog-full';
        var align_ = this.getContentAlign(contentAlign);
        var classname = classnames('lp-normal-dialog', alignClassname, { "lp-nest-dialog": isNest }, className);
        var resultContent = content || children;
        var resultVisible = isQuick ? this.state.visible : visible;
        return (React.createElement(Dialog, __assign({ align: align_ }, config, { visible: resultVisible, onClose: this.handleOnClose, onOk: this.handleOnOK, onCancel: this.handleOnCancel, className: classname }), resultContent));
    };
    return IotDialog;
}(Component));
IotDialog.defaultProps = {
    visible: false,
    contentAlign: 'center',
    locale: {
        ok: '确定',
        cancel: '取消'
    }
};
export default IotDialog;
