[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ var __webpack_modules__ = ({ 3 4 /***/ 6689: 5 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 6 7 "use strict"; 8 /* harmony export */ __webpack_require__.d(__webpack_exports__, { 9 /* harmony export */ createUndoManager: () => (/* binding */ createUndoManager) 10 /* harmony export */ }); 11 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(923); 12 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__); 13 /** 14 * WordPress dependencies 15 */ 16 17 18 /** @typedef {import('./types').HistoryRecord} HistoryRecord */ 19 /** @typedef {import('./types').HistoryChange} HistoryChange */ 20 /** @typedef {import('./types').HistoryChanges} HistoryChanges */ 21 /** @typedef {import('./types').UndoManager} UndoManager */ 22 23 /** 24 * Merge changes for a single item into a record of changes. 25 * 26 * @param {Record< string, HistoryChange >} changes1 Previous changes 27 * @param {Record< string, HistoryChange >} changes2 NextChanges 28 * 29 * @return {Record< string, HistoryChange >} Merged changes 30 */ 31 function mergeHistoryChanges(changes1, changes2) { 32 /** 33 * @type {Record< string, HistoryChange >} 34 */ 35 const newChanges = { 36 ...changes1 37 }; 38 Object.entries(changes2).forEach(([key, value]) => { 39 if (newChanges[key]) { 40 newChanges[key] = { 41 ...newChanges[key], 42 to: value.to 43 }; 44 } else { 45 newChanges[key] = value; 46 } 47 }); 48 return newChanges; 49 } 50 51 /** 52 * Adds history changes for a single item into a record of changes. 53 * 54 * @param {HistoryRecord} record The record to merge into. 55 * @param {HistoryChanges} changes The changes to merge. 56 */ 57 const addHistoryChangesIntoRecord = (record, changes) => { 58 const existingChangesIndex = record?.findIndex(({ 59 id: recordIdentifier 60 }) => { 61 return typeof recordIdentifier === 'string' ? recordIdentifier === changes.id : _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(recordIdentifier, changes.id); 62 }); 63 const nextRecord = [...record]; 64 if (existingChangesIndex !== -1) { 65 // If the edit is already in the stack leave the initial "from" value. 66 nextRecord[existingChangesIndex] = { 67 id: changes.id, 68 changes: mergeHistoryChanges(nextRecord[existingChangesIndex].changes, changes.changes) 69 }; 70 } else { 71 nextRecord.push(changes); 72 } 73 return nextRecord; 74 }; 75 76 /** 77 * Creates an undo manager. 78 * 79 * @return {UndoManager} Undo manager. 80 */ 81 function createUndoManager() { 82 /** 83 * @type {HistoryRecord[]} 84 */ 85 let history = []; 86 /** 87 * @type {HistoryRecord} 88 */ 89 let stagedRecord = []; 90 /** 91 * @type {number} 92 */ 93 let offset = 0; 94 const dropPendingRedos = () => { 95 history = history.slice(0, offset || undefined); 96 offset = 0; 97 }; 98 const appendStagedRecordToLatestHistoryRecord = () => { 99 var _history$index; 100 const index = history.length === 0 ? 0 : history.length - 1; 101 let latestRecord = (_history$index = history[index]) !== null && _history$index !== void 0 ? _history$index : []; 102 stagedRecord.forEach(changes => { 103 latestRecord = addHistoryChangesIntoRecord(latestRecord, changes); 104 }); 105 stagedRecord = []; 106 history[index] = latestRecord; 107 }; 108 109 /** 110 * Checks whether a record is empty. 111 * A record is considered empty if it the changes keep the same values. 112 * Also updates to function values are ignored. 113 * 114 * @param {HistoryRecord} record 115 * @return {boolean} Whether the record is empty. 116 */ 117 const isRecordEmpty = record => { 118 const filteredRecord = record.filter(({ 119 changes 120 }) => { 121 return Object.values(changes).some(({ 122 from, 123 to 124 }) => typeof from !== 'function' && typeof to !== 'function' && !_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(from, to)); 125 }); 126 return !filteredRecord.length; 127 }; 128 return { 129 /** 130 * Record changes into the history. 131 * 132 * @param {HistoryRecord=} record A record of changes to record. 133 * @param {boolean} isStaged Whether to immediately create an undo point or not. 134 */ 135 addRecord(record, isStaged = false) { 136 const isEmpty = !record || isRecordEmpty(record); 137 if (isStaged) { 138 if (isEmpty) { 139 return; 140 } 141 record.forEach(changes => { 142 stagedRecord = addHistoryChangesIntoRecord(stagedRecord, changes); 143 }); 144 } else { 145 dropPendingRedos(); 146 if (stagedRecord.length) { 147 appendStagedRecordToLatestHistoryRecord(); 148 } 149 if (isEmpty) { 150 return; 151 } 152 history.push(record); 153 } 154 }, 155 undo() { 156 if (stagedRecord.length) { 157 dropPendingRedos(); 158 appendStagedRecordToLatestHistoryRecord(); 159 } 160 const undoRecord = history[history.length - 1 + offset]; 161 if (!undoRecord) { 162 return; 163 } 164 offset -= 1; 165 return undoRecord; 166 }, 167 redo() { 168 const redoRecord = history[history.length + offset]; 169 if (!redoRecord) { 170 return; 171 } 172 offset += 1; 173 return redoRecord; 174 }, 175 hasUndo() { 176 return !!history[history.length - 1 + offset]; 177 }, 178 hasRedo() { 179 return !!history[history.length + offset]; 180 } 181 }; 182 } 183 184 185 /***/ }), 186 187 /***/ 3758: 188 /***/ (function(module) { 189 190 /*! 191 * clipboard.js v2.0.11 192 * https://clipboardjs.com/ 193 * 194 * Licensed MIT © Zeno Rocha 195 */ 196 (function webpackUniversalModuleDefinition(root, factory) { 197 if(true) 198 module.exports = factory(); 199 else {} 200 })(this, function() { 201 return /******/ (function() { // webpackBootstrap 202 /******/ var __webpack_modules__ = ({ 203 204 /***/ 686: 205 /***/ (function(__unused_webpack_module, __nested_webpack_exports__, __nested_webpack_require_623__) { 206 207 "use strict"; 208 209 // EXPORTS 210 __nested_webpack_require_623__.d(__nested_webpack_exports__, { 211 "default": function() { return /* binding */ clipboard; } 212 }); 213 214 // EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js 215 var tiny_emitter = __nested_webpack_require_623__(279); 216 var tiny_emitter_default = /*#__PURE__*/__nested_webpack_require_623__.n(tiny_emitter); 217 // EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js 218 var listen = __nested_webpack_require_623__(370); 219 var listen_default = /*#__PURE__*/__nested_webpack_require_623__.n(listen); 220 // EXTERNAL MODULE: ./node_modules/select/src/select.js 221 var src_select = __nested_webpack_require_623__(817); 222 var select_default = /*#__PURE__*/__nested_webpack_require_623__.n(src_select); 223 ;// CONCATENATED MODULE: ./src/common/command.js 224 /** 225 * Executes a given operation type. 226 * @param {String} type 227 * @return {Boolean} 228 */ 229 function command(type) { 230 try { 231 return document.execCommand(type); 232 } catch (err) { 233 return false; 234 } 235 } 236 ;// CONCATENATED MODULE: ./src/actions/cut.js 237 238 239 /** 240 * Cut action wrapper. 241 * @param {String|HTMLElement} target 242 * @return {String} 243 */ 244 245 var ClipboardActionCut = function ClipboardActionCut(target) { 246 var selectedText = select_default()(target); 247 command('cut'); 248 return selectedText; 249 }; 250 251 /* harmony default export */ var actions_cut = (ClipboardActionCut); 252 ;// CONCATENATED MODULE: ./src/common/create-fake-element.js 253 /** 254 * Creates a fake textarea element with a value. 255 * @param {String} value 256 * @return {HTMLElement} 257 */ 258 function createFakeElement(value) { 259 var isRTL = document.documentElement.getAttribute('dir') === 'rtl'; 260 var fakeElement = document.createElement('textarea'); // Prevent zooming on iOS 261 262 fakeElement.style.fontSize = '12pt'; // Reset box model 263 264 fakeElement.style.border = '0'; 265 fakeElement.style.padding = '0'; 266 fakeElement.style.margin = '0'; // Move element out of screen horizontally 267 268 fakeElement.style.position = 'absolute'; 269 fakeElement.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically 270 271 var yPosition = window.pageYOffset || document.documentElement.scrollTop; 272 fakeElement.style.top = "".concat(yPosition, "px"); 273 fakeElement.setAttribute('readonly', ''); 274 fakeElement.value = value; 275 return fakeElement; 276 } 277 ;// CONCATENATED MODULE: ./src/actions/copy.js 278 279 280 281 /** 282 * Create fake copy action wrapper using a fake element. 283 * @param {String} target 284 * @param {Object} options 285 * @return {String} 286 */ 287 288 var fakeCopyAction = function fakeCopyAction(value, options) { 289 var fakeElement = createFakeElement(value); 290 options.container.appendChild(fakeElement); 291 var selectedText = select_default()(fakeElement); 292 command('copy'); 293 fakeElement.remove(); 294 return selectedText; 295 }; 296 /** 297 * Copy action wrapper. 298 * @param {String|HTMLElement} target 299 * @param {Object} options 300 * @return {String} 301 */ 302 303 304 var ClipboardActionCopy = function ClipboardActionCopy(target) { 305 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 306 container: document.body 307 }; 308 var selectedText = ''; 309 310 if (typeof target === 'string') { 311 selectedText = fakeCopyAction(target, options); 312 } else if (target instanceof HTMLInputElement && !['text', 'search', 'url', 'tel', 'password'].includes(target === null || target === void 0 ? void 0 : target.type)) { 313 // If input type doesn't support `setSelectionRange`. Simulate it. https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange 314 selectedText = fakeCopyAction(target.value, options); 315 } else { 316 selectedText = select_default()(target); 317 command('copy'); 318 } 319 320 return selectedText; 321 }; 322 323 /* harmony default export */ var actions_copy = (ClipboardActionCopy); 324 ;// CONCATENATED MODULE: ./src/actions/default.js 325 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 326 327 328 329 /** 330 * Inner function which performs selection from either `text` or `target` 331 * properties and then executes copy or cut operations. 332 * @param {Object} options 333 */ 334 335 var ClipboardActionDefault = function ClipboardActionDefault() { 336 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 337 // Defines base properties passed from constructor. 338 var _options$action = options.action, 339 action = _options$action === void 0 ? 'copy' : _options$action, 340 container = options.container, 341 target = options.target, 342 text = options.text; // Sets the `action` to be performed which can be either 'copy' or 'cut'. 343 344 if (action !== 'copy' && action !== 'cut') { 345 throw new Error('Invalid "action" value, use either "copy" or "cut"'); 346 } // Sets the `target` property using an element that will be have its content copied. 347 348 349 if (target !== undefined) { 350 if (target && _typeof(target) === 'object' && target.nodeType === 1) { 351 if (action === 'copy' && target.hasAttribute('disabled')) { 352 throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute'); 353 } 354 355 if (action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) { 356 throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes'); 357 } 358 } else { 359 throw new Error('Invalid "target" value, use a valid Element'); 360 } 361 } // Define selection strategy based on `text` property. 362 363 364 if (text) { 365 return actions_copy(text, { 366 container: container 367 }); 368 } // Defines which selection strategy based on `target` property. 369 370 371 if (target) { 372 return action === 'cut' ? actions_cut(target) : actions_copy(target, { 373 container: container 374 }); 375 } 376 }; 377 378 /* harmony default export */ var actions_default = (ClipboardActionDefault); 379 ;// CONCATENATED MODULE: ./src/clipboard.js 380 function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); } 381 382 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 383 384 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } 385 386 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 387 388 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } 389 390 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } 391 392 function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } 393 394 function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } 395 396 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 397 398 function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } 399 400 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } 401 402 403 404 405 406 407 /** 408 * Helper function to retrieve attribute value. 409 * @param {String} suffix 410 * @param {Element} element 411 */ 412 413 function getAttributeValue(suffix, element) { 414 var attribute = "data-clipboard-".concat(suffix); 415 416 if (!element.hasAttribute(attribute)) { 417 return; 418 } 419 420 return element.getAttribute(attribute); 421 } 422 /** 423 * Base class which takes one or more elements, adds event listeners to them, 424 * and instantiates a new `ClipboardAction` on each click. 425 */ 426 427 428 var Clipboard = /*#__PURE__*/function (_Emitter) { 429 _inherits(Clipboard, _Emitter); 430 431 var _super = _createSuper(Clipboard); 432 433 /** 434 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 435 * @param {Object} options 436 */ 437 function Clipboard(trigger, options) { 438 var _this; 439 440 _classCallCheck(this, Clipboard); 441 442 _this = _super.call(this); 443 444 _this.resolveOptions(options); 445 446 _this.listenClick(trigger); 447 448 return _this; 449 } 450 /** 451 * Defines if attributes would be resolved using internal setter functions 452 * or custom functions that were passed in the constructor. 453 * @param {Object} options 454 */ 455 456 457 _createClass(Clipboard, [{ 458 key: "resolveOptions", 459 value: function resolveOptions() { 460 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 461 this.action = typeof options.action === 'function' ? options.action : this.defaultAction; 462 this.target = typeof options.target === 'function' ? options.target : this.defaultTarget; 463 this.text = typeof options.text === 'function' ? options.text : this.defaultText; 464 this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body; 465 } 466 /** 467 * Adds a click event listener to the passed trigger. 468 * @param {String|HTMLElement|HTMLCollection|NodeList} trigger 469 */ 470 471 }, { 472 key: "listenClick", 473 value: function listenClick(trigger) { 474 var _this2 = this; 475 476 this.listener = listen_default()(trigger, 'click', function (e) { 477 return _this2.onClick(e); 478 }); 479 } 480 /** 481 * Defines a new `ClipboardAction` on each click event. 482 * @param {Event} e 483 */ 484 485 }, { 486 key: "onClick", 487 value: function onClick(e) { 488 var trigger = e.delegateTarget || e.currentTarget; 489 var action = this.action(trigger) || 'copy'; 490 var text = actions_default({ 491 action: action, 492 container: this.container, 493 target: this.target(trigger), 494 text: this.text(trigger) 495 }); // Fires an event based on the copy operation result. 496 497 this.emit(text ? 'success' : 'error', { 498 action: action, 499 text: text, 500 trigger: trigger, 501 clearSelection: function clearSelection() { 502 if (trigger) { 503 trigger.focus(); 504 } 505 506 window.getSelection().removeAllRanges(); 507 } 508 }); 509 } 510 /** 511 * Default `action` lookup function. 512 * @param {Element} trigger 513 */ 514 515 }, { 516 key: "defaultAction", 517 value: function defaultAction(trigger) { 518 return getAttributeValue('action', trigger); 519 } 520 /** 521 * Default `target` lookup function. 522 * @param {Element} trigger 523 */ 524 525 }, { 526 key: "defaultTarget", 527 value: function defaultTarget(trigger) { 528 var selector = getAttributeValue('target', trigger); 529 530 if (selector) { 531 return document.querySelector(selector); 532 } 533 } 534 /** 535 * Allow fire programmatically a copy action 536 * @param {String|HTMLElement} target 537 * @param {Object} options 538 * @returns Text copied. 539 */ 540 541 }, { 542 key: "defaultText", 543 544 /** 545 * Default `text` lookup function. 546 * @param {Element} trigger 547 */ 548 value: function defaultText(trigger) { 549 return getAttributeValue('text', trigger); 550 } 551 /** 552 * Destroy lifecycle. 553 */ 554 555 }, { 556 key: "destroy", 557 value: function destroy() { 558 this.listener.destroy(); 559 } 560 }], [{ 561 key: "copy", 562 value: function copy(target) { 563 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { 564 container: document.body 565 }; 566 return actions_copy(target, options); 567 } 568 /** 569 * Allow fire programmatically a cut action 570 * @param {String|HTMLElement} target 571 * @returns Text cutted. 572 */ 573 574 }, { 575 key: "cut", 576 value: function cut(target) { 577 return actions_cut(target); 578 } 579 /** 580 * Returns the support of the given action, or all actions if no action is 581 * given. 582 * @param {String} [action] 583 */ 584 585 }, { 586 key: "isSupported", 587 value: function isSupported() { 588 var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut']; 589 var actions = typeof action === 'string' ? [action] : action; 590 var support = !!document.queryCommandSupported; 591 actions.forEach(function (action) { 592 support = support && !!document.queryCommandSupported(action); 593 }); 594 return support; 595 } 596 }]); 597 598 return Clipboard; 599 }((tiny_emitter_default())); 600 601 /* harmony default export */ var clipboard = (Clipboard); 602 603 /***/ }), 604 605 /***/ 828: 606 /***/ (function(module) { 607 608 var DOCUMENT_NODE_TYPE = 9; 609 610 /** 611 * A polyfill for Element.matches() 612 */ 613 if (typeof Element !== 'undefined' && !Element.prototype.matches) { 614 var proto = Element.prototype; 615 616 proto.matches = proto.matchesSelector || 617 proto.mozMatchesSelector || 618 proto.msMatchesSelector || 619 proto.oMatchesSelector || 620 proto.webkitMatchesSelector; 621 } 622 623 /** 624 * Finds the closest parent that matches a selector. 625 * 626 * @param {Element} element 627 * @param {String} selector 628 * @return {Function} 629 */ 630 function closest (element, selector) { 631 while (element && element.nodeType !== DOCUMENT_NODE_TYPE) { 632 if (typeof element.matches === 'function' && 633 element.matches(selector)) { 634 return element; 635 } 636 element = element.parentNode; 637 } 638 } 639 640 module.exports = closest; 641 642 643 /***/ }), 644 645 /***/ 438: 646 /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_15749__) { 647 648 var closest = __nested_webpack_require_15749__(828); 649 650 /** 651 * Delegates event to a selector. 652 * 653 * @param {Element} element 654 * @param {String} selector 655 * @param {String} type 656 * @param {Function} callback 657 * @param {Boolean} useCapture 658 * @return {Object} 659 */ 660 function _delegate(element, selector, type, callback, useCapture) { 661 var listenerFn = listener.apply(this, arguments); 662 663 element.addEventListener(type, listenerFn, useCapture); 664 665 return { 666 destroy: function() { 667 element.removeEventListener(type, listenerFn, useCapture); 668 } 669 } 670 } 671 672 /** 673 * Delegates event to a selector. 674 * 675 * @param {Element|String|Array} [elements] 676 * @param {String} selector 677 * @param {String} type 678 * @param {Function} callback 679 * @param {Boolean} useCapture 680 * @return {Object} 681 */ 682 function delegate(elements, selector, type, callback, useCapture) { 683 // Handle the regular Element usage 684 if (typeof elements.addEventListener === 'function') { 685 return _delegate.apply(null, arguments); 686 } 687 688 // Handle Element-less usage, it defaults to global delegation 689 if (typeof type === 'function') { 690 // Use `document` as the first parameter, then apply arguments 691 // This is a short way to .unshift `arguments` without running into deoptimizations 692 return _delegate.bind(null, document).apply(null, arguments); 693 } 694 695 // Handle Selector-based usage 696 if (typeof elements === 'string') { 697 elements = document.querySelectorAll(elements); 698 } 699 700 // Handle Array-like based usage 701 return Array.prototype.map.call(elements, function (element) { 702 return _delegate(element, selector, type, callback, useCapture); 703 }); 704 } 705 706 /** 707 * Finds closest match and invokes callback. 708 * 709 * @param {Element} element 710 * @param {String} selector 711 * @param {String} type 712 * @param {Function} callback 713 * @return {Function} 714 */ 715 function listener(element, selector, type, callback) { 716 return function(e) { 717 e.delegateTarget = closest(e.target, selector); 718 719 if (e.delegateTarget) { 720 callback.call(element, e); 721 } 722 } 723 } 724 725 module.exports = delegate; 726 727 728 /***/ }), 729 730 /***/ 879: 731 /***/ (function(__unused_webpack_module, exports) { 732 733 /** 734 * Check if argument is a HTML element. 735 * 736 * @param {Object} value 737 * @return {Boolean} 738 */ 739 exports.node = function(value) { 740 return value !== undefined 741 && value instanceof HTMLElement 742 && value.nodeType === 1; 743 }; 744 745 /** 746 * Check if argument is a list of HTML elements. 747 * 748 * @param {Object} value 749 * @return {Boolean} 750 */ 751 exports.nodeList = function(value) { 752 var type = Object.prototype.toString.call(value); 753 754 return value !== undefined 755 && (type === '[object NodeList]' || type === '[object HTMLCollection]') 756 && ('length' in value) 757 && (value.length === 0 || exports.node(value[0])); 758 }; 759 760 /** 761 * Check if argument is a string. 762 * 763 * @param {Object} value 764 * @return {Boolean} 765 */ 766 exports.string = function(value) { 767 return typeof value === 'string' 768 || value instanceof String; 769 }; 770 771 /** 772 * Check if argument is a function. 773 * 774 * @param {Object} value 775 * @return {Boolean} 776 */ 777 exports.fn = function(value) { 778 var type = Object.prototype.toString.call(value); 779 780 return type === '[object Function]'; 781 }; 782 783 784 /***/ }), 785 786 /***/ 370: 787 /***/ (function(module, __unused_webpack_exports, __nested_webpack_require_19113__) { 788 789 var is = __nested_webpack_require_19113__(879); 790 var delegate = __nested_webpack_require_19113__(438); 791 792 /** 793 * Validates all params and calls the right 794 * listener function based on its target type. 795 * 796 * @param {String|HTMLElement|HTMLCollection|NodeList} target 797 * @param {String} type 798 * @param {Function} callback 799 * @return {Object} 800 */ 801 function listen(target, type, callback) { 802 if (!target && !type && !callback) { 803 throw new Error('Missing required arguments'); 804 } 805 806 if (!is.string(type)) { 807 throw new TypeError('Second argument must be a String'); 808 } 809 810 if (!is.fn(callback)) { 811 throw new TypeError('Third argument must be a Function'); 812 } 813 814 if (is.node(target)) { 815 return listenNode(target, type, callback); 816 } 817 else if (is.nodeList(target)) { 818 return listenNodeList(target, type, callback); 819 } 820 else if (is.string(target)) { 821 return listenSelector(target, type, callback); 822 } 823 else { 824 throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList'); 825 } 826 } 827 828 /** 829 * Adds an event listener to a HTML element 830 * and returns a remove listener function. 831 * 832 * @param {HTMLElement} node 833 * @param {String} type 834 * @param {Function} callback 835 * @return {Object} 836 */ 837 function listenNode(node, type, callback) { 838 node.addEventListener(type, callback); 839 840 return { 841 destroy: function() { 842 node.removeEventListener(type, callback); 843 } 844 } 845 } 846 847 /** 848 * Add an event listener to a list of HTML elements 849 * and returns a remove listener function. 850 * 851 * @param {NodeList|HTMLCollection} nodeList 852 * @param {String} type 853 * @param {Function} callback 854 * @return {Object} 855 */ 856 function listenNodeList(nodeList, type, callback) { 857 Array.prototype.forEach.call(nodeList, function(node) { 858 node.addEventListener(type, callback); 859 }); 860 861 return { 862 destroy: function() { 863 Array.prototype.forEach.call(nodeList, function(node) { 864 node.removeEventListener(type, callback); 865 }); 866 } 867 } 868 } 869 870 /** 871 * Add an event listener to a selector 872 * and returns a remove listener function. 873 * 874 * @param {String} selector 875 * @param {String} type 876 * @param {Function} callback 877 * @return {Object} 878 */ 879 function listenSelector(selector, type, callback) { 880 return delegate(document.body, selector, type, callback); 881 } 882 883 module.exports = listen; 884 885 886 /***/ }), 887 888 /***/ 817: 889 /***/ (function(module) { 890 891 function select(element) { 892 var selectedText; 893 894 if (element.nodeName === 'SELECT') { 895 element.focus(); 896 897 selectedText = element.value; 898 } 899 else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { 900 var isReadOnly = element.hasAttribute('readonly'); 901 902 if (!isReadOnly) { 903 element.setAttribute('readonly', ''); 904 } 905 906 element.select(); 907 element.setSelectionRange(0, element.value.length); 908 909 if (!isReadOnly) { 910 element.removeAttribute('readonly'); 911 } 912 913 selectedText = element.value; 914 } 915 else { 916 if (element.hasAttribute('contenteditable')) { 917 element.focus(); 918 } 919 920 var selection = window.getSelection(); 921 var range = document.createRange(); 922 923 range.selectNodeContents(element); 924 selection.removeAllRanges(); 925 selection.addRange(range); 926 927 selectedText = selection.toString(); 928 } 929 930 return selectedText; 931 } 932 933 module.exports = select; 934 935 936 /***/ }), 937 938 /***/ 279: 939 /***/ (function(module) { 940 941 function E () { 942 // Keep this empty so it's easier to inherit from 943 // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3) 944 } 945 946 E.prototype = { 947 on: function (name, callback, ctx) { 948 var e = this.e || (this.e = {}); 949 950 (e[name] || (e[name] = [])).push({ 951 fn: callback, 952 ctx: ctx 953 }); 954 955 return this; 956 }, 957 958 once: function (name, callback, ctx) { 959 var self = this; 960 function listener () { 961 self.off(name, listener); 962 callback.apply(ctx, arguments); 963 }; 964 965 listener._ = callback 966 return this.on(name, listener, ctx); 967 }, 968 969 emit: function (name) { 970 var data = [].slice.call(arguments, 1); 971 var evtArr = ((this.e || (this.e = {}))[name] || []).slice(); 972 var i = 0; 973 var len = evtArr.length; 974 975 for (i; i < len; i++) { 976 evtArr[i].fn.apply(evtArr[i].ctx, data); 977 } 978 979 return this; 980 }, 981 982 off: function (name, callback) { 983 var e = this.e || (this.e = {}); 984 var evts = e[name]; 985 var liveEvents = []; 986 987 if (evts && callback) { 988 for (var i = 0, len = evts.length; i < len; i++) { 989 if (evts[i].fn !== callback && evts[i].fn._ !== callback) 990 liveEvents.push(evts[i]); 991 } 992 } 993 994 // Remove event from queue to prevent memory leak 995 // Suggested by https://github.com/lazd 996 // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910 997 998 (liveEvents.length) 999 ? e[name] = liveEvents 1000 : delete e[name]; 1001 1002 return this; 1003 } 1004 }; 1005 1006 module.exports = E; 1007 module.exports.TinyEmitter = E; 1008 1009 1010 /***/ }) 1011 1012 /******/ }); 1013 /************************************************************************/ 1014 /******/ // The module cache 1015 /******/ var __webpack_module_cache__ = {}; 1016 /******/ 1017 /******/ // The require function 1018 /******/ function __nested_webpack_require_24495__(moduleId) { 1019 /******/ // Check if module is in cache 1020 /******/ if(__webpack_module_cache__[moduleId]) { 1021 /******/ return __webpack_module_cache__[moduleId].exports; 1022 /******/ } 1023 /******/ // Create a new module (and put it into the cache) 1024 /******/ var module = __webpack_module_cache__[moduleId] = { 1025 /******/ // no module.id needed 1026 /******/ // no module.loaded needed 1027 /******/ exports: {} 1028 /******/ }; 1029 /******/ 1030 /******/ // Execute the module function 1031 /******/ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_24495__); 1032 /******/ 1033 /******/ // Return the exports of the module 1034 /******/ return module.exports; 1035 /******/ } 1036 /******/ 1037 /************************************************************************/ 1038 /******/ /* webpack/runtime/compat get default export */ 1039 /******/ !function() { 1040 /******/ // getDefaultExport function for compatibility with non-harmony modules 1041 /******/ __nested_webpack_require_24495__.n = function(module) { 1042 /******/ var getter = module && module.__esModule ? 1043 /******/ function() { return module['default']; } : 1044 /******/ function() { return module; }; 1045 /******/ __nested_webpack_require_24495__.d(getter, { a: getter }); 1046 /******/ return getter; 1047 /******/ }; 1048 /******/ }(); 1049 /******/ 1050 /******/ /* webpack/runtime/define property getters */ 1051 /******/ !function() { 1052 /******/ // define getter functions for harmony exports 1053 /******/ __nested_webpack_require_24495__.d = function(exports, definition) { 1054 /******/ for(var key in definition) { 1055 /******/ if(__nested_webpack_require_24495__.o(definition, key) && !__nested_webpack_require_24495__.o(exports, key)) { 1056 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 1057 /******/ } 1058 /******/ } 1059 /******/ }; 1060 /******/ }(); 1061 /******/ 1062 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 1063 /******/ !function() { 1064 /******/ __nested_webpack_require_24495__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 1065 /******/ }(); 1066 /******/ 1067 /************************************************************************/ 1068 /******/ // module exports must be returned from runtime so entry inlining is disabled 1069 /******/ // startup 1070 /******/ // Load entry module and return exports 1071 /******/ return __nested_webpack_require_24495__(686); 1072 /******/ })() 1073 .default; 1074 }); 1075 1076 /***/ }), 1077 1078 /***/ 1933: 1079 /***/ ((module, exports, __webpack_require__) => { 1080 1081 var __WEBPACK_AMD_DEFINE_RESULT__;/*global define:false */ 1082 /** 1083 * Copyright 2012-2017 Craig Campbell 1084 * 1085 * Licensed under the Apache License, Version 2.0 (the "License"); 1086 * you may not use this file except in compliance with the License. 1087 * You may obtain a copy of the License at 1088 * 1089 * http://www.apache.org/licenses/LICENSE-2.0 1090 * 1091 * Unless required by applicable law or agreed to in writing, software 1092 * distributed under the License is distributed on an "AS IS" BASIS, 1093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1094 * See the License for the specific language governing permissions and 1095 * limitations under the License. 1096 * 1097 * Mousetrap is a simple keyboard shortcut library for Javascript with 1098 * no external dependencies 1099 * 1100 * @version 1.6.5 1101 * @url craig.is/killing/mice 1102 */ 1103 (function(window, document, undefined) { 1104 1105 // Check if mousetrap is used inside browser, if not, return 1106 if (!window) { 1107 return; 1108 } 1109 1110 /** 1111 * mapping of special keycodes to their corresponding keys 1112 * 1113 * everything in this dictionary cannot use keypress events 1114 * so it has to be here to map to the correct keycodes for 1115 * keyup/keydown events 1116 * 1117 * @type {Object} 1118 */ 1119 var _MAP = { 1120 8: 'backspace', 1121 9: 'tab', 1122 13: 'enter', 1123 16: 'shift', 1124 17: 'ctrl', 1125 18: 'alt', 1126 20: 'capslock', 1127 27: 'esc', 1128 32: 'space', 1129 33: 'pageup', 1130 34: 'pagedown', 1131 35: 'end', 1132 36: 'home', 1133 37: 'left', 1134 38: 'up', 1135 39: 'right', 1136 40: 'down', 1137 45: 'ins', 1138 46: 'del', 1139 91: 'meta', 1140 93: 'meta', 1141 224: 'meta' 1142 }; 1143 1144 /** 1145 * mapping for special characters so they can support 1146 * 1147 * this dictionary is only used incase you want to bind a 1148 * keyup or keydown event to one of these keys 1149 * 1150 * @type {Object} 1151 */ 1152 var _KEYCODE_MAP = { 1153 106: '*', 1154 107: '+', 1155 109: '-', 1156 110: '.', 1157 111 : '/', 1158 186: ';', 1159 187: '=', 1160 188: ',', 1161 189: '-', 1162 190: '.', 1163 191: '/', 1164 192: '`', 1165 219: '[', 1166 220: '\\', 1167 221: ']', 1168 222: '\'' 1169 }; 1170 1171 /** 1172 * this is a mapping of keys that require shift on a US keypad 1173 * back to the non shift equivelents 1174 * 1175 * this is so you can use keyup events with these keys 1176 * 1177 * note that this will only work reliably on US keyboards 1178 * 1179 * @type {Object} 1180 */ 1181 var _SHIFT_MAP = { 1182 '~': '`', 1183 '!': '1', 1184 '@': '2', 1185 '#': '3', 1186 '$': '4', 1187 '%': '5', 1188 '^': '6', 1189 '&': '7', 1190 '*': '8', 1191 '(': '9', 1192 ')': '0', 1193 '_': '-', 1194 '+': '=', 1195 ':': ';', 1196 '\"': '\'', 1197 '<': ',', 1198 '>': '.', 1199 '?': '/', 1200 '|': '\\' 1201 }; 1202 1203 /** 1204 * this is a list of special strings you can use to map 1205 * to modifier keys when you specify your keyboard shortcuts 1206 * 1207 * @type {Object} 1208 */ 1209 var _SPECIAL_ALIASES = { 1210 'option': 'alt', 1211 'command': 'meta', 1212 'return': 'enter', 1213 'escape': 'esc', 1214 'plus': '+', 1215 'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl' 1216 }; 1217 1218 /** 1219 * variable to store the flipped version of _MAP from above 1220 * needed to check if we should use keypress or not when no action 1221 * is specified 1222 * 1223 * @type {Object|undefined} 1224 */ 1225 var _REVERSE_MAP; 1226 1227 /** 1228 * loop through the f keys, f1 to f19 and add them to the map 1229 * programatically 1230 */ 1231 for (var i = 1; i < 20; ++i) { 1232 _MAP[111 + i] = 'f' + i; 1233 } 1234 1235 /** 1236 * loop through to map numbers on the numeric keypad 1237 */ 1238 for (i = 0; i <= 9; ++i) { 1239 1240 // This needs to use a string cause otherwise since 0 is falsey 1241 // mousetrap will never fire for numpad 0 pressed as part of a keydown 1242 // event. 1243 // 1244 // @see https://github.com/ccampbell/mousetrap/pull/258 1245 _MAP[i + 96] = i.toString(); 1246 } 1247 1248 /** 1249 * cross browser add event method 1250 * 1251 * @param {Element|HTMLDocument} object 1252 * @param {string} type 1253 * @param {Function} callback 1254 * @returns void 1255 */ 1256 function _addEvent(object, type, callback) { 1257 if (object.addEventListener) { 1258 object.addEventListener(type, callback, false); 1259 return; 1260 } 1261 1262 object.attachEvent('on' + type, callback); 1263 } 1264 1265 /** 1266 * takes the event and returns the key character 1267 * 1268 * @param {Event} e 1269 * @return {string} 1270 */ 1271 function _characterFromEvent(e) { 1272 1273 // for keypress events we should return the character as is 1274 if (e.type == 'keypress') { 1275 var character = String.fromCharCode(e.which); 1276 1277 // if the shift key is not pressed then it is safe to assume 1278 // that we want the character to be lowercase. this means if 1279 // you accidentally have caps lock on then your key bindings 1280 // will continue to work 1281 // 1282 // the only side effect that might not be desired is if you 1283 // bind something like 'A' cause you want to trigger an 1284 // event when capital A is pressed caps lock will no longer 1285 // trigger the event. shift+a will though. 1286 if (!e.shiftKey) { 1287 character = character.toLowerCase(); 1288 } 1289 1290 return character; 1291 } 1292 1293 // for non keypress events the special maps are needed 1294 if (_MAP[e.which]) { 1295 return _MAP[e.which]; 1296 } 1297 1298 if (_KEYCODE_MAP[e.which]) { 1299 return _KEYCODE_MAP[e.which]; 1300 } 1301 1302 // if it is not in the special map 1303 1304 // with keydown and keyup events the character seems to always 1305 // come in as an uppercase character whether you are pressing shift 1306 // or not. we should make sure it is always lowercase for comparisons 1307 return String.fromCharCode(e.which).toLowerCase(); 1308 } 1309 1310 /** 1311 * checks if two arrays are equal 1312 * 1313 * @param {Array} modifiers1 1314 * @param {Array} modifiers2 1315 * @returns {boolean} 1316 */ 1317 function _modifiersMatch(modifiers1, modifiers2) { 1318 return modifiers1.sort().join(',') === modifiers2.sort().join(','); 1319 } 1320 1321 /** 1322 * takes a key event and figures out what the modifiers are 1323 * 1324 * @param {Event} e 1325 * @returns {Array} 1326 */ 1327 function _eventModifiers(e) { 1328 var modifiers = []; 1329 1330 if (e.shiftKey) { 1331 modifiers.push('shift'); 1332 } 1333 1334 if (e.altKey) { 1335 modifiers.push('alt'); 1336 } 1337 1338 if (e.ctrlKey) { 1339 modifiers.push('ctrl'); 1340 } 1341 1342 if (e.metaKey) { 1343 modifiers.push('meta'); 1344 } 1345 1346 return modifiers; 1347 } 1348 1349 /** 1350 * prevents default for this event 1351 * 1352 * @param {Event} e 1353 * @returns void 1354 */ 1355 function _preventDefault(e) { 1356 if (e.preventDefault) { 1357 e.preventDefault(); 1358 return; 1359 } 1360 1361 e.returnValue = false; 1362 } 1363 1364 /** 1365 * stops propogation for this event 1366 * 1367 * @param {Event} e 1368 * @returns void 1369 */ 1370 function _stopPropagation(e) { 1371 if (e.stopPropagation) { 1372 e.stopPropagation(); 1373 return; 1374 } 1375 1376 e.cancelBubble = true; 1377 } 1378 1379 /** 1380 * determines if the keycode specified is a modifier key or not 1381 * 1382 * @param {string} key 1383 * @returns {boolean} 1384 */ 1385 function _isModifier(key) { 1386 return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta'; 1387 } 1388 1389 /** 1390 * reverses the map lookup so that we can look for specific keys 1391 * to see what can and can't use keypress 1392 * 1393 * @return {Object} 1394 */ 1395 function _getReverseMap() { 1396 if (!_REVERSE_MAP) { 1397 _REVERSE_MAP = {}; 1398 for (var key in _MAP) { 1399 1400 // pull out the numeric keypad from here cause keypress should 1401 // be able to detect the keys from the character 1402 if (key > 95 && key < 112) { 1403 continue; 1404 } 1405 1406 if (_MAP.hasOwnProperty(key)) { 1407 _REVERSE_MAP[_MAP[key]] = key; 1408 } 1409 } 1410 } 1411 return _REVERSE_MAP; 1412 } 1413 1414 /** 1415 * picks the best action based on the key combination 1416 * 1417 * @param {string} key - character for key 1418 * @param {Array} modifiers 1419 * @param {string=} action passed in 1420 */ 1421 function _pickBestAction(key, modifiers, action) { 1422 1423 // if no action was picked in we should try to pick the one 1424 // that we think would work best for this key 1425 if (!action) { 1426 action = _getReverseMap()[key] ? 'keydown' : 'keypress'; 1427 } 1428 1429 // modifier keys don't work as expected with keypress, 1430 // switch to keydown 1431 if (action == 'keypress' && modifiers.length) { 1432 action = 'keydown'; 1433 } 1434 1435 return action; 1436 } 1437 1438 /** 1439 * Converts from a string key combination to an array 1440 * 1441 * @param {string} combination like "command+shift+l" 1442 * @return {Array} 1443 */ 1444 function _keysFromString(combination) { 1445 if (combination === '+') { 1446 return ['+']; 1447 } 1448 1449 combination = combination.replace(/\+{2}/g, '+plus'); 1450 return combination.split('+'); 1451 } 1452 1453 /** 1454 * Gets info for a specific key combination 1455 * 1456 * @param {string} combination key combination ("command+s" or "a" or "*") 1457 * @param {string=} action 1458 * @returns {Object} 1459 */ 1460 function _getKeyInfo(combination, action) { 1461 var keys; 1462 var key; 1463 var i; 1464 var modifiers = []; 1465 1466 // take the keys from this pattern and figure out what the actual 1467 // pattern is all about 1468 keys = _keysFromString(combination); 1469 1470 for (i = 0; i < keys.length; ++i) { 1471 key = keys[i]; 1472 1473 // normalize key names 1474 if (_SPECIAL_ALIASES[key]) { 1475 key = _SPECIAL_ALIASES[key]; 1476 } 1477 1478 // if this is not a keypress event then we should 1479 // be smart about using shift keys 1480 // this will only work for US keyboards however 1481 if (action && action != 'keypress' && _SHIFT_MAP[key]) { 1482 key = _SHIFT_MAP[key]; 1483 modifiers.push('shift'); 1484 } 1485 1486 // if this key is a modifier then add it to the list of modifiers 1487 if (_isModifier(key)) { 1488 modifiers.push(key); 1489 } 1490 } 1491 1492 // depending on what the key combination is 1493 // we will try to pick the best event for it 1494 action = _pickBestAction(key, modifiers, action); 1495 1496 return { 1497 key: key, 1498 modifiers: modifiers, 1499 action: action 1500 }; 1501 } 1502 1503 function _belongsTo(element, ancestor) { 1504 if (element === null || element === document) { 1505 return false; 1506 } 1507 1508 if (element === ancestor) { 1509 return true; 1510 } 1511 1512 return _belongsTo(element.parentNode, ancestor); 1513 } 1514 1515 function Mousetrap(targetElement) { 1516 var self = this; 1517 1518 targetElement = targetElement || document; 1519 1520 if (!(self instanceof Mousetrap)) { 1521 return new Mousetrap(targetElement); 1522 } 1523 1524 /** 1525 * element to attach key events to 1526 * 1527 * @type {Element} 1528 */ 1529 self.target = targetElement; 1530 1531 /** 1532 * a list of all the callbacks setup via Mousetrap.bind() 1533 * 1534 * @type {Object} 1535 */ 1536 self._callbacks = {}; 1537 1538 /** 1539 * direct map of string combinations to callbacks used for trigger() 1540 * 1541 * @type {Object} 1542 */ 1543 self._directMap = {}; 1544 1545 /** 1546 * keeps track of what level each sequence is at since multiple 1547 * sequences can start out with the same sequence 1548 * 1549 * @type {Object} 1550 */ 1551 var _sequenceLevels = {}; 1552 1553 /** 1554 * variable to store the setTimeout call 1555 * 1556 * @type {null|number} 1557 */ 1558 var _resetTimer; 1559 1560 /** 1561 * temporary state where we will ignore the next keyup 1562 * 1563 * @type {boolean|string} 1564 */ 1565 var _ignoreNextKeyup = false; 1566 1567 /** 1568 * temporary state where we will ignore the next keypress 1569 * 1570 * @type {boolean} 1571 */ 1572 var _ignoreNextKeypress = false; 1573 1574 /** 1575 * are we currently inside of a sequence? 1576 * type of action ("keyup" or "keydown" or "keypress") or false 1577 * 1578 * @type {boolean|string} 1579 */ 1580 var _nextExpectedAction = false; 1581 1582 /** 1583 * resets all sequence counters except for the ones passed in 1584 * 1585 * @param {Object} doNotReset 1586 * @returns void 1587 */ 1588 function _resetSequences(doNotReset) { 1589 doNotReset = doNotReset || {}; 1590 1591 var activeSequences = false, 1592 key; 1593 1594 for (key in _sequenceLevels) { 1595 if (doNotReset[key]) { 1596 activeSequences = true; 1597 continue; 1598 } 1599 _sequenceLevels[key] = 0; 1600 } 1601 1602 if (!activeSequences) { 1603 _nextExpectedAction = false; 1604 } 1605 } 1606 1607 /** 1608 * finds all callbacks that match based on the keycode, modifiers, 1609 * and action 1610 * 1611 * @param {string} character 1612 * @param {Array} modifiers 1613 * @param {Event|Object} e 1614 * @param {string=} sequenceName - name of the sequence we are looking for 1615 * @param {string=} combination 1616 * @param {number=} level 1617 * @returns {Array} 1618 */ 1619 function _getMatches(character, modifiers, e, sequenceName, combination, level) { 1620 var i; 1621 var callback; 1622 var matches = []; 1623 var action = e.type; 1624 1625 // if there are no events related to this keycode 1626 if (!self._callbacks[character]) { 1627 return []; 1628 } 1629 1630 // if a modifier key is coming up on its own we should allow it 1631 if (action == 'keyup' && _isModifier(character)) { 1632 modifiers = [character]; 1633 } 1634 1635 // loop through all callbacks for the key that was pressed 1636 // and see if any of them match 1637 for (i = 0; i < self._callbacks[character].length; ++i) { 1638 callback = self._callbacks[character][i]; 1639 1640 // if a sequence name is not specified, but this is a sequence at 1641 // the wrong level then move onto the next match 1642 if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) { 1643 continue; 1644 } 1645 1646 // if the action we are looking for doesn't match the action we got 1647 // then we should keep going 1648 if (action != callback.action) { 1649 continue; 1650 } 1651 1652 // if this is a keypress event and the meta key and control key 1653 // are not pressed that means that we need to only look at the 1654 // character, otherwise check the modifiers as well 1655 // 1656 // chrome will not fire a keypress if meta or control is down 1657 // safari will fire a keypress if meta or meta+shift is down 1658 // firefox will fire a keypress if meta or control is down 1659 if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) { 1660 1661 // when you bind a combination or sequence a second time it 1662 // should overwrite the first one. if a sequenceName or 1663 // combination is specified in this call it does just that 1664 // 1665 // @todo make deleting its own method? 1666 var deleteCombo = !sequenceName && callback.combo == combination; 1667 var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level; 1668 if (deleteCombo || deleteSequence) { 1669 self._callbacks[character].splice(i, 1); 1670 } 1671 1672 matches.push(callback); 1673 } 1674 } 1675 1676 return matches; 1677 } 1678 1679 /** 1680 * actually calls the callback function 1681 * 1682 * if your callback function returns false this will use the jquery 1683 * convention - prevent default and stop propogation on the event 1684 * 1685 * @param {Function} callback 1686 * @param {Event} e 1687 * @returns void 1688 */ 1689 function _fireCallback(callback, e, combo, sequence) { 1690 1691 // if this event should not happen stop here 1692 if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) { 1693 return; 1694 } 1695 1696 if (callback(e, combo) === false) { 1697 _preventDefault(e); 1698 _stopPropagation(e); 1699 } 1700 } 1701 1702 /** 1703 * handles a character key event 1704 * 1705 * @param {string} character 1706 * @param {Array} modifiers 1707 * @param {Event} e 1708 * @returns void 1709 */ 1710 self._handleKey = function(character, modifiers, e) { 1711 var callbacks = _getMatches(character, modifiers, e); 1712 var i; 1713 var doNotReset = {}; 1714 var maxLevel = 0; 1715 var processedSequenceCallback = false; 1716 1717 // Calculate the maxLevel for sequences so we can only execute the longest callback sequence 1718 for (i = 0; i < callbacks.length; ++i) { 1719 if (callbacks[i].seq) { 1720 maxLevel = Math.max(maxLevel, callbacks[i].level); 1721 } 1722 } 1723 1724 // loop through matching callbacks for this key event 1725 for (i = 0; i < callbacks.length; ++i) { 1726 1727 // fire for all sequence callbacks 1728 // this is because if for example you have multiple sequences 1729 // bound such as "g i" and "g t" they both need to fire the 1730 // callback for matching g cause otherwise you can only ever 1731 // match the first one 1732 if (callbacks[i].seq) { 1733 1734 // only fire callbacks for the maxLevel to prevent 1735 // subsequences from also firing 1736 // 1737 // for example 'a option b' should not cause 'option b' to fire 1738 // even though 'option b' is part of the other sequence 1739 // 1740 // any sequences that do not match here will be discarded 1741 // below by the _resetSequences call 1742 if (callbacks[i].level != maxLevel) { 1743 continue; 1744 } 1745 1746 processedSequenceCallback = true; 1747 1748 // keep a list of which sequences were matches for later 1749 doNotReset[callbacks[i].seq] = 1; 1750 _fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq); 1751 continue; 1752 } 1753 1754 // if there were no sequence matches but we are still here 1755 // that means this is a regular match so we should fire that 1756 if (!processedSequenceCallback) { 1757 _fireCallback(callbacks[i].callback, e, callbacks[i].combo); 1758 } 1759 } 1760 1761 // if the key you pressed matches the type of sequence without 1762 // being a modifier (ie "keyup" or "keypress") then we should 1763 // reset all sequences that were not matched by this event 1764 // 1765 // this is so, for example, if you have the sequence "h a t" and you 1766 // type "h e a r t" it does not match. in this case the "e" will 1767 // cause the sequence to reset 1768 // 1769 // modifier keys are ignored because you can have a sequence 1770 // that contains modifiers such as "enter ctrl+space" and in most 1771 // cases the modifier key will be pressed before the next key 1772 // 1773 // also if you have a sequence such as "ctrl+b a" then pressing the 1774 // "b" key will trigger a "keypress" and a "keydown" 1775 // 1776 // the "keydown" is expected when there is a modifier, but the 1777 // "keypress" ends up matching the _nextExpectedAction since it occurs 1778 // after and that causes the sequence to reset 1779 // 1780 // we ignore keypresses in a sequence that directly follow a keydown 1781 // for the same character 1782 var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress; 1783 if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) { 1784 _resetSequences(doNotReset); 1785 } 1786 1787 _ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown'; 1788 }; 1789 1790 /** 1791 * handles a keydown event 1792 * 1793 * @param {Event} e 1794 * @returns void 1795 */ 1796 function _handleKeyEvent(e) { 1797 1798 // normalize e.which for key events 1799 // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion 1800 if (typeof e.which !== 'number') { 1801 e.which = e.keyCode; 1802 } 1803 1804 var character = _characterFromEvent(e); 1805 1806 // no character found then stop 1807 if (!character) { 1808 return; 1809 } 1810 1811 // need to use === for the character check because the character can be 0 1812 if (e.type == 'keyup' && _ignoreNextKeyup === character) { 1813 _ignoreNextKeyup = false; 1814 return; 1815 } 1816 1817 self.handleKey(character, _eventModifiers(e), e); 1818 } 1819 1820 /** 1821 * called to set a 1 second timeout on the specified sequence 1822 * 1823 * this is so after each key press in the sequence you have 1 second 1824 * to press the next key before you have to start over 1825 * 1826 * @returns void 1827 */ 1828 function _resetSequenceTimer() { 1829 clearTimeout(_resetTimer); 1830 _resetTimer = setTimeout(_resetSequences, 1000); 1831 } 1832 1833 /** 1834 * binds a key sequence to an event 1835 * 1836 * @param {string} combo - combo specified in bind call 1837 * @param {Array} keys 1838 * @param {Function} callback 1839 * @param {string=} action 1840 * @returns void 1841 */ 1842 function _bindSequence(combo, keys, callback, action) { 1843 1844 // start off by adding a sequence level record for this combination 1845 // and setting the level to 0 1846 _sequenceLevels[combo] = 0; 1847 1848 /** 1849 * callback to increase the sequence level for this sequence and reset 1850 * all other sequences that were active 1851 * 1852 * @param {string} nextAction 1853 * @returns {Function} 1854 */ 1855 function _increaseSequence(nextAction) { 1856 return function() { 1857 _nextExpectedAction = nextAction; 1858 ++_sequenceLevels[combo]; 1859 _resetSequenceTimer(); 1860 }; 1861 } 1862 1863 /** 1864 * wraps the specified callback inside of another function in order 1865 * to reset all sequence counters as soon as this sequence is done 1866 * 1867 * @param {Event} e 1868 * @returns void 1869 */ 1870 function _callbackAndReset(e) { 1871 _fireCallback(callback, e, combo); 1872 1873 // we should ignore the next key up if the action is key down 1874 // or keypress. this is so if you finish a sequence and 1875 // release the key the final key will not trigger a keyup 1876 if (action !== 'keyup') { 1877 _ignoreNextKeyup = _characterFromEvent(e); 1878 } 1879 1880 // weird race condition if a sequence ends with the key 1881 // another sequence begins with 1882 setTimeout(_resetSequences, 10); 1883 } 1884 1885 // loop through keys one at a time and bind the appropriate callback 1886 // function. for any key leading up to the final one it should 1887 // increase the sequence. after the final, it should reset all sequences 1888 // 1889 // if an action is specified in the original bind call then that will 1890 // be used throughout. otherwise we will pass the action that the 1891 // next key in the sequence should match. this allows a sequence 1892 // to mix and match keypress and keydown events depending on which 1893 // ones are better suited to the key provided 1894 for (var i = 0; i < keys.length; ++i) { 1895 var isFinal = i + 1 === keys.length; 1896 var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action); 1897 _bindSingle(keys[i], wrappedCallback, action, combo, i); 1898 } 1899 } 1900 1901 /** 1902 * binds a single keyboard combination 1903 * 1904 * @param {string} combination 1905 * @param {Function} callback 1906 * @param {string=} action 1907 * @param {string=} sequenceName - name of sequence if part of sequence 1908 * @param {number=} level - what part of the sequence the command is 1909 * @returns void 1910 */ 1911 function _bindSingle(combination, callback, action, sequenceName, level) { 1912 1913 // store a direct mapped reference for use with Mousetrap.trigger 1914 self._directMap[combination + ':' + action] = callback; 1915 1916 // make sure multiple spaces in a row become a single space 1917 combination = combination.replace(/\s+/g, ' '); 1918 1919 var sequence = combination.split(' '); 1920 var info; 1921 1922 // if this pattern is a sequence of keys then run through this method 1923 // to reprocess each pattern one key at a time 1924 if (sequence.length > 1) { 1925 _bindSequence(combination, sequence, callback, action); 1926 return; 1927 } 1928 1929 info = _getKeyInfo(combination, action); 1930 1931 // make sure to initialize array if this is the first time 1932 // a callback is added for this key 1933 self._callbacks[info.key] = self._callbacks[info.key] || []; 1934 1935 // remove an existing match if there is one 1936 _getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level); 1937 1938 // add this call back to the array 1939 // if it is a sequence put it at the beginning 1940 // if not put it at the end 1941 // 1942 // this is important because the way these are processed expects 1943 // the sequence ones to come first 1944 self._callbacks[info.key][sequenceName ? 'unshift' : 'push']({ 1945 callback: callback, 1946 modifiers: info.modifiers, 1947 action: info.action, 1948 seq: sequenceName, 1949 level: level, 1950 combo: combination 1951 }); 1952 } 1953 1954 /** 1955 * binds multiple combinations to the same callback 1956 * 1957 * @param {Array} combinations 1958 * @param {Function} callback 1959 * @param {string|undefined} action 1960 * @returns void 1961 */ 1962 self._bindMultiple = function(combinations, callback, action) { 1963 for (var i = 0; i < combinations.length; ++i) { 1964 _bindSingle(combinations[i], callback, action); 1965 } 1966 }; 1967 1968 // start! 1969 _addEvent(targetElement, 'keypress', _handleKeyEvent); 1970 _addEvent(targetElement, 'keydown', _handleKeyEvent); 1971 _addEvent(targetElement, 'keyup', _handleKeyEvent); 1972 } 1973 1974 /** 1975 * binds an event to mousetrap 1976 * 1977 * can be a single key, a combination of keys separated with +, 1978 * an array of keys, or a sequence of keys separated by spaces 1979 * 1980 * be sure to list the modifier keys first to make sure that the 1981 * correct key ends up getting bound (the last key in the pattern) 1982 * 1983 * @param {string|Array} keys 1984 * @param {Function} callback 1985 * @param {string=} action - 'keypress', 'keydown', or 'keyup' 1986 * @returns void 1987 */ 1988 Mousetrap.prototype.bind = function(keys, callback, action) { 1989 var self = this; 1990 keys = keys instanceof Array ? keys : [keys]; 1991 self._bindMultiple.call(self, keys, callback, action); 1992 return self; 1993 }; 1994 1995 /** 1996 * unbinds an event to mousetrap 1997 * 1998 * the unbinding sets the callback function of the specified key combo 1999 * to an empty function and deletes the corresponding key in the 2000 * _directMap dict. 2001 * 2002 * TODO: actually remove this from the _callbacks dictionary instead 2003 * of binding an empty function 2004 * 2005 * the keycombo+action has to be exactly the same as 2006 * it was defined in the bind method 2007 * 2008 * @param {string|Array} keys 2009 * @param {string} action 2010 * @returns void 2011 */ 2012 Mousetrap.prototype.unbind = function(keys, action) { 2013 var self = this; 2014 return self.bind.call(self, keys, function() {}, action); 2015 }; 2016 2017 /** 2018 * triggers an event that has already been bound 2019 * 2020 * @param {string} keys 2021 * @param {string=} action 2022 * @returns void 2023 */ 2024 Mousetrap.prototype.trigger = function(keys, action) { 2025 var self = this; 2026 if (self._directMap[keys + ':' + action]) { 2027 self._directMap[keys + ':' + action]({}, keys); 2028 } 2029 return self; 2030 }; 2031 2032 /** 2033 * resets the library back to its initial state. this is useful 2034 * if you want to clear out the current keyboard shortcuts and bind 2035 * new ones - for example if you switch to another page 2036 * 2037 * @returns void 2038 */ 2039 Mousetrap.prototype.reset = function() { 2040 var self = this; 2041 self._callbacks = {}; 2042 self._directMap = {}; 2043 return self; 2044 }; 2045 2046 /** 2047 * should we stop this event before firing off callbacks 2048 * 2049 * @param {Event} e 2050 * @param {Element} element 2051 * @return {boolean} 2052 */ 2053 Mousetrap.prototype.stopCallback = function(e, element) { 2054 var self = this; 2055 2056 // if the element has the class "mousetrap" then no need to stop 2057 if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) { 2058 return false; 2059 } 2060 2061 if (_belongsTo(element, self.target)) { 2062 return false; 2063 } 2064 2065 // Events originating from a shadow DOM are re-targetted and `e.target` is the shadow host, 2066 // not the initial event target in the shadow tree. Note that not all events cross the 2067 // shadow boundary. 2068 // For shadow trees with `mode: 'open'`, the initial event target is the first element in 2069 // the event’s composed path. For shadow trees with `mode: 'closed'`, the initial event 2070 // target cannot be obtained. 2071 if ('composedPath' in e && typeof e.composedPath === 'function') { 2072 // For open shadow trees, update `element` so that the following check works. 2073 var initialEventTarget = e.composedPath()[0]; 2074 if (initialEventTarget !== e.target) { 2075 element = initialEventTarget; 2076 } 2077 } 2078 2079 // stop for input, select, and textarea 2080 return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable; 2081 }; 2082 2083 /** 2084 * exposes _handleKey publicly so it can be overwritten by extensions 2085 */ 2086 Mousetrap.prototype.handleKey = function() { 2087 var self = this; 2088 return self._handleKey.apply(self, arguments); 2089 }; 2090 2091 /** 2092 * allow custom key mappings 2093 */ 2094 Mousetrap.addKeycodes = function(object) { 2095 for (var key in object) { 2096 if (object.hasOwnProperty(key)) { 2097 _MAP[key] = object[key]; 2098 } 2099 } 2100 _REVERSE_MAP = null; 2101 }; 2102 2103 /** 2104 * Init the global mousetrap functions 2105 * 2106 * This method is needed to allow the global mousetrap functions to work 2107 * now that mousetrap is a constructor function. 2108 */ 2109 Mousetrap.init = function() { 2110 var documentMousetrap = Mousetrap(document); 2111 for (var method in documentMousetrap) { 2112 if (method.charAt(0) !== '_') { 2113 Mousetrap[method] = (function(method) { 2114 return function() { 2115 return documentMousetrap[method].apply(documentMousetrap, arguments); 2116 }; 2117 } (method)); 2118 } 2119 } 2120 }; 2121 2122 Mousetrap.init(); 2123 2124 // expose mousetrap to the global object 2125 window.Mousetrap = Mousetrap; 2126 2127 // expose as a common js module 2128 if ( true && module.exports) { 2129 module.exports = Mousetrap; 2130 } 2131 2132 // expose mousetrap as an AMD module 2133 if (true) { 2134 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 2135 return Mousetrap; 2136 }).call(exports, __webpack_require__, exports, module), 2137 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 2138 } 2139 }) (typeof window !== 'undefined' ? window : null, typeof window !== 'undefined' ? document : null); 2140 2141 2142 /***/ }), 2143 2144 /***/ 5760: 2145 /***/ (() => { 2146 2147 /** 2148 * adds a bindGlobal method to Mousetrap that allows you to 2149 * bind specific keyboard shortcuts that will still work 2150 * inside a text input field 2151 * 2152 * usage: 2153 * Mousetrap.bindGlobal('ctrl+s', _saveChanges); 2154 */ 2155 /* global Mousetrap:true */ 2156 (function(Mousetrap) { 2157 if (! Mousetrap) { 2158 return; 2159 } 2160 var _globalCallbacks = {}; 2161 var _originalStopCallback = Mousetrap.prototype.stopCallback; 2162 2163 Mousetrap.prototype.stopCallback = function(e, element, combo, sequence) { 2164 var self = this; 2165 2166 if (self.paused) { 2167 return true; 2168 } 2169 2170 if (_globalCallbacks[combo] || _globalCallbacks[sequence]) { 2171 return false; 2172 } 2173 2174 return _originalStopCallback.call(self, e, element, combo); 2175 }; 2176 2177 Mousetrap.prototype.bindGlobal = function(keys, callback, action) { 2178 var self = this; 2179 self.bind(keys, callback, action); 2180 2181 if (keys instanceof Array) { 2182 for (var i = 0; i < keys.length; i++) { 2183 _globalCallbacks[keys[i]] = true; 2184 } 2185 return; 2186 } 2187 2188 _globalCallbacks[keys] = true; 2189 }; 2190 2191 Mousetrap.init(); 2192 }) (typeof Mousetrap !== "undefined" ? Mousetrap : undefined); 2193 2194 2195 /***/ }), 2196 2197 /***/ 923: 2198 /***/ ((module) => { 2199 2200 "use strict"; 2201 module.exports = window["wp"]["isShallowEqual"]; 2202 2203 /***/ }) 2204 2205 /******/ }); 2206 /************************************************************************/ 2207 /******/ // The module cache 2208 /******/ var __webpack_module_cache__ = {}; 2209 /******/ 2210 /******/ // The require function 2211 /******/ function __webpack_require__(moduleId) { 2212 /******/ // Check if module is in cache 2213 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 2214 /******/ if (cachedModule !== undefined) { 2215 /******/ return cachedModule.exports; 2216 /******/ } 2217 /******/ // Create a new module (and put it into the cache) 2218 /******/ var module = __webpack_module_cache__[moduleId] = { 2219 /******/ // no module.id needed 2220 /******/ // no module.loaded needed 2221 /******/ exports: {} 2222 /******/ }; 2223 /******/ 2224 /******/ // Execute the module function 2225 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 2226 /******/ 2227 /******/ // Return the exports of the module 2228 /******/ return module.exports; 2229 /******/ } 2230 /******/ 2231 /************************************************************************/ 2232 /******/ /* webpack/runtime/compat get default export */ 2233 /******/ (() => { 2234 /******/ // getDefaultExport function for compatibility with non-harmony modules 2235 /******/ __webpack_require__.n = (module) => { 2236 /******/ var getter = module && module.__esModule ? 2237 /******/ () => (module['default']) : 2238 /******/ () => (module); 2239 /******/ __webpack_require__.d(getter, { a: getter }); 2240 /******/ return getter; 2241 /******/ }; 2242 /******/ })(); 2243 /******/ 2244 /******/ /* webpack/runtime/define property getters */ 2245 /******/ (() => { 2246 /******/ // define getter functions for harmony exports 2247 /******/ __webpack_require__.d = (exports, definition) => { 2248 /******/ for(var key in definition) { 2249 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 2250 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 2251 /******/ } 2252 /******/ } 2253 /******/ }; 2254 /******/ })(); 2255 /******/ 2256 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 2257 /******/ (() => { 2258 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 2259 /******/ })(); 2260 /******/ 2261 /******/ /* webpack/runtime/make namespace object */ 2262 /******/ (() => { 2263 /******/ // define __esModule on exports 2264 /******/ __webpack_require__.r = (exports) => { 2265 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 2266 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 2267 /******/ } 2268 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 2269 /******/ }; 2270 /******/ })(); 2271 /******/ 2272 /************************************************************************/ 2273 var __webpack_exports__ = {}; 2274 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode. 2275 (() => { 2276 "use strict"; 2277 // ESM COMPAT FLAG 2278 __webpack_require__.r(__webpack_exports__); 2279 2280 // EXPORTS 2281 __webpack_require__.d(__webpack_exports__, { 2282 __experimentalUseDialog: () => (/* reexport */ use_dialog), 2283 __experimentalUseDragging: () => (/* reexport */ useDragging), 2284 __experimentalUseDropZone: () => (/* reexport */ useDropZone), 2285 __experimentalUseFixedWindowList: () => (/* reexport */ useFixedWindowList), 2286 __experimentalUseFocusOutside: () => (/* reexport */ useFocusOutside), 2287 compose: () => (/* reexport */ higher_order_compose), 2288 createHigherOrderComponent: () => (/* reexport */ createHigherOrderComponent), 2289 debounce: () => (/* reexport */ debounce), 2290 ifCondition: () => (/* reexport */ if_condition), 2291 observableMap: () => (/* reexport */ observableMap), 2292 pipe: () => (/* reexport */ higher_order_pipe), 2293 pure: () => (/* reexport */ higher_order_pure), 2294 throttle: () => (/* reexport */ throttle), 2295 useAsyncList: () => (/* reexport */ use_async_list), 2296 useConstrainedTabbing: () => (/* reexport */ use_constrained_tabbing), 2297 useCopyOnClick: () => (/* reexport */ useCopyOnClick), 2298 useCopyToClipboard: () => (/* reexport */ useCopyToClipboard), 2299 useDebounce: () => (/* reexport */ useDebounce), 2300 useDebouncedInput: () => (/* reexport */ useDebouncedInput), 2301 useDisabled: () => (/* reexport */ useDisabled), 2302 useEvent: () => (/* reexport */ useEvent), 2303 useFocusOnMount: () => (/* reexport */ useFocusOnMount), 2304 useFocusReturn: () => (/* reexport */ use_focus_return), 2305 useFocusableIframe: () => (/* reexport */ useFocusableIframe), 2306 useInstanceId: () => (/* reexport */ use_instance_id), 2307 useIsomorphicLayoutEffect: () => (/* reexport */ use_isomorphic_layout_effect), 2308 useKeyboardShortcut: () => (/* reexport */ use_keyboard_shortcut), 2309 useMediaQuery: () => (/* reexport */ useMediaQuery), 2310 useMergeRefs: () => (/* reexport */ useMergeRefs), 2311 useObservableValue: () => (/* reexport */ useObservableValue), 2312 usePrevious: () => (/* reexport */ usePrevious), 2313 useReducedMotion: () => (/* reexport */ use_reduced_motion), 2314 useRefEffect: () => (/* reexport */ useRefEffect), 2315 useResizeObserver: () => (/* reexport */ use_resize_observer_useResizeObserver), 2316 useStateWithHistory: () => (/* reexport */ useStateWithHistory), 2317 useThrottle: () => (/* reexport */ useThrottle), 2318 useViewportMatch: () => (/* reexport */ use_viewport_match), 2319 useWarnOnChange: () => (/* reexport */ use_warn_on_change), 2320 withGlobalEvents: () => (/* reexport */ withGlobalEvents), 2321 withInstanceId: () => (/* reexport */ with_instance_id), 2322 withSafeTimeout: () => (/* reexport */ with_safe_timeout), 2323 withState: () => (/* reexport */ withState) 2324 }); 2325 2326 ;// ./node_modules/tslib/tslib.es6.mjs 2327 /****************************************************************************** 2328 Copyright (c) Microsoft Corporation. 2329 2330 Permission to use, copy, modify, and/or distribute this software for any 2331 purpose with or without fee is hereby granted. 2332 2333 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 2334 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 2335 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 2336 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 2337 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 2338 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 2339 PERFORMANCE OF THIS SOFTWARE. 2340 ***************************************************************************** */ 2341 /* global Reflect, Promise, SuppressedError, Symbol, Iterator */ 2342 2343 var extendStatics = function(d, b) { 2344 extendStatics = Object.setPrototypeOf || 2345 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 2346 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 2347 return extendStatics(d, b); 2348 }; 2349 2350 function __extends(d, b) { 2351 if (typeof b !== "function" && b !== null) 2352 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 2353 extendStatics(d, b); 2354 function __() { this.constructor = d; } 2355 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 2356 } 2357 2358 var __assign = function() { 2359 __assign = Object.assign || function __assign(t) { 2360 for (var s, i = 1, n = arguments.length; i < n; i++) { 2361 s = arguments[i]; 2362 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 2363 } 2364 return t; 2365 } 2366 return __assign.apply(this, arguments); 2367 } 2368 2369 function __rest(s, e) { 2370 var t = {}; 2371 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 2372 t[p] = s[p]; 2373 if (s != null && typeof Object.getOwnPropertySymbols === "function") 2374 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 2375 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 2376 t[p[i]] = s[p[i]]; 2377 } 2378 return t; 2379 } 2380 2381 function __decorate(decorators, target, key, desc) { 2382 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 2383 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 2384 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 2385 return c > 3 && r && Object.defineProperty(target, key, r), r; 2386 } 2387 2388 function __param(paramIndex, decorator) { 2389 return function (target, key) { decorator(target, key, paramIndex); } 2390 } 2391 2392 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { 2393 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } 2394 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; 2395 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; 2396 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); 2397 var _, done = false; 2398 for (var i = decorators.length - 1; i >= 0; i--) { 2399 var context = {}; 2400 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; 2401 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; 2402 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; 2403 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); 2404 if (kind === "accessor") { 2405 if (result === void 0) continue; 2406 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); 2407 if (_ = accept(result.get)) descriptor.get = _; 2408 if (_ = accept(result.set)) descriptor.set = _; 2409 if (_ = accept(result.init)) initializers.unshift(_); 2410 } 2411 else if (_ = accept(result)) { 2412 if (kind === "field") initializers.unshift(_); 2413 else descriptor[key] = _; 2414 } 2415 } 2416 if (target) Object.defineProperty(target, contextIn.name, descriptor); 2417 done = true; 2418 }; 2419 2420 function __runInitializers(thisArg, initializers, value) { 2421 var useValue = arguments.length > 2; 2422 for (var i = 0; i < initializers.length; i++) { 2423 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); 2424 } 2425 return useValue ? value : void 0; 2426 }; 2427 2428 function __propKey(x) { 2429 return typeof x === "symbol" ? x : "".concat(x); 2430 }; 2431 2432 function __setFunctionName(f, name, prefix) { 2433 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; 2434 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); 2435 }; 2436 2437 function __metadata(metadataKey, metadataValue) { 2438 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 2439 } 2440 2441 function __awaiter(thisArg, _arguments, P, generator) { 2442 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 2443 return new (P || (P = Promise))(function (resolve, reject) { 2444 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 2445 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 2446 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 2447 step((generator = generator.apply(thisArg, _arguments || [])).next()); 2448 }); 2449 } 2450 2451 function __generator(thisArg, body) { 2452 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype); 2453 return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 2454 function verb(n) { return function (v) { return step([n, v]); }; } 2455 function step(op) { 2456 if (f) throw new TypeError("Generator is already executing."); 2457 while (g && (g = 0, op[0] && (_ = 0)), _) try { 2458 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 2459 if (y = 0, t) op = [op[0] & 2, t.value]; 2460 switch (op[0]) { 2461 case 0: case 1: t = op; break; 2462 case 4: _.label++; return { value: op[1], done: false }; 2463 case 5: _.label++; y = op[1]; op = [0]; continue; 2464 case 7: op = _.ops.pop(); _.trys.pop(); continue; 2465 default: 2466 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 2467 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 2468 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 2469 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 2470 if (t[2]) _.ops.pop(); 2471 _.trys.pop(); continue; 2472 } 2473 op = body.call(thisArg, _); 2474 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 2475 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 2476 } 2477 } 2478 2479 var __createBinding = Object.create ? (function(o, m, k, k2) { 2480 if (k2 === undefined) k2 = k; 2481 var desc = Object.getOwnPropertyDescriptor(m, k); 2482 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 2483 desc = { enumerable: true, get: function() { return m[k]; } }; 2484 } 2485 Object.defineProperty(o, k2, desc); 2486 }) : (function(o, m, k, k2) { 2487 if (k2 === undefined) k2 = k; 2488 o[k2] = m[k]; 2489 }); 2490 2491 function __exportStar(m, o) { 2492 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); 2493 } 2494 2495 function __values(o) { 2496 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; 2497 if (m) return m.call(o); 2498 if (o && typeof o.length === "number") return { 2499 next: function () { 2500 if (o && i >= o.length) o = void 0; 2501 return { value: o && o[i++], done: !o }; 2502 } 2503 }; 2504 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); 2505 } 2506 2507 function __read(o, n) { 2508 var m = typeof Symbol === "function" && o[Symbol.iterator]; 2509 if (!m) return o; 2510 var i = m.call(o), r, ar = [], e; 2511 try { 2512 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 2513 } 2514 catch (error) { e = { error: error }; } 2515 finally { 2516 try { 2517 if (r && !r.done && (m = i["return"])) m.call(i); 2518 } 2519 finally { if (e) throw e.error; } 2520 } 2521 return ar; 2522 } 2523 2524 /** @deprecated */ 2525 function __spread() { 2526 for (var ar = [], i = 0; i < arguments.length; i++) 2527 ar = ar.concat(__read(arguments[i])); 2528 return ar; 2529 } 2530 2531 /** @deprecated */ 2532 function __spreadArrays() { 2533 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 2534 for (var r = Array(s), k = 0, i = 0; i < il; i++) 2535 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) 2536 r[k] = a[j]; 2537 return r; 2538 } 2539 2540 function __spreadArray(to, from, pack) { 2541 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 2542 if (ar || !(i in from)) { 2543 if (!ar) ar = Array.prototype.slice.call(from, 0, i); 2544 ar[i] = from[i]; 2545 } 2546 } 2547 return to.concat(ar || Array.prototype.slice.call(from)); 2548 } 2549 2550 function __await(v) { 2551 return this instanceof __await ? (this.v = v, this) : new __await(v); 2552 } 2553 2554 function __asyncGenerator(thisArg, _arguments, generator) { 2555 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 2556 var g = generator.apply(thisArg, _arguments || []), i, q = []; 2557 return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i; 2558 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; } 2559 function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } } 2560 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } 2561 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } 2562 function fulfill(value) { resume("next", value); } 2563 function reject(value) { resume("throw", value); } 2564 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } 2565 } 2566 2567 function __asyncDelegator(o) { 2568 var i, p; 2569 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 2570 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } 2571 } 2572 2573 function __asyncValues(o) { 2574 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 2575 var m = o[Symbol.asyncIterator], i; 2576 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); 2577 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } 2578 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } 2579 } 2580 2581 function __makeTemplateObject(cooked, raw) { 2582 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 2583 return cooked; 2584 }; 2585 2586 var __setModuleDefault = Object.create ? (function(o, v) { 2587 Object.defineProperty(o, "default", { enumerable: true, value: v }); 2588 }) : function(o, v) { 2589 o["default"] = v; 2590 }; 2591 2592 function __importStar(mod) { 2593 if (mod && mod.__esModule) return mod; 2594 var result = {}; 2595 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 2596 __setModuleDefault(result, mod); 2597 return result; 2598 } 2599 2600 function __importDefault(mod) { 2601 return (mod && mod.__esModule) ? mod : { default: mod }; 2602 } 2603 2604 function __classPrivateFieldGet(receiver, state, kind, f) { 2605 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); 2606 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); 2607 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); 2608 } 2609 2610 function __classPrivateFieldSet(receiver, state, value, kind, f) { 2611 if (kind === "m") throw new TypeError("Private method is not writable"); 2612 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); 2613 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); 2614 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; 2615 } 2616 2617 function __classPrivateFieldIn(state, receiver) { 2618 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); 2619 return typeof state === "function" ? receiver === state : state.has(receiver); 2620 } 2621 2622 function __addDisposableResource(env, value, async) { 2623 if (value !== null && value !== void 0) { 2624 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); 2625 var dispose, inner; 2626 if (async) { 2627 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); 2628 dispose = value[Symbol.asyncDispose]; 2629 } 2630 if (dispose === void 0) { 2631 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); 2632 dispose = value[Symbol.dispose]; 2633 if (async) inner = dispose; 2634 } 2635 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); 2636 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } }; 2637 env.stack.push({ value: value, dispose: dispose, async: async }); 2638 } 2639 else if (async) { 2640 env.stack.push({ async: true }); 2641 } 2642 return value; 2643 } 2644 2645 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { 2646 var e = new Error(message); 2647 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; 2648 }; 2649 2650 function __disposeResources(env) { 2651 function fail(e) { 2652 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; 2653 env.hasError = true; 2654 } 2655 var r, s = 0; 2656 function next() { 2657 while (r = env.stack.pop()) { 2658 try { 2659 if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); 2660 if (r.dispose) { 2661 var result = r.dispose.call(r.value); 2662 if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); 2663 } 2664 else s |= 1; 2665 } 2666 catch (e) { 2667 fail(e); 2668 } 2669 } 2670 if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); 2671 if (env.hasError) throw env.error; 2672 } 2673 return next(); 2674 } 2675 2676 /* harmony default export */ const tslib_es6 = ({ 2677 __extends, 2678 __assign, 2679 __rest, 2680 __decorate, 2681 __param, 2682 __metadata, 2683 __awaiter, 2684 __generator, 2685 __createBinding, 2686 __exportStar, 2687 __values, 2688 __read, 2689 __spread, 2690 __spreadArrays, 2691 __spreadArray, 2692 __await, 2693 __asyncGenerator, 2694 __asyncDelegator, 2695 __asyncValues, 2696 __makeTemplateObject, 2697 __importStar, 2698 __importDefault, 2699 __classPrivateFieldGet, 2700 __classPrivateFieldSet, 2701 __classPrivateFieldIn, 2702 __addDisposableResource, 2703 __disposeResources, 2704 }); 2705 2706 ;// ./node_modules/lower-case/dist.es2015/index.js 2707 /** 2708 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt 2709 */ 2710 var SUPPORTED_LOCALE = { 2711 tr: { 2712 regexp: /\u0130|\u0049|\u0049\u0307/g, 2713 map: { 2714 İ: "\u0069", 2715 I: "\u0131", 2716 İ: "\u0069", 2717 }, 2718 }, 2719 az: { 2720 regexp: /\u0130/g, 2721 map: { 2722 İ: "\u0069", 2723 I: "\u0131", 2724 İ: "\u0069", 2725 }, 2726 }, 2727 lt: { 2728 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, 2729 map: { 2730 I: "\u0069\u0307", 2731 J: "\u006A\u0307", 2732 Į: "\u012F\u0307", 2733 Ì: "\u0069\u0307\u0300", 2734 Í: "\u0069\u0307\u0301", 2735 Ĩ: "\u0069\u0307\u0303", 2736 }, 2737 }, 2738 }; 2739 /** 2740 * Localized lower case. 2741 */ 2742 function localeLowerCase(str, locale) { 2743 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; 2744 if (lang) 2745 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); 2746 return lowerCase(str); 2747 } 2748 /** 2749 * Lower case as a function. 2750 */ 2751 function lowerCase(str) { 2752 return str.toLowerCase(); 2753 } 2754 2755 ;// ./node_modules/no-case/dist.es2015/index.js 2756 2757 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). 2758 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 2759 // Remove all non-word characters. 2760 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 2761 /** 2762 * Normalize the string into something other libraries can manipulate easier. 2763 */ 2764 function noCase(input, options) { 2765 if (options === void 0) { options = {}; } 2766 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; 2767 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 2768 var start = 0; 2769 var end = result.length; 2770 // Trim the delimiter from around the output string. 2771 while (result.charAt(start) === "\0") 2772 start++; 2773 while (result.charAt(end - 1) === "\0") 2774 end--; 2775 // Transform each token independently. 2776 return result.slice(start, end).split("\0").map(transform).join(delimiter); 2777 } 2778 /** 2779 * Replace `re` in the input string with the replacement value. 2780 */ 2781 function replace(input, re, value) { 2782 if (re instanceof RegExp) 2783 return input.replace(re, value); 2784 return re.reduce(function (input, re) { return input.replace(re, value); }, input); 2785 } 2786 2787 ;// ./node_modules/pascal-case/dist.es2015/index.js 2788 2789 2790 function pascalCaseTransform(input, index) { 2791 var firstChar = input.charAt(0); 2792 var lowerChars = input.substr(1).toLowerCase(); 2793 if (index > 0 && firstChar >= "0" && firstChar <= "9") { 2794 return "_" + firstChar + lowerChars; 2795 } 2796 return "" + firstChar.toUpperCase() + lowerChars; 2797 } 2798 function pascalCaseTransformMerge(input) { 2799 return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); 2800 } 2801 function pascalCase(input, options) { 2802 if (options === void 0) { options = {}; } 2803 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); 2804 } 2805 2806 ;// ./node_modules/@wordpress/compose/build-module/utils/create-higher-order-component/index.js 2807 /** 2808 * External dependencies 2809 */ 2810 2811 /** 2812 * Given a function mapping a component to an enhanced component and modifier 2813 * name, returns the enhanced component augmented with a generated displayName. 2814 * 2815 * @param mapComponent Function mapping component to enhanced component. 2816 * @param modifierName Seed name from which to generated display name. 2817 * 2818 * @return Component class with generated display name assigned. 2819 */ 2820 function createHigherOrderComponent(mapComponent, modifierName) { 2821 return Inner => { 2822 const Outer = mapComponent(Inner); 2823 Outer.displayName = hocName(modifierName, Inner); 2824 return Outer; 2825 }; 2826 } 2827 2828 /** 2829 * Returns a displayName for a higher-order component, given a wrapper name. 2830 * 2831 * @example 2832 * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)'; 2833 * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)'; 2834 * 2835 * @param name Name assigned to higher-order component's wrapper component. 2836 * @param Inner Wrapped component inside higher-order component. 2837 * @return Wrapped name of higher-order component. 2838 */ 2839 const hocName = (name, Inner) => { 2840 const inner = Inner.displayName || Inner.name || 'Component'; 2841 const outer = pascalCase(name !== null && name !== void 0 ? name : ''); 2842 return `$outer}($inner})`; 2843 }; 2844 2845 ;// ./node_modules/@wordpress/compose/build-module/utils/debounce/index.js 2846 /** 2847 * Parts of this source were derived and modified from lodash, 2848 * released under the MIT license. 2849 * 2850 * https://github.com/lodash/lodash 2851 * 2852 * Copyright JS Foundation and other contributors <https://js.foundation/> 2853 * 2854 * Based on Underscore.js, copyright Jeremy Ashkenas, 2855 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 2856 * 2857 * This software consists of voluntary contributions made by many 2858 * individuals. For exact contribution history, see the revision history 2859 * available at https://github.com/lodash/lodash 2860 * 2861 * The following license applies to all parts of this software except as 2862 * documented below: 2863 * 2864 * ==== 2865 * 2866 * Permission is hereby granted, free of charge, to any person obtaining 2867 * a copy of this software and associated documentation files (the 2868 * "Software"), to deal in the Software without restriction, including 2869 * without limitation the rights to use, copy, modify, merge, publish, 2870 * distribute, sublicense, and/or sell copies of the Software, and to 2871 * permit persons to whom the Software is furnished to do so, subject to 2872 * the following conditions: 2873 * 2874 * The above copyright notice and this permission notice shall be 2875 * included in all copies or substantial portions of the Software. 2876 * 2877 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2878 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2879 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2880 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 2881 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 2882 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2883 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2884 */ 2885 2886 /** 2887 * A simplified and properly typed version of lodash's `debounce`, that 2888 * always uses timers instead of sometimes using rAF. 2889 * 2890 * Creates a debounced function that delays invoking `func` until after `wait` 2891 * milliseconds have elapsed since the last time the debounced function was 2892 * invoked. The debounced function comes with a `cancel` method to cancel delayed 2893 * `func` invocations and a `flush` method to immediately invoke them. Provide 2894 * `options` to indicate whether `func` should be invoked on the leading and/or 2895 * trailing edge of the `wait` timeout. The `func` is invoked with the last 2896 * arguments provided to the debounced function. Subsequent calls to the debounced 2897 * function return the result of the last `func` invocation. 2898 * 2899 * **Note:** If `leading` and `trailing` options are `true`, `func` is 2900 * invoked on the trailing edge of the timeout only if the debounced function 2901 * is invoked more than once during the `wait` timeout. 2902 * 2903 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 2904 * until the next tick, similar to `setTimeout` with a timeout of `0`. 2905 * 2906 * @param {Function} func The function to debounce. 2907 * @param {number} wait The number of milliseconds to delay. 2908 * @param {Partial< DebounceOptions >} options The options object. 2909 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. 2910 * @param {number} options.maxWait The maximum time `func` is allowed to be delayed before it's invoked. 2911 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. 2912 * 2913 * @return Returns the new debounced function. 2914 */ 2915 const debounce = (func, wait, options) => { 2916 let lastArgs; 2917 let lastThis; 2918 let maxWait = 0; 2919 let result; 2920 let timerId; 2921 let lastCallTime; 2922 let lastInvokeTime = 0; 2923 let leading = false; 2924 let maxing = false; 2925 let trailing = true; 2926 if (options) { 2927 leading = !!options.leading; 2928 maxing = 'maxWait' in options; 2929 if (options.maxWait !== undefined) { 2930 maxWait = Math.max(options.maxWait, wait); 2931 } 2932 trailing = 'trailing' in options ? !!options.trailing : trailing; 2933 } 2934 function invokeFunc(time) { 2935 const args = lastArgs; 2936 const thisArg = lastThis; 2937 lastArgs = undefined; 2938 lastThis = undefined; 2939 lastInvokeTime = time; 2940 result = func.apply(thisArg, args); 2941 return result; 2942 } 2943 function startTimer(pendingFunc, waitTime) { 2944 timerId = setTimeout(pendingFunc, waitTime); 2945 } 2946 function cancelTimer() { 2947 if (timerId !== undefined) { 2948 clearTimeout(timerId); 2949 } 2950 } 2951 function leadingEdge(time) { 2952 // Reset any `maxWait` timer. 2953 lastInvokeTime = time; 2954 // Start the timer for the trailing edge. 2955 startTimer(timerExpired, wait); 2956 // Invoke the leading edge. 2957 return leading ? invokeFunc(time) : result; 2958 } 2959 function getTimeSinceLastCall(time) { 2960 return time - (lastCallTime || 0); 2961 } 2962 function remainingWait(time) { 2963 const timeSinceLastCall = getTimeSinceLastCall(time); 2964 const timeSinceLastInvoke = time - lastInvokeTime; 2965 const timeWaiting = wait - timeSinceLastCall; 2966 return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting; 2967 } 2968 function shouldInvoke(time) { 2969 const timeSinceLastCall = getTimeSinceLastCall(time); 2970 const timeSinceLastInvoke = time - lastInvokeTime; 2971 2972 // Either this is the first call, activity has stopped and we're at the 2973 // trailing edge, the system time has gone backwards and we're treating 2974 // it as the trailing edge, or we've hit the `maxWait` limit. 2975 return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait; 2976 } 2977 function timerExpired() { 2978 const time = Date.now(); 2979 if (shouldInvoke(time)) { 2980 return trailingEdge(time); 2981 } 2982 // Restart the timer. 2983 startTimer(timerExpired, remainingWait(time)); 2984 return undefined; 2985 } 2986 function clearTimer() { 2987 timerId = undefined; 2988 } 2989 function trailingEdge(time) { 2990 clearTimer(); 2991 2992 // Only invoke if we have `lastArgs` which means `func` has been 2993 // debounced at least once. 2994 if (trailing && lastArgs) { 2995 return invokeFunc(time); 2996 } 2997 lastArgs = lastThis = undefined; 2998 return result; 2999 } 3000 function cancel() { 3001 cancelTimer(); 3002 lastInvokeTime = 0; 3003 clearTimer(); 3004 lastArgs = lastCallTime = lastThis = undefined; 3005 } 3006 function flush() { 3007 return pending() ? trailingEdge(Date.now()) : result; 3008 } 3009 function pending() { 3010 return timerId !== undefined; 3011 } 3012 function debounced(...args) { 3013 const time = Date.now(); 3014 const isInvoking = shouldInvoke(time); 3015 lastArgs = args; 3016 lastThis = this; 3017 lastCallTime = time; 3018 if (isInvoking) { 3019 if (!pending()) { 3020 return leadingEdge(lastCallTime); 3021 } 3022 if (maxing) { 3023 // Handle invocations in a tight loop. 3024 startTimer(timerExpired, wait); 3025 return invokeFunc(lastCallTime); 3026 } 3027 } 3028 if (!pending()) { 3029 startTimer(timerExpired, wait); 3030 } 3031 return result; 3032 } 3033 debounced.cancel = cancel; 3034 debounced.flush = flush; 3035 debounced.pending = pending; 3036 return debounced; 3037 }; 3038 3039 ;// ./node_modules/@wordpress/compose/build-module/utils/throttle/index.js 3040 /** 3041 * Parts of this source were derived and modified from lodash, 3042 * released under the MIT license. 3043 * 3044 * https://github.com/lodash/lodash 3045 * 3046 * Copyright JS Foundation and other contributors <https://js.foundation/> 3047 * 3048 * Based on Underscore.js, copyright Jeremy Ashkenas, 3049 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 3050 * 3051 * This software consists of voluntary contributions made by many 3052 * individuals. For exact contribution history, see the revision history 3053 * available at https://github.com/lodash/lodash 3054 * 3055 * The following license applies to all parts of this software except as 3056 * documented below: 3057 * 3058 * ==== 3059 * 3060 * Permission is hereby granted, free of charge, to any person obtaining 3061 * a copy of this software and associated documentation files (the 3062 * "Software"), to deal in the Software without restriction, including 3063 * without limitation the rights to use, copy, modify, merge, publish, 3064 * distribute, sublicense, and/or sell copies of the Software, and to 3065 * permit persons to whom the Software is furnished to do so, subject to 3066 * the following conditions: 3067 * 3068 * The above copyright notice and this permission notice shall be 3069 * included in all copies or substantial portions of the Software. 3070 * 3071 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3072 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3073 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3074 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 3075 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 3076 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 3077 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 3078 */ 3079 3080 /** 3081 * Internal dependencies 3082 */ 3083 3084 /** 3085 * A simplified and properly typed version of lodash's `throttle`, that 3086 * always uses timers instead of sometimes using rAF. 3087 * 3088 * Creates a throttled function that only invokes `func` at most once per 3089 * every `wait` milliseconds. The throttled function comes with a `cancel` 3090 * method to cancel delayed `func` invocations and a `flush` method to 3091 * immediately invoke them. Provide `options` to indicate whether `func` 3092 * should be invoked on the leading and/or trailing edge of the `wait` 3093 * timeout. The `func` is invoked with the last arguments provided to the 3094 * throttled function. Subsequent calls to the throttled function return 3095 * the result of the last `func` invocation. 3096 * 3097 * **Note:** If `leading` and `trailing` options are `true`, `func` is 3098 * invoked on the trailing edge of the timeout only if the throttled function 3099 * is invoked more than once during the `wait` timeout. 3100 * 3101 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 3102 * until the next tick, similar to `setTimeout` with a timeout of `0`. 3103 * 3104 * @param {Function} func The function to throttle. 3105 * @param {number} wait The number of milliseconds to throttle invocations to. 3106 * @param {Partial< ThrottleOptions >} options The options object. 3107 * @param {boolean} options.leading Specify invoking on the leading edge of the timeout. 3108 * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout. 3109 * @return Returns the new throttled function. 3110 */ 3111 const throttle = (func, wait, options) => { 3112 let leading = true; 3113 let trailing = true; 3114 if (options) { 3115 leading = 'leading' in options ? !!options.leading : leading; 3116 trailing = 'trailing' in options ? !!options.trailing : trailing; 3117 } 3118 return debounce(func, wait, { 3119 leading, 3120 trailing, 3121 maxWait: wait 3122 }); 3123 }; 3124 3125 ;// ./node_modules/@wordpress/compose/build-module/utils/observable-map/index.js 3126 /** 3127 * A constructor (factory) for `ObservableMap`, a map-like key/value data structure 3128 * where the individual entries are observable: using the `subscribe` method, you can 3129 * subscribe to updates for a particular keys. Each subscriber always observes one 3130 * specific key and is not notified about any unrelated changes (for different keys) 3131 * in the `ObservableMap`. 3132 * 3133 * @template K The type of the keys in the map. 3134 * @template V The type of the values in the map. 3135 * @return A new instance of the `ObservableMap` type. 3136 */ 3137 function observableMap() { 3138 const map = new Map(); 3139 const listeners = new Map(); 3140 function callListeners(name) { 3141 const list = listeners.get(name); 3142 if (!list) { 3143 return; 3144 } 3145 for (const listener of list) { 3146 listener(); 3147 } 3148 } 3149 return { 3150 get(name) { 3151 return map.get(name); 3152 }, 3153 set(name, value) { 3154 map.set(name, value); 3155 callListeners(name); 3156 }, 3157 delete(name) { 3158 map.delete(name); 3159 callListeners(name); 3160 }, 3161 subscribe(name, listener) { 3162 let list = listeners.get(name); 3163 if (!list) { 3164 list = new Set(); 3165 listeners.set(name, list); 3166 } 3167 list.add(listener); 3168 return () => { 3169 list.delete(listener); 3170 if (list.size === 0) { 3171 listeners.delete(name); 3172 } 3173 }; 3174 } 3175 }; 3176 } 3177 3178 ;// ./node_modules/@wordpress/compose/build-module/higher-order/pipe.js 3179 /** 3180 * Parts of this source were derived and modified from lodash, 3181 * released under the MIT license. 3182 * 3183 * https://github.com/lodash/lodash 3184 * 3185 * Copyright JS Foundation and other contributors <https://js.foundation/> 3186 * 3187 * Based on Underscore.js, copyright Jeremy Ashkenas, 3188 * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/> 3189 * 3190 * This software consists of voluntary contributions made by many 3191 * individuals. For exact contribution history, see the revision history 3192 * available at https://github.com/lodash/lodash 3193 * 3194 * The following license applies to all parts of this software except as 3195 * documented below: 3196 * 3197 * ==== 3198 * 3199 * Permission is hereby granted, free of charge, to any person obtaining 3200 * a copy of this software and associated documentation files (the 3201 * "Software"), to deal in the Software without restriction, including 3202 * without limitation the rights to use, copy, modify, merge, publish, 3203 * distribute, sublicense, and/or sell copies of the Software, and to 3204 * permit persons to whom the Software is furnished to do so, subject to 3205 * the following conditions: 3206 * 3207 * The above copyright notice and this permission notice shall be 3208 * included in all copies or substantial portions of the Software. 3209 * 3210 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 3211 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 3212 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 3213 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 3214 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 3215 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 3216 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 3217 */ 3218 3219 /** 3220 * Creates a pipe function. 3221 * 3222 * Allows to choose whether to perform left-to-right or right-to-left composition. 3223 * 3224 * @see https://lodash.com/docs/4#flow 3225 * 3226 * @param {boolean} reverse True if right-to-left, false for left-to-right composition. 3227 */ 3228 const basePipe = (reverse = false) => (...funcs) => (...args) => { 3229 const functions = funcs.flat(); 3230 if (reverse) { 3231 functions.reverse(); 3232 } 3233 return functions.reduce((prev, func) => [func(...prev)], args)[0]; 3234 }; 3235 3236 /** 3237 * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function 3238 * composition, where each successive invocation is supplied the return value of the previous. 3239 * 3240 * This is inspired by `lodash`'s `flow` function. 3241 * 3242 * @see https://lodash.com/docs/4#flow 3243 */ 3244 const pipe = basePipe(); 3245 3246 /* harmony default export */ const higher_order_pipe = (pipe); 3247 3248 ;// ./node_modules/@wordpress/compose/build-module/higher-order/compose.js 3249 /** 3250 * Internal dependencies 3251 */ 3252 3253 3254 /** 3255 * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function 3256 * composition, where each successive invocation is supplied the return value of the previous. 3257 * 3258 * This is inspired by `lodash`'s `flowRight` function. 3259 * 3260 * @see https://lodash.com/docs/4#flow-right 3261 */ 3262 const compose = basePipe(true); 3263 /* harmony default export */ const higher_order_compose = (compose); 3264 3265 ;// external "ReactJSXRuntime" 3266 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; 3267 ;// ./node_modules/@wordpress/compose/build-module/higher-order/if-condition/index.js 3268 /** 3269 * External dependencies 3270 */ 3271 3272 /** 3273 * Internal dependencies 3274 */ 3275 3276 3277 /** 3278 * Higher-order component creator, creating a new component which renders if 3279 * the given condition is satisfied or with the given optional prop name. 3280 * 3281 * @example 3282 * ```ts 3283 * type Props = { foo: string }; 3284 * const Component = ( props: Props ) => <div>{ props.foo }</div>; 3285 * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component ); 3286 * <ConditionalComponent foo="" />; // => null 3287 * <ConditionalComponent foo="bar" />; // => <div>bar</div>; 3288 * ``` 3289 * 3290 * @param predicate Function to test condition. 3291 * 3292 * @return Higher-order component. 3293 */ 3294 3295 function ifCondition(predicate) { 3296 return createHigherOrderComponent(WrappedComponent => props => { 3297 if (!predicate(props)) { 3298 return null; 3299 } 3300 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3301 ...props 3302 }); 3303 }, 'ifCondition'); 3304 } 3305 /* harmony default export */ const if_condition = (ifCondition); 3306 3307 // EXTERNAL MODULE: external ["wp","isShallowEqual"] 3308 var external_wp_isShallowEqual_ = __webpack_require__(923); 3309 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); 3310 ;// external ["wp","element"] 3311 const external_wp_element_namespaceObject = window["wp"]["element"]; 3312 ;// ./node_modules/@wordpress/compose/build-module/higher-order/pure/index.js 3313 /** 3314 * External dependencies 3315 */ 3316 3317 /** 3318 * WordPress dependencies 3319 */ 3320 3321 3322 3323 /** 3324 * Internal dependencies 3325 */ 3326 3327 3328 /** 3329 * Given a component returns the enhanced component augmented with a component 3330 * only re-rendering when its props/state change 3331 * 3332 * @deprecated Use `memo` or `PureComponent` instead. 3333 */ 3334 3335 const pure = createHigherOrderComponent(function (WrappedComponent) { 3336 if (WrappedComponent.prototype instanceof external_wp_element_namespaceObject.Component) { 3337 return class extends WrappedComponent { 3338 shouldComponentUpdate(nextProps, nextState) { 3339 return !external_wp_isShallowEqual_default()(nextProps, this.props) || !external_wp_isShallowEqual_default()(nextState, this.state); 3340 } 3341 }; 3342 } 3343 return class extends external_wp_element_namespaceObject.Component { 3344 shouldComponentUpdate(nextProps) { 3345 return !external_wp_isShallowEqual_default()(nextProps, this.props); 3346 } 3347 render() { 3348 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3349 ...this.props 3350 }); 3351 } 3352 }; 3353 }, 'pure'); 3354 /* harmony default export */ const higher_order_pure = (pure); 3355 3356 ;// external ["wp","deprecated"] 3357 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 3358 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 3359 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/listener.js 3360 /** 3361 * Class responsible for orchestrating event handling on the global window, 3362 * binding a single event to be shared across all handling instances, and 3363 * removing the handler when no instances are listening for the event. 3364 */ 3365 class Listener { 3366 constructor() { 3367 /** @type {any} */ 3368 this.listeners = {}; 3369 this.handleEvent = this.handleEvent.bind(this); 3370 } 3371 add( /** @type {any} */eventType, /** @type {any} */instance) { 3372 if (!this.listeners[eventType]) { 3373 // Adding first listener for this type, so bind event. 3374 window.addEventListener(eventType, this.handleEvent); 3375 this.listeners[eventType] = []; 3376 } 3377 this.listeners[eventType].push(instance); 3378 } 3379 remove( /** @type {any} */eventType, /** @type {any} */instance) { 3380 if (!this.listeners[eventType]) { 3381 return; 3382 } 3383 this.listeners[eventType] = this.listeners[eventType].filter(( /** @type {any} */listener) => listener !== instance); 3384 if (!this.listeners[eventType].length) { 3385 // Removing last listener for this type, so unbind event. 3386 window.removeEventListener(eventType, this.handleEvent); 3387 delete this.listeners[eventType]; 3388 } 3389 } 3390 handleEvent( /** @type {any} */event) { 3391 this.listeners[event.type]?.forEach(( /** @type {any} */instance) => { 3392 instance.handleEvent(event); 3393 }); 3394 } 3395 } 3396 /* harmony default export */ const listener = (Listener); 3397 3398 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-global-events/index.js 3399 /** 3400 * WordPress dependencies 3401 */ 3402 3403 3404 3405 /** 3406 * Internal dependencies 3407 */ 3408 3409 3410 3411 /** 3412 * Listener instance responsible for managing document event handling. 3413 */ 3414 3415 const with_global_events_listener = new listener(); 3416 3417 /* eslint-disable jsdoc/no-undefined-types */ 3418 /** 3419 * Higher-order component creator which, given an object of DOM event types and 3420 * values corresponding to a callback function name on the component, will 3421 * create or update a window event handler to invoke the callback when an event 3422 * occurs. On behalf of the consuming developer, the higher-order component 3423 * manages unbinding when the component unmounts, and binding at most a single 3424 * event handler for the entire application. 3425 * 3426 * @deprecated 3427 * 3428 * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM 3429 * event type, the value a 3430 * name of the function on 3431 * the original component's 3432 * instance which handles 3433 * the event. 3434 * 3435 * @return {any} Higher-order component. 3436 */ 3437 function withGlobalEvents(eventTypesToHandlers) { 3438 external_wp_deprecated_default()('wp.compose.withGlobalEvents', { 3439 since: '5.7', 3440 alternative: 'useEffect' 3441 }); 3442 3443 // @ts-ignore We don't need to fix the type-related issues because this is deprecated. 3444 return createHigherOrderComponent(WrappedComponent => { 3445 class Wrapper extends external_wp_element_namespaceObject.Component { 3446 constructor( /** @type {any} */props) { 3447 super(props); 3448 this.handleEvent = this.handleEvent.bind(this); 3449 this.handleRef = this.handleRef.bind(this); 3450 } 3451 componentDidMount() { 3452 Object.keys(eventTypesToHandlers).forEach(eventType => { 3453 with_global_events_listener.add(eventType, this); 3454 }); 3455 } 3456 componentWillUnmount() { 3457 Object.keys(eventTypesToHandlers).forEach(eventType => { 3458 with_global_events_listener.remove(eventType, this); 3459 }); 3460 } 3461 handleEvent( /** @type {any} */event) { 3462 const handler = eventTypesToHandlers[( /** @type {keyof GlobalEventHandlersEventMap} */ 3463 event.type 3464 3465 /* eslint-enable jsdoc/no-undefined-types */)]; 3466 if (typeof this.wrappedRef[handler] === 'function') { 3467 this.wrappedRef[handler](event); 3468 } 3469 } 3470 handleRef( /** @type {any} */el) { 3471 this.wrappedRef = el; 3472 // Any component using `withGlobalEvents` that is not setting a `ref` 3473 // will cause `this.props.forwardedRef` to be `null`, so we need this 3474 // check. 3475 if (this.props.forwardedRef) { 3476 this.props.forwardedRef(el); 3477 } 3478 } 3479 render() { 3480 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3481 ...this.props.ownProps, 3482 ref: this.handleRef 3483 }); 3484 } 3485 } 3486 return (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => { 3487 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Wrapper, { 3488 ownProps: props, 3489 forwardedRef: ref 3490 }); 3491 }); 3492 }, 'withGlobalEvents'); 3493 } 3494 3495 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-instance-id/index.js 3496 /** 3497 * WordPress dependencies 3498 */ 3499 3500 const instanceMap = new WeakMap(); 3501 3502 /** 3503 * Creates a new id for a given object. 3504 * 3505 * @param object Object reference to create an id for. 3506 * @return The instance id (index). 3507 */ 3508 function createId(object) { 3509 const instances = instanceMap.get(object) || 0; 3510 instanceMap.set(object, instances + 1); 3511 return instances; 3512 } 3513 3514 /** 3515 * Specify the useInstanceId *function* signatures. 3516 * 3517 * More accurately, useInstanceId distinguishes between three different 3518 * signatures: 3519 * 3520 * 1. When only object is given, the returned value is a number 3521 * 2. When object and prefix is given, the returned value is a string 3522 * 3. When preferredId is given, the returned value is the type of preferredId 3523 * 3524 * @param object Object reference to create an id for. 3525 */ 3526 3527 /** 3528 * Provides a unique instance ID. 3529 * 3530 * @param object Object reference to create an id for. 3531 * @param [prefix] Prefix for the unique id. 3532 * @param [preferredId] Default ID to use. 3533 * @return The unique instance id. 3534 */ 3535 function useInstanceId(object, prefix, preferredId) { 3536 return (0,external_wp_element_namespaceObject.useMemo)(() => { 3537 if (preferredId) { 3538 return preferredId; 3539 } 3540 const id = createId(object); 3541 return prefix ? `$prefix}-$id}` : id; 3542 }, [object, preferredId, prefix]); 3543 } 3544 /* harmony default export */ const use_instance_id = (useInstanceId); 3545 3546 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-instance-id/index.js 3547 /** 3548 * Internal dependencies 3549 */ 3550 3551 3552 3553 3554 /** 3555 * A Higher Order Component used to provide a unique instance ID by component. 3556 */ 3557 const withInstanceId = createHigherOrderComponent(WrappedComponent => { 3558 return props => { 3559 const instanceId = use_instance_id(WrappedComponent); 3560 // @ts-ignore 3561 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, { 3562 ...props, 3563 instanceId: instanceId 3564 }); 3565 }; 3566 }, 'instanceId'); 3567 /* harmony default export */ const with_instance_id = (withInstanceId); 3568 3569 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-safe-timeout/index.js 3570 /** 3571 * WordPress dependencies 3572 */ 3573 3574 3575 /** 3576 * Internal dependencies 3577 */ 3578 3579 3580 3581 /** 3582 * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']` 3583 * types here because those functions include functionality that is not handled 3584 * by this component, like the ability to pass extra arguments. 3585 * 3586 * In the case of this component, we only handle the simplest case where 3587 * `setTimeout` only accepts a function (not a string) and an optional delay. 3588 */ 3589 3590 /** 3591 * A higher-order component used to provide and manage delayed function calls 3592 * that ought to be bound to a component's lifecycle. 3593 */ 3594 const withSafeTimeout = createHigherOrderComponent(OriginalComponent => { 3595 return class WrappedComponent extends external_wp_element_namespaceObject.Component { 3596 constructor(props) { 3597 super(props); 3598 this.timeouts = []; 3599 this.setTimeout = this.setTimeout.bind(this); 3600 this.clearTimeout = this.clearTimeout.bind(this); 3601 } 3602 componentWillUnmount() { 3603 this.timeouts.forEach(clearTimeout); 3604 } 3605 setTimeout(fn, delay) { 3606 const id = setTimeout(() => { 3607 fn(); 3608 this.clearTimeout(id); 3609 }, delay); 3610 this.timeouts.push(id); 3611 return id; 3612 } 3613 clearTimeout(id) { 3614 clearTimeout(id); 3615 this.timeouts = this.timeouts.filter(timeoutId => timeoutId !== id); 3616 } 3617 render() { 3618 return ( 3619 /*#__PURE__*/ 3620 // @ts-ignore 3621 (0,external_ReactJSXRuntime_namespaceObject.jsx)(OriginalComponent, { 3622 ...this.props, 3623 setTimeout: this.setTimeout, 3624 clearTimeout: this.clearTimeout 3625 }) 3626 ); 3627 } 3628 }; 3629 }, 'withSafeTimeout'); 3630 /* harmony default export */ const with_safe_timeout = (withSafeTimeout); 3631 3632 ;// ./node_modules/@wordpress/compose/build-module/higher-order/with-state/index.js 3633 /** 3634 * WordPress dependencies 3635 */ 3636 3637 3638 3639 /** 3640 * Internal dependencies 3641 */ 3642 3643 3644 /** 3645 * A Higher Order Component used to provide and manage internal component state 3646 * via props. 3647 * 3648 * @deprecated Use `useState` instead. 3649 * 3650 * @param {any} initialState Optional initial state of the component. 3651 * 3652 * @return {any} A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props. 3653 */ 3654 3655 function withState(initialState = {}) { 3656 external_wp_deprecated_default()('wp.compose.withState', { 3657 since: '5.8', 3658 alternative: 'wp.element.useState' 3659 }); 3660 return createHigherOrderComponent(OriginalComponent => { 3661 return class WrappedComponent extends external_wp_element_namespaceObject.Component { 3662 constructor( /** @type {any} */props) { 3663 super(props); 3664 this.setState = this.setState.bind(this); 3665 this.state = initialState; 3666 } 3667 render() { 3668 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OriginalComponent, { 3669 ...this.props, 3670 ...this.state, 3671 setState: this.setState 3672 }); 3673 } 3674 }; 3675 }, 'withState'); 3676 } 3677 3678 ;// external ["wp","dom"] 3679 const external_wp_dom_namespaceObject = window["wp"]["dom"]; 3680 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-ref-effect/index.js 3681 /** 3682 * External dependencies 3683 */ 3684 3685 /** 3686 * WordPress dependencies 3687 */ 3688 3689 3690 /** 3691 * Effect-like ref callback. Just like with `useEffect`, this allows you to 3692 * return a cleanup function to be run if the ref changes or one of the 3693 * dependencies changes. The ref is provided as an argument to the callback 3694 * functions. The main difference between this and `useEffect` is that 3695 * the `useEffect` callback is not called when the ref changes, but this is. 3696 * Pass the returned ref callback as the component's ref and merge multiple refs 3697 * with `useMergeRefs`. 3698 * 3699 * It's worth noting that if the dependencies array is empty, there's not 3700 * strictly a need to clean up event handlers for example, because the node is 3701 * to be removed. It *is* necessary if you add dependencies because the ref 3702 * callback will be called multiple times for the same node. 3703 * 3704 * @param callback Callback with ref as argument. 3705 * @param dependencies Dependencies of the callback. 3706 * 3707 * @return Ref callback. 3708 */ 3709 function useRefEffect(callback, dependencies) { 3710 const cleanupRef = (0,external_wp_element_namespaceObject.useRef)(); 3711 return (0,external_wp_element_namespaceObject.useCallback)(node => { 3712 if (node) { 3713 cleanupRef.current = callback(node); 3714 } else if (cleanupRef.current) { 3715 cleanupRef.current(); 3716 } 3717 }, dependencies); 3718 } 3719 3720 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-constrained-tabbing/index.js 3721 /** 3722 * WordPress dependencies 3723 */ 3724 3725 3726 /** 3727 * Internal dependencies 3728 */ 3729 3730 3731 /** 3732 * In Dialogs/modals, the tabbing must be constrained to the content of 3733 * the wrapper element. This hook adds the behavior to the returned ref. 3734 * 3735 * @return {import('react').RefCallback<Element>} Element Ref. 3736 * 3737 * @example 3738 * ```js 3739 * import { useConstrainedTabbing } from '@wordpress/compose'; 3740 * 3741 * const ConstrainedTabbingExample = () => { 3742 * const constrainedTabbingRef = useConstrainedTabbing() 3743 * return ( 3744 * <div ref={ constrainedTabbingRef }> 3745 * <Button /> 3746 * <Button /> 3747 * </div> 3748 * ); 3749 * } 3750 * ``` 3751 */ 3752 function useConstrainedTabbing() { 3753 return useRefEffect(( /** @type {HTMLElement} */node) => { 3754 function onKeyDown( /** @type {KeyboardEvent} */event) { 3755 const { 3756 key, 3757 shiftKey, 3758 target 3759 } = event; 3760 if (key !== 'Tab') { 3761 return; 3762 } 3763 const action = shiftKey ? 'findPrevious' : 'findNext'; 3764 const nextElement = external_wp_dom_namespaceObject.focus.tabbable[action]( /** @type {HTMLElement} */target) || null; 3765 3766 // When the target element contains the element that is about to 3767 // receive focus, for example when the target is a tabbable 3768 // container, browsers may disagree on where to move focus next. 3769 // In this case we can't rely on native browsers behavior. We need 3770 // to manage focus instead. 3771 // See https://github.com/WordPress/gutenberg/issues/46041. 3772 if ( /** @type {HTMLElement} */target.contains(nextElement)) { 3773 event.preventDefault(); 3774 nextElement?.focus(); 3775 return; 3776 } 3777 3778 // If the element that is about to receive focus is inside the 3779 // area, rely on native browsers behavior and let tabbing follow 3780 // the native tab sequence. 3781 if (node.contains(nextElement)) { 3782 return; 3783 } 3784 3785 // If the element that is about to receive focus is outside the 3786 // area, move focus to a div and insert it at the start or end of 3787 // the area, depending on the direction. Without preventing default 3788 // behaviour, the browser will then move focus to the next element. 3789 const domAction = shiftKey ? 'append' : 'prepend'; 3790 const { 3791 ownerDocument 3792 } = node; 3793 const trap = ownerDocument.createElement('div'); 3794 trap.tabIndex = -1; 3795 node[domAction](trap); 3796 3797 // Remove itself when the trap loses focus. 3798 trap.addEventListener('blur', () => node.removeChild(trap)); 3799 trap.focus(); 3800 } 3801 node.addEventListener('keydown', onKeyDown); 3802 return () => { 3803 node.removeEventListener('keydown', onKeyDown); 3804 }; 3805 }, []); 3806 } 3807 /* harmony default export */ const use_constrained_tabbing = (useConstrainedTabbing); 3808 3809 // EXTERNAL MODULE: ./node_modules/clipboard/dist/clipboard.js 3810 var dist_clipboard = __webpack_require__(3758); 3811 var clipboard_default = /*#__PURE__*/__webpack_require__.n(dist_clipboard); 3812 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-copy-on-click/index.js 3813 /** 3814 * External dependencies 3815 */ 3816 3817 3818 /** 3819 * WordPress dependencies 3820 */ 3821 3822 3823 3824 /* eslint-disable jsdoc/no-undefined-types */ 3825 /** 3826 * Copies the text to the clipboard when the element is clicked. 3827 * 3828 * @deprecated 3829 * 3830 * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element. 3831 * @param {string|Function} text The text to copy. 3832 * @param {number} [timeout] Optional timeout to reset the returned 3833 * state. 4 seconds by default. 3834 * 3835 * @return {boolean} Whether or not the text has been copied. Resets after the 3836 * timeout. 3837 */ 3838 function useCopyOnClick(ref, text, timeout = 4000) { 3839 /* eslint-enable jsdoc/no-undefined-types */ 3840 external_wp_deprecated_default()('wp.compose.useCopyOnClick', { 3841 since: '5.8', 3842 alternative: 'wp.compose.useCopyToClipboard' 3843 }); 3844 3845 /** @type {import('react').MutableRefObject<Clipboard | undefined>} */ 3846 const clipboardRef = (0,external_wp_element_namespaceObject.useRef)(); 3847 const [hasCopied, setHasCopied] = (0,external_wp_element_namespaceObject.useState)(false); 3848 (0,external_wp_element_namespaceObject.useEffect)(() => { 3849 /** @type {number | undefined} */ 3850 let timeoutId; 3851 if (!ref.current) { 3852 return; 3853 } 3854 3855 // Clipboard listens to click events. 3856 clipboardRef.current = new (clipboard_default())(ref.current, { 3857 text: () => typeof text === 'function' ? text() : text 3858 }); 3859 clipboardRef.current.on('success', ({ 3860 clearSelection, 3861 trigger 3862 }) => { 3863 // Clearing selection will move focus back to the triggering button, 3864 // ensuring that it is not reset to the body, and further that it is 3865 // kept within the rendered node. 3866 clearSelection(); 3867 3868 // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 3869 if (trigger) { 3870 /** @type {HTMLElement} */trigger.focus(); 3871 } 3872 if (timeout) { 3873 setHasCopied(true); 3874 clearTimeout(timeoutId); 3875 timeoutId = setTimeout(() => setHasCopied(false), timeout); 3876 } 3877 }); 3878 return () => { 3879 if (clipboardRef.current) { 3880 clipboardRef.current.destroy(); 3881 } 3882 clearTimeout(timeoutId); 3883 }; 3884 }, [text, timeout, setHasCopied]); 3885 return hasCopied; 3886 } 3887 3888 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-copy-to-clipboard/index.js 3889 /** 3890 * External dependencies 3891 */ 3892 3893 3894 /** 3895 * WordPress dependencies 3896 */ 3897 3898 3899 /** 3900 * Internal dependencies 3901 */ 3902 3903 3904 /** 3905 * @template T 3906 * @param {T} value 3907 * @return {import('react').RefObject<T>} The updated ref 3908 */ 3909 function useUpdatedRef(value) { 3910 const ref = (0,external_wp_element_namespaceObject.useRef)(value); 3911 ref.current = value; 3912 return ref; 3913 } 3914 3915 /** 3916 * Copies the given text to the clipboard when the element is clicked. 3917 * 3918 * @template {HTMLElement} TElementType 3919 * @param {string | (() => string)} text The text to copy. Use a function if not 3920 * already available and expensive to compute. 3921 * @param {Function} onSuccess Called when to text is copied. 3922 * 3923 * @return {import('react').Ref<TElementType>} A ref to assign to the target element. 3924 */ 3925 function useCopyToClipboard(text, onSuccess) { 3926 // Store the dependencies as refs and continuously update them so they're 3927 // fresh when the callback is called. 3928 const textRef = useUpdatedRef(text); 3929 const onSuccessRef = useUpdatedRef(onSuccess); 3930 return useRefEffect(node => { 3931 // Clipboard listens to click events. 3932 const clipboard = new (clipboard_default())(node, { 3933 text() { 3934 return typeof textRef.current === 'function' ? textRef.current() : textRef.current || ''; 3935 } 3936 }); 3937 clipboard.on('success', ({ 3938 clearSelection 3939 }) => { 3940 // Clearing selection will move focus back to the triggering 3941 // button, ensuring that it is not reset to the body, and 3942 // further that it is kept within the rendered node. 3943 clearSelection(); 3944 if (onSuccessRef.current) { 3945 onSuccessRef.current(); 3946 } 3947 }); 3948 return () => { 3949 clipboard.destroy(); 3950 }; 3951 }, []); 3952 } 3953 3954 ;// external ["wp","keycodes"] 3955 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 3956 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focus-on-mount/index.js 3957 /** 3958 * WordPress dependencies 3959 */ 3960 3961 3962 3963 /** 3964 * Internal dependencies 3965 */ 3966 3967 3968 /** 3969 * Hook used to focus the first tabbable element on mount. 3970 * 3971 * @param {boolean | 'firstElement'} focusOnMount Focus on mount mode. 3972 * @return {import('react').RefCallback<HTMLElement>} Ref callback. 3973 * 3974 * @example 3975 * ```js 3976 * import { useFocusOnMount } from '@wordpress/compose'; 3977 * 3978 * const WithFocusOnMount = () => { 3979 * const ref = useFocusOnMount() 3980 * return ( 3981 * <div ref={ ref }> 3982 * <Button /> 3983 * <Button /> 3984 * </div> 3985 * ); 3986 * } 3987 * ``` 3988 */ 3989 function useFocusOnMount(focusOnMount = 'firstElement') { 3990 const focusOnMountRef = (0,external_wp_element_namespaceObject.useRef)(focusOnMount); 3991 3992 /** 3993 * Sets focus on a DOM element. 3994 * 3995 * @param {HTMLElement} target The DOM element to set focus to. 3996 * @return {void} 3997 */ 3998 const setFocus = target => { 3999 target.focus({ 4000 // When focusing newly mounted dialogs, 4001 // the position of the popover is often not right on the first render 4002 // This prevents the layout shifts when focusing the dialogs. 4003 preventScroll: true 4004 }); 4005 }; 4006 4007 /** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */ 4008 const timerIdRef = (0,external_wp_element_namespaceObject.useRef)(); 4009 (0,external_wp_element_namespaceObject.useEffect)(() => { 4010 focusOnMountRef.current = focusOnMount; 4011 }, [focusOnMount]); 4012 return useRefEffect(node => { 4013 var _node$ownerDocument$a; 4014 if (!node || focusOnMountRef.current === false) { 4015 return; 4016 } 4017 if (node.contains((_node$ownerDocument$a = node.ownerDocument?.activeElement) !== null && _node$ownerDocument$a !== void 0 ? _node$ownerDocument$a : null)) { 4018 return; 4019 } 4020 if (focusOnMountRef.current !== 'firstElement') { 4021 setFocus(node); 4022 return; 4023 } 4024 timerIdRef.current = setTimeout(() => { 4025 const firstTabbable = external_wp_dom_namespaceObject.focus.tabbable.find(node)[0]; 4026 if (firstTabbable) { 4027 setFocus(firstTabbable); 4028 } 4029 }, 0); 4030 return () => { 4031 if (timerIdRef.current) { 4032 clearTimeout(timerIdRef.current); 4033 } 4034 }; 4035 }, []); 4036 } 4037 4038 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focus-return/index.js 4039 /** 4040 * WordPress dependencies 4041 */ 4042 4043 4044 /** @type {Element|null} */ 4045 let origin = null; 4046 4047 /** 4048 * Adds the unmount behavior of returning focus to the element which had it 4049 * previously as is expected for roles like menus or dialogs. 4050 * 4051 * @param {() => void} [onFocusReturn] Overrides the default return behavior. 4052 * @return {import('react').RefCallback<HTMLElement>} Element Ref. 4053 * 4054 * @example 4055 * ```js 4056 * import { useFocusReturn } from '@wordpress/compose'; 4057 * 4058 * const WithFocusReturn = () => { 4059 * const ref = useFocusReturn() 4060 * return ( 4061 * <div ref={ ref }> 4062 * <Button /> 4063 * <Button /> 4064 * </div> 4065 * ); 4066 * } 4067 * ``` 4068 */ 4069 function useFocusReturn(onFocusReturn) { 4070 /** @type {import('react').MutableRefObject<null | HTMLElement>} */ 4071 const ref = (0,external_wp_element_namespaceObject.useRef)(null); 4072 /** @type {import('react').MutableRefObject<null | Element>} */ 4073 const focusedBeforeMount = (0,external_wp_element_namespaceObject.useRef)(null); 4074 const onFocusReturnRef = (0,external_wp_element_namespaceObject.useRef)(onFocusReturn); 4075 (0,external_wp_element_namespaceObject.useEffect)(() => { 4076 onFocusReturnRef.current = onFocusReturn; 4077 }, [onFocusReturn]); 4078 return (0,external_wp_element_namespaceObject.useCallback)(node => { 4079 if (node) { 4080 // Set ref to be used when unmounting. 4081 ref.current = node; 4082 4083 // Only set when the node mounts. 4084 if (focusedBeforeMount.current) { 4085 return; 4086 } 4087 focusedBeforeMount.current = node.ownerDocument.activeElement; 4088 } else if (focusedBeforeMount.current) { 4089 const isFocused = ref.current?.contains(ref.current?.ownerDocument.activeElement); 4090 if (ref.current?.isConnected && !isFocused) { 4091 var _origin; 4092 (_origin = origin) !== null && _origin !== void 0 ? _origin : origin = focusedBeforeMount.current; 4093 return; 4094 } 4095 4096 // Defer to the component's own explicit focus return behavior, if 4097 // specified. This allows for support that the `onFocusReturn` 4098 // decides to allow the default behavior to occur under some 4099 // conditions. 4100 if (onFocusReturnRef.current) { 4101 onFocusReturnRef.current(); 4102 } else { 4103 /** @type {null|HTMLElement} */(!focusedBeforeMount.current.isConnected ? origin : focusedBeforeMount.current)?.focus(); 4104 } 4105 origin = null; 4106 } 4107 }, []); 4108 } 4109 /* harmony default export */ const use_focus_return = (useFocusReturn); 4110 4111 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focus-outside/index.js 4112 /** 4113 * WordPress dependencies 4114 */ 4115 4116 4117 /** 4118 * Input types which are classified as button types, for use in considering 4119 * whether element is a (focus-normalized) button. 4120 */ 4121 const INPUT_BUTTON_TYPES = ['button', 'submit']; 4122 4123 /** 4124 * List of HTML button elements subject to focus normalization 4125 * 4126 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 4127 */ 4128 4129 /** 4130 * Returns true if the given element is a button element subject to focus 4131 * normalization, or false otherwise. 4132 * 4133 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 4134 * 4135 * @param eventTarget The target from a mouse or touch event. 4136 * 4137 * @return Whether the element is a button element subject to focus normalization. 4138 */ 4139 function isFocusNormalizedButton(eventTarget) { 4140 if (!(eventTarget instanceof window.HTMLElement)) { 4141 return false; 4142 } 4143 switch (eventTarget.nodeName) { 4144 case 'A': 4145 case 'BUTTON': 4146 return true; 4147 case 'INPUT': 4148 return INPUT_BUTTON_TYPES.includes(eventTarget.type); 4149 } 4150 return false; 4151 } 4152 /** 4153 * A react hook that can be used to check whether focus has moved outside the 4154 * element the event handlers are bound to. 4155 * 4156 * @param onFocusOutside A callback triggered when focus moves outside 4157 * the element the event handlers are bound to. 4158 * 4159 * @return An object containing event handlers. Bind the event handlers to a 4160 * wrapping element element to capture when focus moves outside that element. 4161 */ 4162 function useFocusOutside(onFocusOutside) { 4163 const currentOnFocusOutsideRef = (0,external_wp_element_namespaceObject.useRef)(onFocusOutside); 4164 (0,external_wp_element_namespaceObject.useEffect)(() => { 4165 currentOnFocusOutsideRef.current = onFocusOutside; 4166 }, [onFocusOutside]); 4167 const preventBlurCheckRef = (0,external_wp_element_namespaceObject.useRef)(false); 4168 const blurCheckTimeoutIdRef = (0,external_wp_element_namespaceObject.useRef)(); 4169 4170 /** 4171 * Cancel a blur check timeout. 4172 */ 4173 const cancelBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(() => { 4174 clearTimeout(blurCheckTimeoutIdRef.current); 4175 }, []); 4176 4177 // Cancel blur checks on unmount. 4178 (0,external_wp_element_namespaceObject.useEffect)(() => { 4179 return () => cancelBlurCheck(); 4180 }, []); 4181 4182 // Cancel a blur check if the callback or ref is no longer provided. 4183 (0,external_wp_element_namespaceObject.useEffect)(() => { 4184 if (!onFocusOutside) { 4185 cancelBlurCheck(); 4186 } 4187 }, [onFocusOutside, cancelBlurCheck]); 4188 4189 /** 4190 * Handles a mousedown or mouseup event to respectively assign and 4191 * unassign a flag for preventing blur check on button elements. Some 4192 * browsers, namely Firefox and Safari, do not emit a focus event on 4193 * button elements when clicked, while others do. The logic here 4194 * intends to normalize this as treating click on buttons as focus. 4195 * 4196 * @param event 4197 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus 4198 */ 4199 const normalizeButtonFocus = (0,external_wp_element_namespaceObject.useCallback)(event => { 4200 const { 4201 type, 4202 target 4203 } = event; 4204 const isInteractionEnd = ['mouseup', 'touchend'].includes(type); 4205 if (isInteractionEnd) { 4206 preventBlurCheckRef.current = false; 4207 } else if (isFocusNormalizedButton(target)) { 4208 preventBlurCheckRef.current = true; 4209 } 4210 }, []); 4211 4212 /** 4213 * A callback triggered when a blur event occurs on the element the handler 4214 * is bound to. 4215 * 4216 * Calls the `onFocusOutside` callback in an immediate timeout if focus has 4217 * move outside the bound element and is still within the document. 4218 */ 4219 const queueBlurCheck = (0,external_wp_element_namespaceObject.useCallback)(event => { 4220 // React does not allow using an event reference asynchronously 4221 // due to recycling behavior, except when explicitly persisted. 4222 event.persist(); 4223 4224 // Skip blur check if clicking button. See `normalizeButtonFocus`. 4225 if (preventBlurCheckRef.current) { 4226 return; 4227 } 4228 4229 // The usage of this attribute should be avoided. The only use case 4230 // would be when we load modals that are not React components and 4231 // therefore don't exist in the React tree. An example is opening 4232 // the Media Library modal from another dialog. 4233 // This attribute should contain a selector of the related target 4234 // we want to ignore, because we still need to trigger the blur event 4235 // on all other cases. 4236 const ignoreForRelatedTarget = event.target.getAttribute('data-unstable-ignore-focus-outside-for-relatedtarget'); 4237 if (ignoreForRelatedTarget && event.relatedTarget?.closest(ignoreForRelatedTarget)) { 4238 return; 4239 } 4240 blurCheckTimeoutIdRef.current = setTimeout(() => { 4241 // If document is not focused then focus should remain 4242 // inside the wrapped component and therefore we cancel 4243 // this blur event thereby leaving focus in place. 4244 // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasFocus. 4245 if (!document.hasFocus()) { 4246 event.preventDefault(); 4247 return; 4248 } 4249 if ('function' === typeof currentOnFocusOutsideRef.current) { 4250 currentOnFocusOutsideRef.current(event); 4251 } 4252 }, 0); 4253 }, []); 4254 return { 4255 onFocus: cancelBlurCheck, 4256 onMouseDown: normalizeButtonFocus, 4257 onMouseUp: normalizeButtonFocus, 4258 onTouchStart: normalizeButtonFocus, 4259 onTouchEnd: normalizeButtonFocus, 4260 onBlur: queueBlurCheck 4261 }; 4262 } 4263 4264 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-merge-refs/index.js 4265 /** 4266 * WordPress dependencies 4267 */ 4268 4269 4270 /* eslint-disable jsdoc/valid-types */ 4271 /** 4272 * @template T 4273 * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef 4274 */ 4275 /* eslint-enable jsdoc/valid-types */ 4276 4277 /** 4278 * @template T 4279 * @param {import('react').Ref<T>} ref 4280 * @param {T} value 4281 */ 4282 function assignRef(ref, value) { 4283 if (typeof ref === 'function') { 4284 ref(value); 4285 } else if (ref && ref.hasOwnProperty('current')) { 4286 /* eslint-disable jsdoc/no-undefined-types */ 4287 /** @type {import('react').MutableRefObject<T>} */ref.current = value; 4288 /* eslint-enable jsdoc/no-undefined-types */ 4289 } 4290 } 4291 4292 /** 4293 * Merges refs into one ref callback. 4294 * 4295 * It also ensures that the merged ref callbacks are only called when they 4296 * change (as a result of a `useCallback` dependency update) OR when the ref 4297 * value changes, just as React does when passing a single ref callback to the 4298 * component. 4299 * 4300 * As expected, if you pass a new function on every render, the ref callback 4301 * will be called after every render. 4302 * 4303 * If you don't wish a ref callback to be called after every render, wrap it 4304 * with `useCallback( callback, dependencies )`. When a dependency changes, the 4305 * old ref callback will be called with `null` and the new ref callback will be 4306 * called with the same value. 4307 * 4308 * To make ref callbacks easier to use, you can also pass the result of 4309 * `useRefEffect`, which makes cleanup easier by allowing you to return a 4310 * cleanup function instead of handling `null`. 4311 * 4312 * It's also possible to _disable_ a ref (and its behaviour) by simply not 4313 * passing the ref. 4314 * 4315 * ```jsx 4316 * const ref = useRefEffect( ( node ) => { 4317 * node.addEventListener( ... ); 4318 * return () => { 4319 * node.removeEventListener( ... ); 4320 * }; 4321 * }, [ ...dependencies ] ); 4322 * const otherRef = useRef(); 4323 * const mergedRefs useMergeRefs( [ 4324 * enabled && ref, 4325 * otherRef, 4326 * ] ); 4327 * return <div ref={ mergedRefs } />; 4328 * ``` 4329 * 4330 * @template {import('react').Ref<any>} TRef 4331 * @param {Array<TRef>} refs The refs to be merged. 4332 * 4333 * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback. 4334 */ 4335 function useMergeRefs(refs) { 4336 const element = (0,external_wp_element_namespaceObject.useRef)(); 4337 const isAttachedRef = (0,external_wp_element_namespaceObject.useRef)(false); 4338 const didElementChangeRef = (0,external_wp_element_namespaceObject.useRef)(false); 4339 /* eslint-disable jsdoc/no-undefined-types */ 4340 /** @type {import('react').MutableRefObject<TRef[]>} */ 4341 /* eslint-enable jsdoc/no-undefined-types */ 4342 const previousRefsRef = (0,external_wp_element_namespaceObject.useRef)([]); 4343 const currentRefsRef = (0,external_wp_element_namespaceObject.useRef)(refs); 4344 4345 // Update on render before the ref callback is called, so the ref callback 4346 // always has access to the current refs. 4347 currentRefsRef.current = refs; 4348 4349 // If any of the refs change, call the previous ref with `null` and the new 4350 // ref with the node, except when the element changes in the same cycle, in 4351 // which case the ref callbacks will already have been called. 4352 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 4353 if (didElementChangeRef.current === false && isAttachedRef.current === true) { 4354 refs.forEach((ref, index) => { 4355 const previousRef = previousRefsRef.current[index]; 4356 if (ref !== previousRef) { 4357 assignRef(previousRef, null); 4358 assignRef(ref, element.current); 4359 } 4360 }); 4361 } 4362 previousRefsRef.current = refs; 4363 }, refs); 4364 4365 // No dependencies, must be reset after every render so ref callbacks are 4366 // correctly called after a ref change. 4367 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 4368 didElementChangeRef.current = false; 4369 }); 4370 4371 // There should be no dependencies so that `callback` is only called when 4372 // the node changes. 4373 return (0,external_wp_element_namespaceObject.useCallback)(value => { 4374 // Update the element so it can be used when calling ref callbacks on a 4375 // dependency change. 4376 assignRef(element, value); 4377 didElementChangeRef.current = true; 4378 isAttachedRef.current = value !== null; 4379 4380 // When an element changes, the current ref callback should be called 4381 // with the new element and the previous one with `null`. 4382 const refsToAssign = value ? currentRefsRef.current : previousRefsRef.current; 4383 4384 // Update the latest refs. 4385 for (const ref of refsToAssign) { 4386 assignRef(ref, value); 4387 } 4388 }, []); 4389 } 4390 4391 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-dialog/index.js 4392 /** 4393 * External dependencies 4394 */ 4395 4396 /** 4397 * WordPress dependencies 4398 */ 4399 4400 4401 4402 /** 4403 * Internal dependencies 4404 */ 4405 4406 4407 4408 4409 4410 /** 4411 * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors: 4412 * - constrained tabbing. 4413 * - focus on mount. 4414 * - return focus on unmount. 4415 * - focus outside. 4416 * 4417 * @param options Dialog Options. 4418 */ 4419 function useDialog(options) { 4420 const currentOptions = (0,external_wp_element_namespaceObject.useRef)(); 4421 const { 4422 constrainTabbing = options.focusOnMount !== false 4423 } = options; 4424 (0,external_wp_element_namespaceObject.useEffect)(() => { 4425 currentOptions.current = options; 4426 }, Object.values(options)); 4427 const constrainedTabbingRef = use_constrained_tabbing(); 4428 const focusOnMountRef = useFocusOnMount(options.focusOnMount); 4429 const focusReturnRef = use_focus_return(); 4430 const focusOutsideProps = useFocusOutside(event => { 4431 // This unstable prop is here only to manage backward compatibility 4432 // for the Popover component otherwise, the onClose should be enough. 4433 if (currentOptions.current?.__unstableOnClose) { 4434 currentOptions.current.__unstableOnClose('focus-outside', event); 4435 } else if (currentOptions.current?.onClose) { 4436 currentOptions.current.onClose(); 4437 } 4438 }); 4439 const closeOnEscapeRef = (0,external_wp_element_namespaceObject.useCallback)(node => { 4440 if (!node) { 4441 return; 4442 } 4443 node.addEventListener('keydown', event => { 4444 // Close on escape. 4445 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) { 4446 event.preventDefault(); 4447 currentOptions.current.onClose(); 4448 } 4449 }); 4450 }, []); 4451 return [useMergeRefs([constrainTabbing ? constrainedTabbingRef : null, options.focusOnMount !== false ? focusReturnRef : null, options.focusOnMount !== false ? focusOnMountRef : null, closeOnEscapeRef]), { 4452 ...focusOutsideProps, 4453 tabIndex: -1 4454 }]; 4455 } 4456 /* harmony default export */ const use_dialog = (useDialog); 4457 4458 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-disabled/index.js 4459 /** 4460 * Internal dependencies 4461 */ 4462 4463 4464 4465 /** 4466 * In some circumstances, such as block previews, all focusable DOM elements 4467 * (input fields, links, buttons, etc.) need to be disabled. This hook adds the 4468 * behavior to disable nested DOM elements to the returned ref. 4469 * 4470 * If you can, prefer the use of the inert HTML attribute. 4471 * 4472 * @param {Object} config Configuration object. 4473 * @param {boolean=} config.isDisabled Whether the element should be disabled. 4474 * @return {import('react').RefCallback<HTMLElement>} Element Ref. 4475 * 4476 * @example 4477 * ```js 4478 * import { useDisabled } from '@wordpress/compose'; 4479 * 4480 * const DisabledExample = () => { 4481 * const disabledRef = useDisabled(); 4482 * return ( 4483 * <div ref={ disabledRef }> 4484 * <a href="#">This link will have tabindex set to -1</a> 4485 * <input placeholder="This input will have the disabled attribute added to it." type="text" /> 4486 * </div> 4487 * ); 4488 * }; 4489 * ``` 4490 */ 4491 function useDisabled({ 4492 isDisabled: isDisabledProp = false 4493 } = {}) { 4494 return useRefEffect(node => { 4495 if (isDisabledProp) { 4496 return; 4497 } 4498 const defaultView = node?.ownerDocument?.defaultView; 4499 if (!defaultView) { 4500 return; 4501 } 4502 4503 /** A variable keeping track of the previous updates in order to restore them. */ 4504 const updates = []; 4505 const disable = () => { 4506 node.childNodes.forEach(child => { 4507 if (!(child instanceof defaultView.HTMLElement)) { 4508 return; 4509 } 4510 if (!child.getAttribute('inert')) { 4511 child.setAttribute('inert', 'true'); 4512 updates.push(() => { 4513 child.removeAttribute('inert'); 4514 }); 4515 } 4516 }); 4517 }; 4518 4519 // Debounce re-disable since disabling process itself will incur 4520 // additional mutations which should be ignored. 4521 const debouncedDisable = debounce(disable, 0, { 4522 leading: true 4523 }); 4524 disable(); 4525 4526 /** @type {MutationObserver | undefined} */ 4527 const observer = new window.MutationObserver(debouncedDisable); 4528 observer.observe(node, { 4529 childList: true 4530 }); 4531 return () => { 4532 if (observer) { 4533 observer.disconnect(); 4534 } 4535 debouncedDisable.cancel(); 4536 updates.forEach(update => update()); 4537 }; 4538 }, [isDisabledProp]); 4539 } 4540 4541 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-event/index.js 4542 /** 4543 * WordPress dependencies 4544 */ 4545 4546 4547 /** 4548 * Any function. 4549 */ 4550 4551 /** 4552 * Creates a stable callback function that has access to the latest state and 4553 * can be used within event handlers and effect callbacks. Throws when used in 4554 * the render phase. 4555 * 4556 * @param callback The callback function to wrap. 4557 * 4558 * @example 4559 * 4560 * ```tsx 4561 * function Component( props ) { 4562 * const onClick = useEvent( props.onClick ); 4563 * useEffect( () => { 4564 * onClick(); 4565 * // Won't trigger the effect again when props.onClick is updated. 4566 * }, [ onClick ] ); 4567 * // Won't re-render Button when props.onClick is updated (if `Button` is 4568 * // wrapped in `React.memo`). 4569 * return <Button onClick={ onClick } />; 4570 * } 4571 * ``` 4572 */ 4573 function useEvent( 4574 /** 4575 * The callback function to wrap. 4576 */ 4577 callback) { 4578 const ref = (0,external_wp_element_namespaceObject.useRef)(() => { 4579 throw new Error('Callbacks created with `useEvent` cannot be called during rendering.'); 4580 }); 4581 (0,external_wp_element_namespaceObject.useInsertionEffect)(() => { 4582 ref.current = callback; 4583 }); 4584 return (0,external_wp_element_namespaceObject.useCallback)((...args) => ref.current?.(...args), []); 4585 } 4586 4587 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-isomorphic-layout-effect/index.js 4588 /** 4589 * WordPress dependencies 4590 */ 4591 4592 4593 /** 4594 * Preferred over direct usage of `useLayoutEffect` when supporting 4595 * server rendered components (SSR) because currently React 4596 * throws a warning when using useLayoutEffect in that environment. 4597 */ 4598 const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? external_wp_element_namespaceObject.useLayoutEffect : external_wp_element_namespaceObject.useEffect; 4599 /* harmony default export */ const use_isomorphic_layout_effect = (useIsomorphicLayoutEffect); 4600 4601 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-dragging/index.js 4602 /** 4603 * WordPress dependencies 4604 */ 4605 4606 4607 /** 4608 * Internal dependencies 4609 */ 4610 4611 4612 // Event handlers that are triggered from `document` listeners accept a MouseEvent, 4613 // while those triggered from React listeners accept a React.MouseEvent. 4614 /** 4615 * @param {Object} props 4616 * @param {(e: import('react').MouseEvent) => void} props.onDragStart 4617 * @param {(e: MouseEvent) => void} props.onDragMove 4618 * @param {(e?: MouseEvent) => void} props.onDragEnd 4619 */ 4620 function useDragging({ 4621 onDragStart, 4622 onDragMove, 4623 onDragEnd 4624 }) { 4625 const [isDragging, setIsDragging] = (0,external_wp_element_namespaceObject.useState)(false); 4626 const eventsRef = (0,external_wp_element_namespaceObject.useRef)({ 4627 onDragStart, 4628 onDragMove, 4629 onDragEnd 4630 }); 4631 use_isomorphic_layout_effect(() => { 4632 eventsRef.current.onDragStart = onDragStart; 4633 eventsRef.current.onDragMove = onDragMove; 4634 eventsRef.current.onDragEnd = onDragEnd; 4635 }, [onDragStart, onDragMove, onDragEnd]); 4636 4637 /** @type {(e: MouseEvent) => void} */ 4638 const onMouseMove = (0,external_wp_element_namespaceObject.useCallback)(event => eventsRef.current.onDragMove && eventsRef.current.onDragMove(event), []); 4639 /** @type {(e?: MouseEvent) => void} */ 4640 const endDrag = (0,external_wp_element_namespaceObject.useCallback)(event => { 4641 if (eventsRef.current.onDragEnd) { 4642 eventsRef.current.onDragEnd(event); 4643 } 4644 document.removeEventListener('mousemove', onMouseMove); 4645 document.removeEventListener('mouseup', endDrag); 4646 setIsDragging(false); 4647 }, []); 4648 /** @type {(e: import('react').MouseEvent) => void} */ 4649 const startDrag = (0,external_wp_element_namespaceObject.useCallback)(event => { 4650 if (eventsRef.current.onDragStart) { 4651 eventsRef.current.onDragStart(event); 4652 } 4653 document.addEventListener('mousemove', onMouseMove); 4654 document.addEventListener('mouseup', endDrag); 4655 setIsDragging(true); 4656 }, []); 4657 4658 // Remove the global events when unmounting if needed. 4659 (0,external_wp_element_namespaceObject.useEffect)(() => { 4660 return () => { 4661 if (isDragging) { 4662 document.removeEventListener('mousemove', onMouseMove); 4663 document.removeEventListener('mouseup', endDrag); 4664 } 4665 }; 4666 }, [isDragging]); 4667 return { 4668 startDrag, 4669 endDrag, 4670 isDragging 4671 }; 4672 } 4673 4674 // EXTERNAL MODULE: ./node_modules/mousetrap/mousetrap.js 4675 var mousetrap_mousetrap = __webpack_require__(1933); 4676 var mousetrap_default = /*#__PURE__*/__webpack_require__.n(mousetrap_mousetrap); 4677 // EXTERNAL MODULE: ./node_modules/mousetrap/plugins/global-bind/mousetrap-global-bind.js 4678 var mousetrap_global_bind = __webpack_require__(5760); 4679 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-keyboard-shortcut/index.js 4680 /** 4681 * External dependencies 4682 */ 4683 4684 4685 4686 /** 4687 * WordPress dependencies 4688 */ 4689 4690 4691 4692 /** 4693 * A block selection object. 4694 * 4695 * @typedef {Object} WPKeyboardShortcutConfig 4696 * 4697 * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields. 4698 * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown. 4699 * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true. 4700 * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event. 4701 */ 4702 4703 /* eslint-disable jsdoc/valid-types */ 4704 /** 4705 * Attach a keyboard shortcut handler. 4706 * 4707 * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter. 4708 * 4709 * @param {string[]|string} shortcuts Keyboard Shortcuts. 4710 * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback. 4711 * @param {WPKeyboardShortcutConfig} options Shortcut options. 4712 */ 4713 function useKeyboardShortcut( /* eslint-enable jsdoc/valid-types */ 4714 shortcuts, callback, { 4715 bindGlobal = false, 4716 eventName = 'keydown', 4717 isDisabled = false, 4718 // This is important for performance considerations. 4719 target 4720 } = {}) { 4721 const currentCallbackRef = (0,external_wp_element_namespaceObject.useRef)(callback); 4722 (0,external_wp_element_namespaceObject.useEffect)(() => { 4723 currentCallbackRef.current = callback; 4724 }, [callback]); 4725 (0,external_wp_element_namespaceObject.useEffect)(() => { 4726 if (isDisabled) { 4727 return; 4728 } 4729 const mousetrap = new (mousetrap_default())(target && target.current ? target.current : 4730 // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`. 4731 // 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 4732 // necessary to maintain the existing behavior. 4733 /** @type {Element} */ /** @type {unknown} */ 4734 document); 4735 const shortcutsArray = Array.isArray(shortcuts) ? shortcuts : [shortcuts]; 4736 shortcutsArray.forEach(shortcut => { 4737 const keys = shortcut.split('+'); 4738 // Determines whether a key is a modifier by the length of the string. 4739 // E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that 4740 // the modifiers are Shift and Cmd because they're not a single character. 4741 const modifiers = new Set(keys.filter(value => value.length > 1)); 4742 const hasAlt = modifiers.has('alt'); 4743 const hasShift = modifiers.has('shift'); 4744 4745 // This should be better moved to the shortcut registration instead. 4746 if ((0,external_wp_keycodes_namespaceObject.isAppleOS)() && (modifiers.size === 1 && hasAlt || modifiers.size === 2 && hasAlt && hasShift)) { 4747 throw new Error(`Cannot bind $shortcut}. Alt and Shift+Alt modifiers are reserved for character input.`); 4748 } 4749 const bindFn = bindGlobal ? 'bindGlobal' : 'bind'; 4750 // @ts-ignore `bindGlobal` is an undocumented property 4751 mousetrap[bindFn](shortcut, ( /* eslint-disable jsdoc/valid-types */ 4752 /** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */...args) => /* eslint-enable jsdoc/valid-types */ 4753 currentCallbackRef.current(...args), eventName); 4754 }); 4755 return () => { 4756 mousetrap.reset(); 4757 }; 4758 }, [shortcuts, bindGlobal, eventName, target, isDisabled]); 4759 } 4760 /* harmony default export */ const use_keyboard_shortcut = (useKeyboardShortcut); 4761 4762 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-media-query/index.js 4763 /** 4764 * WordPress dependencies 4765 */ 4766 4767 const matchMediaCache = new Map(); 4768 4769 /** 4770 * A new MediaQueryList object for the media query 4771 * 4772 * @param {string} [query] Media Query. 4773 * @return {MediaQueryList|null} A new object for the media query 4774 */ 4775 function getMediaQueryList(query) { 4776 if (!query) { 4777 return null; 4778 } 4779 let match = matchMediaCache.get(query); 4780 if (match) { 4781 return match; 4782 } 4783 if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') { 4784 match = window.matchMedia(query); 4785 matchMediaCache.set(query, match); 4786 return match; 4787 } 4788 return null; 4789 } 4790 4791 /** 4792 * Runs a media query and returns its value when it changes. 4793 * 4794 * @param {string} [query] Media Query. 4795 * @return {boolean} return value of the media query. 4796 */ 4797 function useMediaQuery(query) { 4798 const source = (0,external_wp_element_namespaceObject.useMemo)(() => { 4799 const mediaQueryList = getMediaQueryList(query); 4800 return { 4801 /** @type {(onStoreChange: () => void) => () => void} */ 4802 subscribe(onStoreChange) { 4803 if (!mediaQueryList) { 4804 return () => {}; 4805 } 4806 4807 // Avoid a fatal error when browsers don't support `addEventListener` on MediaQueryList. 4808 mediaQueryList.addEventListener?.('change', onStoreChange); 4809 return () => { 4810 mediaQueryList.removeEventListener?.('change', onStoreChange); 4811 }; 4812 }, 4813 getValue() { 4814 var _mediaQueryList$match; 4815 return (_mediaQueryList$match = mediaQueryList?.matches) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false; 4816 } 4817 }; 4818 }, [query]); 4819 return (0,external_wp_element_namespaceObject.useSyncExternalStore)(source.subscribe, source.getValue, () => false); 4820 } 4821 4822 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-previous/index.js 4823 /** 4824 * WordPress dependencies 4825 */ 4826 4827 4828 /** 4829 * Use something's value from the previous render. 4830 * Based on https://usehooks.com/usePrevious/. 4831 * 4832 * @param value The value to track. 4833 * 4834 * @return The value from the previous render. 4835 */ 4836 function usePrevious(value) { 4837 const ref = (0,external_wp_element_namespaceObject.useRef)(); 4838 4839 // Store current value in ref. 4840 (0,external_wp_element_namespaceObject.useEffect)(() => { 4841 ref.current = value; 4842 }, [value]); // Re-run when value changes. 4843 4844 // Return previous value (happens before update in useEffect above). 4845 return ref.current; 4846 } 4847 4848 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-reduced-motion/index.js 4849 /** 4850 * Internal dependencies 4851 */ 4852 4853 4854 /** 4855 * Hook returning whether the user has a preference for reduced motion. 4856 * 4857 * @return {boolean} Reduced motion preference value. 4858 */ 4859 const useReducedMotion = () => useMediaQuery('(prefers-reduced-motion: reduce)'); 4860 /* harmony default export */ const use_reduced_motion = (useReducedMotion); 4861 4862 // EXTERNAL MODULE: ./node_modules/@wordpress/undo-manager/build-module/index.js 4863 var build_module = __webpack_require__(6689); 4864 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-state-with-history/index.js 4865 /** 4866 * WordPress dependencies 4867 */ 4868 4869 4870 function undoRedoReducer(state, action) { 4871 switch (action.type) { 4872 case 'UNDO': 4873 { 4874 const undoRecord = state.manager.undo(); 4875 if (undoRecord) { 4876 return { 4877 ...state, 4878 value: undoRecord[0].changes.prop.from 4879 }; 4880 } 4881 return state; 4882 } 4883 case 'REDO': 4884 { 4885 const redoRecord = state.manager.redo(); 4886 if (redoRecord) { 4887 return { 4888 ...state, 4889 value: redoRecord[0].changes.prop.to 4890 }; 4891 } 4892 return state; 4893 } 4894 case 'RECORD': 4895 { 4896 state.manager.addRecord([{ 4897 id: 'object', 4898 changes: { 4899 prop: { 4900 from: state.value, 4901 to: action.value 4902 } 4903 } 4904 }], action.isStaged); 4905 return { 4906 ...state, 4907 value: action.value 4908 }; 4909 } 4910 } 4911 return state; 4912 } 4913 function initReducer(value) { 4914 return { 4915 manager: (0,build_module.createUndoManager)(), 4916 value 4917 }; 4918 } 4919 4920 /** 4921 * useState with undo/redo history. 4922 * 4923 * @param initialValue Initial value. 4924 * @return Value, setValue, hasUndo, hasRedo, undo, redo. 4925 */ 4926 function useStateWithHistory(initialValue) { 4927 const [state, dispatch] = (0,external_wp_element_namespaceObject.useReducer)(undoRedoReducer, initialValue, initReducer); 4928 return { 4929 value: state.value, 4930 setValue: (0,external_wp_element_namespaceObject.useCallback)((newValue, isStaged) => { 4931 dispatch({ 4932 type: 'RECORD', 4933 value: newValue, 4934 isStaged 4935 }); 4936 }, []), 4937 hasUndo: state.manager.hasUndo(), 4938 hasRedo: state.manager.hasRedo(), 4939 undo: (0,external_wp_element_namespaceObject.useCallback)(() => { 4940 dispatch({ 4941 type: 'UNDO' 4942 }); 4943 }, []), 4944 redo: (0,external_wp_element_namespaceObject.useCallback)(() => { 4945 dispatch({ 4946 type: 'REDO' 4947 }); 4948 }, []) 4949 }; 4950 } 4951 4952 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-viewport-match/index.js 4953 /** 4954 * WordPress dependencies 4955 */ 4956 4957 4958 /** 4959 * Internal dependencies 4960 */ 4961 4962 4963 /** 4964 * @typedef {"xhuge" | "huge" | "wide" | "xlarge" | "large" | "medium" | "small" | "mobile"} WPBreakpoint 4965 */ 4966 4967 /** 4968 * Hash of breakpoint names with pixel width at which it becomes effective. 4969 * 4970 * @see _breakpoints.scss 4971 * 4972 * @type {Record<WPBreakpoint, number>} 4973 */ 4974 const BREAKPOINTS = { 4975 xhuge: 1920, 4976 huge: 1440, 4977 wide: 1280, 4978 xlarge: 1080, 4979 large: 960, 4980 medium: 782, 4981 small: 600, 4982 mobile: 480 4983 }; 4984 4985 /** 4986 * @typedef {">=" | "<"} WPViewportOperator 4987 */ 4988 4989 /** 4990 * Object mapping media query operators to the condition to be used. 4991 * 4992 * @type {Record<WPViewportOperator, string>} 4993 */ 4994 const CONDITIONS = { 4995 '>=': 'min-width', 4996 '<': 'max-width' 4997 }; 4998 4999 /** 5000 * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values. 5001 * 5002 * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>} 5003 */ 5004 const OPERATOR_EVALUATORS = { 5005 '>=': (breakpointValue, width) => width >= breakpointValue, 5006 '<': (breakpointValue, width) => width < breakpointValue 5007 }; 5008 const ViewportMatchWidthContext = (0,external_wp_element_namespaceObject.createContext)( /** @type {null | number} */null); 5009 5010 /** 5011 * Returns true if the viewport matches the given query, or false otherwise. 5012 * 5013 * @param {WPBreakpoint} breakpoint Breakpoint size name. 5014 * @param {WPViewportOperator} [operator=">="] Viewport operator. 5015 * 5016 * @example 5017 * 5018 * ```js 5019 * useViewportMatch( 'huge', '<' ); 5020 * useViewportMatch( 'medium' ); 5021 * ``` 5022 * 5023 * @return {boolean} Whether viewport matches query. 5024 */ 5025 const useViewportMatch = (breakpoint, operator = '>=') => { 5026 const simulatedWidth = (0,external_wp_element_namespaceObject.useContext)(ViewportMatchWidthContext); 5027 const mediaQuery = !simulatedWidth && `($CONDITIONS[operator]}: $BREAKPOINTS[breakpoint]}px)`; 5028 const mediaQueryResult = useMediaQuery(mediaQuery || undefined); 5029 if (simulatedWidth) { 5030 return OPERATOR_EVALUATORS[operator](BREAKPOINTS[breakpoint], simulatedWidth); 5031 } 5032 return mediaQueryResult; 5033 }; 5034 useViewportMatch.__experimentalWidthProvider = ViewportMatchWidthContext.Provider; 5035 /* harmony default export */ const use_viewport_match = (useViewportMatch); 5036 5037 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/use-resize-observer.js 5038 /** 5039 * WordPress dependencies 5040 */ 5041 5042 /** 5043 * Internal dependencies 5044 */ 5045 5046 5047 // This is the current implementation of `useResizeObserver`. 5048 // 5049 // The legacy implementation is still supported for backwards compatibility. 5050 // This is achieved by overloading the exported function with both signatures, 5051 // and detecting which API is being used at runtime. 5052 function useResizeObserver(callback, resizeObserverOptions = {}) { 5053 const callbackEvent = useEvent(callback); 5054 const observedElementRef = (0,external_wp_element_namespaceObject.useRef)(); 5055 const resizeObserverRef = (0,external_wp_element_namespaceObject.useRef)(); 5056 return useEvent(element => { 5057 var _resizeObserverRef$cu; 5058 if (element === observedElementRef.current) { 5059 return; 5060 } 5061 5062 // Set up `ResizeObserver`. 5063 (_resizeObserverRef$cu = resizeObserverRef.current) !== null && _resizeObserverRef$cu !== void 0 ? _resizeObserverRef$cu : resizeObserverRef.current = new ResizeObserver(callbackEvent); 5064 const { 5065 current: resizeObserver 5066 } = resizeObserverRef; 5067 5068 // Unobserve previous element. 5069 if (observedElementRef.current) { 5070 resizeObserver.unobserve(observedElementRef.current); 5071 } 5072 5073 // Observe new element. 5074 observedElementRef.current = element; 5075 if (element) { 5076 resizeObserver.observe(element, resizeObserverOptions); 5077 } 5078 }); 5079 } 5080 5081 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/legacy/index.js 5082 /** 5083 * External dependencies 5084 */ 5085 5086 /** 5087 * WordPress dependencies 5088 */ 5089 5090 /** 5091 * Internal dependencies 5092 */ 5093 5094 5095 // We're only using the first element of the size sequences, until future versions of the spec solidify on how 5096 // exactly it'll be used for fragments in multi-column scenarios: 5097 // From the spec: 5098 // > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments, 5099 // > which occur in multi-column scenarios. However the current definitions of content rect and border box do not 5100 // > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single 5101 // > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column. 5102 // > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information. 5103 // (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface) 5104 // 5105 // Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback, 5106 // regardless of the "box" option. 5107 // The spec states the following on this: 5108 // > This does not have any impact on which box dimensions are returned to the defined callback when the event 5109 // > is fired, it solely defines which box the author wishes to observe layout changes on. 5110 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) 5111 // I'm not exactly clear on what this means, especially when you consider a later section stating the following: 5112 // > This section is non-normative. An author may desire to observe more than one CSS box. 5113 // > In this case, author will need to use multiple ResizeObservers. 5114 // (https://drafts.csswg.org/resize-observer/#resize-observer-interface) 5115 // Which is clearly not how current browser implementations behave, and seems to contradict the previous quote. 5116 // For this reason I decided to only return the requested size, 5117 // even though it seems we have access to results for all box types. 5118 // This also means that we get to keep the current api, being able to return a simple { width, height } pair, 5119 // regardless of box option. 5120 const extractSize = entry => { 5121 let entrySize; 5122 if (!entry.contentBoxSize) { 5123 // The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec. 5124 // See the 6th step in the description for the RO algorithm: 5125 // https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h 5126 // > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box". 5127 // In real browser implementations of course these objects differ, but the width/height values should be equivalent. 5128 entrySize = [entry.contentRect.width, entry.contentRect.height]; 5129 } else if (entry.contentBoxSize[0]) { 5130 const contentBoxSize = entry.contentBoxSize[0]; 5131 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize]; 5132 } else { 5133 // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's buggy 5134 // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`. 5135 const contentBoxSize = entry.contentBoxSize; 5136 entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize]; 5137 } 5138 const [width, height] = entrySize.map(d => Math.round(d)); 5139 return { 5140 width, 5141 height 5142 }; 5143 }; 5144 const RESIZE_ELEMENT_STYLES = { 5145 position: 'absolute', 5146 top: 0, 5147 left: 0, 5148 right: 0, 5149 bottom: 0, 5150 pointerEvents: 'none', 5151 opacity: 0, 5152 overflow: 'hidden', 5153 zIndex: -1 5154 }; 5155 function ResizeElement({ 5156 onResize 5157 }) { 5158 const resizeElementRef = useResizeObserver(entries => { 5159 const newSize = extractSize(entries.at(-1)); // Entries are never empty. 5160 onResize(newSize); 5161 }); 5162 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { 5163 ref: resizeElementRef, 5164 style: RESIZE_ELEMENT_STYLES, 5165 "aria-hidden": "true" 5166 }); 5167 } 5168 function sizeEquals(a, b) { 5169 return a.width === b.width && a.height === b.height; 5170 } 5171 const NULL_SIZE = { 5172 width: null, 5173 height: null 5174 }; 5175 5176 /** 5177 * Hook which allows to listen to the resize event of any target element when it changes size. 5178 * _Note: `useResizeObserver` will report `null` sizes until after first render. 5179 * 5180 * @example 5181 * 5182 * ```js 5183 * const App = () => { 5184 * const [ resizeListener, sizes ] = useResizeObserver(); 5185 * 5186 * return ( 5187 * <div> 5188 * { resizeListener } 5189 * Your content here 5190 * </div> 5191 * ); 5192 * }; 5193 * ``` 5194 */ 5195 function useLegacyResizeObserver() { 5196 const [size, setSize] = (0,external_wp_element_namespaceObject.useState)(NULL_SIZE); 5197 5198 // Using a ref to track the previous width / height to avoid unnecessary renders. 5199 const previousSizeRef = (0,external_wp_element_namespaceObject.useRef)(NULL_SIZE); 5200 const handleResize = (0,external_wp_element_namespaceObject.useCallback)(newSize => { 5201 if (!sizeEquals(previousSizeRef.current, newSize)) { 5202 previousSizeRef.current = newSize; 5203 setSize(newSize); 5204 } 5205 }, []); 5206 const resizeElement = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeElement, { 5207 onResize: handleResize 5208 }); 5209 return [resizeElement, size]; 5210 } 5211 5212 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-resize-observer/index.js 5213 /** 5214 * Internal dependencies 5215 */ 5216 5217 5218 /** 5219 * External dependencies 5220 */ 5221 5222 /** 5223 * Sets up a [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API) 5224 * for an HTML or SVG element. 5225 * 5226 * Pass the returned setter as a callback ref to the React element you want 5227 * to observe, or use it in layout effects for advanced use cases. 5228 * 5229 * @example 5230 * 5231 * ```tsx 5232 * const setElement = useResizeObserver( 5233 * ( resizeObserverEntries ) => console.log( resizeObserverEntries ), 5234 * { box: 'border-box' } 5235 * ); 5236 * <div ref={ setElement } />; 5237 * 5238 * // The setter can be used in other ways, for example: 5239 * useLayoutEffect( () => { 5240 * setElement( document.querySelector( `data-element-id="${ elementId }"` ) ); 5241 * }, [ elementId ] ); 5242 * ``` 5243 * 5244 * @param callback The `ResizeObserver` callback - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback). 5245 * @param options Options passed to `ResizeObserver.observe` when called - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/observe#options). Changes will be ignored. 5246 */ 5247 5248 /** 5249 * **This is a legacy API and should not be used.** 5250 * 5251 * @deprecated Use the other `useResizeObserver` API instead: `const ref = useResizeObserver( ( entries ) => { ... } )`. 5252 * 5253 * Hook which allows to listen to the resize event of any target element when it changes size. 5254 * _Note: `useResizeObserver` will report `null` sizes until after first render. 5255 * 5256 * @example 5257 * 5258 * ```js 5259 * const App = () => { 5260 * const [ resizeListener, sizes ] = useResizeObserver(); 5261 * 5262 * return ( 5263 * <div> 5264 * { resizeListener } 5265 * Your content here 5266 * </div> 5267 * ); 5268 * }; 5269 * ``` 5270 */ 5271 5272 function use_resize_observer_useResizeObserver(callback, options = {}) { 5273 return callback ? useResizeObserver(callback, options) : useLegacyResizeObserver(); 5274 } 5275 5276 ;// external ["wp","priorityQueue"] 5277 const external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"]; 5278 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-async-list/index.js 5279 /** 5280 * WordPress dependencies 5281 */ 5282 5283 5284 /** 5285 * Returns the first items from list that are present on state. 5286 * 5287 * @param list New array. 5288 * @param state Current state. 5289 * @return First items present iin state. 5290 */ 5291 function getFirstItemsPresentInState(list, state) { 5292 const firstItems = []; 5293 for (let i = 0; i < list.length; i++) { 5294 const item = list[i]; 5295 if (!state.includes(item)) { 5296 break; 5297 } 5298 firstItems.push(item); 5299 } 5300 return firstItems; 5301 } 5302 5303 /** 5304 * React hook returns an array which items get asynchronously appended from a source array. 5305 * This behavior is useful if we want to render a list of items asynchronously for performance reasons. 5306 * 5307 * @param list Source array. 5308 * @param config Configuration object. 5309 * 5310 * @return Async array. 5311 */ 5312 function useAsyncList(list, config = { 5313 step: 1 5314 }) { 5315 const { 5316 step = 1 5317 } = config; 5318 const [current, setCurrent] = (0,external_wp_element_namespaceObject.useState)([]); 5319 (0,external_wp_element_namespaceObject.useEffect)(() => { 5320 // On reset, we keep the first items that were previously rendered. 5321 let firstItems = getFirstItemsPresentInState(list, current); 5322 if (firstItems.length < step) { 5323 firstItems = firstItems.concat(list.slice(firstItems.length, step)); 5324 } 5325 setCurrent(firstItems); 5326 const asyncQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)(); 5327 for (let i = firstItems.length; i < list.length; i += step) { 5328 asyncQueue.add({}, () => { 5329 (0,external_wp_element_namespaceObject.flushSync)(() => { 5330 setCurrent(state => [...state, ...list.slice(i, i + step)]); 5331 }); 5332 }); 5333 } 5334 return () => asyncQueue.reset(); 5335 }, [list]); 5336 return current; 5337 } 5338 /* harmony default export */ const use_async_list = (useAsyncList); 5339 5340 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-warn-on-change/index.js 5341 /** 5342 * Internal dependencies 5343 */ 5344 5345 5346 // Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case 5347 // but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript 5348 /* eslint-disable jsdoc/check-types */ 5349 /** 5350 * Hook that performs a shallow comparison between the preview value of an object 5351 * and the new one, if there's a difference, it prints it to the console. 5352 * this is useful in performance related work, to check why a component re-renders. 5353 * 5354 * @example 5355 * 5356 * ```jsx 5357 * function MyComponent(props) { 5358 * useWarnOnChange(props); 5359 * 5360 * return "Something"; 5361 * } 5362 * ``` 5363 * 5364 * @param {object} object Object which changes to compare. 5365 * @param {string} prefix Just a prefix to show when console logging. 5366 */ 5367 function useWarnOnChange(object, prefix = 'Change detection') { 5368 const previousValues = usePrevious(object); 5369 Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(([key, value]) => { 5370 if (value !== object[( /** @type {keyof typeof object} */key)]) { 5371 // eslint-disable-next-line no-console 5372 console.warn(`$prefix}: $key} key changed:`, value, object[( /** @type {keyof typeof object} */key)] 5373 /* eslint-enable jsdoc/check-types */); 5374 } 5375 }); 5376 } 5377 /* harmony default export */ const use_warn_on_change = (useWarnOnChange); 5378 5379 ;// external "React" 5380 const external_React_namespaceObject = window["React"]; 5381 ;// ./node_modules/use-memo-one/dist/use-memo-one.esm.js 5382 5383 5384 function areInputsEqual(newInputs, lastInputs) { 5385 if (newInputs.length !== lastInputs.length) { 5386 return false; 5387 } 5388 5389 for (var i = 0; i < newInputs.length; i++) { 5390 if (newInputs[i] !== lastInputs[i]) { 5391 return false; 5392 } 5393 } 5394 5395 return true; 5396 } 5397 5398 function useMemoOne(getResult, inputs) { 5399 var initial = (0,external_React_namespaceObject.useState)(function () { 5400 return { 5401 inputs: inputs, 5402 result: getResult() 5403 }; 5404 })[0]; 5405 var isFirstRun = (0,external_React_namespaceObject.useRef)(true); 5406 var committed = (0,external_React_namespaceObject.useRef)(initial); 5407 var useCache = isFirstRun.current || Boolean(inputs && committed.current.inputs && areInputsEqual(inputs, committed.current.inputs)); 5408 var cache = useCache ? committed.current : { 5409 inputs: inputs, 5410 result: getResult() 5411 }; 5412 (0,external_React_namespaceObject.useEffect)(function () { 5413 isFirstRun.current = false; 5414 committed.current = cache; 5415 }, [cache]); 5416 return cache.result; 5417 } 5418 function useCallbackOne(callback, inputs) { 5419 return useMemoOne(function () { 5420 return callback; 5421 }, inputs); 5422 } 5423 var useMemo = (/* unused pure expression or super */ null && (useMemoOne)); 5424 var useCallback = (/* unused pure expression or super */ null && (useCallbackOne)); 5425 5426 5427 5428 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-debounce/index.js 5429 /** 5430 * External dependencies 5431 */ 5432 5433 5434 /** 5435 * WordPress dependencies 5436 */ 5437 5438 5439 /** 5440 * Internal dependencies 5441 */ 5442 5443 5444 /** 5445 * Debounces a function similar to Lodash's `debounce`. A new debounced function will 5446 * be returned and any scheduled calls cancelled if any of the arguments change, 5447 * including the function to debounce, so please wrap functions created on 5448 * render in components in `useCallback`. 5449 * 5450 * @see https://lodash.com/docs/4#debounce 5451 * 5452 * @template {(...args: any[]) => void} TFunc 5453 * 5454 * @param {TFunc} fn The function to debounce. 5455 * @param {number} [wait] The number of milliseconds to delay. 5456 * @param {import('../../utils/debounce').DebounceOptions} [options] The options object. 5457 * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Debounced function. 5458 */ 5459 function useDebounce(fn, wait, options) { 5460 const debounced = useMemoOne(() => debounce(fn, wait !== null && wait !== void 0 ? wait : 0, options), [fn, wait, options]); 5461 (0,external_wp_element_namespaceObject.useEffect)(() => () => debounced.cancel(), [debounced]); 5462 return debounced; 5463 } 5464 5465 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-debounced-input/index.js 5466 /** 5467 * WordPress dependencies 5468 */ 5469 5470 5471 /** 5472 * Internal dependencies 5473 */ 5474 5475 5476 /** 5477 * Helper hook for input fields that need to debounce the value before using it. 5478 * 5479 * @param defaultValue The default value to use. 5480 * @return The input value, the setter and the debounced input value. 5481 */ 5482 function useDebouncedInput(defaultValue = '') { 5483 const [input, setInput] = (0,external_wp_element_namespaceObject.useState)(defaultValue); 5484 const [debouncedInput, setDebouncedState] = (0,external_wp_element_namespaceObject.useState)(defaultValue); 5485 const setDebouncedInput = useDebounce(setDebouncedState, 250); 5486 (0,external_wp_element_namespaceObject.useEffect)(() => { 5487 setDebouncedInput(input); 5488 }, [input, setDebouncedInput]); 5489 return [input, setInput, debouncedInput]; 5490 } 5491 5492 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-throttle/index.js 5493 /** 5494 * External dependencies 5495 */ 5496 5497 5498 /** 5499 * WordPress dependencies 5500 */ 5501 5502 5503 /** 5504 * Internal dependencies 5505 */ 5506 5507 5508 /** 5509 * Throttles a function similar to Lodash's `throttle`. A new throttled function will 5510 * be returned and any scheduled calls cancelled if any of the arguments change, 5511 * including the function to throttle, so please wrap functions created on 5512 * render in components in `useCallback`. 5513 * 5514 * @see https://lodash.com/docs/4#throttle 5515 * 5516 * @template {(...args: any[]) => void} TFunc 5517 * 5518 * @param {TFunc} fn The function to throttle. 5519 * @param {number} [wait] The number of milliseconds to throttle invocations to. 5520 * @param {import('../../utils/throttle').ThrottleOptions} [options] The options object. See linked documentation for details. 5521 * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Throttled function. 5522 */ 5523 function useThrottle(fn, wait, options) { 5524 const throttled = useMemoOne(() => throttle(fn, wait !== null && wait !== void 0 ? wait : 0, options), [fn, wait, options]); 5525 (0,external_wp_element_namespaceObject.useEffect)(() => () => throttled.cancel(), [throttled]); 5526 return throttled; 5527 } 5528 5529 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-drop-zone/index.js 5530 /** 5531 * WordPress dependencies 5532 */ 5533 5534 5535 /** 5536 * Internal dependencies 5537 */ 5538 5539 5540 /* eslint-disable jsdoc/valid-types */ 5541 /** 5542 * @template T 5543 * @param {T} value 5544 * @return {import('react').MutableRefObject<T|null>} A ref with the value. 5545 */ 5546 function useFreshRef(value) { 5547 /* eslint-enable jsdoc/valid-types */ 5548 /* eslint-disable jsdoc/no-undefined-types */ 5549 /** @type {import('react').MutableRefObject<T>} */ 5550 /* eslint-enable jsdoc/no-undefined-types */ 5551 // Disable reason: We're doing something pretty JavaScript-y here where the 5552 // ref will always have a current value that is not null or undefined but it 5553 // needs to start as undefined. We don't want to change the return type so 5554 // it's easier to just ts-ignore this specific line that's complaining about 5555 // undefined not being part of T. 5556 // @ts-ignore 5557 const ref = (0,external_wp_element_namespaceObject.useRef)(); 5558 ref.current = value; 5559 return ref; 5560 } 5561 5562 /** 5563 * A hook to facilitate drag and drop handling. 5564 * 5565 * @param {Object} props Named parameters. 5566 * @param {?HTMLElement} [props.dropZoneElement] Optional element to be used as the drop zone. 5567 * @param {boolean} [props.isDisabled] Whether or not to disable the drop zone. 5568 * @param {(e: DragEvent) => void} [props.onDragStart] Called when dragging has started. 5569 * @param {(e: DragEvent) => void} [props.onDragEnter] Called when the zone is entered. 5570 * @param {(e: DragEvent) => void} [props.onDragOver] Called when the zone is moved within. 5571 * @param {(e: DragEvent) => void} [props.onDragLeave] Called when the zone is left. 5572 * @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended. 5573 * @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone. 5574 * 5575 * @return {import('react').RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element. 5576 */ 5577 function useDropZone({ 5578 dropZoneElement, 5579 isDisabled, 5580 onDrop: _onDrop, 5581 onDragStart: _onDragStart, 5582 onDragEnter: _onDragEnter, 5583 onDragLeave: _onDragLeave, 5584 onDragEnd: _onDragEnd, 5585 onDragOver: _onDragOver 5586 }) { 5587 const onDropRef = useFreshRef(_onDrop); 5588 const onDragStartRef = useFreshRef(_onDragStart); 5589 const onDragEnterRef = useFreshRef(_onDragEnter); 5590 const onDragLeaveRef = useFreshRef(_onDragLeave); 5591 const onDragEndRef = useFreshRef(_onDragEnd); 5592 const onDragOverRef = useFreshRef(_onDragOver); 5593 return useRefEffect(elem => { 5594 if (isDisabled) { 5595 return; 5596 } 5597 5598 // If a custom dropZoneRef is passed, use that instead of the element. 5599 // This allows the dropzone to cover an expanded area, rather than 5600 // be restricted to the area of the ref returned by this hook. 5601 const element = dropZoneElement !== null && dropZoneElement !== void 0 ? dropZoneElement : elem; 5602 let isDragging = false; 5603 const { 5604 ownerDocument 5605 } = element; 5606 5607 /** 5608 * Checks if an element is in the drop zone. 5609 * 5610 * @param {EventTarget|null} targetToCheck 5611 * 5612 * @return {boolean} True if in drop zone, false if not. 5613 */ 5614 function isElementInZone(targetToCheck) { 5615 const { 5616 defaultView 5617 } = ownerDocument; 5618 if (!targetToCheck || !defaultView || !(targetToCheck instanceof defaultView.HTMLElement) || !element.contains(targetToCheck)) { 5619 return false; 5620 } 5621 5622 /** @type {HTMLElement|null} */ 5623 let elementToCheck = targetToCheck; 5624 do { 5625 if (elementToCheck.dataset.isDropZone) { 5626 return elementToCheck === element; 5627 } 5628 } while (elementToCheck = elementToCheck.parentElement); 5629 return false; 5630 } 5631 function maybeDragStart( /** @type {DragEvent} */event) { 5632 if (isDragging) { 5633 return; 5634 } 5635 isDragging = true; 5636 5637 // Note that `dragend` doesn't fire consistently for file and 5638 // HTML drag events where the drag origin is outside the browser 5639 // window. In Firefox it may also not fire if the originating 5640 // node is removed. 5641 ownerDocument.addEventListener('dragend', maybeDragEnd); 5642 ownerDocument.addEventListener('mousemove', maybeDragEnd); 5643 if (onDragStartRef.current) { 5644 onDragStartRef.current(event); 5645 } 5646 } 5647 function onDragEnter( /** @type {DragEvent} */event) { 5648 event.preventDefault(); 5649 5650 // The `dragenter` event will also fire when entering child 5651 // elements, but we only want to call `onDragEnter` when 5652 // entering the drop zone, which means the `relatedTarget` 5653 // (element that has been left) should be outside the drop zone. 5654 if (element.contains( /** @type {Node} */event.relatedTarget)) { 5655 return; 5656 } 5657 if (onDragEnterRef.current) { 5658 onDragEnterRef.current(event); 5659 } 5660 } 5661 function onDragOver( /** @type {DragEvent} */event) { 5662 // Only call onDragOver for the innermost hovered drop zones. 5663 if (!event.defaultPrevented && onDragOverRef.current) { 5664 onDragOverRef.current(event); 5665 } 5666 5667 // Prevent the browser default while also signalling to parent 5668 // drop zones that `onDragOver` is already handled. 5669 event.preventDefault(); 5670 } 5671 function onDragLeave( /** @type {DragEvent} */event) { 5672 // The `dragleave` event will also fire when leaving child 5673 // elements, but we only want to call `onDragLeave` when 5674 // leaving the drop zone, which means the `relatedTarget` 5675 // (element that has been entered) should be outside the drop 5676 // zone. 5677 // Note: This is not entirely reliable in Safari due to this bug 5678 // https://bugs.webkit.org/show_bug.cgi?id=66547 5679 5680 if (isElementInZone(event.relatedTarget)) { 5681 return; 5682 } 5683 if (onDragLeaveRef.current) { 5684 onDragLeaveRef.current(event); 5685 } 5686 } 5687 function onDrop( /** @type {DragEvent} */event) { 5688 // Don't handle drop if an inner drop zone already handled it. 5689 if (event.defaultPrevented) { 5690 return; 5691 } 5692 5693 // Prevent the browser default while also signalling to parent 5694 // drop zones that `onDrop` is already handled. 5695 event.preventDefault(); 5696 5697 // This seemingly useless line has been shown to resolve a 5698 // Safari issue where files dragged directly from the dock are 5699 // not recognized. 5700 // eslint-disable-next-line no-unused-expressions 5701 event.dataTransfer && event.dataTransfer.files.length; 5702 if (onDropRef.current) { 5703 onDropRef.current(event); 5704 } 5705 maybeDragEnd(event); 5706 } 5707 function maybeDragEnd( /** @type {MouseEvent} */event) { 5708 if (!isDragging) { 5709 return; 5710 } 5711 isDragging = false; 5712 ownerDocument.removeEventListener('dragend', maybeDragEnd); 5713 ownerDocument.removeEventListener('mousemove', maybeDragEnd); 5714 if (onDragEndRef.current) { 5715 onDragEndRef.current(event); 5716 } 5717 } 5718 element.dataset.isDropZone = 'true'; 5719 element.addEventListener('drop', onDrop); 5720 element.addEventListener('dragenter', onDragEnter); 5721 element.addEventListener('dragover', onDragOver); 5722 element.addEventListener('dragleave', onDragLeave); 5723 // The `dragstart` event doesn't fire if the drag started outside 5724 // the document. 5725 ownerDocument.addEventListener('dragenter', maybeDragStart); 5726 return () => { 5727 delete element.dataset.isDropZone; 5728 element.removeEventListener('drop', onDrop); 5729 element.removeEventListener('dragenter', onDragEnter); 5730 element.removeEventListener('dragover', onDragOver); 5731 element.removeEventListener('dragleave', onDragLeave); 5732 ownerDocument.removeEventListener('dragend', maybeDragEnd); 5733 ownerDocument.removeEventListener('mousemove', maybeDragEnd); 5734 ownerDocument.removeEventListener('dragenter', maybeDragStart); 5735 }; 5736 }, [isDisabled, dropZoneElement] // Refresh when the passed in dropZoneElement changes. 5737 ); 5738 } 5739 5740 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-focusable-iframe/index.js 5741 /** 5742 * External dependencies 5743 */ 5744 5745 /** 5746 * Internal dependencies 5747 */ 5748 5749 5750 /** 5751 * Dispatches a bubbling focus event when the iframe receives focus. Use 5752 * `onFocus` as usual on the iframe or a parent element. 5753 * 5754 * @return Ref to pass to the iframe. 5755 */ 5756 function useFocusableIframe() { 5757 return useRefEffect(element => { 5758 const { 5759 ownerDocument 5760 } = element; 5761 if (!ownerDocument) { 5762 return; 5763 } 5764 const { 5765 defaultView 5766 } = ownerDocument; 5767 if (!defaultView) { 5768 return; 5769 } 5770 5771 /** 5772 * Checks whether the iframe is the activeElement, inferring that it has 5773 * then received focus, and dispatches a focus event. 5774 */ 5775 function checkFocus() { 5776 if (ownerDocument && ownerDocument.activeElement === element) { 5777 element.focus(); 5778 } 5779 } 5780 defaultView.addEventListener('blur', checkFocus); 5781 return () => { 5782 defaultView.removeEventListener('blur', checkFocus); 5783 }; 5784 }, []); 5785 } 5786 5787 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-fixed-window-list/index.js 5788 /** 5789 * WordPress dependencies 5790 */ 5791 5792 5793 5794 5795 /** 5796 * Internal dependencies 5797 */ 5798 5799 const DEFAULT_INIT_WINDOW_SIZE = 30; 5800 5801 /** 5802 * @typedef {Object} WPFixedWindowList 5803 * 5804 * @property {number} visibleItems Items visible in the current viewport 5805 * @property {number} start Start index of the window 5806 * @property {number} end End index of the window 5807 * @property {(index:number)=>boolean} itemInView Returns true if item is in the window 5808 */ 5809 5810 /** 5811 * @typedef {Object} WPFixedWindowListOptions 5812 * 5813 * @property {number} [windowOverscan] Renders windowOverscan number of items before and after the calculated visible window. 5814 * @property {boolean} [useWindowing] When false avoids calculating the window size 5815 * @property {number} [initWindowSize] Initial window size to use on first render before we can calculate the window size. 5816 * @property {any} [expandedState] Used to recalculate the window size when the expanded state of a list changes. 5817 */ 5818 5819 /** 5820 * 5821 * @param {import('react').RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element. 5822 * @param { number } itemHeight Fixed item height in pixels 5823 * @param { number } totalItems Total items in list 5824 * @param { WPFixedWindowListOptions } [options] Options object 5825 * @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter 5826 */ 5827 function useFixedWindowList(elementRef, itemHeight, totalItems, options) { 5828 var _options$initWindowSi, _options$useWindowing; 5829 const initWindowSize = (_options$initWindowSi = options?.initWindowSize) !== null && _options$initWindowSi !== void 0 ? _options$initWindowSi : DEFAULT_INIT_WINDOW_SIZE; 5830 const useWindowing = (_options$useWindowing = options?.useWindowing) !== null && _options$useWindowing !== void 0 ? _options$useWindowing : true; 5831 const [fixedListWindow, setFixedListWindow] = (0,external_wp_element_namespaceObject.useState)({ 5832 visibleItems: initWindowSize, 5833 start: 0, 5834 end: initWindowSize, 5835 itemInView: ( /** @type {number} */index) => { 5836 return index >= 0 && index <= initWindowSize; 5837 } 5838 }); 5839 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 5840 if (!useWindowing) { 5841 return; 5842 } 5843 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); 5844 const measureWindow = ( /** @type {boolean | undefined} */initRender) => { 5845 var _options$windowOversc; 5846 if (!scrollContainer) { 5847 return; 5848 } 5849 const visibleItems = Math.ceil(scrollContainer.clientHeight / itemHeight); 5850 // Aim to keep opening list view fast, afterward we can optimize for scrolling. 5851 const windowOverscan = initRender ? visibleItems : (_options$windowOversc = options?.windowOverscan) !== null && _options$windowOversc !== void 0 ? _options$windowOversc : visibleItems; 5852 const firstViewableIndex = Math.floor(scrollContainer.scrollTop / itemHeight); 5853 const start = Math.max(0, firstViewableIndex - windowOverscan); 5854 const end = Math.min(totalItems - 1, firstViewableIndex + visibleItems + windowOverscan); 5855 setFixedListWindow(lastWindow => { 5856 const nextWindow = { 5857 visibleItems, 5858 start, 5859 end, 5860 itemInView: ( /** @type {number} */index) => { 5861 return start <= index && index <= end; 5862 } 5863 }; 5864 if (lastWindow.start !== nextWindow.start || lastWindow.end !== nextWindow.end || lastWindow.visibleItems !== nextWindow.visibleItems) { 5865 return nextWindow; 5866 } 5867 return lastWindow; 5868 }); 5869 }; 5870 measureWindow(true); 5871 const debounceMeasureList = debounce(() => { 5872 measureWindow(); 5873 }, 16); 5874 scrollContainer?.addEventListener('scroll', debounceMeasureList); 5875 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); 5876 scrollContainer?.ownerDocument?.defaultView?.addEventListener('resize', debounceMeasureList); 5877 return () => { 5878 scrollContainer?.removeEventListener('scroll', debounceMeasureList); 5879 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('resize', debounceMeasureList); 5880 }; 5881 }, [itemHeight, elementRef, totalItems, options?.expandedState, options?.windowOverscan, useWindowing]); 5882 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 5883 if (!useWindowing) { 5884 return; 5885 } 5886 const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(elementRef.current); 5887 const handleKeyDown = ( /** @type {KeyboardEvent} */event) => { 5888 switch (event.keyCode) { 5889 case external_wp_keycodes_namespaceObject.HOME: 5890 { 5891 return scrollContainer?.scrollTo({ 5892 top: 0 5893 }); 5894 } 5895 case external_wp_keycodes_namespaceObject.END: 5896 { 5897 return scrollContainer?.scrollTo({ 5898 top: totalItems * itemHeight 5899 }); 5900 } 5901 case external_wp_keycodes_namespaceObject.PAGEUP: 5902 { 5903 return scrollContainer?.scrollTo({ 5904 top: scrollContainer.scrollTop - fixedListWindow.visibleItems * itemHeight 5905 }); 5906 } 5907 case external_wp_keycodes_namespaceObject.PAGEDOWN: 5908 { 5909 return scrollContainer?.scrollTo({ 5910 top: scrollContainer.scrollTop + fixedListWindow.visibleItems * itemHeight 5911 }); 5912 } 5913 } 5914 }; 5915 scrollContainer?.ownerDocument?.defaultView?.addEventListener('keydown', handleKeyDown); 5916 return () => { 5917 scrollContainer?.ownerDocument?.defaultView?.removeEventListener('keydown', handleKeyDown); 5918 }; 5919 }, [totalItems, itemHeight, elementRef, fixedListWindow.visibleItems, useWindowing, options?.expandedState]); 5920 return [fixedListWindow, setFixedListWindow]; 5921 } 5922 5923 ;// ./node_modules/@wordpress/compose/build-module/hooks/use-observable-value/index.js 5924 /** 5925 * WordPress dependencies 5926 */ 5927 5928 5929 /** 5930 * Internal dependencies 5931 */ 5932 5933 /** 5934 * React hook that lets you observe an entry in an `ObservableMap`. The hook returns the 5935 * current value corresponding to the key, or `undefined` when there is no value stored. 5936 * It also observes changes to the value and triggers an update of the calling component 5937 * in case the value changes. 5938 * 5939 * @template K The type of the keys in the map. 5940 * @template V The type of the values in the map. 5941 * @param map The `ObservableMap` to observe. 5942 * @param name The map key to observe. 5943 * @return The value corresponding to the map key requested. 5944 */ 5945 function useObservableValue(map, name) { 5946 const [subscribe, getValue] = (0,external_wp_element_namespaceObject.useMemo)(() => [listener => map.subscribe(name, listener), () => map.get(name)], [map, name]); 5947 return (0,external_wp_element_namespaceObject.useSyncExternalStore)(subscribe, getValue, getValue); 5948 } 5949 5950 ;// ./node_modules/@wordpress/compose/build-module/index.js 5951 // The `createHigherOrderComponent` helper and helper types. 5952 5953 // The `debounce` helper and its types. 5954 5955 // The `throttle` helper and its types. 5956 5957 // The `ObservableMap` data structure 5958 5959 5960 // The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash). 5961 5962 5963 5964 // Higher-order components. 5965 5966 5967 5968 5969 5970 5971 5972 // Hooks. 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 })(); 6005 6006 (window.wp = window.wp || {}).compose = __webpack_exports__; 6007 /******/ })() 6008 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Wed Dec 25 08:20:01 2024 | Cross-referenced by PHPXref |