"use strict";

require("core-js/modules/es.object.define-property.js");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.WindowType = exports.FcrWindowHeader = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _env = require("agora-foundation/lib/utilities/env");
var _iconButton = require("../icon-button");
var _type = require("../icon/type");
var _tooltip = require("../tooltip");
var _icon = require("../icon");
var _windowsControl = require("../windows-control");
require("./index.css");
var _classnames = _interopRequireDefault(require("classnames"));
var _i18n = require("../../i18n");
var _jsxRuntime = require("react/jsx-runtime");
var platformIsWindows = (0, _env.getPlatform)() === _env.FcrApplicationPlatform.WINDOWS;
var WindowType = exports.WindowType = /*#__PURE__*/function (WindowType) {
  WindowType["WINDOW"] = "window";
  WindowType["MODAL"] = "modal";
  return WindowType;
}({});
var FcrWindowHeader = exports.FcrWindowHeader = function FcrWindowHeader(props) {
  var type = props.type,
    otherActions = props.otherActions,
    otherActionsAfter = props.otherActionsAfter,
    _props$withWindowPopU = props.withWindowPopUpButton,
    withWindowPopUpButton = _props$withWindowPopU === void 0 ? true : _props$withWindowPopU,
    onClose = props.onClose,
    _props$showClose = props.showClose,
    showClose = _props$showClose === void 0 ? type === WindowType.MODAL : _props$showClose,
    enableMaximize = props.enableMaximize,
    enableMinimize = props.enableMinimize,
    onMinimize = props.onMinimize,
    onMaximize = props.onMaximize,
    onReduction = props.onReduction;
  // console.log('[FcrWindowHeader]', props);

  var handlerTypeChange = function handlerTypeChange() {
    if (props.onTypeChange) {
      props.onTypeChange(type === WindowType.WINDOW ? WindowType.MODAL : WindowType.WINDOW);
    }
  };
  var iconColors = {
    iconPrimary: 'var(--fcr_ui_scene_icontext1)'
  };
  var t = (0, _i18n.useI18n)();
  var showInWindowsAndWeb = type === WindowType.WINDOW && platformIsWindows || platformIsWindows && !(0, _env.isElectron)();
  var showInMacAndWeb = type === WindowType.WINDOW && !platformIsWindows || !platformIsWindows && !(0, _env.isElectron)();
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
    className: (0, _classnames["default"])('frc-window-header', (0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, "frc-window-header-".concat(type), type), "frc-window-header-web", showInMacAndWeb), 'frc-window-header-reverse', showInWindowsAndWeb && showClose), props.rootClassName || ''),
    children: [showInWindowsAndWeb && showClose && /*#__PURE__*/(0, _jsxRuntime.jsx)(_windowsControl.FcrWindowControl, {
      enableMaximize: enableMaximize,
      enableMinimize: enableMinimize,
      onMinimize: onMinimize,
      onClose: onClose,
      onMaximize: onMaximize,
      onReduction: onReduction
    }), showInMacAndWeb && showClose && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "frc-window-header-mac-control",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
        className: "frc-window-header-mac_button frc-window-header-mac_close",
        onClick: onClose,
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icon.FcrIcon, {
          className: "frc-window-header-mac-icon frc-window-header-mac_close-icon",
          type: _type.FcrIconType.FCR_CLOSE,
          colors: {
            iconPrimary: 'var(--fcr_ui_scene_black9_5)'
          }
        })
      })
    }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "frc-window-header__title",
      children: props.title
    }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      className: "frc-window-header__operates",
      children: [otherActions, withWindowPopUpButton && /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.FcrToolTip, {
        isArrowAndTargetCenter: true,
        content: type === WindowType.MODAL ? t('fmt_uimanager_option_popwindow') : t('fmt_uimanager_option_mergeview'),
        mouseEnterDelay: 0,
        trigger: "hover",
        children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconButton.FcrIconButton, {
            icon: type === WindowType.MODAL ? _type.FcrIconType.FCR_WINDOWPAGE_LONELY : _type.FcrIconType.FCR_WINDOWPAGE_BIGGER,
            onClick: handlerTypeChange,
            className: "frc-window-header__icon fcr-no-drag",
            iconColors: iconColors
          })
        })
      }), otherActionsAfter]
    })]
  });
};