"use strict";

exports.__esModule = true;
exports.getClickOutsideHandler = exports.default = exports.AboutBox = exports.About = exports.ABOUT_NAME = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactDom = _interopRequireDefault(require("react-dom"));
var _reactRedux = require("react-redux");
var _reactIntl = require("react-intl");
var _styles = require("@material-ui/core/styles");
var _withClickOutside = _interopRequireDefault(require("../../hocs/withClickOutside"));
var _useViewState3 = _interopRequireDefault(require("../../hooks/useViewState"));
var _aboutBackground = _interopRequireDefault(require("../../content/aboutBackground.png"));
var _orckestraLogoWhite = _interopRequireDefault(require("../../content/orckestra-logo-white.png"));
var _close = _interopRequireDefault(require("../../content/close.png"));
var _versionInfo = require("../../selectors/versionInfo");
var _locale = require("../../selectors/locale");
var _sharedMessages = _interopRequireDefault(require("./../../sharedMessages"));
var _lodash = require("lodash");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var ABOUT_NAME = exports.ABOUT_NAME = "__aboutBox";
var getModalRoot = function getModalRoot() {
  return document.getElementById("modal");
};
var useStyles = (0, _styles.makeStyles)(function () {
  return {
    aboutBox: function aboutBox(props) {
      return {
        boxSizing: "border-box",
        zIndex: 9999,
        position: "absolute",
        top: "calc(50% - 210px)",
        left: "calc(50% - 210px)",
        height: "420px",
        width: "420px",
        padding: "15px 20px",
        color: "#ffffff",
        fontSize: "13px",
        lineHeight: "16px",
        background: "#0a0a07 url(".concat(props.bgImage, ")"),
        "&.enter-active": {
          opacity: 1,
          transition: "none",
          visibility: "visible"
        },
        "&.exit-active": {
          opacity: 0,
          transition: "opacity 800ms ease-out, visibility 800ms linear 800ms;",
          visibility: "hidden"
        }
      };
    },
    closeButton: {
      zIndex: 9999,
      position: "absolute",
      color: "#ffffff",
      top: "15px",
      right: "20px",
      margin: "0",
      cursor: "pointer",
      opacity: "1",
      "&:hover": {
        opacity: 0.75
      }
    },
    aboutLink: {
      color: "#337ab7",
      textDecoration: "none"
    },
    aboutParagraph: {
      marginTop: "20px"
    },
    longAboutParagraph: function longAboutParagraph(props) {
      var _props$lang;
      return {
        marginTop: "20px",
        fontSize: (_props$lang = props.lang) != null && _props$lang.toLowerCase().startsWith("fr") ? "10px" : undefined
      };
    }
  };
});
var AboutBox = exports.AboutBox = (0, _withClickOutside.default)(_react.default.forwardRef(__signature__(__signature__(function (_ref, ref) {
  var children = _ref.children,
    className = _ref.className;
  var classes = useStyles({
    bgImage: _aboutBackground.default
  });
  return /*#__PURE__*/_react.default.createElement("div", {
    ref: ref,
    className: "".concat(classes.aboutBox, " ").concat(className ? className : "")
  }, children);
}, "useStyles{classes}", function () {
  return [useStyles];
}), "useStyles{classes}", function () {
  return [useStyles];
})));
var getClickOutsideHandler = exports.getClickOutsideHandler = function getClickOutsideHandler(_ref2, updateViewState) {
  var show = _ref2.show;
  return show ? function (event) {
    event.stopPropagation();
    updateViewState("show", false);
  } : function () {};
};
var About = exports.About = function About(_ref3) {
  var currentApplication = _ref3.currentApplication;
  var lang = document.documentElement.lang;
  var classes = useStyles({
    lang: lang
  });
  var _useViewState = (0, _useViewState3.default)(ABOUT_NAME),
    _useViewState2 = _slicedToArray(_useViewState, 2),
    viewState = _useViewState2[0],
    updateViewState = _useViewState2[1];
  var version = (0, _reactRedux.useSelector)(_versionInfo.getVersionSelector);
  var locale = (0, _reactRedux.useSelector)(_locale.currentLocaleOrDefault);
  var closeAboutBox = getClickOutsideHandler(viewState, updateViewState);
  var aboutLinkUrl = "https://www.orckestra.com".concat(locale.substr(0, 2).toLowerCase() === "fr" ? "/fr" : "");
  return /*#__PURE__*/_react.default.createElement(AboutBox, {
    className: "".concat(viewState.show ? "enter-active" : "exit-active"),
    onClickOutside: closeAboutBox
  }, /*#__PURE__*/_react.default.createElement("p", {
    className: classes.closeButton,
    onClick: closeAboutBox
  }, /*#__PURE__*/_react.default.createElement("img", {
    src: _close.default,
    alt: "X"
  })), /*#__PURE__*/_react.default.createElement("img", {
    src: _orckestraLogoWhite.default,
    width: "250",
    alt: "Orckestra"
  }), /*#__PURE__*/_react.default.createElement("p", {
    className: classes.aboutParagraph
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _extends({}, _sharedMessages.default.ccVersion, {
    values: {
      version: version
    }
  })), currentApplication && currentApplication.displayName ? [/*#__PURE__*/_react.default.createElement("br", {
    key: "application-br"
  }), currentApplication.displayName.concat(" ", window.BUILD_NUMBER)] : null, DEPENDENCIES && DEPENDENCIES["orc-shared"] ? [/*#__PURE__*/_react.default.createElement("br", {
    key: "orc-shared-br"
  }), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _extends({
    key: "orc-shared-version"
  }, _sharedMessages.default.orcSharedVersion, {
    values: {
      version: (0, _lodash.trimStart)(DEPENDENCIES["orc-shared"], "^")
    }
  }))] : null, DEPENDENCIES && DEPENDENCIES["orc-scripts"] ? [/*#__PURE__*/_react.default.createElement("br", {
    key: "orc-scripts-br"
  }), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _extends({
    key: "orc-scripts-version"
  }, _sharedMessages.default.orcScriptsVersion, {
    values: {
      version: (0, _lodash.trimStart)(DEPENDENCIES["orc-scripts"], "^")
    }
  }))] : null, DEPENDENCIES && DEPENDENCIES["orc-secret"] ? [/*#__PURE__*/_react.default.createElement("br", {
    key: "orc-secret-br"
  }), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _extends({
    key: "orc-secret-version"
  }, _sharedMessages.default.orcSecretVersion, {
    values: {
      version: (0, _lodash.trimStart)(DEPENDENCIES["orc-secret"], "^")
    }
  }))] : null), /*#__PURE__*/_react.default.createElement("p", {
    className: classes.longAboutParagraph
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.copyrightTermsNotice)), /*#__PURE__*/_react.default.createElement("p", {
    className: classes.aboutParagraph
  }, /*#__PURE__*/_react.default.createElement("a", {
    className: classes.aboutLink,
    href: aboutLinkUrl,
    target: "_blank",
    rel: "noreferrer"
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.ccName))), /*#__PURE__*/_react.default.createElement("p", {
    className: classes.aboutParagraph
  }, /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _extends({}, _sharedMessages.default.copyright, {
    values: {
      year: new Date().getFullYear()
    }
  })), /*#__PURE__*/_react.default.createElement("br", null), /*#__PURE__*/_react.default.createElement(_reactIntl.FormattedMessage, _sharedMessages.default.allRightsReserved)));
};
__signature__(About, "useStyles{classes}\nuseViewState{[viewState, updateViewState]}\nuseSelector{version}\nuseSelector{locale}", function () {
  return [useStyles, _useViewState3.default, _reactRedux.useSelector, _reactRedux.useSelector];
});
__signature__(About, "useStyles{classes}\nuseViewState{[viewState, updateViewState]}\nuseSelector{version}\nuseSelector{locale}", function () {
  return [useStyles, _useViewState3.default, _reactRedux.useSelector, _reactRedux.useSelector];
});
var WiredAbout = About;
var _default = function _default(props) {
  return _reactDom.default.createPortal(/*#__PURE__*/_react.default.createElement(WiredAbout, props), getModalRoot());
};
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(ABOUT_NAME, "ABOUT_NAME", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(getModalRoot, "getModalRoot", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(AboutBox, "AboutBox", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(getClickOutsideHandler, "getClickOutsideHandler", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(About, "About", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(WiredAbout, "WiredAbout", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(ABOUT_NAME, "ABOUT_NAME", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(getModalRoot, "getModalRoot", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(AboutBox, "AboutBox", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(getClickOutsideHandler, "getClickOutsideHandler", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(About, "About", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(WiredAbout, "WiredAbout", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/AppFrame/About.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();