"use strict";

require("core-js/modules/es.symbol.js");
require("core-js/modules/es.array.filter.js");
require("core-js/modules/es.array.for-each.js");
require("core-js/modules/es.array.iterator.js");
require("core-js/modules/es.array.push.js");
require("core-js/modules/es.object.define-properties.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.get-own-property-descriptors.js");
require("core-js/modules/es.object.keys.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.iterator.constructor.js");
require("core-js/modules/esnext.iterator.filter.js");
require("core-js/modules/esnext.iterator.for-each.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.for-each.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.MultiSelect = exports.MAX_SELECT_CNT = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _textBubble = require("../text-bubble");
var _iconText = require("../icon-text");
var _i18n = require("../../i18n");
var _type = require("../icon/type");
var _icon = require("../icon");
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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var MAX_SELECT_CNT = exports.MAX_SELECT_CNT = 50;
var MultiSelect = exports.MultiSelect = function MultiSelect(_ref) {
  var onCancel = _ref.onCancel,
    onConfirm = _ref.onConfirm,
    _ref$selectCnt = _ref.selectCnt,
    selectCnt = _ref$selectCnt === void 0 ? 0 : _ref$selectCnt;
  var t = (0, _i18n.useI18n)();
  var _useState = (0, _react.useState)(false),
    _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
    tipsVisible = _useState2[0],
    setTipsVisible = _useState2[1];
  (0, _react.useEffect)(function () {
    if (selectCnt >= MAX_SELECT_CNT) setTipsVisible(true);else {
      setTipsVisible(false);
    }
  }, [selectCnt]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "fcr-multi-select",
    style: _objectSpread({}, tipsVisible ? {
      padding: '8px 0 16px'
    } : {}),
    children: [tipsVisible && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "fcr-multi-select-tips",
      children: t('fmt_chat_toast_select_more_error')
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_textBubble.TextBubble, {
      txt: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        className: "fcr-multi-select-content",
        onClick: function onClick() {
          if (!selectCnt) return;
          onConfirm && onConfirm();
        },
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_textBubble.TextBubble, {
          styles: {
            cursor: selectCnt > 0 ? 'pointer' : 'not-allowed',
            paddingRight: 60
          },
          lineHeight: "small",
          txt: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
            className: "fcr-select-actions",
            children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconText.IconText, {
              fontSize: "medium",
              txt: t('fmt_meetingInfo_window_info_meetingID_copy'),
              icon: _type.FcrIconType.FCR_MOBILE_DUPLICATE,
              colors: {
                iconPrimary: 'var(--fcr_ui_scene_icontext1)'
              }
            })
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_textBubble.TextBubble, {
          styles: {
            width: 36,
            height: 36,
            cursor: 'pointer',
            position: 'absolute',
            right: 0
          },
          type: "white",
          txt: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
            onClick: function onClick(event) {
              event.stopPropagation();
              onCancel && onCancel();
            },
            children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
              size: 20,
              type: _type.FcrIconType.FCR_CLOSE,
              colors: {
                iconPrimary: 'var(--fcr_ui_scene_icontext1)'
              }
            })
          })
        })]
      })
    })]
  });
};