"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = NavigationMenuEditor;
var _element = require("@wordpress/element");
var _data = require("@wordpress/data");
var _blockEditor = require("@wordpress/block-editor");
var _blocks = require("@wordpress/blocks");
var _lockUnlock = require("../../lock-unlock");
var _store = require("../../store");
var _navigationMenuContent = _interopRequireDefault(require("../sidebar-navigation-screen-navigation-menus/navigation-menu-content"));
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

const noop = () => {};
function NavigationMenuEditor({
  navigationMenuId
}) {
  const {
    storedSettings
  } = (0, _data.useSelect)(select => {
    const {
      getSettings
    } = (0, _lockUnlock.unlock)(select(_store.store));
    return {
      storedSettings: getSettings()
    };
  }, []);
  const blocks = (0, _element.useMemo)(() => {
    if (!navigationMenuId) {
      return [];
    }
    return [(0, _blocks.createBlock)('core/navigation', {
      ref: navigationMenuId
    })];
  }, [navigationMenuId]);
  if (!navigationMenuId || !blocks?.length) {
    return null;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockEditorProvider, {
    settings: storedSettings,
    value: blocks,
    onChange: noop,
    onInput: noop,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "edit-site-sidebar-navigation-screen-navigation-menus__content",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_navigationMenuContent.default, {
        rootClientId: blocks[0].clientId
      })
    })
  });
}
//# sourceMappingURL=navigation-menu-editor.js.map