PluginProbe
Gutenberg / 23.7.2
Gutenberg v23.7.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.7.2, at build/scripts/edit-widgets/index.js

4,688 lines 179.2 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_editor9 = __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 var import_block_editor7 = __toESM(require_block_editor(), 1);
2931 var { usesNativeUndo } = unlock(import_block_editor7.privateApis);
2932 function KeyboardShortcuts() {
2933 const { redo, undo } = (0, import_data11.useDispatch)(import_core_data6.store);
2934 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data11.useDispatch)(store2);
2935 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/undo", (event) => {
2936 if (usesNativeUndo(event)) {
2937 return;
2938 }
2939 undo();
2940 event.preventDefault();
2941 });
2942 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/redo", (event) => {
2943 if (usesNativeUndo(event)) {
2944 return;
2945 }
2946 redo();
2947 event.preventDefault();
2948 });
2949 (0, import_keyboard_shortcuts.useShortcut)("core/edit-widgets/save", (event) => {
2950 event.preventDefault();
2951 saveEditedWidgetAreas2();
2952 });
2953 return null;
2954 }
2955 function KeyboardShortcutsRegister() {
2956 const { registerShortcut } = (0, import_data11.useDispatch)(import_keyboard_shortcuts.store);
2957 (0, import_element10.useEffect)(() => {
2958 registerShortcut({
2959 name: "core/edit-widgets/undo",
2960 category: "global",
2961 description: (0, import_i18n6.__)("Undo your last changes."),
2962 keyCombination: {
2963 modifier: "primary",
2964 character: "z"
2965 }
2966 });
2967 registerShortcut({
2968 name: "core/edit-widgets/redo",
2969 category: "global",
2970 description: (0, import_i18n6.__)("Redo your last undo."),
2971 keyCombination: {
2972 modifier: "primaryShift",
2973 character: "z"
2974 },
2975 // Disable on Apple OS because it conflicts with the browser's
2976 // history shortcut. It's a fine alias for both Windows and Linux.
2977 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
2978 // Linux, we keep it as the default for consistency.
2979 aliases: (0, import_keycodes.isAppleOS)() ? [] : [
2980 {
2981 modifier: "primary",
2982 character: "y"
2983 }
2984 ]
2985 });
2986 registerShortcut({
2987 name: "core/edit-widgets/save",
2988 category: "global",
2989 description: (0, import_i18n6.__)("Save your changes."),
2990 keyCombination: {
2991 modifier: "primary",
2992 character: "s"
2993 }
2994 });
2995 registerShortcut({
2996 name: "core/edit-widgets/keyboard-shortcuts",
2997 category: "main",
2998 description: (0, import_i18n6.__)("Display these keyboard shortcuts."),
2999 keyCombination: {
3000 modifier: "access",
3001 character: "h"
3002 }
3003 });
3004 registerShortcut({
3005 name: "core/edit-widgets/next-region",
3006 category: "global",
3007 description: (0, import_i18n6.__)("Navigate to the next part of the editor."),
3008 keyCombination: {
3009 modifier: "ctrl",
3010 character: "`"
3011 },
3012 aliases: [
3013 {
3014 modifier: "access",
3015 character: "n"
3016 }
3017 ]
3018 });
3019 registerShortcut({
3020 name: "core/edit-widgets/previous-region",
3021 category: "global",
3022 description: (0, import_i18n6.__)("Navigate to the previous part of the editor."),
3023 keyCombination: {
3024 modifier: "ctrlShift",
3025 character: "`"
3026 },
3027 aliases: [
3028 {
3029 modifier: "access",
3030 character: "p"
3031 },
3032 {
3033 modifier: "ctrlShift",
3034 character: "~"
3035 }
3036 ]
3037 });
3038 }, [registerShortcut]);
3039 return null;
3040 }
3041 KeyboardShortcuts.Register = KeyboardShortcutsRegister;
3042 var keyboard_shortcuts_default = KeyboardShortcuts;
3043
3044 // packages/edit-widgets/build-module/hooks/use-last-selected-widget-area.mjs
3045 var import_data12 = __toESM(require_data(), 1);
3046 var import_block_editor8 = __toESM(require_block_editor(), 1);
3047 var import_core_data7 = __toESM(require_core_data(), 1);
3048 var useLastSelectedWidgetArea = () => (0, import_data12.useSelect)((select) => {
3049 const { getBlockSelectionEnd, getBlockName } = select(import_block_editor8.store);
3050 const selectionEndClientId = getBlockSelectionEnd();
3051 if (getBlockName(selectionEndClientId) === "core/widget-area") {
3052 return selectionEndClientId;
3053 }
3054 const { getParentWidgetAreaBlock: getParentWidgetAreaBlock2 } = select(store2);
3055 const widgetAreaBlock = getParentWidgetAreaBlock2(selectionEndClientId);
3056 const widgetAreaBlockClientId = widgetAreaBlock?.clientId;
3057 if (widgetAreaBlockClientId) {
3058 return widgetAreaBlockClientId;
3059 }
3060 const { getEntityRecord } = select(import_core_data7.store);
3061 const widgetAreasPost = getEntityRecord(
3062 KIND,
3063 POST_TYPE,
3064 buildWidgetAreasPostId()
3065 );
3066 return widgetAreasPost?.blocks[0]?.clientId;
3067 }, []);
3068 var use_last_selected_widget_area_default = useLastSelectedWidgetArea;
3069
3070 // packages/edit-widgets/build-module/constants.mjs
3071 var ALLOW_REUSABLE_BLOCKS = false;
3072 var ENABLE_EXPERIMENTAL_FSE_BLOCKS = false;
3073
3074 // packages/edit-widgets/build-module/components/widget-areas-block-editor-provider/index.mjs
3075 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
3076 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor9.privateApis);
3077 var { PatternsMenuItems } = unlock(import_patterns.privateApis);
3078 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis);
3079 var EMPTY_ARRAY2 = [];
3080 function WidgetAreasBlockEditorProvider({
3081 blockEditorSettings,
3082 children,
3083 ...props
3084 }) {
3085 const isLargeViewport = (0, import_compose5.useViewportMatch)("medium");
3086 const {
3087 hasUploadPermissions,
3088 reusableBlocks,
3089 isFixedToolbarActive,
3090 keepCaretInsideBlock,
3091 pageOnFront,
3092 pageForPosts
3093 } = (0, import_data13.useSelect)((select) => {
3094 const { canUser, getEntityRecord, getEntityRecords } = select(import_core_data8.store);
3095 const siteSettings = canUser("read", {
3096 kind: "root",
3097 name: "site"
3098 }) ? getEntityRecord("root", "site") : void 0;
3099 return {
3100 hasUploadPermissions: canUser("create", {
3101 kind: "postType",
3102 name: "attachment"
3103 }) ?? true,
3104 reusableBlocks: ALLOW_REUSABLE_BLOCKS ? getEntityRecords("postType", "wp_block") : EMPTY_ARRAY2,
3105 isFixedToolbarActive: !!select(import_preferences4.store).get(
3106 "core/edit-widgets",
3107 "fixedToolbar"
3108 ),
3109 keepCaretInsideBlock: !!select(import_preferences4.store).get(
3110 "core/edit-widgets",
3111 "keepCaretInsideBlock"
3112 ),
3113 pageOnFront: siteSettings?.page_on_front,
3114 pageForPosts: siteSettings?.page_for_posts
3115 };
3116 }, []);
3117 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data13.useDispatch)(store2);
3118 const settings2 = (0, import_element11.useMemo)(() => {
3119 let mediaUploadBlockEditor;
3120 if (hasUploadPermissions) {
3121 mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => {
3122 (0, import_media_utils2.uploadMedia)({
3123 wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
3124 onError: ({ message }) => onError(message),
3125 ...argumentsObject
3126 });
3127 };
3128 }
3129 return {
3130 ...blockEditorSettings,
3131 __experimentalReusableBlocks: reusableBlocks,
3132 hasFixedToolbar: isFixedToolbarActive || !isLargeViewport,
3133 keepCaretInsideBlock,
3134 mediaUpload: mediaUploadBlockEditor,
3135 templateLock: "all",
3136 __experimentalSetIsInserterOpened: setIsInserterOpened2,
3137 pageOnFront,
3138 pageForPosts,
3139 editorTool: "edit"
3140 };
3141 }, [
3142 hasUploadPermissions,
3143 blockEditorSettings,
3144 isFixedToolbarActive,
3145 isLargeViewport,
3146 keepCaretInsideBlock,
3147 reusableBlocks,
3148 setIsInserterOpened2,
3149 pageOnFront,
3150 pageForPosts
3151 ]);
3152 const widgetAreaId = use_last_selected_widget_area_default();
3153 const [blocks, onInput, onChange] = (0, import_core_data8.useEntityBlockEditor)(
3154 KIND,
3155 POST_TYPE,
3156 { id: buildWidgetAreasPostId() }
3157 );
3158 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_components9.SlotFillProvider, { children: [
3159 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(keyboard_shortcuts_default.Register, {}),
3160 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(BlockKeyboardShortcuts, {}),
3161 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
3162 ExperimentalBlockEditorProvider,
3163 {
3164 value: blocks,
3165 onInput,
3166 onChange,
3167 settings: settings2,
3168 useSubRegistry: false,
3169 ...props,
3170 children: [
3171 children,
3172 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(PatternsMenuItems, { rootClientId: widgetAreaId })
3173 ]
3174 }
3175 )
3176 ] });
3177 }
3178
3179 // packages/edit-widgets/build-module/components/sidebar/index.mjs
3180 var import_element13 = __toESM(require_element(), 1);
3181 var import_i18n8 = __toESM(require_i18n(), 1);
3182 var import_block_editor11 = __toESM(require_block_editor(), 1);
3183 var import_components11 = __toESM(require_components(), 1);
3184 var import_data15 = __toESM(require_data(), 1);
3185
3186 // packages/edit-widgets/build-module/components/sidebar/widget-areas.mjs
3187 var import_data14 = __toESM(require_data(), 1);
3188 var import_element12 = __toESM(require_element(), 1);
3189 var import_block_editor10 = __toESM(require_block_editor(), 1);
3190 var import_components10 = __toESM(require_components(), 1);
3191 var import_i18n7 = __toESM(require_i18n(), 1);
3192 var import_url = __toESM(require_url(), 1);
3193 var import_dom = __toESM(require_dom(), 1);
3194 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
3195 function WidgetAreas({ selectedWidgetAreaId }) {
3196 const widgetAreas = (0, import_data14.useSelect)(
3197 (select) => select(store2).getWidgetAreas(),
3198 []
3199 );
3200 const selectedWidgetArea = (0, import_element12.useMemo)(
3201 () => selectedWidgetAreaId && widgetAreas?.find(
3202 (widgetArea) => widgetArea.id === selectedWidgetAreaId
3203 ),
3204 [selectedWidgetAreaId, widgetAreas]
3205 );
3206 let description;
3207 if (!selectedWidgetArea) {
3208 description = (0, import_i18n7.__)(
3209 // eslint-disable-next-line no-restricted-syntax -- 'sidebar' is a common web design term for layouts
3210 "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."
3211 );
3212 } else if (selectedWidgetAreaId === "wp_inactive_widgets") {
3213 description = (0, import_i18n7.__)(
3214 "Blocks in this Widget Area will not be displayed in your site."
3215 );
3216 } else {
3217 description = selectedWidgetArea.description;
3218 }
3219 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: [
3220 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_block_editor10.BlockIcon, { icon: block_default_default }),
3221 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { children: [
3222 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3223 "p",
3224 {
3225 dangerouslySetInnerHTML: {
3226 __html: (0, import_dom.safeHTML)(description)
3227 }
3228 }
3229 ),
3230 widgetAreas?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { children: (0, import_i18n7.__)(
3231 "Your theme does not contain any Widget Areas."
3232 ) }),
3233 !selectedWidgetArea && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
3234 import_components10.Button,
3235 {
3236 __next40pxDefaultSize: true,
3237 href: (0, import_url.addQueryArgs)("customize.php", {
3238 "autofocus[panel]": "widgets",
3239 return: window.location.pathname
3240 }),
3241 variant: "tertiary",
3242 children: (0, import_i18n7.__)("Manage with live preview")
3243 }
3244 )
3245 ] })
3246 ] }) });
3247 }
3248
3249 // packages/edit-widgets/build-module/components/sidebar/index.mjs
3250 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3251 var SIDEBAR_ACTIVE_BY_DEFAULT = true;
3252 var BLOCK_INSPECTOR_IDENTIFIER = "edit-widgets/block-inspector";
3253 var WIDGET_AREAS_IDENTIFIER = "edit-widgets/block-areas";
3254 var { Tabs } = unlock(import_components11.privateApis);
3255 function SidebarHeader({ selectedWidgetAreaBlock }) {
3256 return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.TabList, { children: [
3257 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: WIDGET_AREAS_IDENTIFIER, children: selectedWidgetAreaBlock ? selectedWidgetAreaBlock.attributes.name : (0, import_i18n8.__)("Widget Areas") }),
3258 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Tab, { tabId: BLOCK_INSPECTOR_IDENTIFIER, children: (0, import_i18n8.__)("Block") })
3259 ] });
3260 }
3261 function SidebarContent({
3262 hasSelectedNonAreaBlock,
3263 currentArea,
3264 isGeneralSidebarOpen,
3265 selectedWidgetAreaBlock
3266 }) {
3267 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store);
3268 (0, import_element13.useEffect)(() => {
3269 if (hasSelectedNonAreaBlock && currentArea === WIDGET_AREAS_IDENTIFIER && isGeneralSidebarOpen) {
3270 enableComplementaryArea2(
3271 "core/edit-widgets",
3272 BLOCK_INSPECTOR_IDENTIFIER
3273 );
3274 }
3275 if (!hasSelectedNonAreaBlock && currentArea === BLOCK_INSPECTOR_IDENTIFIER && isGeneralSidebarOpen) {
3276 enableComplementaryArea2(
3277 "core/edit-widgets",
3278 WIDGET_AREAS_IDENTIFIER
3279 );
3280 }
3281 }, [hasSelectedNonAreaBlock, enableComplementaryArea2]);
3282 const tabsContextValue = (0, import_element13.useContext)(Tabs.Context);
3283 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3284 complementary_area_default,
3285 {
3286 className: "edit-widgets-sidebar",
3287 header: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3288 SidebarHeader,
3289 {
3290 selectedWidgetAreaBlock
3291 }
3292 ) }),
3293 headerClassName: "edit-widgets-sidebar__panel-tabs",
3294 title: (0, import_i18n8.__)("Settings"),
3295 closeLabel: (0, import_i18n8.__)("Close Settings"),
3296 scope: "core/edit-widgets",
3297 identifier: currentArea,
3298 icon: (0, import_i18n8.isRTL)() ? drawer_left_default : drawer_right_default,
3299 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
3300 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tabs.Context.Provider, { value: tabsContextValue, children: [
3301 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3302 Tabs.TabPanel,
3303 {
3304 tabId: WIDGET_AREAS_IDENTIFIER,
3305 focusable: false,
3306 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3307 WidgetAreas,
3308 {
3309 selectedWidgetAreaId: selectedWidgetAreaBlock?.attributes.id
3310 }
3311 )
3312 }
3313 ),
3314 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3315 Tabs.TabPanel,
3316 {
3317 tabId: BLOCK_INSPECTOR_IDENTIFIER,
3318 focusable: false,
3319 children: hasSelectedNonAreaBlock ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_block_editor11.BlockInspector, {}) : (
3320 // Pretend that Widget Areas are part of the UI by not
3321 // showing the Block Inspector when one is selected.
3322 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "block-editor-block-inspector__no-blocks", children: (0, import_i18n8.__)("No block selected.") })
3323 )
3324 }
3325 )
3326 ] })
3327 }
3328 );
3329 }
3330 function Sidebar() {
3331 const {
3332 currentArea,
3333 hasSelectedNonAreaBlock,
3334 isGeneralSidebarOpen,
3335 selectedWidgetAreaBlock
3336 } = (0, import_data15.useSelect)((select) => {
3337 const { getSelectedBlock, getBlock, getBlockParentsByBlockName } = select(import_block_editor11.store);
3338 const { getActiveComplementaryArea: getActiveComplementaryArea2 } = select(store);
3339 const selectedBlock = getSelectedBlock();
3340 const activeArea = getActiveComplementaryArea2(store2.name);
3341 let currentSelection = activeArea;
3342 if (!currentSelection) {
3343 if (selectedBlock) {
3344 currentSelection = BLOCK_INSPECTOR_IDENTIFIER;
3345 } else {
3346 currentSelection = WIDGET_AREAS_IDENTIFIER;
3347 }
3348 }
3349 let widgetAreaBlock;
3350 if (selectedBlock) {
3351 if (selectedBlock.name === "core/widget-area") {
3352 widgetAreaBlock = selectedBlock;
3353 } else {
3354 widgetAreaBlock = getBlock(
3355 getBlockParentsByBlockName(
3356 selectedBlock.clientId,
3357 "core/widget-area"
3358 )[0]
3359 );
3360 }
3361 }
3362 return {
3363 currentArea: currentSelection,
3364 hasSelectedNonAreaBlock: !!(selectedBlock && selectedBlock.name !== "core/widget-area"),
3365 isGeneralSidebarOpen: !!activeArea,
3366 selectedWidgetAreaBlock: widgetAreaBlock
3367 };
3368 }, []);
3369 const { enableComplementaryArea: enableComplementaryArea2 } = (0, import_data15.useDispatch)(store);
3370 const onTabSelect = (0, import_element13.useCallback)(
3371 (newSelectedTabId) => {
3372 if (!!newSelectedTabId) {
3373 enableComplementaryArea2(
3374 store2.name,
3375 newSelectedTabId
3376 );
3377 }
3378 },
3379 [enableComplementaryArea2]
3380 );
3381 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3382 Tabs,
3383 {
3384 selectedTabId: isGeneralSidebarOpen ? currentArea : null,
3385 onSelect: onTabSelect,
3386 selectOnMove: false,
3387 children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3388 SidebarContent,
3389 {
3390 hasSelectedNonAreaBlock,
3391 currentArea,
3392 isGeneralSidebarOpen,
3393 selectedWidgetAreaBlock
3394 }
3395 )
3396 }
3397 );
3398 }
3399
3400 // packages/edit-widgets/build-module/components/layout/interface.mjs
3401 var import_compose12 = __toESM(require_compose(), 1);
3402 var import_block_editor18 = __toESM(require_block_editor(), 1);
3403 var import_element23 = __toESM(require_element(), 1);
3404 var import_data28 = __toESM(require_data(), 1);
3405 var import_i18n18 = __toESM(require_i18n(), 1);
3406 var import_preferences8 = __toESM(require_preferences(), 1);
3407
3408 // packages/edit-widgets/build-module/components/header/index.mjs
3409 var import_block_editor13 = __toESM(require_block_editor(), 1);
3410 var import_data22 = __toESM(require_data(), 1);
3411 var import_element19 = __toESM(require_element(), 1);
3412 var import_i18n16 = __toESM(require_i18n(), 1);
3413 var import_components19 = __toESM(require_components(), 1);
3414 var import_compose8 = __toESM(require_compose(), 1);
3415 var import_preferences6 = __toESM(require_preferences(), 1);
3416
3417 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs
3418 var import_data18 = __toESM(require_data(), 1);
3419 var import_i18n11 = __toESM(require_i18n(), 1);
3420 var import_components14 = __toESM(require_components(), 1);
3421 var import_block_editor12 = __toESM(require_block_editor(), 1);
3422 var import_element16 = __toESM(require_element(), 1);
3423 var import_compose6 = __toESM(require_compose(), 1);
3424
3425 // packages/edit-widgets/build-module/components/header/undo-redo/undo.mjs
3426 var import_i18n9 = __toESM(require_i18n(), 1);
3427 var import_components12 = __toESM(require_components(), 1);
3428 var import_data16 = __toESM(require_data(), 1);
3429 var import_keycodes2 = __toESM(require_keycodes(), 1);
3430 var import_core_data9 = __toESM(require_core_data(), 1);
3431 var import_element14 = __toESM(require_element(), 1);
3432 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3433 function UndoButton(props, ref) {
3434 const hasUndo = (0, import_data16.useSelect)(
3435 (select) => select(import_core_data9.store).hasUndo(),
3436 []
3437 );
3438 const { undo } = (0, import_data16.useDispatch)(import_core_data9.store);
3439 return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
3440 import_components12.Button,
3441 {
3442 ...props,
3443 ref,
3444 icon: !(0, import_i18n9.isRTL)() ? undo_default : redo_default,
3445 label: (0, import_i18n9.__)("Undo"),
3446 shortcut: import_keycodes2.displayShortcut.primary("z"),
3447 "aria-disabled": !hasUndo,
3448 onClick: hasUndo ? undo : void 0,
3449 size: "compact"
3450 }
3451 );
3452 }
3453 var undo_default2 = (0, import_element14.forwardRef)(UndoButton);
3454
3455 // packages/edit-widgets/build-module/components/header/undo-redo/redo.mjs
3456 var import_i18n10 = __toESM(require_i18n(), 1);
3457 var import_components13 = __toESM(require_components(), 1);
3458 var import_data17 = __toESM(require_data(), 1);
3459 var import_keycodes3 = __toESM(require_keycodes(), 1);
3460 var import_core_data10 = __toESM(require_core_data(), 1);
3461 var import_element15 = __toESM(require_element(), 1);
3462 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3463 function RedoButton(props, ref) {
3464 const shortcut = (0, import_keycodes3.isAppleOS)() ? import_keycodes3.displayShortcut.primaryShift("z") : import_keycodes3.displayShortcut.primary("y");
3465 const hasRedo = (0, import_data17.useSelect)(
3466 (select) => select(import_core_data10.store).hasRedo(),
3467 []
3468 );
3469 const { redo } = (0, import_data17.useDispatch)(import_core_data10.store);
3470 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3471 import_components13.Button,
3472 {
3473 ...props,
3474 ref,
3475 icon: !(0, import_i18n10.isRTL)() ? redo_default : undo_default,
3476 label: (0, import_i18n10.__)("Redo"),
3477 shortcut,
3478 "aria-disabled": !hasRedo,
3479 onClick: hasRedo ? redo : void 0,
3480 size: "compact"
3481 }
3482 );
3483 }
3484 var redo_default2 = (0, import_element15.forwardRef)(RedoButton);
3485
3486 // packages/edit-widgets/build-module/components/header/document-tools/index.mjs
3487 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3488 function DocumentTools() {
3489 const isMediumViewport = (0, import_compose6.useViewportMatch)("medium");
3490 const {
3491 isInserterOpen,
3492 isListViewOpen,
3493 inserterSidebarToggleRef: inserterSidebarToggleRef2,
3494 listViewToggleRef: listViewToggleRef2
3495 } = (0, import_data18.useSelect)((select) => {
3496 const {
3497 isInserterOpened: isInserterOpened2,
3498 getInserterSidebarToggleRef: getInserterSidebarToggleRef2,
3499 isListViewOpened: isListViewOpened2,
3500 getListViewToggleRef: getListViewToggleRef2
3501 } = unlock(select(store2));
3502 return {
3503 isInserterOpen: isInserterOpened2(),
3504 isListViewOpen: isListViewOpened2(),
3505 inserterSidebarToggleRef: getInserterSidebarToggleRef2(),
3506 listViewToggleRef: getListViewToggleRef2()
3507 };
3508 }, []);
3509 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2 } = (0, import_data18.useDispatch)(store2);
3510 const toggleListView = (0, import_element16.useCallback)(
3511 () => setIsListViewOpened2(!isListViewOpen),
3512 [setIsListViewOpened2, isListViewOpen]
3513 );
3514 const toggleInserterSidebar = (0, import_element16.useCallback)(
3515 () => setIsInserterOpened2(!isInserterOpen),
3516 [setIsInserterOpened2, isInserterOpen]
3517 );
3518 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3519 import_block_editor12.NavigableToolbar,
3520 {
3521 className: "edit-widgets-header-toolbar",
3522 "aria-label": (0, import_i18n11.__)("Document tools"),
3523 variant: "unstyled",
3524 children: [
3525 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3526 import_components14.ToolbarItem,
3527 {
3528 ref: inserterSidebarToggleRef2,
3529 as: import_components14.Button,
3530 className: "edit-widgets-header-toolbar__inserter-toggle",
3531 variant: "primary",
3532 isPressed: isInserterOpen,
3533 onMouseDown: (event) => {
3534 event.preventDefault();
3535 },
3536 onClick: toggleInserterSidebar,
3537 icon: plus_default,
3538 label: (0, import_i18n11._x)(
3539 "Block Inserter",
3540 "Generic label for block inserter button"
3541 ),
3542 size: "compact"
3543 }
3544 ),
3545 isMediumViewport && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
3546 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: undo_default2 }),
3547 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components14.ToolbarItem, { as: redo_default2 }),
3548 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3549 import_components14.ToolbarItem,
3550 {
3551 as: import_components14.Button,
3552 className: "edit-widgets-header-toolbar__list-view-toggle",
3553 icon: list_view_default,
3554 isPressed: isListViewOpen,
3555 label: (0, import_i18n11.__)("List View"),
3556 onClick: toggleListView,
3557 ref: listViewToggleRef2,
3558 size: "compact"
3559 }
3560 )
3561 ] })
3562 ]
3563 }
3564 );
3565 }
3566 var document_tools_default = DocumentTools;
3567
3568 // packages/edit-widgets/build-module/components/save-button/index.mjs
3569 var import_components15 = __toESM(require_components(), 1);
3570 var import_i18n12 = __toESM(require_i18n(), 1);
3571 var import_data19 = __toESM(require_data(), 1);
3572 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3573 function SaveButton() {
3574 const { hasEditedWidgetAreaIds, isSaving, isWidgetSaveLocked } = (0, import_data19.useSelect)(
3575 (select) => {
3576 const {
3577 getEditedWidgetAreas: getEditedWidgetAreas2,
3578 isSavingWidgetAreas: isSavingWidgetAreas2,
3579 isWidgetSavingLocked: isWidgetSavingLocked2
3580 } = select(store2);
3581 return {
3582 hasEditedWidgetAreaIds: getEditedWidgetAreas2()?.length > 0,
3583 isSaving: isSavingWidgetAreas2(),
3584 isWidgetSaveLocked: isWidgetSavingLocked2()
3585 };
3586 },
3587 []
3588 );
3589 const { saveEditedWidgetAreas: saveEditedWidgetAreas2 } = (0, import_data19.useDispatch)(store2);
3590 const isDisabled = isWidgetSaveLocked || isSaving || !hasEditedWidgetAreaIds;
3591 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3592 import_components15.Button,
3593 {
3594 variant: "primary",
3595 isBusy: isSaving,
3596 "aria-disabled": isDisabled,
3597 onClick: isDisabled ? void 0 : saveEditedWidgetAreas2,
3598 size: "compact",
3599 children: isSaving ? (0, import_i18n12.__)("Saving\u2026") : (0, import_i18n12.__)("Update")
3600 }
3601 );
3602 }
3603 var save_button_default = SaveButton;
3604
3605 // packages/edit-widgets/build-module/components/more-menu/index.mjs
3606 var import_components18 = __toESM(require_components(), 1);
3607 var import_element18 = __toESM(require_element(), 1);
3608 var import_i18n15 = __toESM(require_i18n(), 1);
3609 var import_preferences5 = __toESM(require_preferences(), 1);
3610 var import_keycodes5 = __toESM(require_keycodes(), 1);
3611 var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts(), 1);
3612 var import_compose7 = __toESM(require_compose(), 1);
3613
3614 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
3615 var import_components16 = __toESM(require_components(), 1);
3616 var import_i18n14 = __toESM(require_i18n(), 1);
3617 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts(), 1);
3618 var import_data21 = __toESM(require_data(), 1);
3619
3620 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/config.mjs
3621 var import_i18n13 = __toESM(require_i18n(), 1);
3622 var textFormattingShortcuts = [
3623 {
3624 keyCombination: { modifier: "primary", character: "b" },
3625 description: (0, import_i18n13.__)("Make the selected text bold.")
3626 },
3627 {
3628 keyCombination: { modifier: "primary", character: "i" },
3629 description: (0, import_i18n13.__)("Make the selected text italic.")
3630 },
3631 {
3632 keyCombination: { modifier: "primary", character: "k" },
3633 description: (0, import_i18n13.__)("Convert the selected text into a link.")
3634 },
3635 {
3636 keyCombination: { modifier: "primaryShift", character: "k" },
3637 description: (0, import_i18n13.__)("Remove a link.")
3638 },
3639 {
3640 keyCombination: { character: "[[" },
3641 description: (0, import_i18n13.__)("Insert a link to a post or page.")
3642 },
3643 {
3644 keyCombination: { modifier: "primary", character: "u" },
3645 description: (0, import_i18n13.__)("Underline the selected text.")
3646 },
3647 {
3648 keyCombination: { modifier: "access", character: "d" },
3649 description: (0, import_i18n13.__)("Strikethrough the selected text.")
3650 },
3651 {
3652 keyCombination: { modifier: "access", character: "x" },
3653 description: (0, import_i18n13.__)("Make the selected text inline code.")
3654 },
3655 {
3656 keyCombination: {
3657 modifier: "access",
3658 character: "0"
3659 },
3660 aliases: [
3661 {
3662 modifier: "access",
3663 character: "7"
3664 }
3665 ],
3666 description: (0, import_i18n13.__)("Convert the current heading to a paragraph.")
3667 },
3668 {
3669 keyCombination: { modifier: "access", character: "1-6" },
3670 description: (0, import_i18n13.__)(
3671 "Convert the current paragraph or heading to a heading of level 1 to 6."
3672 )
3673 },
3674 {
3675 keyCombination: { modifier: "primaryShift", character: "SPACE" },
3676 description: (0, import_i18n13.__)("Add non breaking space.")
3677 }
3678 ];
3679
3680 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs
3681 var import_element17 = __toESM(require_element(), 1);
3682 var import_keycodes4 = __toESM(require_keycodes(), 1);
3683 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3684 function KeyCombination({ keyCombination, forceAriaLabel }) {
3685 const shortcut = keyCombination.modifier ? import_keycodes4.displayShortcutList[keyCombination.modifier](
3686 keyCombination.character
3687 ) : keyCombination.character;
3688 const ariaLabel = keyCombination.modifier ? import_keycodes4.shortcutAriaLabel[keyCombination.modifier](
3689 keyCombination.character
3690 ) : keyCombination.character;
3691 const shortcuts = Array.isArray(shortcut) ? shortcut : [shortcut];
3692 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3693 "kbd",
3694 {
3695 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
3696 "aria-label": forceAriaLabel || ariaLabel,
3697 children: shortcuts.map((character, index) => {
3698 if (character === "+") {
3699 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_element17.Fragment, { children: character }, index);
3700 }
3701 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3702 "kbd",
3703 {
3704 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-key",
3705 children: character
3706 },
3707 index
3708 );
3709 })
3710 }
3711 );
3712 }
3713 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
3714 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
3715 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-description", children: description }),
3716 /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-term", children: [
3717 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3718 KeyCombination,
3719 {
3720 keyCombination,
3721 forceAriaLabel: ariaLabel
3722 }
3723 ),
3724 aliases.map((alias, index) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3725 KeyCombination,
3726 {
3727 keyCombination: alias,
3728 forceAriaLabel: ariaLabel
3729 },
3730 index
3731 ))
3732 ] })
3733 ] });
3734 }
3735 var shortcut_default = Shortcut;
3736
3737 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs
3738 var import_data20 = __toESM(require_data(), 1);
3739 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts(), 1);
3740 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3741 function DynamicShortcut({ name: name2 }) {
3742 const { keyCombination, description, aliases } = (0, import_data20.useSelect)(
3743 (select) => {
3744 const {
3745 getShortcutKeyCombination,
3746 getShortcutDescription,
3747 getShortcutAliases
3748 } = select(import_keyboard_shortcuts3.store);
3749 return {
3750 keyCombination: getShortcutKeyCombination(name2),
3751 aliases: getShortcutAliases(name2),
3752 description: getShortcutDescription(name2)
3753 };
3754 },
3755 [name2]
3756 );
3757 if (!keyCombination) {
3758 return null;
3759 }
3760 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3761 shortcut_default,
3762 {
3763 keyCombination,
3764 description,
3765 aliases
3766 }
3767 );
3768 }
3769 var dynamic_shortcut_default = DynamicShortcut;
3770
3771 // packages/edit-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
3772 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
3773 var ShortcutList = ({ shortcuts }) => (
3774 /*
3775 * Disable reason: The `list` ARIA role is redundant but
3776 * Safari+VoiceOver won't announce the list otherwise.
3777 */
3778 /* eslint-disable jsx-a11y/no-redundant-roles */
3779 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3780 "ul",
3781 {
3782 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut-list",
3783 role: "list",
3784 children: shortcuts.map((shortcut, index) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3785 "li",
3786 {
3787 className: "edit-widgets-keyboard-shortcut-help-modal__shortcut",
3788 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(shortcut_default, { ...shortcut })
3789 },
3790 index
3791 ))
3792 }
3793 )
3794 );
3795 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
3796 "section",
3797 {
3798 className: clsx_default(
3799 "edit-widgets-keyboard-shortcut-help-modal__section",
3800 className
3801 ),
3802 children: [
3803 !!title && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h2", { className: "edit-widgets-keyboard-shortcut-help-modal__section-title", children: title }),
3804 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(ShortcutList, { shortcuts })
3805 ]
3806 }
3807 );
3808 var ShortcutCategorySection = ({
3809 title,
3810 categoryName,
3811 additionalShortcuts = []
3812 }) => {
3813 const categoryShortcuts = (0, import_data21.useSelect)(
3814 (select) => {
3815 return select(import_keyboard_shortcuts4.store).getCategoryShortcuts(
3816 categoryName
3817 );
3818 },
3819 [categoryName]
3820 );
3821 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3822 ShortcutSection,
3823 {
3824 title,
3825 shortcuts: categoryShortcuts.concat(additionalShortcuts)
3826 }
3827 );
3828 };
3829 function KeyboardShortcutHelpModal({
3830 isModalActive: isModalActive2,
3831 toggleModal
3832 }) {
3833 (0, import_keyboard_shortcuts4.useShortcut)("core/edit-widgets/keyboard-shortcuts", toggleModal, {
3834 bindGlobal: true
3835 });
3836 if (!isModalActive2) {
3837 return null;
3838 }
3839 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
3840 import_components16.Modal,
3841 {
3842 className: "edit-widgets-keyboard-shortcut-help-modal",
3843 title: (0, import_i18n14.__)("Keyboard shortcuts"),
3844 onRequestClose: toggleModal,
3845 children: [
3846 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3847 ShortcutSection,
3848 {
3849 className: "edit-widgets-keyboard-shortcut-help-modal__main-shortcuts",
3850 shortcuts: ["core/edit-widgets/keyboard-shortcuts"]
3851 }
3852 ),
3853 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3854 ShortcutCategorySection,
3855 {
3856 title: (0, import_i18n14.__)("Global shortcuts"),
3857 categoryName: "global"
3858 }
3859 ),
3860 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3861 ShortcutCategorySection,
3862 {
3863 title: (0, import_i18n14.__)("Selection shortcuts"),
3864 categoryName: "selection"
3865 }
3866 ),
3867 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3868 ShortcutCategorySection,
3869 {
3870 title: (0, import_i18n14.__)("Block shortcuts"),
3871 categoryName: "block",
3872 additionalShortcuts: [
3873 {
3874 keyCombination: { character: "/" },
3875 description: (0, import_i18n14.__)(
3876 "Change the block type after adding a new paragraph."
3877 ),
3878 /* translators: The forward-slash character. e.g. '/'. */
3879 ariaLabel: (0, import_i18n14.__)("Forward-slash")
3880 }
3881 ]
3882 }
3883 ),
3884 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3885 ShortcutSection,
3886 {
3887 title: (0, import_i18n14.__)("Text formatting"),
3888 shortcuts: textFormattingShortcuts
3889 }
3890 ),
3891 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
3892 ShortcutCategorySection,
3893 {
3894 title: (0, import_i18n14.__)("List View shortcuts"),
3895 categoryName: "list-view"
3896 }
3897 )
3898 ]
3899 }
3900 );
3901 }
3902
3903 // packages/edit-widgets/build-module/components/more-menu/tools-more-menu-group.mjs
3904 var import_components17 = __toESM(require_components(), 1);
3905 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3906 var { Fill: ToolsMoreMenuGroup, Slot: Slot4 } = (0, import_components17.createSlotFill)(
3907 "EditWidgetsToolsMoreMenuGroup"
3908 );
3909 ToolsMoreMenuGroup.Slot = ({ fillProps }) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Slot4, { fillProps, children: (fills) => fills.length > 0 && fills });
3910 var tools_more_menu_group_default = ToolsMoreMenuGroup;
3911
3912 // packages/edit-widgets/build-module/components/more-menu/index.mjs
3913 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3914 function MoreMenu() {
3915 const [
3916 isKeyboardShortcutsModalActive,
3917 setIsKeyboardShortcutsModalVisible
3918 ] = (0, import_element18.useState)(false);
3919 const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive);
3920 (0, import_keyboard_shortcuts5.useShortcut)(
3921 "core/edit-widgets/keyboard-shortcuts",
3922 toggleKeyboardShortcutsModal
3923 );
3924 const isLargeViewport = (0, import_compose7.useViewportMatch)("medium");
3925 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3926 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3927 import_components18.DropdownMenu,
3928 {
3929 icon: more_vertical_default,
3930 label: (0, import_i18n15.__)("Options"),
3931 popoverProps: {
3932 placement: "bottom-end",
3933 className: "more-menu-dropdown__content"
3934 },
3935 toggleProps: {
3936 tooltipPosition: "bottom",
3937 size: "compact"
3938 },
3939 children: (onClose) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3940 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components18.MenuGroup, { label: (0, import_i18n15._x)("View", "noun"), children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3941 import_preferences5.PreferenceToggleMenuItem,
3942 {
3943 scope: "core/edit-widgets",
3944 name: "fixedToolbar",
3945 label: (0, import_i18n15.__)("Top toolbar"),
3946 info: (0, import_i18n15.__)(
3947 "Access all block and document tools in a single place"
3948 ),
3949 messageActivated: (0, import_i18n15.__)(
3950 "Top toolbar activated"
3951 ),
3952 messageDeactivated: (0, import_i18n15.__)(
3953 "Top toolbar deactivated"
3954 )
3955 }
3956 ) }),
3957 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Tools"), children: [
3958 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3959 import_components18.MenuItem,
3960 {
3961 onClick: () => {
3962 setIsKeyboardShortcutsModalVisible(true);
3963 },
3964 shortcut: import_keycodes5.displayShortcut.access("h"),
3965 children: (0, import_i18n15.__)("Keyboard shortcuts")
3966 }
3967 ),
3968 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3969 import_preferences5.PreferenceToggleMenuItem,
3970 {
3971 scope: "core/edit-widgets",
3972 name: "welcomeGuide",
3973 label: (0, import_i18n15.__)("Welcome Guide")
3974 }
3975 ),
3976 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3977 import_components18.MenuItem,
3978 {
3979 role: "menuitem",
3980 icon: external_default,
3981 href: (0, import_i18n15.__)(
3982 "https://wordpress.org/documentation/article/block-based-widgets-editor/"
3983 ),
3984 target: "_blank",
3985 rel: "noopener",
3986 children: [
3987 (0, import_i18n15.__)("Help"),
3988 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(VisuallyHidden, {
3989 render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", {}),
3990 /* translators: accessibility text */
3991 children: (0, import_i18n15.__)("(opens in a new tab)")
3992 })
3993 ]
3994 }
3995 ),
3996 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3997 tools_more_menu_group_default.Slot,
3998 {
3999 fillProps: { onClose }
4000 }
4001 )
4002 ] }),
4003 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components18.MenuGroup, { label: (0, import_i18n15.__)("Preferences"), children: [
4004 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4005 import_preferences5.PreferenceToggleMenuItem,
4006 {
4007 scope: "core/edit-widgets",
4008 name: "keepCaretInsideBlock",
4009 label: (0, import_i18n15.__)(
4010 "Contain text cursor inside block"
4011 ),
4012 info: (0, import_i18n15.__)(
4013 "Aids screen readers by stopping text caret from leaving blocks."
4014 ),
4015 messageActivated: (0, import_i18n15.__)(
4016 "Contain text cursor inside block activated"
4017 ),
4018 messageDeactivated: (0, import_i18n15.__)(
4019 "Contain text cursor inside block deactivated"
4020 )
4021 }
4022 ),
4023 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4024 import_preferences5.PreferenceToggleMenuItem,
4025 {
4026 scope: "core/edit-widgets",
4027 name: "themeStyles",
4028 info: (0, import_i18n15.__)(
4029 "Make the editor look like your theme."
4030 ),
4031 label: (0, import_i18n15.__)("Use theme styles")
4032 }
4033 ),
4034 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4035 import_preferences5.PreferenceToggleMenuItem,
4036 {
4037 scope: "core/edit-widgets",
4038 name: "showBlockBreadcrumbs",
4039 label: (0, import_i18n15.__)("Display block breadcrumbs"),
4040 info: (0, import_i18n15.__)(
4041 "Shows block breadcrumbs at the bottom of the editor."
4042 ),
4043 messageActivated: (0, import_i18n15.__)(
4044 "Display block breadcrumbs activated"
4045 ),
4046 messageDeactivated: (0, import_i18n15.__)(
4047 "Display block breadcrumbs deactivated"
4048 )
4049 }
4050 )
4051 ] })
4052 ] })
4053 }
4054 ),
4055 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4056 KeyboardShortcutHelpModal,
4057 {
4058 isModalActive: isKeyboardShortcutsModalActive,
4059 toggleModal: toggleKeyboardShortcutsModal
4060 }
4061 )
4062 ] });
4063 }
4064
4065 // packages/edit-widgets/build-module/components/header/index.mjs
4066 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
4067 function Header() {
4068 const isLargeViewport = (0, import_compose8.useViewportMatch)("medium");
4069 const blockToolbarRef = (0, import_element19.useRef)();
4070 const { hasFixedToolbar } = (0, import_data22.useSelect)(
4071 (select) => ({
4072 hasFixedToolbar: !!select(import_preferences6.store).get(
4073 "core/edit-widgets",
4074 "fixedToolbar"
4075 )
4076 }),
4077 []
4078 );
4079 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_jsx_runtime38.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header", children: [
4080 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__navigable-toolbar-wrapper", children: [
4081 isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h1", { className: "edit-widgets-header__title", children: (0, import_i18n16.__)("Widgets") }),
4082 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4083 VisuallyHidden,
4084 {
4085 className: "edit-widgets-header__title",
4086 render: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h1", {}),
4087 children: (0, import_i18n16.__)("Widgets")
4088 }
4089 ),
4090 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(document_tools_default, {}),
4091 hasFixedToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
4092 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "selected-block-tools-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_block_editor13.BlockToolbar, { hideDragHandle: true }) }),
4093 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4094 import_components19.Popover.Slot,
4095 {
4096 ref: blockToolbarRef,
4097 name: "block-toolbar"
4098 }
4099 )
4100 ] })
4101 ] }),
4102 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "edit-widgets-header__actions", children: [
4103 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(pinned_items_default.Slot, { scope: "core/edit-widgets" }),
4104 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(save_button_default, {}),
4105 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(MoreMenu, {})
4106 ] })
4107 ] }) });
4108 }
4109 var header_default = Header;
4110
4111 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs
4112 var import_block_editor14 = __toESM(require_block_editor(), 1);
4113 var import_compose9 = __toESM(require_compose(), 1);
4114 var import_data23 = __toESM(require_data(), 1);
4115 var import_element20 = __toESM(require_element(), 1);
4116 var import_preferences7 = __toESM(require_preferences(), 1);
4117
4118 // packages/edit-widgets/build-module/components/notices/index.mjs
4119 var import_notices2 = __toESM(require_notices(), 1);
4120 var import_theme = __toESM(require_theme(), 1);
4121 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
4122 function Notices() {
4123 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_theme.ThemeProvider, { cornerRadius: "none", children: [
4124 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
4125 import_notices2.InlineNotices,
4126 {
4127 className: "edit-widgets-notices",
4128 pinnedNoticesClassName: "edit-widgets-notices__pinned",
4129 dismissibleNoticesClassName: "edit-widgets-notices__dismissible"
4130 }
4131 ),
4132 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_notices2.SnackbarNotices, { className: "edit-widgets-notices__snackbar" })
4133 ] });
4134 }
4135 var notices_default = Notices;
4136
4137 // packages/edit-widgets/build-module/components/widget-areas-block-editor-content/index.mjs
4138 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
4139 function WidgetAreasBlockEditorContent({
4140 blockEditorSettings
4141 }) {
4142 const hasThemeStyles = (0, import_data23.useSelect)(
4143 (select) => !!select(import_preferences7.store).get(
4144 "core/edit-widgets",
4145 "themeStyles"
4146 ),
4147 []
4148 );
4149 const isLargeViewport = (0, import_compose9.useViewportMatch)("medium");
4150 const styles = (0, import_element20.useMemo)(() => {
4151 return hasThemeStyles ? blockEditorSettings.styles : [];
4152 }, [blockEditorSettings, hasThemeStyles]);
4153 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "edit-widgets-block-editor", children: [
4154 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(notices_default, {}),
4155 !isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor14.BlockToolbar, { hideDragHandle: true }),
4156 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_block_editor14.BlockTools, { children: [
4157 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(keyboard_shortcuts_default, {}),
4158 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4159 import_block_editor14.__unstableEditorStyles,
4160 {
4161 styles,
4162 scope: ":where(.editor-styles-wrapper)"
4163 }
4164 ),
4165 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor14.BlockSelectionClearer, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor14.WritingFlow, { children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_block_editor14.BlockList, { className: "edit-widgets-main-block-list" }) }) })
4166 ] })
4167 ] });
4168 }
4169
4170 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs
4171 var import_data27 = __toESM(require_data(), 1);
4172
4173 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs
4174 var import_block_editor16 = __toESM(require_block_editor(), 1);
4175 var import_compose10 = __toESM(require_compose(), 1);
4176 var import_element21 = __toESM(require_element(), 1);
4177 var import_data25 = __toESM(require_data(), 1);
4178
4179 // packages/edit-widgets/build-module/hooks/use-widget-library-insertion-point.mjs
4180 var import_data24 = __toESM(require_data(), 1);
4181 var import_block_editor15 = __toESM(require_block_editor(), 1);
4182 var import_core_data11 = __toESM(require_core_data(), 1);
4183 var useWidgetLibraryInsertionPoint = () => {
4184 const firstRootId = (0, import_data24.useSelect)((select) => {
4185 const { getEntityRecord } = select(import_core_data11.store);
4186 const widgetAreasPost = getEntityRecord(
4187 KIND,
4188 POST_TYPE,
4189 buildWidgetAreasPostId()
4190 );
4191 return widgetAreasPost?.blocks[0]?.clientId;
4192 }, []);
4193 return (0, import_data24.useSelect)(
4194 (select) => {
4195 const {
4196 getBlockRootClientId,
4197 getBlockSelectionEnd,
4198 getBlockOrder,
4199 getBlockIndex
4200 } = select(import_block_editor15.store);
4201 const insertionPoint = select(store2).__experimentalGetInsertionPoint();
4202 if (insertionPoint.rootClientId) {
4203 return insertionPoint;
4204 }
4205 const clientId = getBlockSelectionEnd() || firstRootId;
4206 const rootClientId = getBlockRootClientId(clientId);
4207 if (clientId && rootClientId === "") {
4208 return {
4209 rootClientId: clientId,
4210 insertionIndex: getBlockOrder(clientId).length
4211 };
4212 }
4213 return {
4214 rootClientId,
4215 insertionIndex: getBlockIndex(clientId) + 1
4216 };
4217 },
4218 [firstRootId]
4219 );
4220 };
4221 var use_widget_library_insertion_point_default = useWidgetLibraryInsertionPoint;
4222
4223 // packages/edit-widgets/build-module/components/secondary-sidebar/inserter-sidebar.mjs
4224 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
4225 function InserterSidebar() {
4226 const isMobileViewport = (0, import_compose10.useViewportMatch)("medium", "<");
4227 const { rootClientId, insertionIndex } = use_widget_library_insertion_point_default();
4228 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data25.useDispatch)(store2);
4229 const closeInserter = (0, import_element21.useCallback)(() => {
4230 return setIsInserterOpened2(false);
4231 }, [setIsInserterOpened2]);
4232 const libraryRef = (0, import_element21.useRef)();
4233 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)(
4234 import_block_editor16.__experimentalLibrary,
4235 {
4236 showInserterHelpPanel: true,
4237 shouldFocusBlock: isMobileViewport,
4238 rootClientId,
4239 __experimentalInsertionIndex: insertionIndex,
4240 ref: libraryRef,
4241 onClose: closeInserter
4242 }
4243 ) }) });
4244 }
4245
4246 // packages/edit-widgets/build-module/components/secondary-sidebar/list-view-sidebar.mjs
4247 var import_block_editor17 = __toESM(require_block_editor(), 1);
4248 var import_components20 = __toESM(require_components(), 1);
4249 var import_compose11 = __toESM(require_compose(), 1);
4250 var import_data26 = __toESM(require_data(), 1);
4251 var import_element22 = __toESM(require_element(), 1);
4252 var import_i18n17 = __toESM(require_i18n(), 1);
4253 var import_keycodes6 = __toESM(require_keycodes(), 1);
4254 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
4255 function ListViewSidebar() {
4256 const { setIsListViewOpened: setIsListViewOpened2 } = (0, import_data26.useDispatch)(store2);
4257 const { getListViewToggleRef: getListViewToggleRef2 } = unlock((0, import_data26.useSelect)(store2));
4258 const [dropZoneElement, setDropZoneElement] = (0, import_element22.useState)(null);
4259 const focusOnMountRef = (0, import_compose11.useFocusOnMount)("firstElement");
4260 const closeListView = (0, import_element22.useCallback)(() => {
4261 setIsListViewOpened2(false);
4262 getListViewToggleRef2().current?.focus();
4263 }, [getListViewToggleRef2, setIsListViewOpened2]);
4264 const closeOnEscape = (0, import_element22.useCallback)(
4265 (event) => {
4266 if (event.keyCode === import_keycodes6.ESCAPE && !event.defaultPrevented) {
4267 event.preventDefault();
4268 closeListView();
4269 }
4270 },
4271 [closeListView]
4272 );
4273 return (
4274 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
4275 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
4276 "div",
4277 {
4278 className: "edit-widgets-editor__list-view-panel",
4279 onKeyDown: closeOnEscape,
4280 children: [
4281 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "edit-widgets-editor__list-view-panel-header", children: [
4282 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("strong", { children: (0, import_i18n17.__)("List View") }),
4283 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4284 import_components20.Button,
4285 {
4286 icon: close_small_default,
4287 label: (0, import_i18n17.__)("Close"),
4288 onClick: closeListView,
4289 size: "compact"
4290 }
4291 )
4292 ] }),
4293 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4294 "div",
4295 {
4296 className: "edit-widgets-editor__list-view-panel-content",
4297 ref: (0, import_compose11.useMergeRefs)([focusOnMountRef, setDropZoneElement]),
4298 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_block_editor17.__experimentalListView, { dropZoneElement })
4299 }
4300 )
4301 ]
4302 }
4303 )
4304 );
4305 }
4306
4307 // packages/edit-widgets/build-module/components/secondary-sidebar/index.mjs
4308 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
4309 function SecondarySidebar() {
4310 const { isInserterOpen, isListViewOpen } = (0, import_data27.useSelect)((select) => {
4311 const { isInserterOpened: isInserterOpened2, isListViewOpened: isListViewOpened2 } = select(store2);
4312 return {
4313 isInserterOpen: isInserterOpened2(),
4314 isListViewOpen: isListViewOpened2()
4315 };
4316 }, []);
4317 if (isInserterOpen) {
4318 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(InserterSidebar, {});
4319 }
4320 if (isListViewOpen) {
4321 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ListViewSidebar, {});
4322 }
4323 return null;
4324 }
4325
4326 // packages/edit-widgets/build-module/components/layout/interface.mjs
4327 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
4328 var interfaceLabels = {
4329 /* translators: accessibility text for the widgets screen top bar landmark region. */
4330 header: (0, import_i18n18.__)("Widgets top bar"),
4331 /* translators: accessibility text for the widgets screen content landmark region. */
4332 body: (0, import_i18n18.__)("Widgets and blocks"),
4333 /* translators: accessibility text for the widgets screen settings landmark region. */
4334 sidebar: (0, import_i18n18.__)("Widgets settings"),
4335 /* translators: accessibility text for the widgets screen footer landmark region. */
4336 footer: (0, import_i18n18.__)("Widgets footer")
4337 };
4338 function Interface({ blockEditorSettings }) {
4339 const isMobileViewport = (0, import_compose12.useViewportMatch)("medium", "<");
4340 const isHugeViewport = (0, import_compose12.useViewportMatch)("huge", ">=");
4341 const { setIsInserterOpened: setIsInserterOpened2, setIsListViewOpened: setIsListViewOpened2, closeGeneralSidebar: closeGeneralSidebar2 } = (0, import_data28.useDispatch)(store2);
4342 const {
4343 hasBlockBreadCrumbsEnabled,
4344 hasSidebarEnabled,
4345 isInserterOpened: isInserterOpened2,
4346 isListViewOpened: isListViewOpened2
4347 } = (0, import_data28.useSelect)(
4348 (select) => ({
4349 hasSidebarEnabled: !!select(
4350 store
4351 ).getActiveComplementaryArea(store2.name),
4352 isInserterOpened: !!select(store2).isInserterOpened(),
4353 isListViewOpened: !!select(store2).isListViewOpened(),
4354 hasBlockBreadCrumbsEnabled: !!select(import_preferences8.store).get(
4355 "core/edit-widgets",
4356 "showBlockBreadcrumbs"
4357 )
4358 }),
4359 []
4360 );
4361 (0, import_element23.useEffect)(() => {
4362 if (hasSidebarEnabled && !isHugeViewport) {
4363 setIsInserterOpened2(false);
4364 setIsListViewOpened2(false);
4365 }
4366 }, [hasSidebarEnabled, isHugeViewport]);
4367 (0, import_element23.useEffect)(() => {
4368 if ((isInserterOpened2 || isListViewOpened2) && !isHugeViewport) {
4369 closeGeneralSidebar2();
4370 }
4371 }, [isInserterOpened2, isListViewOpened2, isHugeViewport]);
4372 const secondarySidebarLabel = isListViewOpened2 ? (0, import_i18n18.__)("List View") : (0, import_i18n18.__)("Block Library");
4373 const hasSecondarySidebar = isListViewOpened2 || isInserterOpened2;
4374 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4375 interface_skeleton_default,
4376 {
4377 labels: {
4378 ...interfaceLabels,
4379 secondarySidebar: secondarySidebarLabel
4380 },
4381 header: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(header_default, {}),
4382 secondarySidebar: hasSecondarySidebar && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SecondarySidebar, {}),
4383 sidebar: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(complementary_area_default.Slot, { scope: "core/edit-widgets" }),
4384 content: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_jsx_runtime44.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4385 WidgetAreasBlockEditorContent,
4386 {
4387 blockEditorSettings
4388 }
4389 ) }),
4390 footer: hasBlockBreadCrumbsEnabled && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "edit-widgets-layout__footer", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_block_editor18.BlockBreadcrumb, { rootLabelText: (0, import_i18n18.__)("Widgets") }) })
4391 }
4392 );
4393 }
4394 var interface_default = Interface;
4395
4396 // packages/edit-widgets/build-module/components/layout/unsaved-changes-warning.mjs
4397 var import_i18n19 = __toESM(require_i18n(), 1);
4398 var import_element24 = __toESM(require_element(), 1);
4399 var import_data29 = __toESM(require_data(), 1);
4400 function UnsavedChangesWarning() {
4401 const isDirty = (0, import_data29.useSelect)((select) => {
4402 const { getEditedWidgetAreas: getEditedWidgetAreas2 } = select(store2);
4403 const editedWidgetAreas = getEditedWidgetAreas2();
4404 return editedWidgetAreas?.length > 0;
4405 }, []);
4406 (0, import_element24.useEffect)(() => {
4407 const warnIfUnsavedChanges = (event) => {
4408 if (isDirty) {
4409 event.returnValue = (0, import_i18n19.__)(
4410 "You have unsaved changes. If you proceed, they will be lost."
4411 );
4412 return event.returnValue;
4413 }
4414 };
4415 window.addEventListener("beforeunload", warnIfUnsavedChanges);
4416 return () => {
4417 window.removeEventListener("beforeunload", warnIfUnsavedChanges);
4418 };
4419 }, [isDirty]);
4420 return null;
4421 }
4422
4423 // packages/edit-widgets/build-module/components/welcome-guide/index.mjs
4424 var import_data30 = __toESM(require_data(), 1);
4425 var import_components21 = __toESM(require_components(), 1);
4426 var import_i18n20 = __toESM(require_i18n(), 1);
4427 var import_element25 = __toESM(require_element(), 1);
4428 var import_preferences9 = __toESM(require_preferences(), 1);
4429 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
4430 function WelcomeGuide() {
4431 const isActive = (0, import_data30.useSelect)(
4432 (select) => !!select(import_preferences9.store).get(
4433 "core/edit-widgets",
4434 "welcomeGuide"
4435 ),
4436 []
4437 );
4438 const { toggle } = (0, import_data30.useDispatch)(import_preferences9.store);
4439 const widgetAreas = (0, import_data30.useSelect)(
4440 (select) => select(store2).getWidgetAreas({ per_page: -1 }),
4441 []
4442 );
4443 if (!isActive) {
4444 return null;
4445 }
4446 const isEntirelyBlockWidgets = widgetAreas?.every(
4447 (widgetArea) => widgetArea.id === "wp_inactive_widgets" || widgetArea.widgets.every(
4448 (widgetId) => widgetId.startsWith("block-")
4449 )
4450 );
4451 const numWidgetAreas = widgetAreas?.filter(
4452 (widgetArea) => widgetArea.id !== "wp_inactive_widgets"
4453 ).length ?? 0;
4454 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4455 import_components21.Guide,
4456 {
4457 className: "edit-widgets-welcome-guide",
4458 contentLabel: (0, import_i18n20.__)("Welcome to block Widgets"),
4459 finishButtonText: (0, import_i18n20.__)("Get started"),
4460 onFinish: () => toggle("core/edit-widgets", "welcomeGuide"),
4461 pages: [
4462 {
4463 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4464 WelcomeGuideImage,
4465 {
4466 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.svg",
4467 animatedSrc: "https://s.w.org/images/block-editor/welcome-canvas.gif"
4468 }
4469 ),
4470 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4471 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Welcome to block Widgets") }),
4472 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)(
4473 // Translators: %s: Number of block areas in the current theme.
4474 (0, import_i18n20._n)(
4475 "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.",
4476 "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.",
4477 numWidgetAreas
4478 ),
4479 numWidgetAreas
4480 ) }) }) : /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4481 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)(
4482 "You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly."
4483 ) }),
4484 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("p", { className: "edit-widgets-welcome-guide__text", children: [
4485 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("strong", { children: (0, import_i18n20.__)(
4486 "Want to stick with the old widgets?"
4487 ) }),
4488 " ",
4489 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4490 import_components21.ExternalLink,
4491 {
4492 href: (0, import_i18n20.__)(
4493 "https://wordpress.org/plugins/classic-widgets/"
4494 ),
4495 children: (0, import_i18n20.__)(
4496 "Get the Classic Widgets plugin."
4497 )
4498 }
4499 )
4500 ] })
4501 ] })
4502 ] })
4503 },
4504 {
4505 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4506 WelcomeGuideImage,
4507 {
4508 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-editor.svg",
4509 animatedSrc: "https://s.w.org/images/block-editor/welcome-editor.gif"
4510 }
4511 ),
4512 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4513 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Customize each block") }),
4514 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_i18n20.__)(
4515 "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."
4516 ) })
4517 ] })
4518 },
4519 {
4520 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4521 WelcomeGuideImage,
4522 {
4523 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-library.svg",
4524 animatedSrc: "https://s.w.org/images/block-editor/welcome-library.gif"
4525 }
4526 ),
4527 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4528 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Explore all blocks") }),
4529 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
4530 (0, import_i18n20.__)(
4531 "All of the blocks available to you live in the block library. You\u2019ll find it wherever you see the <InserterIconImage /> icon."
4532 ),
4533 {
4534 InserterIconImage: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4535 "img",
4536 {
4537 className: "edit-widgets-welcome-guide__inserter-icon",
4538 alt: (0, import_i18n20.__)("inserter"),
4539 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"
4540 }
4541 )
4542 }
4543 ) })
4544 ] })
4545 },
4546 {
4547 image: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4548 WelcomeGuideImage,
4549 {
4550 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg",
4551 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif"
4552 }
4553 ),
4554 content: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4555 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h1", { className: "edit-widgets-welcome-guide__heading", children: (0, import_i18n20.__)("Learn more") }),
4556 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("p", { className: "edit-widgets-welcome-guide__text", children: (0, import_element25.createInterpolateElement)(
4557 (0, import_i18n20.__)(
4558 "New to the block editor? Want to learn more about using it? <a>Here's a detailed guide.</a>"
4559 ),
4560 {
4561 a: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4562 import_components21.ExternalLink,
4563 {
4564 href: (0, import_i18n20.__)(
4565 "https://wordpress.org/documentation/article/wordpress-block-editor/"
4566 )
4567 }
4568 )
4569 }
4570 ) })
4571 ] })
4572 }
4573 ]
4574 }
4575 );
4576 }
4577 function WelcomeGuideImage({ nonAnimatedSrc, animatedSrc }) {
4578 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("picture", { className: "edit-widgets-welcome-guide__image", children: [
4579 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4580 "source",
4581 {
4582 srcSet: nonAnimatedSrc,
4583 media: "(prefers-reduced-motion: reduce)"
4584 }
4585 ),
4586 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("img", { src: animatedSrc, width: "312", height: "240", alt: "" })
4587 ] });
4588 }
4589
4590 // packages/edit-widgets/build-module/components/layout/index.mjs
4591 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
4592 function Layout({ blockEditorSettings }) {
4593 const { createErrorNotice } = (0, import_data31.useDispatch)(import_notices4.store);
4594 function onPluginAreaError(name2) {
4595 createErrorNotice(
4596 (0, import_i18n21.sprintf)(
4597 /* translators: %s: plugin name */
4598 (0, import_i18n21.__)(
4599 'The "%s" plugin has encountered an error and cannot be rendered.'
4600 ),
4601 name2
4602 )
4603 );
4604 }
4605 const navigateRegionsProps = (0, import_components22.__unstableUseNavigateRegions)();
4606 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4607 "div",
4608 {
4609 className: navigateRegionsProps.className,
4610 ...navigateRegionsProps,
4611 ref: navigateRegionsProps.ref,
4612 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4613 WidgetAreasBlockEditorProvider,
4614 {
4615 blockEditorSettings,
4616 children: [
4617 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(interface_default, { blockEditorSettings }),
4618 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Sidebar, {}),
4619 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_plugins3.PluginArea, { onError: onPluginAreaError }),
4620 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(UnsavedChangesWarning, {}),
4621 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(WelcomeGuide, {})
4622 ]
4623 }
4624 )
4625 }
4626 ) });
4627 }
4628 var layout_default = Layout;
4629
4630 // packages/edit-widgets/build-module/index.mjs
4631 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
4632 var disabledBlocks = [
4633 "core/more",
4634 "core/freeform",
4635 "core/template-part",
4636 ...ALLOW_REUSABLE_BLOCKS ? [] : ["core/block"]
4637 ];
4638 function initializeEditor(id, settings2) {
4639 const target = document.getElementById(id);
4640 const root = (0, import_element26.createRoot)(target);
4641 const coreBlocks = (0, import_block_library2.__experimentalGetCoreBlocks)().filter((block) => {
4642 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"));
4643 });
4644 (0, import_data32.dispatch)(import_preferences10.store).setDefaults("core/edit-widgets", {
4645 fixedToolbar: false,
4646 welcomeGuide: true,
4647 showBlockBreadcrumbs: true,
4648 themeStyles: true
4649 });
4650 (0, import_data32.dispatch)(import_blocks3.store).reapplyBlockTypeFilters();
4651 (0, import_block_library2.registerCoreBlocks)(coreBlocks);
4652 (0, import_widgets5.registerLegacyWidgetBlock)();
4653 if (true) {
4654 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({
4655 enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS
4656 });
4657 }
4658 (0, import_widgets5.registerLegacyWidgetVariations)(settings2);
4659 registerBlock(widget_area_exports);
4660 (0, import_widgets5.registerWidgetGroupBlock)();
4661 settings2.__experimentalFetchLinkSuggestions = (search, searchOptions) => (0, import_core_data12.__experimentalFetchLinkSuggestions)(search, searchOptions, settings2);
4662 (0, import_blocks3.setFreeformContentHandlerName)("core/html");
4663 root.render(
4664 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_element26.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(layout_default, { blockEditorSettings: settings2 }) })
4665 );
4666 return root;
4667 }
4668 var initialize = initializeEditor;
4669 function reinitializeEditor() {
4670 (0, import_deprecated6.default)("wp.editWidgets.reinitializeEditor", {
4671 since: "6.2",
4672 version: "6.3"
4673 });
4674 }
4675 var registerBlock = (block) => {
4676 if (!block) {
4677 return;
4678 }
4679 const { metadata, settings: settings2, name: name2 } = block;
4680 if (metadata) {
4681 (0, import_blocks3.unstable__bootstrapServerSideBlockDefinitions)({ [name2]: metadata });
4682 }
4683 (0, import_blocks3.registerBlockType)(name2, settings2);
4684 };
4685 return __toCommonJS(index_exports);
4686 })();
4687 //# sourceMappingURL=index.js.map
4688