import { __assign, __extends, __rest } from "tslib";
import React, { Component } from 'react';
import classnames from 'classnames';
import { Dialog, Icon } from '@alicloud/console-components';
var IotConfirm = /** @class */ (function (_super) {
    __extends(IotConfirm, _super);
    function IotConfirm(props) {
        var _this = _super.call(this, props) || this;
        _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;
    }
    IotConfirm.prototype.render = function () {
        var _a = this.props, isQuick = _a.isQuick, visible = _a.visible, onClose = _a.onClose, onCancel = _a.onCancel, onOk = _a.onOk, noIcon = _a.noIcon, iconColor = _a.iconColor, iconType = _a.iconType, iconSize = _a.iconSize, title = _a.title, content = _a.content, children = _a.children, locale = _a.locale, className = _a.className, options = __rest(_a, ["isQuick", "visible", "onClose", "onCancel", "onOk", "noIcon", "iconColor", "iconType", "iconSize", "title", "content", "children", "locale", "className"]);
        var contentResult = content || children;
        var classname = classnames('theme-variable-value', className);
        var resultVisible = isQuick ? this.state.visible : visible;
        return (React.createElement(Dialog, __assign({}, options, { visible: resultVisible, onClose: this.handleOnClose, onOk: this.handleOnOK, onCancel: this.handleOnCancel, className: classname, locale: locale }),
            React.createElement("div", { className: "confirm-warp" },
                !noIcon ? (React.createElement("div", { className: "icon-warp" },
                    React.createElement(Icon, { type: iconType, size: iconSize, style: iconColor ? { color: iconColor } : {} }))) : null,
                React.createElement("div", { className: "confirm-bd" },
                    title ? React.createElement("div", { className: "confirm-title" }, title) : null,
                    contentResult ? React.createElement("div", { className: "confirm-content" }, contentResult) : null))));
    };
    return IotConfirm;
}(Component));
IotConfirm.defaultProps = {
    visible: false,
    iconType: 'warning',
    iconSize: 'large',
    noIcon: false,
    iconColor: undefined,
    locale: {
        ok: '确定',
        cancel: '取消'
    }
};
export default IotConfirm;
