"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.ShareAudio = exports.AudioProcessingChannel = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _react = _interopRequireWildcard(require("react"));
var _i18n = require("../../../i18n");
var _checkbox = require("../../checkbox");
var _icon = require("../../icon");
var _type = require("../../icon/type");
var _popover = require("../../popover");
var _radio = require("../../radio");
var _tooltip = require("../../tooltip");
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 AudioProcessingChannel = exports.AudioProcessingChannel = /*#__PURE__*/function (AudioProcessingChannel) {
  AudioProcessingChannel["MONO"] = "1";
  AudioProcessingChannel["STEREO"] = "2";
  return AudioProcessingChannel;
}({});
var ShareAudio = exports.ShareAudio = function ShareAudio(props) {
  var t = (0, _i18n.useI18n)();
  var shareWithAudio = props.shareWithAudio,
    _props$currentAudioCh = props.currentAudioChannel,
    currentAudioChannel = _props$currentAudioCh === void 0 ? AudioProcessingChannel.MONO : _props$currentAudioCh,
    toggleShareWithAudio = props.toggleShareWithAudio,
    _props$showInfoTip = props.showInfoTip,
    showInfoTip = _props$showInfoTip === void 0 ? false : _props$showInfoTip;
  var _React$useState = _react["default"].useState(false),
    _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
    popoverVisible = _React$useState2[0],
    setVisible = _React$useState2[1];
  var handlerVisibleChange = function handlerVisibleChange(visible) {
    setVisible(visible);
  };
  (0, _react.useEffect)(function () {
    function handleBlur(event) {
      setVisible(false);
    }
    window.addEventListener('blur', handleBlur);
    return function () {
      window.removeEventListener('blur', handleBlur);
    };
  }, []);
  var shareAudioTips = (0, _react.useMemo)(function () {
    if (!shareWithAudio) {
      return t('fmt_screenshare_window_checkbox_shareAudio');
    }
    if (currentAudioChannel === AudioProcessingChannel.STEREO) {
      return t('fmt_uimanager_option_dualchannel');
    }
    return t('fmt_uimanager_option_Sharedmono');
  }, [shareWithAudio, currentAudioChannel]);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: "share-audio-checkbox",
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.FcrToolTip, {
      content: shareAudioTips,
      trigger: "hover",
      placement: "top",
      mouseEnterDelay: 0,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "share-audio-action-button share-selectrion",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkbox.FcrCheckbox, {
          checked: shareWithAudio,
          label: t('fmt_screenshare_window_checkbox_shareAudio'),
          styleType: "brand",
          onChange: toggleShareWithAudio
        })
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_popover.FcrPopover, {
      overlayClassName: "share-audio-popover",
      overlayInnerStyle: {
        border: 0,
        boxShadow: 'var(--fcr_web_light_dropup_m)',
        borderRadius: 'var(--fcr_cornerradius_l)',
        padding: '4px 6px'
      },
      content: /*#__PURE__*/(0, _jsxRuntime.jsx)(ShareAudioOptions, _objectSpread({}, props)),
      trigger: "click",
      visible: popoverVisible,
      onVisibleChange: handlerVisibleChange,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "share-audio-action-button share-selectrion",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
          type: _type.FcrIconType.FCR_DROPUP4,
          size: 24,
          colors: {
            iconPrimary: 'var(--fcr_web_ui_scene_mainicon1)'
          }
        })
      })
    }), showInfoTip ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.FcrToolTip, {
      mouseEnterDelay: 0,
      trigger: "hover",
      placement: "top",
      content: t('fmt_screenshare_tips_share_pc_sound'),
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
        style: {
          marginLeft: '6px'
        },
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
          type: _type.FcrIconType.FCR_EXCLAMATIONMASK,
          size: 20,
          colors: {
            iconPrimary: 'var(--fcr_ui_scene_icontext1)'
          }
        })
      })
    }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {})]
  });
};
var ShareAudioOptions = function ShareAudioOptions(props) {
  var _props$onSwitchAudioC = props.onSwitchAudioChannel,
    onSwitchAudioChannel = _props$onSwitchAudioC === void 0 ? function () {} : _props$onSwitchAudioC,
    _props$currentAudioCh2 = props.currentAudioChannel,
    currentAudioChannel = _props$currentAudioCh2 === void 0 ? AudioProcessingChannel.MONO : _props$currentAudioCh2;
  var t = (0, _i18n.useI18n)();
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "share-audio-options share-audio-not-draggable",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_radio.FcrRadioGroup, {
      defaultValue: currentAudioChannel,
      options: [{
        label: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: currentAudioChannel === AudioProcessingChannel.MONO ? 'radio-label-active' : 'radio-label-normal',
          children: t('fmt_uimanager_option_Monochannel')
        }),
        value: AudioProcessingChannel.MONO,
        iconColor: 'var(--fcr_ui_scene_icontext1)',
        styleType: 'transparent'
      }, {
        label: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          className: currentAudioChannel === AudioProcessingChannel.STEREO ? 'radio-label-active' : 'radio-label-normal',
          children: t('fmt_uimanager_option_Stereo')
        }),
        value: AudioProcessingChannel.STEREO,
        iconColor: 'var(--fcr_ui_scene_icontext1)',
        styleType: 'transparent'
      }],
      onChange: function onChange(value) {
        onSwitchAudioChannel(value);
      }
    })
  });
};