"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _ComponentContainer = _interopRequireDefault(require("../../../../../Framework/ComponentContainer"));
var _Actions = require("../../../../Reducers/UI/Actions");
var _Actions2 = require("../../../../Reducers/Configurator/Actions");
var _get = _interopRequireDefault(require("lodash/get"));
var _ServiceLocator = require("../../../../ServiceLocator");
var _CustomTitleEditor = _interopRequireDefault(require("../../Components/CustomTitleEditor"));
var _Dialog = _interopRequireDefault(require("../../../../../Framework/Components/Dialog"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var mapStateToProps = function mapStateToProps(_ref) {
  var ui = _ref.ui,
    configurator = _ref.configurator;
  return {
    Component: _CustomTitleEditor["default"],
    DialogComponent: _Dialog["default"],
    show: !!ui.visibilityMap.customTitleEditor,
    title: (0, _get["default"])(configurator.configuration, 'customdata.title') || ''
  };
};
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
  return {
    onChange: function onChange(title) {
      dispatch((0, _Actions2.setCustomTitle)(title));
      _ServiceLocator.Services.async.resolve('customEditorConfirm');
    },
    onClose: function onClose() {
      dispatch((0, _Actions.setVisible)('customTitleEditor', false));
      _ServiceLocator.Services.async.reject('customEditorConfirm', 'Custom title not confirmed.');
    }
  };
};
var _default = exports["default"] = (0, _ComponentContainer["default"])(mapStateToProps, mapDispatchToProps);