"use strict";

exports.__esModule = true;
exports.default = void 0;
var _reactRedux = require("react-redux");
var _filterHelper = require("../../../utils/filterHelper");
var _metadata = require("../../../selectors/metadata");
var _localizationHelper = require("../../../utils/localizationHelper");
var _createInput = _interopRequireWildcard(require("./createInput"));
var _excluded = ["moduleName", "lookupName", "value", "onChange", "disabled", "metadata"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
(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 _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
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 LookupSelect = function LookupSelect(_ref) {
  var moduleName = _ref.moduleName,
    lookupName = _ref.lookupName,
    value = _ref.value,
    onChange = _ref.onChange,
    disabled = _ref.disabled,
    metadata = _ref.metadata,
    props = _objectWithoutProperties(_ref, _excluded);
  var options = (0, _filterHelper.extractDropboxOptions)((0, _reactRedux.useSelector)((0, _metadata.namedLookupValuesSelector)(moduleName, lookupName)));
  if (value !== null && !options.some(function (x) {
    return x.value === value;
  })) {
    options.push({
      label: (0, _localizationHelper.getNotLocalizedString)(value),
      value: value,
      sortOrder: 0
    });
  }
  var inputProps = {};
  if (props != null && props["data-qa"]) {
    inputProps["data-qa"] = props["data-qa"];
  }
  return (0, _createInput.default)(_createInput.inputTypes.select, {
    options: options,
    value: value,
    update: function update(newValue) {
      return onChange(newValue, metadata);
    },
    disabled: disabled,
    inputProps: inputProps
  });
};
__signature__(LookupSelect, "useSelector{}", function () {
  return [_reactRedux.useSelector];
});
__signature__(LookupSelect, "useSelector{}", function () {
  return [_reactRedux.useSelector];
});
var _default = LookupSelect;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(LookupSelect, "LookupSelect", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.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(LookupSelect, "LookupSelect", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/Inputs/LookupSelect.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();