PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / scripts / compose / index.js

index.js in Gutenberg 22.7.0, at build/scripts/compose/index.js

3,036 lines 109.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).compose = (() => {
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 // vendor-external:react/jsx-runtime
36 var require_jsx_runtime = __commonJS({
37 "vendor-external:react/jsx-runtime"(exports, module) {
38 module.exports = window.ReactJSXRuntime;
39 }
40 });
41
42 // package-external:@wordpress/is-shallow-equal
43 var require_is_shallow_equal = __commonJS({
44 "package-external:@wordpress/is-shallow-equal"(exports, module) {
45 module.exports = window.wp.isShallowEqual;
46 }
47 });
48
49 // package-external:@wordpress/element
50 var require_element = __commonJS({
51 "package-external:@wordpress/element"(exports, module) {
52 module.exports = window.wp.element;
53 }
54 });
55
56 // package-external:@wordpress/deprecated
57 var require_deprecated = __commonJS({
58 "package-external:@wordpress/deprecated"(exports, module) {
59 module.exports = window.wp.deprecated;
60 }
61 });
62
63 // package-external:@wordpress/dom
64 var require_dom = __commonJS({
65 "package-external:@wordpress/dom"(exports, module) {
66 module.exports = window.wp.dom;
67 }
68 });
69
70 // packages/compose/node_modules/clipboard/dist/clipboard.js
71 var require_clipboard = __commonJS({
72 "packages/compose/node_modules/clipboard/dist/clipboard.js"(exports, module) {
73 (function webpackUniversalModuleDefinition(root, factory) {
74 if (typeof exports === "object" && typeof module === "object")
75 module.exports = factory();
76 else if (typeof define === "function" && define.amd)
77 define([], factory);
78 else if (typeof exports === "object")
79 exports["ClipboardJS"] = factory();
80 else
81 root["ClipboardJS"] = factory();
82 })(exports, function() {
83 return (
84 /******/
85 (function() {
86 var __webpack_modules__ = {
87 /***/
88 686: (
89 /***/
90 (function(__unused_webpack_module, __webpack_exports__, __webpack_require__2) {
91 "use strict";
92 __webpack_require__2.d(__webpack_exports__, {
93 "default": function() {
94 return (
95 /* binding */
96 clipboard
97 );
98 }
99 });
100 var tiny_emitter = __webpack_require__2(279);
101 var tiny_emitter_default = /* @__PURE__ */ __webpack_require__2.n(tiny_emitter);
102 var listen = __webpack_require__2(370);
103 var listen_default = /* @__PURE__ */ __webpack_require__2.n(listen);
104 var src_select = __webpack_require__2(817);
105 var select_default = /* @__PURE__ */ __webpack_require__2.n(src_select);
106 ;
107 function command(type) {
108 try {
109 return document.execCommand(type);
110 } catch (err) {
111 return false;
112 }
113 }
114 ;
115 var ClipboardActionCut = function ClipboardActionCut2(target) {
116 var selectedText = select_default()(target);
117 command("cut");
118 return selectedText;
119 };
120 var actions_cut = ClipboardActionCut;
121 ;
122 function createFakeElement(value) {
123 var isRTL = document.documentElement.getAttribute("dir") === "rtl";
124 var fakeElement = document.createElement("textarea");
125 fakeElement.style.fontSize = "12pt";
126 fakeElement.style.border = "0";
127 fakeElement.style.padding = "0";
128 fakeElement.style.margin = "0";
129 fakeElement.style.position = "absolute";
130 fakeElement.style[isRTL ? "right" : "left"] = "-9999px";
131 var yPosition = window.pageYOffset || document.documentElement.scrollTop;
132 fakeElement.style.top = "".concat(yPosition, "px");
133 fakeElement.setAttribute("readonly", "");
134 fakeElement.value = value;
135 return fakeElement;
136 }
137 ;
138 var fakeCopyAction = function fakeCopyAction2(value, options) {
139 var fakeElement = createFakeElement(value);
140 options.container.appendChild(fakeElement);
141 var selectedText = select_default()(fakeElement);
142 command("copy");
143 fakeElement.remove();
144 return selectedText;
145 };
146 var ClipboardActionCopy = function ClipboardActionCopy2(target) {
147 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
148 container: document.body
149 };
150 var selectedText = "";
151 if (typeof target === "string") {
152 selectedText = fakeCopyAction(target, options);
153 } else if (target instanceof HTMLInputElement && !["text", "search", "url", "tel", "password"].includes(target === null || target === void 0 ? void 0 : target.type)) {
154 selectedText = fakeCopyAction(target.value, options);
155 } else {
156 selectedText = select_default()(target);
157 command("copy");
158 }
159 return selectedText;
160 };
161 var actions_copy = ClipboardActionCopy;
162 ;
163 function _typeof(obj) {
164 "@babel/helpers - typeof";
165 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
166 _typeof = function _typeof2(obj2) {
167 return typeof obj2;
168 };
169 } else {
170 _typeof = function _typeof2(obj2) {
171 return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
172 };
173 }
174 return _typeof(obj);
175 }
176 var ClipboardActionDefault = function ClipboardActionDefault2() {
177 var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
178 var _options$action = options.action, action = _options$action === void 0 ? "copy" : _options$action, container = options.container, target = options.target, text = options.text;
179 if (action !== "copy" && action !== "cut") {
180 throw new Error('Invalid "action" value, use either "copy" or "cut"');
181 }
182 if (target !== void 0) {
183 if (target && _typeof(target) === "object" && target.nodeType === 1) {
184 if (action === "copy" && target.hasAttribute("disabled")) {
185 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
186 }
187 if (action === "cut" && (target.hasAttribute("readonly") || target.hasAttribute("disabled"))) {
188 throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`);
189 }
190 } else {
191 throw new Error('Invalid "target" value, use a valid Element');
192 }
193 }
194 if (text) {
195 return actions_copy(text, {
196 container
197 });
198 }
199 if (target) {
200 return action === "cut" ? actions_cut(target) : actions_copy(target, {
201 container
202 });
203 }
204 };
205 var actions_default = ClipboardActionDefault;
206 ;
207 function clipboard_typeof(obj) {
208 "@babel/helpers - typeof";
209 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
210 clipboard_typeof = function _typeof2(obj2) {
211 return typeof obj2;
212 };
213 } else {
214 clipboard_typeof = function _typeof2(obj2) {
215 return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
216 };
217 }
218 return clipboard_typeof(obj);
219 }
220 function _classCallCheck(instance, Constructor) {
221 if (!(instance instanceof Constructor)) {
222 throw new TypeError("Cannot call a class as a function");
223 }
224 }
225 function _defineProperties(target, props) {
226 for (var i = 0; i < props.length; i++) {
227 var descriptor = props[i];
228 descriptor.enumerable = descriptor.enumerable || false;
229 descriptor.configurable = true;
230 if ("value" in descriptor) descriptor.writable = true;
231 Object.defineProperty(target, descriptor.key, descriptor);
232 }
233 }
234 function _createClass(Constructor, protoProps, staticProps) {
235 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
236 if (staticProps) _defineProperties(Constructor, staticProps);
237 return Constructor;
238 }
239 function _inherits(subClass, superClass) {
240 if (typeof superClass !== "function" && superClass !== null) {
241 throw new TypeError("Super expression must either be null or a function");
242 }
243 subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
244 if (superClass) _setPrototypeOf(subClass, superClass);
245 }
246 function _setPrototypeOf(o, p) {
247 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
248 o2.__proto__ = p2;
249 return o2;
250 };
251 return _setPrototypeOf(o, p);
252 }
253 function _createSuper(Derived) {
254 var hasNativeReflectConstruct = _isNativeReflectConstruct();
255 return function _createSuperInternal() {
256 var Super = _getPrototypeOf(Derived), result;
257 if (hasNativeReflectConstruct) {
258 var NewTarget = _getPrototypeOf(this).constructor;
259 result = Reflect.construct(Super, arguments, NewTarget);
260 } else {
261 result = Super.apply(this, arguments);
262 }
263 return _possibleConstructorReturn(this, result);
264 };
265 }
266 function _possibleConstructorReturn(self, call) {
267 if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) {
268 return call;
269 }
270 return _assertThisInitialized(self);
271 }
272 function _assertThisInitialized(self) {
273 if (self === void 0) {
274 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
275 }
276 return self;
277 }
278 function _isNativeReflectConstruct() {
279 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
280 if (Reflect.construct.sham) return false;
281 if (typeof Proxy === "function") return true;
282 try {
283 Date.prototype.toString.call(Reflect.construct(Date, [], function() {
284 }));
285 return true;
286 } catch (e) {
287 return false;
288 }
289 }
290 function _getPrototypeOf(o) {
291 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
292 return o2.__proto__ || Object.getPrototypeOf(o2);
293 };
294 return _getPrototypeOf(o);
295 }
296 function getAttributeValue(suffix, element) {
297 var attribute = "data-clipboard-".concat(suffix);
298 if (!element.hasAttribute(attribute)) {
299 return;
300 }
301 return element.getAttribute(attribute);
302 }
303 var Clipboard3 = /* @__PURE__ */ (function(_Emitter) {
304 _inherits(Clipboard4, _Emitter);
305 var _super = _createSuper(Clipboard4);
306 function Clipboard4(trigger, options) {
307 var _this;
308 _classCallCheck(this, Clipboard4);
309 _this = _super.call(this);
310 _this.resolveOptions(options);
311 _this.listenClick(trigger);
312 return _this;
313 }
314 _createClass(Clipboard4, [{
315 key: "resolveOptions",
316 value: function resolveOptions() {
317 var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
318 this.action = typeof options.action === "function" ? options.action : this.defaultAction;
319 this.target = typeof options.target === "function" ? options.target : this.defaultTarget;
320 this.text = typeof options.text === "function" ? options.text : this.defaultText;
321 this.container = clipboard_typeof(options.container) === "object" ? options.container : document.body;
322 }
323 /**
324 * Adds a click event listener to the passed trigger.
325 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
326 */
327 }, {
328 key: "listenClick",
329 value: function listenClick(trigger) {
330 var _this2 = this;
331 this.listener = listen_default()(trigger, "click", function(e) {
332 return _this2.onClick(e);
333 });
334 }
335 /**
336 * Defines a new `ClipboardAction` on each click event.
337 * @param {Event} e
338 */
339 }, {
340 key: "onClick",
341 value: function onClick(e) {
342 var trigger = e.delegateTarget || e.currentTarget;
343 var action = this.action(trigger) || "copy";
344 var text = actions_default({
345 action,
346 container: this.container,
347 target: this.target(trigger),
348 text: this.text(trigger)
349 });
350 this.emit(text ? "success" : "error", {
351 action,
352 text,
353 trigger,
354 clearSelection: function clearSelection() {
355 if (trigger) {
356 trigger.focus();
357 }
358 window.getSelection().removeAllRanges();
359 }
360 });
361 }
362 /**
363 * Default `action` lookup function.
364 * @param {Element} trigger
365 */
366 }, {
367 key: "defaultAction",
368 value: function defaultAction(trigger) {
369 return getAttributeValue("action", trigger);
370 }
371 /**
372 * Default `target` lookup function.
373 * @param {Element} trigger
374 */
375 }, {
376 key: "defaultTarget",
377 value: function defaultTarget(trigger) {
378 var selector = getAttributeValue("target", trigger);
379 if (selector) {
380 return document.querySelector(selector);
381 }
382 }
383 /**
384 * Allow fire programmatically a copy action
385 * @param {String|HTMLElement} target
386 * @param {Object} options
387 * @returns Text copied.
388 */
389 }, {
390 key: "defaultText",
391 /**
392 * Default `text` lookup function.
393 * @param {Element} trigger
394 */
395 value: function defaultText(trigger) {
396 return getAttributeValue("text", trigger);
397 }
398 /**
399 * Destroy lifecycle.
400 */
401 }, {
402 key: "destroy",
403 value: function destroy() {
404 this.listener.destroy();
405 }
406 }], [{
407 key: "copy",
408 value: function copy(target) {
409 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
410 container: document.body
411 };
412 return actions_copy(target, options);
413 }
414 /**
415 * Allow fire programmatically a cut action
416 * @param {String|HTMLElement} target
417 * @returns Text cutted.
418 */
419 }, {
420 key: "cut",
421 value: function cut(target) {
422 return actions_cut(target);
423 }
424 /**
425 * Returns the support of the given action, or all actions if no action is
426 * given.
427 * @param {String} [action]
428 */
429 }, {
430 key: "isSupported",
431 value: function isSupported() {
432 var action = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ["copy", "cut"];
433 var actions = typeof action === "string" ? [action] : action;
434 var support = !!document.queryCommandSupported;
435 actions.forEach(function(action2) {
436 support = support && !!document.queryCommandSupported(action2);
437 });
438 return support;
439 }
440 }]);
441 return Clipboard4;
442 })(tiny_emitter_default());
443 var clipboard = Clipboard3;
444 })
445 ),
446 /***/
447 828: (
448 /***/
449 (function(module2) {
450 var DOCUMENT_NODE_TYPE = 9;
451 if (typeof Element !== "undefined" && !Element.prototype.matches) {
452 var proto = Element.prototype;
453 proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector;
454 }
455 function closest(element, selector) {
456 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
457 if (typeof element.matches === "function" && element.matches(selector)) {
458 return element;
459 }
460 element = element.parentNode;
461 }
462 }
463 module2.exports = closest;
464 })
465 ),
466 /***/
467 438: (
468 /***/
469 (function(module2, __unused_webpack_exports, __webpack_require__2) {
470 var closest = __webpack_require__2(828);
471 function _delegate(element, selector, type, callback, useCapture) {
472 var listenerFn = listener2.apply(this, arguments);
473 element.addEventListener(type, listenerFn, useCapture);
474 return {
475 destroy: function() {
476 element.removeEventListener(type, listenerFn, useCapture);
477 }
478 };
479 }
480 function delegate(elements, selector, type, callback, useCapture) {
481 if (typeof elements.addEventListener === "function") {
482 return _delegate.apply(null, arguments);
483 }
484 if (typeof type === "function") {
485 return _delegate.bind(null, document).apply(null, arguments);
486 }
487 if (typeof elements === "string") {
488 elements = document.querySelectorAll(elements);
489 }
490 return Array.prototype.map.call(elements, function(element) {
491 return _delegate(element, selector, type, callback, useCapture);
492 });
493 }
494 function listener2(element, selector, type, callback) {
495 return function(e) {
496 e.delegateTarget = closest(e.target, selector);
497 if (e.delegateTarget) {
498 callback.call(element, e);
499 }
500 };
501 }
502 module2.exports = delegate;
503 })
504 ),
505 /***/
506 879: (
507 /***/
508 (function(__unused_webpack_module, exports2) {
509 exports2.node = function(value) {
510 return value !== void 0 && value instanceof HTMLElement && value.nodeType === 1;
511 };
512 exports2.nodeList = function(value) {
513 var type = Object.prototype.toString.call(value);
514 return value !== void 0 && (type === "[object NodeList]" || type === "[object HTMLCollection]") && "length" in value && (value.length === 0 || exports2.node(value[0]));
515 };
516 exports2.string = function(value) {
517 return typeof value === "string" || value instanceof String;
518 };
519 exports2.fn = function(value) {
520 var type = Object.prototype.toString.call(value);
521 return type === "[object Function]";
522 };
523 })
524 ),
525 /***/
526 370: (
527 /***/
528 (function(module2, __unused_webpack_exports, __webpack_require__2) {
529 var is = __webpack_require__2(879);
530 var delegate = __webpack_require__2(438);
531 function listen(target, type, callback) {
532 if (!target && !type && !callback) {
533 throw new Error("Missing required arguments");
534 }
535 if (!is.string(type)) {
536 throw new TypeError("Second argument must be a String");
537 }
538 if (!is.fn(callback)) {
539 throw new TypeError("Third argument must be a Function");
540 }
541 if (is.node(target)) {
542 return listenNode(target, type, callback);
543 } else if (is.nodeList(target)) {
544 return listenNodeList(target, type, callback);
545 } else if (is.string(target)) {
546 return listenSelector(target, type, callback);
547 } else {
548 throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");
549 }
550 }
551 function listenNode(node, type, callback) {
552 node.addEventListener(type, callback);
553 return {
554 destroy: function() {
555 node.removeEventListener(type, callback);
556 }
557 };
558 }
559 function listenNodeList(nodeList, type, callback) {
560 Array.prototype.forEach.call(nodeList, function(node) {
561 node.addEventListener(type, callback);
562 });
563 return {
564 destroy: function() {
565 Array.prototype.forEach.call(nodeList, function(node) {
566 node.removeEventListener(type, callback);
567 });
568 }
569 };
570 }
571 function listenSelector(selector, type, callback) {
572 return delegate(document.body, selector, type, callback);
573 }
574 module2.exports = listen;
575 })
576 ),
577 /***/
578 817: (
579 /***/
580 (function(module2) {
581 function select(element) {
582 var selectedText;
583 if (element.nodeName === "SELECT") {
584 element.focus();
585 selectedText = element.value;
586 } else if (element.nodeName === "INPUT" || element.nodeName === "TEXTAREA") {
587 var isReadOnly = element.hasAttribute("readonly");
588 if (!isReadOnly) {
589 element.setAttribute("readonly", "");
590 }
591 element.select();
592 element.setSelectionRange(0, element.value.length);
593 if (!isReadOnly) {
594 element.removeAttribute("readonly");
595 }
596 selectedText = element.value;
597 } else {
598 if (element.hasAttribute("contenteditable")) {
599 element.focus();
600 }
601 var selection = window.getSelection();
602 var range = document.createRange();
603 range.selectNodeContents(element);
604 selection.removeAllRanges();
605 selection.addRange(range);
606 selectedText = selection.toString();
607 }
608 return selectedText;
609 }
610 module2.exports = select;
611 })
612 ),
613 /***/
614 279: (
615 /***/
616 (function(module2) {
617 function E() {
618 }
619 E.prototype = {
620 on: function(name, callback, ctx) {
621 var e = this.e || (this.e = {});
622 (e[name] || (e[name] = [])).push({
623 fn: callback,
624 ctx
625 });
626 return this;
627 },
628 once: function(name, callback, ctx) {
629 var self = this;
630 function listener2() {
631 self.off(name, listener2);
632 callback.apply(ctx, arguments);
633 }
634 ;
635 listener2._ = callback;
636 return this.on(name, listener2, ctx);
637 },
638 emit: function(name) {
639 var data = [].slice.call(arguments, 1);
640 var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
641 var i = 0;
642 var len = evtArr.length;
643 for (i; i < len; i++) {
644 evtArr[i].fn.apply(evtArr[i].ctx, data);
645 }
646 return this;
647 },
648 off: function(name, callback) {
649 var e = this.e || (this.e = {});
650 var evts = e[name];
651 var liveEvents = [];
652 if (evts && callback) {
653 for (var i = 0, len = evts.length; i < len; i++) {
654 if (evts[i].fn !== callback && evts[i].fn._ !== callback)
655 liveEvents.push(evts[i]);
656 }
657 }
658 liveEvents.length ? e[name] = liveEvents : delete e[name];
659 return this;
660 }
661 };
662 module2.exports = E;
663 module2.exports.TinyEmitter = E;
664 })
665 )
666 /******/
667 };
668 var __webpack_module_cache__ = {};
669 function __webpack_require__(moduleId) {
670 if (__webpack_module_cache__[moduleId]) {
671 return __webpack_module_cache__[moduleId].exports;
672 }
673 var module2 = __webpack_module_cache__[moduleId] = {
674 /******/
675 // no module.id needed
676 /******/
677 // no module.loaded needed
678 /******/
679 exports: {}
680 /******/
681 };
682 __webpack_modules__[moduleId](module2, module2.exports, __webpack_require__);
683 return module2.exports;
684 }
685 !(function() {
686 __webpack_require__.n = function(module2) {
687 var getter = module2 && module2.__esModule ? (
688 /******/
689 function() {
690 return module2["default"];
691 }
692 ) : (
693 /******/
694 function() {
695 return module2;
696 }
697 );
698 __webpack_require__.d(getter, { a: getter });
699 return getter;
700 };
701 })();
702 !(function() {
703 __webpack_require__.d = function(exports2, definition) {
704 for (var key in definition) {
705 if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports2, key)) {
706 Object.defineProperty(exports2, key, { enumerable: true, get: definition[key] });
707 }
708 }
709 };
710 })();
711 !(function() {
712 __webpack_require__.o = function(obj, prop) {
713 return Object.prototype.hasOwnProperty.call(obj, prop);
714 };
715 })();
716 return __webpack_require__(686);
717 })().default
718 );
719 });
720 }
721 });
722
723 // package-external:@wordpress/keycodes
724 var require_keycodes = __commonJS({
725 "package-external:@wordpress/keycodes"(exports, module) {
726 module.exports = window.wp.keycodes;
727 }
728 });
729
730 // node_modules/mousetrap/mousetrap.js
731 var require_mousetrap = __commonJS({
732 "node_modules/mousetrap/mousetrap.js"(exports, module) {
733 (function(window2, document2, undefined2) {
734 if (!window2) {
735 return;
736 }
737 var _MAP = {
738 8: "backspace",
739 9: "tab",
740 13: "enter",
741 16: "shift",
742 17: "ctrl",
743 18: "alt",
744 20: "capslock",
745 27: "esc",
746 32: "space",
747 33: "pageup",
748 34: "pagedown",
749 35: "end",
750 36: "home",
751 37: "left",
752 38: "up",
753 39: "right",
754 40: "down",
755 45: "ins",
756 46: "del",
757 91: "meta",
758 93: "meta",
759 224: "meta"
760 };
761 var _KEYCODE_MAP = {
762 106: "*",
763 107: "+",
764 109: "-",
765 110: ".",
766 111: "/",
767 186: ";",
768 187: "=",
769 188: ",",
770 189: "-",
771 190: ".",
772 191: "/",
773 192: "`",
774 219: "[",
775 220: "\\",
776 221: "]",
777 222: "'"
778 };
779 var _SHIFT_MAP = {
780 "~": "`",
781 "!": "1",
782 "@": "2",
783 "#": "3",
784 "$": "4",
785 "%": "5",
786 "^": "6",
787 "&": "7",
788 "*": "8",
789 "(": "9",
790 ")": "0",
791 "_": "-",
792 "+": "=",
793 ":": ";",
794 '"': "'",
795 "<": ",",
796 ">": ".",
797 "?": "/",
798 "|": "\\"
799 };
800 var _SPECIAL_ALIASES = {
801 "option": "alt",
802 "command": "meta",
803 "return": "enter",
804 "escape": "esc",
805 "plus": "+",
806 "mod": /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? "meta" : "ctrl"
807 };
808 var _REVERSE_MAP;
809 for (var i = 1; i < 20; ++i) {
810 _MAP[111 + i] = "f" + i;
811 }
812 for (i = 0; i <= 9; ++i) {
813 _MAP[i + 96] = i.toString();
814 }
815 function _addEvent(object, type, callback) {
816 if (object.addEventListener) {
817 object.addEventListener(type, callback, false);
818 return;
819 }
820 object.attachEvent("on" + type, callback);
821 }
822 function _characterFromEvent(e) {
823 if (e.type == "keypress") {
824 var character = String.fromCharCode(e.which);
825 if (!e.shiftKey) {
826 character = character.toLowerCase();
827 }
828 return character;
829 }
830 if (_MAP[e.which]) {
831 return _MAP[e.which];
832 }
833 if (_KEYCODE_MAP[e.which]) {
834 return _KEYCODE_MAP[e.which];
835 }
836 return String.fromCharCode(e.which).toLowerCase();
837 }
838 function _modifiersMatch(modifiers1, modifiers2) {
839 return modifiers1.sort().join(",") === modifiers2.sort().join(",");
840 }
841 function _eventModifiers(e) {
842 var modifiers = [];
843 if (e.shiftKey) {
844 modifiers.push("shift");
845 }
846 if (e.altKey) {
847 modifiers.push("alt");
848 }
849 if (e.ctrlKey) {
850 modifiers.push("ctrl");
851 }
852 if (e.metaKey) {
853 modifiers.push("meta");
854 }
855 return modifiers;
856 }
857 function _preventDefault(e) {
858 if (e.preventDefault) {
859 e.preventDefault();
860 return;
861 }
862 e.returnValue = false;
863 }
864 function _stopPropagation(e) {
865 if (e.stopPropagation) {
866 e.stopPropagation();
867 return;
868 }
869 e.cancelBubble = true;
870 }
871 function _isModifier(key) {
872 return key == "shift" || key == "ctrl" || key == "alt" || key == "meta";
873 }
874 function _getReverseMap() {
875 if (!_REVERSE_MAP) {
876 _REVERSE_MAP = {};
877 for (var key in _MAP) {
878 if (key > 95 && key < 112) {
879 continue;
880 }
881 if (_MAP.hasOwnProperty(key)) {
882 _REVERSE_MAP[_MAP[key]] = key;
883 }
884 }
885 }
886 return _REVERSE_MAP;
887 }
888 function _pickBestAction(key, modifiers, action) {
889 if (!action) {
890 action = _getReverseMap()[key] ? "keydown" : "keypress";
891 }
892 if (action == "keypress" && modifiers.length) {
893 action = "keydown";
894 }
895 return action;
896 }
897 function _keysFromString(combination) {
898 if (combination === "+") {
899 return ["+"];
900 }
901 combination = combination.replace(/\+{2}/g, "+plus");
902 return combination.split("+");
903 }
904 function _getKeyInfo(combination, action) {
905 var keys;
906 var key;
907 var i2;
908 var modifiers = [];
909 keys = _keysFromString(combination);
910 for (i2 = 0; i2 < keys.length; ++i2) {
911 key = keys[i2];
912 if (_SPECIAL_ALIASES[key]) {
913 key = _SPECIAL_ALIASES[key];
914 }
915 if (action && action != "keypress" && _SHIFT_MAP[key]) {
916 key = _SHIFT_MAP[key];
917 modifiers.push("shift");
918 }
919 if (_isModifier(key)) {
920 modifiers.push(key);
921 }
922 }
923 action = _pickBestAction(key, modifiers, action);
924 return {
925 key,
926 modifiers,
927 action
928 };
929 }
930 function _belongsTo(element, ancestor) {
931 if (element === null || element === document2) {
932 return false;
933 }
934 if (element === ancestor) {
935 return true;
936 }
937 return _belongsTo(element.parentNode, ancestor);
938 }
939 function Mousetrap3(targetElement) {
940 var self = this;
941 targetElement = targetElement || document2;
942 if (!(self instanceof Mousetrap3)) {
943 return new Mousetrap3(targetElement);
944 }
945 self.target = targetElement;
946 self._callbacks = {};
947 self._directMap = {};
948 var _sequenceLevels = {};
949 var _resetTimer;
950 var _ignoreNextKeyup = false;
951 var _ignoreNextKeypress = false;
952 var _nextExpectedAction = false;
953 function _resetSequences(doNotReset) {
954 doNotReset = doNotReset || {};
955 var activeSequences = false, key;
956 for (key in _sequenceLevels) {
957 if (doNotReset[key]) {
958 activeSequences = true;
959 continue;
960 }
961 _sequenceLevels[key] = 0;
962 }
963 if (!activeSequences) {
964 _nextExpectedAction = false;
965 }
966 }
967 function _getMatches(character, modifiers, e, sequenceName, combination, level) {
968 var i2;
969 var callback;
970 var matches = [];
971 var action = e.type;
972 if (!self._callbacks[character]) {
973 return [];
974 }
975 if (action == "keyup" && _isModifier(character)) {
976 modifiers = [character];
977 }
978 for (i2 = 0; i2 < self._callbacks[character].length; ++i2) {
979 callback = self._callbacks[character][i2];
980 if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
981 continue;
982 }
983 if (action != callback.action) {
984 continue;
985 }
986 if (action == "keypress" && !e.metaKey && !e.ctrlKey || _modifiersMatch(modifiers, callback.modifiers)) {
987 var deleteCombo = !sequenceName && callback.combo == combination;
988 var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
989 if (deleteCombo || deleteSequence) {
990 self._callbacks[character].splice(i2, 1);
991 }
992 matches.push(callback);
993 }
994 }
995 return matches;
996 }
997 function _fireCallback(callback, e, combo, sequence) {
998 if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
999 return;
1000 }
1001 if (callback(e, combo) === false) {
1002 _preventDefault(e);
1003 _stopPropagation(e);
1004 }
1005 }
1006 self._handleKey = function(character, modifiers, e) {
1007 var callbacks = _getMatches(character, modifiers, e);
1008 var i2;
1009 var doNotReset = {};
1010 var maxLevel = 0;
1011 var processedSequenceCallback = false;
1012 for (i2 = 0; i2 < callbacks.length; ++i2) {
1013 if (callbacks[i2].seq) {
1014 maxLevel = Math.max(maxLevel, callbacks[i2].level);
1015 }
1016 }
1017 for (i2 = 0; i2 < callbacks.length; ++i2) {
1018 if (callbacks[i2].seq) {
1019 if (callbacks[i2].level != maxLevel) {
1020 continue;
1021 }
1022 processedSequenceCallback = true;
1023 doNotReset[callbacks[i2].seq] = 1;
1024 _fireCallback(callbacks[i2].callback, e, callbacks[i2].combo, callbacks[i2].seq);
1025 continue;
1026 }
1027 if (!processedSequenceCallback) {
1028 _fireCallback(callbacks[i2].callback, e, callbacks[i2].combo);
1029 }
1030 }
1031 var ignoreThisKeypress = e.type == "keypress" && _ignoreNextKeypress;
1032 if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
1033 _resetSequences(doNotReset);
1034 }
1035 _ignoreNextKeypress = processedSequenceCallback && e.type == "keydown";
1036 };
1037 function _handleKeyEvent(e) {
1038 if (typeof e.which !== "number") {
1039 e.which = e.keyCode;
1040 }
1041 var character = _characterFromEvent(e);
1042 if (!character) {
1043 return;
1044 }
1045 if (e.type == "keyup" && _ignoreNextKeyup === character) {
1046 _ignoreNextKeyup = false;
1047 return;
1048 }
1049 self.handleKey(character, _eventModifiers(e), e);
1050 }
1051 function _resetSequenceTimer() {
1052 clearTimeout(_resetTimer);
1053 _resetTimer = setTimeout(_resetSequences, 1e3);
1054 }
1055 function _bindSequence(combo, keys, callback, action) {
1056 _sequenceLevels[combo] = 0;
1057 function _increaseSequence(nextAction) {
1058 return function() {
1059 _nextExpectedAction = nextAction;
1060 ++_sequenceLevels[combo];
1061 _resetSequenceTimer();
1062 };
1063 }
1064 function _callbackAndReset(e) {
1065 _fireCallback(callback, e, combo);
1066 if (action !== "keyup") {
1067 _ignoreNextKeyup = _characterFromEvent(e);
1068 }
1069 setTimeout(_resetSequences, 10);
1070 }
1071 for (var i2 = 0; i2 < keys.length; ++i2) {
1072 var isFinal = i2 + 1 === keys.length;
1073 var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i2 + 1]).action);
1074 _bindSingle(keys[i2], wrappedCallback, action, combo, i2);
1075 }
1076 }
1077 function _bindSingle(combination, callback, action, sequenceName, level) {
1078 self._directMap[combination + ":" + action] = callback;
1079 combination = combination.replace(/\s+/g, " ");
1080 var sequence = combination.split(" ");
1081 var info;
1082 if (sequence.length > 1) {
1083 _bindSequence(combination, sequence, callback, action);
1084 return;
1085 }
1086 info = _getKeyInfo(combination, action);
1087 self._callbacks[info.key] = self._callbacks[info.key] || [];
1088 _getMatches(info.key, info.modifiers, { type: info.action }, sequenceName, combination, level);
1089 self._callbacks[info.key][sequenceName ? "unshift" : "push"]({
1090 callback,
1091 modifiers: info.modifiers,
1092 action: info.action,
1093 seq: sequenceName,
1094 level,
1095 combo: combination
1096 });
1097 }
1098 self._bindMultiple = function(combinations, callback, action) {
1099 for (var i2 = 0; i2 < combinations.length; ++i2) {
1100 _bindSingle(combinations[i2], callback, action);
1101 }
1102 };
1103 _addEvent(targetElement, "keypress", _handleKeyEvent);
1104 _addEvent(targetElement, "keydown", _handleKeyEvent);
1105 _addEvent(targetElement, "keyup", _handleKeyEvent);
1106 }
1107 Mousetrap3.prototype.bind = function(keys, callback, action) {
1108 var self = this;
1109 keys = keys instanceof Array ? keys : [keys];
1110 self._bindMultiple.call(self, keys, callback, action);
1111 return self;
1112 };
1113 Mousetrap3.prototype.unbind = function(keys, action) {
1114 var self = this;
1115 return self.bind.call(self, keys, function() {
1116 }, action);
1117 };
1118 Mousetrap3.prototype.trigger = function(keys, action) {
1119 var self = this;
1120 if (self._directMap[keys + ":" + action]) {
1121 self._directMap[keys + ":" + action]({}, keys);
1122 }
1123 return self;
1124 };
1125 Mousetrap3.prototype.reset = function() {
1126 var self = this;
1127 self._callbacks = {};
1128 self._directMap = {};
1129 return self;
1130 };
1131 Mousetrap3.prototype.stopCallback = function(e, element) {
1132 var self = this;
1133 if ((" " + element.className + " ").indexOf(" mousetrap ") > -1) {
1134 return false;
1135 }
1136 if (_belongsTo(element, self.target)) {
1137 return false;
1138 }
1139 if ("composedPath" in e && typeof e.composedPath === "function") {
1140 var initialEventTarget = e.composedPath()[0];
1141 if (initialEventTarget !== e.target) {
1142 element = initialEventTarget;
1143 }
1144 }
1145 return element.tagName == "INPUT" || element.tagName == "SELECT" || element.tagName == "TEXTAREA" || element.isContentEditable;
1146 };
1147 Mousetrap3.prototype.handleKey = function() {
1148 var self = this;
1149 return self._handleKey.apply(self, arguments);
1150 };
1151 Mousetrap3.addKeycodes = function(object) {
1152 for (var key in object) {
1153 if (object.hasOwnProperty(key)) {
1154 _MAP[key] = object[key];
1155 }
1156 }
1157 _REVERSE_MAP = null;
1158 };
1159 Mousetrap3.init = function() {
1160 var documentMousetrap = Mousetrap3(document2);
1161 for (var method in documentMousetrap) {
1162 if (method.charAt(0) !== "_") {
1163 Mousetrap3[method] = /* @__PURE__ */ (function(method2) {
1164 return function() {
1165 return documentMousetrap[method2].apply(documentMousetrap, arguments);
1166 };
1167 })(method);
1168 }
1169 }
1170 };
1171 Mousetrap3.init();
1172 window2.Mousetrap = Mousetrap3;
1173 if (typeof module !== "undefined" && module.exports) {
1174 module.exports = Mousetrap3;
1175 }
1176 if (typeof define === "function" && define.amd) {
1177 define(function() {
1178 return Mousetrap3;
1179 });
1180 }
1181 })(typeof window !== "undefined" ? window : null, typeof window !== "undefined" ? document : null);
1182 }
1183 });
1184
1185 // package-external:@wordpress/undo-manager
1186 var require_undo_manager = __commonJS({
1187 "package-external:@wordpress/undo-manager"(exports, module) {
1188 module.exports = window.wp.undoManager;
1189 }
1190 });
1191
1192 // package-external:@wordpress/priority-queue
1193 var require_priority_queue = __commonJS({
1194 "package-external:@wordpress/priority-queue"(exports, module) {
1195 module.exports = window.wp.priorityQueue;
1196 }
1197 });
1198
1199 // vendor-external:react
1200 var require_react = __commonJS({
1201 "vendor-external:react"(exports, module) {
1202 module.exports = window.React;
1203 }
1204 });
1205
1206 // packages/compose/build-module/index.mjs
1207 var index_exports = {};
1208 __export(index_exports, {
1209 __experimentalUseDialog: () => use_dialog_default,
1210 __experimentalUseDragging: () => useDragging,
1211 __experimentalUseDropZone: () => useDropZone,
1212 __experimentalUseFixedWindowList: () => useFixedWindowList,
1213 __experimentalUseFocusOutside: () => useFocusOutside,
1214 compose: () => compose_default,
1215 createHigherOrderComponent: () => createHigherOrderComponent,
1216 debounce: () => debounce,
1217 ifCondition: () => if_condition_default,
1218 observableMap: () => observableMap,
1219 pipe: () => pipe_default,
1220 pure: () => pure_default,
1221 throttle: () => throttle,
1222 useAsyncList: () => use_async_list_default,
1223 useConstrainedTabbing: () => use_constrained_tabbing_default,
1224 useCopyOnClick: () => useCopyOnClick,
1225 useCopyToClipboard: () => useCopyToClipboard,
1226 useDebounce: () => useDebounce,
1227 useDebouncedInput: () => useDebouncedInput,
1228 useDisabled: () => useDisabled,
1229 useEvent: () => useEvent,
1230 useFocusOnMount: () => useFocusOnMount,
1231 useFocusReturn: () => use_focus_return_default,
1232 useFocusableIframe: () => useFocusableIframe,
1233 useInstanceId: () => use_instance_id_default,
1234 useIsomorphicLayoutEffect: () => use_isomorphic_layout_effect_default,
1235 useKeyboardShortcut: () => use_keyboard_shortcut_default,
1236 useMediaQuery: () => useMediaQuery,
1237 useMergeRefs: () => useMergeRefs,
1238 useObservableValue: () => useObservableValue,
1239 usePrevious: () => usePrevious,
1240 useReducedMotion: () => use_reduced_motion_default,
1241 useRefEffect: () => useRefEffect,
1242 useResizeObserver: () => useResizeObserver2,
1243 useStateWithHistory: () => useStateWithHistory,
1244 useThrottle: () => useThrottle,
1245 useViewportMatch: () => use_viewport_match_default,
1246 useWarnOnChange: () => use_warn_on_change_default,
1247 withGlobalEvents: () => withGlobalEvents,
1248 withInstanceId: () => with_instance_id_default,
1249 withSafeTimeout: () => with_safe_timeout_default,
1250 withState: () => withState
1251 });
1252
1253 // node_modules/tslib/tslib.es6.mjs
1254 var __assign = function() {
1255 __assign = Object.assign || function __assign2(t) {
1256 for (var s, i = 1, n = arguments.length; i < n; i++) {
1257 s = arguments[i];
1258 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1259 }
1260 return t;
1261 };
1262 return __assign.apply(this, arguments);
1263 };
1264
1265 // node_modules/lower-case/dist.es2015/index.js
1266 function lowerCase(str) {
1267 return str.toLowerCase();
1268 }
1269
1270 // node_modules/no-case/dist.es2015/index.js
1271 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
1272 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
1273 function noCase(input, options) {
1274 if (options === void 0) {
1275 options = {};
1276 }
1277 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
1278 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
1279 var start = 0;
1280 var end = result.length;
1281 while (result.charAt(start) === "\0")
1282 start++;
1283 while (result.charAt(end - 1) === "\0")
1284 end--;
1285 return result.slice(start, end).split("\0").map(transform).join(delimiter);
1286 }
1287 function replace(input, re, value) {
1288 if (re instanceof RegExp)
1289 return input.replace(re, value);
1290 return re.reduce(function(input2, re2) {
1291 return input2.replace(re2, value);
1292 }, input);
1293 }
1294
1295 // node_modules/pascal-case/dist.es2015/index.js
1296 function pascalCaseTransform(input, index) {
1297 var firstChar = input.charAt(0);
1298 var lowerChars = input.substr(1).toLowerCase();
1299 if (index > 0 && firstChar >= "0" && firstChar <= "9") {
1300 return "_" + firstChar + lowerChars;
1301 }
1302 return "" + firstChar.toUpperCase() + lowerChars;
1303 }
1304 function pascalCase(input, options) {
1305 if (options === void 0) {
1306 options = {};
1307 }
1308 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
1309 }
1310
1311 // packages/compose/build-module/utils/create-higher-order-component/index.mjs
1312 function createHigherOrderComponent(mapComponent, modifierName) {
1313 return (Inner) => {
1314 const Outer = mapComponent(Inner);
1315 Outer.displayName = hocName(modifierName, Inner);
1316 return Outer;
1317 };
1318 }
1319 var hocName = (name, Inner) => {
1320 const inner = Inner.displayName || Inner.name || "Component";
1321 const outer = pascalCase(name ?? "");
1322 return `${outer}(${inner})`;
1323 };
1324
1325 // packages/compose/build-module/utils/debounce/index.mjs
1326 var debounce = (func, wait, options) => {
1327 let lastArgs;
1328 let lastThis;
1329 let maxWait = 0;
1330 let result;
1331 let timerId;
1332 let lastCallTime;
1333 let lastInvokeTime = 0;
1334 let leading = false;
1335 let maxing = false;
1336 let trailing = true;
1337 if (options) {
1338 leading = !!options.leading;
1339 maxing = "maxWait" in options;
1340 if (options.maxWait !== void 0) {
1341 maxWait = Math.max(options.maxWait, wait);
1342 }
1343 trailing = "trailing" in options ? !!options.trailing : trailing;
1344 }
1345 function invokeFunc(time) {
1346 const args = lastArgs;
1347 const thisArg = lastThis;
1348 lastArgs = void 0;
1349 lastThis = void 0;
1350 lastInvokeTime = time;
1351 result = func.apply(thisArg, args);
1352 return result;
1353 }
1354 function startTimer(pendingFunc, waitTime) {
1355 timerId = setTimeout(pendingFunc, waitTime);
1356 }
1357 function cancelTimer() {
1358 if (timerId !== void 0) {
1359 clearTimeout(timerId);
1360 }
1361 }
1362 function leadingEdge(time) {
1363 lastInvokeTime = time;
1364 startTimer(timerExpired, wait);
1365 return leading ? invokeFunc(time) : result;
1366 }
1367 function getTimeSinceLastCall(time) {
1368 return time - (lastCallTime || 0);
1369 }
1370 function remainingWait(time) {
1371 const timeSinceLastCall = getTimeSinceLastCall(time);
1372 const timeSinceLastInvoke = time - lastInvokeTime;
1373 const timeWaiting = wait - timeSinceLastCall;
1374 return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
1375 }
1376 function shouldInvoke(time) {
1377 const timeSinceLastCall = getTimeSinceLastCall(time);
1378 const timeSinceLastInvoke = time - lastInvokeTime;
1379 return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
1380 }
1381 function timerExpired() {
1382 const time = Date.now();
1383 if (shouldInvoke(time)) {
1384 return trailingEdge(time);
1385 }
1386 startTimer(timerExpired, remainingWait(time));
1387 return void 0;
1388 }
1389 function clearTimer() {
1390 timerId = void 0;
1391 }
1392 function trailingEdge(time) {
1393 clearTimer();
1394 if (trailing && lastArgs) {
1395 return invokeFunc(time);
1396 }
1397 lastArgs = lastThis = void 0;
1398 return result;
1399 }
1400 function cancel() {
1401 cancelTimer();
1402 lastInvokeTime = 0;
1403 clearTimer();
1404 lastArgs = lastCallTime = lastThis = void 0;
1405 }
1406 function flush() {
1407 return pending() ? trailingEdge(Date.now()) : result;
1408 }
1409 function pending() {
1410 return timerId !== void 0;
1411 }
1412 function debounced(...args) {
1413 const time = Date.now();
1414 const isInvoking = shouldInvoke(time);
1415 lastArgs = args;
1416 lastThis = this;
1417 lastCallTime = time;
1418 if (isInvoking) {
1419 if (!pending()) {
1420 return leadingEdge(lastCallTime);
1421 }
1422 if (maxing) {
1423 startTimer(timerExpired, wait);
1424 return invokeFunc(lastCallTime);
1425 }
1426 }
1427 if (!pending()) {
1428 startTimer(timerExpired, wait);
1429 }
1430 return result;
1431 }
1432 debounced.cancel = cancel;
1433 debounced.flush = flush;
1434 debounced.pending = pending;
1435 return debounced;
1436 };
1437
1438 // packages/compose/build-module/utils/throttle/index.mjs
1439 var throttle = (func, wait, options) => {
1440 let leading = true;
1441 let trailing = true;
1442 if (options) {
1443 leading = "leading" in options ? !!options.leading : leading;
1444 trailing = "trailing" in options ? !!options.trailing : trailing;
1445 }
1446 return debounce(func, wait, {
1447 leading,
1448 trailing,
1449 maxWait: wait
1450 });
1451 };
1452
1453 // packages/compose/build-module/utils/observable-map/index.mjs
1454 function observableMap() {
1455 const map = /* @__PURE__ */ new Map();
1456 const listeners = /* @__PURE__ */ new Map();
1457 function callListeners(name) {
1458 const list = listeners.get(name);
1459 if (!list) {
1460 return;
1461 }
1462 for (const listener2 of list) {
1463 listener2();
1464 }
1465 }
1466 return {
1467 get(name) {
1468 return map.get(name);
1469 },
1470 set(name, value) {
1471 map.set(name, value);
1472 callListeners(name);
1473 },
1474 delete(name) {
1475 map.delete(name);
1476 callListeners(name);
1477 },
1478 subscribe(name, listener2) {
1479 let list = listeners.get(name);
1480 if (!list) {
1481 list = /* @__PURE__ */ new Set();
1482 listeners.set(name, list);
1483 }
1484 list.add(listener2);
1485 return () => {
1486 list.delete(listener2);
1487 if (list.size === 0) {
1488 listeners.delete(name);
1489 }
1490 };
1491 }
1492 };
1493 }
1494
1495 // packages/compose/build-module/higher-order/pipe.mjs
1496 var basePipe = (reverse = false) => (...funcs) => (...args) => {
1497 const functions = funcs.flat();
1498 if (reverse) {
1499 functions.reverse();
1500 }
1501 return functions.reduce(
1502 (prev, func) => [func(...prev)],
1503 args
1504 )[0];
1505 };
1506 var pipe = basePipe();
1507 var pipe_default = pipe;
1508
1509 // packages/compose/build-module/higher-order/compose.mjs
1510 var compose = basePipe(true);
1511 var compose_default = compose;
1512
1513 // packages/compose/build-module/higher-order/if-condition/index.mjs
1514 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1515 function ifCondition(predicate) {
1516 return createHigherOrderComponent(
1517 (WrappedComponent) => (props) => {
1518 if (!predicate(props)) {
1519 return null;
1520 }
1521 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WrappedComponent, { ...props });
1522 },
1523 "ifCondition"
1524 );
1525 }
1526 var if_condition_default = ifCondition;
1527
1528 // packages/compose/build-module/higher-order/pure/index.mjs
1529 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1);
1530 var import_element = __toESM(require_element(), 1);
1531 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1532 var pure = createHigherOrderComponent(function(WrappedComponent) {
1533 if (WrappedComponent.prototype instanceof import_element.Component) {
1534 return class extends WrappedComponent {
1535 shouldComponentUpdate(nextProps, nextState) {
1536 return !(0, import_is_shallow_equal.isShallowEqual)(nextProps, this.props) || !(0, import_is_shallow_equal.isShallowEqual)(nextState, this.state);
1537 }
1538 };
1539 }
1540 return class extends import_element.Component {
1541 shouldComponentUpdate(nextProps) {
1542 return !(0, import_is_shallow_equal.isShallowEqual)(nextProps, this.props);
1543 }
1544 render() {
1545 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WrappedComponent, { ...this.props });
1546 }
1547 };
1548 }, "pure");
1549 var pure_default = pure;
1550
1551 // packages/compose/build-module/higher-order/with-global-events/index.mjs
1552 var import_element2 = __toESM(require_element(), 1);
1553 var import_deprecated = __toESM(require_deprecated(), 1);
1554
1555 // packages/compose/build-module/higher-order/with-global-events/listener.mjs
1556 var Listener = class {
1557 constructor() {
1558 this.listeners = {};
1559 this.handleEvent = this.handleEvent.bind(this);
1560 }
1561 add(eventType, instance) {
1562 if (!this.listeners[eventType]) {
1563 window.addEventListener(eventType, this.handleEvent);
1564 this.listeners[eventType] = [];
1565 }
1566 this.listeners[eventType].push(instance);
1567 }
1568 remove(eventType, instance) {
1569 if (!this.listeners[eventType]) {
1570 return;
1571 }
1572 this.listeners[eventType] = this.listeners[eventType].filter(
1573 (listener2) => listener2 !== instance
1574 );
1575 if (!this.listeners[eventType].length) {
1576 window.removeEventListener(eventType, this.handleEvent);
1577 delete this.listeners[eventType];
1578 }
1579 }
1580 handleEvent(event) {
1581 this.listeners[event.type]?.forEach(
1582 (instance) => {
1583 instance.handleEvent(event);
1584 }
1585 );
1586 }
1587 };
1588 var listener_default = Listener;
1589
1590 // packages/compose/build-module/higher-order/with-global-events/index.mjs
1591 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1592 var listener = new listener_default();
1593 function withGlobalEvents(eventTypesToHandlers) {
1594 (0, import_deprecated.default)("wp.compose.withGlobalEvents", {
1595 since: "5.7",
1596 alternative: "useEffect"
1597 });
1598 return createHigherOrderComponent((WrappedComponent) => {
1599 class Wrapper extends import_element2.Component {
1600 constructor(props) {
1601 super(props);
1602 this.handleEvent = this.handleEvent.bind(this);
1603 this.handleRef = this.handleRef.bind(this);
1604 }
1605 componentDidMount() {
1606 Object.keys(eventTypesToHandlers).forEach((eventType) => {
1607 listener.add(eventType, this);
1608 });
1609 }
1610 componentWillUnmount() {
1611 Object.keys(eventTypesToHandlers).forEach((eventType) => {
1612 listener.remove(eventType, this);
1613 });
1614 }
1615 handleEvent(event) {
1616 const handler = eventTypesToHandlers[
1617 /** @type {keyof GlobalEventHandlersEventMap} */
1618 event.type
1619 ];
1620 if (typeof this.wrappedRef[handler] === "function") {
1621 this.wrappedRef[handler](event);
1622 }
1623 }
1624 handleRef(el) {
1625 this.wrappedRef = el;
1626 if (this.props.forwardedRef) {
1627 this.props.forwardedRef(el);
1628 }
1629 }
1630 render() {
1631 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1632 WrappedComponent,
1633 {
1634 ...this.props.ownProps,
1635 ref: this.handleRef
1636 }
1637 );
1638 }
1639 }
1640 return (0, import_element2.forwardRef)((props, ref) => {
1641 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Wrapper, { ownProps: props, forwardedRef: ref });
1642 });
1643 }, "withGlobalEvents");
1644 }
1645
1646 // packages/compose/build-module/hooks/use-instance-id/index.mjs
1647 var import_element3 = __toESM(require_element(), 1);
1648 var instanceMap = /* @__PURE__ */ new WeakMap();
1649 function createId(object) {
1650 const instances = instanceMap.get(object) || 0;
1651 instanceMap.set(object, instances + 1);
1652 return instances;
1653 }
1654 function useInstanceId(object, prefix, preferredId) {
1655 return (0, import_element3.useMemo)(() => {
1656 if (preferredId) {
1657 return preferredId;
1658 }
1659 const id = createId(object);
1660 return prefix ? `${prefix}-${id}` : id;
1661 }, [object, preferredId, prefix]);
1662 }
1663 var use_instance_id_default = useInstanceId;
1664
1665 // packages/compose/build-module/higher-order/with-instance-id/index.mjs
1666 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1667 var withInstanceId = createHigherOrderComponent(
1668 (WrappedComponent) => {
1669 return (props) => {
1670 const instanceId = use_instance_id_default(WrappedComponent);
1671 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WrappedComponent, { ...props, instanceId });
1672 };
1673 },
1674 "instanceId"
1675 );
1676 var with_instance_id_default = withInstanceId;
1677
1678 // packages/compose/build-module/higher-order/with-safe-timeout/index.mjs
1679 var import_element4 = __toESM(require_element(), 1);
1680 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1681 var withSafeTimeout = createHigherOrderComponent(
1682 (OriginalComponent) => {
1683 return class WrappedComponent extends import_element4.Component {
1684 timeouts;
1685 constructor(props) {
1686 super(props);
1687 this.timeouts = [];
1688 this.setTimeout = this.setTimeout.bind(this);
1689 this.clearTimeout = this.clearTimeout.bind(this);
1690 }
1691 componentWillUnmount() {
1692 this.timeouts.forEach(clearTimeout);
1693 }
1694 setTimeout(fn, delay) {
1695 const id = setTimeout(() => {
1696 fn();
1697 this.clearTimeout(id);
1698 }, delay);
1699 this.timeouts.push(id);
1700 return id;
1701 }
1702 clearTimeout(id) {
1703 clearTimeout(id);
1704 this.timeouts = this.timeouts.filter(
1705 (timeoutId) => timeoutId !== id
1706 );
1707 }
1708 render() {
1709 return (
1710 // @ts-ignore
1711 /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1712 OriginalComponent,
1713 {
1714 ...this.props,
1715 setTimeout: this.setTimeout,
1716 clearTimeout: this.clearTimeout
1717 }
1718 )
1719 );
1720 }
1721 };
1722 },
1723 "withSafeTimeout"
1724 );
1725 var with_safe_timeout_default = withSafeTimeout;
1726
1727 // packages/compose/build-module/higher-order/with-state/index.mjs
1728 var import_element5 = __toESM(require_element(), 1);
1729 var import_deprecated2 = __toESM(require_deprecated(), 1);
1730 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1731 function withState(initialState = {}) {
1732 (0, import_deprecated2.default)("wp.compose.withState", {
1733 since: "5.8",
1734 alternative: "wp.element.useState"
1735 });
1736 return createHigherOrderComponent((OriginalComponent) => {
1737 return class WrappedComponent extends import_element5.Component {
1738 constructor(props) {
1739 super(props);
1740 this.setState = this.setState.bind(this);
1741 this.state = initialState;
1742 }
1743 render() {
1744 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1745 OriginalComponent,
1746 {
1747 ...this.props,
1748 ...this.state,
1749 setState: this.setState
1750 }
1751 );
1752 }
1753 };
1754 }, "withState");
1755 }
1756
1757 // packages/compose/build-module/hooks/use-constrained-tabbing/index.mjs
1758 var import_dom = __toESM(require_dom(), 1);
1759
1760 // packages/compose/build-module/hooks/use-ref-effect/index.mjs
1761 var import_element6 = __toESM(require_element(), 1);
1762 function useRefEffect(callback, dependencies) {
1763 const cleanupRef = (0, import_element6.useRef)(void 0);
1764 return (0, import_element6.useCallback)((node) => {
1765 if (node) {
1766 cleanupRef.current = callback(node);
1767 } else if (cleanupRef.current) {
1768 cleanupRef.current();
1769 }
1770 }, dependencies);
1771 }
1772
1773 // packages/compose/build-module/hooks/use-constrained-tabbing/index.mjs
1774 function useConstrainedTabbing() {
1775 return useRefEffect((node) => {
1776 function onKeyDown(event) {
1777 const { key, shiftKey, target } = event;
1778 if (key !== "Tab") {
1779 return;
1780 }
1781 const action = shiftKey ? "findPrevious" : "findNext";
1782 const nextElement = import_dom.focus.tabbable[action](
1783 /** @type {HTMLElement} */
1784 target
1785 ) || null;
1786 if (
1787 /** @type {HTMLElement} */
1788 target.contains(nextElement)
1789 ) {
1790 event.preventDefault();
1791 nextElement?.focus();
1792 return;
1793 }
1794 if (node.contains(nextElement)) {
1795 return;
1796 }
1797 const domAction = shiftKey ? "append" : "prepend";
1798 const { ownerDocument } = node;
1799 const trap = ownerDocument.createElement("div");
1800 trap.tabIndex = -1;
1801 node[domAction](trap);
1802 trap.addEventListener("blur", () => node.removeChild(trap));
1803 trap.focus();
1804 }
1805 node.addEventListener("keydown", onKeyDown);
1806 return () => {
1807 node.removeEventListener("keydown", onKeyDown);
1808 };
1809 }, []);
1810 }
1811 var use_constrained_tabbing_default = useConstrainedTabbing;
1812
1813 // packages/compose/build-module/hooks/use-copy-on-click/index.mjs
1814 var import_clipboard = __toESM(require_clipboard(), 1);
1815 var import_element7 = __toESM(require_element(), 1);
1816 var import_deprecated3 = __toESM(require_deprecated(), 1);
1817 function useCopyOnClick(ref, text, timeout = 4e3) {
1818 (0, import_deprecated3.default)("wp.compose.useCopyOnClick", {
1819 since: "5.8",
1820 alternative: "wp.compose.useCopyToClipboard"
1821 });
1822 const clipboardRef = (0, import_element7.useRef)(void 0);
1823 const [hasCopied, setHasCopied] = (0, import_element7.useState)(false);
1824 (0, import_element7.useEffect)(() => {
1825 let timeoutId;
1826 if (!ref.current) {
1827 return;
1828 }
1829 clipboardRef.current = new import_clipboard.default(ref.current, {
1830 text: () => typeof text === "function" ? text() : text
1831 });
1832 clipboardRef.current.on("success", ({ clearSelection, trigger }) => {
1833 clearSelection();
1834 if (trigger) {
1835 trigger.focus();
1836 }
1837 if (timeout) {
1838 setHasCopied(true);
1839 clearTimeout(timeoutId);
1840 timeoutId = setTimeout(() => setHasCopied(false), timeout);
1841 }
1842 });
1843 return () => {
1844 if (clipboardRef.current) {
1845 clipboardRef.current.destroy();
1846 }
1847 clearTimeout(timeoutId);
1848 };
1849 }, [text, timeout, setHasCopied]);
1850 return hasCopied;
1851 }
1852
1853 // packages/compose/build-module/hooks/use-copy-to-clipboard/index.mjs
1854 var import_clipboard2 = __toESM(require_clipboard(), 1);
1855 var import_element8 = __toESM(require_element(), 1);
1856 function useUpdatedRef(value) {
1857 const ref = (0, import_element8.useRef)(value);
1858 (0, import_element8.useLayoutEffect)(() => {
1859 ref.current = value;
1860 }, [value]);
1861 return ref;
1862 }
1863 function useCopyToClipboard(text, onSuccess) {
1864 const textRef = useUpdatedRef(text);
1865 const onSuccessRef = useUpdatedRef(onSuccess);
1866 return useRefEffect((node) => {
1867 const clipboard = new import_clipboard2.default(node, {
1868 text() {
1869 return typeof textRef.current === "function" ? textRef.current() : textRef.current || "";
1870 }
1871 });
1872 clipboard.on("success", ({ clearSelection }) => {
1873 clearSelection();
1874 if (onSuccessRef.current) {
1875 onSuccessRef.current();
1876 }
1877 });
1878 return () => {
1879 clipboard.destroy();
1880 };
1881 }, []);
1882 }
1883
1884 // packages/compose/build-module/hooks/use-dialog/index.mjs
1885 var import_element13 = __toESM(require_element(), 1);
1886 var import_keycodes = __toESM(require_keycodes(), 1);
1887
1888 // packages/compose/build-module/hooks/use-focus-on-mount/index.mjs
1889 var import_dom2 = __toESM(require_dom(), 1);
1890 var import_element9 = __toESM(require_element(), 1);
1891 function useFocusOnMount(focusOnMount = "firstElement") {
1892 const focusOnMountRef = (0, import_element9.useRef)(focusOnMount);
1893 const setFocus = (target) => {
1894 target.focus({
1895 // When focusing newly mounted dialogs,
1896 // the position of the popover is often not right on the first render
1897 // This prevents the layout shifts when focusing the dialogs.
1898 preventScroll: true
1899 });
1900 };
1901 (0, import_element9.useEffect)(() => {
1902 focusOnMountRef.current = focusOnMount;
1903 }, [focusOnMount]);
1904 return useRefEffect((node) => {
1905 if (focusOnMountRef.current === false) {
1906 return;
1907 }
1908 if (node.contains(node.ownerDocument?.activeElement ?? null)) {
1909 return;
1910 }
1911 if (focusOnMountRef.current !== "firstElement" && focusOnMountRef.current !== "firstInputElement") {
1912 setFocus(node);
1913 return;
1914 }
1915 const timerId = setTimeout(() => {
1916 if (focusOnMountRef.current === "firstInputElement") {
1917 const formInput = node.querySelector(
1918 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled])'
1919 );
1920 if (formInput) {
1921 setFocus(formInput);
1922 return;
1923 }
1924 }
1925 const firstTabbable = import_dom2.focus.tabbable.find(node)[0];
1926 if (firstTabbable) {
1927 setFocus(firstTabbable);
1928 }
1929 }, 0);
1930 return () => {
1931 clearTimeout(timerId);
1932 };
1933 }, []);
1934 }
1935
1936 // packages/compose/build-module/hooks/use-focus-return/index.mjs
1937 var import_element10 = __toESM(require_element(), 1);
1938 var origin = null;
1939 function useFocusReturn(onFocusReturn) {
1940 const ref = (0, import_element10.useRef)(null);
1941 const focusedBeforeMount = (0, import_element10.useRef)(null);
1942 const onFocusReturnRef = (0, import_element10.useRef)(onFocusReturn);
1943 (0, import_element10.useEffect)(() => {
1944 onFocusReturnRef.current = onFocusReturn;
1945 }, [onFocusReturn]);
1946 return (0, import_element10.useCallback)((node) => {
1947 if (node) {
1948 ref.current = node;
1949 if (focusedBeforeMount.current) {
1950 return;
1951 }
1952 const activeDocument = node.ownerDocument.activeElement instanceof window.HTMLIFrameElement ? node.ownerDocument.activeElement.contentDocument : node.ownerDocument;
1953 focusedBeforeMount.current = activeDocument?.activeElement ?? null;
1954 } else if (focusedBeforeMount.current) {
1955 const isFocused = ref.current?.contains(
1956 ref.current?.ownerDocument.activeElement
1957 );
1958 if (ref.current?.isConnected && !isFocused) {
1959 origin ??= focusedBeforeMount.current;
1960 return;
1961 }
1962 if (onFocusReturnRef.current) {
1963 onFocusReturnRef.current();
1964 } else {
1965 (!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus();
1966 }
1967 origin = null;
1968 }
1969 }, []);
1970 }
1971 var use_focus_return_default = useFocusReturn;
1972
1973 // packages/compose/build-module/hooks/use-focus-outside/index.mjs
1974 var import_element11 = __toESM(require_element(), 1);
1975 var INPUT_BUTTON_TYPES = ["button", "submit"];
1976 function isFocusNormalizedButton(eventTarget) {
1977 if (!(eventTarget instanceof window.HTMLElement)) {
1978 return false;
1979 }
1980 switch (eventTarget.nodeName) {
1981 case "A":
1982 case "BUTTON":
1983 return true;
1984 case "INPUT":
1985 return INPUT_BUTTON_TYPES.includes(
1986 eventTarget.type
1987 );
1988 }
1989 return false;
1990 }
1991 function useFocusOutside(onFocusOutside) {
1992 const currentOnFocusOutsideRef = (0, import_element11.useRef)(onFocusOutside);
1993 (0, import_element11.useEffect)(() => {
1994 currentOnFocusOutsideRef.current = onFocusOutside;
1995 }, [onFocusOutside]);
1996 const preventBlurCheckRef = (0, import_element11.useRef)(false);
1997 const blurCheckTimeoutIdRef = (0, import_element11.useRef)(void 0);
1998 const cancelBlurCheck = (0, import_element11.useCallback)(() => {
1999 clearTimeout(blurCheckTimeoutIdRef.current);
2000 }, []);
2001 (0, import_element11.useEffect)(() => {
2002 if (!onFocusOutside) {
2003 cancelBlurCheck();
2004 }
2005 }, [onFocusOutside, cancelBlurCheck]);
2006 const normalizeButtonFocus = (0, import_element11.useCallback)((event) => {
2007 const { type, target } = event;
2008 const isInteractionEnd = ["mouseup", "touchend"].includes(type);
2009 if (isInteractionEnd) {
2010 preventBlurCheckRef.current = false;
2011 } else if (isFocusNormalizedButton(target)) {
2012 preventBlurCheckRef.current = true;
2013 }
2014 }, []);
2015 const queueBlurCheck = (0, import_element11.useCallback)((event) => {
2016 event.persist();
2017 if (preventBlurCheckRef.current) {
2018 return;
2019 }
2020 const ignoreForRelatedTarget = event.target.getAttribute(
2021 "data-unstable-ignore-focus-outside-for-relatedtarget"
2022 );
2023 if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) {
2024 return;
2025 }
2026 blurCheckTimeoutIdRef.current = setTimeout(() => {
2027 if (!document.hasFocus()) {
2028 event.preventDefault();
2029 return;
2030 }
2031 if ("function" === typeof currentOnFocusOutsideRef.current) {
2032 currentOnFocusOutsideRef.current(event);
2033 }
2034 }, 0);
2035 }, []);
2036 return {
2037 onFocus: cancelBlurCheck,
2038 onMouseDown: normalizeButtonFocus,
2039 onMouseUp: normalizeButtonFocus,
2040 onTouchStart: normalizeButtonFocus,
2041 onTouchEnd: normalizeButtonFocus,
2042 onBlur: queueBlurCheck
2043 };
2044 }
2045
2046 // packages/compose/build-module/hooks/use-merge-refs/index.mjs
2047 var import_element12 = __toESM(require_element(), 1);
2048 function assignRef(ref, value) {
2049 if (typeof ref === "function") {
2050 ref(value);
2051 } else if (ref && ref.hasOwnProperty("current")) {
2052 ref.current = value;
2053 }
2054 }
2055 function useMergeRefs(refs) {
2056 const element = (0, import_element12.useRef)(null);
2057 const isAttachedRef = (0, import_element12.useRef)(false);
2058 const didElementChangeRef = (0, import_element12.useRef)(false);
2059 const previousRefsRef = (0, import_element12.useRef)([]);
2060 const currentRefsRef = (0, import_element12.useRef)(refs);
2061 currentRefsRef.current = refs;
2062 (0, import_element12.useLayoutEffect)(() => {
2063 if (didElementChangeRef.current === false && isAttachedRef.current === true) {
2064 refs.forEach((ref, index) => {
2065 const previousRef = previousRefsRef.current[index];
2066 if (ref !== previousRef) {
2067 assignRef(previousRef, null);
2068 assignRef(ref, element.current);
2069 }
2070 });
2071 }
2072 previousRefsRef.current = refs;
2073 }, refs);
2074 (0, import_element12.useLayoutEffect)(() => {
2075 didElementChangeRef.current = false;
2076 });
2077 return (0, import_element12.useCallback)((value) => {
2078 assignRef(element, value);
2079 didElementChangeRef.current = true;
2080 isAttachedRef.current = value !== null;
2081 const refsToAssign = value ? currentRefsRef.current : previousRefsRef.current;
2082 for (const ref of refsToAssign) {
2083 assignRef(ref, value);
2084 }
2085 }, []);
2086 }
2087
2088 // packages/compose/build-module/hooks/use-dialog/index.mjs
2089 function useDialog(options) {
2090 const currentOptions = (0, import_element13.useRef)(void 0);
2091 const { constrainTabbing = options.focusOnMount !== false } = options;
2092 (0, import_element13.useEffect)(() => {
2093 currentOptions.current = options;
2094 }, Object.values(options));
2095 const constrainedTabbingRef = use_constrained_tabbing_default();
2096 const focusOnMountRef = useFocusOnMount(options.focusOnMount);
2097 const focusReturnRef = use_focus_return_default();
2098 const focusOutsideProps = useFocusOutside((event) => {
2099 if (currentOptions.current?.__unstableOnClose) {
2100 currentOptions.current.__unstableOnClose("focus-outside", event);
2101 } else if (currentOptions.current?.onClose) {
2102 currentOptions.current.onClose();
2103 }
2104 });
2105 const closeOnEscapeRef = (0, import_element13.useCallback)((node) => {
2106 if (!node) {
2107 return;
2108 }
2109 node.addEventListener("keydown", (event) => {
2110 if (event.keyCode === import_keycodes.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) {
2111 event.preventDefault();
2112 currentOptions.current.onClose();
2113 }
2114 });
2115 }, []);
2116 return [
2117 useMergeRefs([
2118 constrainTabbing ? constrainedTabbingRef : null,
2119 options.focusOnMount !== false ? focusReturnRef : null,
2120 options.focusOnMount !== false ? focusOnMountRef : null,
2121 closeOnEscapeRef
2122 ]),
2123 {
2124 ...focusOutsideProps,
2125 tabIndex: -1
2126 }
2127 ];
2128 }
2129 var use_dialog_default = useDialog;
2130
2131 // packages/compose/build-module/hooks/use-disabled/index.mjs
2132 function useDisabled({
2133 isDisabled: isDisabledProp = false
2134 } = {}) {
2135 return useRefEffect(
2136 (node) => {
2137 if (isDisabledProp) {
2138 return;
2139 }
2140 const defaultView = node?.ownerDocument?.defaultView;
2141 if (!defaultView) {
2142 return;
2143 }
2144 const updates = [];
2145 const disable = () => {
2146 node.childNodes.forEach((child) => {
2147 if (!(child instanceof defaultView.HTMLElement)) {
2148 return;
2149 }
2150 if (!child.getAttribute("inert")) {
2151 child.setAttribute("inert", "true");
2152 updates.push(() => {
2153 child.removeAttribute("inert");
2154 });
2155 }
2156 });
2157 };
2158 const debouncedDisable = debounce(disable, 0, {
2159 leading: true
2160 });
2161 disable();
2162 const observer = new window.MutationObserver(debouncedDisable);
2163 observer.observe(node, {
2164 childList: true
2165 });
2166 return () => {
2167 if (observer) {
2168 observer.disconnect();
2169 }
2170 debouncedDisable.cancel();
2171 updates.forEach((update) => update());
2172 };
2173 },
2174 [isDisabledProp]
2175 );
2176 }
2177
2178 // packages/compose/build-module/hooks/use-event/index.mjs
2179 var import_element14 = __toESM(require_element(), 1);
2180 function useEvent(callback) {
2181 const ref = (0, import_element14.useRef)(() => {
2182 throw new Error(
2183 "Callbacks created with `useEvent` cannot be called during rendering."
2184 );
2185 });
2186 (0, import_element14.useInsertionEffect)(() => {
2187 ref.current = callback;
2188 });
2189 return (0, import_element14.useCallback)(
2190 (...args) => ref.current?.(...args),
2191 []
2192 );
2193 }
2194
2195 // packages/compose/build-module/hooks/use-dragging/index.mjs
2196 var import_element16 = __toESM(require_element(), 1);
2197
2198 // packages/compose/build-module/hooks/use-isomorphic-layout-effect/index.mjs
2199 var import_element15 = __toESM(require_element(), 1);
2200 var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_element15.useLayoutEffect : import_element15.useEffect;
2201 var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect;
2202
2203 // packages/compose/build-module/hooks/use-dragging/index.mjs
2204 function useDragging({ onDragStart, onDragMove, onDragEnd }) {
2205 const [isDragging, setIsDragging] = (0, import_element16.useState)(false);
2206 const eventsRef = (0, import_element16.useRef)({
2207 onDragStart,
2208 onDragMove,
2209 onDragEnd
2210 });
2211 use_isomorphic_layout_effect_default(() => {
2212 eventsRef.current.onDragStart = onDragStart;
2213 eventsRef.current.onDragMove = onDragMove;
2214 eventsRef.current.onDragEnd = onDragEnd;
2215 }, [onDragStart, onDragMove, onDragEnd]);
2216 const onMouseMove = (0, import_element16.useCallback)(
2217 (event) => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event),
2218 []
2219 );
2220 const endDrag = (0, import_element16.useCallback)((event) => {
2221 if (eventsRef.current.onDragEnd) {
2222 eventsRef.current.onDragEnd(event);
2223 }
2224 document.removeEventListener("mousemove", onMouseMove);
2225 document.removeEventListener("mouseup", endDrag);
2226 setIsDragging(false);
2227 }, []);
2228 const startDrag = (0, import_element16.useCallback)((event) => {
2229 if (eventsRef.current.onDragStart) {
2230 eventsRef.current.onDragStart(event);
2231 }
2232 document.addEventListener("mousemove", onMouseMove);
2233 document.addEventListener("mouseup", endDrag);
2234 setIsDragging(true);
2235 }, []);
2236 (0, import_element16.useEffect)(() => {
2237 return () => {
2238 if (isDragging) {
2239 document.removeEventListener("mousemove", onMouseMove);
2240 document.removeEventListener("mouseup", endDrag);
2241 }
2242 };
2243 }, [isDragging]);
2244 return {
2245 startDrag,
2246 endDrag,
2247 isDragging
2248 };
2249 }
2250
2251 // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs
2252 var import_mousetrap = __toESM(require_mousetrap(), 1);
2253
2254 // node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
2255 (function(Mousetrap3) {
2256 if (!Mousetrap3) {
2257 return;
2258 }
2259 var _globalCallbacks = {};
2260 var _originalStopCallback = Mousetrap3.prototype.stopCallback;
2261 Mousetrap3.prototype.stopCallback = function(e, element, combo, sequence) {
2262 var self = this;
2263 if (self.paused) {
2264 return true;
2265 }
2266 if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
2267 return false;
2268 }
2269 return _originalStopCallback.call(self, e, element, combo);
2270 };
2271 Mousetrap3.prototype.bindGlobal = function(keys, callback, action) {
2272 var self = this;
2273 self.bind(keys, callback, action);
2274 if (keys instanceof Array) {
2275 for (var i = 0; i < keys.length; i++) {
2276 _globalCallbacks[keys[i]] = true;
2277 }
2278 return;
2279 }
2280 _globalCallbacks[keys] = true;
2281 };
2282 Mousetrap3.init();
2283 })(typeof Mousetrap !== "undefined" ? Mousetrap : void 0);
2284
2285 // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs
2286 var import_element17 = __toESM(require_element(), 1);
2287 var import_keycodes2 = __toESM(require_keycodes(), 1);
2288 function useKeyboardShortcut(shortcuts, callback, {
2289 bindGlobal = false,
2290 eventName = "keydown",
2291 isDisabled = false,
2292 // This is important for performance considerations.
2293 target
2294 } = {}) {
2295 const currentCallbackRef = (0, import_element17.useRef)(callback);
2296 (0, import_element17.useEffect)(() => {
2297 currentCallbackRef.current = callback;
2298 }, [callback]);
2299 (0, import_element17.useEffect)(() => {
2300 if (isDisabled) {
2301 return;
2302 }
2303 const mousetrap = new import_mousetrap.default(
2304 target && target.current ? target.current : (
2305 // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
2306 // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's
2307 // necessary to maintain the existing behavior.
2308 /** @type {Element} */
2309 /** @type {unknown} */
2310 document
2311 )
2312 );
2313 const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts];
2314 shortcutsArray.forEach((shortcut) => {
2315 const keys = shortcut.split("+");
2316 const modifiers = new Set(
2317 keys.filter((value) => value.length > 1)
2318 );
2319 const hasAlt = modifiers.has("alt");
2320 const hasShift = modifiers.has("shift");
2321 if ((0, import_keycodes2.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
2322 throw new Error(
2323 `Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`
2324 );
2325 }
2326 const bindFn = bindGlobal ? "bindGlobal" : "bind";
2327 mousetrap[bindFn](
2328 shortcut,
2329 (...args) => currentCallbackRef.current(...args),
2330 eventName
2331 );
2332 });
2333 return () => {
2334 mousetrap.reset();
2335 };
2336 }, [shortcuts, bindGlobal, eventName, target, isDisabled]);
2337 }
2338 var use_keyboard_shortcut_default = useKeyboardShortcut;
2339
2340 // packages/compose/build-module/hooks/use-media-query/index.mjs
2341 var import_element18 = __toESM(require_element(), 1);
2342 var matchMediaCache = /* @__PURE__ */ new Map();
2343 function getMediaQueryList(query) {
2344 if (!query) {
2345 return null;
2346 }
2347 let match = matchMediaCache.get(query);
2348 if (match) {
2349 return match;
2350 }
2351 if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
2352 match = window.matchMedia(query);
2353 matchMediaCache.set(query, match);
2354 return match;
2355 }
2356 return null;
2357 }
2358 function useMediaQuery(query) {
2359 const source = (0, import_element18.useMemo)(() => {
2360 const mediaQueryList = getMediaQueryList(query);
2361 return {
2362 /** @type {(onStoreChange: () => void) => () => void} */
2363 subscribe(onStoreChange) {
2364 if (!mediaQueryList) {
2365 return () => {
2366 };
2367 }
2368 mediaQueryList.addEventListener?.("change", onStoreChange);
2369 return () => {
2370 mediaQueryList.removeEventListener?.(
2371 "change",
2372 onStoreChange
2373 );
2374 };
2375 },
2376 getValue() {
2377 return mediaQueryList?.matches ?? false;
2378 }
2379 };
2380 }, [query]);
2381 return (0, import_element18.useSyncExternalStore)(
2382 source.subscribe,
2383 source.getValue,
2384 () => false
2385 );
2386 }
2387
2388 // packages/compose/build-module/hooks/use-previous/index.mjs
2389 var import_element19 = __toESM(require_element(), 1);
2390 function usePrevious(value) {
2391 const ref = (0, import_element19.useRef)(void 0);
2392 (0, import_element19.useEffect)(() => {
2393 ref.current = value;
2394 }, [value]);
2395 return ref.current;
2396 }
2397
2398 // packages/compose/build-module/hooks/use-reduced-motion/index.mjs
2399 var useReducedMotion = () => useMediaQuery("(prefers-reduced-motion: reduce)");
2400 var use_reduced_motion_default = useReducedMotion;
2401
2402 // packages/compose/build-module/hooks/use-state-with-history/index.mjs
2403 var import_undo_manager = __toESM(require_undo_manager(), 1);
2404 var import_element20 = __toESM(require_element(), 1);
2405 function undoRedoReducer(state, action) {
2406 switch (action.type) {
2407 case "UNDO": {
2408 const undoRecord = state.manager.undo();
2409 if (undoRecord) {
2410 return {
2411 ...state,
2412 value: undoRecord[0].changes.prop.from
2413 };
2414 }
2415 return state;
2416 }
2417 case "REDO": {
2418 const redoRecord = state.manager.redo();
2419 if (redoRecord) {
2420 return {
2421 ...state,
2422 value: redoRecord[0].changes.prop.to
2423 };
2424 }
2425 return state;
2426 }
2427 case "RECORD": {
2428 state.manager.addRecord(
2429 [
2430 {
2431 id: "object",
2432 changes: {
2433 prop: { from: state.value, to: action.value }
2434 }
2435 }
2436 ],
2437 action.isStaged
2438 );
2439 return {
2440 ...state,
2441 value: action.value
2442 };
2443 }
2444 }
2445 return state;
2446 }
2447 function initReducer(value) {
2448 return {
2449 manager: (0, import_undo_manager.createUndoManager)(),
2450 value
2451 };
2452 }
2453 function useStateWithHistory(initialValue) {
2454 const [state, dispatch] = (0, import_element20.useReducer)(
2455 undoRedoReducer,
2456 initialValue,
2457 initReducer
2458 );
2459 return {
2460 value: state.value,
2461 setValue: (0, import_element20.useCallback)((newValue, isStaged) => {
2462 dispatch({
2463 type: "RECORD",
2464 value: newValue,
2465 isStaged
2466 });
2467 }, []),
2468 hasUndo: state.manager.hasUndo(),
2469 hasRedo: state.manager.hasRedo(),
2470 undo: (0, import_element20.useCallback)(() => {
2471 dispatch({ type: "UNDO" });
2472 }, []),
2473 redo: (0, import_element20.useCallback)(() => {
2474 dispatch({ type: "REDO" });
2475 }, [])
2476 };
2477 }
2478
2479 // packages/compose/build-module/hooks/use-viewport-match/index.mjs
2480 var import_element21 = __toESM(require_element(), 1);
2481 var BREAKPOINTS = {
2482 xhuge: 1920,
2483 huge: 1440,
2484 wide: 1280,
2485 xlarge: 1080,
2486 large: 960,
2487 medium: 782,
2488 small: 600,
2489 mobile: 480
2490 };
2491 var CONDITIONS = {
2492 ">=": "min-width",
2493 "<": "max-width"
2494 };
2495 var OPERATOR_EVALUATORS = {
2496 ">=": (breakpointValue, width) => width >= breakpointValue,
2497 "<": (breakpointValue, width) => width < breakpointValue
2498 };
2499 var ViewportMatchWidthContext = (0, import_element21.createContext)(
2500 /** @type {null | number} */
2501 null
2502 );
2503 ViewportMatchWidthContext.displayName = "ViewportMatchWidthContext";
2504 var useViewportMatch = (breakpoint, operator = ">=") => {
2505 const simulatedWidth = (0, import_element21.useContext)(ViewportMatchWidthContext);
2506 const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
2507 const mediaQueryResult = useMediaQuery(mediaQuery || void 0);
2508 if (simulatedWidth) {
2509 return OPERATOR_EVALUATORS[operator](
2510 BREAKPOINTS[breakpoint],
2511 simulatedWidth
2512 );
2513 }
2514 return mediaQueryResult;
2515 };
2516 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
2517 var use_viewport_match_default = useViewportMatch;
2518
2519 // packages/compose/build-module/hooks/use-resize-observer/use-resize-observer.mjs
2520 var import_element22 = __toESM(require_element(), 1);
2521 function useResizeObserver(callback, resizeObserverOptions = {}) {
2522 const callbackEvent = useEvent(callback);
2523 const observedElementRef = (0, import_element22.useRef)(null);
2524 const resizeObserverRef = (0, import_element22.useRef)(void 0);
2525 return useEvent((element) => {
2526 if (element === observedElementRef.current) {
2527 return;
2528 }
2529 resizeObserverRef.current ??= new ResizeObserver(callbackEvent);
2530 const { current: resizeObserver } = resizeObserverRef;
2531 if (observedElementRef.current) {
2532 resizeObserver.unobserve(observedElementRef.current);
2533 }
2534 observedElementRef.current = element ?? null;
2535 if (element) {
2536 resizeObserver.observe(element, resizeObserverOptions);
2537 }
2538 });
2539 }
2540
2541 // packages/compose/build-module/hooks/use-resize-observer/legacy/index.mjs
2542 var import_element23 = __toESM(require_element(), 1);
2543 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
2544 var extractSize = (entry) => {
2545 let entrySize;
2546 if (!entry.contentBoxSize) {
2547 entrySize = [entry.contentRect.width, entry.contentRect.height];
2548 } else if (entry.contentBoxSize[0]) {
2549 const contentBoxSize = entry.contentBoxSize[0];
2550 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
2551 } else {
2552 const contentBoxSize = entry.contentBoxSize;
2553 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
2554 }
2555 const [width, height] = entrySize.map((d) => Math.round(d));
2556 return { width, height };
2557 };
2558 var RESIZE_ELEMENT_STYLES = {
2559 position: "absolute",
2560 top: 0,
2561 left: 0,
2562 right: 0,
2563 bottom: 0,
2564 pointerEvents: "none",
2565 opacity: 0,
2566 overflow: "hidden",
2567 zIndex: -1
2568 };
2569 function ResizeElement({ onResize }) {
2570 const resizeElementRef = useResizeObserver((entries) => {
2571 const newSize = extractSize(entries.at(-1));
2572 onResize(newSize);
2573 });
2574 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2575 "div",
2576 {
2577 ref: resizeElementRef,
2578 style: RESIZE_ELEMENT_STYLES,
2579 "aria-hidden": "true"
2580 }
2581 );
2582 }
2583 function sizeEquals(a, b) {
2584 return a.width === b.width && a.height === b.height;
2585 }
2586 var NULL_SIZE = { width: null, height: null };
2587 function useLegacyResizeObserver() {
2588 const [size, setSize] = (0, import_element23.useState)(NULL_SIZE);
2589 const previousSizeRef = (0, import_element23.useRef)(NULL_SIZE);
2590 const handleResize = (0, import_element23.useCallback)((newSize) => {
2591 if (!sizeEquals(previousSizeRef.current, newSize)) {
2592 previousSizeRef.current = newSize;
2593 setSize(newSize);
2594 }
2595 }, []);
2596 const resizeElement = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ResizeElement, { onResize: handleResize });
2597 return [resizeElement, size];
2598 }
2599
2600 // packages/compose/build-module/hooks/use-resize-observer/index.mjs
2601 function useResizeObserver2(callback, options = {}) {
2602 return callback ? useResizeObserver(callback, options) : useLegacyResizeObserver();
2603 }
2604
2605 // packages/compose/build-module/hooks/use-async-list/index.mjs
2606 var import_element24 = __toESM(require_element(), 1);
2607 var import_priority_queue = __toESM(require_priority_queue(), 1);
2608 function getFirstItemsPresentInState(list, state) {
2609 const firstItems = [];
2610 for (let i = 0; i < list.length; i++) {
2611 const item = list[i];
2612 if (!state.includes(item)) {
2613 break;
2614 }
2615 firstItems.push(item);
2616 }
2617 return firstItems;
2618 }
2619 function useAsyncList(list, config = { step: 1 }) {
2620 const { step = 1 } = config;
2621 const [current, setCurrent] = (0, import_element24.useState)([]);
2622 (0, import_element24.useEffect)(() => {
2623 let firstItems = getFirstItemsPresentInState(list, current);
2624 if (firstItems.length < step) {
2625 firstItems = firstItems.concat(
2626 list.slice(firstItems.length, step)
2627 );
2628 }
2629 setCurrent(firstItems);
2630 const asyncQueue = (0, import_priority_queue.createQueue)();
2631 for (let i = firstItems.length; i < list.length; i += step) {
2632 asyncQueue.add({}, () => {
2633 (0, import_element24.flushSync)(() => {
2634 setCurrent((state) => [
2635 ...state,
2636 ...list.slice(i, i + step)
2637 ]);
2638 });
2639 });
2640 }
2641 return () => asyncQueue.reset();
2642 }, [list]);
2643 return current;
2644 }
2645 var use_async_list_default = useAsyncList;
2646
2647 // packages/compose/build-module/hooks/use-warn-on-change/index.mjs
2648 function useWarnOnChange(object, prefix = "Change detection") {
2649 const previousValues = usePrevious(object);
2650 Object.entries(previousValues ?? []).forEach(([key, value]) => {
2651 if (value !== object[
2652 /** @type {keyof typeof object} */
2653 key
2654 ]) {
2655 console.warn(
2656 `${prefix}: ${key} key changed:`,
2657 value,
2658 object[
2659 /** @type {keyof typeof object} */
2660 key
2661 ]
2662 /* eslint-enable jsdoc/check-types */
2663 );
2664 }
2665 });
2666 }
2667 var use_warn_on_change_default = useWarnOnChange;
2668
2669 // node_modules/use-memo-one/dist/use-memo-one.esm.js
2670 var import_react = __toESM(require_react());
2671 function areInputsEqual(newInputs, lastInputs) {
2672 if (newInputs.length !== lastInputs.length) {
2673 return false;
2674 }
2675 for (var i = 0; i < newInputs.length; i++) {
2676 if (newInputs[i] !== lastInputs[i]) {
2677 return false;
2678 }
2679 }
2680 return true;
2681 }
2682 function useMemoOne(getResult, inputs) {
2683 var initial = (0, import_react.useState)(function() {
2684 return {
2685 inputs,
2686 result: getResult()
2687 };
2688 })[0];
2689 var committed = (0, import_react.useRef)(initial);
2690 var isInputMatch = Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
2691 var cache = isInputMatch ? committed.current : {
2692 inputs,
2693 result: getResult()
2694 };
2695 (0, import_react.useEffect)(function() {
2696 committed.current = cache;
2697 }, [cache]);
2698 return cache.result;
2699 }
2700
2701 // packages/compose/build-module/hooks/use-debounce/index.mjs
2702 var import_element25 = __toESM(require_element(), 1);
2703 function useDebounce(fn, wait, options) {
2704 const debounced = useMemoOne(
2705 () => debounce(fn, wait ?? 0, options),
2706 [fn, wait, options?.leading, options?.trailing, options?.maxWait]
2707 );
2708 (0, import_element25.useEffect)(() => () => debounced.cancel(), [debounced]);
2709 return debounced;
2710 }
2711
2712 // packages/compose/build-module/hooks/use-debounced-input/index.mjs
2713 var import_element26 = __toESM(require_element(), 1);
2714 function useDebouncedInput(defaultValue = "") {
2715 const [input, setInput] = (0, import_element26.useState)(defaultValue);
2716 const [debouncedInput, setDebouncedState] = (0, import_element26.useState)(defaultValue);
2717 const setDebouncedInput = useDebounce(setDebouncedState, 250);
2718 (0, import_element26.useEffect)(() => {
2719 setDebouncedInput(input);
2720 }, [input, setDebouncedInput]);
2721 return [input, setInput, debouncedInput];
2722 }
2723
2724 // packages/compose/build-module/hooks/use-throttle/index.mjs
2725 var import_element27 = __toESM(require_element(), 1);
2726 function useThrottle(fn, wait, options) {
2727 const throttled = useMemoOne(
2728 () => throttle(fn, wait ?? 0, options),
2729 [fn, wait, options]
2730 );
2731 (0, import_element27.useEffect)(() => () => throttled.cancel(), [throttled]);
2732 return throttled;
2733 }
2734
2735 // packages/compose/build-module/hooks/use-drop-zone/index.mjs
2736 function useDropZone({
2737 dropZoneElement,
2738 isDisabled,
2739 onDrop: _onDrop,
2740 onDragStart: _onDragStart,
2741 onDragEnter: _onDragEnter,
2742 onDragLeave: _onDragLeave,
2743 onDragEnd: _onDragEnd,
2744 onDragOver: _onDragOver
2745 }) {
2746 const onDropEvent = useEvent(_onDrop);
2747 const onDragStartEvent = useEvent(_onDragStart);
2748 const onDragEnterEvent = useEvent(_onDragEnter);
2749 const onDragLeaveEvent = useEvent(_onDragLeave);
2750 const onDragEndEvent = useEvent(_onDragEnd);
2751 const onDragOverEvent = useEvent(_onDragOver);
2752 return useRefEffect(
2753 (elem) => {
2754 if (isDisabled) {
2755 return;
2756 }
2757 const element = dropZoneElement ?? elem;
2758 let isDragging = false;
2759 const { ownerDocument } = element;
2760 function isElementInZone(targetToCheck) {
2761 const { defaultView } = ownerDocument;
2762 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) {
2763 return false;
2764 }
2765 let elementToCheck = targetToCheck;
2766 do {
2767 if (elementToCheck.dataset.isDropZone) {
2768 return elementToCheck === element;
2769 }
2770 } while (elementToCheck = elementToCheck.parentElement);
2771 return false;
2772 }
2773 function maybeDragStart(event) {
2774 if (isDragging) {
2775 return;
2776 }
2777 isDragging = true;
2778 ownerDocument.addEventListener("dragend", maybeDragEnd);
2779 ownerDocument.addEventListener("mousemove", maybeDragEnd);
2780 if (_onDragStart) {
2781 onDragStartEvent(event);
2782 }
2783 }
2784 function onDragEnter(event) {
2785 event.preventDefault();
2786 if (element.contains(
2787 /** @type {Node} */
2788 event.relatedTarget
2789 )) {
2790 return;
2791 }
2792 if (_onDragEnter) {
2793 onDragEnterEvent(event);
2794 }
2795 }
2796 function onDragOver(event) {
2797 if (!event.defaultPrevented && _onDragOver) {
2798 onDragOverEvent(event);
2799 }
2800 event.preventDefault();
2801 }
2802 function onDragLeave(event) {
2803 if (isElementInZone(event.relatedTarget)) {
2804 return;
2805 }
2806 if (_onDragLeave) {
2807 onDragLeaveEvent(event);
2808 }
2809 }
2810 function onDrop(event) {
2811 if (event.defaultPrevented) {
2812 return;
2813 }
2814 event.preventDefault();
2815 event.dataTransfer && event.dataTransfer.files.length;
2816 if (_onDrop) {
2817 onDropEvent(event);
2818 }
2819 maybeDragEnd(event);
2820 }
2821 function maybeDragEnd(event) {
2822 if (!isDragging) {
2823 return;
2824 }
2825 isDragging = false;
2826 ownerDocument.removeEventListener("dragend", maybeDragEnd);
2827 ownerDocument.removeEventListener("mousemove", maybeDragEnd);
2828 if (_onDragEnd) {
2829 onDragEndEvent(event);
2830 }
2831 }
2832 element.setAttribute("data-is-drop-zone", "true");
2833 element.addEventListener("drop", onDrop);
2834 element.addEventListener("dragenter", onDragEnter);
2835 element.addEventListener("dragover", onDragOver);
2836 element.addEventListener("dragleave", onDragLeave);
2837 ownerDocument.addEventListener("dragenter", maybeDragStart);
2838 return () => {
2839 element.removeAttribute("data-is-drop-zone");
2840 element.removeEventListener("drop", onDrop);
2841 element.removeEventListener("dragenter", onDragEnter);
2842 element.removeEventListener("dragover", onDragOver);
2843 element.removeEventListener("dragleave", onDragLeave);
2844 ownerDocument.removeEventListener("dragend", maybeDragEnd);
2845 ownerDocument.removeEventListener("mousemove", maybeDragEnd);
2846 ownerDocument.removeEventListener(
2847 "dragenter",
2848 maybeDragStart
2849 );
2850 };
2851 },
2852 [isDisabled, dropZoneElement]
2853 // Refresh when the passed in dropZoneElement changes.
2854 );
2855 }
2856
2857 // packages/compose/build-module/hooks/use-focusable-iframe/index.mjs
2858 function useFocusableIframe() {
2859 return useRefEffect((element) => {
2860 const { ownerDocument } = element;
2861 if (!ownerDocument) {
2862 return;
2863 }
2864 const { defaultView } = ownerDocument;
2865 if (!defaultView) {
2866 return;
2867 }
2868 function checkFocus() {
2869 if (ownerDocument && ownerDocument.activeElement === element) {
2870 element.focus();
2871 }
2872 }
2873 defaultView.addEventListener("blur", checkFocus);
2874 return () => {
2875 defaultView.removeEventListener("blur", checkFocus);
2876 };
2877 }, []);
2878 }
2879
2880 // packages/compose/build-module/hooks/use-fixed-window-list/index.mjs
2881 var import_element28 = __toESM(require_element(), 1);
2882 var import_dom3 = __toESM(require_dom(), 1);
2883 var import_keycodes3 = __toESM(require_keycodes(), 1);
2884 var DEFAULT_INIT_WINDOW_SIZE = 30;
2885 function useFixedWindowList(elementRef, itemHeight, totalItems, options) {
2886 const initWindowSize = options?.initWindowSize ?? DEFAULT_INIT_WINDOW_SIZE;
2887 const useWindowing = options?.useWindowing ?? true;
2888 const [fixedListWindow, setFixedListWindow] = (0, import_element28.useState)({
2889 visibleItems: initWindowSize,
2890 start: 0,
2891 end: initWindowSize,
2892 itemInView: (index) => {
2893 return index >= 0 && index <= initWindowSize;
2894 }
2895 });
2896 (0, import_element28.useLayoutEffect)(() => {
2897 if (!useWindowing) {
2898 return;
2899 }
2900 const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current);
2901 const measureWindow = (initRender) => {
2902 if (!scrollContainer) {
2903 return;
2904 }
2905 const visibleItems = Math.ceil(
2906 scrollContainer.clientHeight / itemHeight
2907 );
2908 const windowOverscan = initRender ? visibleItems : options?.windowOverscan ?? visibleItems;
2909 const firstViewableIndex = Math.floor(
2910 scrollContainer.scrollTop / itemHeight
2911 );
2912 const start = Math.max(0, firstViewableIndex - windowOverscan);
2913 const end = Math.min(
2914 totalItems - 1,
2915 firstViewableIndex + visibleItems + windowOverscan
2916 );
2917 setFixedListWindow((lastWindow) => {
2918 const nextWindow = {
2919 visibleItems,
2920 start,
2921 end,
2922 itemInView: (index) => {
2923 return start <= index && index <= end;
2924 }
2925 };
2926 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) {
2927 return nextWindow;
2928 }
2929 return lastWindow;
2930 });
2931 };
2932 measureWindow(true);
2933 const debounceMeasureList = debounce(() => {
2934 measureWindow();
2935 }, 16);
2936 scrollContainer?.addEventListener("scroll", debounceMeasureList);
2937 scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2938 "resize",
2939 debounceMeasureList
2940 );
2941 scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2942 "resize",
2943 debounceMeasureList
2944 );
2945 return () => {
2946 scrollContainer?.removeEventListener(
2947 "scroll",
2948 debounceMeasureList
2949 );
2950 scrollContainer?.ownerDocument?.defaultView?.removeEventListener(
2951 "resize",
2952 debounceMeasureList
2953 );
2954 };
2955 }, [
2956 itemHeight,
2957 elementRef,
2958 totalItems,
2959 options?.expandedState,
2960 options?.windowOverscan,
2961 useWindowing
2962 ]);
2963 (0, import_element28.useLayoutEffect)(() => {
2964 if (!useWindowing) {
2965 return;
2966 }
2967 const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current);
2968 const handleKeyDown = (event) => {
2969 switch (event.keyCode) {
2970 case import_keycodes3.HOME: {
2971 return scrollContainer?.scrollTo({ top: 0 });
2972 }
2973 case import_keycodes3.END: {
2974 return scrollContainer?.scrollTo({
2975 top: totalItems * itemHeight
2976 });
2977 }
2978 case import_keycodes3.PAGEUP: {
2979 return scrollContainer?.scrollTo({
2980 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight
2981 });
2982 }
2983 case import_keycodes3.PAGEDOWN: {
2984 return scrollContainer?.scrollTo({
2985 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight
2986 });
2987 }
2988 }
2989 };
2990 scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2991 "keydown",
2992 handleKeyDown
2993 );
2994 return () => {
2995 scrollContainer?.ownerDocument?.defaultView?.removeEventListener(
2996 "keydown",
2997 handleKeyDown
2998 );
2999 };
3000 }, [
3001 totalItems,
3002 itemHeight,
3003 elementRef,
3004 fixedListWindow.visibleItems,
3005 useWindowing,
3006 options?.expandedState
3007 ]);
3008 return [fixedListWindow, setFixedListWindow];
3009 }
3010
3011 // packages/compose/build-module/hooks/use-observable-value/index.mjs
3012 var import_element29 = __toESM(require_element(), 1);
3013 function useObservableValue(map, name) {
3014 const [subscribe, getValue] = (0, import_element29.useMemo)(
3015 () => [
3016 (listener2) => map.subscribe(name, listener2),
3017 () => map.get(name)
3018 ],
3019 [map, name]
3020 );
3021 return (0, import_element29.useSyncExternalStore)(subscribe, getValue, getValue);
3022 }
3023 return __toCommonJS(index_exports);
3024 })();
3025 /*! Bundled license information:
3026
3027 clipboard/dist/clipboard.js:
3028 (*!
3029 * clipboard.js v2.0.11
3030 * https://clipboardjs.com/
3031 *
3032 * Licensed MIT © Zeno Rocha
3033 *)
3034 */
3035 //# sourceMappingURL=index.js.map
3036