[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> compose.js (source)

   1  "use strict";
   2  var wp;
   3  (wp ||= {}).compose = (() => {
   4    var __create = Object.create;
   5    var __defProp = Object.defineProperty;
   6    var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
   7    var __getOwnPropNames = Object.getOwnPropertyNames;
   8    var __getProtoOf = Object.getPrototypeOf;
   9    var __hasOwnProp = Object.prototype.hasOwnProperty;
  10    var __commonJS = (cb, mod) => function __require() {
  11      return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  12    };
  13    var __export = (target, all) => {
  14      for (var name in all)
  15        __defProp(target, name, { get: all[name], enumerable: true });
  16    };
  17    var __copyProps = (to, from, except, desc) => {
  18      if (from && typeof from === "object" || typeof from === "function") {
  19        for (let key of __getOwnPropNames(from))
  20          if (!__hasOwnProp.call(to, key) && key !== except)
  21            __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  22      }
  23      return to;
  24    };
  25    var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  26      // If the importer is in node compatibility mode or this is not an ESM
  27      // file that has been converted to a CommonJS file using a Babel-
  28      // compatible transform (i.e. "__esModule" has not been set), then set
  29      // "default" to the CommonJS "module.exports" for node compatibility.
  30      isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  31      mod
  32    ));
  33    var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  34  
  35    // vendor-external:react/jsx-runtime
  36    var require_jsx_runtime = __commonJS({
  37      "vendor-external:react/jsx-runtime"(exports, module) {
  38        module.exports = window.ReactJSXRuntime;
  39      }
  40    });
  41  
  42    // package-external:@wordpress/is-shallow-equal
  43    var require_is_shallow_equal = __commonJS({
  44      "package-external:@wordpress/is-shallow-equal"(exports, module) {
  45        module.exports = window.wp.isShallowEqual;
  46      }
  47    });
  48  
  49    // package-external:@wordpress/element
  50    var require_element = __commonJS({
  51      "package-external:@wordpress/element"(exports, module) {
  52        module.exports = window.wp.element;
  53      }
  54    });
  55  
  56    // package-external:@wordpress/deprecated
  57    var require_deprecated = __commonJS({
  58      "package-external:@wordpress/deprecated"(exports, module) {
  59        module.exports = window.wp.deprecated;
  60      }
  61    });
  62  
  63    // package-external:@wordpress/dom
  64    var require_dom = __commonJS({
  65      "package-external:@wordpress/dom"(exports, module) {
  66        module.exports = window.wp.dom;
  67      }
  68    });
  69  
  70    // 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    // 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    // 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    // 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    // node_modules/lower-case/dist.es2015/index.js
 613    function lowerCase(str) {
 614      return str.toLowerCase();
 615    }
 616  
 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    // 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    // 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    // 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    // 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    // 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    // 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    // packages/compose/build-module/higher-order/compose.mjs
 857    var compose = basePipe(true);
 858    var compose_default = compose;
 859  
 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    // 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    // 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    // 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    // 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    // 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    // 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    // 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    // 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    // packages/compose/build-module/hooks/use-constrained-tabbing/index.mjs
1105    var import_dom = __toESM(require_dom(), 1);
1106  
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    // 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    // 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    // 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 clearSelection(trigger) {
1196      if ("focus" in trigger && typeof trigger.focus === "function") {
1197        trigger.focus();
1198      }
1199      trigger.ownerDocument?.defaultView?.getSelection()?.removeAllRanges();
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 (!isActive) {
1217            return;
1218          }
1219          if (success) {
1220            clearSelection(node);
1221            if (onSuccessRef.current) {
1222              onSuccessRef.current();
1223            }
1224          }
1225        };
1226        node.addEventListener("click", handleClick);
1227        return () => {
1228          isActive = false;
1229          node.removeEventListener("click", handleClick);
1230        };
1231      }, []);
1232    }
1233  
1234    // packages/compose/build-module/hooks/use-copy-on-click/index.mjs
1235    function useCopyOnClick(ref, text, timeout = 4e3) {
1236      (0, import_deprecated3.default)("wp.compose.useCopyOnClick", {
1237        since: "5.8",
1238        alternative: "wp.compose.useCopyToClipboard"
1239      });
1240      const [hasCopied, setHasCopied] = (0, import_element8.useState)(false);
1241      (0, import_element8.useEffect)(() => {
1242        let isActive = true;
1243        let timeoutId;
1244        if (!ref.current) {
1245          return;
1246        }
1247        let targets;
1248        if (typeof ref.current === "string") {
1249          targets = typeof document !== "undefined" ? Array.from(document.querySelectorAll(ref.current)) : [];
1250        } else if ("length" in ref.current && typeof ref.current.length === "number") {
1251          targets = Array.from(ref.current);
1252        } else {
1253          targets = [ref.current];
1254        }
1255        if (targets.length === 0) {
1256          return;
1257        }
1258        const handleClick = async (event) => {
1259          const trigger = event.currentTarget;
1260          if (!trigger) {
1261            return;
1262          }
1263          const success = await copyToClipboard(
1264            typeof text === "function" ? text() : text || "",
1265            trigger
1266          );
1267          if (!isActive) {
1268            return;
1269          }
1270          if (success) {
1271            clearSelection(trigger);
1272            if (timeout) {
1273              setHasCopied(true);
1274              clearTimeout(timeoutId);
1275              timeoutId = setTimeout(
1276                () => setHasCopied(false),
1277                timeout
1278              );
1279            }
1280          }
1281        };
1282        for (const target of targets) {
1283          target.addEventListener("click", handleClick);
1284        }
1285        return () => {
1286          isActive = false;
1287          for (const target of targets) {
1288            target.removeEventListener("click", handleClick);
1289          }
1290          clearTimeout(timeoutId);
1291        };
1292      }, [ref, text, timeout]);
1293      return hasCopied;
1294    }
1295  
1296    // packages/compose/build-module/hooks/use-dialog/index.mjs
1297    var import_element13 = __toESM(require_element(), 1);
1298    var import_keycodes = __toESM(require_keycodes(), 1);
1299  
1300    // packages/compose/build-module/hooks/use-focus-on-mount/index.mjs
1301    var import_element9 = __toESM(require_element(), 1);
1302    var import_dom2 = __toESM(require_dom(), 1);
1303    function useFocusOnMount(focusOnMount = "firstElement") {
1304      const focusOnMountRef = (0, import_element9.useRef)(focusOnMount);
1305      const setFocus = (target) => {
1306        target.focus({
1307          // When focusing newly mounted dialogs,
1308          // the position of the popover is often not right on the first render
1309          // This prevents the layout shifts when focusing the dialogs.
1310          preventScroll: true
1311        });
1312      };
1313      const timerIdRef = (0, import_element9.useRef)(void 0);
1314      (0, import_element9.useEffect)(() => {
1315        focusOnMountRef.current = focusOnMount;
1316      }, [focusOnMount]);
1317      return useRefEffect((node) => {
1318        if (!node || focusOnMountRef.current === false) {
1319          return;
1320        }
1321        if (node.contains(node.ownerDocument?.activeElement ?? null)) {
1322          return;
1323        }
1324        if (focusOnMountRef.current !== "firstElement" && focusOnMountRef.current !== "firstInputElement") {
1325          setFocus(node);
1326          return;
1327        }
1328        timerIdRef.current = setTimeout(() => {
1329          if (focusOnMountRef.current === "firstInputElement") {
1330            let formInput = null;
1331            if (typeof window !== "undefined" && node instanceof window.Element) {
1332              formInput = node.querySelector(
1333                'input:not([type="hidden"]):not([disabled]), select:not([disabled]), textarea:not([disabled])'
1334              );
1335            }
1336            if (formInput) {
1337              setFocus(formInput);
1338              return;
1339            }
1340          }
1341          const firstTabbable = import_dom2.focus.tabbable.find(node)[0];
1342          if (firstTabbable) {
1343            setFocus(firstTabbable);
1344          }
1345        }, 0);
1346        return () => {
1347          if (timerIdRef.current) {
1348            clearTimeout(timerIdRef.current);
1349          }
1350        };
1351      }, []);
1352    }
1353  
1354    // packages/compose/build-module/hooks/use-focus-return/index.mjs
1355    var import_element10 = __toESM(require_element(), 1);
1356    var origin = null;
1357    function useFocusReturn(onFocusReturn) {
1358      const ref = (0, import_element10.useRef)(null);
1359      const focusedBeforeMount = (0, import_element10.useRef)(null);
1360      const onFocusReturnRef = (0, import_element10.useRef)(onFocusReturn);
1361      (0, import_element10.useEffect)(() => {
1362        onFocusReturnRef.current = onFocusReturn;
1363      }, [onFocusReturn]);
1364      return (0, import_element10.useCallback)((node) => {
1365        if (node) {
1366          ref.current = node;
1367          if (focusedBeforeMount.current) {
1368            return;
1369          }
1370          const activeDocument = node.ownerDocument.activeElement instanceof window.HTMLIFrameElement ? node.ownerDocument.activeElement.contentDocument : node.ownerDocument;
1371          focusedBeforeMount.current = activeDocument?.activeElement ?? null;
1372        } else if (focusedBeforeMount.current) {
1373          const isFocused = ref.current?.contains(
1374            ref.current?.ownerDocument.activeElement
1375          );
1376          if (ref.current?.isConnected && !isFocused) {
1377            origin ??= focusedBeforeMount.current;
1378            return;
1379          }
1380          if (onFocusReturnRef.current) {
1381            onFocusReturnRef.current();
1382          } else {
1383            (!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus();
1384          }
1385          origin = null;
1386        }
1387      }, []);
1388    }
1389    var use_focus_return_default = useFocusReturn;
1390  
1391    // packages/compose/build-module/hooks/use-focus-outside/index.mjs
1392    var import_element11 = __toESM(require_element(), 1);
1393    var INPUT_BUTTON_TYPES = ["button", "submit"];
1394    function isFocusNormalizedButton(eventTarget) {
1395      if (!(eventTarget instanceof window.HTMLElement)) {
1396        return false;
1397      }
1398      switch (eventTarget.nodeName) {
1399        case "A":
1400        case "BUTTON":
1401          return true;
1402        case "INPUT":
1403          return INPUT_BUTTON_TYPES.includes(
1404            eventTarget.type
1405          );
1406      }
1407      return false;
1408    }
1409    function useFocusOutside(onFocusOutside) {
1410      const currentOnFocusOutsideRef = (0, import_element11.useRef)(onFocusOutside);
1411      (0, import_element11.useEffect)(() => {
1412        currentOnFocusOutsideRef.current = onFocusOutside;
1413      }, [onFocusOutside]);
1414      const preventBlurCheckRef = (0, import_element11.useRef)(false);
1415      const blurCheckTimeoutIdRef = (0, import_element11.useRef)(void 0);
1416      const cancelBlurCheck = (0, import_element11.useCallback)(() => {
1417        clearTimeout(blurCheckTimeoutIdRef.current);
1418      }, []);
1419      (0, import_element11.useEffect)(() => {
1420        if (!onFocusOutside) {
1421          cancelBlurCheck();
1422        }
1423      }, [onFocusOutside, cancelBlurCheck]);
1424      const normalizeButtonFocus = (0, import_element11.useCallback)((event) => {
1425        const { type, target } = event;
1426        const isInteractionEnd = ["mouseup", "touchend"].includes(type);
1427        if (isInteractionEnd) {
1428          preventBlurCheckRef.current = false;
1429        } else if (isFocusNormalizedButton(target)) {
1430          preventBlurCheckRef.current = true;
1431        }
1432      }, []);
1433      const queueBlurCheck = (0, import_element11.useCallback)((event) => {
1434        event.persist();
1435        if (preventBlurCheckRef.current) {
1436          return;
1437        }
1438        const ignoreForRelatedTarget = event.target.getAttribute(
1439          "data-unstable-ignore-focus-outside-for-relatedtarget"
1440        );
1441        if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) {
1442          return;
1443        }
1444        blurCheckTimeoutIdRef.current = setTimeout(() => {
1445          if (!document.hasFocus()) {
1446            event.preventDefault();
1447            return;
1448          }
1449          if ("function" === typeof currentOnFocusOutsideRef.current) {
1450            currentOnFocusOutsideRef.current(event);
1451          }
1452        }, 0);
1453      }, []);
1454      return {
1455        onFocus: cancelBlurCheck,
1456        onMouseDown: normalizeButtonFocus,
1457        onMouseUp: normalizeButtonFocus,
1458        onTouchStart: normalizeButtonFocus,
1459        onTouchEnd: normalizeButtonFocus,
1460        onBlur: queueBlurCheck
1461      };
1462    }
1463  
1464    // packages/compose/build-module/hooks/use-merge-refs/index.mjs
1465    var import_element12 = __toESM(require_element(), 1);
1466    function assignRef(ref, value) {
1467      if (typeof ref === "function") {
1468        ref(value);
1469      } else if (ref && ref.hasOwnProperty("current")) {
1470        ref.current = value;
1471      }
1472    }
1473    function useMergeRefs(refs) {
1474      const element = (0, import_element12.useRef)(null);
1475      const isAttachedRef = (0, import_element12.useRef)(false);
1476      const didElementChangeRef = (0, import_element12.useRef)(false);
1477      const previousRefsRef = (0, import_element12.useRef)([]);
1478      const currentRefsRef = (0, import_element12.useRef)(refs);
1479      currentRefsRef.current = refs;
1480      (0, import_element12.useLayoutEffect)(() => {
1481        if (didElementChangeRef.current === false && isAttachedRef.current === true) {
1482          refs.forEach((ref, index) => {
1483            const previousRef = previousRefsRef.current[index];
1484            if (ref !== previousRef) {
1485              assignRef(previousRef, null);
1486              assignRef(ref, element.current);
1487            }
1488          });
1489        }
1490        previousRefsRef.current = refs;
1491      }, refs);
1492      (0, import_element12.useLayoutEffect)(() => {
1493        didElementChangeRef.current = false;
1494      });
1495      return (0, import_element12.useCallback)((value) => {
1496        assignRef(element, value);
1497        didElementChangeRef.current = true;
1498        isAttachedRef.current = value !== null;
1499        const refsToAssign = value ? currentRefsRef.current : previousRefsRef.current;
1500        for (const ref of refsToAssign) {
1501          assignRef(ref, value);
1502        }
1503      }, []);
1504    }
1505  
1506    // packages/compose/build-module/hooks/use-dialog/index.mjs
1507    function useDialog(options) {
1508      const currentOptions = (0, import_element13.useRef)(void 0);
1509      const { constrainTabbing = options.focusOnMount !== false } = options;
1510      (0, import_element13.useEffect)(() => {
1511        currentOptions.current = options;
1512      }, Object.values(options));
1513      const constrainedTabbingRef = use_constrained_tabbing_default();
1514      const focusOnMountRef = useFocusOnMount(options.focusOnMount);
1515      const focusReturnRef = use_focus_return_default();
1516      const focusOutsideProps = useFocusOutside((event) => {
1517        if (currentOptions.current?.__unstableOnClose) {
1518          currentOptions.current.__unstableOnClose("focus-outside", event);
1519        } else if (currentOptions.current?.onClose) {
1520          currentOptions.current.onClose();
1521        }
1522      });
1523      const closeOnEscapeRef = (0, import_element13.useCallback)((node) => {
1524        if (!node) {
1525          return;
1526        }
1527        node.addEventListener("keydown", (event) => {
1528          if (event.keyCode === import_keycodes.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) {
1529            event.preventDefault();
1530            currentOptions.current.onClose();
1531          }
1532        });
1533      }, []);
1534      return [
1535        useMergeRefs([
1536          constrainTabbing ? constrainedTabbingRef : null,
1537          options.focusOnMount !== false ? focusReturnRef : null,
1538          options.focusOnMount !== false ? focusOnMountRef : null,
1539          closeOnEscapeRef
1540        ]),
1541        {
1542          ...focusOutsideProps,
1543          tabIndex: -1
1544        }
1545      ];
1546    }
1547    var use_dialog_default = useDialog;
1548  
1549    // packages/compose/build-module/hooks/use-disabled/index.mjs
1550    function useDisabled({
1551      isDisabled: isDisabledProp = false
1552    } = {}) {
1553      return useRefEffect(
1554        (node) => {
1555          if (isDisabledProp) {
1556            return;
1557          }
1558          const defaultView = node?.ownerDocument?.defaultView;
1559          if (!defaultView) {
1560            return;
1561          }
1562          const updates = [];
1563          const disable = () => {
1564            node.childNodes.forEach((child) => {
1565              if (!(child instanceof defaultView.HTMLElement)) {
1566                return;
1567              }
1568              if (!child.getAttribute("inert")) {
1569                child.setAttribute("inert", "true");
1570                updates.push(() => {
1571                  child.removeAttribute("inert");
1572                });
1573              }
1574            });
1575          };
1576          const debouncedDisable = debounce(disable, 0, {
1577            leading: true
1578          });
1579          disable();
1580          const observer = new window.MutationObserver(debouncedDisable);
1581          observer.observe(node, {
1582            childList: true
1583          });
1584          return () => {
1585            if (observer) {
1586              observer.disconnect();
1587            }
1588            debouncedDisable.cancel();
1589            updates.forEach((update) => update());
1590          };
1591        },
1592        [isDisabledProp]
1593      );
1594    }
1595  
1596    // packages/compose/build-module/hooks/use-event/index.mjs
1597    var import_element14 = __toESM(require_element(), 1);
1598    function useEvent(callback) {
1599      const ref = (0, import_element14.useRef)(() => {
1600        throw new Error(
1601          "Callbacks created with `useEvent` cannot be called during rendering."
1602        );
1603      });
1604      (0, import_element14.useInsertionEffect)(() => {
1605        ref.current = callback;
1606      });
1607      return (0, import_element14.useCallback)(
1608        (...args) => ref.current?.(...args),
1609        []
1610      );
1611    }
1612  
1613    // packages/compose/build-module/hooks/use-dragging/index.mjs
1614    var import_element16 = __toESM(require_element(), 1);
1615  
1616    // packages/compose/build-module/hooks/use-isomorphic-layout-effect/index.mjs
1617    var import_element15 = __toESM(require_element(), 1);
1618    var useIsomorphicLayoutEffect = typeof window !== "undefined" ? import_element15.useLayoutEffect : import_element15.useEffect;
1619    var use_isomorphic_layout_effect_default = useIsomorphicLayoutEffect;
1620  
1621    // packages/compose/build-module/hooks/use-dragging/index.mjs
1622    function useDragging({ onDragStart, onDragMove, onDragEnd }) {
1623      const [isDragging, setIsDragging] = (0, import_element16.useState)(false);
1624      const eventsRef = (0, import_element16.useRef)({
1625        onDragStart,
1626        onDragMove,
1627        onDragEnd
1628      });
1629      use_isomorphic_layout_effect_default(() => {
1630        eventsRef.current.onDragStart = onDragStart;
1631        eventsRef.current.onDragMove = onDragMove;
1632        eventsRef.current.onDragEnd = onDragEnd;
1633      }, [onDragStart, onDragMove, onDragEnd]);
1634      const onMouseMove = (0, import_element16.useCallback)(
1635        (event) => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event),
1636        []
1637      );
1638      const endDrag = (0, import_element16.useCallback)((event) => {
1639        if (eventsRef.current.onDragEnd) {
1640          eventsRef.current.onDragEnd(event);
1641        }
1642        document.removeEventListener("mousemove", onMouseMove);
1643        document.removeEventListener("mouseup", endDrag);
1644        setIsDragging(false);
1645      }, []);
1646      const startDrag = (0, import_element16.useCallback)((event) => {
1647        if (eventsRef.current.onDragStart) {
1648          eventsRef.current.onDragStart(event);
1649        }
1650        document.addEventListener("mousemove", onMouseMove);
1651        document.addEventListener("mouseup", endDrag);
1652        setIsDragging(true);
1653      }, []);
1654      (0, import_element16.useEffect)(() => {
1655        return () => {
1656          if (isDragging) {
1657            document.removeEventListener("mousemove", onMouseMove);
1658            document.removeEventListener("mouseup", endDrag);
1659          }
1660        };
1661      }, [isDragging]);
1662      return {
1663        startDrag,
1664        endDrag,
1665        isDragging
1666      };
1667    }
1668  
1669    // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs
1670    var import_mousetrap = __toESM(require_mousetrap(), 1);
1671  
1672    // node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js
1673    (function(Mousetrap3) {
1674      if (!Mousetrap3) {
1675        return;
1676      }
1677      var _globalCallbacks = {};
1678      var _originalStopCallback = Mousetrap3.prototype.stopCallback;
1679      Mousetrap3.prototype.stopCallback = function(e, element, combo, sequence) {
1680        var self = this;
1681        if (self.paused) {
1682          return true;
1683        }
1684        if (_globalCallbacks[combo] || _globalCallbacks[sequence]) {
1685          return false;
1686        }
1687        return _originalStopCallback.call(self, e, element, combo);
1688      };
1689      Mousetrap3.prototype.bindGlobal = function(keys, callback, action) {
1690        var self = this;
1691        self.bind(keys, callback, action);
1692        if (keys instanceof Array) {
1693          for (var i = 0; i < keys.length; i++) {
1694            _globalCallbacks[keys[i]] = true;
1695          }
1696          return;
1697        }
1698        _globalCallbacks[keys] = true;
1699      };
1700      Mousetrap3.init();
1701    })(typeof Mousetrap !== "undefined" ? Mousetrap : void 0);
1702  
1703    // packages/compose/build-module/hooks/use-keyboard-shortcut/index.mjs
1704    var import_element17 = __toESM(require_element(), 1);
1705    var import_keycodes2 = __toESM(require_keycodes(), 1);
1706    function useKeyboardShortcut(shortcuts, callback, {
1707      bindGlobal = false,
1708      eventName = "keydown",
1709      isDisabled = false,
1710      // This is important for performance considerations.
1711      target
1712    } = {}) {
1713      const currentCallbackRef = (0, import_element17.useRef)(callback);
1714      (0, import_element17.useEffect)(() => {
1715        currentCallbackRef.current = callback;
1716      }, [callback]);
1717      (0, import_element17.useEffect)(() => {
1718        if (isDisabled) {
1719          return;
1720        }
1721        const mousetrap = new import_mousetrap.default(
1722          target && target.current ? target.current : (
1723            // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.
1724            // 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
1725            // necessary to maintain the existing behavior.
1726            /** @type {Element} */
1727            /** @type {unknown} */
1728            document
1729          )
1730        );
1731        const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts];
1732        shortcutsArray.forEach((shortcut) => {
1733          const keys = shortcut.split("+");
1734          const modifiers = new Set(
1735            keys.filter((value) => value.length > 1)
1736          );
1737          const hasAlt = modifiers.has("alt");
1738          const hasShift = modifiers.has("shift");
1739          if ((0, import_keycodes2.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) {
1740            throw new Error(
1741              `Cannot bind $shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`
1742            );
1743          }
1744          const bindFn = bindGlobal ? "bindGlobal" : "bind";
1745          mousetrap[bindFn](
1746            shortcut,
1747            (...args) => currentCallbackRef.current(...args),
1748            eventName
1749          );
1750        });
1751        return () => {
1752          mousetrap.reset();
1753        };
1754      }, [shortcuts, bindGlobal, eventName, target, isDisabled]);
1755    }
1756    var use_keyboard_shortcut_default = useKeyboardShortcut;
1757  
1758    // packages/compose/build-module/hooks/use-media-query/index.mjs
1759    var import_element18 = __toESM(require_element(), 1);
1760    var perWindowCache = /* @__PURE__ */ new WeakMap();
1761    function getMediaQueryList(view, query) {
1762      if (!query) {
1763        return null;
1764      }
1765      const matchMediaCache = perWindowCache.get(view) ?? /* @__PURE__ */ new Map();
1766      if (!perWindowCache.has(view)) {
1767        perWindowCache.set(view, matchMediaCache);
1768      }
1769      let match = matchMediaCache.get(query);
1770      if (match) {
1771        return match;
1772      }
1773      if (typeof view?.matchMedia === "function") {
1774        match = view.matchMedia(query);
1775        matchMediaCache.set(query, match);
1776        return match;
1777      }
1778      return null;
1779    }
1780    function useMediaQuery(query, view = window) {
1781      const source = (0, import_element18.useMemo)(() => {
1782        const mediaQueryList = getMediaQueryList(view, query);
1783        return {
1784          subscribe(onStoreChange) {
1785            if (!mediaQueryList) {
1786              return () => {
1787              };
1788            }
1789            mediaQueryList.addEventListener?.("change", onStoreChange);
1790            return () => {
1791              mediaQueryList.removeEventListener?.(
1792                "change",
1793                onStoreChange
1794              );
1795            };
1796          },
1797          getValue() {
1798            return mediaQueryList?.matches ?? false;
1799          }
1800        };
1801      }, [view, query]);
1802      return (0, import_element18.useSyncExternalStore)(
1803        source.subscribe,
1804        source.getValue,
1805        () => false
1806      );
1807    }
1808  
1809    // packages/compose/build-module/hooks/use-previous/index.mjs
1810    var import_element19 = __toESM(require_element(), 1);
1811    function usePrevious(value) {
1812      const ref = (0, import_element19.useRef)(void 0);
1813      (0, import_element19.useEffect)(() => {
1814        ref.current = value;
1815      }, [value]);
1816      return ref.current;
1817    }
1818  
1819    // packages/compose/build-module/hooks/use-reduced-motion/index.mjs
1820    var useReducedMotion = () => useMediaQuery("(prefers-reduced-motion: reduce)");
1821    var use_reduced_motion_default = useReducedMotion;
1822  
1823    // packages/compose/build-module/hooks/use-state-with-history/index.mjs
1824    var import_undo_manager = __toESM(require_undo_manager(), 1);
1825    var import_element20 = __toESM(require_element(), 1);
1826    function undoRedoReducer(state, action) {
1827      switch (action.type) {
1828        case "UNDO": {
1829          const undoRecord = state.manager.undo();
1830          if (undoRecord) {
1831            return {
1832              ...state,
1833              value: undoRecord[0].changes.prop.from
1834            };
1835          }
1836          return state;
1837        }
1838        case "REDO": {
1839          const redoRecord = state.manager.redo();
1840          if (redoRecord) {
1841            return {
1842              ...state,
1843              value: redoRecord[0].changes.prop.to
1844            };
1845          }
1846          return state;
1847        }
1848        case "RECORD": {
1849          state.manager.addRecord(
1850            [
1851              {
1852                id: "object",
1853                changes: {
1854                  prop: { from: state.value, to: action.value }
1855                }
1856              }
1857            ],
1858            action.isStaged
1859          );
1860          return {
1861            ...state,
1862            value: action.value
1863          };
1864        }
1865      }
1866      return state;
1867    }
1868    function initReducer(value) {
1869      return {
1870        manager: (0, import_undo_manager.createUndoManager)(),
1871        value
1872      };
1873    }
1874    function useStateWithHistory(initialValue) {
1875      const [state, dispatch] = (0, import_element20.useReducer)(
1876        undoRedoReducer,
1877        initialValue,
1878        initReducer
1879      );
1880      return {
1881        value: state.value,
1882        setValue: (0, import_element20.useCallback)((newValue, isStaged) => {
1883          dispatch({
1884            type: "RECORD",
1885            value: newValue,
1886            isStaged
1887          });
1888        }, []),
1889        hasUndo: state.manager.hasUndo(),
1890        hasRedo: state.manager.hasRedo(),
1891        undo: (0, import_element20.useCallback)(() => {
1892          dispatch({ type: "UNDO" });
1893        }, []),
1894        redo: (0, import_element20.useCallback)(() => {
1895          dispatch({ type: "REDO" });
1896        }, [])
1897      };
1898    }
1899  
1900    // packages/compose/build-module/hooks/use-viewport-match/index.mjs
1901    var import_element21 = __toESM(require_element(), 1);
1902    var BREAKPOINTS = {
1903      xhuge: 1920,
1904      huge: 1440,
1905      wide: 1280,
1906      xlarge: 1080,
1907      large: 960,
1908      medium: 782,
1909      small: 600,
1910      mobile: 480
1911    };
1912    var CONDITIONS = {
1913      ">=": "min-width",
1914      "<": "max-width"
1915    };
1916    var OPERATOR_EVALUATORS = {
1917      ">=": (breakpointValue, width) => width >= breakpointValue,
1918      "<": (breakpointValue, width) => width < breakpointValue
1919    };
1920    var ViewportMatchWidthContext = (0, import_element21.createContext)(
1921      /** @type {null | number} */
1922      null
1923    );
1924    ViewportMatchWidthContext.displayName = "ViewportMatchWidthContext";
1925    var useViewportMatch = (breakpoint, operator = ">=", view = window) => {
1926      const simulatedWidth = (0, import_element21.useContext)(ViewportMatchWidthContext);
1927      const mediaQuery = !simulatedWidth && `($CONDITIONS[operator]}: $BREAKPOINTS[breakpoint]}px)`;
1928      const mediaQueryResult = useMediaQuery(mediaQuery || void 0, view);
1929      if (simulatedWidth) {
1930        return OPERATOR_EVALUATORS[operator](
1931          BREAKPOINTS[breakpoint],
1932          simulatedWidth
1933        );
1934      }
1935      return mediaQueryResult;
1936    };
1937    useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider;
1938    var use_viewport_match_default = useViewportMatch;
1939  
1940    // packages/compose/build-module/hooks/use-resize-observer/use-resize-observer.mjs
1941    var import_element22 = __toESM(require_element(), 1);
1942    function useResizeObserver(callback, resizeObserverOptions = {}) {
1943      const callbackEvent = useEvent(callback);
1944      const observedElementRef = (0, import_element22.useRef)(null);
1945      const resizeObserverRef = (0, import_element22.useRef)(void 0);
1946      return useEvent((element) => {
1947        if (element === observedElementRef.current) {
1948          return;
1949        }
1950        resizeObserverRef.current ??= new ResizeObserver(callbackEvent);
1951        const { current: resizeObserver } = resizeObserverRef;
1952        if (observedElementRef.current) {
1953          resizeObserver.unobserve(observedElementRef.current);
1954        }
1955        observedElementRef.current = element ?? null;
1956        if (element) {
1957          resizeObserver.observe(element, resizeObserverOptions);
1958        }
1959      });
1960    }
1961  
1962    // packages/compose/build-module/hooks/use-resize-observer/legacy/index.mjs
1963    var import_element23 = __toESM(require_element(), 1);
1964    var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1965    var extractSize = (entry) => {
1966      let entrySize;
1967      if (!entry.contentBoxSize) {
1968        entrySize = [entry.contentRect.width, entry.contentRect.height];
1969      } else if (entry.contentBoxSize[0]) {
1970        const contentBoxSize = entry.contentBoxSize[0];
1971        entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
1972      } else {
1973        const contentBoxSize = entry.contentBoxSize;
1974        entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
1975      }
1976      const [width, height] = entrySize.map((d) => Math.round(d));
1977      return { width, height };
1978    };
1979    var RESIZE_ELEMENT_STYLES = {
1980      position: "absolute",
1981      top: 0,
1982      left: 0,
1983      right: 0,
1984      bottom: 0,
1985      pointerEvents: "none",
1986      opacity: 0,
1987      overflow: "hidden",
1988      zIndex: -1
1989    };
1990    function ResizeElement({ onResize }) {
1991      const resizeElementRef = useResizeObserver((entries) => {
1992        const newSize = extractSize(entries.at(-1));
1993        onResize(newSize);
1994      });
1995      return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1996        "div",
1997        {
1998          ref: resizeElementRef,
1999          style: RESIZE_ELEMENT_STYLES,
2000          "aria-hidden": "true"
2001        }
2002      );
2003    }
2004    function sizeEquals(a, b) {
2005      return a.width === b.width && a.height === b.height;
2006    }
2007    var NULL_SIZE = { width: null, height: null };
2008    function useLegacyResizeObserver() {
2009      const [size, setSize] = (0, import_element23.useState)(NULL_SIZE);
2010      const previousSizeRef = (0, import_element23.useRef)(NULL_SIZE);
2011      const handleResize = (0, import_element23.useCallback)((newSize) => {
2012        if (!sizeEquals(previousSizeRef.current, newSize)) {
2013          previousSizeRef.current = newSize;
2014          setSize(newSize);
2015        }
2016      }, []);
2017      const resizeElement = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ResizeElement, { onResize: handleResize });
2018      return [resizeElement, size];
2019    }
2020  
2021    // packages/compose/build-module/hooks/use-resize-observer/index.mjs
2022    function useResizeObserver2(callback, options = {}) {
2023      return callback ? useResizeObserver(callback, options) : useLegacyResizeObserver();
2024    }
2025  
2026    // packages/compose/build-module/hooks/use-async-list/index.mjs
2027    var import_element24 = __toESM(require_element(), 1);
2028    var import_priority_queue = __toESM(require_priority_queue(), 1);
2029    function getFirstItemsPresentInState(list, state) {
2030      const firstItems = [];
2031      for (let i = 0; i < list.length; i++) {
2032        const item = list[i];
2033        if (!state.includes(item)) {
2034          break;
2035        }
2036        firstItems.push(item);
2037      }
2038      return firstItems;
2039    }
2040    function useAsyncList(list, config = { step: 1 }) {
2041      const { step = 1 } = config;
2042      const [current, setCurrent] = (0, import_element24.useState)([]);
2043      (0, import_element24.useEffect)(() => {
2044        let firstItems = getFirstItemsPresentInState(list, current);
2045        if (firstItems.length < step) {
2046          firstItems = firstItems.concat(
2047            list.slice(firstItems.length, step)
2048          );
2049        }
2050        setCurrent(firstItems);
2051        const asyncQueue = (0, import_priority_queue.createQueue)();
2052        for (let i = firstItems.length; i < list.length; i += step) {
2053          asyncQueue.add({}, () => {
2054            (0, import_element24.flushSync)(() => {
2055              setCurrent((state) => [
2056                ...state,
2057                ...list.slice(i, i + step)
2058              ]);
2059            });
2060          });
2061        }
2062        return () => asyncQueue.reset();
2063      }, [list]);
2064      return current;
2065    }
2066    var use_async_list_default = useAsyncList;
2067  
2068    // packages/compose/build-module/hooks/use-warn-on-change/index.mjs
2069    function useWarnOnChange(object, prefix = "Change detection") {
2070      const previousValues = usePrevious(object);
2071      Object.entries(previousValues ?? []).forEach(([key, value]) => {
2072        if (value !== object[
2073          /** @type {keyof typeof object} */
2074          key
2075        ]) {
2076          console.warn(
2077            `$prefix}: $key} key changed:`,
2078            value,
2079            object[
2080              /** @type {keyof typeof object} */
2081              key
2082            ]
2083            /* eslint-enable jsdoc/check-types */
2084          );
2085        }
2086      });
2087    }
2088    var use_warn_on_change_default = useWarnOnChange;
2089  
2090    // node_modules/use-memo-one/dist/use-memo-one.esm.js
2091    var import_react = __toESM(require_react());
2092    function areInputsEqual(newInputs, lastInputs) {
2093      if (newInputs.length !== lastInputs.length) {
2094        return false;
2095      }
2096      for (var i = 0; i < newInputs.length; i++) {
2097        if (newInputs[i] !== lastInputs[i]) {
2098          return false;
2099        }
2100      }
2101      return true;
2102    }
2103    function useMemoOne(getResult, inputs) {
2104      var initial = (0, import_react.useState)(function() {
2105        return {
2106          inputs,
2107          result: getResult()
2108        };
2109      })[0];
2110      var committed = (0, import_react.useRef)(initial);
2111      var isInputMatch = Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs));
2112      var cache = isInputMatch ? committed.current : {
2113        inputs,
2114        result: getResult()
2115      };
2116      (0, import_react.useEffect)(function() {
2117        committed.current = cache;
2118      }, [cache]);
2119      return cache.result;
2120    }
2121  
2122    // packages/compose/build-module/hooks/use-debounce/index.mjs
2123    var import_element25 = __toESM(require_element(), 1);
2124    function useDebounce(fn, wait, options) {
2125      const debounced = useMemoOne(
2126        () => debounce(fn, wait ?? 0, options),
2127        [fn, wait, options?.leading, options?.trailing, options?.maxWait]
2128      );
2129      (0, import_element25.useEffect)(() => () => debounced.cancel(), [debounced]);
2130      return debounced;
2131    }
2132  
2133    // packages/compose/build-module/hooks/use-debounced-input/index.mjs
2134    var import_element26 = __toESM(require_element(), 1);
2135    function useDebouncedInput(defaultValue = "") {
2136      const [input, setInput] = (0, import_element26.useState)(defaultValue);
2137      const [debouncedInput, setDebouncedState] = (0, import_element26.useState)(defaultValue);
2138      const setDebouncedInput = useDebounce(setDebouncedState, 250);
2139      (0, import_element26.useEffect)(() => {
2140        setDebouncedInput(input);
2141      }, [input, setDebouncedInput]);
2142      return [input, setInput, debouncedInput];
2143    }
2144  
2145    // packages/compose/build-module/hooks/use-throttle/index.mjs
2146    var import_element27 = __toESM(require_element(), 1);
2147    function useThrottle(fn, wait, options) {
2148      const throttled = useMemoOne(
2149        () => throttle(fn, wait ?? 0, options),
2150        [fn, wait, options]
2151      );
2152      (0, import_element27.useEffect)(() => () => throttled.cancel(), [throttled]);
2153      return throttled;
2154    }
2155  
2156    // packages/compose/build-module/hooks/use-drop-zone/index.mjs
2157    function useDropZone({
2158      dropZoneElement,
2159      isDisabled,
2160      onDrop: _onDrop,
2161      onDragStart: _onDragStart,
2162      onDragEnter: _onDragEnter,
2163      onDragLeave: _onDragLeave,
2164      onDragEnd: _onDragEnd,
2165      onDragOver: _onDragOver
2166    }) {
2167      const onDropEvent = useEvent(_onDrop);
2168      const onDragStartEvent = useEvent(_onDragStart);
2169      const onDragEnterEvent = useEvent(_onDragEnter);
2170      const onDragLeaveEvent = useEvent(_onDragLeave);
2171      const onDragEndEvent = useEvent(_onDragEnd);
2172      const onDragOverEvent = useEvent(_onDragOver);
2173      return useRefEffect(
2174        (elem) => {
2175          if (isDisabled) {
2176            return;
2177          }
2178          const element = dropZoneElement ?? elem;
2179          let isDragging = false;
2180          const { ownerDocument } = element;
2181          function isElementInZone(targetToCheck) {
2182            const { defaultView } = ownerDocument;
2183            if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) {
2184              return false;
2185            }
2186            let elementToCheck = targetToCheck;
2187            do {
2188              if (elementToCheck.dataset.isDropZone) {
2189                return elementToCheck === element;
2190              }
2191            } while (elementToCheck = elementToCheck.parentElement);
2192            return false;
2193          }
2194          function maybeDragStart(event) {
2195            if (isDragging) {
2196              return;
2197            }
2198            isDragging = true;
2199            ownerDocument.addEventListener("dragend", maybeDragEnd);
2200            ownerDocument.addEventListener("mousemove", maybeDragEnd);
2201            if (_onDragStart) {
2202              onDragStartEvent(event);
2203            }
2204          }
2205          function onDragEnter(event) {
2206            event.preventDefault();
2207            if (element.contains(
2208              /** @type {Node} */
2209              event.relatedTarget
2210            )) {
2211              return;
2212            }
2213            if (_onDragEnter) {
2214              onDragEnterEvent(event);
2215            }
2216          }
2217          function onDragOver(event) {
2218            if (!event.defaultPrevented && _onDragOver) {
2219              onDragOverEvent(event);
2220            }
2221            event.preventDefault();
2222          }
2223          function onDragLeave(event) {
2224            if (isElementInZone(event.relatedTarget)) {
2225              return;
2226            }
2227            if (_onDragLeave) {
2228              onDragLeaveEvent(event);
2229            }
2230          }
2231          function onDrop(event) {
2232            if (event.defaultPrevented) {
2233              return;
2234            }
2235            event.preventDefault();
2236            event.dataTransfer && event.dataTransfer.files.length;
2237            if (_onDrop) {
2238              onDropEvent(event);
2239            }
2240            maybeDragEnd(event);
2241          }
2242          function maybeDragEnd(event) {
2243            if (!isDragging) {
2244              return;
2245            }
2246            isDragging = false;
2247            ownerDocument.removeEventListener("dragend", maybeDragEnd);
2248            ownerDocument.removeEventListener("mousemove", maybeDragEnd);
2249            if (_onDragEnd) {
2250              onDragEndEvent(event);
2251            }
2252          }
2253          element.setAttribute("data-is-drop-zone", "true");
2254          element.addEventListener("drop", onDrop);
2255          element.addEventListener("dragenter", onDragEnter);
2256          element.addEventListener("dragover", onDragOver);
2257          element.addEventListener("dragleave", onDragLeave);
2258          ownerDocument.addEventListener("dragenter", maybeDragStart);
2259          return () => {
2260            element.removeAttribute("data-is-drop-zone");
2261            element.removeEventListener("drop", onDrop);
2262            element.removeEventListener("dragenter", onDragEnter);
2263            element.removeEventListener("dragover", onDragOver);
2264            element.removeEventListener("dragleave", onDragLeave);
2265            ownerDocument.removeEventListener("dragend", maybeDragEnd);
2266            ownerDocument.removeEventListener("mousemove", maybeDragEnd);
2267            ownerDocument.removeEventListener(
2268              "dragenter",
2269              maybeDragStart
2270            );
2271          };
2272        },
2273        [isDisabled, dropZoneElement]
2274        // Refresh when the passed in dropZoneElement changes.
2275      );
2276    }
2277  
2278    // packages/compose/build-module/hooks/use-focusable-iframe/index.mjs
2279    function useFocusableIframe() {
2280      return useRefEffect((element) => {
2281        const { ownerDocument } = element;
2282        if (!ownerDocument) {
2283          return;
2284        }
2285        const { defaultView } = ownerDocument;
2286        if (!defaultView) {
2287          return;
2288        }
2289        function checkFocus() {
2290          if (ownerDocument && ownerDocument.activeElement === element) {
2291            element.focus();
2292          }
2293        }
2294        defaultView.addEventListener("blur", checkFocus);
2295        return () => {
2296          defaultView.removeEventListener("blur", checkFocus);
2297        };
2298      }, []);
2299    }
2300  
2301    // packages/compose/build-module/hooks/use-fixed-window-list/index.mjs
2302    var import_element28 = __toESM(require_element(), 1);
2303    var import_dom3 = __toESM(require_dom(), 1);
2304    var import_keycodes3 = __toESM(require_keycodes(), 1);
2305    var DEFAULT_INIT_WINDOW_SIZE = 30;
2306    function useFixedWindowList(elementRef, itemHeight, totalItems, options) {
2307      const initWindowSize = options?.initWindowSize ?? DEFAULT_INIT_WINDOW_SIZE;
2308      const useWindowing = options?.useWindowing ?? true;
2309      const [fixedListWindow, setFixedListWindow] = (0, import_element28.useState)({
2310        visibleItems: initWindowSize,
2311        start: 0,
2312        end: initWindowSize,
2313        itemInView: (index) => {
2314          return index >= 0 && index <= initWindowSize;
2315        }
2316      });
2317      (0, import_element28.useLayoutEffect)(() => {
2318        if (!useWindowing) {
2319          return;
2320        }
2321        const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current);
2322        const measureWindow = (initRender) => {
2323          if (!scrollContainer) {
2324            return;
2325          }
2326          const visibleItems = Math.ceil(
2327            scrollContainer.clientHeight / itemHeight
2328          );
2329          const windowOverscan = initRender ? visibleItems : options?.windowOverscan ?? visibleItems;
2330          const firstViewableIndex = Math.floor(
2331            scrollContainer.scrollTop / itemHeight
2332          );
2333          const start = Math.max(0, firstViewableIndex - windowOverscan);
2334          const end = Math.min(
2335            totalItems - 1,
2336            firstViewableIndex + visibleItems + windowOverscan
2337          );
2338          setFixedListWindow((lastWindow) => {
2339            const nextWindow = {
2340              visibleItems,
2341              start,
2342              end,
2343              itemInView: (index) => {
2344                return start <= index && index <= end;
2345              }
2346            };
2347            if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) {
2348              return nextWindow;
2349            }
2350            return lastWindow;
2351          });
2352        };
2353        measureWindow(true);
2354        const debounceMeasureList = debounce(() => {
2355          measureWindow();
2356        }, 16);
2357        scrollContainer?.addEventListener("scroll", debounceMeasureList);
2358        scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2359          "resize",
2360          debounceMeasureList
2361        );
2362        scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2363          "resize",
2364          debounceMeasureList
2365        );
2366        return () => {
2367          scrollContainer?.removeEventListener(
2368            "scroll",
2369            debounceMeasureList
2370          );
2371          scrollContainer?.ownerDocument?.defaultView?.removeEventListener(
2372            "resize",
2373            debounceMeasureList
2374          );
2375        };
2376      }, [
2377        itemHeight,
2378        elementRef,
2379        totalItems,
2380        options?.expandedState,
2381        options?.windowOverscan,
2382        useWindowing
2383      ]);
2384      (0, import_element28.useLayoutEffect)(() => {
2385        if (!useWindowing) {
2386          return;
2387        }
2388        const scrollContainer = (0, import_dom3.getScrollContainer)(elementRef.current);
2389        const handleKeyDown = (event) => {
2390          switch (event.keyCode) {
2391            case import_keycodes3.HOME: {
2392              return scrollContainer?.scrollTo({ top: 0 });
2393            }
2394            case import_keycodes3.END: {
2395              return scrollContainer?.scrollTo({
2396                top: totalItems * itemHeight
2397              });
2398            }
2399            case import_keycodes3.PAGEUP: {
2400              return scrollContainer?.scrollTo({
2401                top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight
2402              });
2403            }
2404            case import_keycodes3.PAGEDOWN: {
2405              return scrollContainer?.scrollTo({
2406                top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight
2407              });
2408            }
2409          }
2410        };
2411        scrollContainer?.ownerDocument?.defaultView?.addEventListener(
2412          "keydown",
2413          handleKeyDown
2414        );
2415        return () => {
2416          scrollContainer?.ownerDocument?.defaultView?.removeEventListener(
2417            "keydown",
2418            handleKeyDown
2419          );
2420        };
2421      }, [
2422        totalItems,
2423        itemHeight,
2424        elementRef,
2425        fixedListWindow.visibleItems,
2426        useWindowing,
2427        options?.expandedState
2428      ]);
2429      return [fixedListWindow, setFixedListWindow];
2430    }
2431  
2432    // packages/compose/build-module/hooks/use-observable-value/index.mjs
2433    var import_element29 = __toESM(require_element(), 1);
2434    function useObservableValue(map, name) {
2435      const [subscribe, getValue] = (0, import_element29.useMemo)(
2436        () => [
2437          (listener2) => map.subscribe(name, listener2),
2438          () => map.get(name)
2439        ],
2440        [map, name]
2441      );
2442      return (0, import_element29.useSyncExternalStore)(subscribe, getValue, getValue);
2443    }
2444    return __toCommonJS(index_exports);
2445  })();


Generated : Thu Jun 18 08:20:10 2026 Cross-referenced by PHPXref