import _defineProperty from "@babel/runtime/helpers/defineProperty";
import "core-js/modules/es.array.map.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/esnext.iterator.constructor.js";
import "core-js/modules/esnext.iterator.map.js";
import classNames from 'classnames';
import React, { useMemo } from 'react';
import './index.css';
import { FcrButton } from '../button';
import { FcrIconType } from '../icon/type';
import { FcrIcon } from '../icon';
import { useI18n } from '../../i18n';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export var 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 = classNames('fcr-video-preview-wrapper');
  var t = 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 = useMemo(function () {
    return [{
      key: 'Video',
      icon: noCamera ? FcrIconType.FCR_CAMERACRASH : enableVideo ? FcrIconType.FCR_CAMERA : FcrIconType.FCR_CAMERAOFF,
      enable: enableVideo !== null && enableVideo !== void 0 ? enableVideo : false,
      bgType: noCamera ? 'noDevice' : enableVideo ? 'enable' : 'disable'
    }, {
      key: 'Audio',
      icon: noMicrophone ? FcrIconType.FCR_MUTECRASH : enableAudio ? FcrIconType.FCR_MUTE : FcrIconType.FCR_NOMUTE,
      enable: enableAudio !== null && enableAudio !== void 0 ? enableAudio : false,
      bgType: noMicrophone ? 'noDevice' : enableAudio ? 'enable' : 'disable'
    }, {
      key: 'Mirror',
      icon: enableMirror ? FcrIconType.FCR_MIRRORIMAGE_LEFT : 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__*/_jsx("div", {
    className: cls,
    children: /*#__PURE__*/_jsxs("div", {
      className: 'fcr-video-content',
      children: [videoPlayer, /*#__PURE__*/_jsxs("div", {
        className: 'fcr_video-action-wrapper',
        children: [/*#__PURE__*/_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__*/_jsx("div", {
              className: classNames('fcr-video-action__item', _defineProperty({}, "fcr-video__actions__bg--".concat(bgType), true)),
              onClick: function onClick() {
                updateSetting === null || updateSetting === void 0 || updateSetting(key);
              },
              children: /*#__PURE__*/_jsx(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__*/_jsx("div", {
          className: "fcr-meeting-meet",
          children: /*#__PURE__*/_jsx(FcrButton, {
            type: 'primary',
            size: 'S',
            onClick: function onClick() {
              handleAction === null || handleAction === void 0 || handleAction();
            },
            children: t('fmt_uimanager_button_Meetnow')
          })
        })]
      })]
    })
  });
};
export var SpeakerPhoneTest = function SpeakerPhoneTest() {
  return /*#__PURE__*/_jsx("div", {
    className: 'fcr-speaker-phone-test'
  });
};