PluginProbe
Gutenberg / 23.6.2
Gutenberg v23.6.2
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 7.4.0 All 402 releases
gutenberg / build / scripts / edit-widgets / index.js

index.js in Gutenberg 23.6.2, at build/scripts/edit-widgets/index.js

4,680 lines 178.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var wp;
2 (wp ||= {}).editWidgets = (() => {
3 var __create = Object.create;
4 var __defProp = Object.defineProperty;
5 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6 var __getOwnPropNames = Object.getOwnPropertyNames;
7 var __getProtoOf = Object.getPrototypeOf;
8 var __hasOwnProp = Object.prototype.hasOwnProperty;
9 var __commonJS = (cb, mod) => function __require() {
10 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11 };
12 var __export = (target, all) => {
13 for (var name2 in all)
14 __defProp(target, name2, { get: all[name2], enumerable: true });
15 };
16 var __copyProps = (to, from, except, desc) => {
17 if (from && typeof from === "object" || typeof from === "function") {
18 for (let key of __getOwnPropNames(from))
19 if (!__hasOwnProp.call(to, key) && key !== except)
20 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21 }
22 return to;
23 };
24 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25 // If the importer is in node compatibility mode or this is not an ESM
26 // file that has been converted to a CommonJS file using a Babel-
27 // compatible transform (i.e. "__esModule" has not been set), then set
28 // "default" to the CommonJS "module.exports" for node compatibility.
29 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30 mod
31 ));
32 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
34 // package-external:@wordpress/blocks
35 var require_blocks = __commonJS({
36 "package-external:@wordpress/blocks"(exports, module) {
37 module.exports = window.wp.blocks;
38 }
39 });
40
41 // package-external:@wordpress/data
42 var require_data = __commonJS({
43 "package-external:@wordpress/data"(exports, module) {
44 module.exports = window.wp.data;
45 }
46 });
47
48 // package-external:@wordpress/deprecated
49 var require_deprecated = __commonJS({
50 "package-external:@wordpress/deprecated"(exports, module) {
51 module.exports = window.wp.deprecated;
52 }
53 });
54
55 // package-external:@wordpress/element
56 var require_element = __commonJS({
57 "package-external:@wordpress/element"(exports, module) {
58 module.exports = window.wp.element;
59 }
60 });
61
62 // package-external:@wordpress/block-library
63 var require_block_library = __commonJS({
64 "package-external:@wordpress/block-library"(exports, module) {
65 module.exports = window.wp.blockLibrary;
66 }
67 });
68
69 // package-external:@wordpress/core-data
70 var require_core_data = __commonJS({
71 "package-external:@wordpress/core-data"(exports, module) {
72 module.exports = window.wp.coreData;
73 }
74 });
75
76 // package-external:@wordpress/widgets
77 var require_widgets = __commonJS({
78 "package-external:@wordpress/widgets"(exports, module) {
79 module.exports = window.wp.widgets;
80 }
81 });
82
83 // package-external:@wordpress/preferences
84 var require_preferences = __commonJS({
85 "package-external:@wordpress/preferences"(exports, module) {
86 module.exports = window.wp.preferences;
87 }
88 });
89
90 // package-external:@wordpress/api-fetch
91 var require_api_fetch = __commonJS({
92 "package-external:@wordpress/api-fetch"(exports, module) {
93 module.exports = window.wp.apiFetch;
94 }
95 });
96
97 // package-external:@wordpress/i18n
98 var require_i18n = __commonJS({
99 "package-external:@wordpress/i18n"(exports, module) {
100 module.exports = window.wp.i18n;
101 }
102 });
103
104 // package-external:@wordpress/notices
105 var require_notices = __commonJS({
106 "package-external:@wordpress/notices"(exports, module) {
107 module.exports = window.wp.notices;
108 }
109 });
110
111 // package-external:@wordpress/components
112 var require_components = __commonJS({
113 "package-external:@wordpress/components"(exports, module) {
114 module.exports = window.wp.components;
115 }
116 });
117
118 // package-external:@wordpress/primitives
119 var require_primitives = __commonJS({
120 "package-external:@wordpress/primitives"(exports, module) {
121 module.exports = window.wp.primitives;
122 }
123 });
124
125 // vendor-external:react/jsx-runtime
126 var require_jsx_runtime = __commonJS({
127 "vendor-external:react/jsx-runtime"(exports, module) {
128 module.exports = window.ReactJSXRuntime;
129 }
130 });
131
132 // package-external:@wordpress/viewport
133 var require_viewport = __commonJS({
134 "package-external:@wordpress/viewport"(exports, module) {
135 module.exports = window.wp.viewport;
136 }
137 });
138
139 // package-external:@wordpress/compose
140 var require_compose = __commonJS({
141 "package-external:@wordpress/compose"(exports, module) {
142 module.exports = window.wp.compose;
143 }
144 });
145
146 // package-external:@wordpress/plugins
147 var require_plugins = __commonJS({
148 "package-external:@wordpress/plugins"(exports, module) {
149 module.exports = window.wp.plugins;
150 }
151 });
152
153 // vendor-external:react
154 var require_react = __commonJS({
155 "vendor-external:react"(exports, module) {
156 module.exports = window.React;
157 }
158 });
159
160 // package-external:@wordpress/theme
161 var require_theme = __commonJS({
162 "package-external:@wordpress/theme"(exports, module) {
163 module.exports = window.wp.theme;
164 }
165 });
166
167 // package-external:@wordpress/private-apis
168 var require_private_apis = __commonJS({
169 "package-external:@wordpress/private-apis"(exports, module) {
170 module.exports = window.wp.privateApis;
171 }
172 });
173
174 // package-external:@wordpress/block-editor
175 var require_block_editor = __commonJS({
176 "package-external:@wordpress/block-editor"(exports, module) {
177 module.exports = window.wp.blockEditor;
178 }
179 });
180
181 // package-external:@wordpress/hooks
182 var require_hooks = __commonJS({
183 "package-external:@wordpress/hooks"(exports, module) {
184 module.exports = window.wp.hooks;
185 }
186 });
187
188 // package-external:@wordpress/media-utils
189 var require_media_utils = __commonJS({
190 "package-external:@wordpress/media-utils"(exports, module) {
191 module.exports = window.wp.mediaUtils;
192 }
193 });
194
195 // package-external:@wordpress/patterns
196 var require_patterns = __commonJS({
197 "package-external:@wordpress/patterns"(exports, module) {
198 module.exports = window.wp.patterns;
199 }
200 });
201
202 // package-external:@wordpress/keyboard-shortcuts
203 var require_keyboard_shortcuts = __commonJS({
204 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
205 module.exports = window.wp.keyboardShortcuts;
206 }
207 });
208
209 // package-external:@wordpress/keycodes
210 var require_keycodes = __commonJS({
211 "package-external:@wordpress/keycodes"(exports, module) {
212 module.exports = window.wp.keycodes;
213 }
214 });
215
216 // package-external:@wordpress/url
217 var require_url = __commonJS({
218 "package-external:@wordpress/url"(exports, module) {
219 module.exports = window.wp.url;
220 }
221 });
222
223 // package-external:@wordpress/dom
224 var require_dom = __commonJS({
225 "package-external:@wordpress/dom"(exports, module) {
226 module.exports = window.wp.dom;
227 }
228 });
229
230 // packages/edit-widgets/build-module/index.mjs
231 var index_exports = {};
232 __export(index_exports, {
233 initialize: () => initialize,
234 initializeEditor: () => initializeEditor,
235 reinitializeEditor: () => reinitializeEditor,
236 store: () => store2
237 });
238 var import_blocks3 = __toESM(require_blocks(), 1);
239 var import_data32 = __toESM(require_data(), 1);
240 var import_deprecated6 = __toESM(require_deprecated(), 1);
241 var import_element26 = __toESM(require_element(), 1);
242 var import_block_library2 = __toESM(require_block_library(), 1);
243 var import_core_data12 = __toESM(require_core_data(), 1);
244 var import_widgets5 = __toESM(require_widgets(), 1);
245 var import_preferences10 = __toESM(require_preferences(), 1);
246
247 // packages/edit-widgets/build-module/store/index.mjs
248 var import_api_fetch = __toESM(require_api_fetch(), 1);
249 var import_data8 = __toESM(require_data(), 1);
250
251 // packages/edit-widgets/build-module/store/reducer.mjs
252 var import_data = __toESM(require_data(), 1);
253 function widgetAreasOpenState(state = {}, action) {
254 const { type } = action;
255 switch (type) {
256 case "SET_WIDGET_AREAS_OPEN_STATE": {
257 return action.widgetAreasOpenState;
258 }
259 case "SET_IS_WIDGET_AREA_OPEN": {
260 const { clientId, isOpen } = action;
261 return {
262 ...state,
263 [clientId]: isOpen
264 };
265 }
266 default: {
267 return state;
268 }
269 }
270 }
271 function blockInserterPanel(state = false, action) {
272 switch (action.type) {
273 case "SET_IS_LIST_VIEW_OPENED":
274 return action.isOpen ? false : state;
275 case "SET_IS_INSERTER_OPENED":
276 return action.value;
277 }
278 return state;
279 }
280 function listViewPanel(state = false, action) {
281 switch (action.type) {
282 case "SET_IS_INSERTER_OPENED":
283 return action.value ? false : state;
284 case "SET_IS_LIST_VIEW_OPENED":
285 return action.isOpen;
286 }
287 return state;
288 }
289 function listViewToggleRef(state = { current: null }) {
290 return state;
291 }
292 function inserterSidebarToggleRef(state = { current: null }) {
293 return state;
294 }
295 function widgetSavingLock(state = {}, action) {
296 switch (action.type) {
297 case "LOCK_WIDGET_SAVING":
298 return { ...state, [action.lockName]: true };
299 case "UNLOCK_WIDGET_SAVING": {
300 const { [action.lockName]: removedLockName, ...restState } = state;
301 return restState;
302 }
303 }
304 return state;
305 }
306 var reducer_default = (0, import_data.combineReducers)({
307 blockInserterPanel,
308 inserterSidebarToggleRef,
309 listViewPanel,
310 listViewToggleRef,
311 widgetAreasOpenState,
312 widgetSavingLock
313 });
314
315 // packages/edit-widgets/build-module/store/resolvers.mjs
316 var resolvers_exports = {};
317 __export(resolvers_exports, {
318 getWidgetAreas: () => getWidgetAreas,
319 getWidgets: () => getWidgets
320 });
321 var import_blocks2 = __toESM(require_blocks(), 1);
322 var import_core_data2 = __toESM(require_core_data(), 1);
323
324 // packages/edit-widgets/build-module/store/actions.mjs
325 var actions_exports2 = {};
326 __export(actions_exports2, {
327 closeGeneralSidebar: () => closeGeneralSidebar,
328 lockWidgetSaving: () => lockWidgetSaving,
329 moveBlockToWidgetArea: () => moveBlockToWidgetArea,
330 persistStubPost: () => persistStubPost,
331 saveEditedWidgetAreas: () => saveEditedWidgetAreas,
332 saveWidgetArea: () => saveWidgetArea,
333 saveWidgetAreas: () => saveWidgetAreas,
334 setIsInserterOpened: () => setIsInserterOpened,
335 setIsListViewOpened: () => setIsListViewOpened,
336 setIsWidgetAreaOpen: () => setIsWidgetAreaOpen,
337 setWidgetAreasOpenState: () => setWidgetAreasOpenState,
338 setWidgetIdForClientId: () => setWidgetIdForClientId,
339 unlockWidgetSaving: () => unlockWidgetSaving
340 });
341 var import_i18n3 = __toESM(require_i18n(), 1);
342 var import_notices = __toESM(require_notices(), 1);
343
344 // node_modules/clsx/dist/clsx.mjs
345 function r(e) {
346 var t, f, n = "";
347 if ("string" == typeof e || "number" == typeof e) n += e;
348 else if ("object" == typeof e) if (Array.isArray(e)) {
349 var o = e.length;
350 for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
351 } else for (f in e) e[f] && (n && (n += " "), n += f);
352 return n;
353 }
354 function clsx() {
355 for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
356 return n;
357 }
358 var clsx_default = clsx;
359
360 // packages/interface/build-module/components/complementary-area/index.mjs
361 var import_components5 = __toESM(require_components(), 1);
362 var import_data6 = __toESM(require_data(), 1);
363 var import_i18n = __toESM(require_i18n(), 1);
364
365 // packages/icons/build-module/library/block-default.mjs
366 var import_primitives = __toESM(require_primitives(), 1);
367 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
368 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) });
369
370 // packages/icons/build-module/library/check.mjs
371 var import_primitives2 = __toESM(require_primitives(), 1);
372 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
373 var check_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
374
375 // packages/icons/build-module/library/close-small.mjs
376 var import_primitives3 = __toESM(require_primitives(), 1);
377 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
378 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { 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" }) });
379
380 // packages/icons/build-module/library/drawer-left.mjs
381 var import_primitives4 = __toESM(require_primitives(), 1);
382 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
383 var drawer_left_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" }) });
384
385 // packages/icons/build-module/library/drawer-right.mjs
386 var import_primitives5 = __toESM(require_primitives(), 1);
387 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
388 var drawer_right_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z" }) });
389
390 // packages/icons/build-module/library/external.mjs
391 var import_primitives6 = __toESM(require_primitives(), 1);
392 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
393 var external_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) });
394
395 // packages/icons/build-module/library/list-view.mjs
396 var import_primitives7 = __toESM(require_primitives(), 1);
397 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
398 var list_view_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" }) });
399
400 // packages/icons/build-module/library/more-vertical.mjs
401 var import_primitives8 = __toESM(require_primitives(), 1);
402 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
403 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
404
405 // packages/icons/build-module/library/plus.mjs
406 var import_primitives9 = __toESM(require_primitives(), 1);
407 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
408 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) });
409
410 // packages/icons/build-module/library/redo.mjs
411 var import_primitives10 = __toESM(require_primitives(), 1);
412 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
413 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { 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" }) });
414
415 // packages/icons/build-module/library/star-empty.mjs
416 var import_primitives11 = __toESM(require_primitives(), 1);
417 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
418 var star_empty_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", 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" }) });
419
420 // packages/icons/build-module/library/star-filled.mjs
421 var import_primitives12 = __toESM(require_primitives(), 1);
422 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
423 var star_filled_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { 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" }) });
424
425 // packages/icons/build-module/library/undo.mjs
426 var import_primitives13 = __toESM(require_primitives(), 1);
427 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
428 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { 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" }) });
429
430 // packages/interface/build-module/components/complementary-area/index.mjs
431 var import_element2 = __toESM(require_element(), 1);
432 var import_viewport = __toESM(require_viewport(), 1);
433 var import_preferences3 = __toESM(require_preferences(), 1);
434 var import_compose = __toESM(require_compose(), 1);
435 var import_plugins2 = __toESM(require_plugins(), 1);
436
437 // packages/interface/build-module/components/complementary-area-toggle/index.mjs
438 var import_components = __toESM(require_components(), 1);
439 var import_data5 = __toESM(require_data(), 1);
440 var import_plugins = __toESM(require_plugins(), 1);
441
442 // packages/interface/build-module/store/index.mjs
443 var import_data4 = __toESM(require_data(), 1);
444
445 // packages/interface/build-module/store/actions.mjs
446 var actions_exports = {};
447 __export(actions_exports, {
448 closeModal: () => closeModal,
449 disableComplementaryArea: () => disableComplementaryArea,
450 enableComplementaryArea: () => enableComplementaryArea,
451 openModal: () => openModal,
452 pinItem: () => pinItem,
453 setDefaultComplementaryArea: () => setDefaultComplementaryArea,
454 setFeatureDefaults: () => setFeatureDefaults,
455 setFeatureValue: () => setFeatureValue,
456 toggleFeature: () => toggleFeature,
457 unpinItem: () => unpinItem
458 });
459 var import_deprecated2 = __toESM(require_deprecated(), 1);
460 var import_preferences = __toESM(require_preferences(), 1);
461
462 // packages/interface/build-module/store/deprecated.mjs
463 var import_deprecated = __toESM(require_deprecated(), 1);
464 function normalizeComplementaryAreaScope(scope) {
465 if (["core/edit-post", "core/edit-site"].includes(scope)) {
466 (0, import_deprecated.default)(`${scope} interface scope`, {
467 alternative: "core interface scope",
468 hint: "core/edit-post and core/edit-site are merging.",
469 version: "6.6"
470 });
471 return "core";
472 }
473 return scope;
474 }
475 function normalizeComplementaryAreaName(scope, name2) {
476 if (scope === "core" && name2 === "edit-site/template") {
477 (0, import_deprecated.default)(`edit-site/template sidebar`, {
478 alternative: "edit-post/document",
479 version: "6.6"
480 });
481 return "edit-post/document";
482 }
483 if (scope === "core" && name2 === "edit-site/block-inspector") {
484 (0, import_deprecated.default)(`edit-site/block-inspector sidebar`, {
485 alternative: "edit-post/block",
486 version: "6.6"
487 });
488 return "edit-post/block";
489 }
490 return name2;
491 }
492
493 // packages/interface/build-module/store/actions.mjs
494 var setDefaultComplementaryArea = (scope, area) => {
495 scope = normalizeComplementaryAreaScope(scope);
496 area = normalizeComplementaryAreaName(scope, area);
497 return {
498 type: "SET_DEFAULT_COMPLEMENTARY_AREA",
499 scope,
500 area
501 };
502 };
503 var enableComplementaryArea = (scope, area) => ({ registry, dispatch: dispatch2 }) => {
504 if (!area) {
505 return;
506 }
507 scope = normalizeComplementaryAreaScope(scope);
508 area = normalizeComplementaryAreaName(scope, area);
509 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible");
510 if (!isComplementaryAreaVisible) {
511 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", true);
512 }
513 dispatch2({
514 type: "ENABLE_COMPLEMENTARY_AREA",
515 scope,
516 area
517 });
518 };
519 var disableComplementaryArea = (scope) => ({ registry }) => {
520 scope = normalizeComplementaryAreaScope(scope);
521 const isComplementaryAreaVisible = registry.select(import_preferences.store).get(scope, "isComplementaryAreaVisible");
522 if (isComplementaryAreaVisible) {
523 registry.dispatch(import_preferences.store).set(scope, "isComplementaryAreaVisible", false);
524 }
525 };
526 var pinItem = (scope, item) => ({ registry }) => {
527 if (!item) {
528 return;
529 }
530 scope = normalizeComplementaryAreaScope(scope);
531 item = normalizeComplementaryAreaName(scope, item);
532 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems");
533 if (pinnedItems?.[item] === true) {
534 return;
535 }
536 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", {
537 ...pinnedItems,
538 [item]: true
539 });
540 };
541 var unpinItem = (scope, item) => ({ registry }) => {
542 if (!item) {
543 return;
544 }
545 scope = normalizeComplementaryAreaScope(scope);
546 item = normalizeComplementaryAreaName(scope, item);
547 const pinnedItems = registry.select(import_preferences.store).get(scope, "pinnedItems");
548 registry.dispatch(import_preferences.store).set(scope, "pinnedItems", {
549 ...pinnedItems,
550 [item]: false
551 });
552 };
553 function toggleFeature(scope, featureName) {
554 return function({ registry }) {
555 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).toggleFeature`, {
556 since: "6.0",
557 alternative: `dispatch( 'core/preferences' ).toggle`
558 });
559 registry.dispatch(import_preferences.store).toggle(scope, featureName);
560 };
561 }
562 function setFeatureValue(scope, featureName, value) {
563 return function({ registry }) {
564 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureValue`, {
565 since: "6.0",
566 alternative: `dispatch( 'core/preferences' ).set`
567 });
568 registry.dispatch(import_preferences.store).set(scope, featureName, !!value);
569 };
570 }
571 function setFeatureDefaults(scope, defaults) {
572 return function({ registry }) {
573 (0, import_deprecated2.default)(`dispatch( 'core/interface' ).setFeatureDefaults`, {
574 since: "6.0",
575 alternative: `dispatch( 'core/preferences' ).setDefaults`
576 });
577 registry.dispatch(import_preferences.store).setDefaults(scope, defaults);
578 };
579 }
580 function openModal(name2) {
581 return {
582 type: "OPEN_MODAL",
583 name: name2
584 };
585 }
586 function closeModal() {
587 return {
588 type: "CLOSE_MODAL"
589 };
590 }
591
592 // packages/interface/build-module/store/selectors.mjs
593 var selectors_exports = {};
594 __export(selectors_exports, {
595 getActiveComplementaryArea: () => getActiveComplementaryArea,
596 isComplementaryAreaLoading: () => isComplementaryAreaLoading,
597 isFeatureActive: () => isFeatureActive,
598 isItemPinned: () => isItemPinned,
599 isModalActive: () => isModalActive
600 });
601 var import_data2 = __toESM(require_data(), 1);
602 var import_deprecated4 = __toESM(require_deprecated(), 1);
603 var import_preferences2 = __toESM(require_preferences(), 1);
604 var getActiveComplementaryArea = (0, import_data2.createRegistrySelector)(
605 (select) => (state, scope) => {
606 scope = normalizeComplementaryAreaScope(scope);
607 const isComplementaryAreaVisible = select(import_preferences2.store).get(
608 scope,
609 "isComplementaryAreaVisible"
610 );
611 if (isComplementaryAreaVisible === void 0) {
612 return void 0;
613 }
614 if (isComplementaryAreaVisible === false) {
615 return null;
616 }
617 return state?.complementaryAreas?.[scope];
618 }
619 );
620 var isComplementaryAreaLoading = (0, import_data2.createRegistrySelector)(
621 (select) => (state, scope) => {
622 scope = normalizeComplementaryAreaScope(scope);
623 const isVisible = select(import_preferences2.store).get(
624 scope,
625 "isComplementaryAreaVisible"
626 );
627 const identifier = state?.complementaryAreas?.[scope];
628 return isVisible && identifier === void 0;
629 }
630 );
631 var isItemPinned = (0, import_data2.createRegistrySelector)(
632 (select) => (state, scope, item) => {
633 scope = normalizeComplementaryAreaScope(scope);
634 item = normalizeComplementaryAreaName(scope, item);
635 const pinnedItems = select(import_preferences2.store).get(
636 scope,
637 "pinnedItems"
638 );
639 return pinnedItems?.[item] ?? true;
640 }
641 );
642 var isFeatureActive = (0, import_data2.createRegistrySelector)(
643 (select) => (state, scope, featureName) => {
644 (0, import_deprecated4.default)(
645 `select( 'core/interface' ).isFeatureActive( scope, featureName )`,
646 {
647 since: "6.0",
648 alternative: `select( 'core/preferences' ).get( scope, featureName )`
649 }
650 );
651 return !!select(import_preferences2.store).get(scope, featureName);
652 }
653 );
654 function isModalActive(state, modalName) {
655 return state.activeModal === modalName;
656 }
657
658 // packages/interface/build-module/store/reducer.mjs
659 var import_data3 = __toESM(require_data(), 1);
660 function complementaryAreas(state = {}, action) {
661 switch (action.type) {
662 case "SET_DEFAULT_COMPLEMENTARY_AREA": {
663 const { scope, area } = action;
664 if (state[scope]) {
665 return state;
666 }
667 return {
668 ...state,
669 [scope]: area
670 };
671 }
672 case "ENABLE_COMPLEMENTARY_AREA": {
673 const { scope, area } = action;
674 return {
675 ...state,
676 [scope]: area
677 };
678 }
679 }
680 return state;
681 }
682 function activeModal(state = null, action) {
683 switch (action.type) {
684 case "OPEN_MODAL":
685 return action.name;
686 case "CLOSE_MODAL":
687 return null;
688 }
689 return state;
690 }
691 var reducer_default2 = (0, import_data3.combineReducers)({
692 complementaryAreas,
693 activeModal
694 });
695
696 // packages/interface/build-module/store/constants.mjs
697 var STORE_NAME = "core/interface";
698
699 // packages/interface/build-module/store/index.mjs
700 var store = (0, import_data4.createReduxStore)(STORE_NAME, {
701 reducer: reducer_default2,
702 actions: actions_exports,
703 selectors: selectors_exports
704 });
705 (0, import_data4.register)(store);
706
707 // packages/interface/build-module/components/complementary-area-toggle/index.mjs
708 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
709 function roleSupportsCheckedState(role) {
710 return [
711 "checkbox",
712 "option",
713 "radio",
714 "switch",
715 "menuitemcheckbox",
716 "menuitemradio",
717 "treeitem"
718 ].includes(role);
719 }
720 function ComplementaryAreaToggle({
721 as = import_components.Button,
722 scope,
723 identifier: identifierProp,
724 icon: iconProp,
725 selectedIcon,
726 name: name2,
727 shortcut,
728 ...props
729 }) {
730 const ComponentToUse = as;
731 const context = (0, import_plugins.usePluginContext)();
732 const icon = iconProp || context.icon;
733 const identifier = identifierProp || `${context.name}/${name2}`;
734 const isSelected = (0, import_data5.useSelect)(
735 (select) => select(store).getActiveComplementaryArea(scope) === identifier,
736 [identifier, scope]
737 );
738 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data5.useDispatch)(store);
739 return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
740 ComponentToUse,
741 {
742 icon: selectedIcon && isSelected ? selectedIcon : icon,
743 "aria-controls": identifier.replace("/", ":"),
744 "aria-checked": roleSupportsCheckedState(props.role) ? isSelected : void 0,
745 onClick: () => {
746 if (isSelected) {
747 disableComplementaryArea2(scope);
748 } else {
749 enableComplementaryArea2(scope, identifier);
750 }
751 },
752 shortcut,
753 ...props
754 }
755 );
756 }
757
758 // packages/interface/build-module/components/complementary-area-header/index.mjs
759 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
760 var ComplementaryAreaHeader = ({
761 children,
762 className,
763 toggleButtonProps
764 }) => {
765 const toggleButton = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ComplementaryAreaToggle, { icon: close_small_default, ...toggleButtonProps });
766 return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
767 "div",
768 {
769 className: clsx_default(
770 "components-panel__header",
771 "interface-complementary-area-header",
772 className
773 ),
774 tabIndex: -1,
775 children: [
776 children,
777 toggleButton
778 ]
779 }
780 );
781 };
782 var complementary_area_header_default = ComplementaryAreaHeader;
783
784 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
785 var import_components3 = __toESM(require_components(), 1);
786
787 // packages/interface/build-module/components/action-item/index.mjs
788 var import_components2 = __toESM(require_components(), 1);
789 var import_element = __toESM(require_element(), 1);
790 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
791 var noop = () => {
792 };
793 function ActionItemSlot({
794 name: name2,
795 as: Component2 = import_components2.MenuGroup,
796 fillProps = {},
797 bubblesVirtually,
798 ...props
799 }) {
800 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
801 import_components2.Slot,
802 {
803 name: name2,
804 bubblesVirtually,
805 fillProps,
806 children: (fills) => {
807 if (!import_element.Children.toArray(fills).length) {
808 return null;
809 }
810 const initializedByPlugins = [];
811 import_element.Children.forEach(
812 fills,
813 ({
814 props: { __unstableExplicitMenuItem, __unstableTarget }
815 }) => {
816 if (__unstableTarget && __unstableExplicitMenuItem) {
817 initializedByPlugins.push(__unstableTarget);
818 }
819 }
820 );
821 const children = import_element.Children.map(fills, (child) => {
822 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(
823 child.props.__unstableTarget
824 )) {
825 return null;
826 }
827 return child;
828 });
829 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Component2, { ...props, children });
830 }
831 }
832 );
833 }
834 function ActionItem({ name: name2, as: Component2 = import_components2.Button, onClick, ...props }) {
835 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components2.Fill, { name: name2, children: ({ onClick: fpOnClick }) => {
836 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
837 Component2,
838 {
839 onClick: onClick || fpOnClick ? (...args) => {
840 (onClick || noop)(...args);
841 (fpOnClick || noop)(...args);
842 } : void 0,
843 ...props
844 }
845 );
846 } });
847 }
848 ActionItem.Slot = ActionItemSlot;
849 var action_item_default = ActionItem;
850
851 // packages/interface/build-module/components/complementary-area-more-menu-item/index.mjs
852 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
853 var PluginsMenuItem = ({
854 // Menu item is marked with unstable prop for backward compatibility.
855 // They are removed so they don't leak to DOM elements.
856 // @see https://github.com/WordPress/gutenberg/issues/14457
857 __unstableExplicitMenuItem,
858 __unstableTarget,
859 ...restProps
860 }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_components3.MenuItem, { ...restProps });
861 function ComplementaryAreaMoreMenuItem({
862 scope,
863 target,
864 __unstableExplicitMenuItem,
865 ...props
866 }) {
867 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
868 ComplementaryAreaToggle,
869 {
870 as: (toggleProps) => {
871 return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
872 action_item_default,
873 {
874 __unstableExplicitMenuItem,
875 __unstableTarget: `${scope}/${target}`,
876 as: PluginsMenuItem,
877 name: `${scope}/plugin-more-menu`,
878 ...toggleProps
879 }
880 );
881 },
882 role: "menuitemcheckbox",
883 selectedIcon: check_default,
884 name: target,
885 scope,
886 ...props
887 }
888 );
889 }
890
891 // packages/interface/build-module/components/pinned-items/index.mjs
892 var import_components4 = __toESM(require_components(), 1);
893 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
894 function PinnedItems({ scope, ...props }) {
895 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components4.Fill, { name: `PinnedItems/${scope}`, ...props });
896 }
897 function PinnedItemsSlot({ scope, className, ...props }) {
898 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_components4.Slot, { name: `PinnedItems/${scope}`, ...props, children: (fills) => fills?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
899 "div",
900 {
901 className: clsx_default(
902 className,
903 "interface-pinned-items"
904 ),
905 children: fills
906 }
907 ) });
908 }
909 PinnedItems.Slot = PinnedItemsSlot;
910 var pinned_items_default = PinnedItems;
911
912 // packages/interface/build-module/components/complementary-area/index.mjs
913 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
914 var ANIMATION_DURATION = 0.3;
915 function ComplementaryAreaSlot({ scope, ...props }) {
916 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Slot, { name: `ComplementaryArea/${scope}`, ...props });
917 }
918 var SIDEBAR_WIDTH = 280;
919 var variants = {
920 open: { width: SIDEBAR_WIDTH },
921 closed: { width: 0 },
922 mobileOpen: { width: "100vw" }
923 };
924 function ComplementaryAreaFill({
925 activeArea,
926 isActive,
927 scope,
928 children,
929 className,
930 id
931 }) {
932 const disableMotion = (0, import_compose.useReducedMotion)();
933 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
934 const previousActiveArea = (0, import_compose.usePrevious)(activeArea);
935 const previousIsActive = (0, import_compose.usePrevious)(isActive);
936 const [, setState] = (0, import_element2.useState)({});
937 (0, import_element2.useEffect)(() => {
938 setState({});
939 }, [isActive]);
940 const transition = {
941 type: "tween",
942 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
943 ease: [0.6, 0, 0.4, 1]
944 };
945 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Fill, { name: `ComplementaryArea/${scope}`, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.__unstableAnimatePresence, { initial: false, children: (previousIsActive || isActive) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
946 import_components5.__unstableMotion.div,
947 {
948 variants,
949 initial: "closed",
950 animate: isMobileViewport ? "mobileOpen" : "open",
951 exit: "closed",
952 transition,
953 className: "interface-complementary-area__fill",
954 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
955 "div",
956 {
957 id,
958 className,
959 style: {
960 width: isMobileViewport ? "100vw" : SIDEBAR_WIDTH
961 },
962 children
963 }
964 )
965 }
966 ) }) });
967 }
968 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
969 const previousIsSmallRef = (0, import_element2.useRef)(false);
970 const shouldOpenWhenNotSmallRef = (0, import_element2.useRef)(false);
971 const { enableComplementaryArea: enableComplementaryArea2, disableComplementaryArea: disableComplementaryArea2 } = (0, import_data6.useDispatch)(store);
972 (0, import_element2.useEffect)(() => {
973 if (isActive && isSmall && !previousIsSmallRef.current) {
974 disableComplementaryArea2(scope);
975 shouldOpenWhenNotSmallRef.current = true;
976 } else if (
977 // If there is a flag indicating the complementary area should be
978 // enabled when we go from small to big window size and we are going
979 // from a small to big window size.
980 shouldOpenWhenNotSmallRef.current && !isSmall && previousIsSmallRef.current
981 ) {
982 shouldOpenWhenNotSmallRef.current = false;
983 enableComplementaryArea2(scope, identifier);
984 } else if (
985 // If the flag is indicating the current complementary should be
986 // reopened but another complementary area becomes active, remove
987 // the flag.
988 shouldOpenWhenNotSmallRef.current && activeArea && activeArea !== identifier
989 ) {
990 shouldOpenWhenNotSmallRef.current = false;
991 }
992 if (isSmall !== previousIsSmallRef.current) {
993 previousIsSmallRef.current = isSmall;
994 }
995 }, [
996 isActive,
997 isSmall,
998 scope,
999 identifier,
1000 activeArea,
1001 disableComplementaryArea2,
1002 enableComplementaryArea2
1003 ]);
1004 }
1005 function ComplementaryArea({
1006 children,
1007 className,
1008 closeLabel = (0, import_i18n.__)("Close plugin"),
1009 identifier: identifierProp,
1010 header,
1011 headerClassName,
1012 icon: iconProp,
1013 isPinnable = true,
1014 panelClassName,
1015 scope,
1016 name: name2,
1017 title,
1018 toggleShortcut,
1019 isActiveByDefault
1020 }) {
1021 const context = (0, import_plugins2.usePluginContext)();
1022 const icon = iconProp || context.icon;
1023 const identifier = identifierProp || `${context.name}/${name2}`;
1024 const [isReady, setIsReady] = (0, import_element2.useState)(false);
1025 const {
1026 isLoading,
1027 isActive,
1028 isPinned,
1029 activeArea,
1030 isSmall,
1031 isLarge,
1032 showIconLabels
1033 } = (0, import_data6.useSelect)(
1034 (select) => {
1035 const {
1036 getActiveComplementaryArea: getActiveComplementaryArea2,
1037 isComplementaryAreaLoading: isComplementaryAreaLoading2,
1038 isItemPinned: isItemPinned2
1039 } = select(store);
1040 const { get } = select(import_preferences3.store);
1041 const _activeArea = getActiveComplementaryArea2(scope);
1042 return {
1043 isLoading: isComplementaryAreaLoading2(scope),
1044 isActive: _activeArea === identifier,
1045 isPinned: isItemPinned2(scope, identifier),
1046 activeArea: _activeArea,
1047 isSmall: select(import_viewport.store).isViewportMatch("< medium"),
1048 isLarge: select(import_viewport.store).isViewportMatch("large"),
1049 showIconLabels: get("core", "showIconLabels")
1050 };
1051 },
1052 [identifier, scope]
1053 );
1054 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
1055 useAdjustComplementaryListener(
1056 scope,
1057 identifier,
1058 activeArea,
1059 isActive,
1060 isSmall
1061 );
1062 const {
1063 enableComplementaryArea: enableComplementaryArea2,
1064 disableComplementaryArea: disableComplementaryArea2,
1065 pinItem: pinItem2,
1066 unpinItem: unpinItem2
1067 } = (0, import_data6.useDispatch)(store);
1068 (0, import_element2.useEffect)(() => {
1069 if (isActiveByDefault && activeArea === void 0 && !isSmall) {
1070 enableComplementaryArea2(scope, identifier);
1071 } else if (activeArea === void 0 && isSmall) {
1072 disableComplementaryArea2(scope, identifier);
1073 }
1074 setIsReady(true);
1075 }, [
1076 activeArea,
1077 isActiveByDefault,
1078 scope,
1079 identifier,
1080 isSmall,
1081 enableComplementaryArea2,
1082 disableComplementaryArea2
1083 ]);
1084 if (!isReady) {
1085 return;
1086 }
1087 return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1088 isPinnable && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(pinned_items_default, { scope, children: isPinned && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1089 ComplementaryAreaToggle,
1090 {
1091 scope,
1092 identifier,
1093 isPressed: isActive && (!showIconLabels || isLarge),
1094 "aria-expanded": isActive,
1095 "aria-disabled": isLoading,
1096 label: title,
1097 icon: showIconLabels ? check_default : icon,
1098 showTooltip: !showIconLabels,
1099 variant: showIconLabels ? "tertiary" : void 0,
1100 size: "compact",
1101 shortcut: toggleShortcut
1102 }
1103 ) }),
1104 name2 && isPinnable && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1105 ComplementaryAreaMoreMenuItem,
1106 {
1107 target: name2,
1108 scope,
1109 icon,
1110 identifier,
1111 children: title
1112 }
1113 ),
1114 /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1115 ComplementaryAreaFill,
1116 {
1117 activeArea,
1118 isActive,
1119 className: clsx_default("interface-complementary-area", className),
1120 scope,
1121 id: identifier.replace("/", ":"),
1122 children: [
1123 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1124 complementary_area_header_default,
1125 {
1126 className: headerClassName,
1127 closeLabel,
1128 onClose: () => disableComplementaryArea2(scope),
1129 toggleButtonProps: {
1130 label: closeLabel,
1131 size: "compact",
1132 shortcut: toggleShortcut,
1133 scope,
1134 identifier
1135 },
1136 children: header || /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1137 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "interface-complementary-area-header__title", children: title }),
1138 isPinnable && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1139 import_components5.Button,
1140 {
1141 className: "interface-complementary-area__pin-unpin-item",
1142 icon: isPinned ? star_filled_default : star_empty_default,
1143 label: isPinned ? (0, import_i18n.__)("Unpin from toolbar") : (0, import_i18n.__)("Pin to toolbar"),
1144 onClick: () => (isPinned ? unpinItem2 : pinItem2)(
1145 scope,
1146 identifier
1147 ),
1148 isPressed: isPinned,
1149 "aria-expanded": isPinned,
1150 size: "compact"
1151 }
1152 )
1153 ] })
1154 }
1155 ),
1156 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_components5.Panel, { className: panelClassName, children })
1157 ]
1158 }
1159 )
1160 ] });
1161 }
1162 ComplementaryArea.Slot = ComplementaryAreaSlot;
1163 var complementary_area_default = ComplementaryArea;
1164
1165 // node_modules/@base-ui/utils/useRefWithInit.mjs
1166 var React = __toESM(require_react(), 1);
1167 var UNINITIALIZED = {};
1168 function useRefWithInit(init, initArg) {
1169 const ref = React.useRef(UNINITIALIZED);
1170 if (ref.current === UNINITIALIZED) {
1171 ref.current = init(initArg);
1172 }
1173 return ref;
1174 }
1175
1176 // node_modules/@base-ui/utils/warn.mjs
1177 var set;
1178 if (true) {
1179 set = /* @__PURE__ */ new Set();
1180 }
1181 function warn(...messages) {
1182 if (true) {
1183 const messageKey = messages.join(" ");
1184 if (!set.has(messageKey)) {
1185 set.add(messageKey);
1186 console.warn(`Base UI: ${messageKey}`);
1187 }
1188 }
1189 }
1190
1191 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1192 var React4 = __toESM(require_react(), 1);
1193
1194 // node_modules/@base-ui/utils/useMergedRefs.mjs
1195 function useMergedRefs(a, b, c, d) {
1196 const forkRef = useRefWithInit(createForkRef).current;
1197 if (didChange(forkRef, a, b, c, d)) {
1198 update(forkRef, [a, b, c, d]);
1199 }
1200 return forkRef.callback;
1201 }
1202 function useMergedRefsN(refs) {
1203 const forkRef = useRefWithInit(createForkRef).current;
1204 if (didChangeN(forkRef, refs)) {
1205 update(forkRef, refs);
1206 }
1207 return forkRef.callback;
1208 }
1209 function createForkRef() {
1210 return {
1211 callback: null,
1212 cleanup: null,
1213 refs: []
1214 };
1215 }
1216 function didChange(forkRef, a, b, c, d) {
1217 return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
1218 }
1219 function didChangeN(forkRef, newRefs) {
1220 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1221 }
1222 function update(forkRef, refs) {
1223 forkRef.refs = refs;
1224 if (refs.every((ref) => ref == null)) {
1225 forkRef.callback = null;
1226 return;
1227 }
1228 forkRef.callback = (instance) => {
1229 if (forkRef.cleanup) {
1230 forkRef.cleanup();
1231 forkRef.cleanup = null;
1232 }
1233 if (instance != null) {
1234 const cleanupCallbacks = Array(refs.length).fill(null);
1235 for (let i = 0; i < refs.length; i += 1) {
1236 const ref = refs[i];
1237 if (ref == null) {
1238 continue;
1239 }
1240 switch (typeof ref) {
1241 case "function": {
1242 const refCleanup = ref(instance);
1243 if (typeof refCleanup === "function") {
1244 cleanupCallbacks[i] = refCleanup;
1245 }
1246 break;
1247 }
1248 case "object": {
1249 ref.current = instance;
1250 break;
1251 }
1252 default:
1253 }
1254 }
1255 forkRef.cleanup = () => {
1256 for (let i = 0; i < refs.length; i += 1) {
1257 const ref = refs[i];
1258 if (ref == null) {
1259 continue;
1260 }
1261 switch (typeof ref) {
1262 case "function": {
1263 const cleanupCallback = cleanupCallbacks[i];
1264 if (typeof cleanupCallback === "function") {
1265 cleanupCallback();
1266 } else {
1267 ref(null);
1268 }
1269 break;
1270 }
1271 case "object": {
1272 ref.current = null;
1273 break;
1274 }
1275 default:
1276 }
1277 }
1278 };
1279 }
1280 };
1281 }
1282
1283 // node_modules/@base-ui/utils/getReactElementRef.mjs
1284 var React3 = __toESM(require_react(), 1);
1285
1286 // node_modules/@base-ui/utils/reactVersion.mjs
1287 var React2 = __toESM(require_react(), 1);
1288 var majorVersion = parseInt(React2.version, 10);
1289 function isReactVersionAtLeast(reactVersionToCheck) {
1290 return majorVersion >= reactVersionToCheck;
1291 }
1292
1293 // node_modules/@base-ui/utils/getReactElementRef.mjs
1294 function getReactElementRef(element) {
1295 if (!/* @__PURE__ */ React3.isValidElement(element)) {
1296 return null;
1297 }
1298 const reactElement = element;
1299 const propsWithRef = reactElement.props;
1300 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1301 }
1302
1303 // node_modules/@base-ui/utils/mergeObjects.mjs
1304 function mergeObjects(a, b) {
1305 if (a && !b) {
1306 return a;
1307 }
1308 if (!a && b) {
1309 return b;
1310 }
1311 if (a || b) {
1312 return {
1313 ...a,
1314 ...b
1315 };
1316 }
1317 return void 0;
1318 }
1319
1320 // node_modules/@base-ui/utils/empty.mjs
1321 var EMPTY_ARRAY = Object.freeze([]);
1322 var EMPTY_OBJECT = Object.freeze({});
1323
1324 // node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1325 function getStateAttributesProps(state, customMapping) {
1326 const props = {};
1327 for (const key in state) {
1328 const value = state[key];
1329 if (customMapping?.hasOwnProperty(key)) {
1330 const customProps = customMapping[key](value);
1331 if (customProps != null) {
1332 Object.assign(props, customProps);
1333 }
1334 continue;
1335 }
1336 if (value === true) {
1337 props[`data-${key.toLowerCase()}`] = "";
1338 } else if (value) {
1339 props[`data-${key.toLowerCase()}`] = value.toString();
1340 }
1341 }
1342 return props;
1343 }
1344
1345 // node_modules/@base-ui/react/utils/resolveClassName.mjs
1346 function resolveClassName(className, state) {
1347 return typeof className === "function" ? className(state) : className;
1348 }
1349
1350 // node_modules/@base-ui/react/utils/resolveStyle.mjs
1351 function resolveStyle(style, state) {
1352 return typeof style === "function" ? style(state) : style;
1353 }
1354
1355 // node_modules/@base-ui/react/merge-props/mergeProps.mjs
1356 var EMPTY_PROPS = {};
1357 function mergeProps(a, b, c, d, e) {
1358 if (!c && !d && !e && !a) {
1359 return createInitialMergedProps(b);
1360 }
1361 let merged = createInitialMergedProps(a);
1362 if (b) {
1363 merged = mergeInto(merged, b);
1364 }
1365 if (c) {
1366 merged = mergeInto(merged, c);
1367 }
1368 if (d) {
1369 merged = mergeInto(merged, d);
1370 }
1371 if (e) {
1372 merged = mergeInto(merged, e);
1373 }
1374 return merged;
1375 }
1376 function mergePropsN(props) {
1377 if (props.length === 0) {
1378 return EMPTY_PROPS;
1379 }
1380 if (props.length === 1) {
1381 return createInitialMergedProps(props[0]);
1382 }
1383 let merged = createInitialMergedProps(props[0]);
1384 for (let i = 1; i < props.length; i += 1) {
1385 merged = mergeInto(merged, props[i]);
1386 }
1387 return merged;
1388 }
1389 function createInitialMergedProps(inputProps) {
1390 if (isPropsGetter(inputProps)) {
1391 return {
1392 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1393 };
1394 }
1395 return copyInitialProps(inputProps);
1396 }
1397 function mergeInto(merged, inputProps) {
1398 if (isPropsGetter(inputProps)) {
1399 return resolvePropsGetter(inputProps, merged);
1400 }
1401 return mutablyMergeInto(merged, inputProps);
1402 }
1403 function copyInitialProps(inputProps) {
1404 const copiedProps = {
1405 ...inputProps
1406 };
1407 for (const propName in copiedProps) {
1408 const propValue = copiedProps[propName];
1409 if (isEventHandler(propName, propValue)) {
1410 copiedProps[propName] = wrapEventHandler(propValue);
1411 }
1412 }
1413 return copiedProps;
1414 }
1415 function mutablyMergeInto(mergedProps, externalProps) {
1416 if (!externalProps) {
1417 return mergedProps;
1418 }
1419 for (const propName in externalProps) {
1420 const externalPropValue = externalProps[propName];
1421 switch (propName) {
1422 case "style": {
1423 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1424 break;
1425 }
1426 case "className": {
1427 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1428 break;
1429 }
1430 default: {
1431 if (isEventHandler(propName, externalPropValue)) {
1432 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1433 } else {
1434 mergedProps[propName] = externalPropValue;
1435 }
1436 }
1437 }
1438 }
1439 return mergedProps;
1440 }
1441 function isEventHandler(key, value) {
1442 const code0 = key.charCodeAt(0);
1443 const code1 = key.charCodeAt(1);
1444 const code2 = key.charCodeAt(2);
1445 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1446 }
1447 function isPropsGetter(inputProps) {
1448 return typeof inputProps === "function";
1449 }
1450 function resolvePropsGetter(inputProps, previousProps) {
1451 if (isPropsGetter(inputProps)) {
1452 return inputProps(previousProps);
1453 }
1454 return inputProps ?? EMPTY_PROPS;
1455 }
1456 function mergeEventHandlers(ourHandler, theirHandler) {
1457 if (!theirHandler) {
1458 return ourHandler;
1459 }
1460 if (!ourHandler) {
1461 return wrapEventHandler(theirHandler);
1462 }
1463 return (...args) => {
1464 const event = args[0];
1465 if (isSyntheticEvent(event)) {
1466 const baseUIEvent = event;
1467 makeEventPreventable(baseUIEvent);
1468 const result2 = theirHandler(...args);
1469 if (!baseUIEvent.baseUIHandlerPrevented) {
1470 ourHandler?.(...args);
1471 }
1472 return result2;
1473 }
1474 const result = theirHandler(...args);
1475 ourHandler?.(...args);
1476 return result;
1477 };
1478 }
1479 function wrapEventHandler(handler) {
1480 if (!handler) {
1481 return handler;
1482 }
1483 return (...args) => {
1484 const event = args[0];
1485 if (isSyntheticEvent(event)) {
1486 makeEventPreventable(event);
1487 }
1488 return handler(...args);
1489 };
1490 }
1491 function makeEventPreventable(event) {
1492 event.preventBaseUIHandler = () => {
1493 event.baseUIHandlerPrevented = true;
1494 };
1495 return event;
1496 }
1497 function mergeClassNames(ourClassName, theirClassName) {
1498 if (theirClassName) {
1499 if (ourClassName) {
1500 return theirClassName + " " + ourClassName;
1501 }
1502 return theirClassName;
1503 }
1504 return ourClassName;
1505 }
1506 function isSyntheticEvent(event) {
1507 return event != null && typeof event === "object" && "nativeEvent" in event;
1508 }
1509
1510 // node_modules/@base-ui/react/internals/useRenderElement.mjs
1511 var import_react = __toESM(require_react(), 1);
1512 function useRenderElement(element, componentProps, params = {}) {
1513 const renderProp = componentProps.render;
1514 const outProps = useRenderElementProps(componentProps, params);
1515 if (params.enabled === false) {
1516 return null;
1517 }
1518 const state = params.state ?? EMPTY_OBJECT;
1519 return evaluateRenderProp(element, renderProp, outProps, state);
1520 }
1521 function useRenderElementProps(componentProps, params = {}) {
1522 const {
1523 className: classNameProp,
1524 style: styleProp,
1525 render: renderProp
1526 } = componentProps;
1527 const {
1528 state = EMPTY_OBJECT,
1529 ref,
1530 props,
1531 stateAttributesMapping,
1532 enabled = true
1533 } = params;
1534 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1535 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1536 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
1537 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1538 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1539 if (typeof document !== "undefined") {
1540 if (!enabled) {
1541 useMergedRefs(null, null);
1542 } else if (Array.isArray(ref)) {
1543 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1544 } else {
1545 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1546 }
1547 }
1548 if (!enabled) {
1549 return EMPTY_OBJECT;
1550 }
1551 if (className !== void 0) {
1552 outProps.className = mergeClassNames(outProps.className, className);
1553 }
1554 if (style !== void 0) {
1555 outProps.style = mergeObjects(outProps.style, style);
1556 }
1557 return outProps;
1558 }
1559 function resolveRenderFunctionProps(props) {
1560 if (Array.isArray(props)) {
1561 return mergePropsN(props);
1562 }
1563 return mergeProps(void 0, props);
1564 }
1565 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1566 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1567 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1568 function evaluateRenderProp(element, render, props, state) {
1569 if (render) {
1570 if (typeof render === "function") {
1571 if (true) {
1572 warnIfRenderPropLooksLikeComponent(render);
1573 }
1574 return render(props, state);
1575 }
1576 const mergedProps = mergeProps(props, render.props);
1577 mergedProps.ref = props.ref;
1578 let newElement = render;
1579 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1580 const children = React4.Children.toArray(render);
1581 newElement = children[0];
1582 }
1583 if (true) {
1584 if (!/* @__PURE__ */ React4.isValidElement(newElement)) {
1585 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
1586 }
1587 }
1588 return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps);
1589 }
1590 if (element) {
1591 if (typeof element === "string") {
1592 return renderTag(element, props);
1593 }
1594 }
1595 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1596 }
1597 function warnIfRenderPropLooksLikeComponent(renderFn) {
1598 const functionName = renderFn.name;
1599 if (functionName.length === 0) {
1600 return;
1601 }
1602 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1603 return;
1604 }
1605 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1606 return;
1607 }
1608 warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
1609 }
1610 function renderTag(Tag, props) {
1611 if (Tag === "button") {
1612 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1613 type: "button",
1614 ...props,
1615 key: props.key
1616 });
1617 }
1618 if (Tag === "img") {
1619 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1620 alt: "",
1621 ...props,
1622 key: props.key
1623 });
1624 }
1625 return /* @__PURE__ */ React4.createElement(Tag, props);
1626 }
1627
1628 // node_modules/@base-ui/react/use-render/useRender.mjs
1629 function useRender(params) {
1630 return useRenderElement(params.defaultTagName ?? "div", params, params);
1631 }
1632
1633 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
1634 var import_element3 = __toESM(require_element(), 1);
1635 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
1636 function getRuntime() {
1637 const globalScope = globalThis;
1638 if (globalScope.__wpStyleRuntime) {
1639 return globalScope.__wpStyleRuntime;
1640 }
1641 globalScope.__wpStyleRuntime = {
1642 documents: /* @__PURE__ */ new Map(),
1643 styles: /* @__PURE__ */ new Map(),
1644 injectedStyles: /* @__PURE__ */ new WeakMap()
1645 };
1646 if (typeof document !== "undefined") {
1647 registerDocument(document);
1648 }
1649 return globalScope.__wpStyleRuntime;
1650 }
1651 function documentContainsStyleHash(targetDocument, hash) {
1652 if (!targetDocument.head) {
1653 return false;
1654 }
1655 for (const style of targetDocument.head.querySelectorAll(
1656 `style[${STYLE_HASH_ATTRIBUTE}]`
1657 )) {
1658 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
1659 return true;
1660 }
1661 }
1662 return false;
1663 }
1664 function injectStyle(targetDocument, hash, css) {
1665 if (!targetDocument.head) {
1666 return;
1667 }
1668 const runtime = getRuntime();
1669 let injectedStyles = runtime.injectedStyles.get(targetDocument);
1670 if (!injectedStyles) {
1671 injectedStyles = /* @__PURE__ */ new Set();
1672 runtime.injectedStyles.set(targetDocument, injectedStyles);
1673 }
1674 if (injectedStyles.has(hash)) {
1675 return;
1676 }
1677 if (documentContainsStyleHash(targetDocument, hash)) {
1678 injectedStyles.add(hash);
1679 return;
1680 }
1681 const style = targetDocument.createElement("style");
1682 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
1683 style.appendChild(targetDocument.createTextNode(css));
1684 targetDocument.head.appendChild(style);
1685 injectedStyles.add(hash);
1686 }
1687 function registerDocument(targetDocument) {
1688 const runtime = getRuntime();
1689 runtime.documents.set(
1690 targetDocument,
1691 (runtime.documents.get(targetDocument) ?? 0) + 1
1692 );
1693 for (const [hash, css] of runtime.styles) {
1694 injectStyle(targetDocument, hash, css);
1695 }
1696 return () => {
1697 const count = runtime.documents.get(targetDocument);
1698 if (count === void 0) {
1699 return;
1700 }
1701 if (count <= 1) {
1702 runtime.documents.delete(targetDocument);
1703 return;
1704 }
1705 runtime.documents.set(targetDocument, count - 1);
1706 };
1707 }
1708 function registerStyle(hash, css) {
1709 const runtime = getRuntime();
1710 runtime.styles.set(hash, css);
1711 for (const targetDocument of runtime.documents.keys()) {
1712 injectStyle(targetDocument, hash, css);
1713 }
1714 }
1715 if (typeof process === "undefined" || true) {
1716 registerStyle("fa606a57ae", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}}");
1717 }
1718 var style_default = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
1719 var VisuallyHidden = (0, import_element3.forwardRef)(
1720 function VisuallyHidden2({ render, ...restProps }, ref) {
1721 const element = useRender({
1722 render,
1723 ref,
1724 props: mergeProps(
1725 { className: style_default["visually-hidden"] },
1726 restProps,
1727 {
1728 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
1729 "data-visually-hidden": ""
1730 }
1731 )
1732 });
1733 return element;
1734 }
1735 );
1736
1737 // packages/admin-ui/build-module/navigable-region/index.mjs
1738 var import_element4 = __toESM(require_element(), 1);
1739 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1740 var NavigableRegion = (0, import_element4.forwardRef)(
1741 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
1742 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
1743 Tag,
1744 {
1745 ref,
1746 className: clsx_default("admin-ui-navigable-region", className),
1747 "aria-label": ariaLabel,
1748 role: "region",
1749 tabIndex: "-1",
1750 ...props,
1751 children
1752 }
1753 );
1754 }
1755 );
1756 NavigableRegion.displayName = "NavigableRegion";
1757 var navigable_region_default = NavigableRegion;
1758
1759 // packages/interface/build-module/components/interface-skeleton/index.mjs
1760 var import_element5 = __toESM(require_element(), 1);
1761 var import_components6 = __toESM(require_components(), 1);
1762 var import_i18n2 = __toESM(require_i18n(), 1);
1763 var import_compose2 = __toESM(require_compose(), 1);
1764 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1765 var ANIMATION_DURATION2 = 0.25;
1766 var commonTransition = {
1767 type: "tween",
1768 duration: ANIMATION_DURATION2,
1769 ease: [0.6, 0, 0.4, 1]
1770 };
1771 function useHTMLClass(className) {
1772 (0, import_element5.useEffect)(() => {
1773 const element = document && document.querySelector(`html:not(.${className})`);
1774 if (!element) {
1775 return;
1776 }
1777 element.classList.toggle(className);
1778 return () => {
1779 element.classList.toggle(className);
1780 };
1781 }, [className]);
1782 }
1783 var headerVariants = {
1784 hidden: { opacity: 1, marginTop: -60 },
1785 visible: { opacity: 1, marginTop: 0 },
1786 distractionFreeHover: {
1787 opacity: 1,
1788 marginTop: 0,
1789 transition: {
1790 ...commonTransition,
1791 delay: 0.2,
1792 delayChildren: 0.2
1793 }
1794 },
1795 distractionFreeHidden: {
1796 opacity: 0,
1797 marginTop: -60
1798 },
1799 distractionFreeDisabled: {
1800 opacity: 0,
1801 marginTop: 0,
1802 transition: {
1803 ...commonTransition,
1804 delay: 0.8,
1805 delayChildren: 0.8
1806 }
1807 }
1808 };
1809 function InterfaceSkeleton({
1810 isDistractionFree,
1811 footer,
1812 header,
1813 editorNotices,
1814 sidebar,
1815 secondarySidebar,
1816 content,
1817 actions,
1818 labels,
1819 className
1820 }, ref) {
1821 const [secondarySidebarResizeListener, secondarySidebarSize] = (0, import_compose2.useResizeObserver)();
1822 const isMobileViewport = (0, import_compose2.useViewportMatch)("medium", "<");
1823 const disableMotion = (0, import_compose2.useReducedMotion)();
1824 const defaultTransition = {
1825 type: "tween",
1826 duration: disableMotion ? 0 : ANIMATION_DURATION2,
1827 ease: [0.6, 0, 0.4, 1]
1828 };
1829 useHTMLClass("interface-interface-skeleton__html-container");
1830 const defaultLabels = {
1831 /* translators: accessibility text for the top bar landmark region. */
1832 header: (0, import_i18n2._x)("Header", "header landmark area"),
1833 /* translators: accessibility text for the content landmark region. */
1834 body: (0, import_i18n2.__)("Content"),
1835 /* translators: accessibility text for the secondary sidebar landmark region. */
1836 secondarySidebar: (0, import_i18n2.__)("Block Library"),
1837 /* translators: accessibility text for the settings landmark region. */
1838 sidebar: (0, import_i18n2._x)("Settings", "settings landmark area"),
1839 /* translators: accessibility text for the publish landmark region. */
1840 actions: (0, import_i18n2.__)("Publish"),
1841 /* translators: accessibility text for the footer landmark region. */
1842 footer: (0, import_i18n2.__)("Footer")
1843 };
1844 const mergedLabels = { ...defaultLabels, ...labels };
1845 return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1846 "div",
1847 {
1848 ref,
1849 className: clsx_default(
1850 className,
1851 "interface-interface-skeleton",
1852 !!footer && "has-footer"
1853 ),
1854 children: [
1855 /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "interface-interface-skeleton__editor", children: [
1856 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components6.__unstableAnimatePresence, { initial: false, children: !!header && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1857 navigable_region_default,
1858 {
1859 as: import_components6.__unstableMotion.div,
1860 className: "interface-interface-skeleton__header",
1861 ariaLabel: mergedLabels.header,
1862 initial: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
1863 whileHover: isDistractionFree && !isMobileViewport ? "distractionFreeHover" : "visible",
1864 animate: isDistractionFree && !isMobileViewport ? "distractionFreeDisabled" : "visible",
1865 exit: isDistractionFree && !isMobileViewport ? "distractionFreeHidden" : "hidden",
1866 variants: headerVariants,
1867 transition: defaultTransition,
1868 children: header
1869 }
1870 ) }),
1871 isDistractionFree && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "interface-interface-skeleton__header", children: editorNotices }),
1872 /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "interface-interface-skeleton__body", children: [
1873 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components6.__unstableAnimatePresence, { initial: false, children: !!secondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1874 navigable_region_default,
1875 {
1876 className: "interface-interface-skeleton__secondary-sidebar",
1877 ariaLabel: mergedLabels.secondarySidebar,
1878 as: import_components6.__unstableMotion.div,
1879 initial: "closed",
1880 animate: "open",
1881 exit: "closed",
1882 variants: {
1883 open: { width: secondarySidebarSize.width },
1884 closed: { width: 0 }
1885 },
1886 transition: defaultTransition,
1887 children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
1888 import_components6.__unstableMotion.div,
1889 {
1890 style: {
1891 position: "absolute",
1892 width: isMobileViewport ? "100vw" : "fit-content",
1893 height: "100%",
1894 left: 0
1895 },
1896 variants: {
1897 open: { x: 0 },
1898 closed: { x: "-100%" }
1899 },
1900 transition: defaultTransition,
1901 children: [
1902 secondarySidebarResizeListener,
1903 secondarySidebar
1904 ]
1905 }
1906 )
1907 }
1908 ) }),
1909 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1910 navigable_region_default,
1911 {
1912 className: "interface-interface-skeleton__content",
1913 ariaLabel: mergedLabels.body,
1914 children: content
1915 }
1916 ),
1917 !!sidebar && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1918 navigable_region_default,
1919 {
1920 className: "interface-interface-skeleton__sidebar",
1921 ariaLabel: mergedLabels.sidebar,
1922 children: sidebar
1923 }
1924 ),
1925 !!actions && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1926 navigable_region_default,
1927 {
1928 className: "interface-interface-skeleton__actions",
1929 ariaLabel: mergedLabels.actions,
1930 children: actions
1931 }
1932 )
1933 ] })
1934 ] }),
1935 !!footer && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1936 navigable_region_default,
1937 {
1938 className: "interface-interface-skeleton__footer",
1939 ariaLabel: mergedLabels.footer,
1940 children: footer
1941 }
1942 )
1943 ]
1944 }
1945 );
1946 }
1947 var interface_skeleton_default = (0, import_element5.forwardRef)(InterfaceSkeleton);
1948
1949 // packages/edit-widgets/build-module/store/actions.mjs
1950 var import_widgets2 = __toESM(require_widgets(), 1);
1951 var import_core_data = __toESM(require_core_data(), 1);
1952 var import_block_editor = __toESM(require_block_editor(), 1);
1953
1954 // packages/edit-widgets/build-module/store/transformers.mjs
1955 var import_blocks = __toESM(require_blocks(), 1);
1956 var import_widgets = __toESM(require_widgets(), 1);
1957 function transformWidgetToBlock(widget) {
1958 if (widget.id_base === "block") {
1959 const parsedBlocks = (0, import_blocks.parse)(widget.instance.raw.content, {
1960 __unstableSkipAutop: true
1961 });
1962 if (!parsedBlocks.length) {
1963 return (0, import_widgets.addWidgetIdToBlock)(
1964 (0, import_blocks.createBlock)("core/paragraph", {}, []),
1965 widget.id
1966 );
1967 }
1968 return (0, import_widgets.addWidgetIdToBlock)(parsedBlocks[0], widget.id);
1969 }
1970 let attributes;
1971 if (widget._embedded.about[0].is_multi) {
1972 attributes = {
1973 idBase: widget.id_base,
1974 instance: widget.instance
1975 };
1976 } else {
1977 attributes = {
1978 id: widget.id
1979 };
1980 }
1981 return (0, import_widgets.addWidgetIdToBlock)(
1982 (0, import_blocks.createBlock)("core/legacy-widget", attributes, []),
1983 widget.id
1984 );
1985 }
1986 function transformBlockToWidget(block, relatedWidget = {}) {
1987 let widget;
1988 const isValidLegacyWidgetBlock = block.name === "core/legacy-widget" && (block.attributes.id || block.attributes.instance);
1989 if (isValidLegacyWidgetBlock) {
1990 widget = {
1991 ...relatedWidget,
1992 id: block.attributes.id ?? relatedWidget.id,
1993 id_base: block.attributes.idBase ?? relatedWidget.id_base,
1994 instance: block.attributes.instance ?? relatedWidget.instance
1995 };
1996 } else {
1997 widget = {
1998 ...relatedWidget,
1999 id_base: "block",
2000 instance: {
2001 raw: {
2002 content: (0, import_blocks.serialize)(block)
2003 }
2004 }
2005 };
2006 }
2007 delete widget.rendered;
2008 delete widget.rendered_form;
2009 return widget;
2010 }
2011
2012 // packages/edit-widgets/build-module/store/utils.mjs
2013 var KIND = "root";
2014 var WIDGET_AREA_ENTITY_TYPE = "sidebar";
2015 var POST_TYPE = "postType";
2016 var buildWidgetAreaPostId = (widgetAreaId) => `widget-area-${widgetAreaId}`;
2017 var buildWidgetAreasPostId = () => `widget-areas`;
2018 function buildWidgetAreasQuery() {
2019 return {
2020 per_page: -1
2021 };
2022 }
2023 function buildWidgetsQuery() {
2024 return {
2025 per_page: -1,
2026 _embed: "about"
2027 };
2028 }
2029 var createStubPost = (id, blocks) => ({
2030 id,
2031 slug: id,
2032 status: "draft",
2033 type: "page",
2034 blocks,
2035 meta: {
2036 widgetAreaId: id
2037 }
2038 });
2039
2040 // packages/edit-widgets/build-module/store/constants.mjs
2041 var STORE_NAME2 = "core/edit-widgets";
2042
2043 // packages/edit-widgets/build-module/store/actions.mjs
2044 var persistStubPost = (id, blocks) => ({ registry }) => {
2045 const stubPost = createStubPost(id, blocks);
2046 registry.dispatch(import_core_data.store).receiveEntityRecords(
2047 KIND,
2048 POST_TYPE,
2049 stubPost,
2050 { id: stubPost.id },
2051 false
2052 );
2053 return stubPost;
2054 };
2055 var saveEditedWidgetAreas = () => async ({ select, dispatch: dispatch2, registry }) => {
2056 const editedWidgetAreas = select.getEditedWidgetAreas();
2057 if (!editedWidgetAreas?.length) {
2058 return;
2059 }
2060 try {
2061 await dispatch2.saveWidgetAreas(editedWidgetAreas);
2062 registry.dispatch(import_notices.store).createSuccessNotice((0, import_i18n3.__)("Widgets saved."), {
2063 type: "snackbar"
2064 });
2065 } catch (e) {
2066 registry.dispatch(import_notices.store).createErrorNotice(
2067 /* translators: %s: The error message. */
2068 (0, import_i18n3.sprintf)((0, import_i18n3.__)("There was an error. %s"), e.message),
2069 {
2070 type: "snackbar"
2071 }
2072 );
2073 }
2074 };
2075 var saveWidgetAreas = (widgetAreas) => async ({ dispatch: dispatch2, registry }) => {
2076 try {
2077 for (const widgetArea of widgetAreas) {
2078 await dispatch2.saveWidgetArea(widgetArea.id);
2079 }
2080 } finally {
2081 await registry.dispatch(import_core_data.store).finishResolution(
2082 "getEntityRecord",
2083 KIND,
2084 WIDGET_AREA_ENTITY_TYPE,
2085 buildWidgetAreasQuery()
2086 );
2087 }
2088 };
2089 var saveWidgetArea = (widgetAreaId) => async ({ dispatch: dispatch2, select, registry }) => {
2090 const widgets = select.getWidgets();
2091 const post = registry.select(import_core_data.store).getEditedEntityRecord(
2092 KIND,
2093 POST_TYPE,
2094 buildWidgetAreaPostId(widgetAreaId)
2095 );
2096 const areaWidgets = Object.values(widgets).filter(
2097 ({ sidebar }) => sidebar === widgetAreaId
2098 );
2099 const usedReferenceWidgets = [];
2100 const widgetsBlocks = post.blocks.filter((block) => {
2101 const { id } = block.attributes;
2102 if (block.name === "core/legacy-widget" && id) {
2103 if (usedReferenceWidgets.includes(id)) {
2104 return false;
2105 }
2106 usedReferenceWidgets.push(id);
2107 }
2108 return true;
2109 });
2110 const deletedWidgets = [];
2111 for (const widget of areaWidgets) {
2112 const widgetsNewArea = select.getWidgetAreaForWidgetId(widget.id);
2113 if (!widgetsNewArea) {
2114 deletedWidgets.push(widget);
2115 }
2116 }
2117 const batchMeta = [];
2118 const batchTasks = [];
2119 const sidebarWidgetsIds = [];
2120 for (let i = 0; i < widgetsBlocks.length; i++) {
2121 const block = widgetsBlocks[i];
2122 const widgetId = (0, import_widgets2.getWidgetIdFromBlock)(block);
2123 const oldWidget = widgets[widgetId];
2124 const widget = transformBlockToWidget(block, oldWidget);
2125 sidebarWidgetsIds.push(widgetId);
2126 if (oldWidget) {
2127 registry.dispatch(import_core_data.store).editEntityRecord(
2128 "root",
2129 "widget",
2130 widgetId,
2131 {
2132 ...widget,
2133 sidebar: widgetAreaId
2134 },
2135 { undoIgnore: true }
2136 );
2137 const hasEdits = registry.select(import_core_data.store).hasEditsForEntityRecord("root", "widget", widgetId);
2138 if (!hasEdits) {
2139 continue;
2140 }
2141 batchTasks.push(
2142 ({ saveEditedEntityRecord }) => saveEditedEntityRecord("root", "widget", widgetId)
2143 );
2144 } else {
2145 batchTasks.push(
2146 ({ saveEntityRecord }) => saveEntityRecord("root", "widget", {
2147 ...widget,
2148 sidebar: widgetAreaId
2149 })
2150 );
2151 }
2152 batchMeta.push({
2153 block,
2154 position: i,
2155 clientId: block.clientId
2156 });
2157 }
2158 for (const widget of deletedWidgets) {
2159 batchTasks.push(
2160 ({ deleteEntityRecord }) => deleteEntityRecord("root", "widget", widget.id, {
2161 force: true
2162 })
2163 );
2164 }
2165 const records = await registry.dispatch(import_core_data.store).__experimentalBatch(batchTasks);
2166 const preservedRecords = records.filter(
2167 (record) => !record.hasOwnProperty("deleted")
2168 );
2169 const failedWidgetNames = [];
2170 for (let i = 0; i < preservedRecords.length; i++) {
2171 const widget = preservedRecords[i];
2172 const { block, position } = batchMeta[i];
2173 post.blocks[position].attributes.__internalWidgetId = widget.id;
2174 const error = registry.select(import_core_data.store).getLastEntitySaveError("root", "widget", widget.id);
2175 if (error) {
2176 failedWidgetNames.push(block.attributes?.name || block?.name);
2177 }
2178 if (!sidebarWidgetsIds[position]) {
2179 sidebarWidgetsIds[position] = widget.id;
2180 }
2181 }
2182 if (failedWidgetNames.length) {
2183 throw new Error(
2184 (0, import_i18n3.sprintf)(
2185 /* translators: %s: List of widget names */
2186 (0, import_i18n3.__)("Could not save the following widgets: %s."),
2187 failedWidgetNames.join(", ")
2188 )
2189 );
2190 }
2191 registry.dispatch(import_core_data.store).editEntityRecord(
2192 KIND,
2193 WIDGET_AREA_ENTITY_TYPE,
2194 widgetAreaId,
2195 {
2196 widgets: sidebarWidgetsIds
2197 },
2198 { undoIgnore: true }
2199 );
2200 dispatch2(trySaveWidgetArea(widgetAreaId));
2201 registry.dispatch(import_core_data.store).receiveEntityRecords(KIND, POST_TYPE, post, void 0);
2202 };
2203 var trySaveWidgetArea = (widgetAreaId) => ({ registry }) => {
2204 registry.dispatch(import_core_data.store).saveEditedEntityRecord(
2205 KIND,
2206 WIDGET_AREA_ENTITY_TYPE,
2207 widgetAreaId,
2208 {
2209 throwOnError: true
2210 }
2211 );
2212 };
2213 function setWidgetIdForClientId(clientId, widgetId) {
2214 return {
2215 type: "SET_WIDGET_ID_FOR_CLIENT_ID",
2216 clientId,
2217 widgetId
2218 };
2219 }
2220 function setWidgetAreasOpenState(widgetAreasOpenState2) {
2221 return {
2222 type: "SET_WIDGET_AREAS_OPEN_STATE",
2223 widgetAreasOpenState: widgetAreasOpenState2
2224 };
2225 }
2226 function setIsWidgetAreaOpen(clientId, isOpen) {
2227 return {
2228 type: "SET_IS_WIDGET_AREA_OPEN",
2229 clientId,
2230 isOpen
2231 };
2232 }
2233 function setIsInserterOpened(value) {
2234 return {
2235 type: "SET_IS_INSERTER_OPENED",
2236 value
2237 };
2238 }
2239 function setIsListViewOpened(isOpen) {
2240 return {
2241 type: "SET_IS_LIST_VIEW_OPENED",
2242 isOpen
2243 };
2244 }
2245 var closeGeneralSidebar = () => ({ registry }) => {
2246 registry.dispatch(store).disableComplementaryArea(STORE_NAME2);
2247 };
2248 var moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({ dispatch: dispatch2, select, registry }) => {
2249 const sourceRootClientId = registry.select(import_block_editor.store).getBlockRootClientId(clientId);
2250 const widgetAreas = registry.select(import_block_editor.store).getBlocks();
2251 const destinationWidgetAreaBlock = widgetAreas.find(
2252 ({ attributes }) => attributes.id === widgetAreaId
2253 );
2254 const destinationRootClientId = destinationWidgetAreaBlock.clientId;
2255 const destinationInnerBlocksClientIds = registry.select(import_block_editor.store).getBlockOrder(destinationRootClientId);
2256 const destinationIndex = destinationInnerBlocksClientIds.length;
2257 const isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(
2258 destinationRootClientId
2259 );
2260 if (!isDestinationWidgetAreaOpen) {
2261 dispatch2.setIsWidgetAreaOpen(destinationRootClientId, true);
2262 }
2263 registry.dispatch(import_block_editor.store).moveBlocksToPosition(
2264 [clientId],
2265 sourceRootClientId,
2266 destinationRootClientId,
2267 destinationIndex
2268 );
2269 };
2270 function unlockWidgetSaving(lockName) {
2271 return {
2272 type: "UNLOCK_WIDGET_SAVING",
2273 lockName
2274 };
2275 }
2276 function lockWidgetSaving(lockName) {
2277 return {
2278 type: "LOCK_WIDGET_SAVING",
2279 lockName
2280 };
2281 }
2282
2283 // packages/edit-widgets/build-module/store/resolvers.mjs
2284 var getWidgetAreas = () => async ({ dispatch: dispatch2, registry }) => {
2285 const query = buildWidgetAreasQuery();
2286 const widgetAreas = await registry.resolveSelect(import_core_data2.store).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query);
2287 const widgetAreaBlocks = [];
2288 const sortedWidgetAreas = widgetAreas.sort((a, b) => {
2289 if (a.id === "wp_inactive_widgets") {
2290 return 1;
2291 }
2292 if (b.id === "wp_inactive_widgets") {
2293 return -1;
2294 }
2295 return 0;
2296 });
2297 for (const widgetArea of sortedWidgetAreas) {
2298 widgetAreaBlocks.push(
2299 (0, import_blocks2.createBlock)("core/widget-area", {
2300 id: widgetArea.id,
2301 name: widgetArea.name
2302 })
2303 );
2304 if (!widgetArea.widgets.length) {
2305 dispatch2(
2306 persistStubPost(
2307 buildWidgetAreaPostId(widgetArea.id),
2308 []
2309 )
2310 );
2311 }
2312 }
2313 const widgetAreasOpenState2 = {};
2314 widgetAreaBlocks.forEach((widgetAreaBlock, index) => {
2315 widgetAreasOpenState2[widgetAreaBlock.clientId] = index === 0;
2316 });
2317 dispatch2(setWidgetAreasOpenState(widgetAreasOpenState2));
2318 dispatch2(
2319 persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks)
2320 );
2321 };
2322 var getWidgets = () => async ({ dispatch: dispatch2, registry }) => {
2323 const query = buildWidgetsQuery();
2324 const widgets = await registry.resolveSelect(import_core_data2.store).getEntityRecords("root", "widget", query);
2325 const groupedBySidebar = {};
2326 for (const widget of widgets) {
2327 const block = transformWidgetToBlock(widget);
2328 groupedBySidebar[widget.sidebar] = groupedBySidebar[widget.sidebar] || [];
2329 groupedBySidebar[widget.sidebar].push(block);
2330 }
2331 for (const sidebarId in groupedBySidebar) {
2332 if (groupedBySidebar.hasOwnProperty(sidebarId)) {
2333 dispatch2(
2334 persistStubPost(
2335 buildWidgetAreaPostId(sidebarId),
2336 groupedBySidebar[sidebarId]
2337 )
2338 );
2339 }
2340 }
2341 };
2342
2343 // packages/edit-widgets/build-module/store/selectors.mjs
2344 var selectors_exports2 = {};
2345 __export(selectors_exports2, {
2346 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
2347 canInsertBlockInWidgetArea: () => canInsertBlockInWidgetArea,
2348 getEditedWidgetAreas: () => getEditedWidgetAreas,
2349 getIsWidgetAreaOpen: () => getIsWidgetAreaOpen,
2350 getParentWidgetAreaBlock: () => getParentWidgetAreaBlock,
2351 getReferenceWidgetBlocks: () => getReferenceWidgetBlocks,
2352 getWidget: () => getWidget,
2353 getWidgetAreaForWidgetId: () => getWidgetAreaForWidgetId,
2354 getWidgetAreas: () => getWidgetAreas2,
2355 getWidgets: () => getWidgets2,
2356 isInserterOpened: () => isInserterOpened,
2357 isListViewOpened: () => isListViewOpened,
2358 isSavingWidgetAreas: () => isSavingWidgetAreas,
2359 isWidgetSavingLocked: () => isWidgetSavingLocked
2360 });
2361 var import_data7 = __toESM(require_data(), 1);
2362 var import_widgets3 = __toESM(require_widgets(), 1);
2363 var import_core_data3 = __toESM(require_core_data(), 1);
2364 var import_block_editor2 = __toESM(require_block_editor(), 1);
2365 var EMPTY_INSERTION_POINT = {
2366 rootClientId: void 0,
2367 insertionIndex: void 0
2368 };
2369 var getWidgets2 = (0, import_data7.createRegistrySelector)(
2370 (select) => (0, import_data7.createSelector)(
2371 () => {
2372 const widgets = select(import_core_data3.store).getEntityRecords(
2373 "root",
2374 "widget",
2375 buildWidgetsQuery()
2376 );
2377 return (
2378 // Key widgets by their ID.
2379 widgets?.reduce(
2380 (allWidgets, widget) => ({
2381 ...allWidgets,
2382 [widget.id]: widget
2383 }),
2384 {}
2385 ) ?? {}
2386 );
2387 },
2388 () => [
2389 select(import_core_data3.store).getEntityRecords(
2390 "root",
2391 "widget",
2392 buildWidgetsQuery()
2393 )
2394 ]
2395 )
2396 );
2397 var getWidget = (0, import_data7.createRegistrySelector)(
2398 (select) => (state, id) => {
2399 const widgets = select(STORE_NAME2).getWidgets();
2400 return widgets[id];
2401 }
2402 );
2403 var getWidgetAreas2 = (0, import_data7.createRegistrySelector)((select) => () => {
2404 const query = buildWidgetAreasQuery();
2405 return select(import_core_data3.store).getEntityRecords(
2406 KIND,
2407 WIDGET_AREA_ENTITY_TYPE,
2408 query
2409 );
2410 });
2411 var getWidgetAreaForWidgetId = (0, import_data7.createRegistrySelector)(
2412 (select) => (state, widgetId) => {
2413 const widgetAreas = select(STORE_NAME2).getWidgetAreas();
2414 return widgetAreas.find((widgetArea) => {
2415 const post = select(import_core_data3.store).getEditedEntityRecord(
2416 KIND,
2417 POST_TYPE,
2418 buildWidgetAreaPostId(widgetArea.id)
2419 );
2420 const blockWidgetIds = post.blocks.map(
2421 (block) => (0, import_widgets3.getWidgetIdFromBlock)(block)
2422 );
2423 return blockWidgetIds.includes(widgetId);
2424 });
2425 }
2426 );
2427 var getParentWidgetAreaBlock = (0, import_data7.createRegistrySelector)(
2428 (select) => (state, clientId) => {
2429 const { getBlock, getBlockName, getBlockParents } = select(import_block_editor2.store);
2430 const blockParents = getBlockParents(clientId);
2431 const widgetAreaClientId = blockParents.find(
2432 (parentClientId) => getBlockName(parentClientId) === "core/widget-area"
2433 );
2434 return getBlock(widgetAreaClientId);
2435 }
2436 );
2437 var getEditedWidgetAreas = (0, import_data7.createRegistrySelector)(
2438 (select) => (state, ids) => {
2439 let widgetAreas = select(STORE_NAME2).getWidgetAreas();
2440 if (!widgetAreas) {
2441 return [];
2442 }
2443 if (ids) {
2444 widgetAreas = widgetAreas.filter(
2445 ({ id }) => ids.includes(id)
2446 );
2447 }
2448 return widgetAreas.filter(
2449 ({ id }) => select(import_core_data3.store).hasEditsForEntityRecord(
2450 KIND,
2451 POST_TYPE,
2452 buildWidgetAreaPostId(id)
2453 )
2454 ).map(
2455 ({ id }) => select(import_core_data3.store).getEditedEntityRecord(
2456 KIND,
2457 WIDGET_AREA_ENTITY_TYPE,
2458 id
2459 )
2460 );
2461 }
2462 );
2463 var getReferenceWidgetBlocks = (0, import_data7.createRegistrySelector)(
2464 (select) => (state, referenceWidgetName = null) => {
2465 const results = [];
2466 const widgetAreas = select(STORE_NAME2).getWidgetAreas();
2467 for (const _widgetArea of widgetAreas) {
2468 const post = select(import_core_data3.store).getEditedEntityRecord(
2469 KIND,
2470 POST_TYPE,
2471 buildWidgetAreaPostId(_widgetArea.id)
2472 );
2473 for (const block of post.blocks) {
2474 if (block.name === "core/legacy-widget" && (!referenceWidgetName || block.attributes?.referenceWidgetName === referenceWidgetName)) {
2475 results.push(block);
2476 }
2477 }
2478 }
2479 return results;
2480 }
2481 );
2482 var isSavingWidgetAreas = (0, import_data7.createRegistrySelector)((select) => () => {
2483 const widgetAreasIds = select(STORE_NAME2).getWidgetAreas()?.map(({ id }) => id);
2484 if (!widgetAreasIds) {
2485 return false;
2486 }
2487 for (const id of widgetAreasIds) {
2488 const isSaving = select(import_core_data3.store).isSavingEntityRecord(
2489 KIND,
2490 WIDGET_AREA_ENTITY_TYPE,
2491 id
2492 );
2493 if (isSaving) {
2494 return true;
2495 }
2496 }
2497 const widgetIds = [
2498 ...Object.keys(select(STORE_NAME2).getWidgets()),
2499 void 0
2500 // account for new widgets without an ID
2501 ];
2502 for (const id of widgetIds) {
2503 const isSaving = select(import_core_data3.store).isSavingEntityRecord(
2504 "root",
2505 "widget",
2506 id
2507 );
2508 if (isSaving) {
2509 return true;
2510 }
2511 }
2512 return false;
2513 });
2514 var getIsWidgetAreaOpen = (state, clientId) => {
2515 const { widgetAreasOpenState: widgetAreasOpenState2 } = state;
2516 return !!widgetAreasOpenState2[clientId];
2517 };
2518 function isInserterOpened(state) {
2519 return !!state.blockInserterPanel;
2520 }
2521 function __experimentalGetInsertionPoint(state) {
2522 if (typeof state.blockInserterPanel === "boolean") {
2523 return EMPTY_INSERTION_POINT;
2524 }
2525 return state.blockInserterPanel;
2526 }
2527 var canInsertBlockInWidgetArea = (0, import_data7.createRegistrySelector)(
2528 (select) => (state, blockName) => {
2529 const widgetAreas = select(import_block_editor2.store).getBlocks();
2530 const [firstWidgetArea] = widgetAreas;
2531 return select(import_block_editor2.store).canInsertBlockType(
2532 blockName,
2533 firstWidgetArea.clientId
2534 );
2535 }
2536 );
2537 function isListViewOpened(state) {
2538 return state.listViewPanel;
2539 }
2540 function isWidgetSavingLocked(state) {
2541 return Object.keys(state.widgetSavingLock).length > 0;
2542 }
2543
2544 // packages/edit-widgets/build-module/store/private-selectors.mjs
2545 var private_selectors_exports = {};
2546 __export(private_selectors_exports, {
2547 getInserterSidebarToggleRef: () => getInserterSidebarToggleRef,
2548 getListViewToggleRef: () => getListViewToggleRef
2549 });
2550 function getListViewToggleRef(state) {
2551 return state.listViewToggleRef;
2552 }
2553 function getInserterSidebarToggleRef(state) {
2554 return state.inserterSidebarToggleRef;
2555 }
2556
2557 // packages/edit-widgets/build-module/lock-unlock.mjs
2558 var import_private_apis = __toESM(require_private_apis(), 1);
2559 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
2560 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
2561 "@wordpress/edit-widgets"
2562 );
2563
2564 // packages/edit-widgets/build-module/store/index.mjs
2565 var storeConfig = {
2566 reducer: reducer_default,
2567 selectors: selectors_exports2,
2568 resolvers: resolvers_exports,
2569 actions: actions_exports2
2570 };
2571 var store2 = (0, import_data8.createReduxStore)(STORE_NAME2, storeConfig);
2572 (0, import_data8.register)(store2);
2573 import_api_fetch.default.use(function(options, next) {
2574 if (options.path?.indexOf("/wp/v2/types/widget-area") === 0) {
2575 return Promise.resolve({});
2576 }
2577 return next(options);
2578 });
2579 unlock(store2).registerPrivateSelectors(private_selectors_exports);
2580
2581 // packages/edit-widgets/build-module/filters/move-to-widget-area.mjs
2582 var import_block_editor3 = __toESM(require_block_editor(), 1);
2583 var import_compose3 = __toESM(require_compose(), 1);
2584 var import_data9 = __toESM(require_data(), 1);
2585 var import_hooks = __toESM(require_hooks(), 1);
2586 var import_widgets4 = __toESM(require_widgets(), 1);
2587 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
2588 var withMoveToWidgetAreaToolbarItem = (0, import_compose3.createHigherOrderComponent)(
2589 (BlockEdit) => (props) => {
2590 const { clientId, name: blockName } = props;
2591 const { widgetAreas, currentWidgetAreaId, canInsertBlockInWidgetArea: canInsertBlockInWidgetArea2 } = (0, import_data9.useSelect)(
2592 (select) => {
2593 if (blockName === "core/widget-area") {
2594 return {};
2595 }
2596 const selectors = select(store2);
2597 const widgetAreaBlock = selectors.getParentWidgetAreaBlock(clientId);
2598 return {
2599 widgetAreas: selectors.getWidgetAreas(),
2600 currentWidgetAreaId: widgetAreaBlock?.attributes?.id,
2601 canInsertBlockInWidgetArea: selectors.canInsertBlockInWidgetArea(blockName)
2602 };
2603 },
2604 [clientId, blockName]
2605 );
2606 const { moveBlockToWidgetArea: moveBlockToWidgetArea2 } = (0, import_data9.useDispatch)(store2);
2607 const hasMultipleWidgetAreas = widgetAreas?.length > 1;
2608 const isMoveToWidgetAreaVisible = blockName !== "core/widget-area" && hasMultipleWidgetAreas && canInsertBlockInWidgetArea2;
2609 return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
2610 /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BlockEdit, { ...props }, "edit"),
2611 isMoveToWidgetAreaVisible && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_block_editor3.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2612 import_widgets4.MoveToWidgetArea,
2613 {
2614 widgetAreas,
2615 currentWidgetAreaId,
2616 onSelect: (widgetAreaId) => {
2617 moveBlockToWidgetArea2(
2618 props.clientId,
2619 widgetAreaId
2620 );
2621 }
2622 }
2623 ) })
2624 ] });
2625 },
2626 "withMoveToWidgetAreaToolbarItem"
2627 );
2628 (0, import_hooks.addFilter)(
2629 "editor.BlockEdit",
2630 "core/edit-widgets/block-edit",
2631 withMoveToWidgetAreaToolbarItem
2632 );
2633
2634 // packages/edit-widgets/build-module/filters/replace-media-upload.mjs
2635 var import_hooks2 = __toESM(require_hooks(), 1);
2636 var import_media_utils = __toESM(require_media_utils(), 1);
2637 var replaceMediaUpload = () => import_media_utils.MediaUpload;
2638 (0, import_hooks2.addFilter)(
2639 "editor.MediaUpload",
2640 "core/edit-widgets/replace-media-upload",
2641 replaceMediaUpload
2642 );
2643
2644 // packages/edit-widgets/build-module/blocks/widget-area/index.mjs
2645 var widget_area_exports = {};
2646 __export(widget_area_exports, {
2647 metadata: () => block_default,
2648 name: () => name,
2649 settings: () => settings
2650 });
2651 var import_i18n4 = __toESM(require_i18n(), 1);
2652
2653 // packages/edit-widgets/build-module/blocks/widget-area/block.json
2654 var block_default = {
2655 $schema: "https://schemas.wp.org/trunk/block.json",
2656 apiVersion: 3,
2657 name: "core/widget-area",
2658 title: "Widget Area",
2659 category: "widgets",
2660 attributes: {
2661 id: {
2662 type: "string"
2663 },
2664 name: {
2665 type: "string"
2666 }
2667 },
2668 supports: {
2669 html: false,
2670 inserter: false,
2671 customClassName: false,
2672 reusable: false,
2673 renaming: false,
2674 visibility: false,
2675 __experimentalToolbar: false,
2676 __experimentalParentSelector: false,
2677 __experimentalDisableBlockOverlay: true
2678 },
2679 editorStyle: "wp-block-widget-area-editor",
2680 style: "wp-block-widget-area"
2681 };
2682
2683 // packages/edit-widgets/build-module/blocks/widget-area/edit/index.mjs
2684 var import_element8 = __toESM(require_element(), 1);
2685 var import_data10 = __toESM(require_data(), 1);
2686 var import_core_data5 = __toESM(require_core_data(), 1);
2687 var import_components7 = __toESM(require_components(), 1);
2688 var import_block_editor5 = __toESM(require_block_editor(), 1);
2689
2690 // packages/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.mjs
2691 var import_core_data4 = __toESM(require_core_data(), 1);
2692 var import_block_editor4 = __toESM(require_block_editor(), 1);
2693 var import_element7 = __toESM(require_element(), 1);
2694
2695 // packages/edit-widgets/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs
2696 var import_element6 = __toESM(require_element(), 1);
2697 var useIsDraggingWithin = (elementRef) => {
2698 const [isDraggingWithin, setIsDraggingWithin] = (0, import_element6.useState)(false);
2699 (0, import_element6.useEffect)(() => {
2700 const { ownerDocument } = elementRef.current;
2701 function handleDragStart(event) {
2702 handleDragEnter(event);
2703 }
2704 function handleDragEnd() {
2705 setIsDraggingWithin(false);
2706 }
2707 function handleDragEnter(event) {
2708 if (elementRef.current.contains(event.target)) {
2709 setIsDraggingWithin(true);
2710 } else {
2711 setIsDraggingWithin(false);
2712 }
2713 }
2714 ownerDocument.addEventListener("dragstart", handleDragStart);
2715 ownerDocument.addEventListener("dragend", handleDragEnd);
2716 ownerDocument.addEventListener("dragenter", handleDragEnter);
2717 return () => {
2718 ownerDocument.removeEventListener("dragstart", handleDragStart);
2719 ownerDocument.removeEventListener("dragend", handleDragEnd);
2720 ownerDocument.removeEventListener("dragenter", handleDragEnter);
2721 };
2722 }, []);
2723 return isDraggingWithin;
2724 };
2725 var use_is_dragging_within_default = useIsDraggingWithin;
2726
2727 // packages/edit-widgets/build-module/blocks/widget-area/edit/inner-blocks.mjs
2728 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
2729 function WidgetAreaInnerBlocks({ id }) {
2730 const [blocks, onInput, onChange] = (0, import_core_data4.useEntityBlockEditor)(
2731 "root",
2732 "postType"
2733 );
2734 const innerBlocksRef = (0, import_element7.useRef)();
2735 const isDraggingWithinInnerBlocks = use_is_dragging_within_default(innerBlocksRef);
2736 const shouldHighlightDropZone = isDraggingWithinInnerBlocks;
2737 const innerBlocksProps = (0, import_block_editor4.useInnerBlocksProps)(
2738 { ref: innerBlocksRef },
2739 {
2740 value: blocks,
2741 onInput,
2742 onChange,
2743 templateLock: false,
2744 renderAppender: import_block_editor4.InnerBlocks.ButtonBlockAppender
2745 }
2746 );
2747 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2748 "div",
2749 {
2750 "data-widget-area-id": id,
2751 className: clsx_default(
2752 "wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper",
2753 {
2754 "wp-block-widget-area__highlight-drop-zone": shouldHighlightDropZone
2755 }
2756 ),
2757 children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { ...innerBlocksProps })
2758 }
2759 );
2760 }
2761
2762 // packages/edit-widgets/build-module/blocks/widget-area/edit/index.mjs
2763 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
2764 function WidgetAreaEdit({
2765 clientId,
2766 attributes: { id, name: name2 }
2767 }) {
2768 const isOpen = (0, import_data10.useSelect)(
2769 (select) => select(store2).getIsWidgetAreaOpen(clientId),
2770 [clientId]
2771 );
2772 const { setIsWidgetAreaOpen: setIsWidgetAreaOpen2 } = (0, import_data10.useDispatch)(store2);
2773 const wrapper = (0, import_element8.useRef)();
2774 const setOpen = (0, import_element8.useCallback)(
2775 (openState) => setIsWidgetAreaOpen2(clientId, openState),
2776 [clientId]
2777 );
2778 const isDragging = useIsDragging(wrapper);
2779 const isDraggingWithin = use_is_dragging_within_default(wrapper);
2780 const [openedWhileDragging, setOpenedWhileDragging] = (0, import_element8.useState)(false);
2781 (0, import_element8.useEffect)(() => {
2782 if (!isDragging) {
2783 setOpenedWhileDragging(false);
2784 return;
2785 }
2786 if (isDraggingWithin && !isOpen) {
2787 setOpen(true);
2788 setOpenedWhileDragging(true);
2789 } else if (!isDraggingWithin && isOpen && openedWhileDragging) {
2790 setOpen(false);
2791 }
2792 }, [isOpen, isDragging, isDraggingWithin, openedWhileDragging]);
2793 const blockProps = (0, import_block_editor5.useBlockProps)();
2794 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { ...blockProps, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_components7.Panel, { ref: wrapper, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2795 import_components7.PanelBody,
2796 {
2797 title: name2,
2798 opened: isOpen,
2799 onToggle: () => {
2800 setIsWidgetAreaOpen2(clientId, !isOpen);
2801 },
2802 scrollAfterOpen: !isDragging,
2803 children: ({ opened }) => (
2804 // This is required to ensure LegacyWidget blocks are not
2805 // unmounted when the panel is collapsed. Unmounting legacy
2806 // widgets may have unintended consequences (e.g. TinyMCE
2807 // not being properly reinitialized)
2808 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2809 import_components7.__unstableDisclosureContent,
2810 {
2811 className: "wp-block-widget-area__panel-body-content",
2812 visible: opened,
2813 children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2814 import_core_data5.EntityProvider,
2815 {
2816 kind: "root",
2817 type: "postType",
2818 id: `widget-area-${id}`,
2819 children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(WidgetAreaInnerBlocks, { id })
2820 }
2821 )
2822 }
2823 )
2824 )
2825 }
2826 ) }) });
2827 }
2828 var useIsDragging = (elementRef) => {
2829 const [isDragging, setIsDragging] = (0, import_element8.useState)(false);
2830 (0, import_element8.useEffect)(() => {
2831 const { ownerDocument } = elementRef.current;
2832 function handleDragStart() {
2833 setIsDragging(true);
2834 }
2835 function handleDragEnd() {
2836 setIsDragging(false);
2837 }
2838 ownerDocument.addEventListener("dragstart", handleDragStart);
2839 ownerDocument.addEventListener("dragend", handleDragEnd);
2840 return () => {
2841 ownerDocument.removeEventListener("dragstart", handleDragStart);
2842 ownerDocument.removeEventListener("dragend", handleDragEnd);
2843 };
2844 }, []);
2845 return isDragging;
2846 };
2847
2848 // packages/edit-widgets/build-module/blocks/widget-area/index.mjs
2849 var { name } = block_default;
2850 var settings = {
2851 title: (0, import_i18n4.__)("Widget Area"),
2852 description: (0, import_i18n4.__)("A widget area container."),
2853 __experimentalLabel: ({ name: label }) => label,
2854 edit: WidgetAreaEdit
2855 };
2856
2857 // packages/edit-widgets/build-module/components/layout/index.mjs
2858 var import_i18n21 = __toESM(require_i18n(), 1);
2859 var import_data31 = __toESM(require_data(), 1);
2860 var import_plugins3 = __toESM(require_plugins(), 1);
2861 var import_notices4 = __toESM(require_notices(), 1);
2862 var import_components22 = __toESM(require_components(), 1);
2863
2864 // packages/edit-widgets/build-module/components/error-boundary/index.mjs
2865 var import_element9 = __toESM(require_element(), 1);
2866 var import_i18n5 = __toESM(require_i18n(), 1);
2867 var import_components8 = __toESM(require_components(), 1);
2868 var import_block_editor6 = __toESM(require_block_editor(), 1);
2869 var import_compose4 = __toESM(require_compose(), 1);
2870 var import_hooks3 = __toESM(require_hooks(), 1);
2871 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
2872 function CopyButton({ text, children }) {
2873 const ref = (0, import_compose4.useCopyToClipboard)(text);
2874 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_components8.Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children });
2875 }
2876 function ErrorBoundaryWarning({ message, error }) {
2877 const actions = [
2878 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CopyButton, { text: error.stack, children: (0, import_i18n5.__)("Copy Error") }, "copy-error")
2879 ];
2880 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_block_editor6.Warning, { className: "edit-widgets-error-boundary", actions, children: message });
2881 }
2882 var ErrorBoundary = class extends import_element9.Component {
2883 constructor() {
2884 super(...arguments);
2885 this.state = {
2886 error: null
2887 };
2888 }
2889 componentDidCatch(error) {
2890 (0, import_hooks3.doAction)("editor.ErrorBoundary.errorLogged", error);
2891 }
2892 static getDerivedStateFromError(error) {
2893 return { error };
2894 }
2895 render() {
2896 if (!this.state.error) {
2897 return this.props.children;
2898 }
2899 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2900 ErrorBoundaryWarning,
2901 {
2902 message: (0, import_i18n5.__)(
2903 "The editor has encountered an unexpected error."
2904 ),
2905 error: this.state.error
2906 }
2907 );
2908 }
2909 };
2910
2911 // packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.mjs
2912 var import_components9 = __toESM(require_components(), 1);
2913 var import_compose5 = __toESM(require_compose(), 1);
2914 var import_media_utils2 = __toESM(require_media_utils(), 1);
2915 var import_data13 = __toESM(require_data(), 1);
2916 var import_core_data8 = __toESM(require_core_data(), 1);
2917 var import_element11 = __toESM(require_element(), 1);
2918 var import_block_editor8 = __toESM(require_block_editor(), 1);
2919 var import_patterns = __toESM(require_patterns(), 1);
2920 var import_preferences4 = __toESM(require_preferences(), 1);
2921 var import_block_library = __toESM(require_block_library(), 1);
2922
2923 // packages/edit-widgets/build-module/components/keyboard-shortcuts/index.mjs
2924 var import_element10 = __toESM(require_element(), 1);
2925 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
2926 var import_keycodes = __toESM(require_keycodes(), 1);
2927 var import_data11 = __toESM(require_data(), 1);
2928 var import_i18n6 = __toESM(require_i18n(), 1);
2929 var import_core_data6 = __toESM(require_core_data(), 1);
2930 function KeyboardShortcuts() {
2931 const { redo, undo } = (0, import_data11.useDispatch)(import_core_data6.store);
2932 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data11.useDispatch)(store2);
2933 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/undo", (event) => {
2934 undo();
2935 event.preventDefault();
2936 });
2937 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/redo", (event) => {
2938 redo();
2939 event.preventDefault();
2940 });
2941 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/save", (event) => {
2942 event.preventDefault();
2943 saveEditedWidgetAreas2();
2944 });
2945 return null;
2946 }
2947 function KeyboardShortcutsRegister() {
2948 const { registerShortcut } = (0, import_data11.useDispatch)(import_keyboard_shortcuts.store);
2949 (0, import_element10.useEffect)(() => {
2950 registerShortcut({
2951 name: "core/edit-widgets/undo",
2952 category: "global",
2953 description: (0, import_i18n6.__)("Undo your last changes."),
2954 keyCombination: {
2955 modifier: "primary",
2956 character: "z"
2957 }
2958 });
2959 registerShortcut({
2960 name: "core/edit-widgets/redo",
2961 category: "global",
2962 description: (0, import_i18n6.__)("Redo your last undo."),
2963 keyCombination: {
2964 modifier: "primaryShift",
2965 character: "z"
2966 },
2967 // Disable on Apple OS because it conflicts with the browser's
2968 // history shortcut. It's a fine alias for both Windows and Linux.
2969 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
2970 // Linux, we keep it as the default for consistency.
2971 aliases: (0, import_keycodes.isAppleOS)() ? [] : [
2972 {
2973 modifier: "primary",
2974 character: "y"
2975 }
2976 ]
2977 });
2978 registerShortcut({
2979 name: "core/edit-widgets/save",
2980 category: "global",
2981 description: (0, import_i18n6.__)("Save your changes."),
2982 keyCombination: {
2983 modifier: "primary",
2984 character: "s"
2985 }
2986 });
2987 registerShortcut({
2988 name: "core/edit-widgets/keyboard-shortcuts",
2989 category: "main",
2990 description: (0, import_i18n6.__)("Display these keyboard shortcuts."),
2991 keyCombination: {
2992 modifier: "access",
2993 character: "h"
2994 }
2995 });
2996 registerShortcut({
2997 name: "core/edit-widgets/next-region",
2998 category: "global",
2999 description: (0, import_i18n6.__)("Navigate to the next part of the editor."),
3000 keyCombination: {
3001 modifier: "ctrl",
3002 character: "`"
3003 },
3004 aliases: [
3005 {
3006 modifier: "access",
3007 character: "n"
3008 }
3009 ]
3010 });
3011 registerShortcut({
3012 name: "core/edit-widgets/previous-region",
3013 category: "global",
3014 description: (0, import_i18n6.__)("Navigate to the previous part of the editor."),
3015 keyCombination: {
3016 modifier: "ctrlShift",
3017 character: "`"
3018 },
3019 aliases: [
3020 {
3021 modifier: "access",
3022 character: "p"
3023 },
3024 {
3025 modifier: "ctrlShift",
3026 character: "~"
3027 }
3028 ]
3029 });
3030 }, [registerShortcut]);
3031 return null;
3032 }
3033 KeyboardShortcuts.Register = KeyboardShortcutsRegister;
3034 var keyboard_shortcuts_default = KeyboardShortcuts;
3035
3036 // packages/edit-widgets/build-module/hooks/use-last-selected-widget-area.mjs
3037 var import_data12 = __toESM(require_data(), 1);
3038 var import_block_editor7 = __toESM(require_block_editor(), 1);
3039 var import_core_data7 = __toESM(require_core_data(), 1);
3040 var useLastSelectedWidgetArea = () => (0, import_data12.useSelect)((select) => {
3041 const { getBlockSelectionEnd, getBlockName } = select(import_block_editor7.store);
3042 const selectionEndClientId = getBlockSelectionEnd();
3043 if (getBlockName(selectionEndClientId) === "core/widget-area") {
3044 return selectionEndClientId;
3045 }
3046 const { getParentWidgetAreaBlock: getParentWidgetAreaBlock2 } = select(store2);
3047 const widgetAreaBlock = getParentWidgetAreaBlock2(selectionEndClientId);
3048 const widgetAreaBlockClientId = widgetAreaBlock?.clientId;
3049 if (widgetAreaBlockClientId) {
3050 return widgetAreaBlockClientId;
3051 }
3052 const { getEntityRecord } = select(import_core_data7.store);
3053 const widgetAreasPost = getEntityRecord(
3054 KIND,
3055 POST_TYPE,
3056 buildWidgetAreasPostId()
3057 );
3058 return widgetAreasPost?.blocks[0]?.clientId;
3059 }, []);
3060 var use_last_selected_widget_area_default = useLastSelectedWidgetArea;
3061
3062 // packages/edit-widgets/build-module/constants.mjs
3063 var ALLOW_REUSABLE_BLOCKS = false;
3064 var ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
3065
3066 // packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.mjs
3067 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
3068 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor8.privateApis);
3069 var { PatternsMenuItems } = unlock(import_patterns.privateApis);
3070 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis);
3071 var EMPTY_ARRAY2 = [];
3072 function WidgetAreasBlockEditorProvider({
3073 blockEditorSettings,
3074 children,
3075 ...props
3076 }) {
3077 const isLargeViewport = (0, import_compose5.useViewportMatch)("medium");
3078 const {
3079 hasUploadPermissions,
3080 reusableBlocks,
3081 isFixedToolbarActive,
3082 keepCaretInsideBlock,
3083 pageOnFront,
3084 pageForPosts
3085 } = (0, import_data13.useSelect)((select) => {
3086 const { canUser, getEntityRecord, getEntityRecords } = select(import_core_data8.store);
3087 const siteSettings = canUser("read", {
3088 kind: "root",
3089 name: "site"
3090 }) ? getEntityRecord("root", "site") : void 0;
3091 return {
3092 hasUploadPermissions: canUser("create", {
3093 kind: "postType",
3094 name: "attachment"
3095 }) ?? true,
3096 reusableBlocks: ALLOW_REUSABLE_BLOCKS ? getEntityRecords("postType", "wp_block") : EMPTY_ARRAY2,
3097 isFixedToolbarActive: !!select(import_preferences4.store).get(
3098 "core/edit-widgets",
3099 "fixedToolbar"
3100 ),
3101 keepCaretInsideBlock: !!select(import_preferences4.store).get(
3102 "core/edit-widgets",
3103 "keepCaretInsideBlock"
3104 ),
3105 pageOnFront: siteSettings?.page_on_front,
3106 pageForPosts: siteSettings?.page_for_posts
3107 };
3108 }, []);
3109 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data13.useDispatch)(store2);
3110 const settings2 = (0, import_element11.useMemo)(() => {
3111 let mediaUploadBlockEditor;
3112 if (hasUploadPermissions) {
3113 mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => {
3114 (0, import_media_utils2.uploadMedia)({
3115 wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
3116 onError: ({ message }) => onError(message),
3117 ...argumentsObject
3118 });
3119 };
3120 }
3121 return {
3122 ...blockEditorSettings,
3123 __experimentalReusableBlocks: reusableBlocks,
3124 hasFixedToolbar: isFixedToolbarActive || !isLargeViewport,
3125 keepCaretInsideBlock,
3126 mediaUpload: mediaUploadBlockEditor,
3127 templateLock: "all",
3128 __experimentalSetIsInserterOpened: setIsInserterOpened2,
3129 pageOnFront,
3130 pageForPosts,
3131 editorTool: "edit"
3132 };
3133 }, [
3134 hasUploadPermissions,
3135 blockEditorSettings,
3136 isFixedToolbarActive,
3137 isLargeViewport,
3138 keepCaretInsideBlock,
3139 reusableBlocks,
3140 setIsInserterOpened2,
3141 pageOnFront,
3142 pageForPosts
3143 ]);
3144 const widgetAreaId = use_last_selected_widget_area_default();
3145 const [blocks, onInput, onChange] = (0, import_core_data8.useEntityBlockEditor)(
3146 KIND,
3147 POST_TYPE,
3148 { id: buildWidgetAreasPostId() }
3149 );
3150 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_components9.SlotFillProvider, { children: [
3151 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(keyboard_shortcuts_default.Register, {}),
3152 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BlockKeyboardShortcuts, {}),
3153 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3154 ExperimentalBlockEditorProvider,
3155 {
3156 value: blocks,
3157 onInput,
3158 onChange,
3159 settings: settings2,
3160 useSubRegistry: false,
3161 ...props,
3162 children: [
3163 children,
3164 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PatternsMenuItems, { rootClientId: widgetAreaId })
3165 ]
3166 }
3167 )
3168 ] });
3169 }
3170
3171 // packages/edit-widgets/build-module/components/sidebar/index.mjs
3172 var import_element13 = __toESM(require_element(), 1);
3173 var import_i18n8 = __toESM(require_i18n(), 1);
3174 var import_block_editor10 = __toESM(require_block_editor(), 1);
3175 var import_components11 = __toESM(require_components(), 1);
3176 var import_data15 = __toESM(require_data(), 1);
3177
3178 // packages/edit-widgets/build-module/components/sidebar/widget-areas.mjs
3179 var import_data14 = __toESM(require_data(), 1);
3180 var import_element12 = __toESM(require_element(), 1);
3181 var import_block_editor9 = __toESM(require_block_editor(), 1);
3182 var import_components10 = __toESM(require_components(), 1);
3183 var import_i18n7 = __toESM(require_i18n(), 1);
3184 var import_url = __toESM(require_url(), 1);
3185 var import_dom = __toESM(require_dom(), 1);
3186 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
3187 function WidgetAreas({ selectedWidgetAreaId }) {
3188 const widgetAreas = (0, import_data14.useSelect)(
3189 (select) => select(store2).getWidgetAreas(),
3190 []
3191 );
3192 const selectedWidgetArea = (0, import_element12.useMemo)(
3193 () => selectedWidgetAreaId && widgetAreas?.find(
3194 (widgetArea) => widgetArea.id === selectedWidgetAreaId
3195 ),
3196 [selectedWidgetAreaId, widgetAreas]
3197 );
3198 let description;
3199 if (!selectedWidgetArea) {
3200 description = (0, import_i18n7.__)(
3201 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
3202 "Widget Areas are global parts in your site\u2019s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer."
3203 );
3204 } else if (selectedWidgetAreaId === "wp_inactive_widgets") {
3205 description = (0, import_i18n7.__)(
3206 "Blocks in this Widget Area will not be displayed in your site."
3207 );
3208 } else {
3209 description = selectedWidgetArea.description;
3210 }
3211 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "edit-widgets-widget-areas", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "edit-widgets-widget-areas__top-container", children: [
3212 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_block_editor9.BlockIcon, { icon: block_default_default }),
3213 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { children: [
3214 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3215 "p",
3216 {
3217 dangerouslySetInnerHTML: {
3218 __html: (0, import_dom.safeHTML)(description)
3219 }
3220 }
3221 ),
3222 widgetAreas?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: (0, import_i18n7.__)(
3223 "Your theme does not contain any Widget Areas."
3224 ) }),
3225 !selectedWidgetArea && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3226 import_components10.Button,
3227 {
3228 __next40pxDefaultSize: true,
3229 href: (0, import_url.addQueryArgs)("customize.php", {
3230 "autofocus[panel]": "widgets",
3231 return: window.location.pathname
3232 }),
3233 variant: "tertiary",
3234 children: (0, import_i18n7.__)("Manage with live preview")
3235 }
3236 )
3237 ] })
3238 ] }) });
3239 }
3240
3241 // packages/edit-widgets/build-module/components/sidebar/index.mjs
3242 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3243 var SIDEBAR_ACTIVE_BY_DEFAULT = true;
3244 var BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector";
3245 var WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas";
3246 var { Tabs } = unlock(import_components11.privateApis);
3247 function SidebarHeader({ selectedWidgetAreaBlock }) {
3248 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.TabList, { children: [
3249 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: WIDGET_AREAS_IDENTIFIER, children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0, import_i18n8.__)("Widget Areas") }),
3250 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: BLOCK_INSPECTOR_IDENTIFIER, children: (0, import_i18n8.__)("Block") })
3251 ] });
3252 }
3253 function SidebarContent({
3254 hasSelectedNonAreaBlock,
3255 currentArea,
3256 isGeneralSidebarOpen,
3257 selectedWidgetAreaBlock
3258 }) {
3259 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store);
3260 (0, import_element13.useEffect)(() => {
3261 if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) {
3262 enableComplementaryArea2(
3263 "core/edit-widgets",
3264 BLOCK_INSPECTOR_IDENTIFIER
3265 );
3266 }
3267 if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) {
3268 enableComplementaryArea2(
3269 "core/edit-widgets",
3270 WIDGET_AREAS_IDENTIFIER
3271 );
3272 }
3273 }, [hasSelectedNonAreaBlock, enableComplementaryArea2]);
3274 const tabsContextValue = (0, import_element13.useContext)(Tabs.Context);
3275 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3276 complementary_area_default,
3277 {
3278 className: "edit-widgets-sidebar",
3279 header: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3280 SidebarHeader,
3281 {
3282 selectedWidgetAreaBlock
3283 }
3284 ) }),
3285 headerClassName: "edit-widgets-sidebar__panel-tabs",
3286 title: (0, import_i18n8.__)("Settings"),
3287 closeLabel: (0, import_i18n8.__)("Close Settings"),
3288 scope: "core/edit-widgets",
3289 identifier: currentArea,
3290 icon: (0, import_i18n8.isRTL)() ? drawer_left_default : drawer_right_default,
3291 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
3292 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.Context.Provider, { value: tabsContextValue, children: [
3293 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3294 Tabs.TabPanel,
3295 {
3296 tabId: WIDGET_AREAS_IDENTIFIER,
3297 focusable: false,
3298 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3299 WidgetAreas,
3300 {
3301 selectedWidgetAreaId: selectedWidgetAreaBlock?.attributes.id
3302 }
3303 )
3304 }
3305 ),
3306 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3307 Tabs.TabPanel,
3308 {
3309 tabId: BLOCK_INSPECTOR_IDENTIFIER,
3310 focusable: false,
3311 children: hasSelectedNonAreaBlock ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_block_editor10.BlockInspector, {}) : (
3312 // Pretend that Widget Areas are part of the UI by not
3313 // showing the Block Inspector when one is selected.
3314 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "block-editor-block-inspector__no-blocks", children: (0, import_i18n8.__)("No block selected.") })
3315 )
3316 }
3317 )
3318 ] })
3319 }
3320 );
3321 }
3322 function Sidebar() {
3323 const {
3324 currentArea,
3325 hasSelectedNonAreaBlock,
3326 isGeneralSidebarOpen,
3327 selectedWidgetAreaBlock
3328 } = (0, import_data15.useSelect)((select) => {
3329 const { getSelectedBlock, getBlock, getBlockParentsByBlockName } = select(import_block_editor10.store);
3330 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select(store);
3331 const selectedBlock = getSelectedBlock();
3332 const activeArea = getActiveComplementaryArea2(store2.name);
3333 let currentSelection = activeArea;
3334 if (!currentSelection) {
3335 if (selectedBlock) {
3336 currentSelection = BLOCK_INSPECTOR_IDENTIFIER;
3337 } else {
3338 currentSelection = WIDGET_AREAS_IDENTIFIER;
3339 }
3340 }
3341 let widgetAreaBlock;
3342 if (selectedBlock) {
3343 if (selectedBlock.name === "core/widget-area") {
3344 widgetAreaBlock = selectedBlock;
3345 } else {
3346 widgetAreaBlock = getBlock(
3347 getBlockParentsByBlockName(
3348 selectedBlock.clientId,
3349 "core/widget-area"
3350 )[0]
3351 );
3352 }
3353 }
3354 return {
3355 currentArea: currentSelection,
3356 hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== "core/widget-area"),
3357 isGeneralSidebarOpen: !!activeArea,
3358 selectedWidgetAreaBlock: widgetAreaBlock
3359 };
3360 }, []);
3361 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store);
3362 const onTabSelect = (0, import_element13.useCallback)(
3363 (newSelectedTabId) => {
3364 if (!!newSelectedTabId) {
3365 enableComplementaryArea2(
3366 store2.name,
3367 newSelectedTabId
3368 );
3369 }
3370 },
3371 [enableComplementaryArea2]
3372 );
3373 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3374 Tabs,
3375 {
3376 selectedTabId: isGeneralSidebarOpen ? currentArea : null,
3377 onSelect: onTabSelect,
3378 selectOnMove: false,
3379 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3380 SidebarContent,
3381 {
3382 hasSelectedNonAreaBlock,
3383 currentArea,
3384 isGeneralSidebarOpen,
3385 selectedWidgetAreaBlock
3386 }
3387 )
3388 }
3389 );
3390 }
3391
3392 // packages/edit-widgets/build-module/components/layout/interface.mjs
3393 var import_compose12 = __toESM(require_compose(), 1);
3394 var import_block_editor17 = __toESM(require_block_editor(), 1);
3395 var import_element23 = __toESM(require_element(), 1);
3396 var import_data28 = __toESM(require_data(), 1);
3397 var import_i18n18 = __toESM(require_i18n(), 1);
3398 var import_preferences8 = __toESM(require_preferences(), 1);
3399
3400 // packages/edit-widgets/build-module/components/header/index.mjs
3401 var import_block_editor12 = __toESM(require_block_editor(), 1);
3402 var import_data22 = __toESM(require_data(), 1);
3403 var import_element19 = __toESM(require_element(), 1);
3404 var import_i18n16 = __toESM(require_i18n(), 1);
3405 var import_components19 = __toESM(require_components(), 1);
3406 var import_compose8 = __toESM(require_compose(), 1);
3407 var import_preferences6 = __toESM(require_preferences(), 1);
3408
3409 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs
3410 var import_data18 = __toESM(require_data(), 1);
3411 var import_i18n11 = __toESM(require_i18n(), 1);
3412 var import_components14 = __toESM(require_components(), 1);
3413 var import_block_editor11 = __toESM(require_block_editor(), 1);
3414 var import_element16 = __toESM(require_element(), 1);
3415 var import_compose6 = __toESM(require_compose(), 1);
3416
3417 // packages/edit-widgets/build-module/components/header/undo-redo/undo.mjs
3418 var import_i18n9 = __toESM(require_i18n(), 1);
3419 var import_components12 = __toESM(require_components(), 1);
3420 var import_data16 = __toESM(require_data(), 1);
3421 var import_keycodes2 = __toESM(require_keycodes(), 1);
3422 var import_core_data9 = __toESM(require_core_data(), 1);
3423 var import_element14 = __toESM(require_element(), 1);
3424 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3425 function UndoButton(props, ref) {
3426 const hasUndo = (0, import_data16.useSelect)(
3427 (select) => select(import_core_data9.store).hasUndo(),
3428 []
3429 );
3430 const { undo } = (0, import_data16.useDispatch)(import_core_data9.store);
3431 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
3432 import_components12.Button,
3433 {
3434 ...props,
3435 ref,
3436 icon: !(0, import_i18n9.isRTL)() ? undo_default : redo_default,
3437 label: (0, import_i18n9.__)("Undo"),
3438 shortcut: import_keycodes2.displayShortcut.primary("z"),
3439 "aria-disabled": !hasUndo,
3440 onClick: hasUndo ? undo : void 0,
3441 size: "compact"
3442 }
3443 );
3444 }
3445 var undo_default2 = (0, import_element14.forwardRef)(UndoButton);
3446
3447 // packages/edit-widgets/build-module/components/header/undo-redo/redo.mjs
3448 var import_i18n10 = __toESM(require_i18n(), 1);
3449 var import_components13 = __toESM(require_components(), 1);
3450 var import_data17 = __toESM(require_data(), 1);
3451 var import_keycodes3 = __toESM(require_keycodes(), 1);
3452 var import_core_data10 = __toESM(require_core_data(), 1);
3453 var import_element15 = __toESM(require_element(), 1);
3454 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3455 function RedoButton(props, ref) {
3456 const shortcut = (0, import_keycodes3.isAppleOS)() ? import_keycodes3.displayShortcut.primaryShift("z") : import_keycodes3.displayShortcut.primary("y");
3457 const hasRedo = (0, import_data17.useSelect)(
3458 (select) => select(import_core_data10.store).hasRedo(),
3459 []
3460 );
3461 const { redo } = (0, import_data17.useDispatch)(import_core_data10.store);
3462 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3463 import_components13.Button,
3464 {
3465 ...props,
3466 ref,
3467 icon: !(0, import_i18n10.isRTL)() ? redo_default : undo_default,
3468 label: (0, import_i18n10.__)("Redo"),
3469 shortcut,
3470 "aria-disabled": !hasRedo,
3471 onClick: hasRedo ? redo : void 0,
3472 size: "compact"
3473 }
3474 );
3475 }
3476 var redo_default2 = (0, import_element15.forwardRef)(RedoButton);
3477
3478 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs
3479 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3480 function DocumentTools() {
3481 const isMediumViewport = (0, import_compose6.useViewportMatch)("medium");
3482 const {
3483 isInserterOpen,
3484 isListViewOpen,
3485 inserterSidebarToggleRef: inserterSidebarToggleRef2,
3486 listViewToggleRef: listViewToggleRef2
3487 } = (0, import_data18.useSelect)((select) => {
3488 const {
3489 isInserterOpened: isInserterOpened2,
3490 getInserterSidebarToggleRef: getInserterSidebarToggleRef2,
3491 isListViewOpened: isListViewOpened2,
3492 getListViewToggleRef: getListViewToggleRef2
3493 } = unlock(select(store2));
3494 return {
3495 isInserterOpen: isInserterOpened2(),
3496 isListViewOpen: isListViewOpened2(),
3497 inserterSidebarToggleRef: getInserterSidebarToggleRef2(),
3498 listViewToggleRef: getListViewToggleRef2()
3499 };
3500 }, []);
3501 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2 } = (0, import_data18.useDispatch)(store2);
3502 const toggleListView = (0, import_element16.useCallback)(
3503 () => setIsListViewOpened2(!isListViewOpen),
3504 [setIsListViewOpened2, isListViewOpen]
3505 );
3506 const toggleInserterSidebar = (0, import_element16.useCallback)(
3507 () => setIsInserterOpened2(!isInserterOpen),
3508 [setIsInserterOpened2, isInserterOpen]
3509 );
3510 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3511 import_block_editor11.NavigableToolbar,
3512 {
3513 className: "edit-widgets-header-toolbar",
3514 "aria-label": (0, import_i18n11.__)("Document tools"),
3515 variant: "unstyled",
3516 children: [
3517 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3518 import_components14.ToolbarItem,
3519 {
3520 ref: inserterSidebarToggleRef2,
3521 as: import_components14.Button,
3522 className: "edit-widgets-header-toolbar__inserter-toggle",
3523 variant: "primary",
3524 isPressed: isInserterOpen,
3525 onMouseDown: (event) => {
3526 event.preventDefault();
3527 },
3528 onClick: toggleInserterSidebar,
3529 icon: plus_default,
3530 label: (0, import_i18n11._x)(
3531 "Block Inserter",
3532 "Generic label for block inserter button"
3533 ),
3534 size: "compact"
3535 }
3536 ),
3537 isMediumViewport && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
3538 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: undo_default2 }),
3539 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: redo_default2 }),
3540 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3541 import_components14.ToolbarItem,
3542 {
3543 as: import_components14.Button,
3544 className: "edit-widgets-header-toolbar__list-view-toggle",
3545 icon: list_view_default,
3546 isPressed: isListViewOpen,
3547 label: (0, import_i18n11.__)("List View"),
3548 onClick: toggleListView,
3549 ref: listViewToggleRef2,
3550 size: "compact"
3551 }
3552 )
3553 ] })
3554 ]
3555 }
3556 );
3557 }
3558 var document_tools_default = DocumentTools;
3559
3560 // packages/edit-widgets/build-module/components/save-button/index.mjs
3561 var import_components15 = __toESM(require_components(), 1);
3562 var import_i18n12 = __toESM(require_i18n(), 1);
3563 var import_data19 = __toESM(require_data(), 1);
3564 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3565 function SaveButton() {
3566 const { hasEditedWidgetAreaIds, isSaving, isWidgetSaveLocked } = (0, import_data19.useSelect)(
3567 (select) => {
3568 const {
3569 getEditedWidgetAreas: getEditedWidgetAreas2,
3570 isSavingWidgetAreas: isSavingWidgetAreas2,
3571 isWidgetSavingLocked: isWidgetSavingLocked2
3572 } = select(store2);
3573 return {
3574 hasEditedWidgetAreaIds: getEditedWidgetAreas2()?.length > 0,
3575 isSaving: isSavingWidgetAreas2(),
3576 isWidgetSaveLocked: isWidgetSavingLocked2()
3577 };
3578 },
3579 []
3580 );
3581 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data19.useDispatch)(store2);
3582 const isDisabled = isWidgetSaveLocked || isSaving || !hasEditedWidgetAreaIds;
3583 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3584 import_components15.Button,
3585 {
3586 variant: "primary",
3587 isBusy: isSaving,
3588 "aria-disabled": isDisabled,
3589 onClick: isDisabled ? void 0 : saveEditedWidgetAreas2,
3590 size: "compact",
3591 children: isSaving ? (0, import_i18n12.__)("Saving\u2026") : (0, import_i18n12.__)("Update")
3592 }
3593 );
3594 }
3595 var save_button_default = SaveButton;
3596
3597 // packages/edit-widgets/build-module/components/more-menu/index.mjs
3598 var import_components18 = __toESM(require_components(), 1);
3599 var import_element18 = __toESM(require_element(), 1);
3600 var import_i18n15 = __toESM(require_i18n(), 1);
3601 var import_preferences5 = __toESM(require_preferences(), 1);
3602 var import_keycodes5 = __toESM(require_keycodes(), 1);
3603 var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts(), 1);
3604 var import_compose7 = __toESM(require_compose(), 1);
3605
3606 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
3607 var import_components16 = __toESM(require_components(), 1);
3608 var import_i18n14 = __toESM(require_i18n(), 1);
3609 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts(), 1);
3610 var import_data21 = __toESM(require_data(), 1);
3611
3612 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/config.mjs
3613 var import_i18n13 = __toESM(require_i18n(), 1);
3614 var textFormattingShortcuts = [
3615 {
3616 keyCombination: { modifier: "primary", character: "b" },
3617 description: (0, import_i18n13.__)("Make the selected text bold.")
3618 },
3619 {
3620 keyCombination: { modifier: "primary", character: "i" },
3621 description: (0, import_i18n13.__)("Make the selected text italic.")
3622 },
3623 {
3624 keyCombination: { modifier: "primary", character: "k" },
3625 description: (0, import_i18n13.__)("Convert the selected text into a link.")
3626 },
3627 {
3628 keyCombination: { modifier: "primaryShift", character: "k" },
3629 description: (0, import_i18n13.__)("Remove a link.")
3630 },
3631 {
3632 keyCombination: { character: "[[" },
3633 description: (0, import_i18n13.__)("Insert a link to a post or page.")
3634 },
3635 {
3636 keyCombination: { modifier: "primary", character: "u" },
3637 description: (0, import_i18n13.__)("Underline the selected text.")
3638 },
3639 {
3640 keyCombination: { modifier: "access", character: "d" },
3641 description: (0, import_i18n13.__)("Strikethrough the selected text.")
3642 },
3643 {
3644 keyCombination: { modifier: "access", character: "x" },
3645 description: (0, import_i18n13.__)("Make the selected text inline code.")
3646 },
3647 {
3648 keyCombination: {
3649 modifier: "access",
3650 character: "0"
3651 },
3652 aliases: [
3653 {
3654 modifier: "access",
3655 character: "7"
3656 }
3657 ],
3658 description: (0, import_i18n13.__)("Convert the current heading to a paragraph.")
3659 },
3660 {
3661 keyCombination: { modifier: "access", character: "1-6" },
3662 description: (0, import_i18n13.__)(
3663 "Convert the current paragraph or heading to a heading of level 1 to 6."
3664 )
3665 },
3666 {
3667 keyCombination: { modifier: "primaryShift", character: "SPACE" },
3668 description: (0, import_i18n13.__)("Add non breaking space.")
3669 }
3670 ];
3671
3672 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs
3673 var import_element17 = __toESM(require_element(), 1);
3674 var import_keycodes4 = __toESM(require_keycodes(), 1);
3675 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3676 function KeyCombination({ keyCombination, forceAriaLabel }) {
3677 const shortcut = keyCombination.modifier ? import_keycodes4.displayShortcutList[keyCombination.modifier](
3678 keyCombination.character
3679 ) : keyCombination.character;
3680 const ariaLabel = keyCombination.modifier ? import_keycodes4.shortcutAriaLabel[keyCombination.modifier](
3681 keyCombination.character
3682 ) : keyCombination.character;
3683 const shortcuts = Array.isArray(shortcut) ? shortcut : [shortcut];
3684 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3685 "kbd",
3686 {
3687 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
3688 "aria-label": forceAriaLabel || ariaLabel,
3689 children: shortcuts.map((character, index) => {
3690 if (character === "+") {
3691 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_element17.Fragment, { children: character }, index);
3692 }
3693 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3694 "kbd",
3695 {
3696 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key",
3697 children: character
3698 },
3699 index
3700 );
3701 })
3702 }
3703 );
3704 }
3705 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
3706 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
3707 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-description", children: description }),
3708 /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-term", children: [
3709 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3710 KeyCombination,
3711 {
3712 keyCombination,
3713 forceAriaLabel: ariaLabel
3714 }
3715 ),
3716 aliases.map((alias, index) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3717 KeyCombination,
3718 {
3719 keyCombination: alias,
3720 forceAriaLabel: ariaLabel
3721 },
3722 index
3723 ))
3724 ] })
3725 ] });
3726 }
3727 var shortcut_default = Shortcut;
3728
3729 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs
3730 var import_data20 = __toESM(require_data(), 1);
3731 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts(), 1);
3732 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3733 function DynamicShortcut({ name: name2 }) {
3734 const { keyCombination, description, aliases } = (0, import_data20.useSelect)(
3735 (select) => {
3736 const {
3737 getShortcutKeyCombination,
3738 getShortcutDescription,
3739 getShortcutAliases
3740 } = select(import_keyboard_shortcuts3.store);
3741 return {
3742 keyCombination: getShortcutKeyCombination(name2),
3743 aliases: getShortcutAliases(name2),
3744 description: getShortcutDescription(name2)
3745 };
3746 },
3747 [name2]
3748 );
3749 if (!keyCombination) {
3750 return null;
3751 }
3752 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3753 shortcut_default,
3754 {
3755 keyCombination,
3756 description,
3757 aliases
3758 }
3759 );
3760 }
3761 var dynamic_shortcut_default = DynamicShortcut;
3762
3763 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
3764 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
3765 var ShortcutList = ({ shortcuts }) => (
3766 /*
3767 * Disable reason: The `list` ARIA role is redundant but
3768 * Safari+VoiceOver won't announce the list otherwise.
3769 */
3770 /* eslint-disable jsx-a11y/no-redundant-roles */
3771 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3772 "ul",
3773 {
3774 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-list",
3775 role: "list",
3776 children: shortcuts.map((shortcut, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3777 "li",
3778 {
3779 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut",
3780 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(shortcut_default, { ...shortcut })
3781 },
3782 index
3783 ))
3784 }
3785 )
3786 );
3787 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
3788 "section",
3789 {
3790 className: clsx_default(
3791 "edit-widgets-keyboard-shortcut-help-modal__section",
3792 className
3793 ),
3794 children: [
3795 !!title && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h2", { className: "edit-widgets-keyboard-shortcut-help-modal__section-title", children: title }),
3796 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ShortcutList, { shortcuts })
3797 ]
3798 }
3799 );
3800 var ShortcutCategorySection = ({
3801 title,
3802 categoryName,
3803 additionalShortcuts = []
3804 }) => {
3805 const categoryShortcuts = (0, import_data21.useSelect)(
3806 (select) => {
3807 return select(import_keyboard_shortcuts4.store).getCategoryShortcuts(
3808 categoryName
3809 );
3810 },
3811 [categoryName]
3812 );
3813 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3814 ShortcutSection,
3815 {
3816 title,
3817 shortcuts: categoryShortcuts.concat(additionalShortcuts)
3818 }
3819 );
3820 };
3821 function KeyboardShortcutHelpModal({
3822 isModalActive: isModalActive2,
3823 toggleModal
3824 }) {
3825 (0, import_keyboard_shortcuts4.useShortcut)("core/edit-widgets/keyboard-shortcuts", toggleModal, {
3826 bindGlobal: true
3827 });
3828 if (!isModalActive2) {
3829 return null;
3830 }
3831 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
3832 import_components16.Modal,
3833 {
3834 className: "edit-widgets-keyboard-shortcut-help-modal",
3835 title: (0, import_i18n14.__)("Keyboard shortcuts"),
3836 onRequestClose: toggleModal,
3837 children: [
3838 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3839 ShortcutSection,
3840 {
3841 className: "edit-widgets-keyboard-shortcut-help-modal__main-shortcuts",
3842 shortcuts: ["core/edit-widgets/keyboard-shortcuts"]
3843 }
3844 ),
3845 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3846 ShortcutCategorySection,
3847 {
3848 title: (0, import_i18n14.__)("Global shortcuts"),
3849 categoryName: "global"
3850 }
3851 ),
3852 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3853 ShortcutCategorySection,
3854 {
3855 title: (0, import_i18n14.__)("Selection shortcuts"),
3856 categoryName: "selection"
3857 }
3858 ),
3859 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3860 ShortcutCategorySection,
3861 {
3862 title: (0, import_i18n14.__)("Block shortcuts"),
3863 categoryName: "block",
3864 additionalShortcuts: [
3865 {
3866 keyCombination: { character: "/" },
3867 description: (0, import_i18n14.__)(
3868 "Change the block type after adding a new paragraph."
3869 ),
3870 /* translators: The forward-slash character. e.g. '/'. */
3871 ariaLabel: (0, import_i18n14.__)("Forward-slash")
3872 }
3873 ]
3874 }
3875 ),
3876 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3877 ShortcutSection,
3878 {
3879 title: (0, import_i18n14.__)("Text formatting"),
3880 shortcuts: textFormattingShortcuts
3881 }
3882 ),
3883 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3884 ShortcutCategorySection,
3885 {
3886 title: (0, import_i18n14.__)("List View shortcuts"),
3887 categoryName: "list-view"
3888 }
3889 )
3890 ]
3891 }
3892 );
3893 }
3894
3895 // packages/edit-widgets/build-module/components/more-menu/tools-more-menu-group.mjs
3896 var import_components17 = __toESM(require_components(), 1);
3897 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3898 var { Fill: ToolsMoreMenuGroup, Slot: Slot4 } = (0, import_components17.createSlotFill)(
3899 "EditWidgetsToolsMoreMenuGroup"
3900 );
3901 ToolsMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Slot4, { fillProps, children: (fills) => fills.length > 0 && fills });
3902 var tools_more_menu_group_default = ToolsMoreMenuGroup;
3903
3904 // packages/edit-widgets/build-module/components/more-menu/index.mjs
3905 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3906 function MoreMenu() {
3907 const [
3908 isKeyboardShortcutsModalActive,
3909 setIsKeyboardShortcutsModalVisible
3910 ] = (0, import_element18.useState)(false);
3911 const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive);
3912 (0, import_keyboard_shortcuts5.useShortcut)(
3913 "core/edit-widgets/keyboard-shortcuts",
3914 toggleKeyboardShortcutsModal
3915 );
3916 const isLargeViewport = (0, import_compose7.useViewportMatch)("medium");
3917 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3918 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3919 import_components18.DropdownMenu,
3920 {
3921 icon: more_vertical_default,
3922 label: (0, import_i18n15.__)("Options"),
3923 popoverProps: {
3924 placement: "bottom-end",
3925 className: "more-menu-dropdown__content"
3926 },
3927 toggleProps: {
3928 tooltipPosition: "bottom",
3929 size: "compact"
3930 },
3931 children: (onClose) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3932 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components18.MenuGroup, { label: (0, import_i18n15._x)("View", "noun"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3933 import_preferences5.PreferenceToggleMenuItem,
3934 {
3935 scope: "core/edit-widgets",
3936 name: "fixedToolbar",
3937 label: (0, import_i18n15.__)("Top toolbar"),
3938 info: (0, import_i18n15.__)(
3939 "Access all block and document tools in a single place"
3940 ),
3941 messageActivated: (0, import_i18n15.__)(
3942 "Top toolbar activated"
3943 ),
3944 messageDeactivated: (0, import_i18n15.__)(
3945 "Top toolbar deactivated"
3946 )
3947 }
3948 ) }),
3949 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Tools"), children: [
3950 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3951 import_components18.MenuItem,
3952 {
3953 onClick: () => {
3954 setIsKeyboardShortcutsModalVisible(true);
3955 },
3956 shortcut: import_keycodes5.displayShortcut.access("h"),
3957 children: (0, import_i18n15.__)("Keyboard shortcuts")
3958 }
3959 ),
3960 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3961 import_preferences5.PreferenceToggleMenuItem,
3962 {
3963 scope: "core/edit-widgets",
3964 name: "welcomeGuide",
3965 label: (0, import_i18n15.__)("Welcome Guide")
3966 }
3967 ),
3968 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3969 import_components18.MenuItem,
3970 {
3971 role: "menuitem",
3972 icon: external_default,
3973 href: (0, import_i18n15.__)(
3974 "https://wordpress.org/documentation/article/block-based-widgets-editor/"
3975 ),
3976 target: "_blank",
3977 rel: "noopener",
3978 children: [
3979 (0, import_i18n15.__)("Help"),
3980 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(VisuallyHidden, {
3981 render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", {}),
3982 /* translators: accessibility text */
3983 children: (0, import_i18n15.__)("(opens in a new tab)")
3984 })
3985 ]
3986 }
3987 ),
3988 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3989 tools_more_menu_group_default.Slot,
3990 {
3991 fillProps: { onClose }
3992 }
3993 )
3994 ] }),
3995 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Preferences"), children: [
3996 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3997 import_preferences5.PreferenceToggleMenuItem,
3998 {
3999 scope: "core/edit-widgets",
4000 name: "keepCaretInsideBlock",
4001 label: (0, import_i18n15.__)(
4002 "Contain text cursor inside block"
4003 ),
4004 info: (0, import_i18n15.__)(
4005 "Aids screen readers by stopping text caret from leaving blocks."
4006 ),
4007 messageActivated: (0, import_i18n15.__)(
4008 "Contain text cursor inside block activated"
4009 ),
4010 messageDeactivated: (0, import_i18n15.__)(
4011 "Contain text cursor inside block deactivated"
4012 )
4013 }
4014 ),
4015 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4016 import_preferences5.PreferenceToggleMenuItem,
4017 {
4018 scope: "core/edit-widgets",
4019 name: "themeStyles",
4020 info: (0, import_i18n15.__)(
4021 "Make the editor look like your theme."
4022 ),
4023 label: (0, import_i18n15.__)("Use theme styles")
4024 }
4025 ),
4026 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4027 import_preferences5.PreferenceToggleMenuItem,
4028 {
4029 scope: "core/edit-widgets",
4030 name: "showBlockBreadcrumbs",
4031 label: (0, import_i18n15.__)("Display block breadcrumbs"),
4032 info: (0, import_i18n15.__)(
4033 "Shows block breadcrumbs at the bottom of the editor."
4034 ),
4035 messageActivated: (0, import_i18n15.__)(
4036 "Display block breadcrumbs activated"
4037 ),
4038 messageDeactivated: (0, import_i18n15.__)(
4039 "Display block breadcrumbs deactivated"
4040 )
4041 }
4042 )
4043 ] })
4044 ] })
4045 }
4046 ),
4047 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4048 KeyboardShortcutHelpModal,
4049 {
4050 isModalActive: isKeyboardShortcutsModalActive,
4051 toggleModal: toggleKeyboardShortcutsModal
4052 }
4053 )
4054 ] });
4055 }
4056
4057 // packages/edit-widgets/build-module/components/header/index.mjs
4058 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
4059 function Header() {
4060 const isLargeViewport = (0, import_compose8.useViewportMatch)("medium");
4061 const blockToolbarRef = (0, import_element19.useRef)();
4062 const { hasFixedToolbar } = (0, import_data22.useSelect)(
4063 (select) => ({
4064 hasFixedToolbar: !!select(import_preferences6.store).get(
4065 "core/edit-widgets",
4066 "fixedToolbar"
4067 )
4068 }),
4069 []
4070 );
4071 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header", children: [
4072 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__navigable-toolbar-wrapper", children: [
4073 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h1", { className: "edit-widgets-header__title", children: (0, import_i18n16.__)("Widgets") }),
4074 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4075 VisuallyHidden,
4076 {
4077 className: "edit-widgets-header__title",
4078 render: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h1", {}),
4079 children: (0, import_i18n16.__)("Widgets")
4080 }
4081 ),
4082 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(document_tools_default, {}),
4083 hasFixedToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
4084 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "selected-block-tools-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_block_editor12.BlockToolbar, { hideDragHandle: true }) }),
4085 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4086 import_components19.Popover.Slot,
4087 {
4088 ref: blockToolbarRef,
4089 name: "block-toolbar"
4090 }
4091 )
4092 ] })
4093 ] }),
4094 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__actions", children: [
4095 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(pinned_items_default.Slot, { scope: "core/edit-widgets" }),
4096 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(save_button_default, {}),
4097 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(MoreMenu, {})
4098 ] })
4099 ] }) });
4100 }
4101 var header_default = Header;
4102
4103 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs
4104 var import_block_editor13 = __toESM(require_block_editor(), 1);
4105 var import_compose9 = __toESM(require_compose(), 1);
4106 var import_data23 = __toESM(require_data(), 1);
4107 var import_element20 = __toESM(require_element(), 1);
4108 var import_preferences7 = __toESM(require_preferences(), 1);
4109
4110 // packages/edit-widgets/build-module/components/notices/index.mjs
4111 var import_notices2 = __toESM(require_notices(), 1);
4112 var import_theme = __toESM(require_theme(), 1);
4113 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
4114 function Notices() {
4115 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_theme.ThemeProvider, { cornerRadius: "none", children: [
4116 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4117 import_notices2.InlineNotices,
4118 {
4119 className: "edit-widgets-notices",
4120 pinnedNoticesClassName: "edit-widgets-notices__pinned",
4121 dismissibleNoticesClassName: "edit-widgets-notices__dismissible"
4122 }
4123 ),
4124 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_notices2.SnackbarNotices, { className: "edit-widgets-notices__snackbar" })
4125 ] });
4126 }
4127 var notices_default = Notices;
4128
4129 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs
4130 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
4131 function WidgetAreasBlockEditorContent({
4132 blockEditorSettings
4133 }) {
4134 const hasThemeStyles = (0, import_data23.useSelect)(
4135 (select) => !!select(import_preferences7.store).get(
4136 "core/edit-widgets",
4137 "themeStyles"
4138 ),
4139 []
4140 );
4141 const isLargeViewport = (0, import_compose9.useViewportMatch)("medium");
4142 const styles = (0, import_element20.useMemo)(() => {
4143 return hasThemeStyles ? blockEditorSettings.styles : [];
4144 }, [blockEditorSettings, hasThemeStyles]);
4145 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "edit-widgets-block-editor", children: [
4146 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(notices_default, {}),
4147 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockToolbar, { hideDragHandle: true }),
4148 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_block_editor13.BlockTools, { children: [
4149 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(keyboard_shortcuts_default, {}),
4150 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4151 import_block_editor13.__unstableEditorStyles,
4152 {
4153 styles,
4154 scope: ":where(.editor-styles-wrapper)"
4155 }
4156 ),
4157 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockSelectionClearer, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.WritingFlow, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor13.BlockList, { className: "edit-widgets-main-block-list" }) }) })
4158 ] })
4159 ] });
4160 }
4161
4162 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs
4163 var import_data27 = __toESM(require_data(), 1);
4164
4165 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs
4166 var import_block_editor15 = __toESM(require_block_editor(), 1);
4167 var import_compose10 = __toESM(require_compose(), 1);
4168 var import_element21 = __toESM(require_element(), 1);
4169 var import_data25 = __toESM(require_data(), 1);
4170
4171 // packages/edit-widgets/build-module/hooks/use-widget-library-insertion-point.mjs
4172 var import_data24 = __toESM(require_data(), 1);
4173 var import_block_editor14 = __toESM(require_block_editor(), 1);
4174 var import_core_data11 = __toESM(require_core_data(), 1);
4175 var useWidgetLibraryInsertionPoint = () => {
4176 const firstRootId = (0, import_data24.useSelect)((select) => {
4177 const { getEntityRecord } = select(import_core_data11.store);
4178 const widgetAreasPost = getEntityRecord(
4179 KIND,
4180 POST_TYPE,
4181 buildWidgetAreasPostId()
4182 );
4183 return widgetAreasPost?.blocks[0]?.clientId;
4184 }, []);
4185 return (0, import_data24.useSelect)(
4186 (select) => {
4187 const {
4188 getBlockRootClientId,
4189 getBlockSelectionEnd,
4190 getBlockOrder,
4191 getBlockIndex
4192 } = select(import_block_editor14.store);
4193 const insertionPoint = select(store2).__experimentalGetInsertionPoint();
4194 if (insertionPoint.rootClientId) {
4195 return insertionPoint;
4196 }
4197 const clientId = getBlockSelectionEnd() || firstRootId;
4198 const rootClientId = getBlockRootClientId(clientId);
4199 if (clientId && rootClientId === "") {
4200 return {
4201 rootClientId: clientId,
4202 insertionIndex: getBlockOrder(clientId).length
4203 };
4204 }
4205 return {
4206 rootClientId,
4207 insertionIndex: getBlockIndex(clientId) + 1
4208 };
4209 },
4210 [firstRootId]
4211 );
4212 };
4213 var use_widget_library_insertion_point_default = useWidgetLibraryInsertionPoint;
4214
4215 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs
4216 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
4217 function InserterSidebar() {
4218 const isMobileViewport = (0, import_compose10.useViewportMatch)("medium", "<");
4219 const { rootClientId, insertionIndex } = use_widget_library_insertion_point_default();
4220 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data25.useDispatch)(store2);
4221 const closeInserter = (0, import_element21.useCallback)(() => {
4222 return setIsInserterOpened2(false);
4223 }, [setIsInserterOpened2]);
4224 const libraryRef = (0, import_element21.useRef)();
4225 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "edit-widgets-layout__inserter-panel", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "edit-widgets-layout__inserter-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4226 import_block_editor15.__experimentalLibrary,
4227 {
4228 showInserterHelpPanel: true,
4229 shouldFocusBlock: isMobileViewport,
4230 rootClientId,
4231 __experimentalInsertionIndex: insertionIndex,
4232 ref: libraryRef,
4233 onClose: closeInserter
4234 }
4235 ) }) });
4236 }
4237
4238 // packages/edit-widgets/build-module/components/secondary-sidebar/list-view-sidebar.mjs
4239 var import_block_editor16 = __toESM(require_block_editor(), 1);
4240 var import_components20 = __toESM(require_components(), 1);
4241 var import_compose11 = __toESM(require_compose(), 1);
4242 var import_data26 = __toESM(require_data(), 1);
4243 var import_element22 = __toESM(require_element(), 1);
4244 var import_i18n17 = __toESM(require_i18n(), 1);
4245 var import_keycodes6 = __toESM(require_keycodes(), 1);
4246 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
4247 function ListViewSidebar() {
4248 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data26.useDispatch)(store2);
4249 const { getListViewToggleRef: getListViewToggleRef2 } = unlock((0, import_data26.useSelect)(store2));
4250 const [dropZoneElement, setDropZoneElement] = (0, import_element22.useState)(null);
4251 const focusOnMountRef = (0, import_compose11.useFocusOnMount)("firstElement");
4252 const closeListView = (0, import_element22.useCallback)(() => {
4253 setIsListViewOpened2(false);
4254 getListViewToggleRef2().current?.focus();
4255 }, [getListViewToggleRef2, setIsListViewOpened2]);
4256 const closeOnEscape = (0, import_element22.useCallback)(
4257 (event) => {
4258 if (event.keyCode === import_keycodes6.ESCAPE && !event.defaultPrevented) {
4259 event.preventDefault();
4260 closeListView();
4261 }
4262 },
4263 [closeListView]
4264 );
4265 return (
4266 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
4267 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
4268 "div",
4269 {
4270 className: "edit-widgets-editor__list-view-panel",
4271 onKeyDown: closeOnEscape,
4272 children: [
4273 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "edit-widgets-editor__list-view-panel-header", children: [
4274 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: (0, import_i18n17.__)("List View") }),
4275 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4276 import_components20.Button,
4277 {
4278 icon: close_small_default,
4279 label: (0, import_i18n17.__)("Close"),
4280 onClick: closeListView,
4281 size: "compact"
4282 }
4283 )
4284 ] }),
4285 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4286 "div",
4287 {
4288 className: "edit-widgets-editor__list-view-panel-content",
4289 ref: (0, import_compose11.useMergeRefs)([focusOnMountRef, setDropZoneElement]),
4290 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_block_editor16.__experimentalListView, { dropZoneElement })
4291 }
4292 )
4293 ]
4294 }
4295 )
4296 );
4297 }
4298
4299 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs
4300 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
4301 function SecondarySidebar() {
4302 const { isInserterOpen, isListViewOpen } = (0, import_data27.useSelect)((select) => {
4303 const { isInserterOpened: isInserterOpened2, isListViewOpened: isListViewOpened2 } = select(store2);
4304 return {
4305 isInserterOpen: isInserterOpened2(),
4306 isListViewOpen: isListViewOpened2()
4307 };
4308 }, []);
4309 if (isInserterOpen) {
4310 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(InserterSidebar, {});
4311 }
4312 if (isListViewOpen) {
4313 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ListViewSidebar, {});
4314 }
4315 return null;
4316 }
4317
4318 // packages/edit-widgets/build-module/components/layout/interface.mjs
4319 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
4320 var interfaceLabels = {
4321 /* translators: accessibility text for the widgets screen top bar landmark region. */
4322 header: (0, import_i18n18.__)("Widgets top bar"),
4323 /* translators: accessibility text for the widgets screen content landmark region. */
4324 body: (0, import_i18n18.__)("Widgets and blocks"),
4325 /* translators: accessibility text for the widgets screen settings landmark region. */
4326 sidebar: (0, import_i18n18.__)("Widgets settings"),
4327 /* translators: accessibility text for the widgets screen footer landmark region. */
4328 footer: (0, import_i18n18.__)("Widgets footer")
4329 };
4330 function Interface({ blockEditorSettings }) {
4331 const isMobileViewport = (0, import_compose12.useViewportMatch)("medium", "<");
4332 const isHugeViewport = (0, import_compose12.useViewportMatch)("huge", ">=");
4333 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2, closeGeneralSidebar: closeGeneralSidebar2 } = (0, import_data28.useDispatch)(store2);
4334 const {
4335 hasBlockBreadCrumbsEnabled,
4336 hasSidebarEnabled,
4337 isInserterOpened: isInserterOpened2,
4338 isListViewOpened: isListViewOpened2
4339 } = (0, import_data28.useSelect)(
4340 (select) => ({
4341 hasSidebarEnabled: !!select(
4342 store
4343 ).getActiveComplementaryArea(store2.name),
4344 isInserterOpened: !!select(store2).isInserterOpened(),
4345 isListViewOpened: !!select(store2).isListViewOpened(),
4346 hasBlockBreadCrumbsEnabled: !!select(import_preferences8.store).get(
4347 "core/edit-widgets",
4348 "showBlockBreadcrumbs"
4349 )
4350 }),
4351 []
4352 );
4353 (0, import_element23.useEffect)(() => {
4354 if (hasSidebarEnabled && !isHugeViewport) {
4355 setIsInserterOpened2(false);
4356 setIsListViewOpened2(false);
4357 }
4358 }, [hasSidebarEnabled, isHugeViewport]);
4359 (0, import_element23.useEffect)(() => {
4360 if ((isInserterOpened2 || isListViewOpened2) && !isHugeViewport) {
4361 closeGeneralSidebar2();
4362 }
4363 }, [isInserterOpened2, isListViewOpened2, isHugeViewport]);
4364 const secondarySidebarLabel = isListViewOpened2 ? (0, import_i18n18.__)("List View") : (0, import_i18n18.__)("Block Library");
4365 const hasSecondarySidebar = isListViewOpened2 || isInserterOpened2;
4366 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4367 interface_skeleton_default,
4368 {
4369 labels: {
4370 ...interfaceLabels,
4371 secondarySidebar: secondarySidebarLabel
4372 },
4373 header: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(header_default, {}),
4374 secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SecondarySidebar, {}),
4375 sidebar: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(complementary_area_default.Slot, { scope: "core/edit-widgets" }),
4376 content: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4377 WidgetAreasBlockEditorContent,
4378 {
4379 blockEditorSettings
4380 }
4381 ) }),
4382 footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "edit-widgets-layout__footer", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_block_editor17.BlockBreadcrumb, { rootLabelText: (0, import_i18n18.__)("Widgets") }) })
4383 }
4384 );
4385 }
4386 var interface_default = Interface;
4387
4388 // packages/edit-widgets/build-module/components/layout/unsaved-changes-warning.mjs
4389 var import_i18n19 = __toESM(require_i18n(), 1);
4390 var import_element24 = __toESM(require_element(), 1);
4391 var import_data29 = __toESM(require_data(), 1);
4392 function UnsavedChangesWarning() {
4393 const isDirty = (0, import_data29.useSelect)((select) => {
4394 const { getEditedWidgetAreas: getEditedWidgetAreas2 } = select(store2);
4395 const editedWidgetAreas = getEditedWidgetAreas2();
4396 return editedWidgetAreas?.length > 0;
4397 }, []);
4398 (0, import_element24.useEffect)(() => {
4399 const warnIfUnsavedChanges = (event) => {
4400 if (isDirty) {
4401 event.returnValue = (0, import_i18n19.__)(
4402 "You have unsaved changes. If you proceed, they will be lost."
4403 );
4404 return event.returnValue;
4405 }
4406 };
4407 window.addEventListener("beforeunload", warnIfUnsavedChanges);
4408 return () => {
4409 window.removeEventListener("beforeunload", warnIfUnsavedChanges);
4410 };
4411 }, [isDirty]);
4412 return null;
4413 }
4414
4415 // packages/edit-widgets/build-module/components/welcome-guide/index.mjs
4416 var import_data30 = __toESM(require_data(), 1);
4417 var import_components21 = __toESM(require_components(), 1);
4418 var import_i18n20 = __toESM(require_i18n(), 1);
4419 var import_element25 = __toESM(require_element(), 1);
4420 var import_preferences9 = __toESM(require_preferences(), 1);
4421 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
4422 function WelcomeGuide() {
4423 const isActive = (0, import_data30.useSelect)(
4424 (select) => !!select(import_preferences9.store).get(
4425 "core/edit-widgets",
4426 "welcomeGuide"
4427 ),
4428 []
4429 );
4430 const { toggle } = (0, import_data30.useDispatch)(import_preferences9.store);
4431 const widgetAreas = (0, import_data30.useSelect)(
4432 (select) => select(store2).getWidgetAreas({ per_page: -1 }),
4433 []
4434 );
4435 if (!isActive) {
4436 return null;
4437 }
4438 const isEntirelyBlockWidgets = widgetAreas?.every(
4439 (widgetArea) => widgetArea.id === "wp_inactive_widgets" || widgetArea.widgets.every(
4440 (widgetId) => widgetId.startsWith("block-")
4441 )
4442 );
4443 const numWidgetAreas = widgetAreas?.filter(
4444 (widgetArea) => widgetArea.id !== "wp_inactive_widgets"
4445 ).length ?? 0;
4446 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4447 import_components21.Guide,
4448 {
4449 className: "edit-widgets-welcome-guide",
4450 contentLabel: (0, import_i18n20.__)("Welcome to block Widgets"),
4451 finishButtonText: (0, import_i18n20.__)("Get started"),
4452 onFinish: () => toggle("core/edit-widgets", "welcomeGuide"),
4453 pages: [
4454 {
4455 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4456 WelcomeGuideImage,
4457 {
4458 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
4459 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
4460 }
4461 ),
4462 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4463 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Welcome to block Widgets") }),
4464 isEntirelyBlockWidgets ? /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_jsx_runtime45.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.sprintf)(
4465 // Translators: %s: Number of block areas in the current theme.
4466 (0, import_i18n20._n)(
4467 "Your theme provides %s \u201Cblock\u201D area for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.",
4468 "Your theme provides %s different \u201Cblock\u201D areas for you to add and edit content.\xA0Try adding a search bar, social icons, or other types of blocks here and see how they\u2019ll look on your site.",
4469 numWidgetAreas
4470 ),
4471 numWidgetAreas
4472 ) }) }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4473 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)(
4474 "You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly."
4475 ) }),
4476 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("p", { className: "edit-widgets-welcome-guide__text", children: [
4477 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("strong", { children: (0, import_i18n20.__)(
4478 "Want to stick with the old widgets?"
4479 ) }),
4480 " ",
4481 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4482 import_components21.ExternalLink,
4483 {
4484 href: (0, import_i18n20.__)(
4485 "https://wordpress.org/plugins/classic-widgets/"
4486 ),
4487 children: (0, import_i18n20.__)(
4488 "Get the Classic Widgets plugin."
4489 )
4490 }
4491 )
4492 ] })
4493 ] })
4494 ] })
4495 },
4496 {
4497 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4498 WelcomeGuideImage,
4499 {
4500 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
4501 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
4502 }
4503 ),
4504 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4505 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Customize each block") }),
4506 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)(
4507 "Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected."
4508 ) })
4509 ] })
4510 },
4511 {
4512 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4513 WelcomeGuideImage,
4514 {
4515 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
4516 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
4517 }
4518 ),
4519 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4520 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Explore all blocks") }),
4521 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
4522 (0, import_i18n20.__)(
4523 "All of the blocks available to you live in the block library. You\u2019ll find it wherever you see the <InserterIconImage /> icon."
4524 ),
4525 {
4526 InserterIconImage: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4527 "img",
4528 {
4529 className: "edit-widgets-welcome-guide__inserter-icon",
4530 alt: (0, import_i18n20.__)("inserter"),
4531 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A"
4532 }
4533 )
4534 }
4535 ) })
4536 ] })
4537 },
4538 {
4539 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4540 WelcomeGuideImage,
4541 {
4542 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
4543 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
4544 }
4545 ),
4546 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4547 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Learn more") }),
4548 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
4549 (0, import_i18n20.__)(
4550 "New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"
4551 ),
4552 {
4553 a: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4554 import_components21.ExternalLink,
4555 {
4556 href: (0, import_i18n20.__)(
4557 "https://wordpress.org/documentation/article/wordpress-block-editor/"
4558 )
4559 }
4560 )
4561 }
4562 ) })
4563 ] })
4564 }
4565 ]
4566 }
4567 );
4568 }
4569 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
4570 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("picture", { className: "edit-widgets-welcome-guide__image", children: [
4571 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4572 "source",
4573 {
4574 srcSet: nonAnimatedSrc,
4575 media: "(prefers-reduced-motion: reduce)"
4576 }
4577 ),
4578 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
4579 ] });
4580 }
4581
4582 // packages/edit-widgets/build-module/components/layout/index.mjs
4583 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
4584 function Layout({ blockEditorSettings }) {
4585 const { createErrorNotice } = (0, import_data31.useDispatch)(import_notices4.store);
4586 function onPluginAreaError(name2) {
4587 createErrorNotice(
4588 (0, import_i18n21.sprintf)(
4589 /* translators: %s: plugin name */
4590 (0, import_i18n21.__)(
4591 'The "%s" plugin has encountered an error and cannot be rendered.'
4592 ),
4593 name2
4594 )
4595 );
4596 }
4597 const navigateRegionsProps = (0, import_components22.__unstableUseNavigateRegions)();
4598 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4599 "div",
4600 {
4601 className: navigateRegionsProps.className,
4602 ...navigateRegionsProps,
4603 ref: navigateRegionsProps.ref,
4604 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4605 WidgetAreasBlockEditorProvider,
4606 {
4607 blockEditorSettings,
4608 children: [
4609 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(interface_default, { blockEditorSettings }),
4610 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Sidebar, {}),
4611 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_plugins3.PluginArea, { onError: onPluginAreaError }),
4612 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(UnsavedChangesWarning, {}),
4613 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(WelcomeGuide, {})
4614 ]
4615 }
4616 )
4617 }
4618 ) });
4619 }
4620 var layout_default = Layout;
4621
4622 // packages/edit-widgets/build-module/index.mjs
4623 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
4624 var disabledBlocks = [
4625 "core/more",
4626 "core/freeform",
4627 "core/template-part",
4628 ...ALLOW_REUSABLE_BLOCKS ? [] : ["core/block"]
4629 ];
4630 function initializeEditor(id, settings2) {
4631 const target = document.getElementById(id);
4632 const root = (0, import_element26.createRoot)(target);
4633 const coreBlocks = (0, import_block_library2.__experimentalGetCoreBlocks)().filter((block) => {
4634 return !(disabledBlocks.includes(block.name) || block.name.startsWith("core/post") || block.name.startsWith("core/query") || block.name.startsWith("core/site") || block.name.startsWith("core/navigation") || block.name.startsWith("core/term"));
4635 });
4636 (0, import_data32.dispatch)(import_preferences10.store).setDefaults("core/edit-widgets", {
4637 fixedToolbar: false,
4638 welcomeGuide: true,
4639 showBlockBreadcrumbs: true,
4640 themeStyles: true
4641 });
4642 (0, import_data32.dispatch)(import_blocks3.store).reapplyBlockTypeFilters();
4643 (0, import_block_library2.registerCoreBlocks)(coreBlocks);
4644 (0, import_widgets5.registerLegacyWidgetBlock)();
4645 if (true) {
4646 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({
4647 enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS
4648 });
4649 }
4650 (0, import_widgets5.registerLegacyWidgetVariations)(settings2);
4651 registerBlock(widget_area_exports);
4652 (0, import_widgets5.registerWidgetGroupBlock)();
4653 settings2.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0, import_core_data12.__experimentalFetchLinkSuggestions)(search, searchOptions, settings2);
4654 (0, import_blocks3.setFreeformContentHandlerName)("core/html");
4655 root.render(
4656 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_element26.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(layout_default, { blockEditorSettings: settings2 }) })
4657 );
4658 return root;
4659 }
4660 var initialize = initializeEditor;
4661 function reinitializeEditor() {
4662 (0, import_deprecated6.default)("wp.editWidgets.reinitializeEditor", {
4663 since: "6.2",
4664 version: "6.3"
4665 });
4666 }
4667 var registerBlock = (block) => {
4668 if (!block) {
4669 return;
4670 }
4671 const { metadata, settings: settings2, name: name2 } = block;
4672 if (metadata) {
4673 (0, import_blocks3.unstable__bootstrapServerSideBlockDefinitions)({ [name2]: metadata });
4674 }
4675 (0, import_blocks3.registerBlockType)(name2, settings2);
4676 };
4677 return __toCommonJS(index_exports);
4678 })();
4679 //# sourceMappingURL=index.js.map
4680