"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.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.SpeakerPhoneTest = exports.FcrDevicePretestPage = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
require("core-js/modules/es.array.map.js");
require("core-js/modules/es.object.to-string.js");
require("core-js/modules/esnext.iterator.constructor.js");
require("core-js/modules/esnext.iterator.map.js");
var _classnames = _interopRequireDefault(require("classnames"));
var _react = _interopRequireWildcard(require("react"));
require("./index.css");
var _button = require("../button");
var _type = require("../icon/type");
var _icon = require("../icon");
var _i18n = require("../../i18n");
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 FcrDevicePretestPage = exports.FcrDevicePretestPage = function FcrDevicePretestPage(_ref) {
  var nickName = _ref.nickName,
    meetingInfo = _ref.meetingInfo,
    videoInfos = _ref.videoInfos,
    handleAction = _ref.handleAction,
    videoPlayer = _ref.videoPlayer,
    updateSetting = _ref.updateSetting,
    speakerElement = _ref.speakerElement,
    _ref$showCameraPrevie = _ref.showCameraPreview,
    showCameraPreview = _ref$showCameraPrevie === void 0 ? false : _ref$showCameraPrevie;
  var cls = (0, _classnames["default"])('fcr-video-preview-wrapper');
  var t = (0, _i18n.useI18n)();
  var _ref2 = meetingInfo || {
      meetingName: '',
      meetingHostName: ''
    },
    meetingName = _ref2.meetingName,
    meetingHostName = _ref2.meetingHostName;
  var _videoInfos$enableVid = videoInfos.enableVideo,
    enableVideo = _videoInfos$enableVid === void 0 ? false : _videoInfos$enableVid,
    _videoInfos$enableAud = videoInfos.enableAudio,
    enableAudio = _videoInfos$enableAud === void 0 ? false : _videoInfos$enableAud,
    _videoInfos$enableVir = videoInfos.enableVirtualBg,
    enableVirtualBg = _videoInfos$enableVir === void 0 ? false : _videoInfos$enableVir,
    _videoInfos$enableBea = videoInfos.enableBeauty,
    enableBeauty = _videoInfos$enableBea === void 0 ? false : _videoInfos$enableBea,
    _videoInfos$enableMir = videoInfos.enableMirror,
    enableMirror = _videoInfos$enableMir === void 0 ? false : _videoInfos$enableMir,
    _videoInfos$leftRotat = videoInfos.leftRotationAngle,
    leftRotationAngle = _videoInfos$leftRotat === void 0 ? false : _videoInfos$leftRotat,
    _videoInfos$microphon = videoInfos.microphonePercentage,
    microphonePercentage = _videoInfos$microphon === void 0 ? 0 : _videoInfos$microphon,
    _videoInfos$noCamera = videoInfos.noCamera,
    noCamera = _videoInfos$noCamera === void 0 ? true : _videoInfos$noCamera,
    _videoInfos$noMicroph = videoInfos.noMicrophone,
    noMicrophone = _videoInfos$noMicroph === void 0 ? true : _videoInfos$noMicroph;
  var actions = (0, _react.useMemo)(function () {
    return [{
      key: 'Video',
      icon: noCamera ? _type.FcrIconType.FCR_CAMERACRASH : enableVideo ? _type.FcrIconType.FCR_CAMERA : _type.FcrIconType.FCR_CAMERAOFF,
      enable: enableVideo !== null && enableVideo !== void 0 ? enableVideo : false,
      bgType: noCamera ? 'noDevice' : enableVideo ? 'enable' : 'disable'
    }, {
      key: 'Audio',
      icon: noMicrophone ? _type.FcrIconType.FCR_MUTECRASH : enableAudio ? _type.FcrIconType.FCR_MUTE : _type.FcrIconType.FCR_NOMUTE,
      enable: enableAudio !== null && enableAudio !== void 0 ? enableAudio : false,
      bgType: noMicrophone ? 'noDevice' : enableAudio ? 'enable' : 'disable'
    }, {
      key: 'Mirror',
      icon: enableMirror ? _type.FcrIconType.FCR_MIRRORIMAGE_LEFT : _type.FcrIconType.FCR_MIRRORIMAGE_OFF,
      enable: enableMirror !== null && enableMirror !== void 0 ? enableMirror : false,
      bgType: enableMirror ? 'enable' : 'gray',
      show: showCameraPreview
    }];
  }, [enableVideo, enableAudio, enableVirtualBg, enableBeauty, enableMirror, noCamera, noMicrophone, showCameraPreview]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: cls,
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: 'fcr-video-content',
      children: [videoPlayer, /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
        className: 'fcr_video-action-wrapper',
        children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
          className: 'fcr-video__actions',
          children: [actions.map(function (actionInfo) {
            var key = actionInfo.key,
              icon = actionInfo.icon,
              bgType = actionInfo.bgType,
              _actionInfo$show = actionInfo.show,
              show = _actionInfo$show === void 0 ? true : _actionInfo$show;
            if (!show) {
              return null;
            }
            return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
              className: (0, _classnames["default"])('fcr-video-action__item', (0, _defineProperty2["default"])({}, "fcr-video__actions__bg--".concat(bgType), true)),
              onClick: function onClick() {
                updateSetting === null || updateSetting === void 0 || updateSetting(key);
              },
              children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
                size: 30,
                type: icon,
                colors: {
                  iconPrimary: bgType === 'noDevice' ? 'var(fcr_ui_scene_icontext5)' : bgType === 'gray' ? 'var(--fcr_web_ui_scene_mainicon1)' : 'var(--fcr_ui_scene_white10)',
                  iconSecondary: bgType === 'noDevice' ? 'var(--fcr_ui_scene_ramp_red6)' : 'var(--fcr_ui_scene_white10)'
                }
              })
            }, key);
          }), speakerElement]
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: "fcr-meeting-meet",
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.FcrButton, {
            type: 'primary',
            size: 'S',
            onClick: function onClick() {
              handleAction === null || handleAction === void 0 || handleAction();
            },
            children: t('fmt_uimanager_button_Meetnow')
          })
        })]
      })]
    })
  });
};
var SpeakerPhoneTest = exports.SpeakerPhoneTest = function SpeakerPhoneTest() {
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: 'fcr-speaker-phone-test'
  });
};