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