"use strict";

require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.object.define-property.js");
require("core-js/modules/es.object.get-own-property-descriptor.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/es.string.iterator.js");
require("core-js/modules/es.weak-map.js");
require("core-js/modules/esnext.weak-map.delete-all.js");
require("core-js/modules/esnext.weak-map.emplace.js");
require("core-js/modules/web.dom-collections.iterator.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LoginConfirmDialog = void 0;
require("core-js/modules/web.timers.js");
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _button = require("../button");
require("./index.css");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var LoginConfirmDialog = exports.LoginConfirmDialog = function LoginConfirmDialog(_ref) {
  var title = _ref.title,
    desc = _ref.desc,
    id = _ref.id,
    btnTxt = _ref.btnTxt,
    isShowCoutDown = _ref.isShowCoutDown,
    onConfirm = _ref.onConfirm,
    _ref$showImg = _ref.showImg,
    showImg = _ref$showImg === void 0 ? true : _ref$showImg,
    imgSrc = _ref.imgSrc;
  var _useState = (0, _react.useState)(6),
    _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
    countDown = _useState2[0],
    setCountDown = _useState2[1];
  (0, _react.useEffect)(function () {
    var timer;
    if (isShowCoutDown) {
      timer = setInterval(function () {
        if (countDown === 0) {
          clearInterval(timer);
          onConfirm && onConfirm();
        }
        setCountDown(countDown - 1);
      }, 1000);
    }
    return function () {
      clearInterval(timer);
    };
  }, [countDown, isShowCoutDown]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "fcr-login-confirm-dialog-content",
    children: [showImg && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-login-confirm-dialog-img",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
        style: {
          width: 280,
          height: 192
        },
        src: imgSrc,
        alt: ""
      })
    }), title && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-login-confirm-dialog-title",
      children: title
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-login-confirm-dialog-desc",
      children: desc
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-login-confirm-dialog-btn",
      children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_button.FcrButton, {
        size: "S",
        shape: "rounded",
        onClick: function onClick() {
          onConfirm && onConfirm();
        },
        children: [btnTxt, isShowCoutDown && "(".concat(countDown, "s)")]
      })
    })]
  });
};