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