"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _tslib = require("tslib");

var _react = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _consoleComponents = require("@alicloud/console-components");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var IotConfirm =
/** @class */
function (_super) {
  (0, _tslib.__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 = (0, _tslib.__rest)(_a, ["isQuick", "visible", "onClose", "onCancel", "onOk", "noIcon", "iconColor", "iconType", "iconSize", "title", "content", "children", "locale", "className"]);
    var contentResult = content || children;
    var classname = (0, _classnames["default"])('theme-variable-value', className);
    var resultVisible = isQuick ? this.state.visible : visible;
    return /*#__PURE__*/_react["default"].createElement(_consoleComponents.Dialog, (0, _tslib.__assign)({}, options, {
      visible: resultVisible,
      onClose: this.handleOnClose,
      onOk: this.handleOnOK,
      onCancel: this.handleOnCancel,
      className: classname,
      locale: locale
    }), /*#__PURE__*/_react["default"].createElement("div", {
      className: "confirm-warp"
    }, !noIcon ? /*#__PURE__*/_react["default"].createElement("div", {
      className: "icon-warp"
    }, /*#__PURE__*/_react["default"].createElement(_consoleComponents.Icon, {
      type: iconType,
      size: iconSize,
      style: iconColor ? {
        color: iconColor
      } : {}
    })) : null, /*#__PURE__*/_react["default"].createElement("div", {
      className: "confirm-bd"
    }, title ? /*#__PURE__*/_react["default"].createElement("div", {
      className: "confirm-title"
    }, title) : null, contentResult ? /*#__PURE__*/_react["default"].createElement("div", {
      className: "confirm-content"
    }, contentResult) : null)));
  };

  return IotConfirm;
}(_react.Component);

IotConfirm.defaultProps = {
  visible: false,
  iconType: 'warning',
  iconSize: 'large',
  noIcon: false,
  iconColor: undefined,
  locale: {
    ok: '确定',
    cancel: '取消'
  }
};
var _default = IotConfirm;
exports["default"] = _default;