You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

5818 lines
194 KiB

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