PluginProbe
Gutenberg / 10.1.0
Gutenberg v10.1.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
← All changes | build/edit-navigation/index.js +3 -5088 12.6.0 → 10.1.0 View file →
@@ -1,5088 +1,3 @@
1 -/******/ (function() { // webpackBootstrap
2 -/******/ var __webpack_modules__ = ({
3 -
4 -/***/ 4184:
5 -/***/ (function(module, exports) {
6 -
7 -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
8 - Copyright (c) 2018 Jed Watson.
9 - Licensed under the MIT License (MIT), see
10 - http://jedwatson.github.io/classnames
11 -*/
12 -/* global define */
13 -
14 -(function () {
15 - 'use strict';
16 -
17 - var hasOwn = {}.hasOwnProperty;
18 -
19 - function classNames() {
20 - var classes = [];
21 -
22 - for (var i = 0; i < arguments.length; i++) {
23 - var arg = arguments[i];
24 - if (!arg) continue;
25 -
26 - var argType = typeof arg;
27 -
28 - if (argType === 'string' || argType === 'number') {
29 - classes.push(arg);
30 - } else if (Array.isArray(arg)) {
31 - if (arg.length) {
32 - var inner = classNames.apply(null, arg);
33 - if (inner) {
34 - classes.push(inner);
35 - }
36 - }
37 - } else if (argType === 'object') {
38 - if (arg.toString === Object.prototype.toString) {
39 - for (var key in arg) {
40 - if (hasOwn.call(arg, key) && arg[key]) {
41 - classes.push(key);
42 - }
43 - }
44 - } else {
45 - classes.push(arg.toString());
46 - }
47 - }
48 - }
49 -
50 - return classes.join(' ');
51 - }
52 -
53 - if ( true && module.exports) {
54 - classNames.default = classNames;
55 - module.exports = classNames;
56 - } else if (true) {
57 - // register as 'classnames', consistent with npm package name
58 - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
59 - return classNames;
60 - }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
61 - __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
62 - } else {}
63 -}());
64 -
65 -
66 -/***/ })
67 -
68 -/******/ });
69 -/************************************************************************/
70 -/******/ // The module cache
71 -/******/ var __webpack_module_cache__ = {};
72 -/******/
73 -/******/ // The require function
74 -/******/ function __webpack_require__(moduleId) {
75 -/******/ // Check if module is in cache
76 -/******/ var cachedModule = __webpack_module_cache__[moduleId];
77 -/******/ if (cachedModule !== undefined) {
78 -/******/ return cachedModule.exports;
79 -/******/ }
80 -/******/ // Create a new module (and put it into the cache)
81 -/******/ var module = __webpack_module_cache__[moduleId] = {
82 -/******/ // no module.id needed
83 -/******/ // no module.loaded needed
84 -/******/ exports: {}
85 -/******/ };
86 -/******/
87 -/******/ // Execute the module function
88 -/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
89 -/******/
90 -/******/ // Return the exports of the module
91 -/******/ return module.exports;
92 -/******/ }
93 -/******/
94 -/************************************************************************/
95 -/******/ /* webpack/runtime/compat get default export */
96 -/******/ !function() {
97 -/******/ // getDefaultExport function for compatibility with non-harmony modules
98 -/******/ __webpack_require__.n = function(module) {
99 -/******/ var getter = module && module.__esModule ?
100 -/******/ function() { return module['default']; } :
101 -/******/ function() { return module; };
102 -/******/ __webpack_require__.d(getter, { a: getter });
103 -/******/ return getter;
104 -/******/ };
105 -/******/ }();
106 -/******/
107 -/******/ /* webpack/runtime/define property getters */
108 -/******/ !function() {
109 -/******/ // define getter functions for harmony exports
110 -/******/ __webpack_require__.d = function(exports, definition) {
111 -/******/ for(var key in definition) {
112 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
113 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
114 -/******/ }
115 -/******/ }
116 -/******/ };
117 -/******/ }();
118 -/******/
119 -/******/ /* webpack/runtime/hasOwnProperty shorthand */
120 -/******/ !function() {
121 -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
122 -/******/ }();
123 -/******/
124 -/******/ /* webpack/runtime/make namespace object */
125 -/******/ !function() {
126 -/******/ // define __esModule on exports
127 -/******/ __webpack_require__.r = function(exports) {
128 -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
129 -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
130 -/******/ }
131 -/******/ Object.defineProperty(exports, '__esModule', { value: true });
132 -/******/ };
133 -/******/ }();
134 -/******/
135 -/************************************************************************/
136 -var __webpack_exports__ = {};
137 -// This entry need to be wrapped in an IIFE because it need to be in strict mode.
138 -!function() {
139 -"use strict";
140 -// ESM COMPAT FLAG
141 -__webpack_require__.r(__webpack_exports__);
142 -
143 -// EXPORTS
144 -__webpack_require__.d(__webpack_exports__, {
145 - "__unstableCreateMenuPreloadingMiddleware": function() { return /* reexport */ createMenuPreloadingMiddleware; },
146 - "initialize": function() { return /* binding */ initialize; }
147 -});
148 -
149 -// NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/resolvers.js
150 -var resolvers_namespaceObject = {};
151 -__webpack_require__.r(resolvers_namespaceObject);
152 -__webpack_require__.d(resolvers_namespaceObject, {
153 - "getNavigationPostForMenu": function() { return getNavigationPostForMenu; }
154 -});
155 -
156 -// NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/selectors.js
157 -var selectors_namespaceObject = {};
158 -__webpack_require__.r(selectors_namespaceObject);
159 -__webpack_require__.d(selectors_namespaceObject, {
160 - "getNavigationPostForMenu": function() { return selectors_getNavigationPostForMenu; },
161 - "getSelectedMenuId": function() { return getSelectedMenuId; },
162 - "hasResolvedNavigationPost": function() { return hasResolvedNavigationPost; },
163 - "isInserterOpened": function() { return isInserterOpened; }
164 -});
165 -
166 -// NAMESPACE OBJECT: ./packages/edit-navigation/build-module/store/actions.js
167 -var actions_namespaceObject = {};
168 -__webpack_require__.r(actions_namespaceObject);
169 -__webpack_require__.d(actions_namespaceObject, {
170 - "saveNavigationPost": function() { return saveNavigationPost; },
171 - "setIsInserterOpened": function() { return setIsInserterOpened; },
172 - "setSelectedMenuId": function() { return setSelectedMenuId; }
173 -});
174 -
175 -// NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
176 -var store_actions_namespaceObject = {};
177 -__webpack_require__.r(store_actions_namespaceObject);
178 -__webpack_require__.d(store_actions_namespaceObject, {
179 - "disableComplementaryArea": function() { return disableComplementaryArea; },
180 - "enableComplementaryArea": function() { return enableComplementaryArea; },
181 - "pinItem": function() { return pinItem; },
182 - "setFeatureDefaults": function() { return setFeatureDefaults; },
183 - "setFeatureValue": function() { return setFeatureValue; },
184 - "toggleFeature": function() { return toggleFeature; },
185 - "unpinItem": function() { return unpinItem; }
186 -});
187 -
188 -// NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
189 -var store_selectors_namespaceObject = {};
190 -__webpack_require__.r(store_selectors_namespaceObject);
191 -__webpack_require__.d(store_selectors_namespaceObject, {
192 - "getActiveComplementaryArea": function() { return getActiveComplementaryArea; },
193 - "isFeatureActive": function() { return isFeatureActive; },
194 - "isItemPinned": function() { return isItemPinned; }
195 -});
196 -
197 -;// CONCATENATED MODULE: external ["wp","element"]
198 -var external_wp_element_namespaceObject = window["wp"]["element"];
199 -;// CONCATENATED MODULE: external ["wp","blocks"]
200 -var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
201 -;// CONCATENATED MODULE: external ["wp","blockLibrary"]
202 -var external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"];
203 -;// CONCATENATED MODULE: external ["wp","data"]
204 -var external_wp_data_namespaceObject = window["wp"]["data"];
205 -;// CONCATENATED MODULE: external ["wp","coreData"]
206 -var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
207 -;// CONCATENATED MODULE: external ["wp","i18n"]
208 -var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
209 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/constants/index.js
210 -/**
211 - * "Kind" of the menu post.
212 - *
213 - * @type {string}
214 - */
215 -const MENU_KIND = 'root';
216 -/**
217 - * "post type" of the menu post.
218 - *
219 - * @type {string}
220 - */
221 -
222 -const MENU_POST_TYPE = 'menu';
223 -/**
224 - * "Kind" of the navigation post.
225 - *
226 - * @type {string}
227 - */
228 -
229 -const NAVIGATION_POST_KIND = 'root';
230 -/**
231 - * "post type" of the navigation post.
232 - *
233 - * @type {string}
234 - */
235 -
236 -const NAVIGATION_POST_POST_TYPE = 'navigationPost';
237 -/**
238 - * The scope name of the editor's complementary area.
239 - *
240 - * @type {string}
241 - */
242 -
243 -const SIDEBAR_SCOPE = 'core/edit-navigation';
244 -/**
245 - * The identifier of the editor's menu complementary area.
246 - *
247 - * @type {string}
248 - */
249 -
250 -const SIDEBAR_MENU = 'edit-navigation/menu';
251 -/**
252 - * The identifier of the editor's block complementary area.
253 - *
254 - * @type {string}
255 - */
256 -
257 -const SIDEBAR_BLOCK = 'edit-navigation/block-inspector';
258 -/**
259 - * The string identifier for the menu item's "target" attribute indicating
260 - * the menu item link should open in a new tab.
261 - *
262 - * @type {string}
263 - */
264 -
265 -const NEW_TAB_TARGET_ATTRIBUTE = '_blank';
266 -//# sourceMappingURL=index.js.map
267 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/reducer.js
268 -/**
269 - * WordPress dependencies
270 - */
271 -
272 -/**
273 - * Reducer keeping track of selected menu ID.
274 - *
275 - * @param {number} state Current state.
276 - * @param {Object} action Dispatched action.
277 - * @return {Object} Updated state.
278 - */
279 -
280 -function selectedMenuId() {
281 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
282 - let action = arguments.length > 1 ? arguments[1] : undefined;
283 -
284 - switch (action.type) {
285 - case 'SET_SELECTED_MENU_ID':
286 - return action.menuId;
287 - }
288 -
289 - return state;
290 -}
291 -/**
292 - * Reducer tracking whether the inserter is open.
293 - *
294 - * @param {boolean|Object} state Current state.
295 - * @param {Object} action Dispatched action.
296 - * @param {string} action.type String indicating action type.
297 - * @param {boolean} action.value Flag indicating whether the panel should be open/close.
298 - */
299 -
300 -function blockInserterPanel() {
301 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
302 - let action = arguments.length > 1 ? arguments[1] : undefined;
303 -
304 - switch (action.type) {
305 - case 'SET_IS_INSERTER_OPENED':
306 - return action.value;
307 - }
308 -
309 - return state;
310 -}
311 -
312 -/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
313 - selectedMenuId,
314 - blockInserterPanel
315 -}));
316 -//# sourceMappingURL=reducer.js.map
317 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/utils.js
318 -/**
319 - * A WP nav_menu_item object.
320 - * For more documentation on the individual fields present on a menu item please see:
321 - * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789
322 - *
323 - * Changes made here should also be mirrored in packages/block-library/src/navigation/map-menu-items-to-blocks.js.
324 - *
325 - * @typedef WPNavMenuItem
326 - *
327 - * @property {Object} title stores the raw and rendered versions of the title/label for this menu item.
328 - * @property {Array} xfn the XFN relationships expressed in the link of this menu item.
329 - * @property {Array} classes the HTML class attributes for this menu item.
330 - * @property {string} attr_title the HTML title attribute for this menu item.
331 - * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'.
332 - * @property {string} object_id The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
333 - * @property {string} description The description of this menu item.
334 - * @property {string} url The URL to which this menu item points.
335 - * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'.
336 - * @property {string} target The target attribute of the link element for this menu item.
337 - */
338 -
339 -/**
340 - * Builds an ID for a new navigation post.
341 - *
342 - * @param {number} menuId Menu id.
343 - * @return {string} An ID.
344 - */
345 -const buildNavigationPostId = menuId => `navigation-post-${menuId}`;
346 -/**
347 - * Builds a query to resolve menu items.
348 - *
349 - * @param {number} menuId Menu id.
350 - * @return {Object} Query.
351 - */
352 -
353 -function menuItemsQuery(menuId) {
354 - return {
355 - menus: menuId,
356 - per_page: -1
357 - };
358 -}
359 -/**
360 - * Get the internal record id from block.
361 - *
362 - * @typedef {Object} Attributes
363 - * @property {string} __internalRecordId The internal record id.
364 - * @typedef {Object} Block
365 - * @property {Attributes} attributes The attributes of the block.
366 - *
367 - * @param {Block} block The block.
368 - * @return {string} The internal record id.
369 - */
370 -
371 -function getRecordIdFromBlock(block) {
372 - return block.attributes.__internalRecordId;
373 -}
374 -/**
375 - * Add internal record id to block's attributes.
376 - *
377 - * @param {Block} block The block.
378 - * @param {string} recordId The record id.
379 - * @return {Block} The updated block.
380 - */
381 -
382 -function addRecordIdToBlock(block, recordId) {
383 - return { ...block,
384 - attributes: { ...(block.attributes || {}),
385 - __internalRecordId: recordId
386 - }
387 - };
388 -}
389 -/**
390 - * Checks if a given block should be persisted as a menu item.
391 - *
392 - * @param {Object} block Block to check.
393 - * @return {boolean} True if a given block should be persisted as a menu item, false otherwise.
394 - */
395 -
396 -const isBlockSupportedInNav = block => ['core/navigation-link', 'core/navigation-submenu'].includes(block.name);
397 -//# sourceMappingURL=utils.js.map
398 -;// CONCATENATED MODULE: external "lodash"
399 -var external_lodash_namespaceObject = window["lodash"];
400 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/transform.js
401 -/**
402 - * External dependencies
403 - */
404 -
405 -/**
406 - * WordPress dependencies
407 - */
408 -
409 -
410 -/**
411 - * Internal dependencies
412 - */
413 -
414 -
415 -
416 -/**
417 - * A WP nav_menu_item object.
418 - * For more documentation on the individual fields present on a menu item please see:
419 - * https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L789
420 - *
421 - * Changes made here should also be mirrored in packages/edit-navigation/src/store/utils.js.
422 - *
423 - * @typedef WPNavMenuItem
424 - *
425 - * @property {Object} title stores the raw and rendered versions of the title/label for this menu item.
426 - * @property {Array} xfn the XFN relationships expressed in the link of this menu item.
427 - * @property {Array} classes the HTML class attributes for this menu item.
428 - * @property {string} attr_title the HTML title attribute for this menu item.
429 - * @property {string} object The type of object originally represented, such as 'category', 'post', or 'attachment'.
430 - * @property {string} object_id The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
431 - * @property {string} description The description of this menu item.
432 - * @property {string} url The URL to which this menu item points.
433 - * @property {string} type The family of objects originally represented, such as 'post_type' or 'taxonomy'.
434 - * @property {string} target The target attribute of the link element for this menu item.
435 - */
436 -
437 -function blockToMenuItem(block, menuItem, parentId, blockPosition, menuId) {
438 - menuItem = (0,external_lodash_namespaceObject.omit)(menuItem, 'menus', 'meta', '_links');
439 - menuItem.content = (0,external_lodash_namespaceObject.get)(menuItem.content, 'raw', menuItem.content);
440 - let attributes;
441 -
442 - if (isBlockSupportedInNav(block)) {
443 - attributes = blockAttributesToMenuItem(block.attributes);
444 - } else {
445 - attributes = {
446 - type: 'block',
447 - content: (0,external_wp_blocks_namespaceObject.serialize)(block)
448 - };
449 - }
450 -
451 - return { ...menuItem,
452 - ...attributes,
453 - content: attributes.content || '',
454 - id: getRecordIdFromBlock(block),
455 - menu_order: blockPosition + 1,
456 - menus: menuId,
457 - parent: !parentId ? 0 : parentId,
458 - status: 'publish'
459 - };
460 -}
461 -/**
462 - * Convert block attributes to menu item fields.
463 - *
464 - * Note that nav_menu_item has defaults provided in Core so in the case of undefined Block attributes
465 - * we need only include a subset of values in the knowledge that the defaults will be provided in Core.
466 - *
467 - * See: https://core.trac.wordpress.org/browser/tags/5.7.1/src/wp-includes/nav-menu.php#L438.
468 - *
469 - * @param {Object} blockAttributes the block attributes of the block to be converted into menu item fields.
470 - * @param {string} blockAttributes.label the visual name of the block shown in the UI.
471 - * @param {string} blockAttributes.url the URL for the link.
472 - * @param {string} blockAttributes.description a link description.
473 - * @param {string} blockAttributes.rel the XFN relationship expressed in the link of this menu item.
474 - * @param {string} blockAttributes.className the custom CSS classname attributes for this block.
475 - * @param {string} blockAttributes.title the HTML title attribute for the block's link.
476 - * @param {string} blockAttributes.type the type of variation of the block used (eg: 'Post', 'Custom', 'Category'...etc).
477 - * @param {number} blockAttributes.id the ID of the entity optionally associated with the block's link (eg: the Post ID).
478 - * @param {string} blockAttributes.kind the family of objects originally represented, such as 'post-type' or 'taxonomy'.
479 - * @param {boolean} blockAttributes.opensInNewTab whether or not the block's link should open in a new tab.
480 - * @return {WPNavMenuItem} the menu item (converted from block attributes).
481 - */
482 -
483 -const blockAttributesToMenuItem = _ref => {
484 - var _type;
485 -
486 - let {
487 - label = '',
488 - url = '',
489 - description,
490 - rel,
491 - className,
492 - title: blockTitleAttr,
493 - type,
494 - id,
495 - kind,
496 - opensInNewTab
497 - } = _ref;
498 -
499 - // For historical reasons, the `core/navigation-link` variation type is `tag`
500 - // whereas WP Core expects `post_tag` as the `object` type.
501 - // To avoid writing a block migration we perform a conversion here.
502 - // See also inverse equivalent in `menuItemToBlockAttributes`.
503 - if (type && type === 'tag') {
504 - type = 'post_tag';
505 - }
506 -
507 - return {
508 - title: label,
509 - url,
510 - ...((description === null || description === void 0 ? void 0 : description.length) && {
511 - description
512 - }),
513 - ...((rel === null || rel === void 0 ? void 0 : rel.length) && {
514 - xfn: rel === null || rel === void 0 ? void 0 : rel.trim().split(' ')
515 - }),
516 - ...((className === null || className === void 0 ? void 0 : className.length) && {
517 - classes: className === null || className === void 0 ? void 0 : className.trim().split(' ')
518 - }),
519 - ...((blockTitleAttr === null || blockTitleAttr === void 0 ? void 0 : blockTitleAttr.length) && {
520 - attr_title: blockTitleAttr
521 - }),
522 - ...(((_type = type) === null || _type === void 0 ? void 0 : _type.length) && {
523 - object: type
524 - }),
525 - ...((kind === null || kind === void 0 ? void 0 : kind.length) && {
526 - type: kind === null || kind === void 0 ? void 0 : kind.replace('-', '_')
527 - }),
528 - // Only assign object_id if it's a entity type (ie: not "custom").
529 - ...(id && 'custom' !== type && {
530 - object_id: id
531 - }),
532 - target: opensInNewTab ? NEW_TAB_TARGET_ATTRIBUTE : ''
533 - };
534 -};
535 -/**
536 - * Convert a flat menu item structure to a nested blocks structure.
537 - *
538 - * @param {Object[]} menuItems An array of menu items.
539 - *
540 - * @return {WPBlock[]} An array of blocks.
541 - */
542 -
543 -function menuItemsToBlocks(menuItems) {
544 - if (!menuItems) {
545 - return null;
546 - }
547 -
548 - const menuTree = createDataTree(menuItems);
549 - return mapMenuItemsToBlocks(menuTree);
550 -}
551 -/**
552 - * A recursive function that maps menu item nodes to blocks.
553 - *
554 - * @param {WPNavMenuItem[]} menuItems An array of WPNavMenuItem items.
555 - * @return {Object} Object containing innerBlocks and mapping.
556 - */
557 -
558 -function mapMenuItemsToBlocks(menuItems) {
559 - // The menuItem should be in menu_order sort order.
560 - const sortedItems = (0,external_lodash_namespaceObject.sortBy)(menuItems, 'menu_order');
561 - const blocks = sortedItems.map(menuItem => {
562 - var _menuItem$children;
563 -
564 - if (menuItem.type === 'block') {
565 - const [block] = (0,external_wp_blocks_namespaceObject.parse)(menuItem.content.raw);
566 -
567 - if (!block) {
568 - return (0,external_wp_blocks_namespaceObject.createBlock)('core/freeform', {
569 - content: menuItem.content
570 - });
571 - }
572 -
573 - return block;
574 - }
575 -
576 - const attributes = menuItemToBlockAttributes(menuItem); // If there are children recurse to build those nested blocks.
577 -
578 - const nestedBlocks = (_menuItem$children = menuItem.children) !== null && _menuItem$children !== void 0 && _menuItem$children.length ? mapMenuItemsToBlocks(menuItem.children) : []; // Create a submenu block when there are inner blocks, or just a link
579 - // for a standalone item.
580 -
581 - const itemBlockName = nestedBlocks !== null && nestedBlocks !== void 0 && nestedBlocks.length ? 'core/navigation-submenu' : 'core/navigation-link'; // Create block with nested "innerBlocks".
582 -
583 - return (0,external_wp_blocks_namespaceObject.createBlock)(itemBlockName, attributes, nestedBlocks);
584 - });
585 - return (0,external_lodash_namespaceObject.zip)(blocks, sortedItems).map(_ref2 => {
586 - let [block, menuItem] = _ref2;
587 - return addRecordIdToBlock(block, menuItem.id);
588 - });
589 -} // A few parameters are using snake case, let's embrace that for convenience:
590 -
591 -/* eslint-disable camelcase */
592 -
593 -/**
594 - * Convert block attributes to menu item.
595 - *
596 - * @param {WPNavMenuItem} menuItem the menu item to be converted to block attributes.
597 - * @return {Object} the block attributes converted from the WPNavMenuItem item.
598 - */
599 -
600 -
601 -function menuItemToBlockAttributes(_ref3) {
602 - var _object;
603 -
604 - let {
605 - title: menuItemTitleField,
606 - xfn,
607 - classes,
608 - attr_title,
609 - object,
610 - object_id,
611 - description,
612 - url,
613 - type: menuItemTypeField,
614 - target
615 - } = _ref3;
616 -
617 - // For historical reasons, the `core/navigation-link` variation type is `tag`
618 - // whereas WP Core expects `post_tag` as the `object` type.
619 - // To avoid writing a block migration we perform a conversion here.
620 - // See also inverse equivalent in `blockAttributesToMenuItem`.
621 - if (object && object === 'post_tag') {
622 - object = 'tag';
623 - }
624 -
625 - return {
626 - label: (menuItemTitleField === null || menuItemTitleField === void 0 ? void 0 : menuItemTitleField.rendered) || '',
627 - ...(((_object = object) === null || _object === void 0 ? void 0 : _object.length) && {
628 - type: object
629 - }),
630 - kind: (menuItemTypeField === null || menuItemTypeField === void 0 ? void 0 : menuItemTypeField.replace('_', '-')) || 'custom',
631 - url: url || '',
632 - ...((xfn === null || xfn === void 0 ? void 0 : xfn.length) && xfn.join(' ').trim() && {
633 - rel: xfn.join(' ').trim()
634 - }),
635 - ...((classes === null || classes === void 0 ? void 0 : classes.length) && classes.join(' ').trim() && {
636 - className: classes.join(' ').trim()
637 - }),
638 - ...((attr_title === null || attr_title === void 0 ? void 0 : attr_title.length) && {
639 - title: attr_title
640 - }),
641 - ...(object_id && 'custom' !== object && {
642 - id: object_id
643 - }),
644 - ...((description === null || description === void 0 ? void 0 : description.length) && {
645 - description
646 - }),
647 - ...(target === NEW_TAB_TARGET_ATTRIBUTE && {
648 - opensInNewTab: true
649 - })
650 - };
651 -}
652 -/* eslint-enable camelcase */
653 -
654 -/**
655 - * Creates a nested, hierarchical tree representation from unstructured data that
656 - * has an inherent relationship defined between individual items.
657 - *
658 - * For example, by default, each element in the dataset should have an `id` and
659 - * `parent` property where the `parent` property indicates a relationship between
660 - * the current item and another item with a matching `id` properties.
661 - *
662 - * This is useful for building linked lists of data from flat data structures.
663 - *
664 - * @param {Array} dataset linked data to be rearranged into a hierarchical tree based on relational fields.
665 - * @param {string} id the property which uniquely identifies each entry within the array.
666 - * @param {*} relation the property which identifies how the current item is related to other items in the data (if at all).
667 - * @return {Array} a nested array of parent/child relationships
668 - */
669 -
670 -function createDataTree(dataset) {
671 - let id = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
672 - let relation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'parent';
673 - const hashTable = Object.create(null);
674 - const dataTree = [];
675 -
676 - for (const data of dataset) {
677 - hashTable[data[id]] = { ...data,
678 - children: []
679 - };
680 - }
681 -
682 - for (const data of dataset) {
683 - if (data[relation]) {
684 - hashTable[data[relation]] = hashTable[data[relation]] || {};
685 - hashTable[data[relation]].children = hashTable[data[relation]].children || [];
686 - hashTable[data[relation]].children.push(hashTable[data[id]]);
687 - } else {
688 - dataTree.push(hashTable[data[id]]);
689 - }
690 - }
691 -
692 - return dataTree;
693 -}
694 -//# sourceMappingURL=transform.js.map
695 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/resolvers.js
696 -/**
697 - * WordPress dependencies
698 - */
699 -
700 -
701 -/**
702 - * Internal dependencies
703 - */
704 -
705 -
706 -
707 -
708 -/**
709 - * Creates a "stub" navigation post reflecting the contents of menu with id=menuId. The
710 - * post is meant as a convenient to only exists in runtime and should never be saved. It
711 - * enables a convenient way of editing the navigation by using a regular post editor.
712 - *
713 - * Fetches all menu items, converts them into blocks, and hydrates a new post with them.
714 - *
715 - * @param {number} menuId The id of menu to create a post from
716 - * @return {void}
717 - */
718 -
719 -const getNavigationPostForMenu = menuId => async _ref => {
720 - let {
721 - registry,
722 - dispatch
723 - } = _ref;
724 -
725 - if (!menuId) {
726 - return;
727 - }
728 -
729 - const stubPost = createStubPost(menuId); // Persist an empty post to warm up the state
730 -
731 - dispatch(persistPost(stubPost)); // Dispatch startResolution to skip the execution of the real getEntityRecord resolver - it would
732 - // issue an http request and fail.
733 -
734 - const args = [NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, stubPost.id];
735 - registry.dispatch(external_wp_coreData_namespaceObject.store).startResolution('getEntityRecord', args); // Now let's create a proper one hydrated using actual menu items
736 -
737 - const menuItems = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getMenuItems(menuItemsQuery(menuId));
738 - const navigationBlock = createNavigationBlock(menuItems); // Persist the actual post containing the navigation block
739 -
740 - const builtPost = createStubPost(menuId, navigationBlock);
741 - dispatch(persistPost(builtPost)); // Dispatch finishResolution to conclude startResolution dispatched earlier
742 -
743 - registry.dispatch(external_wp_coreData_namespaceObject.store).finishResolution('getEntityRecord', args);
744 -};
745 -
746 -const createStubPost = function (menuId) {
747 - let navigationBlock = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
748 - const id = buildNavigationPostId(menuId);
749 - return {
750 - id,
751 - slug: id,
752 - status: 'draft',
753 - type: 'page',
754 - blocks: navigationBlock ? [navigationBlock] : [],
755 - meta: {
756 - menuId
757 - }
758 - };
759 -};
760 -
761 -const persistPost = post => _ref2 => {
762 - let {
763 - registry
764 - } = _ref2;
765 - registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, post, {
766 - id: post.id
767 - }, false);
768 -};
769 -/**
770 - * Converts an adjacency list of menuItems into a navigation block.
771 - *
772 - * @param {Array} menuItems a list of menu items
773 - * @return {Object} Navigation block
774 - */
775 -
776 -
777 -function createNavigationBlock(menuItems) {
778 - const innerBlocks = menuItemsToBlocks(menuItems);
779 - return (0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', {
780 - orientation: 'vertical'
781 - }, innerBlocks);
782 -}
783 -//# sourceMappingURL=resolvers.js.map
784 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/selectors.js
785 -/**
786 - * WordPress dependencies
787 - */
788 -
789 -
790 -/**
791 - * Internal dependencies
792 - */
793 -
794 -
795 -
796 -/**
797 - * Returns the selected menu ID.
798 - *
799 - * @param {Object} state Global application state.
800 - * @return {number} The selected menu ID.
801 - */
802 -
803 -function getSelectedMenuId(state) {
804 - var _state$selectedMenuId;
805 -
806 - return (_state$selectedMenuId = state.selectedMenuId) !== null && _state$selectedMenuId !== void 0 ? _state$selectedMenuId : null;
807 -}
808 -/**
809 - * Returns a "stub" navigation post reflecting the contents of menu with id=menuId. The
810 - * post is meant as a convenient to only exists in runtime and should never be saved. It
811 - * enables a convenient way of editing the navigation by using a regular post editor.
812 - *
813 - * Related resolver fetches all menu items, converts them into blocks, and hydrates a new post with them.
814 - *
815 - * @param {number} menuId The id of menu to create a post from.
816 - * @return {null|Object} Post once the resolver fetches it, otherwise null
817 - */
818 -
819 -const selectors_getNavigationPostForMenu = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, menuId) => {
820 - // When the record is unavailable, calling getEditedEntityRecord triggers a http
821 - // request via it's related resolver. Let's return nothing until getNavigationPostForMenu
822 - // resolver marks the record as resolved.
823 - if (!hasResolvedNavigationPost(state, menuId)) {
824 - return null;
825 - }
826 -
827 - return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, buildNavigationPostId(menuId));
828 -});
829 -/**
830 - * Returns true if the navigation post related to menuId was already resolved.
831 - *
832 - * @param {number} menuId The id of menu.
833 - * @return {boolean} True if the navigation post related to menuId was already resolved, false otherwise.
834 - */
835 -
836 -const hasResolvedNavigationPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, menuId) => {
837 - return select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEntityRecord', [NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, buildNavigationPostId(menuId)]);
838 -});
839 -/**
840 - * Returns true if the inserter is opened.
841 - *
842 - * @param {Object} state Global application state.
843 - * @return {boolean} Whether the inserter is opened.
844 - */
845 -
846 -function isInserterOpened() {
847 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
848 - return !!(state !== null && state !== void 0 && state.blockInserterPanel);
849 -}
850 -//# sourceMappingURL=selectors.js.map
851 -;// CONCATENATED MODULE: external ["wp","notices"]
852 -var external_wp_notices_namespaceObject = window["wp"]["notices"];
853 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/constants.js
854 -/**
855 - * Module Constants
856 - */
857 -const STORE_NAME = 'core/edit-navigation';
858 -//# sourceMappingURL=constants.js.map
859 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/actions.js
860 -/**
861 - * External dependencies
862 - */
863 -
864 -/**
865 - * WordPress dependencies
866 - */
867 -
868 -
869 -
870 -
871 -/**
872 - * Internal dependencies
873 - */
874 -
875 -
876 -
877 -
878 -
879 -/**
880 - * Returns an action object used to select menu.
881 - *
882 - * @param {number} menuId The menu ID.
883 - * @return {Object} Action object.
884 - */
885 -
886 -function setSelectedMenuId(menuId) {
887 - return {
888 - type: 'SET_SELECTED_MENU_ID',
889 - menuId
890 - };
891 -}
892 -/**
893 - * Converts all the blocks into menu items and submits a batch request to save everything at once.
894 - *
895 - * @param {Object} post A navigation post to process
896 - * @return {Function} An action creator
897 - */
898 -
899 -const saveNavigationPost = post => async _ref => {
900 - let {
901 - registry,
902 - dispatch
903 - } = _ref;
904 - const lock = await registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableAcquireStoreLock(STORE_NAME, ['savingMenu'], {
905 - exclusive: true
906 - });
907 -
908 - try {
909 - const menuId = post.meta.menuId; // Save menu
910 -
911 - await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord('root', 'menu', menuId);
912 - const error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('root', 'menu', menuId);
913 -
914 - if (error) {
915 - throw new Error(error.message);
916 - } // Save menu items
917 -
918 -
919 - const updatedBlocks = await dispatch(batchSaveMenuItems(post.blocks[0], menuId)); // Clear "stub" navigation post edits to avoid a false "dirty" state.
920 -
921 - registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, post, undefined);
922 - const updatedPost = { ...post,
923 - blocks: [updatedBlocks]
924 - };
925 - registry.dispatch(external_wp_coreData_namespaceObject.store).receiveEntityRecords(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, updatedPost, undefined);
926 - registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Navigation saved.'), {
927 - type: 'snackbar'
928 - });
929 - } catch (saveError) {
930 - const errorMessage = saveError ? (0,external_wp_i18n_namespaceObject.sprintf)(
931 - /* translators: %s: The text of an error message (potentially untranslated). */
932 - (0,external_wp_i18n_namespaceObject.__)("Unable to save: '%s'"), saveError.message) : (0,external_wp_i18n_namespaceObject.__)('Unable to save: An error ocurred.');
933 - registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
934 - type: 'snackbar'
935 - });
936 - } finally {
937 - registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableReleaseStoreLock(lock);
938 - }
939 -};
940 -/**
941 - * Executes appropriate insert, update, and delete operations to turn the current
942 - * menu (with id=menuId) into one represented by the passed navigation block.
943 - *
944 - * @param {Object} navigationBlock The navigation block representing the desired state of the menu.
945 - * @param {number} menuId Menu Id to process.
946 - * @return {Function} An action creator
947 - */
948 -
949 -const batchSaveMenuItems = (navigationBlock, menuId) => async _ref2 => {
950 - let {
951 - dispatch,
952 - registry
953 - } = _ref2;
954 - // Make sure all the existing menu items are available before proceeding
955 - const oldMenuItems = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getMenuItems({
956 - menus: menuId,
957 - per_page: -1
958 - }); // Insert placeholders for new menu items to have an ID to work with.
959 - // We need that in case these new items have any children. If so,
960 - // we need to provide a parent id that we don't have yet.
961 -
962 - const navBlockWithRecordIds = await dispatch(batchInsertPlaceholderMenuItems(navigationBlock)); // Update menu items. This is separate from deleting, because there
963 - // are no consistency guarantees and we don't want to delete something
964 - // that was a parent node before another node takes it place.
965 -
966 - const navBlockAfterUpdates = await dispatch(batchUpdateMenuItems(navBlockWithRecordIds, menuId)); // Delete menu items
967 -
968 - const deletedIds = (0,external_lodash_namespaceObject.difference)(oldMenuItems.map(_ref3 => {
969 - let {
970 - id
971 - } = _ref3;
972 - return id;
973 - }), blocksTreeToList(navBlockAfterUpdates).map(getRecordIdFromBlock));
974 - await dispatch(batchDeleteMenuItems(deletedIds));
975 - return navBlockAfterUpdates;
976 -};
977 -/**
978 - * Creates a menu item for every block that doesn't have an associated menuItem.
979 - * Sends a batch request with one POST /wp/v2/menu-items for every created menu item.
980 - *
981 - * @param {Object} navigationBlock A navigation block to find created menu items in.
982 - * @return {Function} An action creator
983 - */
984 -
985 -
986 -const batchInsertPlaceholderMenuItems = navigationBlock => async _ref4 => {
987 - let {
988 - registry
989 - } = _ref4;
990 - const blocksWithoutRecordId = blocksTreeToList(navigationBlock).filter(block => isBlockSupportedInNav(block) && !getRecordIdFromBlock(block));
991 - const tasks = blocksWithoutRecordId.map(() => _ref5 => {
992 - let {
993 - saveEntityRecord
994 - } = _ref5;
995 - return saveEntityRecord('root', 'menuItem', {
996 - title: (0,external_wp_i18n_namespaceObject.__)('Menu item'),
997 - url: '#placeholder',
998 - menu_order: 1
999 - });
1000 - });
1001 - const results = await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(tasks); // Return an updated navigation block with all the IDs in
1002 -
1003 - const blockToResult = new Map((0,external_lodash_namespaceObject.zip)(blocksWithoutRecordId, results));
1004 - return mapBlocksTree(navigationBlock, block => {
1005 - if (!blockToResult.has(block)) {
1006 - return block;
1007 - }
1008 -
1009 - return addRecordIdToBlock(block, blockToResult.get(block).id);
1010 - });
1011 -};
1012 -/**
1013 - * Updates every menu item where a related block has changed.
1014 - * Sends a batch request with one PUT /wp/v2/menu-items for every updated menu item.
1015 - *
1016 - * @param {Object} navigationBlock A navigation block to find updated menu items in.
1017 - * @param {number} menuId Menu ID.
1018 - * @return {Function} An action creator
1019 - */
1020 -
1021 -
1022 -const batchUpdateMenuItems = (navigationBlock, menuId) => async _ref6 => {
1023 - let {
1024 - registry
1025 - } = _ref6;
1026 - const allMenuItems = blocksTreeToAnnotatedList(navigationBlock);
1027 - const unsupportedMenuItems = allMenuItems.filter(_ref7 => {
1028 - let {
1029 - block
1030 - } = _ref7;
1031 - return !isBlockSupportedInNav(block);
1032 - }).map(_ref8 => {
1033 - let {
1034 - block
1035 - } = _ref8;
1036 - return block.name;
1037 - });
1038 -
1039 - if (unsupportedMenuItems.length) {
1040 - window.console.warn((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: Name of block (i.e. core/legacy-widget)
1041 - (0,external_wp_i18n_namespaceObject.__)('The following blocks haven\'t been saved because they are not supported: "%s".'), unsupportedMenuItems.join('", "')));
1042 - }
1043 -
1044 - const updatedMenuItems = allMenuItems // Filter out unsupported blocks
1045 - .filter(_ref9 => {
1046 - let {
1047 - block
1048 - } = _ref9;
1049 - return isBlockSupportedInNav(block);
1050 - }) // Transform the blocks into menu items
1051 - .map(_ref10 => {
1052 - let {
1053 - block,
1054 - parentBlock,
1055 - childIndex
1056 - } = _ref10;
1057 - return blockToMenuItem(block, registry.select(external_wp_coreData_namespaceObject.store).getMenuItem(getRecordIdFromBlock(block)), getRecordIdFromBlock(parentBlock), childIndex, menuId);
1058 - }) // Filter out menu items without any edits
1059 - .filter(menuItem => {
1060 - // Update an existing entity record.
1061 - registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('root', 'menuItem', menuItem.id, menuItem, {
1062 - undoIgnore: true
1063 - });
1064 - return registry.select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('root', 'menuItem', menuItem.id);
1065 - }); // Map the edited menu items to batch tasks
1066 -
1067 - const tasks = updatedMenuItems.map(menuItem => _ref11 => {
1068 - let {
1069 - saveEditedEntityRecord
1070 - } = _ref11;
1071 - return saveEditedEntityRecord('root', 'menuItem', menuItem.id);
1072 - });
1073 - await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(tasks); // Throw on failure. @TODO failures should be thrown in core-data
1074 -
1075 - updatedMenuItems.forEach(menuItem => {
1076 - const failure = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('root', 'menuItem', menuItem.id);
1077 -
1078 - if (failure) {
1079 - throw new Error(failure.message);
1080 - }
1081 - }); // Return an updated navigation block reflecting the changes persisted in the batch update.
1082 -
1083 - return mapBlocksTree(navigationBlock, block => {
1084 - if (!isBlockSupportedInNav(block)) {
1085 - return block;
1086 - }
1087 -
1088 - const updatedMenuItem = registry.select(external_wp_coreData_namespaceObject.store).getMenuItem(getRecordIdFromBlock(block));
1089 - return addRecordIdToBlock({ ...block,
1090 - attributes: menuItemToBlockAttributes(updatedMenuItem)
1091 - }, updatedMenuItem.id);
1092 - });
1093 -};
1094 -/**
1095 - * Deletes multiple menu items.
1096 - * Sends a batch request with one DELETE /wp/v2/menu-items for every deleted menu item.
1097 - *
1098 - * @param {Object} deletedIds A list of menu item ids to delete
1099 - * @return {Function} An action creator
1100 - */
1101 -
1102 -
1103 -const batchDeleteMenuItems = deletedIds => async _ref12 => {
1104 - let {
1105 - registry
1106 - } = _ref12;
1107 - const deleteBatch = deletedIds.map(id => async _ref13 => {
1108 - let {
1109 - deleteEntityRecord
1110 - } = _ref13;
1111 - const success = await deleteEntityRecord('root', 'menuItem', id, {
1112 - force: true
1113 - }); // @TODO failures should be thrown in core-data
1114 -
1115 - if (!success) {
1116 - throw new Error(id);
1117 - }
1118 -
1119 - return success;
1120 - });
1121 - return await registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalBatch(deleteBatch);
1122 -};
1123 -/**
1124 - * Turns a recursive list of blocks into a flat list of blocks annotated with
1125 - * their child index and parent block.
1126 - *
1127 - * @param {Object} parentBlock A parent block to flatten
1128 - * @return {Object} A flat list of blocks, annotated by their index and parent ID, consisting
1129 - * of all the input blocks and all the inner blocks in the tree.
1130 - */
1131 -
1132 -
1133 -function blocksTreeToAnnotatedList(parentBlock) {
1134 - return (parentBlock.innerBlocks || []).flatMap((innerBlock, index) => [{
1135 - block: innerBlock,
1136 - parentBlock,
1137 - childIndex: index
1138 - }].concat(blocksTreeToAnnotatedList(innerBlock)));
1139 -}
1140 -
1141 -function blocksTreeToList(parentBlock) {
1142 - return blocksTreeToAnnotatedList(parentBlock).map(_ref14 => {
1143 - let {
1144 - block
1145 - } = _ref14;
1146 - return block;
1147 - });
1148 -}
1149 -/**
1150 - * Maps one tree of blocks into another tree by invoking a callback on every node.
1151 - *
1152 - * @param {Object} block The root of the mapped tree.
1153 - * @param {Function} callback The callback to invoke.
1154 - * @param {Object} parentBlock Internal. The current parent block.
1155 - * @param {number} idx Internal. The current child index.
1156 - * @return {Object} A mapped tree.
1157 - */
1158 -
1159 -
1160 -function mapBlocksTree(block, callback) {
1161 - let parentBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1162 - let idx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1163 - return { ...callback(block, parentBlock, idx),
1164 - innerBlocks: (block.innerBlocks || []).map((innerBlock, index) => mapBlocksTree(innerBlock, callback, block, index))
1165 - };
1166 -}
1167 -/**
1168 - * Returns an action object used to open/close the inserter.
1169 - *
1170 - * @param {boolean|Object} value Whether the inserter should be
1171 - * opened (true) or closed (false).
1172 - * To specify an insertion point,
1173 - * use an object.
1174 - * @param {string} value.rootClientId The root client ID to insert at.
1175 - * @param {number} value.insertionIndex The index to insert at.
1176 - *
1177 - * @return {Object} Action object.
1178 - */
1179 -
1180 -
1181 -function setIsInserterOpened(value) {
1182 - return {
1183 - type: 'SET_IS_INSERTER_OPENED',
1184 - value
1185 - };
1186 -}
1187 -//# sourceMappingURL=actions.js.map
1188 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/store/index.js
1189 -/**
1190 - * WordPress dependencies
1191 - */
1192 -
1193 -/**
1194 - * Internal dependencies
1195 - */
1196 -
1197 -
1198 -
1199 -
1200 -
1201 -
1202 -/**
1203 - * Block editor data store configuration.
1204 - *
1205 - * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
1206 - *
1207 - * @type {Object}
1208 - */
1209 -
1210 -const storeConfig = {
1211 - reducer: reducer,
1212 - selectors: selectors_namespaceObject,
1213 - resolvers: resolvers_namespaceObject,
1214 - actions: actions_namespaceObject,
1215 - persist: ['selectedMenuId'],
1216 - __experimentalUseThunks: true
1217 -};
1218 -/**
1219 - * Store definition for the edit navigation namespace.
1220 - *
1221 - * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
1222 - *
1223 - * @type {Object}
1224 - */
1225 -
1226 -const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig); // Once we build a more generic persistence plugin that works across types of stores
1227 -// we'd be able to replace this with a register call.
1228 -
1229 -(0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, storeConfig);
1230 -//# sourceMappingURL=index.js.map
1231 -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
1232 -function _extends() {
1233 - _extends = Object.assign || function (target) {
1234 - for (var i = 1; i < arguments.length; i++) {
1235 - var source = arguments[i];
1236 -
1237 - for (var key in source) {
1238 - if (Object.prototype.hasOwnProperty.call(source, key)) {
1239 - target[key] = source[key];
1240 - }
1241 - }
1242 - }
1243 -
1244 - return target;
1245 - };
1246 -
1247 - return _extends.apply(this, arguments);
1248 -}
1249 -;// CONCATENATED MODULE: external ["wp","hooks"]
1250 -var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
1251 -;// CONCATENATED MODULE: external ["wp","compose"]
1252 -var external_wp_compose_namespaceObject = window["wp"]["compose"];
1253 -;// CONCATENATED MODULE: external ["wp","blockEditor"]
1254 -var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1255 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-navigation-editor-custom-appender.js
1256 -
1257 -
1258 -
1259 -/**
1260 - * WordPress dependencies
1261 - */
1262 -
1263 -
1264 -
1265 -
1266 -
1267 -function CustomAppender() {
1268 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.InnerBlocks.ButtonBlockAppender, {
1269 - isToggle: true
1270 - });
1271 -}
1272 -
1273 -function EnhancedNavigationBlock(_ref) {
1274 - let {
1275 - blockEdit: BlockEdit,
1276 - ...props
1277 - } = _ref;
1278 - const clientId = props.clientId;
1279 - const {
1280 - noBlockSelected,
1281 - isSelected,
1282 - isImmediateParentOfSelectedBlock,
1283 - selectedBlockHasDescendants
1284 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1285 - var _getClientIdsOfDescen;
1286 -
1287 - const {
1288 - getClientIdsOfDescendants,
1289 - hasSelectedInnerBlock,
1290 - getSelectedBlockClientId
1291 - } = select(external_wp_blockEditor_namespaceObject.store);
1292 -
1293 - const _isImmediateParentOfSelectedBlock = hasSelectedInnerBlock(clientId, false);
1294 -
1295 - const selectedBlockId = getSelectedBlockClientId();
1296 -
1297 - const _selectedBlockHasDescendants = !!((_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockId])) !== null && _getClientIdsOfDescen !== void 0 && _getClientIdsOfDescen.length);
1298 -
1299 - return {
1300 - isSelected: selectedBlockId === clientId,
1301 - noBlockSelected: !selectedBlockId,
1302 - isImmediateParentOfSelectedBlock: _isImmediateParentOfSelectedBlock,
1303 - selectedBlockHasDescendants: _selectedBlockHasDescendants
1304 - };
1305 - }, [clientId]);
1306 - const customAppender = noBlockSelected || isSelected || isImmediateParentOfSelectedBlock && !selectedBlockHasDescendants ? CustomAppender : false;
1307 - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
1308 - customAppender: customAppender
1309 - }));
1310 -}
1311 -
1312 -const addNavigationEditorCustomAppender = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
1313 - if (props.name !== 'core/navigation') {
1314 - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
1315 - } // Use a separate component so that `useSelect` only run on the navigation block.
1316 -
1317 -
1318 - return (0,external_wp_element_namespaceObject.createElement)(EnhancedNavigationBlock, _extends({
1319 - blockEdit: BlockEdit
1320 - }, props));
1321 -}, 'withNavigationEditorCustomAppender');
1322 -/* harmony default export */ var add_navigation_editor_custom_appender = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-navigation-editor-custom-appender', addNavigationEditorCustomAppender));
1323 -//# sourceMappingURL=add-navigation-editor-custom-appender.js.map
1324 -;// CONCATENATED MODULE: external ["wp","components"]
1325 -var external_wp_components_namespaceObject = window["wp"]["components"];
1326 -;// CONCATENATED MODULE: external ["wp","primitives"]
1327 -var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
1328 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-down.js
1329 -
1330 -
1331 -/**
1332 - * WordPress dependencies
1333 - */
1334 -
1335 -const chevronDown = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1336 - viewBox: "0 0 24 24",
1337 - xmlns: "http://www.w3.org/2000/svg"
1338 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1339 - d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
1340 -}));
1341 -/* harmony default export */ var chevron_down = (chevronDown);
1342 -//# sourceMappingURL=chevron-down.js.map
1343 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-entity.js
1344 -/**
1345 - * WordPress dependencies
1346 - */
1347 -
1348 -
1349 -/**
1350 - * Internal dependencies
1351 - */
1352 -
1353 -
1354 -function useMenuEntity(menuId) {
1355 - const {
1356 - editEntityRecord
1357 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
1358 - const menuEntityData = [MENU_KIND, MENU_POST_TYPE, menuId];
1359 - const {
1360 - editedMenu,
1361 - hasLoadedEditedMenu
1362 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1363 - return {
1364 - editedMenu: menuId && select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(...menuEntityData),
1365 - hasLoadedEditedMenu: select(external_wp_coreData_namespaceObject.store).hasFinishedResolution('getEditedEntityRecord', [...menuEntityData])
1366 - };
1367 - }, [menuId]);
1368 - return {
1369 - editedMenu,
1370 - menuEntityData,
1371 - editMenuEntityRecord: editEntityRecord,
1372 - hasLoadedEditedMenu
1373 - };
1374 -}
1375 -//# sourceMappingURL=use-menu-entity.js.map
1376 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-entity-prop.js
1377 -/**
1378 - * WordPress dependencies
1379 - */
1380 -
1381 -/**
1382 - * Internal dependencies
1383 - */
1384 -
1385 -
1386 -/**
1387 - * Returns the value and setter for the specified
1388 - * property of the menu.
1389 - *
1390 - * @param {string} prop A Property name.
1391 - * @param {string} menuId A menu ID.
1392 - *
1393 - * @return {[*, Function]} A tuple where the first item is the
1394 - * property value and the second is the
1395 - * setter.
1396 - */
1397 -
1398 -function useMenuEntityProp(prop, menuId) {
1399 - return (0,external_wp_coreData_namespaceObject.useEntityProp)(MENU_KIND, MENU_POST_TYPE, prop, menuId);
1400 -}
1401 -//# sourceMappingURL=use-menu-entity-prop.js.map
1402 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-navigation-editor.js
1403 -/**
1404 - * WordPress dependencies
1405 - */
1406 -
1407 -
1408 -
1409 -
1410 -
1411 -/**
1412 - * Internal dependencies
1413 - */
1414 -
1415 -
1416 -
1417 -
1418 -
1419 -const getMenusData = select => {
1420 - const selectors = select('core');
1421 - const params = {
1422 - per_page: -1
1423 - };
1424 - return {
1425 - menus: selectors.getMenus(params),
1426 - hasLoadedMenus: selectors.hasFinishedResolution('getMenus', [params])
1427 - };
1428 -};
1429 -
1430 -function useNavigationEditor() {
1431 - var _menus$find;
1432 -
1433 - const {
1434 - deleteMenu: _deleteMenu
1435 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
1436 - const [selectedMenuId, setSelectedMenuId] = useSelectedMenuId();
1437 - const [hasFinishedInitialLoad, setHasFinishedInitialLoad] = (0,external_wp_element_namespaceObject.useState)(false);
1438 - const {
1439 - editedMenu,
1440 - hasLoadedEditedMenu
1441 - } = useMenuEntity(selectedMenuId);
1442 - const {
1443 - menus,
1444 - hasLoadedMenus
1445 - } = (0,external_wp_data_namespaceObject.useSelect)(getMenusData, []);
1446 - /**
1447 - * If the Menu being edited has been requested from API and it has
1448 - * no values then it has been deleted so reset the selected menu ID.
1449 - */
1450 -
1451 - (0,external_wp_element_namespaceObject.useEffect)(() => {
1452 - var _Object$keys;
1453 -
1454 - if (hasLoadedEditedMenu && !((_Object$keys = Object.keys(editedMenu)) !== null && _Object$keys !== void 0 && _Object$keys.length)) {
1455 - setSelectedMenuId(null);
1456 - }
1457 - }, [hasLoadedEditedMenu, editedMenu]);
1458 - const {
1459 - createErrorNotice,
1460 - createInfoNotice
1461 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
1462 - const isMenuBeingDeleted = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).isDeletingEntityRecord('root', 'menu', selectedMenuId), [selectedMenuId]);
1463 - const selectedMenuName = (menus === null || menus === void 0 ? void 0 : (_menus$find = menus.find(_ref => {
1464 - let {
1465 - id
1466 - } = _ref;
1467 - return id === selectedMenuId;
1468 - })) === null || _menus$find === void 0 ? void 0 : _menus$find.name) || '';
1469 - (0,external_wp_element_namespaceObject.useEffect)(() => {
1470 - if (hasLoadedMenus) {
1471 - setHasFinishedInitialLoad(true);
1472 - }
1473 - }, [hasLoadedMenus]);
1474 - const navigationPost = (0,external_wp_data_namespaceObject.useSelect)(select => {
1475 - if (!selectedMenuId) {
1476 - return;
1477 - }
1478 -
1479 - return select(store).getNavigationPostForMenu(selectedMenuId);
1480 - }, [selectedMenuId]);
1481 -
1482 - const deleteMenu = async () => {
1483 - const didDeleteMenu = await _deleteMenu(selectedMenuId, {
1484 - force: true
1485 - });
1486 -
1487 - if (didDeleteMenu) {
1488 - setSelectedMenuId(null);
1489 - createInfoNotice((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of a menu.
1490 - (0,external_wp_i18n_namespaceObject.__)('"%s" menu has been deleted'), selectedMenuName), {
1491 - type: 'snackbar',
1492 - isDismissible: true
1493 - });
1494 - } else {
1495 - createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Menu deletion unsuccessful'));
1496 - }
1497 - };
1498 -
1499 - return {
1500 - menus,
1501 - hasLoadedMenus,
1502 - hasFinishedInitialLoad,
1503 - selectedMenuId,
1504 - navigationPost,
1505 - isMenuBeingDeleted,
1506 - selectMenu: setSelectedMenuId,
1507 - deleteMenu,
1508 - isMenuSelected: !!selectedMenuId
1509 - };
1510 -}
1511 -//# sourceMappingURL=use-navigation-editor.js.map
1512 -;// CONCATENATED MODULE: external ["wp","dom"]
1513 -var external_wp_dom_namespaceObject = window["wp"]["dom"];
1514 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-notifications.js
1515 -/**
1516 - * WordPress dependencies
1517 - */
1518 -
1519 -
1520 -
1521 -
1522 -
1523 -/**
1524 - * Internal dependencies
1525 - */
1526 -
1527 -
1528 -function useMenuNotifications(menuId) {
1529 - const {
1530 - createErrorNotice
1531 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
1532 - const lastDeleteError = (0,external_wp_data_namespaceObject.useSelect)(select => {
1533 - return select(external_wp_coreData_namespaceObject.store).getLastEntityDeleteError(MENU_KIND, MENU_POST_TYPE, menuId);
1534 - }, [menuId]);
1535 - (0,external_wp_element_namespaceObject.useEffect)(() => {
1536 - if (lastDeleteError) {
1537 - createErrorNotice((0,external_wp_dom_namespaceObject.__unstableStripHTML)(lastDeleteError === null || lastDeleteError === void 0 ? void 0 : lastDeleteError.message), {
1538 - id: 'edit-navigation-error'
1539 - });
1540 - }
1541 - }, [lastDeleteError]);
1542 -}
1543 -//# sourceMappingURL=use-menu-notifications.js.map
1544 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-selected-menu-id.js
1545 -/**
1546 - * WordPress dependencies
1547 - */
1548 -
1549 -/**
1550 - * Internal dependencies
1551 - */
1552 -
1553 -
1554 -/**
1555 - * Returns selected menu ID and the setter.
1556 - *
1557 - * @return {[number, Function]} A tuple where first item is the
1558 - * selected menu ID and second is
1559 - * the setter.
1560 - */
1561 -
1562 -function useSelectedMenuId() {
1563 - const selectedMenuId = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getSelectedMenuId(), []);
1564 - const {
1565 - setSelectedMenuId
1566 - } = (0,external_wp_data_namespaceObject.useDispatch)(store);
1567 - return [selectedMenuId, setSelectedMenuId];
1568 -}
1569 -//# sourceMappingURL=use-selected-menu-id.js.map
1570 -;// CONCATENATED MODULE: external ["wp","apiFetch"]
1571 -var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
1572 -var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
1573 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-menu-locations.js
1574 -/**
1575 - * WordPress dependencies
1576 - */
1577 -
1578 -
1579 -/**
1580 - * External dependencies
1581 - */
1582 -
1583 -
1584 -/**
1585 - * Internal dependencies
1586 - */
1587 -
1588 -
1589 -
1590 -const locationsForMenuId = (menuLocationsByName, id) => Object.values(menuLocationsByName).filter(_ref => {
1591 - let {
1592 - menu
1593 - } = _ref;
1594 - return menu === id;
1595 -}).map(_ref2 => {
1596 - let {
1597 - name
1598 - } = _ref2;
1599 - return name;
1600 -});
1601 -
1602 -function useMenuLocations() {
1603 - const [menuLocationsByName, setMenuLocationsByName] = (0,external_wp_element_namespaceObject.useState)(null);
1604 - const [menuId] = useSelectedMenuId();
1605 - const {
1606 - editMenuEntityRecord,
1607 - menuEntityData
1608 - } = useMenuEntity(menuId);
1609 - (0,external_wp_element_namespaceObject.useEffect)(() => {
1610 - let isMounted = true;
1611 -
1612 - const fetchMenuLocationsByName = async () => {
1613 - const newMenuLocationsByName = await external_wp_apiFetch_default()({
1614 - method: 'GET',
1615 - path: '/wp/v2/menu-locations'
1616 - });
1617 -
1618 - if (isMounted) {
1619 - setMenuLocationsByName(newMenuLocationsByName);
1620 - }
1621 - };
1622 -
1623 - fetchMenuLocationsByName();
1624 - return () => isMounted = false;
1625 - }, []);
1626 - const assignMenuToLocation = (0,external_wp_element_namespaceObject.useCallback)(async (locationName, newMenuId) => {
1627 - const oldMenuId = menuLocationsByName[locationName].menu;
1628 - const newMenuLocationsByName = (0,external_lodash_namespaceObject.merge)(menuLocationsByName, {
1629 - [locationName]: {
1630 - menu: newMenuId
1631 - }
1632 - });
1633 - setMenuLocationsByName(newMenuLocationsByName);
1634 - const activeMenuId = newMenuId || oldMenuId;
1635 - editMenuEntityRecord(...menuEntityData, {
1636 - locations: locationsForMenuId(newMenuLocationsByName, activeMenuId)
1637 - });
1638 - }, [menuLocationsByName]);
1639 -
1640 - const toggleMenuLocationAssignment = (locationName, newMenuId) => {
1641 - const idToSet = menuLocationsByName[locationName].menu === newMenuId ? 0 : newMenuId;
1642 - assignMenuToLocation(locationName, idToSet);
1643 - };
1644 -
1645 - const menuLocations = (0,external_wp_element_namespaceObject.useMemo)(() => Object.values(menuLocationsByName || {}), [menuLocationsByName]);
1646 - return {
1647 - menuLocations,
1648 - assignMenuToLocation,
1649 - toggleMenuLocationAssignment
1650 - };
1651 -}
1652 -//# sourceMappingURL=use-menu-locations.js.map
1653 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/use-navigation-editor-root-block.js
1654 -/**
1655 - * WordPress dependencies
1656 - */
1657 -
1658 -
1659 -/**
1660 - * Internal dependencies
1661 - */
1662 -
1663 -const useNavigationEditorRootBlock = () => {
1664 - return (0,external_wp_data_namespaceObject.useSelect)(select => {
1665 - const {
1666 - getBlockOrder
1667 - } = select(external_wp_blockEditor_namespaceObject.store);
1668 - const lockedNavigationBlock = getBlockOrder()[0];
1669 - return {
1670 - navBlockClientId: lockedNavigationBlock,
1671 - lastNavBlockItemIndex: getBlockOrder(lockedNavigationBlock).length
1672 - };
1673 - }, []);
1674 -};
1675 -
1676 -/* harmony default export */ var use_navigation_editor_root_block = (useNavigationEditorRootBlock);
1677 -//# sourceMappingURL=use-navigation-editor-root-block.js.map
1678 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/hooks/index.js
1679 -/**
1680 - * WordPress dependencies
1681 - */
1682 -
1683 -
1684 -const untitledMenu = (0,external_wp_i18n_namespaceObject.__)('(untitled menu)');
1685 -const IsMenuNameControlFocusedContext = (0,external_wp_element_namespaceObject.createContext)();
1686 -
1687 -
1688 -
1689 -
1690 -
1691 -
1692 -
1693 -//# sourceMappingURL=index.js.map
1694 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/block-placeholder/use-navigation-entities.js
1695 -/**
1696 - * WordPress dependencies
1697 - */
1698 -
1699 -
1700 -/**
1701 - * @typedef {Object} NavigationEntitiesData
1702 - * @property {Array|undefined} pages - a collection of WP Post entity objects of post type "Page".
1703 - * @property {boolean} isResolvingPages - indicates whether the request to fetch pages is currently resolving.
1704 - * @property {boolean} hasResolvedPages - indicates whether the request to fetch pages has finished resolving.
1705 - * @property {Array|undefined} menus - a collection of Menu entity objects.
1706 - * @property {boolean} isResolvingMenus - indicates whether the request to fetch menus is currently resolving.
1707 - * @property {boolean} hasResolvedMenus - indicates whether the request to fetch menus has finished resolving.
1708 - * @property {Array|undefined} menusItems - a collection of Menu Item entity objects for the current menuId.
1709 - * @property {boolean} hasResolvedMenuItems - indicates whether the request to fetch menuItems has finished resolving.
1710 - * @property {boolean} hasPages - indicates whether there is currently any data for pages.
1711 - * @property {boolean} hasMenus - indicates whether there is currently any data for menus.
1712 - */
1713 -
1714 -/**
1715 - * Manages fetching and resolution state for all entities required
1716 - * for the Navigation block.
1717 - *
1718 - * @param {number} menuId the menu for which to retrieve menuItem data.
1719 - * @return { NavigationEntitiesData } the entity data.
1720 - */
1721 -
1722 -function useNavigationEntities(menuId) {
1723 - return { ...usePageEntities(),
1724 - ...useMenuEntities(),
1725 - ...useMenuItemEntities(menuId)
1726 - };
1727 -}
1728 -
1729 -function useMenuEntities() {
1730 - const {
1731 - menus,
1732 - isResolvingMenus,
1733 - hasResolvedMenus
1734 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1735 - const {
1736 - getMenus,
1737 - isResolving,
1738 - hasFinishedResolution
1739 - } = select(external_wp_coreData_namespaceObject.store);
1740 - const menusParameters = [{
1741 - per_page: -1
1742 - }];
1743 - return {
1744 - menus: getMenus(...menusParameters),
1745 - isResolvingMenus: isResolving('getMenus', menusParameters),
1746 - hasResolvedMenus: hasFinishedResolution('getMenus', menusParameters)
1747 - };
1748 - }, []);
1749 - return {
1750 - menus,
1751 - isResolvingMenus,
1752 - hasResolvedMenus,
1753 - hasMenus: !!(hasResolvedMenus && menus !== null && menus !== void 0 && menus.length)
1754 - };
1755 -}
1756 -
1757 -function useMenuItemEntities(menuId) {
1758 - const {
1759 - menuItems,
1760 - hasResolvedMenuItems
1761 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1762 - const {
1763 - getMenuItems,
1764 - hasFinishedResolution
1765 - } = select(external_wp_coreData_namespaceObject.store);
1766 - const hasSelectedMenu = menuId !== undefined;
1767 - const menuItemsParameters = hasSelectedMenu ? [{
1768 - menus: menuId,
1769 - per_page: -1
1770 - }] : undefined;
1771 - return {
1772 - menuItems: hasSelectedMenu ? getMenuItems(...menuItemsParameters) : undefined,
1773 - hasResolvedMenuItems: hasSelectedMenu ? hasFinishedResolution('getMenuItems', menuItemsParameters) : false
1774 - };
1775 - }, [menuId]);
1776 - return {
1777 - menuItems,
1778 - hasResolvedMenuItems
1779 - };
1780 -}
1781 -
1782 -function usePageEntities() {
1783 - const {
1784 - pages,
1785 - isResolvingPages,
1786 - hasResolvedPages
1787 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
1788 - const {
1789 - getEntityRecords,
1790 - isResolving,
1791 - hasFinishedResolution
1792 - } = select(external_wp_coreData_namespaceObject.store);
1793 - const pagesParameters = ['postType', 'page', {
1794 - parent: 0,
1795 - order: 'asc',
1796 - orderby: 'id',
1797 - per_page: -1
1798 - }];
1799 - return {
1800 - pages: getEntityRecords(...pagesParameters) || null,
1801 - isResolvingPages: isResolving('getEntityRecords', pagesParameters),
1802 - hasResolvedPages: hasFinishedResolution('getEntityRecords', pagesParameters)
1803 - };
1804 - }, []);
1805 - return {
1806 - pages,
1807 - isResolvingPages,
1808 - hasResolvedPages,
1809 - hasPages: !!(hasResolvedPages && pages !== null && pages !== void 0 && pages.length)
1810 - };
1811 -}
1812 -//# sourceMappingURL=use-navigation-entities.js.map
1813 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/block-placeholder/index.js
1814 -
1815 -
1816 -/**
1817 - * WordPress dependencies
1818 - */
1819 -
1820 -
1821 -
1822 -
1823 -
1824 -/**
1825 - * Internal dependencies
1826 - */
1827 -
1828 -
1829 -
1830 -
1831 -/**
1832 - * Convert pages to blocks.
1833 - *
1834 - * @param {Object[]} pages An array of pages.
1835 - *
1836 - * @return {WPBlock[]} An array of blocks.
1837 - */
1838 -
1839 -function convertPagesToBlocks(pages) {
1840 - if (!(pages !== null && pages !== void 0 && pages.length)) {
1841 - return null;
1842 - }
1843 -
1844 - return pages.map(_ref => {
1845 - let {
1846 - title,
1847 - type,
1848 - link: url,
1849 - id
1850 - } = _ref;
1851 - return (0,external_wp_blocks_namespaceObject.createBlock)('core/navigation-link', {
1852 - type,
1853 - id,
1854 - url,
1855 - label: !title.rendered ? (0,external_wp_i18n_namespaceObject.__)('(no title)') : title.rendered,
1856 - opensInNewTab: false
1857 - });
1858 - });
1859 -}
1860 -
1861 -const TOGGLE_PROPS = {
1862 - variant: 'tertiary'
1863 -};
1864 -const POPOVER_PROPS = {
1865 - position: 'bottom center'
1866 -};
1867 -
1868 -function BlockPlaceholder(_ref2, ref) {
1869 - let {
1870 - onCreate
1871 - } = _ref2;
1872 - const [selectedMenu, setSelectedMenu] = (0,external_wp_element_namespaceObject.useState)();
1873 - const [isCreatingFromMenu, setIsCreatingFromMenu] = (0,external_wp_element_namespaceObject.useState)(false);
1874 - const [selectedMenuId] = useSelectedMenuId();
1875 - const [menuName] = useMenuEntityProp('name', selectedMenuId);
1876 - const {
1877 - isResolvingPages,
1878 - menus,
1879 - isResolvingMenus,
1880 - menuItems,
1881 - hasResolvedMenuItems,
1882 - pages,
1883 - hasPages,
1884 - hasMenus
1885 - } = useNavigationEntities(selectedMenu);
1886 - const isLoading = isResolvingPages || isResolvingMenus;
1887 - const createFromMenu = (0,external_wp_element_namespaceObject.useCallback)(() => {
1888 - const {
1889 - innerBlocks: blocks
1890 - } = menuItemsToBlocks(menuItems);
1891 - const selectNavigationBlock = true;
1892 - onCreate(blocks, selectNavigationBlock);
1893 - }, [menuItems, menuItemsToBlocks, onCreate]);
1894 -
1895 - const onCreateFromMenu = () => {
1896 - // If we have menu items, create the block right away.
1897 - if (hasResolvedMenuItems) {
1898 - createFromMenu();
1899 - return;
1900 - } // Otherwise, create the block when resolution finishes.
1901 -
1902 -
1903 - setIsCreatingFromMenu(true);
1904 - };
1905 -
1906 - const onCreateEmptyMenu = () => {
1907 - onCreate([]);
1908 - };
1909 -
1910 - const onCreateAllPages = () => {
1911 - const blocks = convertPagesToBlocks(pages);
1912 - const selectNavigationBlock = true;
1913 - onCreate(blocks, selectNavigationBlock);
1914 - };
1915 -
1916 - (0,external_wp_element_namespaceObject.useEffect)(() => {
1917 - // If the user selected a menu but we had to wait for menu items to
1918 - // finish resolving, then create the block once resolution finishes.
1919 - if (isCreatingFromMenu && hasResolvedMenuItems) {
1920 - createFromMenu();
1921 - setIsCreatingFromMenu(false);
1922 - }
1923 - }, [isCreatingFromMenu, hasResolvedMenuItems]);
1924 - const selectableMenus = menus === null || menus === void 0 ? void 0 : menus.filter(menu => menu.id !== selectedMenuId);
1925 - const hasSelectableMenus = !!(selectableMenus !== null && selectableMenus !== void 0 && selectableMenus.length);
1926 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Placeholder, {
1927 - className: "edit-navigation-block-placeholder",
1928 - label: menuName,
1929 - instructions: (0,external_wp_i18n_namespaceObject.__)('This menu is empty. You can start blank and choose what to add,' + ' add your existing pages, or add the content of another menu.')
1930 - }, (0,external_wp_element_namespaceObject.createElement)("div", {
1931 - className: "edit-navigation-block-placeholder__controls"
1932 - }, isLoading && (0,external_wp_element_namespaceObject.createElement)("div", {
1933 - ref: ref
1934 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), !isLoading && (0,external_wp_element_namespaceObject.createElement)("div", {
1935 - ref: ref,
1936 - className: "edit-navigation-block-placeholder__actions"
1937 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1938 - variant: "tertiary",
1939 - onClick: onCreateEmptyMenu
1940 - }, (0,external_wp_i18n_namespaceObject.__)('Start blank')), hasPages ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1941 - variant: hasMenus ? 'tertiary' : 'primary',
1942 - onClick: onCreateAllPages
1943 - }, (0,external_wp_i18n_namespaceObject.__)('Add all pages')) : undefined, hasSelectableMenus ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
1944 - text: (0,external_wp_i18n_namespaceObject.__)('Copy existing menu'),
1945 - icon: chevron_down,
1946 - toggleProps: TOGGLE_PROPS,
1947 - popoverProps: POPOVER_PROPS
1948 - }, _ref3 => {
1949 - let {
1950 - onClose
1951 - } = _ref3;
1952 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, selectableMenus.map(menu => {
1953 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
1954 - onClick: () => {
1955 - setSelectedMenu(menu.id);
1956 - onCreateFromMenu();
1957 - },
1958 - onClose: onClose,
1959 - key: menu.id
1960 - }, menu.name);
1961 - }));
1962 - }) : undefined)));
1963 -}
1964 -
1965 -/* harmony default export */ var block_placeholder = ((0,external_wp_element_namespaceObject.forwardRef)(BlockPlaceholder));
1966 -//# sourceMappingURL=index.js.map
1967 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-navigation-editor-placeholder.js
1968 -
1969 -
1970 -
1971 -/**
1972 - * WordPress dependencies
1973 - */
1974 -
1975 -
1976 -/**
1977 - * Internal dependencies
1978 - */
1979 -
1980 -
1981 -const addNavigationEditorPlaceholder = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
1982 - if (props.name !== 'core/navigation') {
1983 - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
1984 - }
1985 -
1986 - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
1987 - customPlaceholder: block_placeholder
1988 - }));
1989 -}, 'withNavigationEditorPlaceholder');
1990 -/* harmony default export */ var add_navigation_editor_placeholder = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-navigation-editor-placeholder', addNavigationEditorPlaceholder));
1991 -//# sourceMappingURL=add-navigation-editor-placeholder.js.map
1992 -// EXTERNAL MODULE: ./node_modules/classnames/index.js
1993 -var classnames = __webpack_require__(4184);
1994 -var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
1995 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
1996 -
1997 -
1998 -/**
1999 - * WordPress dependencies
2000 - */
2001 -
2002 -const check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2003 - xmlns: "http://www.w3.org/2000/svg",
2004 - viewBox: "0 0 24 24"
2005 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2006 - d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
2007 -}));
2008 -/* harmony default export */ var library_check = (check);
2009 -//# sourceMappingURL=check.js.map
2010 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
2011 -
2012 -
2013 -/**
2014 - * WordPress dependencies
2015 - */
2016 -
2017 -const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2018 - xmlns: "http://www.w3.org/2000/svg",
2019 - viewBox: "0 0 24 24"
2020 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2021 - d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"
2022 -}));
2023 -/* harmony default export */ var star_filled = (starFilled);
2024 -//# sourceMappingURL=star-filled.js.map
2025 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
2026 -
2027 -
2028 -/**
2029 - * WordPress dependencies
2030 - */
2031 -
2032 -const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2033 - xmlns: "http://www.w3.org/2000/svg",
2034 - viewBox: "0 0 24 24"
2035 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2036 - fillRule: "evenodd",
2037 - d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",
2038 - clipRule: "evenodd"
2039 -}));
2040 -/* harmony default export */ var star_empty = (starEmpty);
2041 -//# sourceMappingURL=star-empty.js.map
2042 -;// CONCATENATED MODULE: external ["wp","viewport"]
2043 -var external_wp_viewport_namespaceObject = window["wp"]["viewport"];
2044 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
2045 -
2046 -
2047 -/**
2048 - * WordPress dependencies
2049 - */
2050 -
2051 -const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2052 - xmlns: "http://www.w3.org/2000/svg",
2053 - viewBox: "0 0 24 24"
2054 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
2055 - d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
2056 -}));
2057 -/* harmony default export */ var close_small = (closeSmall);
2058 -//# sourceMappingURL=close-small.js.map
2059 -;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
2060 -/**
2061 - * External dependencies
2062 - */
2063 -
2064 -/**
2065 - * WordPress dependencies
2066 - */
2067 -
2068 -
2069 -/**
2070 - * Reducer to keep tract of the active area per scope.
2071 - *
2072 - * @param {boolean} state Previous state.
2073 - * @param {Object} action Action object.
2074 - * @param {string} action.type Action type.
2075 - * @param {string} action.itemType Type of item.
2076 - * @param {string} action.scope Item scope.
2077 - * @param {string} action.item Item name.
2078 - *
2079 - * @return {Object} Updated state.
2080 - */
2081 -
2082 -function singleEnableItems() {
2083 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2084 - let {
2085 - type,
2086 - itemType,
2087 - scope,
2088 - item
2089 - } = arguments.length > 1 ? arguments[1] : undefined;
2090 -
2091 - if (type !== 'SET_SINGLE_ENABLE_ITEM' || !itemType || !scope) {
2092 - return state;
2093 - }
2094 -
2095 - return { ...state,
2096 - [itemType]: { ...state[itemType],
2097 - [scope]: item || null
2098 - }
2099 - };
2100 -}
2101 -/**
2102 - * Reducer keeping track of the "pinned" items per scope.
2103 - *
2104 - * @param {boolean} state Previous state.
2105 - * @param {Object} action Action object.
2106 - * @param {string} action.type Action type.
2107 - * @param {string} action.itemType Type of item.
2108 - * @param {string} action.scope Item scope.
2109 - * @param {string} action.item Item name.
2110 - * @param {boolean} action.isEnable Whether the item is pinned.
2111 - *
2112 - * @return {Object} Updated state.
2113 - */
2114 -
2115 -function multipleEnableItems() {
2116 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2117 - let {
2118 - type,
2119 - itemType,
2120 - scope,
2121 - item,
2122 - isEnable
2123 - } = arguments.length > 1 ? arguments[1] : undefined;
2124 -
2125 - if (type !== 'SET_MULTIPLE_ENABLE_ITEM' || !itemType || !scope || !item || (0,external_lodash_namespaceObject.get)(state, [itemType, scope, item]) === isEnable) {
2126 - return state;
2127 - }
2128 -
2129 - const currentTypeState = state[itemType] || {};
2130 - const currentScopeState = currentTypeState[scope] || {};
2131 - return { ...state,
2132 - [itemType]: { ...currentTypeState,
2133 - [scope]: { ...currentScopeState,
2134 - [item]: isEnable || false
2135 - }
2136 - }
2137 - };
2138 -}
2139 -/**
2140 - * Reducer returning the defaults for user preferences.
2141 - *
2142 - * This is kept intentionally separate from the preferences
2143 - * themselves so that defaults are not persisted.
2144 - *
2145 - * @param {Object} state Current state.
2146 - * @param {Object} action Dispatched action.
2147 - *
2148 - * @return {Object} Updated state.
2149 - */
2150 -
2151 -const preferenceDefaults = (0,external_wp_data_namespaceObject.combineReducers)({
2152 - features() {
2153 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2154 - let action = arguments.length > 1 ? arguments[1] : undefined;
2155 -
2156 - if (action.type === 'SET_FEATURE_DEFAULTS') {
2157 - const {
2158 - scope,
2159 - defaults
2160 - } = action;
2161 - return { ...state,
2162 - [scope]: { ...state[scope],
2163 - ...defaults
2164 - }
2165 - };
2166 - }
2167 -
2168 - return state;
2169 - }
2170 -
2171 -});
2172 -/**
2173 - * Reducer returning the user preferences.
2174 - *
2175 - * @param {Object} state Current state.
2176 - * @param {Object} action Dispatched action.
2177 - *
2178 - * @return {Object} Updated state.
2179 - */
2180 -
2181 -const preferences = (0,external_wp_data_namespaceObject.combineReducers)({
2182 - features() {
2183 - let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2184 - let action = arguments.length > 1 ? arguments[1] : undefined;
2185 -
2186 - if (action.type === 'SET_FEATURE_VALUE') {
2187 - const {
2188 - scope,
2189 - featureName,
2190 - value
2191 - } = action;
2192 - return { ...state,
2193 - [scope]: { ...state[scope],
2194 - [featureName]: value
2195 - }
2196 - };
2197 - }
2198 -
2199 - return state;
2200 - }
2201 -
2202 -});
2203 -const enableItems = (0,external_wp_data_namespaceObject.combineReducers)({
2204 - singleEnableItems,
2205 - multipleEnableItems
2206 -});
2207 -/* harmony default export */ var store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2208 - enableItems,
2209 - preferenceDefaults,
2210 - preferences
2211 -}));
2212 -//# sourceMappingURL=reducer.js.map
2213 -;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
2214 -/**
2215 - * Returns an action object used in signalling that an active area should be changed.
2216 - *
2217 - * @param {string} itemType Type of item.
2218 - * @param {string} scope Item scope.
2219 - * @param {string} item Item identifier.
2220 - *
2221 - * @return {Object} Action object.
2222 - */
2223 -function setSingleEnableItem(itemType, scope, item) {
2224 - return {
2225 - type: 'SET_SINGLE_ENABLE_ITEM',
2226 - itemType,
2227 - scope,
2228 - item
2229 - };
2230 -}
2231 -/**
2232 - * Returns an action object used in signalling that a complementary item should be enabled.
2233 - *
2234 - * @param {string} scope Complementary area scope.
2235 - * @param {string} area Area identifier.
2236 - *
2237 - * @return {Object} Action object.
2238 - */
2239 -
2240 -
2241 -function enableComplementaryArea(scope, area) {
2242 - return setSingleEnableItem('complementaryArea', scope, area);
2243 -}
2244 -/**
2245 - * Returns an action object used in signalling that the complementary area of a given scope should be disabled.
2246 - *
2247 - * @param {string} scope Complementary area scope.
2248 - *
2249 - * @return {Object} Action object.
2250 - */
2251 -
2252 -function disableComplementaryArea(scope) {
2253 - return setSingleEnableItem('complementaryArea', scope, undefined);
2254 -}
2255 -/**
2256 - * Returns an action object to make an area enabled/disabled.
2257 - *
2258 - * @param {string} itemType Type of item.
2259 - * @param {string} scope Item scope.
2260 - * @param {string} item Item identifier.
2261 - * @param {boolean} isEnable Boolean indicating if an area should be pinned or not.
2262 - *
2263 - * @return {Object} Action object.
2264 - */
2265 -
2266 -function setMultipleEnableItem(itemType, scope, item, isEnable) {
2267 - return {
2268 - type: 'SET_MULTIPLE_ENABLE_ITEM',
2269 - itemType,
2270 - scope,
2271 - item,
2272 - isEnable
2273 - };
2274 -}
2275 -/**
2276 - * Returns an action object used in signalling that an item should be pinned.
2277 - *
2278 - * @param {string} scope Item scope.
2279 - * @param {string} itemId Item identifier.
2280 - *
2281 - * @return {Object} Action object.
2282 - */
2283 -
2284 -
2285 -function pinItem(scope, itemId) {
2286 - return setMultipleEnableItem('pinnedItems', scope, itemId, true);
2287 -}
2288 -/**
2289 - * Returns an action object used in signalling that an item should be unpinned.
2290 - *
2291 - * @param {string} scope Item scope.
2292 - * @param {string} itemId Item identifier.
2293 - *
2294 - * @return {Object} Action object.
2295 - */
2296 -
2297 -function unpinItem(scope, itemId) {
2298 - return setMultipleEnableItem('pinnedItems', scope, itemId, false);
2299 -}
2300 -/**
2301 - * Returns an action object used in signalling that a feature should be toggled.
2302 - *
2303 - * @param {string} scope The feature scope (e.g. core/edit-post).
2304 - * @param {string} featureName The feature name.
2305 - */
2306 -
2307 -function toggleFeature(scope, featureName) {
2308 - return function (_ref) {
2309 - let {
2310 - select,
2311 - dispatch
2312 - } = _ref;
2313 - const currentValue = select.isFeatureActive(scope, featureName);
2314 - dispatch.setFeatureValue(scope, featureName, !currentValue);
2315 - };
2316 -}
2317 -/**
2318 - * Returns an action object used in signalling that a feature should be set to
2319 - * a true or false value
2320 - *
2321 - * @param {string} scope The feature scope (e.g. core/edit-post).
2322 - * @param {string} featureName The feature name.
2323 - * @param {boolean} value The value to set.
2324 - *
2325 - * @return {Object} Action object.
2326 - */
2327 -
2328 -function setFeatureValue(scope, featureName, value) {
2329 - return {
2330 - type: 'SET_FEATURE_VALUE',
2331 - scope,
2332 - featureName,
2333 - value: !!value
2334 - };
2335 -}
2336 -/**
2337 - * Returns an action object used in signalling that defaults should be set for features.
2338 - *
2339 - * @param {string} scope The feature scope (e.g. core/edit-post).
2340 - * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
2341 - *
2342 - * @return {Object} Action object.
2343 - */
2344 -
2345 -function setFeatureDefaults(scope, defaults) {
2346 - return {
2347 - type: 'SET_FEATURE_DEFAULTS',
2348 - scope,
2349 - defaults
2350 - };
2351 -}
2352 -//# sourceMappingURL=actions.js.map
2353 -;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
2354 -/**
2355 - * External dependencies
2356 - */
2357 -
2358 -/**
2359 - * Returns the item that is enabled in a given scope.
2360 - *
2361 - * @param {Object} state Global application state.
2362 - * @param {string} itemType Type of item.
2363 - * @param {string} scope Item scope.
2364 - *
2365 - * @return {?string|null} The item that is enabled in the passed scope and type.
2366 - */
2367 -
2368 -function getSingleEnableItem(state, itemType, scope) {
2369 - return (0,external_lodash_namespaceObject.get)(state.enableItems.singleEnableItems, [itemType, scope]);
2370 -}
2371 -/**
2372 - * Returns the complementary area that is active in a given scope.
2373 - *
2374 - * @param {Object} state Global application state.
2375 - * @param {string} scope Item scope.
2376 - *
2377 - * @return {string} The complementary area that is active in the given scope.
2378 - */
2379 -
2380 -
2381 -function getActiveComplementaryArea(state, scope) {
2382 - return getSingleEnableItem(state, 'complementaryArea', scope);
2383 -}
2384 -/**
2385 - * Returns a boolean indicating if an item is enabled or not in a given scope.
2386 - *
2387 - * @param {Object} state Global application state.
2388 - * @param {string} itemType Type of item.
2389 - * @param {string} scope Scope.
2390 - * @param {string} item Item to check.
2391 - *
2392 - * @return {boolean|undefined} True if the item is enabled, false otherwise if the item is explicitly disabled, and undefined if there is no information for that item.
2393 - */
2394 -
2395 -function isMultipleEnabledItemEnabled(state, itemType, scope, item) {
2396 - return (0,external_lodash_namespaceObject.get)(state.enableItems.multipleEnableItems, [itemType, scope, item]);
2397 -}
2398 -/**
2399 - * Returns a boolean indicating if an item is pinned or not.
2400 - *
2401 - * @param {Object} state Global application state.
2402 - * @param {string} scope Scope.
2403 - * @param {string} item Item to check.
2404 - *
2405 - * @return {boolean} True if the item is pinned and false otherwise.
2406 - */
2407 -
2408 -
2409 -function isItemPinned(state, scope, item) {
2410 - return isMultipleEnabledItemEnabled(state, 'pinnedItems', scope, item) !== false;
2411 -}
2412 -/**
2413 - * Returns a boolean indicating whether a feature is active for a particular
2414 - * scope.
2415 - *
2416 - * @param {Object} state The store state.
2417 - * @param {string} scope The scope of the feature (e.g. core/edit-post).
2418 - * @param {string} featureName The name of the feature.
2419 - *
2420 - * @return {boolean} Is the feature enabled?
2421 - */
2422 -
2423 -function isFeatureActive(state, scope, featureName) {
2424 - var _state$preferences$fe, _state$preferenceDefa;
2425 -
2426 - const featureValue = (_state$preferences$fe = state.preferences.features[scope]) === null || _state$preferences$fe === void 0 ? void 0 : _state$preferences$fe[featureName];
2427 - const defaultedFeatureValue = featureValue !== undefined ? featureValue : (_state$preferenceDefa = state.preferenceDefaults.features[scope]) === null || _state$preferenceDefa === void 0 ? void 0 : _state$preferenceDefa[featureName];
2428 - return !!defaultedFeatureValue;
2429 -}
2430 -//# sourceMappingURL=selectors.js.map
2431 -;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
2432 -/**
2433 - * The identifier for the data store.
2434 - *
2435 - * @type {string}
2436 - */
2437 -const constants_STORE_NAME = 'core/interface';
2438 -//# sourceMappingURL=constants.js.map
2439 -;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
2440 -/**
2441 - * WordPress dependencies
2442 - */
2443 -
2444 -/**
2445 - * Internal dependencies
2446 - */
2447 -
2448 -
2449 -
2450 -
2451 -
2452 -/**
2453 - * Store definition for the interface namespace.
2454 - *
2455 - * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
2456 - *
2457 - * @type {Object}
2458 - */
2459 -
2460 -const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
2461 - reducer: store_reducer,
2462 - actions: store_actions_namespaceObject,
2463 - selectors: store_selectors_namespaceObject,
2464 - persist: ['enableItems', 'preferences'],
2465 - __experimentalUseThunks: true
2466 -}); // Once we build a more generic persistence plugin that works across types of stores
2467 -// we'd be able to replace this with a register call.
2468 -
2469 -(0,external_wp_data_namespaceObject.registerStore)(constants_STORE_NAME, {
2470 - reducer: store_reducer,
2471 - actions: store_actions_namespaceObject,
2472 - selectors: store_selectors_namespaceObject,
2473 - persist: ['enableItems', 'preferences'],
2474 - __experimentalUseThunks: true
2475 -});
2476 -//# sourceMappingURL=index.js.map
2477 -;// CONCATENATED MODULE: external ["wp","plugins"]
2478 -var external_wp_plugins_namespaceObject = window["wp"]["plugins"];
2479 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
2480 -/**
2481 - * WordPress dependencies
2482 - */
2483 -
2484 -/* harmony default export */ var complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
2485 - return {
2486 - icon: ownProps.icon || context.icon,
2487 - identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
2488 - };
2489 -}));
2490 -//# sourceMappingURL=index.js.map
2491 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
2492 -
2493 -
2494 -
2495 -/**
2496 - * External dependencies
2497 - */
2498 -
2499 -/**
2500 - * WordPress dependencies
2501 - */
2502 -
2503 -
2504 -
2505 -/**
2506 - * Internal dependencies
2507 - */
2508 -
2509 -
2510 -
2511 -
2512 -function ComplementaryAreaToggle(_ref) {
2513 - let {
2514 - as = external_wp_components_namespaceObject.Button,
2515 - scope,
2516 - identifier,
2517 - icon,
2518 - selectedIcon,
2519 - ...props
2520 - } = _ref;
2521 - const ComponentToUse = as;
2522 - const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getActiveComplementaryArea(scope) === identifier, [identifier]);
2523 - const {
2524 - enableComplementaryArea,
2525 - disableComplementaryArea
2526 - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
2527 - return (0,external_wp_element_namespaceObject.createElement)(ComponentToUse, _extends({
2528 - icon: selectedIcon && isSelected ? selectedIcon : icon,
2529 - onClick: () => {
2530 - if (isSelected) {
2531 - disableComplementaryArea(scope);
2532 - } else {
2533 - enableComplementaryArea(scope, identifier);
2534 - }
2535 - }
2536 - }, (0,external_lodash_namespaceObject.omit)(props, ['name'])));
2537 -}
2538 -
2539 -/* harmony default export */ var complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
2540 -//# sourceMappingURL=index.js.map
2541 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
2542 -
2543 -
2544 -
2545 -/**
2546 - * External dependencies
2547 - */
2548 -
2549 -/**
2550 - * WordPress dependencies
2551 - */
2552 -
2553 -
2554 -/**
2555 - * Internal dependencies
2556 - */
2557 -
2558 -
2559 -
2560 -const ComplementaryAreaHeader = _ref => {
2561 - let {
2562 - smallScreenTitle,
2563 - children,
2564 - className,
2565 - toggleButtonProps
2566 - } = _ref;
2567 - const toggleButton = (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
2568 - icon: close_small
2569 - }, toggleButtonProps));
2570 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
2571 - className: "components-panel__header interface-complementary-area-header__small"
2572 - }, smallScreenTitle && (0,external_wp_element_namespaceObject.createElement)("span", {
2573 - className: "interface-complementary-area-header__small-title"
2574 - }, smallScreenTitle), toggleButton), (0,external_wp_element_namespaceObject.createElement)("div", {
2575 - className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className),
2576 - tabIndex: -1
2577 - }, children, toggleButton));
2578 -};
2579 -
2580 -/* harmony default export */ var complementary_area_header = (ComplementaryAreaHeader);
2581 -//# sourceMappingURL=index.js.map
2582 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
2583 -
2584 -
2585 -
2586 -/**
2587 - * External dependencies
2588 - */
2589 -
2590 -/**
2591 - * WordPress dependencies
2592 - */
2593 -
2594 -
2595 -
2596 -
2597 -function ActionItemSlot(_ref) {
2598 - let {
2599 - name,
2600 - as: Component = external_wp_components_namespaceObject.ButtonGroup,
2601 - fillProps = {},
2602 - bubblesVirtually,
2603 - ...props
2604 - } = _ref;
2605 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, {
2606 - name: name,
2607 - bubblesVirtually: bubblesVirtually,
2608 - fillProps: fillProps
2609 - }, fills => {
2610 - if ((0,external_lodash_namespaceObject.isEmpty)(external_wp_element_namespaceObject.Children.toArray(fills))) {
2611 - return null;
2612 - } // Special handling exists for backward compatibility.
2613 - // It ensures that menu items created by plugin authors aren't
2614 - // duplicated with automatically injected menu items coming
2615 - // from pinnable plugin sidebars.
2616 - // @see https://github.com/WordPress/gutenberg/issues/14457
2617 -
2618 -
2619 - const initializedByPlugins = [];
2620 - external_wp_element_namespaceObject.Children.forEach(fills, _ref2 => {
2621 - let {
2622 - props: {
2623 - __unstableExplicitMenuItem,
2624 - __unstableTarget
2625 - }
2626 - } = _ref2;
2627 -
2628 - if (__unstableTarget && __unstableExplicitMenuItem) {
2629 - initializedByPlugins.push(__unstableTarget);
2630 - }
2631 - });
2632 - const children = external_wp_element_namespaceObject.Children.map(fills, child => {
2633 - if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
2634 - return null;
2635 - }
2636 -
2637 - return child;
2638 - });
2639 - return (0,external_wp_element_namespaceObject.createElement)(Component, props, children);
2640 - });
2641 -}
2642 -
2643 -function ActionItem(_ref3) {
2644 - let {
2645 - name,
2646 - as: Component = external_wp_components_namespaceObject.Button,
2647 - onClick,
2648 - ...props
2649 - } = _ref3;
2650 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
2651 - name: name
2652 - }, _ref4 => {
2653 - let {
2654 - onClick: fpOnClick
2655 - } = _ref4;
2656 - return (0,external_wp_element_namespaceObject.createElement)(Component, _extends({
2657 - onClick: onClick || fpOnClick ? function () {
2658 - (onClick || external_lodash_namespaceObject.noop)(...arguments);
2659 - (fpOnClick || external_lodash_namespaceObject.noop)(...arguments);
2660 - } : undefined
2661 - }, props));
2662 - });
2663 -}
2664 -
2665 -ActionItem.Slot = ActionItemSlot;
2666 -/* harmony default export */ var action_item = (ActionItem);
2667 -//# sourceMappingURL=index.js.map
2668 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
2669 -
2670 -
2671 -
2672 -/**
2673 - * External dependencies
2674 - */
2675 -
2676 -/**
2677 - * WordPress dependencies
2678 - */
2679 -
2680 -
2681 -
2682 -/**
2683 - * Internal dependencies
2684 - */
2685 -
2686 -
2687 -
2688 -
2689 -const PluginsMenuItem = props => // Menu item is marked with unstable prop for backward compatibility.
2690 -// They are removed so they don't leak to DOM elements.
2691 -// @see https://github.com/WordPress/gutenberg/issues/14457
2692 -(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, (0,external_lodash_namespaceObject.omit)(props, ['__unstableExplicitMenuItem', '__unstableTarget']));
2693 -
2694 -function ComplementaryAreaMoreMenuItem(_ref) {
2695 - let {
2696 - scope,
2697 - target,
2698 - __unstableExplicitMenuItem,
2699 - ...props
2700 - } = _ref;
2701 - return (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, _extends({
2702 - as: toggleProps => {
2703 - return (0,external_wp_element_namespaceObject.createElement)(action_item, _extends({
2704 - __unstableExplicitMenuItem: __unstableExplicitMenuItem,
2705 - __unstableTarget: `${scope}/${target}`,
2706 - as: PluginsMenuItem,
2707 - name: `${scope}/plugin-more-menu`
2708 - }, toggleProps));
2709 - },
2710 - role: "menuitemcheckbox",
2711 - selectedIcon: library_check,
2712 - name: target,
2713 - scope: scope
2714 - }, props));
2715 -}
2716 -//# sourceMappingURL=index.js.map
2717 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
2718 -
2719 -
2720 -
2721 -/**
2722 - * External dependencies
2723 - */
2724 -
2725 -
2726 -/**
2727 - * WordPress dependencies
2728 - */
2729 -
2730 -
2731 -
2732 -function PinnedItems(_ref) {
2733 - let {
2734 - scope,
2735 - ...props
2736 - } = _ref;
2737 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, _extends({
2738 - name: `PinnedItems/${scope}`
2739 - }, props));
2740 -}
2741 -
2742 -function PinnedItemsSlot(_ref2) {
2743 - let {
2744 - scope,
2745 - className,
2746 - ...props
2747 - } = _ref2;
2748 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
2749 - name: `PinnedItems/${scope}`
2750 - }, props), fills => !(0,external_lodash_namespaceObject.isEmpty)(fills) && (0,external_wp_element_namespaceObject.createElement)("div", {
2751 - className: classnames_default()(className, 'interface-pinned-items')
2752 - }, fills));
2753 -}
2754 -
2755 -PinnedItems.Slot = PinnedItemsSlot;
2756 -/* harmony default export */ var pinned_items = (PinnedItems);
2757 -//# sourceMappingURL=index.js.map
2758 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
2759 -
2760 -
2761 -
2762 -/**
2763 - * External dependencies
2764 - */
2765 -
2766 -/**
2767 - * WordPress dependencies
2768 - */
2769 -
2770 -
2771 -
2772 -
2773 -
2774 -
2775 -
2776 -/**
2777 - * Internal dependencies
2778 - */
2779 -
2780 -
2781 -
2782 -
2783 -
2784 -
2785 -
2786 -
2787 -function ComplementaryAreaSlot(_ref) {
2788 - let {
2789 - scope,
2790 - ...props
2791 - } = _ref;
2792 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Slot, _extends({
2793 - name: `ComplementaryArea/${scope}`
2794 - }, props));
2795 -}
2796 -
2797 -function ComplementaryAreaFill(_ref2) {
2798 - let {
2799 - scope,
2800 - children,
2801 - className
2802 - } = _ref2;
2803 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Fill, {
2804 - name: `ComplementaryArea/${scope}`
2805 - }, (0,external_wp_element_namespaceObject.createElement)("div", {
2806 - className: className
2807 - }, children));
2808 -}
2809 -
2810 -function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
2811 - const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
2812 - const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
2813 - const {
2814 - enableComplementaryArea,
2815 - disableComplementaryArea
2816 - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
2817 - (0,external_wp_element_namespaceObject.useEffect)(() => {
2818 - // If the complementary area is active and the editor is switching from a big to a small window size.
2819 - if (isActive && isSmall && !previousIsSmall.current) {
2820 - // Disable the complementary area.
2821 - disableComplementaryArea(scope); // Flag the complementary area to be reopened when the window size goes from small to big.
2822 -
2823 - shouldOpenWhenNotSmall.current = true;
2824 - } else if ( // If there is a flag indicating the complementary area should be enabled when we go from small to big window size
2825 - // and we are going from a small to big window size.
2826 - shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
2827 - // Remove the flag indicating the complementary area should be enabled.
2828 - shouldOpenWhenNotSmall.current = false; // Enable the complementary area.
2829 -
2830 - enableComplementaryArea(scope, identifier);
2831 - } else if ( // If the flag is indicating the current complementary should be reopened but another complementary area becomes active,
2832 - // remove the flag.
2833 - shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
2834 - shouldOpenWhenNotSmall.current = false;
2835 - }
2836 -
2837 - if (isSmall !== previousIsSmall.current) {
2838 - previousIsSmall.current = isSmall;
2839 - }
2840 - }, [isActive, isSmall, scope, identifier, activeArea]);
2841 -}
2842 -
2843 -function ComplementaryArea(_ref3) {
2844 - let {
2845 - children,
2846 - className,
2847 - closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
2848 - identifier,
2849 - header,
2850 - headerClassName,
2851 - icon,
2852 - isPinnable = true,
2853 - panelClassName,
2854 - scope,
2855 - name,
2856 - smallScreenTitle,
2857 - title,
2858 - toggleShortcut,
2859 - isActiveByDefault,
2860 - showIconLabels = false
2861 - } = _ref3;
2862 - const {
2863 - isActive,
2864 - isPinned,
2865 - activeArea,
2866 - isSmall,
2867 - isLarge
2868 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
2869 - const {
2870 - getActiveComplementaryArea,
2871 - isItemPinned
2872 - } = select(store_store);
2873 -
2874 - const _activeArea = getActiveComplementaryArea(scope);
2875 -
2876 - return {
2877 - isActive: _activeArea === identifier,
2878 - isPinned: isItemPinned(scope, identifier),
2879 - activeArea: _activeArea,
2880 - isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
2881 - isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large')
2882 - };
2883 - }, [identifier, scope]);
2884 - useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
2885 - const {
2886 - enableComplementaryArea,
2887 - disableComplementaryArea,
2888 - pinItem,
2889 - unpinItem
2890 - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
2891 - (0,external_wp_element_namespaceObject.useEffect)(() => {
2892 - if (isActiveByDefault && activeArea === undefined && !isSmall) {
2893 - enableComplementaryArea(scope, identifier);
2894 - }
2895 - }, [activeArea, isActiveByDefault, scope, identifier, isSmall]);
2896 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, isPinnable && (0,external_wp_element_namespaceObject.createElement)(pinned_items, {
2897 - scope: scope
2898 - }, isPinned && (0,external_wp_element_namespaceObject.createElement)(complementary_area_toggle, {
2899 - scope: scope,
2900 - identifier: identifier,
2901 - isPressed: isActive && (!showIconLabels || isLarge),
2902 - "aria-expanded": isActive,
2903 - label: title,
2904 - icon: showIconLabels ? library_check : icon,
2905 - showTooltip: !showIconLabels,
2906 - variant: showIconLabels ? 'tertiary' : undefined
2907 - })), name && isPinnable && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaMoreMenuItem, {
2908 - target: name,
2909 - scope: scope,
2910 - icon: icon
2911 - }, title), isActive && (0,external_wp_element_namespaceObject.createElement)(ComplementaryAreaFill, {
2912 - className: classnames_default()('interface-complementary-area', className),
2913 - scope: scope
2914 - }, (0,external_wp_element_namespaceObject.createElement)(complementary_area_header, {
2915 - className: headerClassName,
2916 - closeLabel: closeLabel,
2917 - onClose: () => disableComplementaryArea(scope),
2918 - smallScreenTitle: smallScreenTitle,
2919 - toggleButtonProps: {
2920 - label: closeLabel,
2921 - shortcut: toggleShortcut,
2922 - scope,
2923 - identifier
2924 - }
2925 - }, header || (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("strong", null, title), isPinnable && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
2926 - className: "interface-complementary-area__pin-unpin-item",
2927 - icon: isPinned ? star_filled : star_empty,
2928 - label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
2929 - onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
2930 - isPressed: isPinned,
2931 - "aria-expanded": isPinned
2932 - }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Panel, {
2933 - className: panelClassName
2934 - }, children)));
2935 -}
2936 -
2937 -const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
2938 -ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
2939 -/* harmony default export */ var complementary_area = (ComplementaryAreaWrapped);
2940 -//# sourceMappingURL=index.js.map
2941 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
2942 -
2943 -
2944 -
2945 -/**
2946 - * External dependencies
2947 - */
2948 -
2949 -/**
2950 - * WordPress dependencies
2951 - */
2952 -
2953 -/**
2954 - * WordPress dependencies
2955 - */
2956 -
2957 -
2958 -
2959 -
2960 -
2961 -
2962 -function useHTMLClass(className) {
2963 - (0,external_wp_element_namespaceObject.useEffect)(() => {
2964 - const element = document && document.querySelector(`html:not(.${className})`);
2965 -
2966 - if (!element) {
2967 - return;
2968 - }
2969 -
2970 - element.classList.toggle(className);
2971 - return () => {
2972 - element.classList.toggle(className);
2973 - };
2974 - }, [className]);
2975 -}
2976 -
2977 -function InterfaceSkeleton(_ref, ref) {
2978 - let {
2979 - footer,
2980 - header,
2981 - sidebar,
2982 - secondarySidebar,
2983 - notices,
2984 - content,
2985 - drawer,
2986 - actions,
2987 - labels,
2988 - className,
2989 - shortcuts
2990 - } = _ref;
2991 - const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
2992 - useHTMLClass('interface-interface-skeleton__html-container');
2993 - const defaultLabels = {
2994 - /* translators: accessibility text for the nav bar landmark region. */
2995 - drawer: (0,external_wp_i18n_namespaceObject.__)('Drawer'),
2996 -
2997 - /* translators: accessibility text for the top bar landmark region. */
2998 - header: (0,external_wp_i18n_namespaceObject.__)('Header'),
2999 -
3000 - /* translators: accessibility text for the content landmark region. */
3001 - body: (0,external_wp_i18n_namespaceObject.__)('Content'),
3002 -
3003 - /* translators: accessibility text for the secondary sidebar landmark region. */
3004 - secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
3005 -
3006 - /* translators: accessibility text for the settings landmark region. */
3007 - sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
3008 -
3009 - /* translators: accessibility text for the publish landmark region. */
3010 - actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
3011 -
3012 - /* translators: accessibility text for the footer landmark region. */
3013 - footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
3014 - };
3015 - const mergedLabels = { ...defaultLabels,
3016 - ...labels
3017 - };
3018 - return (0,external_wp_element_namespaceObject.createElement)("div", _extends({}, navigateRegionsProps, {
3019 - ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, navigateRegionsProps.ref]),
3020 - className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer')
3021 - }), !!drawer && (0,external_wp_element_namespaceObject.createElement)("div", {
3022 - className: "interface-interface-skeleton__drawer",
3023 - role: "region",
3024 - "aria-label": mergedLabels.drawer,
3025 - tabIndex: "-1"
3026 - }, drawer), (0,external_wp_element_namespaceObject.createElement)("div", {
3027 - className: "interface-interface-skeleton__editor"
3028 - }, !!header && (0,external_wp_element_namespaceObject.createElement)("div", {
3029 - className: "interface-interface-skeleton__header",
3030 - role: "region",
3031 - "aria-label": mergedLabels.header,
3032 - tabIndex: "-1"
3033 - }, header), (0,external_wp_element_namespaceObject.createElement)("div", {
3034 - className: "interface-interface-skeleton__body"
3035 - }, !!secondarySidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
3036 - className: "interface-interface-skeleton__secondary-sidebar",
3037 - role: "region",
3038 - "aria-label": mergedLabels.secondarySidebar,
3039 - tabIndex: "-1"
3040 - }, secondarySidebar), !!notices && (0,external_wp_element_namespaceObject.createElement)("div", {
3041 - className: "interface-interface-skeleton__notices"
3042 - }, notices), (0,external_wp_element_namespaceObject.createElement)("div", {
3043 - className: "interface-interface-skeleton__content",
3044 - role: "region",
3045 - "aria-label": mergedLabels.body,
3046 - tabIndex: "-1"
3047 - }, content), !!sidebar && (0,external_wp_element_namespaceObject.createElement)("div", {
3048 - className: "interface-interface-skeleton__sidebar",
3049 - role: "region",
3050 - "aria-label": mergedLabels.sidebar,
3051 - tabIndex: "-1"
3052 - }, sidebar), !!actions && (0,external_wp_element_namespaceObject.createElement)("div", {
3053 - className: "interface-interface-skeleton__actions",
3054 - role: "region",
3055 - "aria-label": mergedLabels.actions,
3056 - tabIndex: "-1"
3057 - }, actions))), !!footer && (0,external_wp_element_namespaceObject.createElement)("div", {
3058 - className: "interface-interface-skeleton__footer",
3059 - role: "region",
3060 - "aria-label": mergedLabels.footer,
3061 - tabIndex: "-1"
3062 - }, footer));
3063 -}
3064 -
3065 -/* harmony default export */ var interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
3066 -//# sourceMappingURL=index.js.map
3067 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
3068 -
3069 -
3070 -/**
3071 - * WordPress dependencies
3072 - */
3073 -
3074 -const moreVertical = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3075 - xmlns: "http://www.w3.org/2000/svg",
3076 - viewBox: "0 0 24 24"
3077 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3078 - d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
3079 -}));
3080 -/* harmony default export */ var more_vertical = (moreVertical);
3081 -//# sourceMappingURL=more-vertical.js.map
3082 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/more-menu-dropdown/index.js
3083 -
3084 -
3085 -/**
3086 - * External dependencies
3087 - */
3088 -
3089 -/**
3090 - * WordPress dependencies
3091 - */
3092 -
3093 -
3094 -
3095 -
3096 -function MoreMenuDropdown(_ref) {
3097 - let {
3098 - as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu,
3099 - className,
3100 -
3101 - /* translators: button label text should, if possible, be under 16 characters. */
3102 - label = (0,external_wp_i18n_namespaceObject.__)('Options'),
3103 - popoverProps,
3104 - toggleProps,
3105 - children
3106 - } = _ref;
3107 - return (0,external_wp_element_namespaceObject.createElement)(DropdownComponent, {
3108 - className: classnames_default()('interface-more-menu-dropdown', className),
3109 - icon: more_vertical,
3110 - label: label,
3111 - popoverProps: {
3112 - position: 'bottom left',
3113 - ...popoverProps,
3114 - className: classnames_default()('interface-more-menu-dropdown__content', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className)
3115 - },
3116 - toggleProps: {
3117 - tooltipPosition: 'bottom',
3118 - ...toggleProps
3119 - }
3120 - }, onClose => children(onClose));
3121 -}
3122 -//# sourceMappingURL=index.js.map
3123 -;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
3124 -
3125 -
3126 -
3127 -
3128 -
3129 -
3130 -
3131 -
3132 -//# sourceMappingURL=index.js.map
3133 -;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
3134 -
3135 -
3136 -//# sourceMappingURL=index.js.map
3137 -;// CONCATENATED MODULE: external ["wp","htmlEntities"]
3138 -var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
3139 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/name-display/index.js
3140 -
3141 -
3142 -/**
3143 - * WordPress dependencies
3144 - */
3145 -
3146 -
3147 -
3148 -
3149 -
3150 -
3151 -
3152 -/**
3153 - * Internal dependencies
3154 - */
3155 -
3156 -
3157 -
3158 -function NameDisplay() {
3159 - const {
3160 - enableComplementaryArea
3161 - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
3162 - const [menuId] = useSelectedMenuId();
3163 - const [name] = useMenuEntityProp('name', menuId);
3164 - const [, setIsMenuNameEditFocused] = (0,external_wp_element_namespaceObject.useContext)(IsMenuNameControlFocusedContext);
3165 - const menuName = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name !== null && name !== void 0 ? name : untitledMenu);
3166 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
3167 - "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s: the name of a menu.
3168 - (0,external_wp_i18n_namespaceObject.__)(`Edit menu name: %s`), menuName),
3169 - onClick: () => {
3170 - enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU);
3171 - setIsMenuNameEditFocused(true);
3172 - }
3173 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
3174 - limit: 24,
3175 - ellipsizeMode: "tail",
3176 - truncate: true
3177 - }, menuName))));
3178 -}
3179 -//# sourceMappingURL=index.js.map
3180 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/add-menu-name-editor.js
3181 -
3182 -
3183 -/**
3184 - * WordPress dependencies
3185 - */
3186 -
3187 -/**
3188 - * Internal dependencies
3189 - */
3190 -
3191 -
3192 -
3193 -const addMenuNameEditor = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
3194 - if (props.name !== 'core/navigation') {
3195 - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
3196 - }
3197 -
3198 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(NameDisplay, null), (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props));
3199 -}, 'withMenuName');
3200 -/* harmony default export */ var add_menu_name_editor = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/with-menu-name', addMenuNameEditor));
3201 -//# sourceMappingURL=add-menu-name-editor.js.map
3202 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/disable-inserting-non-navigation-blocks.js
3203 -/**
3204 - * WordPress dependencies
3205 - */
3206 -
3207 -/**
3208 - * External dependencies
3209 - */
3210 -
3211 -
3212 -
3213 -function disableInsertingNonNavigationBlocks(settings, name) {
3214 - if (!['core/navigation', 'core/navigation-link', 'core/navigation-submenu'].includes(name)) {
3215 - (0,external_lodash_namespaceObject.set)(settings, ['supports', 'inserter'], false);
3216 - }
3217 -
3218 - return settings;
3219 -}
3220 -
3221 -/* harmony default export */ var disable_inserting_non_navigation_blocks = (() => (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/edit-navigation/disable-inserting-non-navigation-blocks', disableInsertingNonNavigationBlocks));
3222 -//# sourceMappingURL=disable-inserting-non-navigation-blocks.js.map
3223 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/remove-edit-unsupported-features.js
3224 -
3225 -
3226 -
3227 -/**
3228 - * WordPress dependencies
3229 - */
3230 -
3231 -
3232 -const removeNavigationBlockEditUnsupportedFeatures = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
3233 - if (props.name !== 'core/navigation') {
3234 - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, props);
3235 - }
3236 -
3237 - return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({}, props, {
3238 - hasSubmenuIndicatorSetting: false,
3239 - hasItemJustificationControls: false,
3240 - hasColorSettings: false
3241 - }));
3242 -}, 'removeNavigationBlockEditUnsupportedFeatures');
3243 -/* harmony default export */ var remove_edit_unsupported_features = (() => (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-navigation/remove-navigation-block-edit-unsupported-features', removeNavigationBlockEditUnsupportedFeatures));
3244 -//# sourceMappingURL=remove-edit-unsupported-features.js.map
3245 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/remove-settings-unsupported-features.js
3246 -/**
3247 - * WordPress dependencies
3248 - */
3249 -
3250 -
3251 -function removeNavigationBlockSettingsUnsupportedFeatures(settings, name) {
3252 - if (name !== 'core/navigation') {
3253 - return settings;
3254 - }
3255 -
3256 - return { ...settings,
3257 - supports: {
3258 - customClassName: false,
3259 - html: false,
3260 - inserter: true
3261 - },
3262 - // Remove any block variations.
3263 - variations: undefined
3264 - };
3265 -}
3266 -
3267 -/* harmony default export */ var remove_settings_unsupported_features = (() => (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/edit-navigation/remove-navigation-block-settings-unsupported-features', removeNavigationBlockSettingsUnsupportedFeatures));
3268 -//# sourceMappingURL=remove-settings-unsupported-features.js.map
3269 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/filters/index.js
3270 -/**
3271 - * Internal dependencies
3272 - */
3273 -
3274 -
3275 -
3276 -
3277 -
3278 -
3279 -const addFilters = shouldAddDisableInsertingNonNavigationBlocksFilter => {
3280 - add_navigation_editor_custom_appender();
3281 - add_navigation_editor_placeholder();
3282 - add_menu_name_editor();
3283 -
3284 - if (shouldAddDisableInsertingNonNavigationBlocksFilter) {
3285 - disable_inserting_non_navigation_blocks();
3286 - }
3287 -
3288 - remove_edit_unsupported_features();
3289 - remove_settings_unsupported_features();
3290 -};
3291 -//# sourceMappingURL=index.js.map
3292 -;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
3293 -var external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
3294 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/add-menu/index.js
3295 -
3296 -
3297 -/**
3298 - * External dependencies
3299 - */
3300 -
3301 -/**
3302 - * WordPress dependencies
3303 - */
3304 -
3305 -
3306 -
3307 -
3308 -
3309 -
3310 -
3311 -
3312 -
3313 -/**
3314 - * Internal dependencies
3315 - */
3316 -
3317 -
3318 -
3319 -function AddMenu(_ref) {
3320 - let {
3321 - className,
3322 - onCreate,
3323 - titleText,
3324 - helpText,
3325 - focusInputOnMount = false,
3326 - noticeUI,
3327 - noticeOperations
3328 - } = _ref;
3329 - const inputRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)(focusInputOnMount);
3330 - const [menuName, setMenuName] = (0,external_wp_element_namespaceObject.useState)('');
3331 - const [isCreatingMenu, setIsCreatingMenu] = (0,external_wp_element_namespaceObject.useState)(false);
3332 - const {
3333 - createInfoNotice
3334 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
3335 - const {
3336 - saveMenu
3337 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
3338 - const {
3339 - createErrorNotice,
3340 - removeAllNotices
3341 - } = noticeOperations;
3342 - const lastSaveError = (0,external_wp_data_namespaceObject.useSelect)(select => {
3343 - return select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError(MENU_KIND, MENU_POST_TYPE);
3344 - }, []);
3345 - (0,external_wp_element_namespaceObject.useEffect)(() => {
3346 - if (lastSaveError) {
3347 - createErrorNotice((0,external_wp_dom_namespaceObject.__unstableStripHTML)(lastSaveError === null || lastSaveError === void 0 ? void 0 : lastSaveError.message));
3348 - }
3349 - }, [lastSaveError]);
3350 -
3351 - const createMenu = async event => {
3352 - event.preventDefault();
3353 -
3354 - if (!menuName.length || isCreatingMenu) {
3355 - return;
3356 - }
3357 -
3358 - setIsCreatingMenu(true); // Remove any existing notices.
3359 -
3360 - removeAllNotices();
3361 - const menu = await saveMenu({
3362 - name: menuName
3363 - });
3364 - setIsCreatingMenu(false);
3365 -
3366 - if (menu) {
3367 - createInfoNotice((0,external_wp_i18n_namespaceObject.__)('Menu created'), {
3368 - type: 'snackbar',
3369 - isDismissible: true
3370 - });
3371 -
3372 - if (onCreate) {
3373 - onCreate(menu.id);
3374 - }
3375 - }
3376 - };
3377 -
3378 - return (0,external_wp_element_namespaceObject.createElement)("form", {
3379 - className: classnames_default()('edit-navigation-add-menu', className),
3380 - onSubmit: createMenu
3381 - }, noticeUI, titleText && (0,external_wp_element_namespaceObject.createElement)("h3", {
3382 - className: "edit-navigation-add-menu__title"
3383 - }, titleText), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
3384 - ref: inputRef,
3385 - label: (0,external_wp_i18n_namespaceObject.__)('Menu name'),
3386 - value: menuName,
3387 - onChange: setMenuName,
3388 - help: helpText
3389 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3390 - className: "edit-navigation-add-menu__create-menu-button",
3391 - type: "submit",
3392 - variant: "primary",
3393 - disabled: !menuName.length,
3394 - isBusy: isCreatingMenu
3395 - /* Button is disabled but still focusable */
3396 - ,
3397 - "aria-disabled": !menuName.length || isCreatingMenu
3398 - }, (0,external_wp_i18n_namespaceObject.__)('Create menu')));
3399 -}
3400 -
3401 -/* harmony default export */ var add_menu = ((0,external_wp_components_namespaceObject.withNotices)(AddMenu));
3402 -//# sourceMappingURL=index.js.map
3403 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/menu-switcher/index.js
3404 -
3405 -
3406 -/**
3407 - * External dependencies
3408 - */
3409 -
3410 -/**
3411 - * WordPress dependencies
3412 - */
3413 -
3414 -
3415 -
3416 -
3417 -
3418 -/**
3419 - * Internal dependencies
3420 - */
3421 -
3422 -
3423 -function MenuSwitcher(_ref) {
3424 - let {
3425 - menus,
3426 - selectedMenuId,
3427 - onSelectMenu = external_lodash_namespaceObject.noop
3428 - } = _ref;
3429 - const [isModalVisible, setIsModalVisible] = (0,external_wp_element_namespaceObject.useState)(false);
3430 -
3431 - const openModal = () => setIsModalVisible(true);
3432 -
3433 - const closeModal = () => setIsModalVisible(false);
3434 -
3435 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, {
3436 - value: selectedMenuId,
3437 - onSelect: onSelectMenu,
3438 - choices: menus.map(_ref2 => {
3439 - let {
3440 - id,
3441 - name
3442 - } = _ref2;
3443 - return {
3444 - value: id,
3445 - label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name),
3446 - 'aria-label': (0,external_wp_i18n_namespaceObject.sprintf)(
3447 - /* translators: %s: The name of a menu. */
3448 - (0,external_wp_i18n_namespaceObject.__)("Switch to '%s'"), name)
3449 - };
3450 - })
3451 - })), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
3452 - hideSeparator: true
3453 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
3454 - className: "edit-navigation-menu-switcher__new-button",
3455 - onClick: openModal
3456 - }, (0,external_wp_i18n_namespaceObject.__)('Create a new menu')), isModalVisible && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
3457 - title: (0,external_wp_i18n_namespaceObject.__)('Create a new menu'),
3458 - className: "edit-navigation-menu-switcher__modal",
3459 - onRequestClose: closeModal
3460 - }, (0,external_wp_element_namespaceObject.createElement)(add_menu, {
3461 - onCreate: menuId => {
3462 - closeModal();
3463 - onSelectMenu(menuId);
3464 - },
3465 - helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.')
3466 - }))));
3467 -}
3468 -//# sourceMappingURL=index.js.map
3469 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/unselected-menu-state.js
3470 -
3471 -
3472 -/**
3473 - * WordPress dependencies
3474 - */
3475 -
3476 -
3477 -/**
3478 - * Internal dependencies
3479 - */
3480 -
3481 -
3482 -
3483 -function UnselectedMenuState(_ref) {
3484 - let {
3485 - onCreate,
3486 - onSelectMenu,
3487 - menus
3488 - } = _ref;
3489 - const showMenuSwitcher = (menus === null || menus === void 0 ? void 0 : menus.length) > 0;
3490 - return (0,external_wp_element_namespaceObject.createElement)("div", {
3491 - className: "edit-navigation-empty-state"
3492 - }, showMenuSwitcher && (0,external_wp_element_namespaceObject.createElement)("h4", null, (0,external_wp_i18n_namespaceObject.__)('Choose a menu to edit:')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CardBody, null, showMenuSwitcher ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NavigableMenu, null, (0,external_wp_element_namespaceObject.createElement)(MenuSwitcher, {
3493 - onSelectMenu: onSelectMenu,
3494 - menus: menus
3495 - })) : (0,external_wp_element_namespaceObject.createElement)(add_menu, {
3496 - onCreate: onCreate,
3497 - titleText: (0,external_wp_i18n_namespaceObject.__)('Create your first menu'),
3498 - helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.'),
3499 - focusInputOnMount: true
3500 - }))));
3501 -}
3502 -//# sourceMappingURL=unselected-menu-state.js.map
3503 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/error-boundary/index.js
3504 -
3505 -
3506 -/**
3507 - * WordPress dependencies
3508 - */
3509 -
3510 -
3511 -
3512 -
3513 -
3514 -class ErrorBoundary extends external_wp_element_namespaceObject.Component {
3515 - constructor() {
3516 - super(...arguments);
3517 - this.reboot = this.reboot.bind(this);
3518 - this.state = {
3519 - error: null
3520 - };
3521 - }
3522 -
3523 - componentDidCatch(error) {
3524 - this.setState({
3525 - error
3526 - });
3527 - }
3528 -
3529 - reboot() {
3530 - if (this.props.onError) {
3531 - this.props.onError();
3532 - }
3533 - }
3534 -
3535 - render() {
3536 - const {
3537 - error
3538 - } = this.state;
3539 -
3540 - if (!error) {
3541 - return this.props.children;
3542 - }
3543 -
3544 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
3545 - className: "navigation-editor-error-boundary",
3546 - actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3547 - key: "recovery",
3548 - onClick: this.reboot,
3549 - variant: "secondary"
3550 - }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery'))]
3551 - }, (0,external_wp_i18n_namespaceObject.__)('The navigation editor has encountered an unexpected error.'));
3552 - }
3553 -
3554 -}
3555 -
3556 -/* harmony default export */ var error_boundary = (ErrorBoundary);
3557 -//# sourceMappingURL=index.js.map
3558 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/shortcuts.js
3559 -/**
3560 - * WordPress dependencies
3561 - */
3562 -
3563 -
3564 -
3565 -
3566 -
3567 -
3568 -function NavigationEditorShortcuts(_ref) {
3569 - let {
3570 - saveBlocks
3571 - } = _ref;
3572 - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/save-menu', event => {
3573 - event.preventDefault();
3574 - saveBlocks();
3575 - });
3576 - const {
3577 - redo,
3578 - undo
3579 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
3580 - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/undo', event => {
3581 - undo();
3582 - event.preventDefault();
3583 - });
3584 - (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-navigation/redo', event => {
3585 - redo();
3586 - event.preventDefault();
3587 - });
3588 - return null;
3589 -}
3590 -
3591 -function RegisterNavigationEditorShortcuts() {
3592 - const {
3593 - registerShortcut
3594 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
3595 - (0,external_wp_element_namespaceObject.useEffect)(() => {
3596 - registerShortcut({
3597 - name: 'core/edit-navigation/save-menu',
3598 - category: 'global',
3599 - description: (0,external_wp_i18n_namespaceObject.__)('Save the navigation currently being edited.'),
3600 - keyCombination: {
3601 - modifier: 'primary',
3602 - character: 's'
3603 - }
3604 - });
3605 - registerShortcut({
3606 - name: 'core/edit-navigation/undo',
3607 - category: 'global',
3608 - description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
3609 - keyCombination: {
3610 - modifier: 'primary',
3611 - character: 'z'
3612 - }
3613 - });
3614 - registerShortcut({
3615 - name: 'core/edit-navigation/redo',
3616 - category: 'global',
3617 - description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
3618 - keyCombination: {
3619 - modifier: 'primaryShift',
3620 - character: 'z'
3621 - }
3622 - });
3623 - }, [registerShortcut]);
3624 - return null;
3625 -}
3626 -
3627 -NavigationEditorShortcuts.Register = RegisterNavigationEditorShortcuts;
3628 -/* harmony default export */ var shortcuts = (NavigationEditorShortcuts);
3629 -//# sourceMappingURL=shortcuts.js.map
3630 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/cog.js
3631 -
3632 -
3633 -/**
3634 - * WordPress dependencies
3635 - */
3636 -
3637 -const cog = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
3638 - xmlns: "http://www.w3.org/2000/svg",
3639 - viewBox: "0 0 24 24"
3640 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
3641 - fillRule: "evenodd",
3642 - d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z",
3643 - clipRule: "evenodd"
3644 -}));
3645 -/* harmony default export */ var library_cog = (cog);
3646 -//# sourceMappingURL=cog.js.map
3647 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/sidebar-header.js
3648 -
3649 -
3650 -/**
3651 - * WordPress dependencies
3652 - */
3653 -
3654 -
3655 -
3656 -
3657 -/**
3658 - * Internal dependencies
3659 - */
3660 -
3661 -
3662 -function SidebarHeader(_ref) {
3663 - let {
3664 - sidebarName
3665 - } = _ref;
3666 - const {
3667 - enableComplementaryArea
3668 - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
3669 -
3670 - const openMenuSettings = () => enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU);
3671 -
3672 - const openBlockSettings = () => enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_BLOCK);
3673 -
3674 - const [menuAriaLabel, menuActiveClass] = sidebarName === SIDEBAR_MENU ? // translators: ARIA label for the Menu sidebar tab, selected.
3675 - [(0,external_wp_i18n_namespaceObject.__)('Menu (selected)'), 'is-active'] : // translators: ARIA label for the Menu Settings Sidebar tab, not selected.
3676 - [(0,external_wp_i18n_namespaceObject.__)('Menu'), ''];
3677 - const [blockAriaLabel, blockActiveClass] = sidebarName === SIDEBAR_BLOCK ? // translators: ARIA label for the Block Settings Sidebar tab, selected.
3678 - [(0,external_wp_i18n_namespaceObject.__)('Block (selected)'), 'is-active'] : // translators: ARIA label for the Block Settings Sidebar tab, not selected.
3679 - [(0,external_wp_i18n_namespaceObject.__)('Block'), ''];
3680 - /* Use a list so screen readers will announce how many tabs there are. */
3681 -
3682 - return (0,external_wp_element_namespaceObject.createElement)("ul", null, (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3683 - onClick: openMenuSettings,
3684 - className: `edit-navigation-sidebar__panel-tab ${menuActiveClass}`,
3685 - "aria-label": menuAriaLabel // translators: Data label for the Menu Settings Sidebar tab.
3686 - ,
3687 - "data-label": (0,external_wp_i18n_namespaceObject.__)('Menu')
3688 - }, // translators: Text label for the Menu Settings Sidebar tab.
3689 - (0,external_wp_i18n_namespaceObject.__)('Menu'))), (0,external_wp_element_namespaceObject.createElement)("li", null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3690 - onClick: openBlockSettings,
3691 - className: `edit-navigation-sidebar__panel-tab ${blockActiveClass}`,
3692 - "aria-label": blockAriaLabel // translators: Data label for the Block Settings Sidebar tab.
3693 - ,
3694 - "data-label": (0,external_wp_i18n_namespaceObject.__)('Block')
3695 - }, // translators: Text label for the Block Settings Sidebar tab.
3696 - (0,external_wp_i18n_namespaceObject.__)('Block'))));
3697 -}
3698 -//# sourceMappingURL=sidebar-header.js.map
3699 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/name-editor/index.js
3700 -
3701 -
3702 -/**
3703 - * WordPress dependencies
3704 - */
3705 -
3706 -
3707 -
3708 -
3709 -/**
3710 - * Internal dependencies
3711 - */
3712 -
3713 -
3714 -function NameEditor() {
3715 - const [isMenuNameEditFocused, setIsMenuNameEditFocused] = (0,external_wp_element_namespaceObject.useContext)(IsMenuNameControlFocusedContext);
3716 - const [menuId] = useSelectedMenuId();
3717 - const [name, setName] = useMenuEntityProp('name', menuId);
3718 - const inputRef = (0,external_wp_element_namespaceObject.useRef)();
3719 - (0,external_wp_element_namespaceObject.useEffect)(() => {
3720 - if (isMenuNameEditFocused) inputRef.current.focus();
3721 - }, [isMenuNameEditFocused]);
3722 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
3723 - ref: inputRef,
3724 - help: (0,external_wp_i18n_namespaceObject.__)('A short, descriptive name used to refer to this menu elsewhere.'),
3725 - label: (0,external_wp_i18n_namespaceObject.__)('Name'),
3726 - onBlur: () => setIsMenuNameEditFocused(false),
3727 - className: "edit-navigation-name-editor__text-control",
3728 - value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name || ''),
3729 - onChange: setName
3730 - });
3731 -}
3732 -//# sourceMappingURL=index.js.map
3733 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/auto-add-pages.js
3734 -
3735 -
3736 -/**
3737 - * WordPress dependencies
3738 - */
3739 -
3740 -
3741 -/**
3742 - * Internal dependencies
3743 - */
3744 -
3745 -
3746 -function AutoAddPages(_ref) {
3747 - let {
3748 - menuId
3749 - } = _ref;
3750 - const [autoAddPages, setAutoAddPages] = useMenuEntityProp('auto_add', menuId);
3751 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToggleControl, {
3752 - label: (0,external_wp_i18n_namespaceObject.__)('Add new pages'),
3753 - help: (0,external_wp_i18n_namespaceObject.__)('Automatically add published top-level pages to this menu.'),
3754 - checked: autoAddPages !== null && autoAddPages !== void 0 ? autoAddPages : false,
3755 - onChange: setAutoAddPages
3756 - });
3757 -}
3758 -//# sourceMappingURL=auto-add-pages.js.map
3759 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/menu-settings.js
3760 -
3761 -
3762 -/**
3763 - * WordPress dependencies
3764 - */
3765 -
3766 -
3767 -/**
3768 - * Internal dependencies
3769 - */
3770 -
3771 -
3772 -
3773 -function MenuSettings(_ref) {
3774 - let {
3775 - menuId
3776 - } = _ref;
3777 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
3778 - title: (0,external_wp_i18n_namespaceObject.__)('Menu settings')
3779 - }, (0,external_wp_element_namespaceObject.createElement)(NameEditor, null), (0,external_wp_element_namespaceObject.createElement)(AutoAddPages, {
3780 - menuId: menuId
3781 - }));
3782 -}
3783 -//# sourceMappingURL=menu-settings.js.map
3784 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/manage-locations.js
3785 -
3786 -
3787 -/**
3788 - * WordPress dependencies
3789 - */
3790 -
3791 -
3792 -
3793 -
3794 -
3795 -
3796 -
3797 -/**
3798 - * Internal dependencies
3799 - */
3800 -
3801 -
3802 -function ManageLocations(_ref) {
3803 - let {
3804 - menus,
3805 - selectedMenuId,
3806 - onSelectMenu
3807 - } = _ref;
3808 - const {
3809 - menuLocations,
3810 - assignMenuToLocation,
3811 - toggleMenuLocationAssignment
3812 - } = useMenuLocations();
3813 - const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
3814 -
3815 - const openModal = () => setIsModalOpen(true);
3816 -
3817 - const closeModal = () => setIsModalOpen(false);
3818 -
3819 - const {
3820 - createSuccessNotice,
3821 - createErrorNotice
3822 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
3823 -
3824 - const validateBatchResponse = batchResponse => {
3825 - if (batchResponse.failed) {
3826 - return false;
3827 - }
3828 -
3829 - const errorResponses = batchResponse.responses.filter(response => {
3830 - return 200 > response.status || 300 <= response.status;
3831 - });
3832 - return 1 > errorResponses.length;
3833 - };
3834 -
3835 - const handleUpdateMenuLocations = async () => {
3836 - const method = 'POST';
3837 - const batchRequests = menus.map(_ref2 => {
3838 - let {
3839 - id
3840 - } = _ref2;
3841 - const locations = menuLocations.filter(menuLocation => menuLocation.menu === id).map(menuLocation => menuLocation.name);
3842 - return {
3843 - path: `/wp/v2/menus/${id}`,
3844 - body: {
3845 - locations
3846 - },
3847 - method
3848 - };
3849 - });
3850 - const batchResponse = await external_wp_apiFetch_default()({
3851 - path: 'batch/v1',
3852 - data: {
3853 - validation: 'require-all-validate',
3854 - requests: batchRequests
3855 - },
3856 - method
3857 - });
3858 - const isSuccess = validateBatchResponse(batchResponse);
3859 -
3860 - if (isSuccess) {
3861 - createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Menu locations have been updated.'), {
3862 - type: 'snackbar'
3863 - });
3864 - closeModal();
3865 - return;
3866 - }
3867 -
3868 - createErrorNotice((0,external_wp_i18n_namespaceObject.__)('An error occurred while trying to update menu locations.'), {
3869 - type: 'snackbar'
3870 - });
3871 - };
3872 -
3873 - if (!menuLocations || !(menus !== null && menus !== void 0 && menus.length)) {
3874 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null);
3875 - }
3876 -
3877 - if (!menuLocations.length) {
3878 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
3879 - title: (0,external_wp_i18n_namespaceObject.__)('Theme locations')
3880 - }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('There are no available menu locations.')));
3881 - }
3882 -
3883 - const themeLocationCountTextMain = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: Number of available theme locations.
3884 - (0,external_wp_i18n_namespaceObject.__)('Your current theme provides %d different locations to place menu.'), menuLocations.length);
3885 - const themeLocationCountTextModal = (0,external_wp_i18n_namespaceObject.sprintf)( // translators: Number of available theme locations.
3886 - (0,external_wp_i18n_namespaceObject.__)('Your current theme supports %d different locations. Select which menu appears in each location.'), menuLocations.length);
3887 - const menusWithSelection = menuLocations.map(_ref3 => {
3888 - let {
3889 - name,
3890 - description,
3891 - menu
3892 - } = _ref3;
3893 - const menuOnLocation = menus.filter(_ref4 => {
3894 - let {
3895 - id
3896 - } = _ref4;
3897 - return ![0, selectedMenuId].includes(id);
3898 - }).find(_ref5 => {
3899 - let {
3900 - id
3901 - } = _ref5;
3902 - return id === menu;
3903 - });
3904 - return (0,external_wp_element_namespaceObject.createElement)("li", {
3905 - key: name,
3906 - className: "edit-navigation-manage-locations__checklist-item"
3907 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
3908 - className: "edit-navigation-manage-locations__menu-location-checkbox",
3909 - checked: menu === selectedMenuId,
3910 - onChange: () => toggleMenuLocationAssignment(name, selectedMenuId),
3911 - label: description,
3912 - help: menuOnLocation && (0,external_wp_i18n_namespaceObject.sprintf)( // translators: menu name.
3913 - (0,external_wp_i18n_namespaceObject.__)('Currently using %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuOnLocation.name))
3914 - }));
3915 - });
3916 - const menuLocationCard = menuLocations.map(menuLocation => (0,external_wp_element_namespaceObject.createElement)("div", {
3917 - key: menuLocation.name,
3918 - className: "edit-navigation-manage-locations__menu-entry"
3919 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
3920 - key: menuLocation.name,
3921 - className: "edit-navigation-manage-locations__select-menu",
3922 - label: menuLocation.description,
3923 - labelPosition: "top",
3924 - value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuLocation.menu),
3925 - options: [{
3926 - value: 0,
3927 - label: (0,external_wp_i18n_namespaceObject.__)('Select a Menu'),
3928 - key: 0
3929 - }, ...menus.map(_ref6 => {
3930 - let {
3931 - id,
3932 - name
3933 - } = _ref6;
3934 - return {
3935 - key: id,
3936 - value: id,
3937 - label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(name)
3938 - };
3939 - })],
3940 - onChange: menuId => {
3941 - assignMenuToLocation(menuLocation.name, Number(menuId));
3942 - }
3943 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3944 - variant: "secondary",
3945 - style: {
3946 - visibility: !!menuLocation.menu ? 'visible' : 'hidden'
3947 - },
3948 - className: "edit-navigation-manage-locations__edit-button",
3949 - onClick: () => (closeModal(), onSelectMenu(menuLocation.menu))
3950 - }, (0,external_wp_i18n_namespaceObject.__)('Edit'))));
3951 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
3952 - title: (0,external_wp_i18n_namespaceObject.__)('Theme locations')
3953 - }, (0,external_wp_element_namespaceObject.createElement)("div", {
3954 - className: "edit-navigation-manage-locations__theme-location-text-main"
3955 - }, themeLocationCountTextMain), (0,external_wp_element_namespaceObject.createElement)("ul", {
3956 - className: "edit-navigation-manage-locations__checklist"
3957 - }, menusWithSelection), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3958 - variant: "secondary",
3959 - className: "edit-navigation-manage-locations__open-menu-locations-modal-button",
3960 - "aria-expanded": isModalOpen,
3961 - onClick: openModal
3962 - }, (0,external_wp_i18n_namespaceObject.__)('Manage locations')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
3963 - className: "edit-navigation-manage-locations__modal",
3964 - title: (0,external_wp_i18n_namespaceObject.__)('Manage locations'),
3965 - onRequestClose: closeModal
3966 - }, (0,external_wp_element_namespaceObject.createElement)("div", {
3967 - className: "edit-navigation-manage-locations__theme-location-text-modal"
3968 - }, themeLocationCountTextModal), menuLocationCard, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3969 - className: "edit-navigation-manage-locations__save-button",
3970 - variant: "primary",
3971 - onClick: handleUpdateMenuLocations
3972 - }, (0,external_wp_i18n_namespaceObject.__)('Update'))));
3973 -}
3974 -//# sourceMappingURL=manage-locations.js.map
3975 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/delete-menu.js
3976 -
3977 -
3978 -/**
3979 - * WordPress dependencies
3980 - */
3981 -
3982 -
3983 -
3984 -function DeleteMenu(_ref) {
3985 - let {
3986 - onDeleteMenu,
3987 - isMenuBeingDeleted
3988 - } = _ref;
3989 - const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
3990 -
3991 - const handleConfirm = () => {
3992 - setShowConfirmDialog(false);
3993 - onDeleteMenu();
3994 - };
3995 -
3996 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
3997 - className: "edit-navigation-inspector-additions__delete-menu-button",
3998 - variant: "secondary",
3999 - isDestructive: true,
4000 - isBusy: isMenuBeingDeleted,
4001 - onClick: () => {
4002 - setShowConfirmDialog(true);
4003 - }
4004 - }, (0,external_wp_i18n_namespaceObject.__)('Delete menu')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
4005 - isOpen: showConfirmDialog,
4006 - onConfirm: handleConfirm,
4007 - onCancel: () => setShowConfirmDialog(false)
4008 - }, (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete this navigation? This action cannot be undone.'))));
4009 -}
4010 -//# sourceMappingURL=delete-menu.js.map
4011 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/sidebar/index.js
4012 -
4013 -
4014 -/**
4015 - * WordPress dependencies
4016 - */
4017 -
4018 -
4019 -
4020 -
4021 -
4022 -
4023 -
4024 -/**
4025 - * Internal dependencies
4026 - */
4027 -
4028 -
4029 -
4030 -
4031 -
4032 -
4033 -function Sidebar(_ref) {
4034 - let {
4035 - menuId,
4036 - menus,
4037 - isMenuBeingDeleted,
4038 - onDeleteMenu,
4039 - onSelectMenu
4040 - } = _ref;
4041 - const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
4042 - const {
4043 - sidebar,
4044 - hasBlockSelection,
4045 - hasSidebarEnabled
4046 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4047 - const _sidebar = select(store_store).getActiveComplementaryArea(SIDEBAR_SCOPE);
4048 -
4049 - const _hasSidebarEnabled = [SIDEBAR_MENU, SIDEBAR_BLOCK].includes(_sidebar);
4050 -
4051 - return {
4052 - sidebar: _sidebar,
4053 - hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(),
4054 - hasSidebarEnabled: _hasSidebarEnabled
4055 - };
4056 - }, []);
4057 - const {
4058 - enableComplementaryArea
4059 - } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4060 - (0,external_wp_element_namespaceObject.useEffect)(() => {
4061 - if (!hasSidebarEnabled) {
4062 - return;
4063 - }
4064 -
4065 - if (hasBlockSelection) {
4066 - enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_BLOCK);
4067 - } else {
4068 - enableComplementaryArea(SIDEBAR_SCOPE, SIDEBAR_MENU);
4069 - }
4070 - }, [hasBlockSelection, hasSidebarEnabled]);
4071 - let sidebarName = sidebar;
4072 -
4073 - if (!hasSidebarEnabled) {
4074 - sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_MENU;
4075 - }
4076 -
4077 - return (0,external_wp_element_namespaceObject.createElement)(complementary_area, {
4078 - className: "edit-navigation-sidebar"
4079 - /* translators: button label text should, if possible, be under 16 characters. */
4080 - ,
4081 - title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
4082 - closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close settings'),
4083 - scope: SIDEBAR_SCOPE,
4084 - identifier: sidebarName,
4085 - icon: library_cog,
4086 - isActiveByDefault: isLargeViewport,
4087 - header: (0,external_wp_element_namespaceObject.createElement)(SidebarHeader, {
4088 - sidebarName: sidebarName
4089 - }),
4090 - headerClassName: "edit-navigation-sidebar__panel-tabs",
4091 - isPinnable: true
4092 - }, sidebarName === SIDEBAR_MENU && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(MenuSettings, {
4093 - menuId: menuId
4094 - }), (0,external_wp_element_namespaceObject.createElement)(ManageLocations, {
4095 - menus: menus,
4096 - selectedMenuId: menuId,
4097 - onSelectMenu: onSelectMenu
4098 - }), (0,external_wp_element_namespaceObject.createElement)(DeleteMenu, {
4099 - onDeleteMenu: onDeleteMenu,
4100 - isMenuBeingDeleted: isMenuBeingDeleted
4101 - })), sidebarName === SIDEBAR_BLOCK && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null));
4102 -}
4103 -//# sourceMappingURL=index.js.map
4104 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/menu-actions.js
4105 -
4106 -
4107 -/**
4108 - * WordPress dependencies
4109 - */
4110 -
4111 -
4112 -
4113 -
4114 -
4115 -/**
4116 - * Internal dependencies
4117 - */
4118 -
4119 -
4120 -
4121 -function MenuActions(_ref) {
4122 - let {
4123 - menus,
4124 - isLoading
4125 - } = _ref;
4126 - const [selectedMenuId, setSelectedMenuId] = useSelectedMenuId();
4127 - const [menuName] = useMenuEntityProp('name', selectedMenuId); // The title ref is passed to the popover as the anchorRef so that the
4128 - // dropdown is centered over the whole title area rather than just one
4129 - // part of it.
4130 -
4131 - const titleRef = (0,external_wp_element_namespaceObject.useRef)();
4132 -
4133 - if (isLoading) {
4134 - return (0,external_wp_element_namespaceObject.createElement)("div", {
4135 - className: "edit-navigation-menu-actions"
4136 - }, (0,external_wp_i18n_namespaceObject.__)('Loading…'));
4137 - }
4138 -
4139 - return (0,external_wp_element_namespaceObject.createElement)("div", {
4140 - className: "edit-navigation-menu-actions"
4141 - }, (0,external_wp_element_namespaceObject.createElement)("div", {
4142 - ref: titleRef,
4143 - className: "edit-navigation-menu-actions__subtitle-wrapper"
4144 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalText, {
4145 - size: "body",
4146 - className: "edit-navigation-menu-actions__subtitle",
4147 - as: "h2",
4148 - limit: 24,
4149 - ellipsizeMode: "tail",
4150 - truncate: true
4151 - }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuName)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropdownMenu, {
4152 - icon: chevron_down,
4153 - toggleProps: {
4154 - label: (0,external_wp_i18n_namespaceObject.__)('Switch menu'),
4155 - className: 'edit-navigation-menu-actions__switcher-toggle',
4156 - showTooltip: false,
4157 - __experimentalIsFocusable: true
4158 - },
4159 - popoverProps: {
4160 - className: 'edit-navigation-menu-actions__switcher-dropdown',
4161 - position: 'bottom center',
4162 - anchorRef: titleRef.current
4163 - }
4164 - }, _ref2 => {
4165 - let {
4166 - onClose
4167 - } = _ref2;
4168 - return (0,external_wp_element_namespaceObject.createElement)(MenuSwitcher, {
4169 - menus: menus,
4170 - selectedMenuId: selectedMenuId,
4171 - onSelectMenu: menuId => {
4172 - setSelectedMenuId(menuId);
4173 - onClose();
4174 - }
4175 - });
4176 - })));
4177 -}
4178 -//# sourceMappingURL=menu-actions.js.map
4179 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/new-button.js
4180 -
4181 -
4182 -/**
4183 - * WordPress dependencies
4184 - */
4185 -
4186 -
4187 -
4188 -/**
4189 - * Internal dependencies
4190 - */
4191 -
4192 -
4193 -
4194 -function NewButton() {
4195 - const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
4196 - const [, setSelectedMenuId] = useSelectedMenuId();
4197 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4198 - variant: "tertiary",
4199 - onClick: () => setIsModalOpen(true)
4200 - }, (0,external_wp_i18n_namespaceObject.__)('New menu')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
4201 - title: (0,external_wp_i18n_namespaceObject.__)('Create a new menu'),
4202 - className: "edit-navigation-menu-switcher__modal",
4203 - onRequestClose: () => setIsModalOpen(false)
4204 - }, (0,external_wp_element_namespaceObject.createElement)(add_menu, {
4205 - helpText: (0,external_wp_i18n_namespaceObject.__)('A short descriptive name for your menu.'),
4206 - onCreate: menuId => {
4207 - setIsModalOpen(false);
4208 - setSelectedMenuId(menuId);
4209 - }
4210 - })));
4211 -}
4212 -//# sourceMappingURL=new-button.js.map
4213 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/save-button.js
4214 -
4215 -
4216 -/**
4217 - * WordPress dependencies
4218 - */
4219 -
4220 -
4221 -
4222 -
4223 -/**
4224 - * Internal dependencies
4225 - */
4226 -
4227 -
4228 -function SaveButton(_ref) {
4229 - let {
4230 - navigationPost
4231 - } = _ref;
4232 - const {
4233 - isDirty
4234 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4235 - const {
4236 - __experimentalGetDirtyEntityRecords
4237 - } = select(external_wp_coreData_namespaceObject.store);
4238 -
4239 - const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
4240 -
4241 - return {
4242 - isDirty: dirtyEntityRecords.length > 0
4243 - };
4244 - }, []);
4245 - const {
4246 - saveNavigationPost
4247 - } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4248 - const disabled = !isDirty || !navigationPost;
4249 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4250 - className: "edit-navigation-toolbar__save-button",
4251 - variant: "primary",
4252 - onClick: () => {
4253 - saveNavigationPost(navigationPost);
4254 - },
4255 - disabled: disabled
4256 - }, (0,external_wp_i18n_namespaceObject.__)('Save'));
4257 -}
4258 -//# sourceMappingURL=save-button.js.map
4259 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
4260 -
4261 -
4262 -/**
4263 - * WordPress dependencies
4264 - */
4265 -
4266 -const undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4267 - xmlns: "http://www.w3.org/2000/svg",
4268 - viewBox: "0 0 24 24"
4269 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4270 - d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"
4271 -}));
4272 -/* harmony default export */ var library_undo = (undo);
4273 -//# sourceMappingURL=undo.js.map
4274 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
4275 -
4276 -
4277 -/**
4278 - * WordPress dependencies
4279 - */
4280 -
4281 -const redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4282 - xmlns: "http://www.w3.org/2000/svg",
4283 - viewBox: "0 0 24 24"
4284 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4285 - d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"
4286 -}));
4287 -/* harmony default export */ var library_redo = (redo);
4288 -//# sourceMappingURL=redo.js.map
4289 -;// CONCATENATED MODULE: external ["wp","keycodes"]
4290 -var external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
4291 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/undo-button.js
4292 -
4293 -
4294 -/**
4295 - * WordPress dependencies
4296 - */
4297 -
4298 -
4299 -
4300 -
4301 -
4302 -
4303 -function UndoButton() {
4304 - const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasUndo(), []);
4305 - const {
4306 - undo
4307 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4308 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
4309 - icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo,
4310 - label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
4311 - shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
4312 - // button, because it will remove focus for keyboard users.
4313 - // See: https://github.com/WordPress/gutenberg/issues/3486
4314 - ,
4315 - "aria-disabled": !hasUndo,
4316 - onClick: hasUndo ? undo : undefined
4317 - });
4318 -}
4319 -//# sourceMappingURL=undo-button.js.map
4320 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/redo-button.js
4321 -
4322 -
4323 -/**
4324 - * WordPress dependencies
4325 - */
4326 -
4327 -
4328 -
4329 -
4330 -
4331 -
4332 -function RedoButton() {
4333 - const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).hasRedo(), []);
4334 - const {
4335 - redo
4336 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
4337 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarButton, {
4338 - icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo,
4339 - label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
4340 - shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no undo levels we don't want to actually disable this
4341 - // button, because it will remove focus for keyboard users.
4342 - // See: https://github.com/WordPress/gutenberg/issues/3486
4343 - ,
4344 - "aria-disabled": !hasRedo,
4345 - onClick: hasRedo ? redo : undefined
4346 - });
4347 -}
4348 -//# sourceMappingURL=redo-button.js.map
4349 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
4350 -
4351 -
4352 -/**
4353 - * WordPress dependencies
4354 - */
4355 -
4356 -const plus = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4357 - xmlns: "http://www.w3.org/2000/svg",
4358 - viewBox: "0 0 24 24"
4359 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4360 - d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
4361 -}));
4362 -/* harmony default export */ var library_plus = (plus);
4363 -//# sourceMappingURL=plus.js.map
4364 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/inserter-toggle.js
4365 -
4366 -
4367 -/**
4368 - * WordPress dependencies
4369 - */
4370 -
4371 -
4372 -
4373 -
4374 -
4375 -/**
4376 - * Internal dependencies
4377 - */
4378 -
4379 -
4380 -
4381 -
4382 -function InserterToggle() {
4383 - const {
4384 - navBlockClientId
4385 - } = use_navigation_editor_root_block();
4386 - const {
4387 - isInserterOpened,
4388 - hasInserterItems
4389 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4390 - return {
4391 - hasInserterItems: select(external_wp_blockEditor_namespaceObject.store).hasInserterItems(navBlockClientId),
4392 - isInserterOpened: select(store).isInserterOpened()
4393 - };
4394 - }, [navBlockClientId]);
4395 - const {
4396 - setIsInserterOpened
4397 - } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4398 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ToolbarItem, {
4399 - as: external_wp_components_namespaceObject.Button,
4400 - className: "edit-navigation-header-inserter-toggle",
4401 - variant: "primary",
4402 - isPressed: isInserterOpened,
4403 - onMouseDown: event => {
4404 - event.preventDefault();
4405 - },
4406 - onClick: () => setIsInserterOpened(!isInserterOpened),
4407 - icon: library_plus
4408 - /* translators: button label text should, if possible, be under 16
4409 - characters. */
4410 - ,
4411 - label: (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button'),
4412 - disabled: !hasInserterItems
4413 - });
4414 -}
4415 -
4416 -/* harmony default export */ var inserter_toggle = (InserterToggle);
4417 -//# sourceMappingURL=inserter-toggle.js.map
4418 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
4419 -
4420 -
4421 -/**
4422 - * WordPress dependencies
4423 - */
4424 -
4425 -const external = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4426 - xmlns: "http://www.w3.org/2000/svg",
4427 - viewBox: "0 0 24 24"
4428 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4429 - d: "M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"
4430 -}));
4431 -/* harmony default export */ var library_external = (external);
4432 -//# sourceMappingURL=external.js.map
4433 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/tools-more-menu-group.js
4434 -
4435 -
4436 -/**
4437 - * WordPress dependencies
4438 - */
4439 -
4440 -const {
4441 - Fill: ToolsMoreMenuGroup,
4442 - Slot
4443 -} = (0,external_wp_components_namespaceObject.createSlotFill)('EditNavigationToolsMoreMenuGroup');
4444 -
4445 -ToolsMoreMenuGroup.Slot = _ref => {
4446 - let {
4447 - fillProps
4448 - } = _ref;
4449 - return (0,external_wp_element_namespaceObject.createElement)(Slot, {
4450 - fillProps: fillProps
4451 - }, fills => fills);
4452 -};
4453 -
4454 -/* harmony default export */ var tools_more_menu_group = (ToolsMoreMenuGroup);
4455 -//# sourceMappingURL=tools-more-menu-group.js.map
4456 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/more-menu.js
4457 -
4458 -
4459 -/**
4460 - * WordPress dependencies
4461 - */
4462 -
4463 -
4464 -
4465 -
4466 -/**
4467 - * Internal dependencies
4468 - */
4469 -
4470 -
4471 -function MoreMenu() {
4472 - return (0,external_wp_element_namespaceObject.createElement)(MoreMenuDropdown, null, onClose => (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuGroup, {
4473 - label: (0,external_wp_i18n_namespaceObject.__)('Tools')
4474 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
4475 - role: "menuitem",
4476 - icon: library_external,
4477 - href: "https://github.com/WordPress/gutenberg/tree/trunk/packages/edit-navigation/docs/user-documentation.md",
4478 - target: "_blank",
4479 - rel: "noopener noreferrer"
4480 - }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
4481 - as: "span"
4482 - },
4483 - /* translators: accessibility text */
4484 - (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_wp_element_namespaceObject.createElement)(tools_more_menu_group.Slot, {
4485 - fillProps: {
4486 - onClose
4487 - }
4488 - })));
4489 -}
4490 -//# sourceMappingURL=more-menu.js.map
4491 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/header/index.js
4492 -
4493 -
4494 -/**
4495 - * WordPress dependencies
4496 - */
4497 -
4498 -
4499 -
4500 -
4501 -/**
4502 - * Internal dependencies
4503 - */
4504 -
4505 -
4506 -
4507 -
4508 -
4509 -
4510 -
4511 -
4512 -function Header(_ref) {
4513 - let {
4514 - isMenuSelected,
4515 - menus,
4516 - isPending,
4517 - navigationPost
4518 - } = _ref;
4519 - const isMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
4520 -
4521 - if (!isMenuSelected) {
4522 - return (0,external_wp_element_namespaceObject.createElement)("div", {
4523 - className: "edit-navigation-header"
4524 - }, (0,external_wp_element_namespaceObject.createElement)("div", {
4525 - className: "edit-navigation-header__toolbar-wrapper"
4526 - }, (0,external_wp_element_namespaceObject.createElement)("h1", {
4527 - className: "edit-navigation-header__title"
4528 - }, (0,external_wp_i18n_namespaceObject.__)('Navigation'))));
4529 - }
4530 -
4531 - return (0,external_wp_element_namespaceObject.createElement)("div", {
4532 - className: "edit-navigation-header"
4533 - }, (0,external_wp_element_namespaceObject.createElement)("div", {
4534 - className: "edit-navigation-header__toolbar-wrapper"
4535 - }, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)("h1", {
4536 - className: "edit-navigation-header__title"
4537 - }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
4538 - className: "edit-navigation-header__toolbar",
4539 - "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document tools')
4540 - }, (0,external_wp_element_namespaceObject.createElement)(inserter_toggle, null), isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(UndoButton, null), (0,external_wp_element_namespaceObject.createElement)(RedoButton, null)))), (0,external_wp_element_namespaceObject.createElement)(MenuActions, {
4541 - menus: menus,
4542 - isLoading: isPending
4543 - }), (0,external_wp_element_namespaceObject.createElement)("div", {
4544 - className: "edit-navigation-header__actions"
4545 - }, isMediumViewport && (0,external_wp_element_namespaceObject.createElement)(NewButton, null), (0,external_wp_element_namespaceObject.createElement)(SaveButton, {
4546 - navigationPost: navigationPost
4547 - }), (0,external_wp_element_namespaceObject.createElement)(pinned_items.Slot, {
4548 - scope: "core/edit-navigation"
4549 - }), (0,external_wp_element_namespaceObject.createElement)(MoreMenu, null)));
4550 -}
4551 -//# sourceMappingURL=index.js.map
4552 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/notices/index.js
4553 -
4554 -
4555 -/**
4556 - * External dependencies
4557 - */
4558 -
4559 -/**
4560 - * WordPress dependencies
4561 - */
4562 -
4563 -
4564 -
4565 -
4566 -function EditNavigationNotices() {
4567 - const {
4568 - removeNotice
4569 - } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
4570 - const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
4571 - const dismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
4572 - isDismissible: true,
4573 - type: 'default'
4574 - });
4575 - const nonDismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
4576 - isDismissible: false,
4577 - type: 'default'
4578 - });
4579 - const snackbarNotices = (0,external_lodash_namespaceObject.filter)(notices, {
4580 - type: 'snackbar'
4581 - });
4582 - return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
4583 - notices: nonDismissibleNotices,
4584 - className: "edit-navigation-notices__notice-list"
4585 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
4586 - notices: dismissibleNotices,
4587 - className: "edit-navigation-notices__notice-list",
4588 - onRemove: removeNotice
4589 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SnackbarList, {
4590 - notices: snackbarNotices,
4591 - className: "edit-navigation-notices__snackbar-list",
4592 - onRemove: removeNotice
4593 - }));
4594 -}
4595 -//# sourceMappingURL=index.js.map
4596 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/editor/index.js
4597 -
4598 -
4599 -/**
4600 - * WordPress dependencies
4601 - */
4602 -
4603 -
4604 -function Editor(_ref) {
4605 - let {
4606 - isPending
4607 - } = _ref;
4608 - return (0,external_wp_element_namespaceObject.createElement)("div", {
4609 - className: "edit-navigation-editor"
4610 - }, isPending ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null) : (0,external_wp_element_namespaceObject.createElement)("div", {
4611 - className: "editor-styles-wrapper"
4612 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.WritingFlow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ObserveTyping, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockList, null)))));
4613 -}
4614 -//# sourceMappingURL=index.js.map
4615 -;// CONCATENATED MODULE: ./packages/icons/build-module/library/close.js
4616 -
4617 -
4618 -/**
4619 - * WordPress dependencies
4620 - */
4621 -
4622 -const close_close = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
4623 - xmlns: "http://www.w3.org/2000/svg",
4624 - viewBox: "0 0 24 24"
4625 -}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
4626 - d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
4627 -}));
4628 -/* harmony default export */ var library_close = (close_close);
4629 -//# sourceMappingURL=close.js.map
4630 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/inserter-sidebar/index.js
4631 -
4632 -
4633 -
4634 -/**
4635 - * WordPress dependencies
4636 - */
4637 -
4638 -
4639 -
4640 -
4641 -
4642 -/**
4643 - * Internal dependencies
4644 - */
4645 -
4646 -
4647 -
4648 -const SHOW_PREVIEWS = false;
4649 -
4650 -function InserterSidebar() {
4651 - const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
4652 - const {
4653 - navBlockClientId,
4654 - lastNavBlockItemIndex
4655 - } = use_navigation_editor_root_block();
4656 - const {
4657 - hasInserterItems,
4658 - selectedBlockClientId
4659 - } = (0,external_wp_data_namespaceObject.useSelect)(select => {
4660 - var _select$getSelectedBl;
4661 -
4662 - return {
4663 - hasInserterItems: select(external_wp_blockEditor_namespaceObject.store).hasInserterItems(navBlockClientId),
4664 - selectedBlockClientId: (_select$getSelectedBl = select(external_wp_blockEditor_namespaceObject.store).getSelectedBlock()) === null || _select$getSelectedBl === void 0 ? void 0 : _select$getSelectedBl.clientId
4665 - };
4666 - }, [navBlockClientId]);
4667 - const {
4668 - setIsInserterOpened
4669 - } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4670 - const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
4671 - onClose: () => setIsInserterOpened(false)
4672 - }); // Only concerned with whether there are items to display. If not then
4673 - // we shouldn't render.
4674 -
4675 - if (!hasInserterItems) {
4676 - return null;
4677 - }
4678 -
4679 - const shouldInsertInNavBlock = !selectedBlockClientId || navBlockClientId === selectedBlockClientId;
4680 - return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
4681 - ref: inserterDialogRef
4682 - }, inserterDialogProps, {
4683 - className: "edit-navigation-layout__inserter-panel"
4684 - }), (0,external_wp_element_namespaceObject.createElement)("div", {
4685 - className: "edit-navigation-layout__inserter-panel-header"
4686 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
4687 - icon: library_close,
4688 - onClick: () => setIsInserterOpened(false)
4689 - })), (0,external_wp_element_namespaceObject.createElement)("div", {
4690 - className: "edit-navigation-layout__inserter-panel-content"
4691 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLibrary // If the root Nav block is selected then any items inserted by the
4692 - // global inserter should append after the last nav item. Otherwise
4693 - // simply allow default Gutenberg behaviour.
4694 - , {
4695 - rootClientId: shouldInsertInNavBlock ? navBlockClientId : undefined // If set, insertion will be into the block with this ID.
4696 - ,
4697 - __experimentalInsertionIndex: // If set, insertion will be into this explicit position.
4698 - shouldInsertInNavBlock ? lastNavBlockItemIndex : undefined,
4699 - shouldFocusBlock: isMobileViewport,
4700 - showInserterHelpPanel: SHOW_PREVIEWS
4701 - })));
4702 -}
4703 -
4704 -/* harmony default export */ var inserter_sidebar = (InserterSidebar);
4705 -//# sourceMappingURL=index.js.map
4706 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/unsaved-changes-warning.js
4707 -/**
4708 - * WordPress dependencies
4709 - */
4710 -
4711 -
4712 -
4713 -
4714 -/**
4715 - * Warns the user if there are unsaved changes before leaving the editor.
4716 - *
4717 - * This is a duplicate of the component implemented in the editor package.
4718 - * Duplicated here as edit-navigation doesn't depend on editor.
4719 - *
4720 - * @return {WPComponent} The component.
4721 - */
4722 -
4723 -function UnsavedChangesWarning() {
4724 - const isDirty = (0,external_wp_data_namespaceObject.useSelect)(select => {
4725 - const {
4726 - __experimentalGetDirtyEntityRecords
4727 - } = select(external_wp_coreData_namespaceObject.store);
4728 -
4729 - const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
4730 -
4731 - return dirtyEntityRecords.length > 0;
4732 - }, []);
4733 - (0,external_wp_element_namespaceObject.useEffect)(() => {
4734 - /**
4735 - * Warns the user if there are unsaved changes before leaving the editor.
4736 - *
4737 - * @param {Event} event `beforeunload` event.
4738 - *
4739 - * @return {?string} Warning prompt message, if unsaved changes exist.
4740 - */
4741 - const warnIfUnsavedChanges = event => {
4742 - if (isDirty) {
4743 - event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
4744 - return event.returnValue;
4745 - }
4746 - };
4747 -
4748 - window.addEventListener('beforeunload', warnIfUnsavedChanges);
4749 - return () => {
4750 - window.removeEventListener('beforeunload', warnIfUnsavedChanges);
4751 - };
4752 - }, [isDirty]);
4753 - return null;
4754 -}
4755 -//# sourceMappingURL=unsaved-changes-warning.js.map
4756 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/components/layout/index.js
4757 -
4758 -
4759 -/**
4760 - * WordPress dependencies
4761 - */
4762 -
4763 -
4764 -
4765 -
4766 -
4767 -
4768 -
4769 -
4770 -
4771 -/**
4772 - * Internal dependencies
4773 - */
4774 -
4775 -
4776 -
4777 -
4778 -
4779 -
4780 -
4781 -
4782 -
4783 -
4784 -
4785 -
4786 -
4787 -const interfaceLabels = {
4788 - /* translators: accessibility text for the navigation screen top bar landmark region. */
4789 - header: (0,external_wp_i18n_namespaceObject.__)('Navigation top bar'),
4790 -
4791 - /* translators: accessibility text for the navigation screen content landmark region. */
4792 - body: (0,external_wp_i18n_namespaceObject.__)('Navigation menu blocks'),
4793 -
4794 - /* translators: accessibility text for the navigation screen settings landmark region. */
4795 - sidebar: (0,external_wp_i18n_namespaceObject.__)('Navigation settings'),
4796 - secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block library')
4797 -};
4798 -function Layout(_ref) {
4799 - let {
4800 - blockEditorSettings
4801 - } = _ref;
4802 - const contentAreaRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseBlockSelectionClearer)();
4803 - const [isMenuNameControlFocused, setIsMenuNameControlFocused] = (0,external_wp_element_namespaceObject.useState)(false);
4804 - const {
4805 - saveNavigationPost
4806 - } = (0,external_wp_data_namespaceObject.useDispatch)(store);
4807 -
4808 - const savePost = () => saveNavigationPost(navigationPost);
4809 -
4810 - const {
4811 - menus,
4812 - hasLoadedMenus,
4813 - hasFinishedInitialLoad,
4814 - selectedMenuId,
4815 - navigationPost,
4816 - isMenuBeingDeleted,
4817 - selectMenu,
4818 - deleteMenu,
4819 - isMenuSelected
4820 - } = useNavigationEditor();
4821 - const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)(NAVIGATION_POST_KIND, NAVIGATION_POST_POST_TYPE, {
4822 - id: navigationPost === null || navigationPost === void 0 ? void 0 : navigationPost.id
4823 - });
4824 - const {
4825 - hasSidebarEnabled,
4826 - isInserterOpened
4827 - } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
4828 - hasSidebarEnabled: !!select(store_store).getActiveComplementaryArea('core/edit-navigation'),
4829 - isInserterOpened: select(store).isInserterOpened()
4830 - }), []);
4831 - (0,external_wp_element_namespaceObject.useEffect)(() => {
4832 - if (!selectedMenuId && menus !== null && menus !== void 0 && menus.length) {
4833 - selectMenu(menus[0].id);
4834 - }
4835 - }, [selectedMenuId, menus]);
4836 - useMenuNotifications(selectedMenuId);
4837 - const hasMenus = !!(menus !== null && menus !== void 0 && menus.length);
4838 - const isBlockEditorReady = !!(hasMenus && navigationPost && isMenuSelected);
4839 - return (0,external_wp_element_namespaceObject.createElement)(error_boundary, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_keyboardShortcuts_namespaceObject.ShortcutProvider, null, (0,external_wp_element_namespaceObject.createElement)("div", {
4840 - hidden: !isMenuBeingDeleted,
4841 - className: 'edit-navigation-layout__overlay'
4842 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(shortcuts.Register, null), (0,external_wp_element_namespaceObject.createElement)(shortcuts, {
4843 - saveBlocks: savePost
4844 - }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
4845 - value: blocks,
4846 - onInput: onInput,
4847 - onChange: onChange,
4848 - settings: { ...blockEditorSettings,
4849 - templateLock: 'all'
4850 - },
4851 - useSubRegistry: false
4852 - }, (0,external_wp_element_namespaceObject.createElement)(IsMenuNameControlFocusedContext.Provider, {
4853 - value: (0,external_wp_element_namespaceObject.useMemo)(() => [isMenuNameControlFocused, setIsMenuNameControlFocused], [isMenuNameControlFocused])
4854 - }, (0,external_wp_element_namespaceObject.createElement)(interface_skeleton, {
4855 - className: "edit-navigation-layout",
4856 - labels: interfaceLabels,
4857 - header: (0,external_wp_element_namespaceObject.createElement)(Header, {
4858 - isMenuSelected: isMenuSelected,
4859 - isPending: !hasLoadedMenus,
4860 - menus: menus,
4861 - navigationPost: navigationPost
4862 - }),
4863 - content: (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(EditNavigationNotices, null), !hasFinishedInitialLoad && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null), !isMenuSelected && hasFinishedInitialLoad && (0,external_wp_element_namespaceObject.createElement)(UnselectedMenuState, {
4864 - onSelectMenu: selectMenu,
4865 - onCreate: selectMenu,
4866 - menus: menus
4867 - }), isBlockEditorReady && (0,external_wp_element_namespaceObject.createElement)("div", {
4868 - className: "edit-navigation-layout__content-area",
4869 - ref: contentAreaRef
4870 - }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockTools, null, (0,external_wp_element_namespaceObject.createElement)(Editor, {
4871 - isPending: !hasLoadedMenus
4872 - })))),
4873 - sidebar: hasSidebarEnabled && (0,external_wp_element_namespaceObject.createElement)(complementary_area.Slot, {
4874 - scope: "core/edit-navigation"
4875 - }),
4876 - secondarySidebar: isInserterOpened && (0,external_wp_element_namespaceObject.createElement)(inserter_sidebar, null)
4877 - }), isMenuSelected && (0,external_wp_element_namespaceObject.createElement)(Sidebar, {
4878 - menus: menus,
4879 - menuId: selectedMenuId,
4880 - onSelectMenu: selectMenu,
4881 - onDeleteMenu: deleteMenu,
4882 - isMenuBeingDeleted: isMenuBeingDeleted
4883 - })), (0,external_wp_element_namespaceObject.createElement)(UnsavedChangesWarning, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover.Slot, null), (0,external_wp_element_namespaceObject.createElement)(external_wp_plugins_namespaceObject.PluginArea, null))));
4884 -}
4885 -//# sourceMappingURL=index.js.map
4886 -;// CONCATENATED MODULE: external ["wp","url"]
4887 -var external_wp_url_namespaceObject = window["wp"]["url"];
4888 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/utils/index.js
4889 -/**
4890 - * WordPress dependencies
4891 - */
4892 -
4893 -/**
4894 - * The purpose of this function is to create a middleware that is responsible for preloading menu-related data.
4895 - * It uses data that is returned from the /wp/v2/menus endpoint for requests
4896 - * to the /wp/v2/menu/<menuId> endpoint, because the data is the same.
4897 - * This way, we can avoid making additional REST API requests.
4898 - * This middleware can be removed if/when we implement caching at the wordpress/core-data level.
4899 - *
4900 - * @param {Object} preloadedData
4901 - * @return {Function} Preloading middleware.
4902 - */
4903 -
4904 -function createMenuPreloadingMiddleware(preloadedData) {
4905 - const cache = Object.keys(preloadedData).reduce((result, path) => {
4906 - result[(0,external_wp_url_namespaceObject.normalizePath)(path)] = preloadedData[path];
4907 - return result;
4908 - },
4909 - /** @type {Record<string, any>} */
4910 - {});
4911 - let menusDataLoaded = false;
4912 - let menuDataLoaded = false;
4913 - return (options, next) => {
4914 - var _Object$keys, _cache$key;
4915 -
4916 - const {
4917 - parse = true
4918 - } = options;
4919 -
4920 - if ('string' !== typeof options.path) {
4921 - return next(options);
4922 - }
4923 -
4924 - const method = options.method || 'GET';
4925 -
4926 - if ('GET' !== method) {
4927 - return next(options);
4928 - }
4929 -
4930 - const path = (0,external_wp_url_namespaceObject.normalizePath)(options.path);
4931 -
4932 - if (!menusDataLoaded && cache[path]) {
4933 - menusDataLoaded = true;
4934 - return sendSuccessResponse(cache[path], parse);
4935 - }
4936 -
4937 - if (menuDataLoaded) {
4938 - return next(options);
4939 - }
4940 -
4941 - const matches = path.match(/^\/wp\/v2\/menus\/(\d+)\?context=edit$/);
4942 -
4943 - if (!matches) {
4944 - return next(options);
4945 - }
4946 -
4947 - const key = (_Object$keys = Object.keys(cache)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
4948 - const menuData = (_cache$key = cache[key]) === null || _cache$key === void 0 ? void 0 : _cache$key.body;
4949 -
4950 - if (!menuData) {
4951 - return next(options);
4952 - }
4953 -
4954 - const menuId = parseInt(matches[1]);
4955 - const menu = menuData.filter(_ref => {
4956 - let {
4957 - id
4958 - } = _ref;
4959 - return id === menuId;
4960 - });
4961 -
4962 - if (menu.length > 0) {
4963 - menuDataLoaded = true; // We don't have headers because we "emulate" this request
4964 -
4965 - return sendSuccessResponse({
4966 - body: menu[0],
4967 - headers: {}
4968 - }, parse);
4969 - }
4970 -
4971 - return next(options);
4972 - };
4973 -}
4974 -/**
4975 - * This is a helper function that sends a success response.
4976 - *
4977 - * @param {Object} responseData An object with the menu data
4978 - * @param {boolean} parse A boolean that controls whether to send a response or just the response data
4979 - * @return {Object} Resolved promise
4980 - */
4981 -
4982 -function sendSuccessResponse(responseData, parse) {
4983 - return Promise.resolve(parse ? responseData.body : new window.Response(JSON.stringify(responseData.body), {
4984 - status: 200,
4985 - statusText: 'OK',
4986 - headers: responseData.headers
4987 - }));
4988 -}
4989 -//# sourceMappingURL=index.js.map
4990 -;// CONCATENATED MODULE: ./packages/edit-navigation/build-module/index.js
4991 -
4992 -
4993 -/**
4994 - * WordPress dependencies
4995 - */
4996 -
4997 -
4998 -
4999 -
5000 -
5001 -
5002 -/**
5003 - * Internal dependencies
5004 - */
5005 -
5006 -
5007 -
5008 -
5009 -
5010 -
5011 -function NavEditor(_ref) {
5012 - let {
5013 - settings
5014 - } = _ref;
5015 - const {
5016 - setIsInserterOpened
5017 - } = (0,external_wp_data_namespaceObject.useDispatch)(store); // Allows the QuickInserter to toggle the sidebar inserter.
5018 - // This is marked as experimental to give time for the quick inserter to mature.
5019 -
5020 - const __experimentalSetIsInserterOpened = setIsInserterOpened; // Provide link suggestions handler to fetch search results for Link UI.
5021 -
5022 - const __experimentalFetchLinkSuggestions = (search, searchOptions) => {
5023 - // Bump the default number of suggestions.
5024 - // See https://github.com/WordPress/gutenberg/issues/34283.
5025 - searchOptions.perPage = 10;
5026 - return (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings);
5027 - };
5028 -
5029 - const editorSettings = (0,external_wp_element_namespaceObject.useMemo)(() => {
5030 - return { ...settings,
5031 - __experimentalFetchLinkSuggestions,
5032 - __experimentalSetIsInserterOpened,
5033 - __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData
5034 - };
5035 - }, [settings, __experimentalFetchLinkSuggestions, __experimentalSetIsInserterOpened]);
5036 - return (0,external_wp_element_namespaceObject.createElement)(Layout, {
5037 - blockEditorSettings: editorSettings
5038 - });
5039 -}
5040 -/**
5041 - * Setup and registration of editor.
5042 - *
5043 - * @param {Object} settings blockEditor settings.
5044 - */
5045 -
5046 -
5047 -function setUpEditor(settings) {
5048 - addFilters(!settings.blockNavMenus); // Set up the navigation post entity.
5049 -
5050 - (0,external_wp_data_namespaceObject.dispatch)(external_wp_coreData_namespaceObject.store).addEntities([{
5051 - kind: NAVIGATION_POST_KIND,
5052 - name: NAVIGATION_POST_POST_TYPE,
5053 - transientEdits: {
5054 - blocks: true,
5055 - selection: true
5056 - },
5057 - label: (0,external_wp_i18n_namespaceObject.__)('Navigation Post'),
5058 - __experimentalNoFetch: true
5059 - }]);
5060 -
5061 - (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).__experimentalReapplyBlockTypeFilters();
5062 -
5063 - (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)();
5064 -
5065 - if (true) {
5066 - (0,external_wp_blockLibrary_namespaceObject.__experimentalRegisterExperimentalCoreBlocks)();
5067 - }
5068 -}
5069 -/**
5070 - * Initalise and render editor into DOM.
5071 - *
5072 - * @param {string} id ID of HTML element into which the editor will be rendered.
5073 - * @param {Object} settings blockEditor settings.
5074 - */
5075 -
5076 -
5077 -function initialize(id, settings) {
5078 - setUpEditor(settings);
5079 - (0,external_wp_element_namespaceObject.render)((0,external_wp_element_namespaceObject.createElement)(NavEditor, {
5080 - settings: settings
5081 - }), document.getElementById(id));
5082 -}
5083 -
5084 -//# sourceMappingURL=index.js.map
5085 -}();
5086 -(window.wp = window.wp || {}).editNavigation = __webpack_exports__;
5087 -/******/ })()
5088 -;
1 +window.wp=window.wp||{},window.wp.editNavigation=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=530)}({0:function(e,t){e.exports=window.wp.element},1:function(e,t){e.exports=window.wp.i18n},10:function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}n.d(t,"a",(function(){return r}))},11:function(e,t){e.exports=window.wp.blocks},12:function(e,t,n){var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var c=typeof r;if("string"===c||"number"===c)e.push(r);else if(Array.isArray(r))e.push(o.apply(null,r));else if("object"===c)for(var i in r)n.call(r,i)&&r[i]&&e.push(i)}}return e.join(" ")}e.exports?e.exports=o:void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},13:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(48);function o(e,t){if(null==e)return{};var n,o,c=Object(r.a)(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)n=i[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(c[n]=e[n])}return c}},14:function(e,t){e.exports=window.wp.compose},15:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(24),o=n(42),c=n(30);function i(e){return function(e){if(Array.isArray(e))return Object(r.a)(e)}(e)||Object(o.a)(e)||Object(c.a)(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}},16:function(e,t){e.exports=window.regeneratorRuntime},19:function(e,t,n){"use strict";function r(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}n.d(t,"a",(function(){return r}))},2:function(e,t){e.exports=window.lodash},204:function(e,t,n){"use strict";var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),o=new Uint8Array(16);function c(){if(!r)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return r(o)}for(var i=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,a=function(e){return"string"==typeof e&&i.test(e)},u=[],s=0;s<256;++s)u.push((s+256).toString(16).substr(1));t.a=function(e,t,n){var r=(e=e||{}).random||(e.rng||c)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(u[e[t+0]]+u[e[t+1]]+u[e[t+2]]+u[e[t+3]]+"-"+u[e[t+4]]+u[e[t+5]]+"-"+u[e[t+6]]+u[e[t+7]]+"-"+u[e[t+8]]+u[e[t+9]]+"-"+u[e[t+10]]+u[e[t+11]]+u[e[t+12]]+u[e[t+13]]+u[e[t+14]]+u[e[t+15]]).toLowerCase();if(!a(n))throw TypeError("Stringified UUID is invalid");return n}(r)}},22:function(e,t,n){"use strict";function r(e){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}n.d(t,"a",(function(){return r}))},24:function(e,t,n){"use strict";function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}n.d(t,"a",(function(){return r}))},27:function(e,t){e.exports=window.wp.coreData},28:function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}n.d(t,"a",(function(){return r}))},29:function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}n.d(t,"a",(function(){return o}))},3:function(e,t){e.exports=window.wp.components},30:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(24);function o(e,t){if(e){if("string"==typeof e)return Object(r.a)(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Object(r.a)(e,t):void 0}}},31:function(e,t){e.exports=window.wp.url},32:function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(58);function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Object(r.a)(e,t)}},33:function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(43),o=n(19);function c(e,t){return!t||"object"!==Object(r.a)(t)&&"function"!=typeof t?Object(o.a)(e):t}},35:function(e,t){e.exports=window.wp.hooks},39:function(e,t,n){"use strict";function r(e){if(Array.isArray(e))return e}n.d(t,"a",(function(){return r}))},4:function(e,t){e.exports=window.wp.data},40:function(e,t,n){"use strict";function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}n.d(t,"a",(function(){return r}))},42:function(e,t,n){"use strict";function r(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}n.d(t,"a",(function(){return r}))},43:function(e,t,n){"use strict";function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}n.d(t,"a",(function(){return r}))},45:function(e,t,n){"use strict";function r(e,t,n,r,o,c,i){try{var a=e[c](i),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,c){var i=e.apply(t,n);function a(e){r(i,o,c,a,u,"next",e)}function u(e){r(i,o,c,a,u,"throw",e)}a(void 0)}))}}n.d(t,"a",(function(){return o}))},46:function(e,t){e.exports=window.wp.keyboardShortcuts},47:function(e,t){e.exports=window.wp.apiFetch},48:function(e,t,n){"use strict";function r(e,t){if(null==e)return{};var n,r,o={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}n.d(t,"a",(function(){return r}))},5:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},51:function(e,t){e.exports=window.wp.notices},530:function(e,t,n){"use strict";n.r(t),n.d(t,"initialize",(function(){return Ke}));var r={};n.r(r),n.d(r,"getNavigationPostForMenu",(function(){return te}));var o={};n.r(o),n.d(o,"getNavigationPostForMenu",(function(){return ie})),n.d(o,"hasResolvedNavigationPost",(function(){return ae})),n.d(o,"getMenuItemForClientId",(function(){return ue}));var c={};n.r(c),n.d(c,"createMissingMenuItems",(function(){return pe})),n.d(c,"saveNavigationPost",(function(){return be}));var i=n(10),a=n(5),u=n(0),s=n(2),l=n(77),f=n(14),p=n(1),b=n(47),d=n.n(b),O=n(31),m=n(71),v=n(35),j=n(8),y=n(12),g=n.n(y),h=n(3),_=n(4),E=n(6),w=n(16),S=n.n(w),P=n(45),I=n(51),k=function(e){return function(t){return t.name.toLowerCase()===e.toLowerCase()}};function x(e){var t=e.className,n=e.menus,r=e.onCreate,o=Object(u.useState)(""),c=Object(j.a)(o,2),i=c[0],a=c[1],l=Object(_.useDispatch)(I.store),f=l.createErrorNotice,b=l.createInfoNotice,d=Object(u.useState)(!1),O=Object(j.a)(d,2),m=O[0],v=O[1],y=Object(_.useDispatch)("core").saveMenu,E=function(){var e=Object(P.a)(S.a.mark((function e(t){var o,c;return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),i.length){e.next=3;break}return e.abrupt("return");case 3:if(!Object(s.some)(n,k(i))){e.next=7;break}return o=Object(p.sprintf)(// translators: %s: the name of a menu.
2 +Object(p.__)("The menu name %s conflicts with another menu name. Please try another."),i),f(o,{id:"edit-navigation-error"}),e.abrupt("return");case 7:return v(!0),e.next=10,y({name:i});case 10:(c=e.sent)&&(b(Object(p.__)("Menu created"),{type:"snackbar",isDismissible:!0}),r&&r(c.id)),v(!1);case 13:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),w=null==n?void 0:n.length,x=w?Object(p.__)("Create a new menu"):Object(p.__)("Create your first menu"),N=w?Object(p.__)("A short descriptive name for your menu."):Object(p.__)("A short descriptive name for your first menu.");return Object(u.createElement)("form",{className:g()("edit-navigation-add-menu",t),onSubmit:E},Object(u.createElement)("h3",{className:"edit-navigation-add-menu__title"},x),Object(u.createElement)(h.TextControl,{autoFocus:!0,label:Object(p.__)("Menu name"),value:i,onChange:a,help:N}),Object(u.createElement)(h.Button,{className:"edit-navigation-add-menu__create-menu-button",type:"submit",isPrimary:!0,disabled:!i.length,isBusy:m},Object(p.__)("Create menu")))}function N(){return Object(u.createElement)(h.Card,{className:"edit-navigation-empty-state"},Object(u.createElement)(h.CardBody,null,Object(u.createElement)(x,null)))}var C=n(15),T=n(13);function D(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function M(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?D(Object(n),!0).forEach((function(t){Object(a.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var R=Object(_.combineReducers)({mapping:function(e,t){var n=t.type,r=t.postId,o=Object(T.a)(t,["type","postId"]);return"SET_MENU_ITEM_TO_CLIENT_ID_MAPPING"===n?M(M({},e),{},Object(a.a)({},r,o.mapping)):e||{}},processingQueue:function(e,t){var n,r=t.type,o=t.postId,c=Object(T.a)(t,["type","postId"]);switch(r){case"START_PROCESSING_POST":return M(M({},e),{},Object(a.a)({},o,M(M({},e[o]),{},{inProgress:!0})));case"FINISH_PROCESSING_POST":return M(M({},e),{},Object(a.a)({},o,M(M({},e[o]),{},{inProgress:!1})));case"POP_PENDING_ACTION":var i,u=M({},e[o]);return"pendingActions"in u&&(u.pendingActions=null===(i=u.pendingActions)||void 0===i?void 0:i.filter((function(e){return e!==c.action}))),M(M({},e),{},Object(a.a)({},o,u));case"ENQUEUE_AFTER_PROCESSING":var s=(null===(n=e[o])||void 0===n?void 0:n.pendingActions)||[];if(!s.includes(c.action))return M(M({},e),{},Object(a.a)({},o,M(M({},e[o]),{},{pendingActions:[].concat(Object(C.a)(s),[c.action])})))}return e||{}}}),A=n(11);function B(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function L(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?B(Object(n),!0).forEach((function(t){Object(a.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):B(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var F=function(e){return"navigation-post-".concat(e)};function G(e){return{menus:e,per_page:-1}}function U(e){return S.a.mark((function t(n){var r,o,c;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=n.id,t.next=3,q(r);case 3:if(!t.sent){t.next=8;break}return t.next=7,{type:"ENQUEUE_AFTER_PROCESSING",postId:r,action:e};case 7:return t.abrupt("return",{status:"pending"});case 8:return t.next=10,{type:"POP_PENDING_ACTION",postId:r,action:e};case 10:return t.next=12,{type:"START_PROCESSING_POST",postId:r};case 12:return t.prev=12,t.t0=e,t.next=16,i=n.meta.menuId,{type:"SELECT",registryName:V,selectorName:"getNavigationPostForMenu",args:[i]};case 16:return t.t1=t.sent,t.delegateYield((0,t.t0)(t.t1),"t2",18);case 18:return t.prev=18,t.next=21,{type:"FINISH_PROCESSING_POST",postId:r,action:e};case 21:return t.next=23,H(r);case 23:if(!(o=t.sent).length){t.next=27;break}return c=U(o[0]),t.delegateYield(c(n),"t3",27);case 27:return t.finish(18);case 28:case"end":return t.stop()}var i}),t,null,[[12,,18,28]])}))}function z(e,t,n){var r=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t.flatMap((function(t,r){var o;return[{block:t,parentId:n,position:r+1}].concat(e(t.innerBlocks,null===(o=u(t))||void 0===o?void 0:o.id))}))}(e).map((function(e){return n=e.block,r=e.parentId,o=e.position,f=Object(s.omit)(u(n),"menus","meta"),c="core/navigation-link"===n.name?{type:"custom",title:null===(i=n.attributes)||void 0===i?void 0:i.label,original_title:"",url:n.attributes.url,description:n.attributes.description,xfn:null===(a=n.attributes.rel)||void 0===a?void 0:a.split(" "),classes:null===(l=n.attributes.className)||void 0===l?void 0:l.split(" "),attr_title:n.attributes.title}:{type:"block",content:Object(A.serialize)(n)},L(L(L({},f),c),{},{position:o,nav_menu_term_id:t,menu_item_parent:r,status:"publish",_invalid:!1});var n,r,o,c,i,a,l,f})),o=function(e){return"nav_menu_item[".concat(e.id,"]")},c=Object(s.keyBy)(r,o);for(var i in n){var a=o(n[i]);a in c||(c[a]=!1)}return JSON.stringify(c);function u(e){return Object(s.omit)(n[e.clientId]||{},"_links")}}var V="core/edit-navigation";function Q(e){return{type:"API_FETCH",request:e}}function H(e){return{type:"GET_PENDING_ACTIONS",postId:e}}function q(e){return{type:"IS_PROCESSING_POST",postId:e}}function $(e){return{type:"GET_MENU_ITEM_TO_CLIENT_ID_MAPPING",postId:e}}function Y(e){return{type:"RESOLVE_MENU_ITEMS",query:G(e)}}function J(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];return{type:"DISPATCH",registryName:e,actionName:t,args:r}}var K={API_FETCH:function(e){var t=e.request;return d()(t)},SELECT:Object(_.createRegistryControl)((function(e){return function(t){var n,r=t.registryName,o=t.selectorName,c=t.args;return(n=e.select(r))[o].apply(n,Object(C.a)(c))}})),GET_PENDING_ACTIONS:Object(_.createRegistryControl)((function(e){return function(t){var n,r=t.postId;return(null===(n=W(e).processingQueue[r])||void 0===n?void 0:n.pendingActions)||[]}})),IS_PROCESSING_POST:Object(_.createRegistryControl)((function(e){return function(t){var n,r=t.postId;return!(null===(n=W(e).processingQueue[r])||void 0===n||!n.inProgress)}})),GET_MENU_ITEM_TO_CLIENT_ID_MAPPING:Object(_.createRegistryControl)((function(e){return function(t){var n=t.postId;return W(e).mapping[n]||{}}})),DISPATCH:Object(_.createRegistryControl)((function(e){return function(t){var n,r=t.registryName,o=t.actionName,c=t.args;return(n=e.dispatch(r))[o].apply(n,Object(C.a)(c))}})),RESOLVE_MENU_ITEMS:Object(_.createRegistryControl)((function(e){return function(t){var n=t.query;return e.resolveSelect("core").getMenuItems(n)}}))},W=function(e){return e.stores[V].store.getState()},Z=K;function X(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var ee=S.a.mark(te);function te(e){var t,n,r,o,c,i,a;return S.a.wrap((function(u){for(;;)switch(u.prev=u.next){case 0:if(e){u.next=2;break}return u.abrupt("return");case 2:return t=ne(e),u.next=5,re(t);case 5:return n=["root","postType",t.id],u.next=8,J("core","startResolution","getEntityRecord",n);case 8:return u.next=10,Y(e);case 10:return r=u.sent,o=oe(r),c=Object(j.a)(o,2),i=c[0],a=c[1],u.next=14,{type:"SET_MENU_ITEM_TO_CLIENT_ID_MAPPING",postId:t.id,mapping:a};case 14:return u.next=16,re(ne(e,i));case 16:return u.next=18,J("core","finishResolution","getEntityRecord",n);case 18:case"end":return u.stop()}}),ee)}var ne=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=F(e);return{id:n,slug:n,status:"draft",type:"page",blocks:t?[t]:[],meta:{menuId:e}}},re=function(e){return J("core","receiveEntityRecords","root","postType",e,{id:e.id},!1)};function oe(e){var t=Object(s.groupBy)(e,"parent"),n={},r=function e(r){var o=[];if(r){var c,i=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return X(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?X(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,i=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,c=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw c}}}}(Object(s.sortBy)(r,"menu_order"));try{for(i.s();!(c=i.n()).done;){var a,u=c.value,l=[];null!==(a=t[u.id])&&void 0!==a&&a.length&&(l=e(t[u.id]));var f=ce(u,l);n[u.id]=f.clientId,o.push(f)}}catch(e){i.e(e)}finally{i.f()}return o}}(t[0]||[]);return[Object(A.createBlock)("core/navigation",{orientation:"vertical"},r),n]}function ce(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if("block"===e.type){var n=Object(A.parse)(e.content.raw),r=Object(j.a)(n,1),o=r[0];return o?Object(A.createBlock)(o.name,o.attributes,t):Object(A.createBlock)("core/freeform",{originalContent:e.content.raw})}var c={label:e.title.rendered,url:e.url,title:e.attr_title,className:e.classes.join(" "),description:e.description,rel:e.xfn.join(" ")};return Object(A.createBlock)("core/navigation-link",c,t)}var ie=Object(_.createRegistrySelector)((function(e){return function(t,n){return ae(t,n)?e("core").getEditedEntityRecord("root","postType",F(n)):null}})),ae=Object(_.createRegistrySelector)((function(e){return function(t,n){return e("core").hasFinishedResolution("getEntityRecord",["root","postType",F(n)])}})),ue=Object(_.createRegistrySelector)((function(e){return function(t,n,r){var o=Object(s.invert)(t.mapping[n]);return e("core").getMenuItem(o[r])}})),se=n(204),le=S.a.mark(Oe);function fe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var pe=U(S.a.mark((function e(t){var n,r,o,c,i,a,u;return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.meta.menuId,e.next=3,$(t.id);case 3:r=e.sent,o=Object(s.invert)(r),c=[t.blocks[0]];case 6:if(!c.length){e.next=21;break}if((i=c.pop()).clientId in o){e.next=18;break}return e.next=11,Q({path:"/__experimental/menu-items",method:"POST",data:{title:"Placeholder",url:"Placeholder",menu_order:0}});case 11:return a=e.sent,r[a.id]=i.clientId,e.next=15,Y(n);case 15:return u=e.sent,e.next=18,J("core","receiveEntityRecords","root","menuItem",[].concat(Object(C.a)(u),[a]),G(n),!1);case 18:c.push.apply(c,Object(C.a)(i.innerBlocks)),e.next=6;break;case 21:return e.next=23,{type:"SET_MENU_ITEM_TO_CLIENT_ID_MAPPING",postId:t.id,mapping:r};case 23:case"end":return e.stop()}}),e)}))),be=U(S.a.mark((function e(t){var n,r;return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.meta.menuId,e.t0=de,e.next=4,Y(n);case 4:return e.t1=e.sent,e.next=7,$(t.id);case 7:return e.t2=e.sent,r=(0,e.t0)(e.t1,e.t2),e.prev=9,e.delegateYield(Oe(n,r,t.blocks[0]),"t3",11);case 11:if(e.t3.success){e.next=14;break}throw new Error;case 14:return e.next=16,J(I.store,"createSuccessNotice",Object(p.__)("Navigation saved."),{type:"snackbar"});case 16:e.next=22;break;case 18:return e.prev=18,e.t4=e.catch(9),e.next=22,J(I.store,"createErrorNotice",Object(p.__)("There was an error."),{type:"snackbar"});case 22:case"end":return e.stop()}}),e,null,[[9,18]])})));function de(e,t){var n={};if(!e||!t)return n;var r,o=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return fe(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?fe(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var c,i=!0,a=!1;return{s:function(){n=e[Symbol.iterator]()},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,c=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw c}}}}(e);try{for(o.s();!(r=o.n()).done;){var c=r.value,i=t[c.id];i&&(n[i]=c)}}catch(e){o.e(e)}finally{o.f()}return n}function Oe(e,t,n){var r,o,c,i;return S.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,Q({path:"/__experimental/customizer-nonces/get-save-nonce"});case 2:if(r=a.sent,o=r.nonce,c=r.stylesheet,o){a.next=7;break}throw new Error;case 7:return(i=new FormData).append("wp_customize","on"),i.append("customize_theme",c),i.append("nonce",o),i.append("customize_changeset_uuid",Object(se.a)()),i.append("customize_autosaved","on"),i.append("customize_changeset_status","publish"),i.append("action","customize_save"),i.append("customized",z(n.innerBlocks,e,t)),a.next=18,Q({url:"/wp-admin/admin-ajax.php",method:"POST",body:i});case 18:return a.abrupt("return",a.sent);case 19:case"end":return a.stop()}}),le)}var me={reducer:R,controls:Z,selectors:o,resolvers:r,actions:c},ve=Object(_.createReduxStore)(V,me);Object(_.register)(ve);var je=n(27),ye=n(28),ge=n(29),he=n(19),_e=n(32),Ee=n(33),we=n(22);var Se=function(e){Object(_e.a)(o,e);var t,n,r=(t=o,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,r=Object(we.a)(t);if(n){var o=Object(we.a)(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return Object(Ee.a)(this,e)});function o(){var e;return Object(ye.a)(this,o),(e=r.apply(this,arguments)).reboot=e.reboot.bind(Object(he.a)(e)),e.state={error:null},e}return Object(ge.a)(o,[{key:"componentDidCatch",value:function(e){this.setState({error:e})}},{key:"reboot",value:function(){this.props.onError&&this.props.onError()}},{key:"render",value:function(){return this.state.error?Object(u.createElement)(E.Warning,{className:"navigation-editor-error-boundary",actions:[Object(u.createElement)(h.Button,{key:"recovery",onClick:this.reboot,isSecondary:!0},Object(p.__)("Attempt Recovery"))]},Object(p.__)("The navigation editor has encountered an unexpected error.")):this.props.children}}]),o}(u.Component),Pe=n(46);function Ie(e){var t=e.saveBlocks;Object(Pe.useShortcut)("core/edit-navigation/save-menu",Object(u.useCallback)((function(e){e.preventDefault(),t()})),{bindGlobal:!0});var n=Object(_.useDispatch)("core"),r=n.redo,o=n.undo;return Object(Pe.useShortcut)("core/edit-navigation/undo",(function(e){o(),e.preventDefault()}),{bindGlobal:!0}),Object(Pe.useShortcut)("core/edit-navigation/redo",(function(e){r(),e.preventDefault()}),{bindGlobal:!0}),null}Ie.Register=function(){var e=Object(_.useDispatch)(Pe.store).registerShortcut;return Object(u.useEffect)((function(){e({name:"core/edit-navigation/save-menu",category:"global",description:Object(p.__)("Save the navigation currently being edited."),keyCombination:{modifier:"primary",character:"s"}}),e({name:"core/edit-navigation/undo",category:"global",description:Object(p.__)("Undo your last changes."),keyCombination:{modifier:"primary",character:"z"}}),e({name:"core/edit-navigation/redo",category:"global",description:Object(p.__)("Redo your last undo."),keyCombination:{modifier:"primaryShift",character:"z"}})}),[e]),null};var ke=Ie;function xe(e){var t=e.navigationPost,n=Object(_.useDispatch)(ve).saveNavigationPost;return Object(u.createElement)(h.Button,{className:"edit-navigation-toolbar__save-button",isPrimary:!0,onClick:function(){n(t)},disabled:!t},Object(p.__)("Save"))}function Ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ce(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ne(Object(n),!0).forEach((function(t){Object(a.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ne(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Te(){var e=Object(_.useSelect)((function(e){return e("core").getMenus()}),[]),t=function(){var e=Object(u.useState)(null),t=Object(j.a)(e,2),n=t[0],r=t[1];Object(u.useEffect)((function(){var e=!0;return function(){var t=Object(P.a)(S.a.mark((function t(){var n;return S.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d()({method:"GET",path:"/__experimental/menu-locations"});case 2:n=t.sent,e&&r(n);case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}()(),function(){return e=!1}}),[]);var o=Object(_.useDispatch)("core").saveMenu,c=Object(u.useCallback)(function(){var e=Object(P.a)(S.a.mark((function e(t,c){var i,u,s;return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n[t].menu,u=Ce(Ce({},n),{},Object(a.a)({},t,Ce(Ce({},n[t]),{},{menu:c}))),r(u),s=[],i&&s.push(o({id:i,locations:Object.values(u).filter((function(e){return e.menu===i})).map((function(e){return e.name}))})),c&&s.push(o({id:c,locations:Object.values(u).filter((function(e){return e.menu===c})).map((function(e){return e.name}))})),e.next=8,Promise.all(s);case 8:case"end":return e.stop()}}),e)})));return function(_x,t){return e.apply(this,arguments)}}(),[n]);return[Object(u.useMemo)((function(){return n?Object.values(n):null}),[n]),c]}(),n=Object(j.a)(t,2),r=n[0],o=n[1];return e&&r?e.length?r.length?r.map((function(t){return Object(u.createElement)(h.SelectControl,{key:t.name,label:t.description,labelPosition:"top",value:t.menu,options:[{value:0,label:Object(p.__)("-")}].concat(Object(C.a)(e.map((function(e){return{value:e.id,label:e.name}})))),onChange:function(e){o(t.name,Number(e))}})})):Object(u.createElement)("p",null,Object(p.__)("There are no available menu locations.")):Object(u.createElement)("p",null,Object(p.__)("There are no available menus.")):Object(u.createElement)(h.Spinner,null)}function De(e){var t,n=e.menus,r=e.selectedMenuId,o=e.onSelectMenu,c=e.isPending,i=e.navigationPost,a=Object(s.find)(n,{id:r}),l=a?a.name:void 0;t=l?Object(p.sprintf)(// translators: Name of the menu being edited, e.g. 'Main Menu'.
3 +Object(p.__)("Editing: %s"),l):c?Object(p.__)("Loading …"):Object(p.__)("No menus available");var f=!(null==n||!n.length);return Object(u.createElement)("div",{className:"edit-navigation-header"},Object(u.createElement)("div",{className:"edit-navigation-header__title-subtitle"},Object(u.createElement)("h1",{className:"edit-navigation-header__title"},Object(p.__)("Navigation")),Object(u.createElement)("h2",{className:"edit-navigation-header__subtitle"},f&&t)),f&&Object(u.createElement)("div",{className:"edit-navigation-header__actions"},Object(u.createElement)(h.DropdownMenu,{icon:null,toggleProps:{showTooltip:!1,children:Object(p.__)("Select menu"),isTertiary:!0,disabled:!(null!=n&&n.length),__experimentalIsFocusable:!0},popoverProps:{position:"bottom left"}},(function(){return Object(u.createElement)(h.MenuGroup,null,Object(u.createElement)(h.MenuItemsChoice,{value:r,onSelect:o,choices:n.map((function(e){return{value:e.id,label:e.name}}))}))})),Object(u.createElement)(h.Dropdown,{position:"bottom left",renderToggle:function(e){var t=e.isOpen,n=e.onToggle;return Object(u.createElement)(h.Button,{isTertiary:!0,"aria-expanded":t,onClick:n},Object(p.__)("Add new"))},renderContent:function(){return Object(u.createElement)(x,{className:"edit-navigation-header__add-menu",menus:n,onCreate:o})}}),Object(u.createElement)(h.Dropdown,{contentClassName:"edit-navigation-header__manage-locations",position:"bottom left",renderToggle:function(e){var t=e.isOpen,n=e.onToggle;return Object(u.createElement)(h.Button,{isTertiary:!0,"aria-expanded":t,onClick:n},Object(p.__)("Manage locations"))},renderContent:function(){return Object(u.createElement)(Te,null)}}),Object(u.createElement)(xe,{navigationPost:i}),Object(u.createElement)(h.Popover.Slot,{name:"block-toolbar"})))}function Me(){var e=Object(_.useDispatch)(I.store).removeNotice,t=Object(_.useSelect)((function(e){return e(I.store).getNotices()}),[]),n=Object(s.filter)(t,{isDismissible:!0,type:"default"}),r=Object(s.filter)(t,{isDismissible:!1,type:"default"}),o=Object(s.filter)(t,{type:"snackbar"});return Object(u.createElement)(u.Fragment,null,Object(u.createElement)(h.NoticeList,{notices:r,className:"edit-navigation-notices__notice-list"}),Object(u.createElement)(h.NoticeList,{notices:n,className:"edit-navigation-notices__notice-list",onRemove:e}),Object(u.createElement)(h.SnackbarList,{notices:o,className:"edit-navigation-notices__snackbar-list",onRemove:e}))}function Re(e){var t=e.isPending;return Object(u.createElement)("div",{className:"edit-navigation-editor"},t?Object(u.createElement)(h.Spinner,null):Object(u.createElement)("div",{className:"editor-styles-wrapper"},Object(u.createElement)(E.WritingFlow,null,Object(u.createElement)(E.ObserveTyping,null,Object(u.createElement)(E.BlockList,null)))))}function Ae(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Be(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ae(Object(n),!0).forEach((function(t){Object(a.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ae(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Le(e){var t=e.menuId,n=Object(_.useSelect)((function(e){return e("core").getMenu(t)}),[t]),r=Object(u.useState)(null),o=Object(j.a)(r,2),c=o[0],i=o[1];Object(u.useEffect)((function(){null===c&&n&&i(n.auto_add)}),[c,n]);var a=Object(_.useDispatch)("core").saveMenu;return Object(u.createElement)(h.PanelBody,null,Object(u.createElement)(h.CheckboxControl,{label:Object(p.__)("Automatically add new top-level pages"),checked:null!=c&&c,onChange:function(e){i(e),a(Be(Be({},n),{},{auto_add:e}))}}))}function Fe(e){var t=e.onDeleteMenu;return Object(u.createElement)(h.PanelBody,{className:"edit-navigation-inspector-additions__delete-menu-panel"},Object(u.createElement)(h.Button,{isLink:!0,isDestructive:!0,onClick:function(){window.confirm(Object(p.__)("Are you sure you want to delete this navigation?"))&&t()}},Object(p.__)("Delete menu")))}function Ge(e){var t=e.menuId,n=e.onDeleteMenu,r=Object(_.useSelect)((function(e){return e("core/block-editor").getSelectedBlock()}),[]);return"core/navigation"!==(null==r?void 0:r.name)?null:Object(u.createElement)(E.InspectorControls,null,Object(u.createElement)(Le,{menuId:t}),Object(u.createElement)(Fe,{onDeleteMenu:n}))}function Ue(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ze(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ue(Object(n),!0).forEach((function(t){Object(a.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ue(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ve(e){var t,n,r,o,c,i,a=e.blockEditorSettings,s=Object(E.__unstableUseBlockSelectionClearer)(),l=Object(_.useDispatch)(ve).saveNavigationPost,f=function(){var e=Object(u.useState)(!1),t=Object(j.a)(e,2),n=t[0],r=t[1],o=Object(_.useSelect)((function(e){var t=e("core"),n={per_page:-1};return{menus:t.getMenus(n),hasLoadedMenus:t.hasFinishedResolution("getMenus",[n])}}),[]),c=o.menus,i=o.hasLoadedMenus;Object(u.useEffect)((function(){i&&r(!0)}),[i]);var a=Object(u.useState)(null),s=Object(j.a)(a,2),l=s[0],f=s[1];Object(u.useEffect)((function(){!l&&null!=c&&c.length&&f(c[0].id)}),[l,c]);var p=Object(_.useSelect)((function(e){if(l)return e(ve).getNavigationPostForMenu(l)}),[l]),b=Object(_.useDispatch)("core").deleteMenu;return{menus:c,hasLoadedMenus:i,hasFinishedInitialLoad:n,selectedMenuId:l,navigationPost:p,selectMenu:function(e){f(e)},deleteMenu:function(){var e=Object(P.a)(S.a.mark((function e(){return S.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,b(l,{force:!0});case 2:e.sent&&f(null);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()}}(),p=f.menus,b=f.hasLoadedMenus,d=f.hasFinishedInitialLoad,O=f.selectedMenuId,m=f.navigationPost,v=f.selectMenu,y=f.deleteMenu,w=function(e){var t=Object(_.useDispatch)(ve).createMissingMenuItems,n=Object(je.useEntityBlockEditor)("root","postType",{id:null==e?void 0:e.id}),r=Object(j.a)(n,3),o=r[0],c=r[1],i=r[2];return[o,c,Object(u.useCallback)(Object(P.a)(S.a.mark((function n(){var r=arguments;return S.a.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,i.apply(void 0,r);case 2:t(e);case 3:case"end":return n.stop()}}),n)}))),[i,e])]}(m),k=Object(j.a)(w,3),x=k[0],C=k[1],T=k[2];t=O,n=Object(_.useSelect)((function(e){return{lastSaveError:e("core").getLastEntitySaveError("root","menu"),lastDeleteError:e("core").getLastEntityDeleteError("root","menu",t)}}),[t]),r=n.lastSaveError,o=n.lastDeleteError,c=Object(_.useDispatch)(I.store).createErrorNotice,i=function(e){var t=(new window.DOMParser).parseFromString(e.message,"text/html").body.textContent||"";c(t,{id:"edit-navigation-error"})},Object(u.useEffect)((function(){r&&i(r)}),[r]),Object(u.useEffect)((function(){o&&i(o)}),[o]);var D=!(null==p||!p.length),M=!(!D||!m);return Object(u.createElement)(Se,null,Object(u.createElement)(h.SlotFillProvider,null,Object(u.createElement)(h.DropZoneProvider,null,Object(u.createElement)(E.BlockEditorKeyboardShortcuts.Register,null),Object(u.createElement)(ke.Register,null),Object(u.createElement)(Me,null),Object(u.createElement)("div",{className:g()("edit-navigation-layout",{"has-block-inspector":M})},Object(u.createElement)(De,{isPending:!b,menus:p,selectedMenuId:O,onSelectMenu:v,navigationPost:m}),!d&&Object(u.createElement)(h.Spinner,null),d&&!D&&Object(u.createElement)(N,null),M&&Object(u.createElement)(E.BlockEditorProvider,{value:x,onInput:C,onChange:T,settings:ze(ze({},a),{},{templateLock:"all"}),useSubRegistry:!1},Object(u.createElement)(E.BlockEditorKeyboardShortcuts,null),Object(u.createElement)(ke,{saveBlocks:function(){return l(m)}}),Object(u.createElement)("div",{className:"edit-navigation-layout__canvas",ref:s},Object(u.createElement)(Re,{isPending:!b,blocks:x})),Object(u.createElement)(Ge,{menuId:O,onDeleteMenu:y}),Object(u.createElement)(E.BlockInspector,{bubblesVirtually:!1}))),Object(u.createElement)(h.Popover.Slot,null))))}function Qe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function He(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qe(Object(n),!0).forEach((function(t){Object(a.a)(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qe(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function qe(e,t){return["core/navigation","core/navigation-link"].includes(t)||Object(s.set)(e,["supports","inserter"],!1),e}function $e(e,t){return"core/navigation"!==t?e:He(He({},e),{},{supports:{customClassName:!1,html:!1,inserter:!0},variations:void 0})}var Ye=Object(f.createHigherOrderComponent)((function(e){return function(t){return"core/navigation"!==t.name?Object(u.createElement)(e,t):Object(u.createElement)(e,Object(i.a)({},t,{hasSubmenuIndicatorSetting:!1,hasItemJustificationControls:!1,hasListViewModal:!1}))}}),"removeNavigationBlockEditUnsupportedFeatures"),Je=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.isInitialSuggestions,r=t.type,o=t.subtype,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=c.disablePostFormats,a=void 0!==i&&i,u=n?3:20,l=[];return r&&"post"!==r||l.push(d()({path:Object(O.addQueryArgs)("/wp/v2/search",{search:e,per_page:u,type:"post",subtype:o})}).catch((function(){return[]}))),r&&"term"!==r||l.push(d()({path:Object(O.addQueryArgs)("/wp/v2/search",{search:e,per_page:u,type:"term",subtype:o})}).catch((function(){return[]}))),a||r&&"post-format"!==r||l.push(d()({path:Object(O.addQueryArgs)("/wp/v2/search",{search:e,per_page:u,type:"post-format",subtype:o})}).catch((function(){return[]}))),Promise.all(l).then((function(e){return Object(s.map)(Object(s.flatten)(e).slice(0,u),(function(e){return{id:e.id,url:e.url,title:Object(m.decodeEntities)(e.title)||Object(p.__)("(no title)"),type:e.subtype||e.type}}))}))};function Ke(e,t){t.blockNavMenus||Object(v.addFilter)("blocks.registerBlockType","core/edit-navigation/disable-inserting-non-navigation-blocks",qe),Object(v.addFilter)("blocks.registerBlockType","core/edit-navigation/remove-navigation-block-settings-unsupported-features",$e),Object(v.addFilter)("editor.BlockEdit","core/edit-navigation/remove-navigation-block-edit-unsupported-features",Ye),Object(l.registerCoreBlocks)(),Object(l.__experimentalRegisterExperimentalCoreBlocks)(),t.__experimentalFetchLinkSuggestions=Object(s.partialRight)(Je,t),Object(u.render)(Object(u.createElement)(Ve,{blockEditorSettings:t}),document.getElementById(e))}},58:function(e,t,n){"use strict";function r(e,t){return(r=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}n.d(t,"a",(function(){return r}))},6:function(e,t){e.exports=window.wp.blockEditor},71:function(e,t){e.exports=window.wp.htmlEntities},77:function(e,t){e.exports=window.wp.blockLibrary},8:function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(39),o=n(30),c=n(40);function i(e,t){return Object(r.a)(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var n=[],_n=!0,r=!1,o=void 0;try{for(var c,i=e[Symbol.iterator]();!(_n=(c=i.next()).done)&&(n.push(c.value),!t||n.length!==t);_n=!0);}catch(e){r=!0,o=e}finally{try{_n||null==i.return||i.return()}finally{if(r)throw o}}return n}}(e,t)||Object(o.a)(e,t)||Object(c.a)()}}});