Liferay.Loader.define("layout-content-page-editor-web@2.0.157/page_editor/app/components/fragment-configuration-fields/HideFromSearchField", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/button', 'frontend-js-react-web$prop-types', 'frontend-js-react-web$react', '../../selectors/selectSegmentsExperienceId', '../../store/index', '../../thunks/updateItemConfig', '../Controls', './CheckboxField'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.HideFromSearchField = HideFromSearchField;

    var _button = _interopRequireDefault(require("@frontend-taglib-clay$clayui/button"));

    var _propTypes = _interopRequireDefault(require("frontend-js-react-web$prop-types"));

    var _react = _interopRequireDefault(require("frontend-js-react-web$react"));

    var _selectSegmentsExperienceId = _interopRequireDefault(require("../../selectors/selectSegmentsExperienceId"));

    var _index = require("../../store/index");

    var _updateItemConfig = _interopRequireDefault(require("../../thunks/updateItemConfig"));

    var _Controls = require("../Controls");

    var _CheckboxField = require("./CheckboxField");

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _defineProperty(obj, key, value) {
      if (key in obj) {
        Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true });
      } else {
        obj[key] = value;
      }return obj;
    }

    function getHiddenAncestorId(layoutData, item) {
      var parent = layoutData.items[item.parentId];

      if (!parent) {
        return null;
      }

      return parent.config.indexed === false ? parent.itemId : getHiddenAncestorId(layoutData, parent);
    }

    function HideFromSearchField(_ref) {
      var item = _ref.item;
      var dispatch = (0, _index.useDispatch)();
      var segmentsExperienceId = (0, _index.useSelector)(_selectSegmentsExperienceId.default);
      var layoutData = (0, _index.useSelector)(function (state) {
        return state.layoutData;
      });
      var selectItem = (0, _Controls.useSelectItem)();
      var hiddenAncestorId = getHiddenAncestorId(layoutData, item);
      return (/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_CheckboxField.CheckboxField, {
          disabled: Boolean(hiddenAncestorId),
          field: {
            label: Liferay.Language.get('hide-from-site-search-results'),
            name: 'indexed'
          },
          onValueSelect: function onValueSelect(name, value) {
            var itemConfig = _defineProperty({}, name, !value);

            dispatch((0, _updateItemConfig.default)({
              itemConfig: itemConfig,
              itemId: item.itemId,
              segmentsExperienceId: segmentsExperienceId
            }));
          },
          title: hiddenAncestorId ? Liferay.Language.get('configuration-inherited-from-parent-fragment') : null,
          value: hiddenAncestorId || item.config.indexed === false
        }), hiddenAncestorId && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
          className: "m-0 small text-secondary"
        }, Liferay.Language.get('this-configuration-is-inherited')), /*#__PURE__*/_react.default.createElement(_button.default, {
          className: "p-0 page-editor__hide-feedback-button text-left",
          displayType: "link",
          onClick: function onClick() {
            return selectItem(hiddenAncestorId);
          }
        }, Liferay.Language.get('go-to-parent-fragment-to-edit'))))
      );
    }
    //# sourceMappingURL=HideFromSearchField.js.map
  }
});
//# sourceMappingURL=HideFromSearchField.js.map