"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _ScopeTreeView = _interopRequireDefault(require("./ScopeTreeView"));
var _styles = require("@material-ui/core/styles");
var _Sidepanel = _interopRequireDefault(require("./../../Sidepanel"));
var _ClickAwayListener = _interopRequireDefault(require("@material-ui/core/ClickAwayListener"));
var _InputBase = _interopRequireDefault(require("./../Inputs/InputBase"));
var _reactIntl = require("react-intl");
var _InputBaseProps = _interopRequireDefault(require("./../Inputs/InputBaseProps"));
var _sharedMessages = _interopRequireDefault(require("./../../../sharedMessages"));
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);
})();
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 useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    container: {
      top: theme.spacing(9),
      zIndex: 9999,
      backgroundColor: theme.palette.grey.light,
      border: "1px solid ".concat(theme.palette.grey.borders),
      boxShadow: "0 2px 4px rgba(0,0,0,0.5)",
      width: theme.spacing(50),
      display: "flex"
    },
    scopeContainer: {
      width: "100%"
    },
    scopeSelector: {
      display: "flex",
      flexDirection: "column",
      height: "calc(100% - ".concat(theme.spacing(12), ")"),
      overflowY: "auto",
      overflowX: "hidden",
      padding: "".concat(theme.spacing(3), " ").concat(theme.spacing(2), " ").concat(theme.spacing(2), " ").concat(theme.spacing(2))
    },
    inputContainer: {
      padding: theme.spacing(2),
      borderBottom: "1px solid ".concat(theme.palette.grey.icon)
    }
  };
});
var ScopeSelector = function ScopeSelector(_ref) {
  var show = _ref.show,
    getScope = _ref.getScope,
    selectedScope = _ref.selectedScope,
    closeSelector = _ref.closeSelector,
    filter = _ref.filter,
    updateFilter = _ref.updateFilter,
    isScopeSelectable = _ref.isScopeSelectable;
  var classes = useStyles();
  var _useIntl = (0, _reactIntl.useIntl)(),
    formatMessage = _useIntl.formatMessage;
  var inputBaseProps = new _InputBaseProps.default();
  inputBaseProps.set(_InputBaseProps.default.propNames.placeholder, formatMessage(_sharedMessages.default.scopeFilterPlaceholder));
  inputBaseProps.set(_InputBaseProps.default.propNames.value, filter);
  inputBaseProps.set(_InputBaseProps.default.propNames.update, updateFilter);
  var scopeSelectorContent = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.inputContainer
  }, /*#__PURE__*/_react.default.createElement(_InputBase.default, {
    inputProps: inputBaseProps
  })), /*#__PURE__*/_react.default.createElement("div", {
    className: classes.scopeSelector
  }, /*#__PURE__*/_react.default.createElement(_ScopeTreeView.default, {
    className: classes.test,
    rootId: "Global",
    getScope: getScope,
    selected: selectedScope.id,
    expanded: selectedScope.scopePath,
    onSelected: closeSelector,
    isScopeSelectable: isScopeSelectable
  })));
  var scopeSelector = /*#__PURE__*/_react.default.createElement(_Sidepanel.default, {
    className: classes.container,
    in: show,
    timeout: 300
  }, /*#__PURE__*/_react.default.createElement(_ClickAwayListener.default, {
    onClickAway: function onClickAway(e) {
      return closeSelector(e);
    }
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: classes.scopeContainer
  }, show ? scopeSelectorContent : null)));
  return scopeSelector;
};
__signature__(ScopeSelector, "useStyles{classes}\nuseIntl{{ formatMessage }}", function () {
  return [useStyles, _reactIntl.useIntl];
});
__signature__(ScopeSelector, "useStyles{classes}\nuseIntl{{ formatMessage }}", function () {
  return [useStyles, _reactIntl.useIntl];
});
var _default = ScopeSelector;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/ScopeSelector/ScopeSelector.js");
  reactHotLoader.register(ScopeSelector, "ScopeSelector", "/home/vsts/work/1/s/src/components/MaterialUI/ScopeSelector/ScopeSelector.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/ScopeSelector/ScopeSelector.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(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/ScopeSelector/ScopeSelector.js");
  reactHotLoader.register(ScopeSelector, "ScopeSelector", "/home/vsts/work/1/s/src/components/MaterialUI/ScopeSelector/ScopeSelector.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/ScopeSelector/ScopeSelector.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();