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.

4790 lines
152 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 1919:
  4. /***/ (function(module) {
  5. "use strict";
  6. var isMergeableObject = function isMergeableObject(value) {
  7. return isNonNullObject(value)
  8. && !isSpecial(value)
  9. };
  10. function isNonNullObject(value) {
  11. return !!value && typeof value === 'object'
  12. }
  13. function isSpecial(value) {
  14. var stringValue = Object.prototype.toString.call(value);
  15. return stringValue === '[object RegExp]'
  16. || stringValue === '[object Date]'
  17. || isReactElement(value)
  18. }
  19. // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
  20. var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
  21. var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
  22. function isReactElement(value) {
  23. return value.$$typeof === REACT_ELEMENT_TYPE
  24. }
  25. function emptyTarget(val) {
  26. return Array.isArray(val) ? [] : {}
  27. }
  28. function cloneUnlessOtherwiseSpecified(value, options) {
  29. return (options.clone !== false && options.isMergeableObject(value))
  30. ? deepmerge(emptyTarget(value), value, options)
  31. : value
  32. }
  33. function defaultArrayMerge(target, source, options) {
  34. return target.concat(source).map(function(element) {
  35. return cloneUnlessOtherwiseSpecified(element, options)
  36. })
  37. }
  38. function getMergeFunction(key, options) {
  39. if (!options.customMerge) {
  40. return deepmerge
  41. }
  42. var customMerge = options.customMerge(key);
  43. return typeof customMerge === 'function' ? customMerge : deepmerge
  44. }
  45. function getEnumerableOwnPropertySymbols(target) {
  46. return Object.getOwnPropertySymbols
  47. ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
  48. return Object.propertyIsEnumerable.call(target, symbol)
  49. })
  50. : []
  51. }
  52. function getKeys(target) {
  53. return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
  54. }
  55. function propertyIsOnObject(object, property) {
  56. try {
  57. return property in object
  58. } catch(_) {
  59. return false
  60. }
  61. }
  62. // Protects from prototype poisoning and unexpected merging up the prototype chain.
  63. function propertyIsUnsafe(target, key) {
  64. return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
  65. && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
  66. && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
  67. }
  68. function mergeObject(target, source, options) {
  69. var destination = {};
  70. if (options.isMergeableObject(target)) {
  71. getKeys(target).forEach(function(key) {
  72. destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
  73. });
  74. }
  75. getKeys(source).forEach(function(key) {
  76. if (propertyIsUnsafe(target, key)) {
  77. return
  78. }
  79. if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
  80. destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
  81. } else {
  82. destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
  83. }
  84. });
  85. return destination
  86. }
  87. function deepmerge(target, source, options) {
  88. options = options || {};
  89. options.arrayMerge = options.arrayMerge || defaultArrayMerge;
  90. options.isMergeableObject = options.isMergeableObject || isMergeableObject;
  91. // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
  92. // implementations can use it. The caller may not replace it.
  93. options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
  94. var sourceIsArray = Array.isArray(source);
  95. var targetIsArray = Array.isArray(target);
  96. var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
  97. if (!sourceAndTargetTypesMatch) {
  98. return cloneUnlessOtherwiseSpecified(source, options)
  99. } else if (sourceIsArray) {
  100. return options.arrayMerge(target, source, options)
  101. } else {
  102. return mergeObject(target, source, options)
  103. }
  104. }
  105. deepmerge.all = function deepmergeAll(array, options) {
  106. if (!Array.isArray(array)) {
  107. throw new Error('first argument should be an array')
  108. }
  109. return array.reduce(function(prev, next) {
  110. return deepmerge(prev, next, options)
  111. }, {})
  112. };
  113. var deepmerge_1 = deepmerge;
  114. module.exports = deepmerge_1;
  115. /***/ }),
  116. /***/ 2167:
  117. /***/ (function(module) {
  118. "use strict";
  119. function _typeof(obj) {
  120. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  121. _typeof = function (obj) {
  122. return typeof obj;
  123. };
  124. } else {
  125. _typeof = function (obj) {
  126. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  127. };
  128. }
  129. return _typeof(obj);
  130. }
  131. function _classCallCheck(instance, Constructor) {
  132. if (!(instance instanceof Constructor)) {
  133. throw new TypeError("Cannot call a class as a function");
  134. }
  135. }
  136. function _defineProperties(target, props) {
  137. for (var i = 0; i < props.length; i++) {
  138. var descriptor = props[i];
  139. descriptor.enumerable = descriptor.enumerable || false;
  140. descriptor.configurable = true;
  141. if ("value" in descriptor) descriptor.writable = true;
  142. Object.defineProperty(target, descriptor.key, descriptor);
  143. }
  144. }
  145. function _createClass(Constructor, protoProps, staticProps) {
  146. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  147. if (staticProps) _defineProperties(Constructor, staticProps);
  148. return Constructor;
  149. }
  150. /**
  151. * Given an instance of EquivalentKeyMap, returns its internal value pair tuple
  152. * for a key, if one exists. The tuple members consist of the last reference
  153. * value for the key (used in efficient subsequent lookups) and the value
  154. * assigned for the key at the leaf node.
  155. *
  156. * @param {EquivalentKeyMap} instance EquivalentKeyMap instance.
  157. * @param {*} key The key for which to return value pair.
  158. *
  159. * @return {?Array} Value pair, if exists.
  160. */
  161. function getValuePair(instance, key) {
  162. var _map = instance._map,
  163. _arrayTreeMap = instance._arrayTreeMap,
  164. _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the
  165. // value, which can be used to shortcut immediately to the value.
  166. if (_map.has(key)) {
  167. return _map.get(key);
  168. } // Sort keys to ensure stable retrieval from tree.
  169. var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.
  170. var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;
  171. for (var i = 0; i < properties.length; i++) {
  172. var property = properties[i];
  173. map = map.get(property);
  174. if (map === undefined) {
  175. return;
  176. }
  177. var propertyValue = key[property];
  178. map = map.get(propertyValue);
  179. if (map === undefined) {
  180. return;
  181. }
  182. }
  183. var valuePair = map.get('_ekm_value');
  184. if (!valuePair) {
  185. return;
  186. } // If reached, it implies that an object-like key was set with another
  187. // reference, so delete the reference and replace with the current.
  188. _map.delete(valuePair[0]);
  189. valuePair[0] = key;
  190. map.set('_ekm_value', valuePair);
  191. _map.set(key, valuePair);
  192. return valuePair;
  193. }
  194. /**
  195. * Variant of a Map object which enables lookup by equivalent (deeply equal)
  196. * object and array keys.
  197. */
  198. var EquivalentKeyMap =
  199. /*#__PURE__*/
  200. function () {
  201. /**
  202. * Constructs a new instance of EquivalentKeyMap.
  203. *
  204. * @param {Iterable.<*>} iterable Initial pair of key, value for map.
  205. */
  206. function EquivalentKeyMap(iterable) {
  207. _classCallCheck(this, EquivalentKeyMap);
  208. this.clear();
  209. if (iterable instanceof EquivalentKeyMap) {
  210. // Map#forEach is only means of iterating with support for IE11.
  211. var iterablePairs = [];
  212. iterable.forEach(function (value, key) {
  213. iterablePairs.push([key, value]);
  214. });
  215. iterable = iterablePairs;
  216. }
  217. if (iterable != null) {
  218. for (var i = 0; i < iterable.length; i++) {
  219. this.set(iterable[i][0], iterable[i][1]);
  220. }
  221. }
  222. }
  223. /**
  224. * Accessor property returning the number of elements.
  225. *
  226. * @return {number} Number of elements.
  227. */
  228. _createClass(EquivalentKeyMap, [{
  229. key: "set",
  230. /**
  231. * Add or update an element with a specified key and value.
  232. *
  233. * @param {*} key The key of the element to add.
  234. * @param {*} value The value of the element to add.
  235. *
  236. * @return {EquivalentKeyMap} Map instance.
  237. */
  238. value: function set(key, value) {
  239. // Shortcut non-object-like to set on internal Map.
  240. if (key === null || _typeof(key) !== 'object') {
  241. this._map.set(key, value);
  242. return this;
  243. } // Sort keys to ensure stable assignment into tree.
  244. var properties = Object.keys(key).sort();
  245. var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.
  246. var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;
  247. for (var i = 0; i < properties.length; i++) {
  248. var property = properties[i];
  249. if (!map.has(property)) {
  250. map.set(property, new EquivalentKeyMap());
  251. }
  252. map = map.get(property);
  253. var propertyValue = key[property];
  254. if (!map.has(propertyValue)) {
  255. map.set(propertyValue, new EquivalentKeyMap());
  256. }
  257. map = map.get(propertyValue);
  258. } // If an _ekm_value exists, there was already an equivalent key. Before
  259. // overriding, ensure that the old key reference is removed from map to
  260. // avoid memory leak of accumulating equivalent keys. This is, in a
  261. // sense, a poor man's WeakMap, while still enabling iterability.
  262. var previousValuePair = map.get('_ekm_value');
  263. if (previousValuePair) {
  264. this._map.delete(previousValuePair[0]);
  265. }
  266. map.set('_ekm_value', valuePair);
  267. this._map.set(key, valuePair);
  268. return this;
  269. }
  270. /**
  271. * Returns a specified element.
  272. *
  273. * @param {*} key The key of the element to return.
  274. *
  275. * @return {?*} The element associated with the specified key or undefined
  276. * if the key can't be found.
  277. */
  278. }, {
  279. key: "get",
  280. value: function get(key) {
  281. // Shortcut non-object-like to get from internal Map.
  282. if (key === null || _typeof(key) !== 'object') {
  283. return this._map.get(key);
  284. }
  285. var valuePair = getValuePair(this, key);
  286. if (valuePair) {
  287. return valuePair[1];
  288. }
  289. }
  290. /**
  291. * Returns a boolean indicating whether an element with the specified key
  292. * exists or not.
  293. *
  294. * @param {*} key The key of the element to test for presence.
  295. *
  296. * @return {boolean} Whether an element with the specified key exists.
  297. */
  298. }, {
  299. key: "has",
  300. value: function has(key) {
  301. if (key === null || _typeof(key) !== 'object') {
  302. return this._map.has(key);
  303. } // Test on the _presence_ of the pair, not its value, as even undefined
  304. // can be a valid member value for a key.
  305. return getValuePair(this, key) !== undefined;
  306. }
  307. /**
  308. * Removes the specified element.
  309. *
  310. * @param {*} key The key of the element to remove.
  311. *
  312. * @return {boolean} Returns true if an element existed and has been
  313. * removed, or false if the element does not exist.
  314. */
  315. }, {
  316. key: "delete",
  317. value: function _delete(key) {
  318. if (!this.has(key)) {
  319. return false;
  320. } // This naive implementation will leave orphaned child trees. A better
  321. // implementation should traverse and remove orphans.
  322. this.set(key, undefined);
  323. return true;
  324. }
  325. /**
  326. * Executes a provided function once per each key/value pair, in insertion
  327. * order.
  328. *
  329. * @param {Function} callback Function to execute for each element.
  330. * @param {*} thisArg Value to use as `this` when executing
  331. * `callback`.
  332. */
  333. }, {
  334. key: "forEach",
  335. value: function forEach(callback) {
  336. var _this = this;
  337. var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;
  338. this._map.forEach(function (value, key) {
  339. // Unwrap value from object-like value pair.
  340. if (key !== null && _typeof(key) === 'object') {
  341. value = value[1];
  342. }
  343. callback.call(thisArg, value, key, _this);
  344. });
  345. }
  346. /**
  347. * Removes all elements.
  348. */
  349. }, {
  350. key: "clear",
  351. value: function clear() {
  352. this._map = new Map();
  353. this._arrayTreeMap = new Map();
  354. this._objectTreeMap = new Map();
  355. }
  356. }, {
  357. key: "size",
  358. get: function get() {
  359. return this._map.size;
  360. }
  361. }]);
  362. return EquivalentKeyMap;
  363. }();
  364. module.exports = EquivalentKeyMap;
  365. /***/ }),
  366. /***/ 9125:
  367. /***/ (function(module) {
  368. function combineReducers( reducers ) {
  369. var keys = Object.keys( reducers ),
  370. getNextState;
  371. getNextState = ( function() {
  372. var fn, i, key;
  373. fn = 'return {';
  374. for ( i = 0; i < keys.length; i++ ) {
  375. // Rely on Quoted escaping of JSON.stringify with guarantee that
  376. // each member of Object.keys is a string.
  377. //
  378. // "If Type(value) is String, then return the result of calling the
  379. // abstract operation Quote with argument value. [...] The abstract
  380. // operation Quote(value) wraps a String value in double quotes and
  381. // escapes characters within it."
  382. //
  383. // https://www.ecma-international.org/ecma-262/5.1/#sec-15.12.3
  384. key = JSON.stringify( keys[ i ] );
  385. fn += key + ':r[' + key + '](s[' + key + '],a),';
  386. }
  387. fn += '}';
  388. return new Function( 'r,s,a', fn );
  389. } )();
  390. return function combinedReducer( state, action ) {
  391. var nextState, i, key;
  392. // Assumed changed if initial state.
  393. if ( state === undefined ) {
  394. return getNextState( reducers, {}, action );
  395. }
  396. nextState = getNextState( reducers, state, action );
  397. // Determine whether state has changed.
  398. i = keys.length;
  399. while ( i-- ) {
  400. key = keys[ i ];
  401. if ( state[ key ] !== nextState[ key ] ) {
  402. // Return immediately if a changed value is encountered.
  403. return nextState;
  404. }
  405. }
  406. return state;
  407. };
  408. }
  409. module.exports = combineReducers;
  410. /***/ })
  411. /******/ });
  412. /************************************************************************/
  413. /******/ // The module cache
  414. /******/ var __webpack_module_cache__ = {};
  415. /******/
  416. /******/ // The require function
  417. /******/ function __webpack_require__(moduleId) {
  418. /******/ // Check if module is in cache
  419. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  420. /******/ if (cachedModule !== undefined) {
  421. /******/ return cachedModule.exports;
  422. /******/ }
  423. /******/ // Create a new module (and put it into the cache)
  424. /******/ var module = __webpack_module_cache__[moduleId] = {
  425. /******/ // no module.id needed
  426. /******/ // no module.loaded needed
  427. /******/ exports: {}
  428. /******/ };
  429. /******/
  430. /******/ // Execute the module function
  431. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  432. /******/
  433. /******/ // Return the exports of the module
  434. /******/ return module.exports;
  435. /******/ }
  436. /******/
  437. /************************************************************************/
  438. /******/ /* webpack/runtime/compat get default export */
  439. /******/ !function() {
  440. /******/ // getDefaultExport function for compatibility with non-harmony modules
  441. /******/ __webpack_require__.n = function(module) {
  442. /******/ var getter = module && module.__esModule ?
  443. /******/ function() { return module['default']; } :
  444. /******/ function() { return module; };
  445. /******/ __webpack_require__.d(getter, { a: getter });
  446. /******/ return getter;
  447. /******/ };
  448. /******/ }();
  449. /******/
  450. /******/ /* webpack/runtime/define property getters */
  451. /******/ !function() {
  452. /******/ // define getter functions for harmony exports
  453. /******/ __webpack_require__.d = function(exports, definition) {
  454. /******/ for(var key in definition) {
  455. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  456. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  457. /******/ }
  458. /******/ }
  459. /******/ };
  460. /******/ }();
  461. /******/
  462. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  463. /******/ !function() {
  464. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  465. /******/ }();
  466. /******/
  467. /******/ /* webpack/runtime/make namespace object */
  468. /******/ !function() {
  469. /******/ // define __esModule on exports
  470. /******/ __webpack_require__.r = function(exports) {
  471. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  472. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  473. /******/ }
  474. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  475. /******/ };
  476. /******/ }();
  477. /******/
  478. /************************************************************************/
  479. var __webpack_exports__ = {};
  480. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  481. !function() {
  482. "use strict";
  483. // ESM COMPAT FLAG
  484. __webpack_require__.r(__webpack_exports__);
  485. // EXPORTS
  486. __webpack_require__.d(__webpack_exports__, {
  487. AsyncModeProvider: function() { return /* reexport */ async_mode_provider_context; },
  488. RegistryConsumer: function() { return /* reexport */ RegistryConsumer; },
  489. RegistryProvider: function() { return /* reexport */ context; },
  490. combineReducers: function() { return /* binding */ build_module_combineReducers; },
  491. controls: function() { return /* reexport */ controls; },
  492. createReduxStore: function() { return /* reexport */ createReduxStore; },
  493. createRegistry: function() { return /* reexport */ createRegistry; },
  494. createRegistryControl: function() { return /* reexport */ createRegistryControl; },
  495. createRegistrySelector: function() { return /* reexport */ createRegistrySelector; },
  496. dispatch: function() { return /* reexport */ dispatch_dispatch; },
  497. plugins: function() { return /* reexport */ plugins_namespaceObject; },
  498. register: function() { return /* binding */ register; },
  499. registerGenericStore: function() { return /* binding */ registerGenericStore; },
  500. registerStore: function() { return /* binding */ registerStore; },
  501. resolveSelect: function() { return /* binding */ build_module_resolveSelect; },
  502. select: function() { return /* reexport */ select_select; },
  503. subscribe: function() { return /* binding */ subscribe; },
  504. suspendSelect: function() { return /* binding */ suspendSelect; },
  505. use: function() { return /* binding */ use; },
  506. useDispatch: function() { return /* reexport */ use_dispatch; },
  507. useRegistry: function() { return /* reexport */ useRegistry; },
  508. useSelect: function() { return /* reexport */ useSelect; },
  509. useSuspenseSelect: function() { return /* reexport */ useSuspenseSelect; },
  510. withDispatch: function() { return /* reexport */ with_dispatch; },
  511. withRegistry: function() { return /* reexport */ with_registry; },
  512. withSelect: function() { return /* reexport */ with_select; }
  513. });
  514. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
  515. var selectors_namespaceObject = {};
  516. __webpack_require__.r(selectors_namespaceObject);
  517. __webpack_require__.d(selectors_namespaceObject, {
  518. countSelectorsByStatus: function() { return countSelectorsByStatus; },
  519. getCachedResolvers: function() { return getCachedResolvers; },
  520. getIsResolving: function() { return getIsResolving; },
  521. getResolutionError: function() { return getResolutionError; },
  522. getResolutionState: function() { return getResolutionState; },
  523. hasFinishedResolution: function() { return hasFinishedResolution; },
  524. hasResolutionFailed: function() { return hasResolutionFailed; },
  525. hasResolvingSelectors: function() { return hasResolvingSelectors; },
  526. hasStartedResolution: function() { return hasStartedResolution; },
  527. isResolving: function() { return isResolving; }
  528. });
  529. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
  530. var actions_namespaceObject = {};
  531. __webpack_require__.r(actions_namespaceObject);
  532. __webpack_require__.d(actions_namespaceObject, {
  533. failResolution: function() { return failResolution; },
  534. failResolutions: function() { return failResolutions; },
  535. finishResolution: function() { return finishResolution; },
  536. finishResolutions: function() { return finishResolutions; },
  537. invalidateResolution: function() { return invalidateResolution; },
  538. invalidateResolutionForStore: function() { return invalidateResolutionForStore; },
  539. invalidateResolutionForStoreSelector: function() { return invalidateResolutionForStoreSelector; },
  540. startResolution: function() { return startResolution; },
  541. startResolutions: function() { return startResolutions; }
  542. });
  543. // NAMESPACE OBJECT: ./node_modules/@wordpress/data/build-module/plugins/index.js
  544. var plugins_namespaceObject = {};
  545. __webpack_require__.r(plugins_namespaceObject);
  546. __webpack_require__.d(plugins_namespaceObject, {
  547. persistence: function() { return persistence; }
  548. });
  549. // EXTERNAL MODULE: ./node_modules/turbo-combine-reducers/index.js
  550. var turbo_combine_reducers = __webpack_require__(9125);
  551. var turbo_combine_reducers_default = /*#__PURE__*/__webpack_require__.n(turbo_combine_reducers);
  552. ;// CONCATENATED MODULE: external ["wp","deprecated"]
  553. var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
  554. var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
  555. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
  556. function _typeof(o) {
  557. "@babel/helpers - typeof";
  558. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  559. return typeof o;
  560. } : function (o) {
  561. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  562. }, _typeof(o);
  563. }
  564. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js
  565. function _toPrimitive(input, hint) {
  566. if (_typeof(input) !== "object" || input === null) return input;
  567. var prim = input[Symbol.toPrimitive];
  568. if (prim !== undefined) {
  569. var res = prim.call(input, hint || "default");
  570. if (_typeof(res) !== "object") return res;
  571. throw new TypeError("@@toPrimitive must return a primitive value.");
  572. }
  573. return (hint === "string" ? String : Number)(input);
  574. }
  575. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
  576. function _toPropertyKey(arg) {
  577. var key = _toPrimitive(arg, "string");
  578. return _typeof(key) === "symbol" ? key : String(key);
  579. }
  580. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
  581. function _defineProperty(obj, key, value) {
  582. key = _toPropertyKey(key);
  583. if (key in obj) {
  584. Object.defineProperty(obj, key, {
  585. value: value,
  586. enumerable: true,
  587. configurable: true,
  588. writable: true
  589. });
  590. } else {
  591. obj[key] = value;
  592. }
  593. return obj;
  594. }
  595. ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread2.js
  596. function ownKeys(e, r) {
  597. var t = Object.keys(e);
  598. if (Object.getOwnPropertySymbols) {
  599. var o = Object.getOwnPropertySymbols(e);
  600. r && (o = o.filter(function (r) {
  601. return Object.getOwnPropertyDescriptor(e, r).enumerable;
  602. })), t.push.apply(t, o);
  603. }
  604. return t;
  605. }
  606. function _objectSpread2(e) {
  607. for (var r = 1; r < arguments.length; r++) {
  608. var t = null != arguments[r] ? arguments[r] : {};
  609. r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
  610. _defineProperty(e, r, t[r]);
  611. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
  612. Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
  613. });
  614. }
  615. return e;
  616. }
  617. ;// CONCATENATED MODULE: ./node_modules/redux/es/redux.js
  618. /**
  619. * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
  620. *
  621. * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
  622. * during build.
  623. * @param {number} code
  624. */
  625. function formatProdErrorMessage(code) {
  626. return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
  627. }
  628. // Inlined version of the `symbol-observable` polyfill
  629. var $$observable = (function () {
  630. return typeof Symbol === 'function' && Symbol.observable || '@@observable';
  631. })();
  632. /**
  633. * These are private action types reserved by Redux.
  634. * For any unknown actions, you must return the current state.
  635. * If the current state is undefined, you must return the initial state.
  636. * Do not reference these action types directly in your code.
  637. */
  638. var randomString = function randomString() {
  639. return Math.random().toString(36).substring(7).split('').join('.');
  640. };
  641. var ActionTypes = {
  642. INIT: "@@redux/INIT" + randomString(),
  643. REPLACE: "@@redux/REPLACE" + randomString(),
  644. PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
  645. return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
  646. }
  647. };
  648. /**
  649. * @param {any} obj The object to inspect.
  650. * @returns {boolean} True if the argument appears to be a plain object.
  651. */
  652. function isPlainObject(obj) {
  653. if (typeof obj !== 'object' || obj === null) return false;
  654. var proto = obj;
  655. while (Object.getPrototypeOf(proto) !== null) {
  656. proto = Object.getPrototypeOf(proto);
  657. }
  658. return Object.getPrototypeOf(obj) === proto;
  659. }
  660. // Inlined / shortened version of `kindOf` from https://github.com/jonschlinkert/kind-of
  661. function miniKindOf(val) {
  662. if (val === void 0) return 'undefined';
  663. if (val === null) return 'null';
  664. var type = typeof val;
  665. switch (type) {
  666. case 'boolean':
  667. case 'string':
  668. case 'number':
  669. case 'symbol':
  670. case 'function':
  671. {
  672. return type;
  673. }
  674. }
  675. if (Array.isArray(val)) return 'array';
  676. if (isDate(val)) return 'date';
  677. if (isError(val)) return 'error';
  678. var constructorName = ctorName(val);
  679. switch (constructorName) {
  680. case 'Symbol':
  681. case 'Promise':
  682. case 'WeakMap':
  683. case 'WeakSet':
  684. case 'Map':
  685. case 'Set':
  686. return constructorName;
  687. } // other
  688. return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
  689. }
  690. function ctorName(val) {
  691. return typeof val.constructor === 'function' ? val.constructor.name : null;
  692. }
  693. function isError(val) {
  694. return val instanceof Error || typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number';
  695. }
  696. function isDate(val) {
  697. if (val instanceof Date) return true;
  698. return typeof val.toDateString === 'function' && typeof val.getDate === 'function' && typeof val.setDate === 'function';
  699. }
  700. function kindOf(val) {
  701. var typeOfVal = typeof val;
  702. if (false) {}
  703. return typeOfVal;
  704. }
  705. /**
  706. * @deprecated
  707. *
  708. * **We recommend using the `configureStore` method
  709. * of the `@reduxjs/toolkit` package**, which replaces `createStore`.
  710. *
  711. * Redux Toolkit is our recommended approach for writing Redux logic today,
  712. * including store setup, reducers, data fetching, and more.
  713. *
  714. * **For more details, please read this Redux docs page:**
  715. * **https://redux.js.org/introduction/why-rtk-is-redux-today**
  716. *
  717. * `configureStore` from Redux Toolkit is an improved version of `createStore` that
  718. * simplifies setup and helps avoid common bugs.
  719. *
  720. * You should not be using the `redux` core package by itself today, except for learning purposes.
  721. * The `createStore` method from the core `redux` package will not be removed, but we encourage
  722. * all users to migrate to using Redux Toolkit for all Redux code.
  723. *
  724. * If you want to use `createStore` without this visual deprecation warning, use
  725. * the `legacy_createStore` import instead:
  726. *
  727. * `import { legacy_createStore as createStore} from 'redux'`
  728. *
  729. */
  730. function createStore(reducer, preloadedState, enhancer) {
  731. var _ref2;
  732. if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
  733. throw new Error( true ? formatProdErrorMessage(0) : 0);
  734. }
  735. if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
  736. enhancer = preloadedState;
  737. preloadedState = undefined;
  738. }
  739. if (typeof enhancer !== 'undefined') {
  740. if (typeof enhancer !== 'function') {
  741. throw new Error( true ? formatProdErrorMessage(1) : 0);
  742. }
  743. return enhancer(createStore)(reducer, preloadedState);
  744. }
  745. if (typeof reducer !== 'function') {
  746. throw new Error( true ? formatProdErrorMessage(2) : 0);
  747. }
  748. var currentReducer = reducer;
  749. var currentState = preloadedState;
  750. var currentListeners = [];
  751. var nextListeners = currentListeners;
  752. var isDispatching = false;
  753. /**
  754. * This makes a shallow copy of currentListeners so we can use
  755. * nextListeners as a temporary list while dispatching.
  756. *
  757. * This prevents any bugs around consumers calling
  758. * subscribe/unsubscribe in the middle of a dispatch.
  759. */
  760. function ensureCanMutateNextListeners() {
  761. if (nextListeners === currentListeners) {
  762. nextListeners = currentListeners.slice();
  763. }
  764. }
  765. /**
  766. * Reads the state tree managed by the store.
  767. *
  768. * @returns {any} The current state tree of your application.
  769. */
  770. function getState() {
  771. if (isDispatching) {
  772. throw new Error( true ? formatProdErrorMessage(3) : 0);
  773. }
  774. return currentState;
  775. }
  776. /**
  777. * Adds a change listener. It will be called any time an action is dispatched,
  778. * and some part of the state tree may potentially have changed. You may then
  779. * call `getState()` to read the current state tree inside the callback.
  780. *
  781. * You may call `dispatch()` from a change listener, with the following
  782. * caveats:
  783. *
  784. * 1. The subscriptions are snapshotted just before every `dispatch()` call.
  785. * If you subscribe or unsubscribe while the listeners are being invoked, this
  786. * will not have any effect on the `dispatch()` that is currently in progress.
  787. * However, the next `dispatch()` call, whether nested or not, will use a more
  788. * recent snapshot of the subscription list.
  789. *
  790. * 2. The listener should not expect to see all state changes, as the state
  791. * might have been updated multiple times during a nested `dispatch()` before
  792. * the listener is called. It is, however, guaranteed that all subscribers
  793. * registered before the `dispatch()` started will be called with the latest
  794. * state by the time it exits.
  795. *
  796. * @param {Function} listener A callback to be invoked on every dispatch.
  797. * @returns {Function} A function to remove this change listener.
  798. */
  799. function subscribe(listener) {
  800. if (typeof listener !== 'function') {
  801. throw new Error( true ? formatProdErrorMessage(4) : 0);
  802. }
  803. if (isDispatching) {
  804. throw new Error( true ? formatProdErrorMessage(5) : 0);
  805. }
  806. var isSubscribed = true;
  807. ensureCanMutateNextListeners();
  808. nextListeners.push(listener);
  809. return function unsubscribe() {
  810. if (!isSubscribed) {
  811. return;
  812. }
  813. if (isDispatching) {
  814. throw new Error( true ? formatProdErrorMessage(6) : 0);
  815. }
  816. isSubscribed = false;
  817. ensureCanMutateNextListeners();
  818. var index = nextListeners.indexOf(listener);
  819. nextListeners.splice(index, 1);
  820. currentListeners = null;
  821. };
  822. }
  823. /**
  824. * Dispatches an action. It is the only way to trigger a state change.
  825. *
  826. * The `reducer` function, used to create the store, will be called with the
  827. * current state tree and the given `action`. Its return value will
  828. * be considered the **next** state of the tree, and the change listeners
  829. * will be notified.
  830. *
  831. * The base implementation only supports plain object actions. If you want to
  832. * dispatch a Promise, an Observable, a thunk, or something else, you need to
  833. * wrap your store creating function into the corresponding middleware. For
  834. * example, see the documentation for the `redux-thunk` package. Even the
  835. * middleware will eventually dispatch plain object actions using this method.
  836. *
  837. * @param {Object} action A plain object representing what changed. It is
  838. * a good idea to keep actions serializable so you can record and replay user
  839. * sessions, or use the time travelling `redux-devtools`. An action must have
  840. * a `type` property which may not be `undefined`. It is a good idea to use
  841. * string constants for action types.
  842. *
  843. * @returns {Object} For convenience, the same action object you dispatched.
  844. *
  845. * Note that, if you use a custom middleware, it may wrap `dispatch()` to
  846. * return something else (for example, a Promise you can await).
  847. */
  848. function dispatch(action) {
  849. if (!isPlainObject(action)) {
  850. throw new Error( true ? formatProdErrorMessage(7) : 0);
  851. }
  852. if (typeof action.type === 'undefined') {
  853. throw new Error( true ? formatProdErrorMessage(8) : 0);
  854. }
  855. if (isDispatching) {
  856. throw new Error( true ? formatProdErrorMessage(9) : 0);
  857. }
  858. try {
  859. isDispatching = true;
  860. currentState = currentReducer(currentState, action);
  861. } finally {
  862. isDispatching = false;
  863. }
  864. var listeners = currentListeners = nextListeners;
  865. for (var i = 0; i < listeners.length; i++) {
  866. var listener = listeners[i];
  867. listener();
  868. }
  869. return action;
  870. }
  871. /**
  872. * Replaces the reducer currently used by the store to calculate the state.
  873. *
  874. * You might need this if your app implements code splitting and you want to
  875. * load some of the reducers dynamically. You might also need this if you
  876. * implement a hot reloading mechanism for Redux.
  877. *
  878. * @param {Function} nextReducer The reducer for the store to use instead.
  879. * @returns {void}
  880. */
  881. function replaceReducer(nextReducer) {
  882. if (typeof nextReducer !== 'function') {
  883. throw new Error( true ? formatProdErrorMessage(10) : 0);
  884. }
  885. currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
  886. // Any reducers that existed in both the new and old rootReducer
  887. // will receive the previous state. This effectively populates
  888. // the new state tree with any relevant data from the old one.
  889. dispatch({
  890. type: ActionTypes.REPLACE
  891. });
  892. }
  893. /**
  894. * Interoperability point for observable/reactive libraries.
  895. * @returns {observable} A minimal observable of state changes.
  896. * For more information, see the observable proposal:
  897. * https://github.com/tc39/proposal-observable
  898. */
  899. function observable() {
  900. var _ref;
  901. var outerSubscribe = subscribe;
  902. return _ref = {
  903. /**
  904. * The minimal observable subscription method.
  905. * @param {Object} observer Any object that can be used as an observer.
  906. * The observer object should have a `next` method.
  907. * @returns {subscription} An object with an `unsubscribe` method that can
  908. * be used to unsubscribe the observable from the store, and prevent further
  909. * emission of values from the observable.
  910. */
  911. subscribe: function subscribe(observer) {
  912. if (typeof observer !== 'object' || observer === null) {
  913. throw new Error( true ? formatProdErrorMessage(11) : 0);
  914. }
  915. function observeState() {
  916. if (observer.next) {
  917. observer.next(getState());
  918. }
  919. }
  920. observeState();
  921. var unsubscribe = outerSubscribe(observeState);
  922. return {
  923. unsubscribe: unsubscribe
  924. };
  925. }
  926. }, _ref[$$observable] = function () {
  927. return this;
  928. }, _ref;
  929. } // When a store is created, an "INIT" action is dispatched so that every
  930. // reducer returns their initial state. This effectively populates
  931. // the initial state tree.
  932. dispatch({
  933. type: ActionTypes.INIT
  934. });
  935. return _ref2 = {
  936. dispatch: dispatch,
  937. subscribe: subscribe,
  938. getState: getState,
  939. replaceReducer: replaceReducer
  940. }, _ref2[$$observable] = observable, _ref2;
  941. }
  942. /**
  943. * Creates a Redux store that holds the state tree.
  944. *
  945. * **We recommend using `configureStore` from the
  946. * `@reduxjs/toolkit` package**, which replaces `createStore`:
  947. * **https://redux.js.org/introduction/why-rtk-is-redux-today**
  948. *
  949. * The only way to change the data in the store is to call `dispatch()` on it.
  950. *
  951. * There should only be a single store in your app. To specify how different
  952. * parts of the state tree respond to actions, you may combine several reducers
  953. * into a single reducer function by using `combineReducers`.
  954. *
  955. * @param {Function} reducer A function that returns the next state tree, given
  956. * the current state tree and the action to handle.
  957. *
  958. * @param {any} [preloadedState] The initial state. You may optionally specify it
  959. * to hydrate the state from the server in universal apps, or to restore a
  960. * previously serialized user session.
  961. * If you use `combineReducers` to produce the root reducer function, this must be
  962. * an object with the same shape as `combineReducers` keys.
  963. *
  964. * @param {Function} [enhancer] The store enhancer. You may optionally specify it
  965. * to enhance the store with third-party capabilities such as middleware,
  966. * time travel, persistence, etc. The only store enhancer that ships with Redux
  967. * is `applyMiddleware()`.
  968. *
  969. * @returns {Store} A Redux store that lets you read the state, dispatch actions
  970. * and subscribe to changes.
  971. */
  972. var legacy_createStore = (/* unused pure expression or super */ null && (createStore));
  973. /**
  974. * Prints a warning in the console if it exists.
  975. *
  976. * @param {String} message The warning message.
  977. * @returns {void}
  978. */
  979. function warning(message) {
  980. /* eslint-disable no-console */
  981. if (typeof console !== 'undefined' && typeof console.error === 'function') {
  982. console.error(message);
  983. }
  984. /* eslint-enable no-console */
  985. try {
  986. // This error was thrown as a convenience so that if you enable
  987. // "break on all exceptions" in your console,
  988. // it would pause the execution at this line.
  989. throw new Error(message);
  990. } catch (e) {} // eslint-disable-line no-empty
  991. }
  992. function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
  993. var reducerKeys = Object.keys(reducers);
  994. var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
  995. if (reducerKeys.length === 0) {
  996. return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
  997. }
  998. if (!isPlainObject(inputState)) {
  999. return "The " + argumentName + " has unexpected type of \"" + kindOf(inputState) + "\". Expected argument to be an object with the following " + ("keys: \"" + reducerKeys.join('", "') + "\"");
  1000. }
  1001. var unexpectedKeys = Object.keys(inputState).filter(function (key) {
  1002. return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
  1003. });
  1004. unexpectedKeys.forEach(function (key) {
  1005. unexpectedKeyCache[key] = true;
  1006. });
  1007. if (action && action.type === ActionTypes.REPLACE) return;
  1008. if (unexpectedKeys.length > 0) {
  1009. return "Unexpected " + (unexpectedKeys.length > 1 ? 'keys' : 'key') + " " + ("\"" + unexpectedKeys.join('", "') + "\" found in " + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ("\"" + reducerKeys.join('", "') + "\". Unexpected keys will be ignored.");
  1010. }
  1011. }
  1012. function assertReducerShape(reducers) {
  1013. Object.keys(reducers).forEach(function (key) {
  1014. var reducer = reducers[key];
  1015. var initialState = reducer(undefined, {
  1016. type: ActionTypes.INIT
  1017. });
  1018. if (typeof initialState === 'undefined') {
  1019. throw new Error( true ? formatProdErrorMessage(12) : 0);
  1020. }
  1021. if (typeof reducer(undefined, {
  1022. type: ActionTypes.PROBE_UNKNOWN_ACTION()
  1023. }) === 'undefined') {
  1024. throw new Error( true ? formatProdErrorMessage(13) : 0);
  1025. }
  1026. });
  1027. }
  1028. /**
  1029. * Turns an object whose values are different reducer functions, into a single
  1030. * reducer function. It will call every child reducer, and gather their results
  1031. * into a single state object, whose keys correspond to the keys of the passed
  1032. * reducer functions.
  1033. *
  1034. * @param {Object} reducers An object whose values correspond to different
  1035. * reducer functions that need to be combined into one. One handy way to obtain
  1036. * it is to use ES6 `import * as reducers` syntax. The reducers may never return
  1037. * undefined for any action. Instead, they should return their initial state
  1038. * if the state passed to them was undefined, and the current state for any
  1039. * unrecognized action.
  1040. *
  1041. * @returns {Function} A reducer function that invokes every reducer inside the
  1042. * passed object, and builds a state object with the same shape.
  1043. */
  1044. function combineReducers(reducers) {
  1045. var reducerKeys = Object.keys(reducers);
  1046. var finalReducers = {};
  1047. for (var i = 0; i < reducerKeys.length; i++) {
  1048. var key = reducerKeys[i];
  1049. if (false) {}
  1050. if (typeof reducers[key] === 'function') {
  1051. finalReducers[key] = reducers[key];
  1052. }
  1053. }
  1054. var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
  1055. // keys multiple times.
  1056. var unexpectedKeyCache;
  1057. if (false) {}
  1058. var shapeAssertionError;
  1059. try {
  1060. assertReducerShape(finalReducers);
  1061. } catch (e) {
  1062. shapeAssertionError = e;
  1063. }
  1064. return function combination(state, action) {
  1065. if (state === void 0) {
  1066. state = {};
  1067. }
  1068. if (shapeAssertionError) {
  1069. throw shapeAssertionError;
  1070. }
  1071. if (false) { var warningMessage; }
  1072. var hasChanged = false;
  1073. var nextState = {};
  1074. for (var _i = 0; _i < finalReducerKeys.length; _i++) {
  1075. var _key = finalReducerKeys[_i];
  1076. var reducer = finalReducers[_key];
  1077. var previousStateForKey = state[_key];
  1078. var nextStateForKey = reducer(previousStateForKey, action);
  1079. if (typeof nextStateForKey === 'undefined') {
  1080. var actionType = action && action.type;
  1081. throw new Error( true ? formatProdErrorMessage(14) : 0);
  1082. }
  1083. nextState[_key] = nextStateForKey;
  1084. hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
  1085. }
  1086. hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
  1087. return hasChanged ? nextState : state;
  1088. };
  1089. }
  1090. function bindActionCreator(actionCreator, dispatch) {
  1091. return function () {
  1092. return dispatch(actionCreator.apply(this, arguments));
  1093. };
  1094. }
  1095. /**
  1096. * Turns an object whose values are action creators, into an object with the
  1097. * same keys, but with every function wrapped into a `dispatch` call so they
  1098. * may be invoked directly. This is just a convenience method, as you can call
  1099. * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
  1100. *
  1101. * For convenience, you can also pass an action creator as the first argument,
  1102. * and get a dispatch wrapped function in return.
  1103. *
  1104. * @param {Function|Object} actionCreators An object whose values are action
  1105. * creator functions. One handy way to obtain it is to use ES6 `import * as`
  1106. * syntax. You may also pass a single function.
  1107. *
  1108. * @param {Function} dispatch The `dispatch` function available on your Redux
  1109. * store.
  1110. *
  1111. * @returns {Function|Object} The object mimicking the original object, but with
  1112. * every action creator wrapped into the `dispatch` call. If you passed a
  1113. * function as `actionCreators`, the return value will also be a single
  1114. * function.
  1115. */
  1116. function bindActionCreators(actionCreators, dispatch) {
  1117. if (typeof actionCreators === 'function') {
  1118. return bindActionCreator(actionCreators, dispatch);
  1119. }
  1120. if (typeof actionCreators !== 'object' || actionCreators === null) {
  1121. throw new Error( true ? formatProdErrorMessage(16) : 0);
  1122. }
  1123. var boundActionCreators = {};
  1124. for (var key in actionCreators) {
  1125. var actionCreator = actionCreators[key];
  1126. if (typeof actionCreator === 'function') {
  1127. boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
  1128. }
  1129. }
  1130. return boundActionCreators;
  1131. }
  1132. /**
  1133. * Composes single-argument functions from right to left. The rightmost
  1134. * function can take multiple arguments as it provides the signature for
  1135. * the resulting composite function.
  1136. *
  1137. * @param {...Function} funcs The functions to compose.
  1138. * @returns {Function} A function obtained by composing the argument functions
  1139. * from right to left. For example, compose(f, g, h) is identical to doing
  1140. * (...args) => f(g(h(...args))).
  1141. */
  1142. function compose() {
  1143. for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
  1144. funcs[_key] = arguments[_key];
  1145. }
  1146. if (funcs.length === 0) {
  1147. return function (arg) {
  1148. return arg;
  1149. };
  1150. }
  1151. if (funcs.length === 1) {
  1152. return funcs[0];
  1153. }
  1154. return funcs.reduce(function (a, b) {
  1155. return function () {
  1156. return a(b.apply(void 0, arguments));
  1157. };
  1158. });
  1159. }
  1160. /**
  1161. * Creates a store enhancer that applies middleware to the dispatch method
  1162. * of the Redux store. This is handy for a variety of tasks, such as expressing
  1163. * asynchronous actions in a concise manner, or logging every action payload.
  1164. *
  1165. * See `redux-thunk` package as an example of the Redux middleware.
  1166. *
  1167. * Because middleware is potentially asynchronous, this should be the first
  1168. * store enhancer in the composition chain.
  1169. *
  1170. * Note that each middleware will be given the `dispatch` and `getState` functions
  1171. * as named arguments.
  1172. *
  1173. * @param {...Function} middlewares The middleware chain to be applied.
  1174. * @returns {Function} A store enhancer applying the middleware.
  1175. */
  1176. function applyMiddleware() {
  1177. for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
  1178. middlewares[_key] = arguments[_key];
  1179. }
  1180. return function (createStore) {
  1181. return function () {
  1182. var store = createStore.apply(void 0, arguments);
  1183. var _dispatch = function dispatch() {
  1184. throw new Error( true ? formatProdErrorMessage(15) : 0);
  1185. };
  1186. var middlewareAPI = {
  1187. getState: store.getState,
  1188. dispatch: function dispatch() {
  1189. return _dispatch.apply(void 0, arguments);
  1190. }
  1191. };
  1192. var chain = middlewares.map(function (middleware) {
  1193. return middleware(middlewareAPI);
  1194. });
  1195. _dispatch = compose.apply(void 0, chain)(store.dispatch);
  1196. return _objectSpread2(_objectSpread2({}, store), {}, {
  1197. dispatch: _dispatch
  1198. });
  1199. };
  1200. };
  1201. }
  1202. // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  1203. var equivalent_key_map = __webpack_require__(2167);
  1204. var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  1205. ;// CONCATENATED MODULE: external ["wp","reduxRoutine"]
  1206. var external_wp_reduxRoutine_namespaceObject = window["wp"]["reduxRoutine"];
  1207. var external_wp_reduxRoutine_default = /*#__PURE__*/__webpack_require__.n(external_wp_reduxRoutine_namespaceObject);
  1208. ;// CONCATENATED MODULE: external ["wp","compose"]
  1209. var external_wp_compose_namespaceObject = window["wp"]["compose"];
  1210. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/factory.js
  1211. /**
  1212. * Creates a selector function that takes additional curried argument with the
  1213. * registry `select` function. While a regular selector has signature
  1214. * ```js
  1215. * ( state, ...selectorArgs ) => ( result )
  1216. * ```
  1217. * that allows to select data from the store's `state`, a registry selector
  1218. * has signature:
  1219. * ```js
  1220. * ( select ) => ( state, ...selectorArgs ) => ( result )
  1221. * ```
  1222. * that supports also selecting from other registered stores.
  1223. *
  1224. * @example
  1225. * ```js
  1226. * import { store as coreStore } from '@wordpress/core-data';
  1227. * import { store as editorStore } from '@wordpress/editor';
  1228. *
  1229. * const getCurrentPostId = createRegistrySelector( ( select ) => ( state ) => {
  1230. * return select( editorStore ).getCurrentPostId();
  1231. * } );
  1232. *
  1233. * const getPostEdits = createRegistrySelector( ( select ) => ( state ) => {
  1234. * // calling another registry selector just like any other function
  1235. * const postType = getCurrentPostType( state );
  1236. * const postId = getCurrentPostId( state );
  1237. * return select( coreStore ).getEntityRecordEdits( 'postType', postType, postId );
  1238. * } );
  1239. * ```
  1240. *
  1241. * Note how the `getCurrentPostId` selector can be called just like any other function,
  1242. * (it works even inside a regular non-registry selector) and we don't need to pass the
  1243. * registry as argument. The registry binding happens automatically when registering the selector
  1244. * with a store.
  1245. *
  1246. * @param {Function} registrySelector Function receiving a registry `select`
  1247. * function and returning a state selector.
  1248. *
  1249. * @return {Function} Registry selector that can be registered with a store.
  1250. */
  1251. function createRegistrySelector(registrySelector) {
  1252. // Create a selector function that is bound to the registry referenced by `selector.registry`
  1253. // and that has the same API as a regular selector. Binding it in such a way makes it
  1254. // possible to call the selector directly from another selector.
  1255. const selector = (...args) => registrySelector(selector.registry.select)(...args);
  1256. /**
  1257. * Flag indicating that the selector is a registry selector that needs the correct registry
  1258. * reference to be assigned to `selector.registry` to make it work correctly.
  1259. * be mapped as a registry selector.
  1260. *
  1261. * @type {boolean}
  1262. */
  1263. selector.isRegistrySelector = true;
  1264. return selector;
  1265. }
  1266. /**
  1267. * Creates a control function that takes additional curried argument with the `registry` object.
  1268. * While a regular control has signature
  1269. * ```js
  1270. * ( action ) => ( iteratorOrPromise )
  1271. * ```
  1272. * where the control works with the `action` that it's bound to, a registry control has signature:
  1273. * ```js
  1274. * ( registry ) => ( action ) => ( iteratorOrPromise )
  1275. * ```
  1276. * A registry control is typically used to select data or dispatch an action to a registered
  1277. * store.
  1278. *
  1279. * When registering a control created with `createRegistryControl` with a store, the store
  1280. * knows which calling convention to use when executing the control.
  1281. *
  1282. * @param {Function} registryControl Function receiving a registry object and returning a control.
  1283. *
  1284. * @return {Function} Registry control that can be registered with a store.
  1285. */
  1286. function createRegistryControl(registryControl) {
  1287. registryControl.isRegistryControl = true;
  1288. return registryControl;
  1289. }
  1290. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/controls.js
  1291. /**
  1292. * Internal dependencies
  1293. */
  1294. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  1295. const SELECT = '@@data/SELECT';
  1296. const RESOLVE_SELECT = '@@data/RESOLVE_SELECT';
  1297. const DISPATCH = '@@data/DISPATCH';
  1298. function isObject(object) {
  1299. return object !== null && typeof object === 'object';
  1300. }
  1301. /**
  1302. * Dispatches a control action for triggering a synchronous registry select.
  1303. *
  1304. * Note: This control synchronously returns the current selector value, triggering the
  1305. * resolution, but not waiting for it.
  1306. *
  1307. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1308. * @param {string} selectorName The name of the selector.
  1309. * @param {Array} args Arguments for the selector.
  1310. *
  1311. * @example
  1312. * ```js
  1313. * import { controls } from '@wordpress/data';
  1314. *
  1315. * // Action generator using `select`.
  1316. * export function* myAction() {
  1317. * const isEditorSideBarOpened = yield controls.select( 'core/edit-post', 'isEditorSideBarOpened' );
  1318. * // Do stuff with the result from the `select`.
  1319. * }
  1320. * ```
  1321. *
  1322. * @return {Object} The control descriptor.
  1323. */
  1324. function controls_select(storeNameOrDescriptor, selectorName, ...args) {
  1325. return {
  1326. type: SELECT,
  1327. storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1328. selectorName,
  1329. args
  1330. };
  1331. }
  1332. /**
  1333. * Dispatches a control action for triggering and resolving a registry select.
  1334. *
  1335. * Note: when this control action is handled, it automatically considers
  1336. * selectors that may have a resolver. In such case, it will return a `Promise` that resolves
  1337. * after the selector finishes resolving, with the final result value.
  1338. *
  1339. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1340. * @param {string} selectorName The name of the selector
  1341. * @param {Array} args Arguments for the selector.
  1342. *
  1343. * @example
  1344. * ```js
  1345. * import { controls } from '@wordpress/data';
  1346. *
  1347. * // Action generator using resolveSelect
  1348. * export function* myAction() {
  1349. * const isSidebarOpened = yield controls.resolveSelect( 'core/edit-post', 'isEditorSideBarOpened' );
  1350. * // do stuff with the result from the select.
  1351. * }
  1352. * ```
  1353. *
  1354. * @return {Object} The control descriptor.
  1355. */
  1356. function resolveSelect(storeNameOrDescriptor, selectorName, ...args) {
  1357. return {
  1358. type: RESOLVE_SELECT,
  1359. storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1360. selectorName,
  1361. args
  1362. };
  1363. }
  1364. /**
  1365. * Dispatches a control action for triggering a registry dispatch.
  1366. *
  1367. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  1368. * @param {string} actionName The name of the action to dispatch
  1369. * @param {Array} args Arguments for the dispatch action.
  1370. *
  1371. * @example
  1372. * ```js
  1373. * import { controls } from '@wordpress/data-controls';
  1374. *
  1375. * // Action generator using dispatch
  1376. * export function* myAction() {
  1377. * yield controls.dispatch( 'core/edit-post', 'togglePublishSidebar' );
  1378. * // do some other things.
  1379. * }
  1380. * ```
  1381. *
  1382. * @return {Object} The control descriptor.
  1383. */
  1384. function dispatch(storeNameOrDescriptor, actionName, ...args) {
  1385. return {
  1386. type: DISPATCH,
  1387. storeKey: isObject(storeNameOrDescriptor) ? storeNameOrDescriptor.name : storeNameOrDescriptor,
  1388. actionName,
  1389. args
  1390. };
  1391. }
  1392. const controls = {
  1393. select: controls_select,
  1394. resolveSelect,
  1395. dispatch
  1396. };
  1397. const builtinControls = {
  1398. [SELECT]: createRegistryControl(registry => ({
  1399. storeKey,
  1400. selectorName,
  1401. args
  1402. }) => registry.select(storeKey)[selectorName](...args)),
  1403. [RESOLVE_SELECT]: createRegistryControl(registry => ({
  1404. storeKey,
  1405. selectorName,
  1406. args
  1407. }) => {
  1408. const method = registry.select(storeKey)[selectorName].hasResolver ? 'resolveSelect' : 'select';
  1409. return registry[method](storeKey)[selectorName](...args);
  1410. }),
  1411. [DISPATCH]: createRegistryControl(registry => ({
  1412. storeKey,
  1413. actionName,
  1414. args
  1415. }) => registry.dispatch(storeKey)[actionName](...args))
  1416. };
  1417. ;// CONCATENATED MODULE: external ["wp","privateApis"]
  1418. var external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
  1419. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/lock-unlock.js
  1420. /**
  1421. * WordPress dependencies
  1422. */
  1423. const {
  1424. lock,
  1425. unlock
  1426. } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/data');
  1427. ;// CONCATENATED MODULE: ./node_modules/is-promise/index.mjs
  1428. function isPromise(obj) {
  1429. return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
  1430. }
  1431. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/promise-middleware.js
  1432. /**
  1433. * External dependencies
  1434. */
  1435. /**
  1436. * Simplest possible promise redux middleware.
  1437. *
  1438. * @type {import('redux').Middleware}
  1439. */
  1440. const promiseMiddleware = () => next => action => {
  1441. if (isPromise(action)) {
  1442. return action.then(resolvedAction => {
  1443. if (resolvedAction) {
  1444. return next(resolvedAction);
  1445. }
  1446. });
  1447. }
  1448. return next(action);
  1449. };
  1450. /* harmony default export */ var promise_middleware = (promiseMiddleware);
  1451. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/store/index.js
  1452. const coreDataStore = {
  1453. name: 'core/data',
  1454. instantiate(registry) {
  1455. const getCoreDataSelector = selectorName => (key, ...args) => {
  1456. return registry.select(key)[selectorName](...args);
  1457. };
  1458. const getCoreDataAction = actionName => (key, ...args) => {
  1459. return registry.dispatch(key)[actionName](...args);
  1460. };
  1461. return {
  1462. getSelectors() {
  1463. return Object.fromEntries(['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'].map(selectorName => [selectorName, getCoreDataSelector(selectorName)]));
  1464. },
  1465. getActions() {
  1466. return Object.fromEntries(['startResolution', 'finishResolution', 'invalidateResolution', 'invalidateResolutionForStore', 'invalidateResolutionForStoreSelector'].map(actionName => [actionName, getCoreDataAction(actionName)]));
  1467. },
  1468. subscribe() {
  1469. // There's no reasons to trigger any listener when we subscribe to this store
  1470. // because there's no state stored in this store that need to retrigger selectors
  1471. // if a change happens, the corresponding store where the tracking stated live
  1472. // would have already triggered a "subscribe" call.
  1473. return () => () => {};
  1474. }
  1475. };
  1476. }
  1477. };
  1478. /* harmony default export */ var store = (coreDataStore);
  1479. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/resolvers-cache-middleware.js
  1480. /**
  1481. * Internal dependencies
  1482. */
  1483. /** @typedef {import('./registry').WPDataRegistry} WPDataRegistry */
  1484. /**
  1485. * Creates a middleware handling resolvers cache invalidation.
  1486. *
  1487. * @param {WPDataRegistry} registry The registry reference for which to create
  1488. * the middleware.
  1489. * @param {string} reducerKey The namespace for which to create the
  1490. * middleware.
  1491. *
  1492. * @return {Function} Middleware function.
  1493. */
  1494. const createResolversCacheMiddleware = (registry, reducerKey) => () => next => action => {
  1495. const resolvers = registry.select(store).getCachedResolvers(reducerKey);
  1496. Object.entries(resolvers).forEach(([selectorName, resolversByArgs]) => {
  1497. const resolver = registry.stores?.[reducerKey]?.resolvers?.[selectorName];
  1498. if (!resolver || !resolver.shouldInvalidate) {
  1499. return;
  1500. }
  1501. resolversByArgs.forEach((value, args) => {
  1502. // resolversByArgs is the map Map([ args ] => boolean) storing the cache resolution status for a given selector.
  1503. // If the value is "finished" or "error" it means this resolver has finished its resolution which means we need
  1504. // to invalidate it, if it's true it means it's inflight and the invalidation is not necessary.
  1505. if (value?.status !== 'finished' && value?.status !== 'error' || !resolver.shouldInvalidate(action, ...args)) {
  1506. return;
  1507. }
  1508. // Trigger cache invalidation
  1509. registry.dispatch(store).invalidateResolution(reducerKey, selectorName, args);
  1510. });
  1511. });
  1512. return next(action);
  1513. };
  1514. /* harmony default export */ var resolvers_cache_middleware = (createResolversCacheMiddleware);
  1515. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/thunk-middleware.js
  1516. function createThunkMiddleware(args) {
  1517. return () => next => action => {
  1518. if (typeof action === 'function') {
  1519. return action(args);
  1520. }
  1521. return next(action);
  1522. };
  1523. }
  1524. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/utils.js
  1525. /**
  1526. * External dependencies
  1527. */
  1528. /**
  1529. * Higher-order reducer creator which creates a combined reducer object, keyed
  1530. * by a property on the action object.
  1531. *
  1532. * @param actionProperty Action property by which to key object.
  1533. * @return Higher-order reducer.
  1534. */
  1535. const onSubKey = actionProperty => reducer => (state = {}, action) => {
  1536. // Retrieve subkey from action. Do not track if undefined; useful for cases
  1537. // where reducer is scoped by action shape.
  1538. const key = action[actionProperty];
  1539. if (key === undefined) {
  1540. return state;
  1541. }
  1542. // Avoid updating state if unchanged. Note that this also accounts for a
  1543. // reducer which returns undefined on a key which is not yet tracked.
  1544. const nextKeyState = reducer(state[key], action);
  1545. if (nextKeyState === state[key]) {
  1546. return state;
  1547. }
  1548. return {
  1549. ...state,
  1550. [key]: nextKeyState
  1551. };
  1552. };
  1553. /**
  1554. * Normalize selector argument array by defaulting `undefined` value to an empty array
  1555. * and removing trailing `undefined` values.
  1556. *
  1557. * @param args Selector argument array
  1558. * @return Normalized state key array
  1559. */
  1560. function selectorArgsToStateKey(args) {
  1561. if (args === undefined || args === null) {
  1562. return [];
  1563. }
  1564. const len = args.length;
  1565. let idx = len;
  1566. while (idx > 0 && args[idx - 1] === undefined) {
  1567. idx--;
  1568. }
  1569. return idx === len ? args : args.slice(0, idx);
  1570. }
  1571. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/reducer.js
  1572. /**
  1573. * External dependencies
  1574. */
  1575. /**
  1576. * Internal dependencies
  1577. */
  1578. /**
  1579. * Reducer function returning next state for selector resolution of
  1580. * subkeys, object form:
  1581. *
  1582. * selectorName -> EquivalentKeyMap<Array,boolean>
  1583. */
  1584. const subKeysIsResolved = onSubKey('selectorName')((state = new (equivalent_key_map_default())(), action) => {
  1585. switch (action.type) {
  1586. case 'START_RESOLUTION':
  1587. {
  1588. const nextState = new (equivalent_key_map_default())(state);
  1589. nextState.set(selectorArgsToStateKey(action.args), {
  1590. status: 'resolving'
  1591. });
  1592. return nextState;
  1593. }
  1594. case 'FINISH_RESOLUTION':
  1595. {
  1596. const nextState = new (equivalent_key_map_default())(state);
  1597. nextState.set(selectorArgsToStateKey(action.args), {
  1598. status: 'finished'
  1599. });
  1600. return nextState;
  1601. }
  1602. case 'FAIL_RESOLUTION':
  1603. {
  1604. const nextState = new (equivalent_key_map_default())(state);
  1605. nextState.set(selectorArgsToStateKey(action.args), {
  1606. status: 'error',
  1607. error: action.error
  1608. });
  1609. return nextState;
  1610. }
  1611. case 'START_RESOLUTIONS':
  1612. {
  1613. const nextState = new (equivalent_key_map_default())(state);
  1614. for (const resolutionArgs of action.args) {
  1615. nextState.set(selectorArgsToStateKey(resolutionArgs), {
  1616. status: 'resolving'
  1617. });
  1618. }
  1619. return nextState;
  1620. }
  1621. case 'FINISH_RESOLUTIONS':
  1622. {
  1623. const nextState = new (equivalent_key_map_default())(state);
  1624. for (const resolutionArgs of action.args) {
  1625. nextState.set(selectorArgsToStateKey(resolutionArgs), {
  1626. status: 'finished'
  1627. });
  1628. }
  1629. return nextState;
  1630. }
  1631. case 'FAIL_RESOLUTIONS':
  1632. {
  1633. const nextState = new (equivalent_key_map_default())(state);
  1634. action.args.forEach((resolutionArgs, idx) => {
  1635. const resolutionState = {
  1636. status: 'error',
  1637. error: undefined
  1638. };
  1639. const error = action.errors[idx];
  1640. if (error) {
  1641. resolutionState.error = error;
  1642. }
  1643. nextState.set(selectorArgsToStateKey(resolutionArgs), resolutionState);
  1644. });
  1645. return nextState;
  1646. }
  1647. case 'INVALIDATE_RESOLUTION':
  1648. {
  1649. const nextState = new (equivalent_key_map_default())(state);
  1650. nextState.delete(selectorArgsToStateKey(action.args));
  1651. return nextState;
  1652. }
  1653. }
  1654. return state;
  1655. });
  1656. /**
  1657. * Reducer function returning next state for selector resolution, object form:
  1658. *
  1659. * selectorName -> EquivalentKeyMap<Array, boolean>
  1660. *
  1661. * @param state Current state.
  1662. * @param action Dispatched action.
  1663. *
  1664. * @return Next state.
  1665. */
  1666. const isResolved = (state = {}, action) => {
  1667. switch (action.type) {
  1668. case 'INVALIDATE_RESOLUTION_FOR_STORE':
  1669. return {};
  1670. case 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR':
  1671. {
  1672. if (action.selectorName in state) {
  1673. const {
  1674. [action.selectorName]: removedSelector,
  1675. ...restState
  1676. } = state;
  1677. return restState;
  1678. }
  1679. return state;
  1680. }
  1681. case 'START_RESOLUTION':
  1682. case 'FINISH_RESOLUTION':
  1683. case 'FAIL_RESOLUTION':
  1684. case 'START_RESOLUTIONS':
  1685. case 'FINISH_RESOLUTIONS':
  1686. case 'FAIL_RESOLUTIONS':
  1687. case 'INVALIDATE_RESOLUTION':
  1688. return subKeysIsResolved(state, action);
  1689. }
  1690. return state;
  1691. };
  1692. /* harmony default export */ var metadata_reducer = (isResolved);
  1693. ;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js
  1694. /** @typedef {(...args: any[]) => *[]} GetDependants */
  1695. /** @typedef {() => void} Clear */
  1696. /**
  1697. * @typedef {{
  1698. * getDependants: GetDependants,
  1699. * clear: Clear
  1700. * }} EnhancedSelector
  1701. */
  1702. /**
  1703. * Internal cache entry.
  1704. *
  1705. * @typedef CacheNode
  1706. *
  1707. * @property {?CacheNode|undefined} [prev] Previous node.
  1708. * @property {?CacheNode|undefined} [next] Next node.
  1709. * @property {*[]} args Function arguments for cache entry.
  1710. * @property {*} val Function result.
  1711. */
  1712. /**
  1713. * @typedef Cache
  1714. *
  1715. * @property {Clear} clear Function to clear cache.
  1716. * @property {boolean} [isUniqueByDependants] Whether dependants are valid in
  1717. * considering cache uniqueness. A cache is unique if dependents are all arrays
  1718. * or objects.
  1719. * @property {CacheNode?} [head] Cache head.
  1720. * @property {*[]} [lastDependants] Dependants from previous invocation.
  1721. */
  1722. /**
  1723. * Arbitrary value used as key for referencing cache object in WeakMap tree.
  1724. *
  1725. * @type {{}}
  1726. */
  1727. var LEAF_KEY = {};
  1728. /**
  1729. * Returns the first argument as the sole entry in an array.
  1730. *
  1731. * @template T
  1732. *
  1733. * @param {T} value Value to return.
  1734. *
  1735. * @return {[T]} Value returned as entry in array.
  1736. */
  1737. function arrayOf(value) {
  1738. return [value];
  1739. }
  1740. /**
  1741. * Returns true if the value passed is object-like, or false otherwise. A value
  1742. * is object-like if it can support property assignment, e.g. object or array.
  1743. *
  1744. * @param {*} value Value to test.
  1745. *
  1746. * @return {boolean} Whether value is object-like.
  1747. */
  1748. function isObjectLike(value) {
  1749. return !!value && 'object' === typeof value;
  1750. }
  1751. /**
  1752. * Creates and returns a new cache object.
  1753. *
  1754. * @return {Cache} Cache object.
  1755. */
  1756. function createCache() {
  1757. /** @type {Cache} */
  1758. var cache = {
  1759. clear: function () {
  1760. cache.head = null;
  1761. },
  1762. };
  1763. return cache;
  1764. }
  1765. /**
  1766. * Returns true if entries within the two arrays are strictly equal by
  1767. * reference from a starting index.
  1768. *
  1769. * @param {*[]} a First array.
  1770. * @param {*[]} b Second array.
  1771. * @param {number} fromIndex Index from which to start comparison.
  1772. *
  1773. * @return {boolean} Whether arrays are shallowly equal.
  1774. */
  1775. function isShallowEqual(a, b, fromIndex) {
  1776. var i;
  1777. if (a.length !== b.length) {
  1778. return false;
  1779. }
  1780. for (i = fromIndex; i < a.length; i++) {
  1781. if (a[i] !== b[i]) {
  1782. return false;
  1783. }
  1784. }
  1785. return true;
  1786. }
  1787. /**
  1788. * Returns a memoized selector function. The getDependants function argument is
  1789. * called before the memoized selector and is expected to return an immutable
  1790. * reference or array of references on which the selector depends for computing
  1791. * its own return value. The memoize cache is preserved only as long as those
  1792. * dependant references remain the same. If getDependants returns a different
  1793. * reference(s), the cache is cleared and the selector value regenerated.
  1794. *
  1795. * @template {(...args: *[]) => *} S
  1796. *
  1797. * @param {S} selector Selector function.
  1798. * @param {GetDependants=} getDependants Dependant getter returning an array of
  1799. * references used in cache bust consideration.
  1800. */
  1801. /* harmony default export */ function rememo(selector, getDependants) {
  1802. /** @type {WeakMap<*,*>} */
  1803. var rootCache;
  1804. /** @type {GetDependants} */
  1805. var normalizedGetDependants = getDependants ? getDependants : arrayOf;
  1806. /**
  1807. * Returns the cache for a given dependants array. When possible, a WeakMap
  1808. * will be used to create a unique cache for each set of dependants. This
  1809. * is feasible due to the nature of WeakMap in allowing garbage collection
  1810. * to occur on entries where the key object is no longer referenced. Since
  1811. * WeakMap requires the key to be an object, this is only possible when the
  1812. * dependant is object-like. The root cache is created as a hierarchy where
  1813. * each top-level key is the first entry in a dependants set, the value a
  1814. * WeakMap where each key is the next dependant, and so on. This continues
  1815. * so long as the dependants are object-like. If no dependants are object-
  1816. * like, then the cache is shared across all invocations.
  1817. *
  1818. * @see isObjectLike
  1819. *
  1820. * @param {*[]} dependants Selector dependants.
  1821. *
  1822. * @return {Cache} Cache object.
  1823. */
  1824. function getCache(dependants) {
  1825. var caches = rootCache,
  1826. isUniqueByDependants = true,
  1827. i,
  1828. dependant,
  1829. map,
  1830. cache;
  1831. for (i = 0; i < dependants.length; i++) {
  1832. dependant = dependants[i];
  1833. // Can only compose WeakMap from object-like key.
  1834. if (!isObjectLike(dependant)) {
  1835. isUniqueByDependants = false;
  1836. break;
  1837. }
  1838. // Does current segment of cache already have a WeakMap?
  1839. if (caches.has(dependant)) {
  1840. // Traverse into nested WeakMap.
  1841. caches = caches.get(dependant);
  1842. } else {
  1843. // Create, set, and traverse into a new one.
  1844. map = new WeakMap();
  1845. caches.set(dependant, map);
  1846. caches = map;
  1847. }
  1848. }
  1849. // We use an arbitrary (but consistent) object as key for the last item
  1850. // in the WeakMap to serve as our running cache.
  1851. if (!caches.has(LEAF_KEY)) {
  1852. cache = createCache();
  1853. cache.isUniqueByDependants = isUniqueByDependants;
  1854. caches.set(LEAF_KEY, cache);
  1855. }
  1856. return caches.get(LEAF_KEY);
  1857. }
  1858. /**
  1859. * Resets root memoization cache.
  1860. */
  1861. function clear() {
  1862. rootCache = new WeakMap();
  1863. }
  1864. /* eslint-disable jsdoc/check-param-names */
  1865. /**
  1866. * The augmented selector call, considering first whether dependants have
  1867. * changed before passing it to underlying memoize function.
  1868. *
  1869. * @param {*} source Source object for derivation.
  1870. * @param {...*} extraArgs Additional arguments to pass to selector.
  1871. *
  1872. * @return {*} Selector result.
  1873. */
  1874. /* eslint-enable jsdoc/check-param-names */
  1875. function callSelector(/* source, ...extraArgs */) {
  1876. var len = arguments.length,
  1877. cache,
  1878. node,
  1879. i,
  1880. args,
  1881. dependants;
  1882. // Create copy of arguments (avoid leaking deoptimization).
  1883. args = new Array(len);
  1884. for (i = 0; i < len; i++) {
  1885. args[i] = arguments[i];
  1886. }
  1887. dependants = normalizedGetDependants.apply(null, args);
  1888. cache = getCache(dependants);
  1889. // If not guaranteed uniqueness by dependants (primitive type), shallow
  1890. // compare against last dependants and, if references have changed,
  1891. // destroy cache to recalculate result.
  1892. if (!cache.isUniqueByDependants) {
  1893. if (
  1894. cache.lastDependants &&
  1895. !isShallowEqual(dependants, cache.lastDependants, 0)
  1896. ) {
  1897. cache.clear();
  1898. }
  1899. cache.lastDependants = dependants;
  1900. }
  1901. node = cache.head;
  1902. while (node) {
  1903. // Check whether node arguments match arguments
  1904. if (!isShallowEqual(node.args, args, 1)) {
  1905. node = node.next;
  1906. continue;
  1907. }
  1908. // At this point we can assume we've found a match
  1909. // Surface matched node to head if not already
  1910. if (node !== cache.head) {
  1911. // Adjust siblings to point to each other.
  1912. /** @type {CacheNode} */ (node.prev).next = node.next;
  1913. if (node.next) {
  1914. node.next.prev = node.prev;
  1915. }
  1916. node.next = cache.head;
  1917. node.prev = null;
  1918. /** @type {CacheNode} */ (cache.head).prev = node;
  1919. cache.head = node;
  1920. }
  1921. // Return immediately
  1922. return node.val;
  1923. }
  1924. // No cached value found. Continue to insertion phase:
  1925. node = /** @type {CacheNode} */ ({
  1926. // Generate the result from original function
  1927. val: selector.apply(null, args),
  1928. });
  1929. // Avoid including the source object in the cache.
  1930. args[0] = null;
  1931. node.args = args;
  1932. // Don't need to check whether node is already head, since it would
  1933. // have been returned above already if it was
  1934. // Shift existing head down list
  1935. if (cache.head) {
  1936. cache.head.prev = node;
  1937. node.next = cache.head;
  1938. }
  1939. cache.head = node;
  1940. return node.val;
  1941. }
  1942. callSelector.getDependants = normalizedGetDependants;
  1943. callSelector.clear = clear;
  1944. clear();
  1945. return /** @type {S & EnhancedSelector} */ (callSelector);
  1946. }
  1947. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/selectors.js
  1948. /**
  1949. * External dependencies
  1950. */
  1951. /**
  1952. * Internal dependencies
  1953. */
  1954. /** @typedef {Record<string, import('./reducer').State>} State */
  1955. /** @typedef {import('./reducer').StateValue} StateValue */
  1956. /** @typedef {import('./reducer').Status} Status */
  1957. /**
  1958. * Returns the raw resolution state value for a given selector name,
  1959. * and arguments set. May be undefined if the selector has never been resolved
  1960. * or not resolved for the given set of arguments, otherwise true or false for
  1961. * resolution started and completed respectively.
  1962. *
  1963. * @param {State} state Data state.
  1964. * @param {string} selectorName Selector name.
  1965. * @param {unknown[]?} args Arguments passed to selector.
  1966. *
  1967. * @return {StateValue|undefined} isResolving value.
  1968. */
  1969. function getResolutionState(state, selectorName, args) {
  1970. const map = state[selectorName];
  1971. if (!map) {
  1972. return;
  1973. }
  1974. return map.get(selectorArgsToStateKey(args));
  1975. }
  1976. /**
  1977. * Returns the raw `isResolving` value for a given selector name,
  1978. * and arguments set. May be undefined if the selector has never been resolved
  1979. * or not resolved for the given set of arguments, otherwise true or false for
  1980. * resolution started and completed respectively.
  1981. *
  1982. * @param {State} state Data state.
  1983. * @param {string} selectorName Selector name.
  1984. * @param {unknown[]?} args Arguments passed to selector.
  1985. *
  1986. * @return {boolean | undefined} isResolving value.
  1987. */
  1988. function getIsResolving(state, selectorName, args) {
  1989. const resolutionState = getResolutionState(state, selectorName, args);
  1990. return resolutionState && resolutionState.status === 'resolving';
  1991. }
  1992. /**
  1993. * Returns true if resolution has already been triggered for a given
  1994. * selector name, and arguments set.
  1995. *
  1996. * @param {State} state Data state.
  1997. * @param {string} selectorName Selector name.
  1998. * @param {unknown[]?} args Arguments passed to selector.
  1999. *
  2000. * @return {boolean} Whether resolution has been triggered.
  2001. */
  2002. function hasStartedResolution(state, selectorName, args) {
  2003. return getResolutionState(state, selectorName, args) !== undefined;
  2004. }
  2005. /**
  2006. * Returns true if resolution has completed for a given selector
  2007. * name, and arguments set.
  2008. *
  2009. * @param {State} state Data state.
  2010. * @param {string} selectorName Selector name.
  2011. * @param {unknown[]?} args Arguments passed to selector.
  2012. *
  2013. * @return {boolean} Whether resolution has completed.
  2014. */
  2015. function hasFinishedResolution(state, selectorName, args) {
  2016. const status = getResolutionState(state, selectorName, args)?.status;
  2017. return status === 'finished' || status === 'error';
  2018. }
  2019. /**
  2020. * Returns true if resolution has failed for a given selector
  2021. * name, and arguments set.
  2022. *
  2023. * @param {State} state Data state.
  2024. * @param {string} selectorName Selector name.
  2025. * @param {unknown[]?} args Arguments passed to selector.
  2026. *
  2027. * @return {boolean} Has resolution failed
  2028. */
  2029. function hasResolutionFailed(state, selectorName, args) {
  2030. return getResolutionState(state, selectorName, args)?.status === 'error';
  2031. }
  2032. /**
  2033. * Returns the resolution error for a given selector name, and arguments set.
  2034. * Note it may be of an Error type, but may also be null, undefined, or anything else
  2035. * that can be `throw`-n.
  2036. *
  2037. * @param {State} state Data state.
  2038. * @param {string} selectorName Selector name.
  2039. * @param {unknown[]?} args Arguments passed to selector.
  2040. *
  2041. * @return {Error|unknown} Last resolution error
  2042. */
  2043. function getResolutionError(state, selectorName, args) {
  2044. const resolutionState = getResolutionState(state, selectorName, args);
  2045. return resolutionState?.status === 'error' ? resolutionState.error : null;
  2046. }
  2047. /**
  2048. * Returns true if resolution has been triggered but has not yet completed for
  2049. * a given selector name, and arguments set.
  2050. *
  2051. * @param {State} state Data state.
  2052. * @param {string} selectorName Selector name.
  2053. * @param {unknown[]?} args Arguments passed to selector.
  2054. *
  2055. * @return {boolean} Whether resolution is in progress.
  2056. */
  2057. function isResolving(state, selectorName, args) {
  2058. return getResolutionState(state, selectorName, args)?.status === 'resolving';
  2059. }
  2060. /**
  2061. * Returns the list of the cached resolvers.
  2062. *
  2063. * @param {State} state Data state.
  2064. *
  2065. * @return {State} Resolvers mapped by args and selectorName.
  2066. */
  2067. function getCachedResolvers(state) {
  2068. return state;
  2069. }
  2070. /**
  2071. * Whether the store has any currently resolving selectors.
  2072. *
  2073. * @param {State} state Data state.
  2074. *
  2075. * @return {boolean} True if one or more selectors are resolving, false otherwise.
  2076. */
  2077. function hasResolvingSelectors(state) {
  2078. return Object.values(state).some(selectorState =>
  2079. /**
  2080. * This uses the internal `_map` property of `EquivalentKeyMap` for
  2081. * optimization purposes, since the `EquivalentKeyMap` implementation
  2082. * does not support a `.values()` implementation.
  2083. *
  2084. * @see https://github.com/aduth/equivalent-key-map
  2085. */
  2086. Array.from(selectorState._map.values()).some(resolution => resolution[1]?.status === 'resolving'));
  2087. }
  2088. /**
  2089. * Retrieves the total number of selectors, grouped per status.
  2090. *
  2091. * @param {State} state Data state.
  2092. *
  2093. * @return {Object} Object, containing selector totals by status.
  2094. */
  2095. const countSelectorsByStatus = rememo(state => {
  2096. const selectorsByStatus = {};
  2097. Object.values(state).forEach(selectorState =>
  2098. /**
  2099. * This uses the internal `_map` property of `EquivalentKeyMap` for
  2100. * optimization purposes, since the `EquivalentKeyMap` implementation
  2101. * does not support a `.values()` implementation.
  2102. *
  2103. * @see https://github.com/aduth/equivalent-key-map
  2104. */
  2105. Array.from(selectorState._map.values()).forEach(resolution => {
  2106. var _resolution$1$status;
  2107. const currentStatus = (_resolution$1$status = resolution[1]?.status) !== null && _resolution$1$status !== void 0 ? _resolution$1$status : 'error';
  2108. if (!selectorsByStatus[currentStatus]) {
  2109. selectorsByStatus[currentStatus] = 0;
  2110. }
  2111. selectorsByStatus[currentStatus]++;
  2112. }));
  2113. return selectorsByStatus;
  2114. }, state => [state]);
  2115. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/metadata/actions.js
  2116. /**
  2117. * Returns an action object used in signalling that selector resolution has
  2118. * started.
  2119. *
  2120. * @param {string} selectorName Name of selector for which resolver triggered.
  2121. * @param {unknown[]} args Arguments to associate for uniqueness.
  2122. *
  2123. * @return {{ type: 'START_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
  2124. */
  2125. function startResolution(selectorName, args) {
  2126. return {
  2127. type: 'START_RESOLUTION',
  2128. selectorName,
  2129. args
  2130. };
  2131. }
  2132. /**
  2133. * Returns an action object used in signalling that selector resolution has
  2134. * completed.
  2135. *
  2136. * @param {string} selectorName Name of selector for which resolver triggered.
  2137. * @param {unknown[]} args Arguments to associate for uniqueness.
  2138. *
  2139. * @return {{ type: 'FINISH_RESOLUTION', selectorName: string, args: unknown[] }} Action object.
  2140. */
  2141. function finishResolution(selectorName, args) {
  2142. return {
  2143. type: 'FINISH_RESOLUTION',
  2144. selectorName,
  2145. args
  2146. };
  2147. }
  2148. /**
  2149. * Returns an action object used in signalling that selector resolution has
  2150. * failed.
  2151. *
  2152. * @param {string} selectorName Name of selector for which resolver triggered.
  2153. * @param {unknown[]} args Arguments to associate for uniqueness.
  2154. * @param {Error|unknown} error The error that caused the failure.
  2155. *
  2156. * @return {{ type: 'FAIL_RESOLUTION', selectorName: string, args: unknown[], error: Error|unknown }} Action object.
  2157. */
  2158. function failResolution(selectorName, args, error) {
  2159. return {
  2160. type: 'FAIL_RESOLUTION',
  2161. selectorName,
  2162. args,
  2163. error
  2164. };
  2165. }
  2166. /**
  2167. * Returns an action object used in signalling that a batch of selector resolutions has
  2168. * started.
  2169. *
  2170. * @param {string} selectorName Name of selector for which resolver triggered.
  2171. * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
  2172. * is associated to a resolution.
  2173. *
  2174. * @return {{ type: 'START_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
  2175. */
  2176. function startResolutions(selectorName, args) {
  2177. return {
  2178. type: 'START_RESOLUTIONS',
  2179. selectorName,
  2180. args
  2181. };
  2182. }
  2183. /**
  2184. * Returns an action object used in signalling that a batch of selector resolutions has
  2185. * completed.
  2186. *
  2187. * @param {string} selectorName Name of selector for which resolver triggered.
  2188. * @param {unknown[][]} args Array of arguments to associate for uniqueness, each item
  2189. * is associated to a resolution.
  2190. *
  2191. * @return {{ type: 'FINISH_RESOLUTIONS', selectorName: string, args: unknown[][] }} Action object.
  2192. */
  2193. function finishResolutions(selectorName, args) {
  2194. return {
  2195. type: 'FINISH_RESOLUTIONS',
  2196. selectorName,
  2197. args
  2198. };
  2199. }
  2200. /**
  2201. * Returns an action object used in signalling that a batch of selector resolutions has
  2202. * completed and at least one of them has failed.
  2203. *
  2204. * @param {string} selectorName Name of selector for which resolver triggered.
  2205. * @param {unknown[]} args Array of arguments to associate for uniqueness, each item
  2206. * is associated to a resolution.
  2207. * @param {(Error|unknown)[]} errors Array of errors to associate for uniqueness, each item
  2208. * is associated to a resolution.
  2209. * @return {{ type: 'FAIL_RESOLUTIONS', selectorName: string, args: unknown[], errors: Array<Error|unknown> }} Action object.
  2210. */
  2211. function failResolutions(selectorName, args, errors) {
  2212. return {
  2213. type: 'FAIL_RESOLUTIONS',
  2214. selectorName,
  2215. args,
  2216. errors
  2217. };
  2218. }
  2219. /**
  2220. * Returns an action object used in signalling that we should invalidate the resolution cache.
  2221. *
  2222. * @param {string} selectorName Name of selector for which resolver should be invalidated.
  2223. * @param {unknown[]} args Arguments to associate for uniqueness.
  2224. *
  2225. * @return {{ type: 'INVALIDATE_RESOLUTION', selectorName: string, args: any[] }} Action object.
  2226. */
  2227. function invalidateResolution(selectorName, args) {
  2228. return {
  2229. type: 'INVALIDATE_RESOLUTION',
  2230. selectorName,
  2231. args
  2232. };
  2233. }
  2234. /**
  2235. * Returns an action object used in signalling that the resolution
  2236. * should be invalidated.
  2237. *
  2238. * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE' }} Action object.
  2239. */
  2240. function invalidateResolutionForStore() {
  2241. return {
  2242. type: 'INVALIDATE_RESOLUTION_FOR_STORE'
  2243. };
  2244. }
  2245. /**
  2246. * Returns an action object used in signalling that the resolution cache for a
  2247. * given selectorName should be invalidated.
  2248. *
  2249. * @param {string} selectorName Name of selector for which all resolvers should
  2250. * be invalidated.
  2251. *
  2252. * @return {{ type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR', selectorName: string }} Action object.
  2253. */
  2254. function invalidateResolutionForStoreSelector(selectorName) {
  2255. return {
  2256. type: 'INVALIDATE_RESOLUTION_FOR_STORE_SELECTOR',
  2257. selectorName
  2258. };
  2259. }
  2260. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/redux-store/index.js
  2261. /**
  2262. * External dependencies
  2263. */
  2264. /**
  2265. * WordPress dependencies
  2266. */
  2267. /**
  2268. * Internal dependencies
  2269. */
  2270. /** @typedef {import('../types').DataRegistry} DataRegistry */
  2271. /** @typedef {import('../types').ListenerFunction} ListenerFunction */
  2272. /**
  2273. * @typedef {import('../types').StoreDescriptor<C>} StoreDescriptor
  2274. * @template {import('../types').AnyConfig} C
  2275. */
  2276. /**
  2277. * @typedef {import('../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
  2278. * @template State
  2279. * @template {Record<string,import('../../types').ActionCreator>} Actions
  2280. * @template Selectors
  2281. */
  2282. const trimUndefinedValues = array => {
  2283. const result = [...array];
  2284. for (let i = result.length - 1; i >= 0; i--) {
  2285. if (result[i] === undefined) {
  2286. result.splice(i, 1);
  2287. }
  2288. }
  2289. return result;
  2290. };
  2291. /**
  2292. * Creates a new object with the same keys, but with `callback()` called as
  2293. * a transformer function on each of the values.
  2294. *
  2295. * @param {Object} obj The object to transform.
  2296. * @param {Function} callback The function to transform each object value.
  2297. * @return {Array} Transformed object.
  2298. */
  2299. const mapValues = (obj, callback) => Object.fromEntries(Object.entries(obj !== null && obj !== void 0 ? obj : {}).map(([key, value]) => [key, callback(value, key)]));
  2300. // Convert Map objects to plain objects
  2301. const mapToObject = (key, state) => {
  2302. if (state instanceof Map) {
  2303. return Object.fromEntries(state);
  2304. }
  2305. return state;
  2306. };
  2307. /**
  2308. * Create a cache to track whether resolvers started running or not.
  2309. *
  2310. * @return {Object} Resolvers Cache.
  2311. */
  2312. function createResolversCache() {
  2313. const cache = {};
  2314. return {
  2315. isRunning(selectorName, args) {
  2316. return cache[selectorName] && cache[selectorName].get(trimUndefinedValues(args));
  2317. },
  2318. clear(selectorName, args) {
  2319. if (cache[selectorName]) {
  2320. cache[selectorName].delete(trimUndefinedValues(args));
  2321. }
  2322. },
  2323. markAsRunning(selectorName, args) {
  2324. if (!cache[selectorName]) {
  2325. cache[selectorName] = new (equivalent_key_map_default())();
  2326. }
  2327. cache[selectorName].set(trimUndefinedValues(args), true);
  2328. }
  2329. };
  2330. }
  2331. function createBindingCache(bind) {
  2332. const cache = new WeakMap();
  2333. return {
  2334. get(item, itemName) {
  2335. let boundItem = cache.get(item);
  2336. if (!boundItem) {
  2337. boundItem = bind(item, itemName);
  2338. cache.set(item, boundItem);
  2339. }
  2340. return boundItem;
  2341. }
  2342. };
  2343. }
  2344. /**
  2345. * Creates a data store descriptor for the provided Redux store configuration containing
  2346. * properties describing reducer, actions, selectors, controls and resolvers.
  2347. *
  2348. * @example
  2349. * ```js
  2350. * import { createReduxStore } from '@wordpress/data';
  2351. *
  2352. * const store = createReduxStore( 'demo', {
  2353. * reducer: ( state = 'OK' ) => state,
  2354. * selectors: {
  2355. * getValue: ( state ) => state,
  2356. * },
  2357. * } );
  2358. * ```
  2359. *
  2360. * @template State
  2361. * @template {Record<string,import('../../types').ActionCreator>} Actions
  2362. * @template Selectors
  2363. * @param {string} key Unique namespace identifier.
  2364. * @param {ReduxStoreConfig<State,Actions,Selectors>} options Registered store options, with properties
  2365. * describing reducer, actions, selectors,
  2366. * and resolvers.
  2367. *
  2368. * @return {StoreDescriptor<ReduxStoreConfig<State,Actions,Selectors>>} Store Object.
  2369. */
  2370. function createReduxStore(key, options) {
  2371. const privateActions = {};
  2372. const privateSelectors = {};
  2373. const privateRegistrationFunctions = {
  2374. privateActions,
  2375. registerPrivateActions: actions => {
  2376. Object.assign(privateActions, actions);
  2377. },
  2378. privateSelectors,
  2379. registerPrivateSelectors: selectors => {
  2380. Object.assign(privateSelectors, selectors);
  2381. }
  2382. };
  2383. const storeDescriptor = {
  2384. name: key,
  2385. instantiate: registry => {
  2386. /**
  2387. * Stores listener functions registered with `subscribe()`.
  2388. *
  2389. * When functions register to listen to store changes with
  2390. * `subscribe()` they get added here. Although Redux offers
  2391. * its own `subscribe()` function directly, by wrapping the
  2392. * subscription in this store instance it's possible to
  2393. * optimize checking if the state has changed before calling
  2394. * each listener.
  2395. *
  2396. * @type {Set<ListenerFunction>}
  2397. */
  2398. const listeners = new Set();
  2399. const reducer = options.reducer;
  2400. const thunkArgs = {
  2401. registry,
  2402. get dispatch() {
  2403. return thunkActions;
  2404. },
  2405. get select() {
  2406. return thunkSelectors;
  2407. },
  2408. get resolveSelect() {
  2409. return getResolveSelectors();
  2410. }
  2411. };
  2412. const store = instantiateReduxStore(key, options, registry, thunkArgs);
  2413. // Expose the private registration functions on the store
  2414. // so they can be copied to a sub registry in registry.js.
  2415. lock(store, privateRegistrationFunctions);
  2416. const resolversCache = createResolversCache();
  2417. function bindAction(action) {
  2418. return (...args) => Promise.resolve(store.dispatch(action(...args)));
  2419. }
  2420. const actions = {
  2421. ...mapValues(actions_namespaceObject, bindAction),
  2422. ...mapValues(options.actions, bindAction)
  2423. };
  2424. const boundPrivateActions = createBindingCache(bindAction);
  2425. const allActions = new Proxy(() => {}, {
  2426. get: (target, prop) => {
  2427. const privateAction = privateActions[prop];
  2428. return privateAction ? boundPrivateActions.get(privateAction, prop) : actions[prop];
  2429. }
  2430. });
  2431. const thunkActions = new Proxy(allActions, {
  2432. apply: (target, thisArg, [action]) => store.dispatch(action)
  2433. });
  2434. lock(actions, allActions);
  2435. const resolvers = options.resolvers ? mapResolvers(options.resolvers) : {};
  2436. function bindSelector(selector, selectorName) {
  2437. if (selector.isRegistrySelector) {
  2438. selector.registry = registry;
  2439. }
  2440. const boundSelector = (...args) => {
  2441. const state = store.__unstableOriginalGetState();
  2442. return selector(state.root, ...args);
  2443. };
  2444. const resolver = resolvers[selectorName];
  2445. if (!resolver) {
  2446. boundSelector.hasResolver = false;
  2447. return boundSelector;
  2448. }
  2449. return mapSelectorWithResolver(boundSelector, selectorName, resolver, store, resolversCache);
  2450. }
  2451. function bindMetadataSelector(selector) {
  2452. const boundSelector = (...args) => {
  2453. const state = store.__unstableOriginalGetState();
  2454. return selector(state.metadata, ...args);
  2455. };
  2456. boundSelector.hasResolver = false;
  2457. return boundSelector;
  2458. }
  2459. const selectors = {
  2460. ...mapValues(selectors_namespaceObject, bindMetadataSelector),
  2461. ...mapValues(options.selectors, bindSelector)
  2462. };
  2463. const boundPrivateSelectors = createBindingCache(bindSelector);
  2464. // Pre-bind the private selectors that have been registered by the time of
  2465. // instantiation, so that registry selectors are bound to the registry.
  2466. for (const [selectorName, selector] of Object.entries(privateSelectors)) {
  2467. boundPrivateSelectors.get(selector, selectorName);
  2468. }
  2469. const allSelectors = new Proxy(() => {}, {
  2470. get: (target, prop) => {
  2471. const privateSelector = privateSelectors[prop];
  2472. return privateSelector ? boundPrivateSelectors.get(privateSelector, prop) : selectors[prop];
  2473. }
  2474. });
  2475. const thunkSelectors = new Proxy(allSelectors, {
  2476. apply: (target, thisArg, [selector]) => selector(store.__unstableOriginalGetState())
  2477. });
  2478. lock(selectors, allSelectors);
  2479. const resolveSelectors = mapResolveSelectors(selectors, store);
  2480. const suspendSelectors = mapSuspendSelectors(selectors, store);
  2481. const getSelectors = () => selectors;
  2482. const getActions = () => actions;
  2483. const getResolveSelectors = () => resolveSelectors;
  2484. const getSuspendSelectors = () => suspendSelectors;
  2485. // We have some modules monkey-patching the store object
  2486. // It's wrong to do so but until we refactor all of our effects to controls
  2487. // We need to keep the same "store" instance here.
  2488. store.__unstableOriginalGetState = store.getState;
  2489. store.getState = () => store.__unstableOriginalGetState().root;
  2490. // Customize subscribe behavior to call listeners only on effective change,
  2491. // not on every dispatch.
  2492. const subscribe = store && (listener => {
  2493. listeners.add(listener);
  2494. return () => listeners.delete(listener);
  2495. });
  2496. let lastState = store.__unstableOriginalGetState();
  2497. store.subscribe(() => {
  2498. const state = store.__unstableOriginalGetState();
  2499. const hasChanged = state !== lastState;
  2500. lastState = state;
  2501. if (hasChanged) {
  2502. for (const listener of listeners) {
  2503. listener();
  2504. }
  2505. }
  2506. });
  2507. // This can be simplified to just { subscribe, getSelectors, getActions }
  2508. // Once we remove the use function.
  2509. return {
  2510. reducer,
  2511. store,
  2512. actions,
  2513. selectors,
  2514. resolvers,
  2515. getSelectors,
  2516. getResolveSelectors,
  2517. getSuspendSelectors,
  2518. getActions,
  2519. subscribe
  2520. };
  2521. }
  2522. };
  2523. // Expose the private registration functions on the store
  2524. // descriptor. That's a natural choice since that's where the
  2525. // public actions and selectors are stored .
  2526. lock(storeDescriptor, privateRegistrationFunctions);
  2527. return storeDescriptor;
  2528. }
  2529. /**
  2530. * Creates a redux store for a namespace.
  2531. *
  2532. * @param {string} key Unique namespace identifier.
  2533. * @param {Object} options Registered store options, with properties
  2534. * describing reducer, actions, selectors,
  2535. * and resolvers.
  2536. * @param {DataRegistry} registry Registry reference.
  2537. * @param {Object} thunkArgs Argument object for the thunk middleware.
  2538. * @return {Object} Newly created redux store.
  2539. */
  2540. function instantiateReduxStore(key, options, registry, thunkArgs) {
  2541. const controls = {
  2542. ...options.controls,
  2543. ...builtinControls
  2544. };
  2545. const normalizedControls = mapValues(controls, control => control.isRegistryControl ? control(registry) : control);
  2546. const middlewares = [resolvers_cache_middleware(registry, key), promise_middleware, external_wp_reduxRoutine_default()(normalizedControls), createThunkMiddleware(thunkArgs)];
  2547. const enhancers = [applyMiddleware(...middlewares)];
  2548. if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
  2549. enhancers.push(window.__REDUX_DEVTOOLS_EXTENSION__({
  2550. name: key,
  2551. instanceId: key,
  2552. serialize: {
  2553. replacer: mapToObject
  2554. }
  2555. }));
  2556. }
  2557. const {
  2558. reducer,
  2559. initialState
  2560. } = options;
  2561. const enhancedReducer = turbo_combine_reducers_default()({
  2562. metadata: metadata_reducer,
  2563. root: reducer
  2564. });
  2565. return createStore(enhancedReducer, {
  2566. root: initialState
  2567. }, (0,external_wp_compose_namespaceObject.compose)(enhancers));
  2568. }
  2569. /**
  2570. * Maps selectors to functions that return a resolution promise for them
  2571. *
  2572. * @param {Object} selectors Selectors to map.
  2573. * @param {Object} store The redux store the selectors select from.
  2574. *
  2575. * @return {Object} Selectors mapped to their resolution functions.
  2576. */
  2577. function mapResolveSelectors(selectors, store) {
  2578. const {
  2579. getIsResolving,
  2580. hasStartedResolution,
  2581. hasFinishedResolution,
  2582. hasResolutionFailed,
  2583. isResolving,
  2584. getCachedResolvers,
  2585. getResolutionState,
  2586. getResolutionError,
  2587. hasResolvingSelectors,
  2588. countSelectorsByStatus,
  2589. ...storeSelectors
  2590. } = selectors;
  2591. return mapValues(storeSelectors, (selector, selectorName) => {
  2592. // If the selector doesn't have a resolver, just convert the return value
  2593. // (including exceptions) to a Promise, no additional extra behavior is needed.
  2594. if (!selector.hasResolver) {
  2595. return async (...args) => selector.apply(null, args);
  2596. }
  2597. return (...args) => {
  2598. return new Promise((resolve, reject) => {
  2599. const hasFinished = () => selectors.hasFinishedResolution(selectorName, args);
  2600. const finalize = result => {
  2601. const hasFailed = selectors.hasResolutionFailed(selectorName, args);
  2602. if (hasFailed) {
  2603. const error = selectors.getResolutionError(selectorName, args);
  2604. reject(error);
  2605. } else {
  2606. resolve(result);
  2607. }
  2608. };
  2609. const getResult = () => selector.apply(null, args);
  2610. // Trigger the selector (to trigger the resolver)
  2611. const result = getResult();
  2612. if (hasFinished()) {
  2613. return finalize(result);
  2614. }
  2615. const unsubscribe = store.subscribe(() => {
  2616. if (hasFinished()) {
  2617. unsubscribe();
  2618. finalize(getResult());
  2619. }
  2620. });
  2621. });
  2622. };
  2623. });
  2624. }
  2625. /**
  2626. * Maps selectors to functions that throw a suspense promise if not yet resolved.
  2627. *
  2628. * @param {Object} selectors Selectors to map.
  2629. * @param {Object} store The redux store the selectors select from.
  2630. *
  2631. * @return {Object} Selectors mapped to their suspense functions.
  2632. */
  2633. function mapSuspendSelectors(selectors, store) {
  2634. return mapValues(selectors, (selector, selectorName) => {
  2635. // Selector without a resolver doesn't have any extra suspense behavior.
  2636. if (!selector.hasResolver) {
  2637. return selector;
  2638. }
  2639. return (...args) => {
  2640. const result = selector.apply(null, args);
  2641. if (selectors.hasFinishedResolution(selectorName, args)) {
  2642. if (selectors.hasResolutionFailed(selectorName, args)) {
  2643. throw selectors.getResolutionError(selectorName, args);
  2644. }
  2645. return result;
  2646. }
  2647. throw new Promise(resolve => {
  2648. const unsubscribe = store.subscribe(() => {
  2649. if (selectors.hasFinishedResolution(selectorName, args)) {
  2650. resolve();
  2651. unsubscribe();
  2652. }
  2653. });
  2654. });
  2655. };
  2656. });
  2657. }
  2658. /**
  2659. * Convert resolvers to a normalized form, an object with `fulfill` method and
  2660. * optional methods like `isFulfilled`.
  2661. *
  2662. * @param {Object} resolvers Resolver to convert
  2663. */
  2664. function mapResolvers(resolvers) {
  2665. return mapValues(resolvers, resolver => {
  2666. if (resolver.fulfill) {
  2667. return resolver;
  2668. }
  2669. return {
  2670. ...resolver,
  2671. // Copy the enumerable properties of the resolver function.
  2672. fulfill: resolver // Add the fulfill method.
  2673. };
  2674. });
  2675. }
  2676. /**
  2677. * Returns a selector with a matched resolver.
  2678. * Resolvers are side effects invoked once per argument set of a given selector call,
  2679. * used in ensuring that the data needs for the selector are satisfied.
  2680. *
  2681. * @param {Object} selector The selector function to be bound.
  2682. * @param {string} selectorName The selector name.
  2683. * @param {Object} resolver Resolver to call.
  2684. * @param {Object} store The redux store to which the resolvers should be mapped.
  2685. * @param {Object} resolversCache Resolvers Cache.
  2686. */
  2687. function mapSelectorWithResolver(selector, selectorName, resolver, store, resolversCache) {
  2688. function fulfillSelector(args) {
  2689. const state = store.getState();
  2690. if (resolversCache.isRunning(selectorName, args) || typeof resolver.isFulfilled === 'function' && resolver.isFulfilled(state, ...args)) {
  2691. return;
  2692. }
  2693. const {
  2694. metadata
  2695. } = store.__unstableOriginalGetState();
  2696. if (hasStartedResolution(metadata, selectorName, args)) {
  2697. return;
  2698. }
  2699. resolversCache.markAsRunning(selectorName, args);
  2700. setTimeout(async () => {
  2701. resolversCache.clear(selectorName, args);
  2702. store.dispatch(startResolution(selectorName, args));
  2703. try {
  2704. const action = resolver.fulfill(...args);
  2705. if (action) {
  2706. await store.dispatch(action);
  2707. }
  2708. store.dispatch(finishResolution(selectorName, args));
  2709. } catch (error) {
  2710. store.dispatch(failResolution(selectorName, args, error));
  2711. }
  2712. }, 0);
  2713. }
  2714. const selectorResolver = (...args) => {
  2715. fulfillSelector(args);
  2716. return selector(...args);
  2717. };
  2718. selectorResolver.hasResolver = true;
  2719. return selectorResolver;
  2720. }
  2721. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/utils/emitter.js
  2722. /**
  2723. * Create an event emitter.
  2724. *
  2725. * @return {import("../types").DataEmitter} Emitter.
  2726. */
  2727. function createEmitter() {
  2728. let isPaused = false;
  2729. let isPending = false;
  2730. const listeners = new Set();
  2731. const notifyListeners = () =>
  2732. // We use Array.from to clone the listeners Set
  2733. // This ensures that we don't run a listener
  2734. // that was added as a response to another listener.
  2735. Array.from(listeners).forEach(listener => listener());
  2736. return {
  2737. get isPaused() {
  2738. return isPaused;
  2739. },
  2740. subscribe(listener) {
  2741. listeners.add(listener);
  2742. return () => listeners.delete(listener);
  2743. },
  2744. pause() {
  2745. isPaused = true;
  2746. },
  2747. resume() {
  2748. isPaused = false;
  2749. if (isPending) {
  2750. isPending = false;
  2751. notifyListeners();
  2752. }
  2753. },
  2754. emit() {
  2755. if (isPaused) {
  2756. isPending = true;
  2757. return;
  2758. }
  2759. notifyListeners();
  2760. }
  2761. };
  2762. }
  2763. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/registry.js
  2764. /**
  2765. * WordPress dependencies
  2766. */
  2767. /**
  2768. * Internal dependencies
  2769. */
  2770. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  2771. /**
  2772. * @typedef {Object} WPDataRegistry An isolated orchestrator of store registrations.
  2773. *
  2774. * @property {Function} registerGenericStore Given a namespace key and settings
  2775. * object, registers a new generic
  2776. * store.
  2777. * @property {Function} registerStore Given a namespace key and settings
  2778. * object, registers a new namespace
  2779. * store.
  2780. * @property {Function} subscribe Given a function callback, invokes
  2781. * the callback on any change to state
  2782. * within any registered store.
  2783. * @property {Function} select Given a namespace key, returns an
  2784. * object of the store's registered
  2785. * selectors.
  2786. * @property {Function} dispatch Given a namespace key, returns an
  2787. * object of the store's registered
  2788. * action dispatchers.
  2789. */
  2790. /**
  2791. * @typedef {Object} WPDataPlugin An object of registry function overrides.
  2792. *
  2793. * @property {Function} registerStore registers store.
  2794. */
  2795. function getStoreName(storeNameOrDescriptor) {
  2796. return typeof storeNameOrDescriptor === 'string' ? storeNameOrDescriptor : storeNameOrDescriptor.name;
  2797. }
  2798. /**
  2799. * Creates a new store registry, given an optional object of initial store
  2800. * configurations.
  2801. *
  2802. * @param {Object} storeConfigs Initial store configurations.
  2803. * @param {Object?} parent Parent registry.
  2804. *
  2805. * @return {WPDataRegistry} Data registry.
  2806. */
  2807. function createRegistry(storeConfigs = {}, parent = null) {
  2808. const stores = {};
  2809. const emitter = createEmitter();
  2810. let listeningStores = null;
  2811. /**
  2812. * Global listener called for each store's update.
  2813. */
  2814. function globalListener() {
  2815. emitter.emit();
  2816. }
  2817. /**
  2818. * Subscribe to changes to any data, either in all stores in registry, or
  2819. * in one specific store.
  2820. *
  2821. * @param {Function} listener Listener function.
  2822. * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.
  2823. *
  2824. * @return {Function} Unsubscribe function.
  2825. */
  2826. const subscribe = (listener, storeNameOrDescriptor) => {
  2827. // subscribe to all stores
  2828. if (!storeNameOrDescriptor) {
  2829. return emitter.subscribe(listener);
  2830. }
  2831. // subscribe to one store
  2832. const storeName = getStoreName(storeNameOrDescriptor);
  2833. const store = stores[storeName];
  2834. if (store) {
  2835. return store.subscribe(listener);
  2836. }
  2837. // Trying to access a store that hasn't been registered,
  2838. // this is a pattern rarely used but seen in some places.
  2839. // We fallback to global `subscribe` here for backward-compatibility for now.
  2840. // See https://github.com/WordPress/gutenberg/pull/27466 for more info.
  2841. if (!parent) {
  2842. return emitter.subscribe(listener);
  2843. }
  2844. return parent.subscribe(listener, storeNameOrDescriptor);
  2845. };
  2846. /**
  2847. * Calls a selector given the current state and extra arguments.
  2848. *
  2849. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  2850. * or the store descriptor.
  2851. *
  2852. * @return {*} The selector's returned value.
  2853. */
  2854. function select(storeNameOrDescriptor) {
  2855. const storeName = getStoreName(storeNameOrDescriptor);
  2856. listeningStores?.add(storeName);
  2857. const store = stores[storeName];
  2858. if (store) {
  2859. return store.getSelectors();
  2860. }
  2861. return parent?.select(storeName);
  2862. }
  2863. function __unstableMarkListeningStores(callback, ref) {
  2864. listeningStores = new Set();
  2865. try {
  2866. return callback.call(this);
  2867. } finally {
  2868. ref.current = Array.from(listeningStores);
  2869. listeningStores = null;
  2870. }
  2871. }
  2872. /**
  2873. * Given a store descriptor, returns an object containing the store's selectors pre-bound to
  2874. * state so that you only need to supply additional arguments, and modified so that they return
  2875. * promises that resolve to their eventual values, after any resolvers have ran.
  2876. *
  2877. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  2878. * convention of passing the store name is
  2879. * also supported.
  2880. *
  2881. * @return {Object} Each key of the object matches the name of a selector.
  2882. */
  2883. function resolveSelect(storeNameOrDescriptor) {
  2884. const storeName = getStoreName(storeNameOrDescriptor);
  2885. listeningStores?.add(storeName);
  2886. const store = stores[storeName];
  2887. if (store) {
  2888. return store.getResolveSelectors();
  2889. }
  2890. return parent && parent.resolveSelect(storeName);
  2891. }
  2892. /**
  2893. * Given a store descriptor, returns an object containing the store's selectors pre-bound to
  2894. * state so that you only need to supply additional arguments, and modified so that they throw
  2895. * promises in case the selector is not resolved yet.
  2896. *
  2897. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  2898. * convention of passing the store name is
  2899. * also supported.
  2900. *
  2901. * @return {Object} Object containing the store's suspense-wrapped selectors.
  2902. */
  2903. function suspendSelect(storeNameOrDescriptor) {
  2904. const storeName = getStoreName(storeNameOrDescriptor);
  2905. listeningStores?.add(storeName);
  2906. const store = stores[storeName];
  2907. if (store) {
  2908. return store.getSuspendSelectors();
  2909. }
  2910. return parent && parent.suspendSelect(storeName);
  2911. }
  2912. /**
  2913. * Returns the available actions for a part of the state.
  2914. *
  2915. * @param {string|StoreDescriptor} storeNameOrDescriptor Unique namespace identifier for the store
  2916. * or the store descriptor.
  2917. *
  2918. * @return {*} The action's returned value.
  2919. */
  2920. function dispatch(storeNameOrDescriptor) {
  2921. const storeName = getStoreName(storeNameOrDescriptor);
  2922. const store = stores[storeName];
  2923. if (store) {
  2924. return store.getActions();
  2925. }
  2926. return parent && parent.dispatch(storeName);
  2927. }
  2928. //
  2929. // Deprecated
  2930. // TODO: Remove this after `use()` is removed.
  2931. function withPlugins(attributes) {
  2932. return Object.fromEntries(Object.entries(attributes).map(([key, attribute]) => {
  2933. if (typeof attribute !== 'function') {
  2934. return [key, attribute];
  2935. }
  2936. return [key, function () {
  2937. return registry[key].apply(null, arguments);
  2938. }];
  2939. }));
  2940. }
  2941. /**
  2942. * Registers a store instance.
  2943. *
  2944. * @param {string} name Store registry name.
  2945. * @param {Function} createStore Function that creates a store object (getSelectors, getActions, subscribe).
  2946. */
  2947. function registerStoreInstance(name, createStore) {
  2948. if (stores[name]) {
  2949. // eslint-disable-next-line no-console
  2950. console.error('Store "' + name + '" is already registered.');
  2951. return stores[name];
  2952. }
  2953. const store = createStore();
  2954. if (typeof store.getSelectors !== 'function') {
  2955. throw new TypeError('store.getSelectors must be a function');
  2956. }
  2957. if (typeof store.getActions !== 'function') {
  2958. throw new TypeError('store.getActions must be a function');
  2959. }
  2960. if (typeof store.subscribe !== 'function') {
  2961. throw new TypeError('store.subscribe must be a function');
  2962. }
  2963. // The emitter is used to keep track of active listeners when the registry
  2964. // get paused, that way, when resumed we should be able to call all these
  2965. // pending listeners.
  2966. store.emitter = createEmitter();
  2967. const currentSubscribe = store.subscribe;
  2968. store.subscribe = listener => {
  2969. const unsubscribeFromEmitter = store.emitter.subscribe(listener);
  2970. const unsubscribeFromStore = currentSubscribe(() => {
  2971. if (store.emitter.isPaused) {
  2972. store.emitter.emit();
  2973. return;
  2974. }
  2975. listener();
  2976. });
  2977. return () => {
  2978. unsubscribeFromStore?.();
  2979. unsubscribeFromEmitter?.();
  2980. };
  2981. };
  2982. stores[name] = store;
  2983. store.subscribe(globalListener);
  2984. // Copy private actions and selectors from the parent store.
  2985. if (parent) {
  2986. try {
  2987. unlock(store.store).registerPrivateActions(unlock(parent).privateActionsOf(name));
  2988. unlock(store.store).registerPrivateSelectors(unlock(parent).privateSelectorsOf(name));
  2989. } catch (e) {
  2990. // unlock() throws if store.store was not locked.
  2991. // The error indicates there's nothing to do here so let's
  2992. // ignore it.
  2993. }
  2994. }
  2995. return store;
  2996. }
  2997. /**
  2998. * Registers a new store given a store descriptor.
  2999. *
  3000. * @param {StoreDescriptor} store Store descriptor.
  3001. */
  3002. function register(store) {
  3003. registerStoreInstance(store.name, () => store.instantiate(registry));
  3004. }
  3005. function registerGenericStore(name, store) {
  3006. external_wp_deprecated_default()('wp.data.registerGenericStore', {
  3007. since: '5.9',
  3008. alternative: 'wp.data.register( storeDescriptor )'
  3009. });
  3010. registerStoreInstance(name, () => store);
  3011. }
  3012. /**
  3013. * Registers a standard `@wordpress/data` store.
  3014. *
  3015. * @param {string} storeName Unique namespace identifier.
  3016. * @param {Object} options Store description (reducer, actions, selectors, resolvers).
  3017. *
  3018. * @return {Object} Registered store object.
  3019. */
  3020. function registerStore(storeName, options) {
  3021. if (!options.reducer) {
  3022. throw new TypeError('Must specify store reducer');
  3023. }
  3024. const store = registerStoreInstance(storeName, () => createReduxStore(storeName, options).instantiate(registry));
  3025. return store.store;
  3026. }
  3027. function batch(callback) {
  3028. // If we're already batching, just call the callback.
  3029. if (emitter.isPaused) {
  3030. callback();
  3031. return;
  3032. }
  3033. emitter.pause();
  3034. Object.values(stores).forEach(store => store.emitter.pause());
  3035. callback();
  3036. emitter.resume();
  3037. Object.values(stores).forEach(store => store.emitter.resume());
  3038. }
  3039. let registry = {
  3040. batch,
  3041. stores,
  3042. namespaces: stores,
  3043. // TODO: Deprecate/remove this.
  3044. subscribe,
  3045. select,
  3046. resolveSelect,
  3047. suspendSelect,
  3048. dispatch,
  3049. use,
  3050. register,
  3051. registerGenericStore,
  3052. registerStore,
  3053. __unstableMarkListeningStores
  3054. };
  3055. //
  3056. // TODO:
  3057. // This function will be deprecated as soon as it is no longer internally referenced.
  3058. function use(plugin, options) {
  3059. if (!plugin) {
  3060. return;
  3061. }
  3062. registry = {
  3063. ...registry,
  3064. ...plugin(registry, options)
  3065. };
  3066. return registry;
  3067. }
  3068. registry.register(store);
  3069. for (const [name, config] of Object.entries(storeConfigs)) {
  3070. registry.register(createReduxStore(name, config));
  3071. }
  3072. if (parent) {
  3073. parent.subscribe(globalListener);
  3074. }
  3075. const registryWithPlugins = withPlugins(registry);
  3076. lock(registryWithPlugins, {
  3077. privateActionsOf: name => {
  3078. try {
  3079. return unlock(stores[name].store).privateActions;
  3080. } catch (e) {
  3081. // unlock() throws an error the store was not locked – this means
  3082. // there no private actions are available
  3083. return {};
  3084. }
  3085. },
  3086. privateSelectorsOf: name => {
  3087. try {
  3088. return unlock(stores[name].store).privateSelectors;
  3089. } catch (e) {
  3090. return {};
  3091. }
  3092. }
  3093. });
  3094. return registryWithPlugins;
  3095. }
  3096. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/default-registry.js
  3097. /**
  3098. * Internal dependencies
  3099. */
  3100. /* harmony default export */ var default_registry = (createRegistry());
  3101. ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
  3102. /*!
  3103. * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
  3104. *
  3105. * Copyright (c) 2014-2017, Jon Schlinkert.
  3106. * Released under the MIT License.
  3107. */
  3108. function is_plain_object_isObject(o) {
  3109. return Object.prototype.toString.call(o) === '[object Object]';
  3110. }
  3111. function is_plain_object_isPlainObject(o) {
  3112. var ctor,prot;
  3113. if (is_plain_object_isObject(o) === false) return false;
  3114. // If has modified constructor
  3115. ctor = o.constructor;
  3116. if (ctor === undefined) return true;
  3117. // If has modified prototype
  3118. prot = ctor.prototype;
  3119. if (is_plain_object_isObject(prot) === false) return false;
  3120. // If constructor does not have an Object-specific method
  3121. if (prot.hasOwnProperty('isPrototypeOf') === false) {
  3122. return false;
  3123. }
  3124. // Most likely a plain Object
  3125. return true;
  3126. }
  3127. // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js
  3128. var cjs = __webpack_require__(1919);
  3129. var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
  3130. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/object.js
  3131. let objectStorage;
  3132. const storage = {
  3133. getItem(key) {
  3134. if (!objectStorage || !objectStorage[key]) {
  3135. return null;
  3136. }
  3137. return objectStorage[key];
  3138. },
  3139. setItem(key, value) {
  3140. if (!objectStorage) {
  3141. storage.clear();
  3142. }
  3143. objectStorage[key] = String(value);
  3144. },
  3145. clear() {
  3146. objectStorage = Object.create(null);
  3147. }
  3148. };
  3149. /* harmony default export */ var object = (storage);
  3150. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/storage/default.js
  3151. /**
  3152. * Internal dependencies
  3153. */
  3154. let default_storage;
  3155. try {
  3156. // Private Browsing in Safari 10 and earlier will throw an error when
  3157. // attempting to set into localStorage. The test here is intentional in
  3158. // causing a thrown error as condition for using fallback object storage.
  3159. default_storage = window.localStorage;
  3160. default_storage.setItem('__wpDataTestLocalStorage', '');
  3161. default_storage.removeItem('__wpDataTestLocalStorage');
  3162. } catch (error) {
  3163. default_storage = object;
  3164. }
  3165. /* harmony default export */ var storage_default = (default_storage);
  3166. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/persistence/index.js
  3167. /**
  3168. * External dependencies
  3169. */
  3170. /**
  3171. * Internal dependencies
  3172. */
  3173. /** @typedef {import('../../registry').WPDataRegistry} WPDataRegistry */
  3174. /** @typedef {import('../../registry').WPDataPlugin} WPDataPlugin */
  3175. /**
  3176. * @typedef {Object} WPDataPersistencePluginOptions Persistence plugin options.
  3177. *
  3178. * @property {Storage} storage Persistent storage implementation. This must
  3179. * at least implement `getItem` and `setItem` of
  3180. * the Web Storage API.
  3181. * @property {string} storageKey Key on which to set in persistent storage.
  3182. */
  3183. /**
  3184. * Default plugin storage.
  3185. *
  3186. * @type {Storage}
  3187. */
  3188. const DEFAULT_STORAGE = storage_default;
  3189. /**
  3190. * Default plugin storage key.
  3191. *
  3192. * @type {string}
  3193. */
  3194. const DEFAULT_STORAGE_KEY = 'WP_DATA';
  3195. /**
  3196. * Higher-order reducer which invokes the original reducer only if state is
  3197. * inequal from that of the action's `nextState` property, otherwise returning
  3198. * the original state reference.
  3199. *
  3200. * @param {Function} reducer Original reducer.
  3201. *
  3202. * @return {Function} Enhanced reducer.
  3203. */
  3204. const withLazySameState = reducer => (state, action) => {
  3205. if (action.nextState === state) {
  3206. return state;
  3207. }
  3208. return reducer(state, action);
  3209. };
  3210. /**
  3211. * Creates a persistence interface, exposing getter and setter methods (`get`
  3212. * and `set` respectively).
  3213. *
  3214. * @param {WPDataPersistencePluginOptions} options Plugin options.
  3215. *
  3216. * @return {Object} Persistence interface.
  3217. */
  3218. function createPersistenceInterface(options) {
  3219. const {
  3220. storage = DEFAULT_STORAGE,
  3221. storageKey = DEFAULT_STORAGE_KEY
  3222. } = options;
  3223. let data;
  3224. /**
  3225. * Returns the persisted data as an object, defaulting to an empty object.
  3226. *
  3227. * @return {Object} Persisted data.
  3228. */
  3229. function getData() {
  3230. if (data === undefined) {
  3231. // If unset, getItem is expected to return null. Fall back to
  3232. // empty object.
  3233. const persisted = storage.getItem(storageKey);
  3234. if (persisted === null) {
  3235. data = {};
  3236. } else {
  3237. try {
  3238. data = JSON.parse(persisted);
  3239. } catch (error) {
  3240. // Similarly, should any error be thrown during parse of
  3241. // the string (malformed JSON), fall back to empty object.
  3242. data = {};
  3243. }
  3244. }
  3245. }
  3246. return data;
  3247. }
  3248. /**
  3249. * Merges an updated reducer state into the persisted data.
  3250. *
  3251. * @param {string} key Key to update.
  3252. * @param {*} value Updated value.
  3253. */
  3254. function setData(key, value) {
  3255. data = {
  3256. ...data,
  3257. [key]: value
  3258. };
  3259. storage.setItem(storageKey, JSON.stringify(data));
  3260. }
  3261. return {
  3262. get: getData,
  3263. set: setData
  3264. };
  3265. }
  3266. /**
  3267. * Data plugin to persist store state into a single storage key.
  3268. *
  3269. * @param {WPDataRegistry} registry Data registry.
  3270. * @param {?WPDataPersistencePluginOptions} pluginOptions Plugin options.
  3271. *
  3272. * @return {WPDataPlugin} Data plugin.
  3273. */
  3274. function persistencePlugin(registry, pluginOptions) {
  3275. const persistence = createPersistenceInterface(pluginOptions);
  3276. /**
  3277. * Creates an enhanced store dispatch function, triggering the state of the
  3278. * given store name to be persisted when changed.
  3279. *
  3280. * @param {Function} getState Function which returns current state.
  3281. * @param {string} storeName Store name.
  3282. * @param {?Array<string>} keys Optional subset of keys to save.
  3283. *
  3284. * @return {Function} Enhanced dispatch function.
  3285. */
  3286. function createPersistOnChange(getState, storeName, keys) {
  3287. let getPersistedState;
  3288. if (Array.isArray(keys)) {
  3289. // Given keys, the persisted state should by produced as an object
  3290. // of the subset of keys. This implementation uses combineReducers
  3291. // to leverage its behavior of returning the same object when none
  3292. // of the property values changes. This allows a strict reference
  3293. // equality to bypass a persistence set on an unchanging state.
  3294. const reducers = keys.reduce((accumulator, key) => Object.assign(accumulator, {
  3295. [key]: (state, action) => action.nextState[key]
  3296. }), {});
  3297. getPersistedState = withLazySameState(build_module_combineReducers(reducers));
  3298. } else {
  3299. getPersistedState = (state, action) => action.nextState;
  3300. }
  3301. let lastState = getPersistedState(undefined, {
  3302. nextState: getState()
  3303. });
  3304. return () => {
  3305. const state = getPersistedState(lastState, {
  3306. nextState: getState()
  3307. });
  3308. if (state !== lastState) {
  3309. persistence.set(storeName, state);
  3310. lastState = state;
  3311. }
  3312. };
  3313. }
  3314. return {
  3315. registerStore(storeName, options) {
  3316. if (!options.persist) {
  3317. return registry.registerStore(storeName, options);
  3318. }
  3319. // Load from persistence to use as initial state.
  3320. const persistedState = persistence.get()[storeName];
  3321. if (persistedState !== undefined) {
  3322. let initialState = options.reducer(options.initialState, {
  3323. type: '@@WP/PERSISTENCE_RESTORE'
  3324. });
  3325. if (is_plain_object_isPlainObject(initialState) && is_plain_object_isPlainObject(persistedState)) {
  3326. // If state is an object, ensure that:
  3327. // - Other keys are left intact when persisting only a
  3328. // subset of keys.
  3329. // - New keys in what would otherwise be used as initial
  3330. // state are deeply merged as base for persisted value.
  3331. initialState = cjs_default()(initialState, persistedState, {
  3332. isMergeableObject: is_plain_object_isPlainObject
  3333. });
  3334. } else {
  3335. // If there is a mismatch in object-likeness of default
  3336. // initial or persisted state, defer to persisted value.
  3337. initialState = persistedState;
  3338. }
  3339. options = {
  3340. ...options,
  3341. initialState
  3342. };
  3343. }
  3344. const store = registry.registerStore(storeName, options);
  3345. store.subscribe(createPersistOnChange(store.getState, storeName, options.persist));
  3346. return store;
  3347. }
  3348. };
  3349. }
  3350. persistencePlugin.__unstableMigrate = () => {};
  3351. /* harmony default export */ var persistence = (persistencePlugin);
  3352. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/plugins/index.js
  3353. ;// CONCATENATED MODULE: external ["wp","element"]
  3354. var external_wp_element_namespaceObject = window["wp"]["element"];
  3355. ;// CONCATENATED MODULE: external ["wp","priorityQueue"]
  3356. var external_wp_priorityQueue_namespaceObject = window["wp"]["priorityQueue"];
  3357. ;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
  3358. var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
  3359. var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
  3360. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/context.js
  3361. /**
  3362. * WordPress dependencies
  3363. */
  3364. /**
  3365. * Internal dependencies
  3366. */
  3367. const Context = (0,external_wp_element_namespaceObject.createContext)(default_registry);
  3368. const {
  3369. Consumer,
  3370. Provider
  3371. } = Context;
  3372. /**
  3373. * A custom react Context consumer exposing the provided `registry` to
  3374. * children components. Used along with the RegistryProvider.
  3375. *
  3376. * You can read more about the react context api here:
  3377. * https://reactjs.org/docs/context.html#contextprovider
  3378. *
  3379. * @example
  3380. * ```js
  3381. * import {
  3382. * RegistryProvider,
  3383. * RegistryConsumer,
  3384. * createRegistry
  3385. * } from '@wordpress/data';
  3386. *
  3387. * const registry = createRegistry( {} );
  3388. *
  3389. * const App = ( { props } ) => {
  3390. * return <RegistryProvider value={ registry }>
  3391. * <div>Hello There</div>
  3392. * <RegistryConsumer>
  3393. * { ( registry ) => (
  3394. * <ComponentUsingRegistry
  3395. * { ...props }
  3396. * registry={ registry }
  3397. * ) }
  3398. * </RegistryConsumer>
  3399. * </RegistryProvider>
  3400. * }
  3401. * ```
  3402. */
  3403. const RegistryConsumer = Consumer;
  3404. /**
  3405. * A custom Context provider for exposing the provided `registry` to children
  3406. * components via a consumer.
  3407. *
  3408. * See <a name="#RegistryConsumer">RegistryConsumer</a> documentation for
  3409. * example.
  3410. */
  3411. /* harmony default export */ var context = (Provider);
  3412. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/registry-provider/use-registry.js
  3413. /**
  3414. * WordPress dependencies
  3415. */
  3416. /**
  3417. * Internal dependencies
  3418. */
  3419. /**
  3420. * A custom react hook exposing the registry context for use.
  3421. *
  3422. * This exposes the `registry` value provided via the
  3423. * <a href="#RegistryProvider">Registry Provider</a> to a component implementing
  3424. * this hook.
  3425. *
  3426. * It acts similarly to the `useContext` react hook.
  3427. *
  3428. * Note: Generally speaking, `useRegistry` is a low level hook that in most cases
  3429. * won't be needed for implementation. Most interactions with the `@wordpress/data`
  3430. * API can be performed via the `useSelect` hook, or the `withSelect` and
  3431. * `withDispatch` higher order components.
  3432. *
  3433. * @example
  3434. * ```js
  3435. * import {
  3436. * RegistryProvider,
  3437. * createRegistry,
  3438. * useRegistry,
  3439. * } from '@wordpress/data';
  3440. *
  3441. * const registry = createRegistry( {} );
  3442. *
  3443. * const SomeChildUsingRegistry = ( props ) => {
  3444. * const registry = useRegistry();
  3445. * // ...logic implementing the registry in other react hooks.
  3446. * };
  3447. *
  3448. *
  3449. * const ParentProvidingRegistry = ( props ) => {
  3450. * return <RegistryProvider value={ registry }>
  3451. * <SomeChildUsingRegistry { ...props } />
  3452. * </RegistryProvider>
  3453. * };
  3454. * ```
  3455. *
  3456. * @return {Function} A custom react hook exposing the registry context value.
  3457. */
  3458. function useRegistry() {
  3459. return (0,external_wp_element_namespaceObject.useContext)(Context);
  3460. }
  3461. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/context.js
  3462. /**
  3463. * WordPress dependencies
  3464. */
  3465. const context_Context = (0,external_wp_element_namespaceObject.createContext)(false);
  3466. const {
  3467. Consumer: context_Consumer,
  3468. Provider: context_Provider
  3469. } = context_Context;
  3470. const AsyncModeConsumer = (/* unused pure expression or super */ null && (context_Consumer));
  3471. /**
  3472. * Context Provider Component used to switch the data module component rerendering
  3473. * between Sync and Async modes.
  3474. *
  3475. * @example
  3476. *
  3477. * ```js
  3478. * import { useSelect, AsyncModeProvider } from '@wordpress/data';
  3479. * import { store as blockEditorStore } from '@wordpress/block-editor';
  3480. *
  3481. * function BlockCount() {
  3482. * const count = useSelect( ( select ) => {
  3483. * return select( blockEditorStore ).getBlockCount()
  3484. * }, [] );
  3485. *
  3486. * return count;
  3487. * }
  3488. *
  3489. * function App() {
  3490. * return (
  3491. * <AsyncModeProvider value={ true }>
  3492. * <BlockCount />
  3493. * </AsyncModeProvider>
  3494. * );
  3495. * }
  3496. * ```
  3497. *
  3498. * In this example, the BlockCount component is rerendered asynchronously.
  3499. * It means if a more critical task is being performed (like typing in an input),
  3500. * the rerendering is delayed until the browser becomes IDLE.
  3501. * It is possible to nest multiple levels of AsyncModeProvider to fine-tune the rendering behavior.
  3502. *
  3503. * @param {boolean} props.value Enable Async Mode.
  3504. * @return {WPComponent} The component to be rendered.
  3505. */
  3506. /* harmony default export */ var async_mode_provider_context = (context_Provider);
  3507. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/async-mode-provider/use-async-mode.js
  3508. /**
  3509. * WordPress dependencies
  3510. */
  3511. /**
  3512. * Internal dependencies
  3513. */
  3514. function useAsyncMode() {
  3515. return (0,external_wp_element_namespaceObject.useContext)(context_Context);
  3516. }
  3517. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-select/index.js
  3518. /**
  3519. * WordPress dependencies
  3520. */
  3521. /**
  3522. * Internal dependencies
  3523. */
  3524. const renderQueue = (0,external_wp_priorityQueue_namespaceObject.createQueue)();
  3525. /**
  3526. * @typedef {import('../../types').StoreDescriptor<C>} StoreDescriptor
  3527. * @template {import('../../types').AnyConfig} C
  3528. */
  3529. /**
  3530. * @typedef {import('../../types').ReduxStoreConfig<State,Actions,Selectors>} ReduxStoreConfig
  3531. * @template State
  3532. * @template {Record<string,import('../../types').ActionCreator>} Actions
  3533. * @template Selectors
  3534. */
  3535. /** @typedef {import('../../types').MapSelect} MapSelect */
  3536. /**
  3537. * @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
  3538. * @template {MapSelect|StoreDescriptor<any>} T
  3539. */
  3540. function Store(registry, suspense) {
  3541. const select = suspense ? registry.suspendSelect : registry.select;
  3542. const queueContext = {};
  3543. let lastMapSelect;
  3544. let lastMapResult;
  3545. let lastMapResultValid = false;
  3546. let lastIsAsync;
  3547. let subscriber;
  3548. let didWarnUnstableReference;
  3549. const createSubscriber = stores => {
  3550. // The set of stores the `subscribe` function is supposed to subscribe to. Here it is
  3551. // initialized, and then the `updateStores` function can add new stores to it.
  3552. const activeStores = [...stores];
  3553. // The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could
  3554. // be called multiple times to establish multiple subscriptions. That's why we need to
  3555. // keep a set of active subscriptions;
  3556. const activeSubscriptions = new Set();
  3557. function subscribe(listener) {
  3558. // Invalidate the value right after subscription was created. React will
  3559. // call `getValue` after subscribing, to detect store updates that happened
  3560. // in the interval between the `getValue` call during render and creating
  3561. // the subscription, which is slightly delayed. We need to ensure that this
  3562. // second `getValue` call will compute a fresh value.
  3563. lastMapResultValid = false;
  3564. const onStoreChange = () => {
  3565. // Invalidate the value on store update, so that a fresh value is computed.
  3566. lastMapResultValid = false;
  3567. listener();
  3568. };
  3569. const onChange = () => {
  3570. if (lastIsAsync) {
  3571. renderQueue.add(queueContext, onStoreChange);
  3572. } else {
  3573. onStoreChange();
  3574. }
  3575. };
  3576. const unsubs = [];
  3577. function subscribeStore(storeName) {
  3578. unsubs.push(registry.subscribe(onChange, storeName));
  3579. }
  3580. for (const storeName of activeStores) {
  3581. subscribeStore(storeName);
  3582. }
  3583. activeSubscriptions.add(subscribeStore);
  3584. return () => {
  3585. activeSubscriptions.delete(subscribeStore);
  3586. for (const unsub of unsubs.values()) {
  3587. // The return value of the subscribe function could be undefined if the store is a custom generic store.
  3588. unsub?.();
  3589. }
  3590. // Cancel existing store updates that were already scheduled.
  3591. renderQueue.cancel(queueContext);
  3592. };
  3593. }
  3594. // Check if `newStores` contains some stores we're not subscribed to yet, and add them.
  3595. function updateStores(newStores) {
  3596. for (const newStore of newStores) {
  3597. if (activeStores.includes(newStore)) {
  3598. continue;
  3599. }
  3600. // New `subscribe` calls will subscribe to `newStore`, too.
  3601. activeStores.push(newStore);
  3602. // Add `newStore` to existing subscriptions.
  3603. for (const subscription of activeSubscriptions) {
  3604. subscription(newStore);
  3605. }
  3606. }
  3607. }
  3608. return {
  3609. subscribe,
  3610. updateStores
  3611. };
  3612. };
  3613. return (mapSelect, isAsync) => {
  3614. function updateValue() {
  3615. // If the last value is valid, and the `mapSelect` callback hasn't changed,
  3616. // then we can safely return the cached value. The value can change only on
  3617. // store update, and in that case value will be invalidated by the listener.
  3618. if (lastMapResultValid && mapSelect === lastMapSelect) {
  3619. return lastMapResult;
  3620. }
  3621. const listeningStores = {
  3622. current: null
  3623. };
  3624. const mapResult = registry.__unstableMarkListeningStores(() => mapSelect(select, registry), listeningStores);
  3625. if (false) {}
  3626. if (!subscriber) {
  3627. subscriber = createSubscriber(listeningStores.current);
  3628. } else {
  3629. subscriber.updateStores(listeningStores.current);
  3630. }
  3631. // If the new value is shallow-equal to the old one, keep the old one so
  3632. // that we don't trigger unwanted updates that do a `===` check.
  3633. if (!external_wp_isShallowEqual_default()(lastMapResult, mapResult)) {
  3634. lastMapResult = mapResult;
  3635. }
  3636. lastMapSelect = mapSelect;
  3637. lastMapResultValid = true;
  3638. }
  3639. function getValue() {
  3640. // Update the value in case it's been invalidated or `mapSelect` has changed.
  3641. updateValue();
  3642. return lastMapResult;
  3643. }
  3644. // When transitioning from async to sync mode, cancel existing store updates
  3645. // that have been scheduled, and invalidate the value so that it's freshly
  3646. // computed. It might have been changed by the update we just cancelled.
  3647. if (lastIsAsync && !isAsync) {
  3648. lastMapResultValid = false;
  3649. renderQueue.cancel(queueContext);
  3650. }
  3651. updateValue();
  3652. lastIsAsync = isAsync;
  3653. // Return a pair of functions that can be passed to `useSyncExternalStore`.
  3654. return {
  3655. subscribe: subscriber.subscribe,
  3656. getValue
  3657. };
  3658. };
  3659. }
  3660. function useStaticSelect(storeName) {
  3661. return useRegistry().select(storeName);
  3662. }
  3663. function useMappingSelect(suspense, mapSelect, deps) {
  3664. const registry = useRegistry();
  3665. const isAsync = useAsyncMode();
  3666. const store = (0,external_wp_element_namespaceObject.useMemo)(() => Store(registry, suspense), [registry]);
  3667. const selector = (0,external_wp_element_namespaceObject.useCallback)(mapSelect, deps);
  3668. const {
  3669. subscribe,
  3670. getValue
  3671. } = store(selector, isAsync);
  3672. const result = (0,external_wp_element_namespaceObject.useSyncExternalStore)(subscribe, getValue, getValue);
  3673. (0,external_wp_element_namespaceObject.useDebugValue)(result);
  3674. return result;
  3675. }
  3676. /**
  3677. * Custom react hook for retrieving props from registered selectors.
  3678. *
  3679. * In general, this custom React hook follows the
  3680. * [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
  3681. *
  3682. * @template {MapSelect | StoreDescriptor<any>} T
  3683. * @param {T} mapSelect Function called on every state change. The returned value is
  3684. * exposed to the component implementing this hook. The function
  3685. * receives the `registry.select` method on the first argument
  3686. * and the `registry` on the second argument.
  3687. * When a store key is passed, all selectors for the store will be
  3688. * returned. This is only meant for usage of these selectors in event
  3689. * callbacks, not for data needed to create the element tree.
  3690. * @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
  3691. * invoked on every state change unless the dependencies change.
  3692. *
  3693. * @example
  3694. * ```js
  3695. * import { useSelect } from '@wordpress/data';
  3696. * import { store as myCustomStore } from 'my-custom-store';
  3697. *
  3698. * function HammerPriceDisplay( { currency } ) {
  3699. * const price = useSelect( ( select ) => {
  3700. * return select( myCustomStore ).getPrice( 'hammer', currency );
  3701. * }, [ currency ] );
  3702. * return new Intl.NumberFormat( 'en-US', {
  3703. * style: 'currency',
  3704. * currency,
  3705. * } ).format( price );
  3706. * }
  3707. *
  3708. * // Rendered in the application:
  3709. * // <HammerPriceDisplay currency="USD" />
  3710. * ```
  3711. *
  3712. * In the above example, when `HammerPriceDisplay` is rendered into an
  3713. * application, the price will be retrieved from the store state using the
  3714. * `mapSelect` callback on `useSelect`. If the currency prop changes then
  3715. * any price in the state for that currency is retrieved. If the currency prop
  3716. * doesn't change and other props are passed in that do change, the price will
  3717. * not change because the dependency is just the currency.
  3718. *
  3719. * When data is only used in an event callback, the data should not be retrieved
  3720. * on render, so it may be useful to get the selectors function instead.
  3721. *
  3722. * **Don't use `useSelect` this way when calling the selectors in the render
  3723. * function because your component won't re-render on a data change.**
  3724. *
  3725. * ```js
  3726. * import { useSelect } from '@wordpress/data';
  3727. * import { store as myCustomStore } from 'my-custom-store';
  3728. *
  3729. * function Paste( { children } ) {
  3730. * const { getSettings } = useSelect( myCustomStore );
  3731. * function onPaste() {
  3732. * // Do something with the settings.
  3733. * const settings = getSettings();
  3734. * }
  3735. * return <div onPaste={ onPaste }>{ children }</div>;
  3736. * }
  3737. * ```
  3738. * @return {UseSelectReturn<T>} A custom react hook.
  3739. */
  3740. function useSelect(mapSelect, deps) {
  3741. // On initial call, on mount, determine the mode of this `useSelect` call
  3742. // and then never allow it to change on subsequent updates.
  3743. const staticSelectMode = typeof mapSelect !== 'function';
  3744. const staticSelectModeRef = (0,external_wp_element_namespaceObject.useRef)(staticSelectMode);
  3745. if (staticSelectMode !== staticSelectModeRef.current) {
  3746. const prevMode = staticSelectModeRef.current ? 'static' : 'mapping';
  3747. const nextMode = staticSelectMode ? 'static' : 'mapping';
  3748. throw new Error(`Switching useSelect from ${prevMode} to ${nextMode} is not allowed`);
  3749. }
  3750. /* eslint-disable react-hooks/rules-of-hooks */
  3751. // `staticSelectMode` is not allowed to change during the hook instance's,
  3752. // lifetime, so the rules of hooks are not really violated.
  3753. return staticSelectMode ? useStaticSelect(mapSelect) : useMappingSelect(false, mapSelect, deps);
  3754. /* eslint-enable react-hooks/rules-of-hooks */
  3755. }
  3756. /**
  3757. * A variant of the `useSelect` hook that has the same API, but will throw a
  3758. * suspense Promise if any of the called selectors is in an unresolved state.
  3759. *
  3760. * @param {Function} mapSelect Function called on every state change. The
  3761. * returned value is exposed to the component
  3762. * using this hook. The function receives the
  3763. * `registry.suspendSelect` method as the first
  3764. * argument and the `registry` as the second one.
  3765. * @param {Array} deps A dependency array used to memoize the `mapSelect`
  3766. * so that the same `mapSelect` is invoked on every
  3767. * state change unless the dependencies change.
  3768. *
  3769. * @return {Object} Data object returned by the `mapSelect` function.
  3770. */
  3771. function useSuspenseSelect(mapSelect, deps) {
  3772. return useMappingSelect(true, mapSelect, deps);
  3773. }
  3774. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js
  3775. /**
  3776. * WordPress dependencies
  3777. */
  3778. /**
  3779. * Internal dependencies
  3780. */
  3781. /** @typedef {import('@wordpress/element').WPComponent} WPComponent */
  3782. /**
  3783. * Higher-order component used to inject state-derived props using registered
  3784. * selectors.
  3785. *
  3786. * @param {Function} mapSelectToProps Function called on every state change,
  3787. * expected to return object of props to
  3788. * merge with the component's own props.
  3789. *
  3790. * @example
  3791. * ```js
  3792. * import { withSelect } from '@wordpress/data';
  3793. * import { store as myCustomStore } from 'my-custom-store';
  3794. *
  3795. * function PriceDisplay( { price, currency } ) {
  3796. * return new Intl.NumberFormat( 'en-US', {
  3797. * style: 'currency',
  3798. * currency,
  3799. * } ).format( price );
  3800. * }
  3801. *
  3802. * const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
  3803. * const { getPrice } = select( myCustomStore );
  3804. * const { currency } = ownProps;
  3805. *
  3806. * return {
  3807. * price: getPrice( 'hammer', currency ),
  3808. * };
  3809. * } )( PriceDisplay );
  3810. *
  3811. * // Rendered in the application:
  3812. * //
  3813. * // <HammerPriceDisplay currency="USD" />
  3814. * ```
  3815. * In the above example, when `HammerPriceDisplay` is rendered into an
  3816. * application, it will pass the price into the underlying `PriceDisplay`
  3817. * component and update automatically if the price of a hammer ever changes in
  3818. * the store.
  3819. *
  3820. * @return {WPComponent} Enhanced component with merged state data props.
  3821. */
  3822. const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => {
  3823. const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry);
  3824. const mergeProps = useSelect(mapSelect);
  3825. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, {
  3826. ...ownProps,
  3827. ...mergeProps
  3828. });
  3829. }), 'withSelect');
  3830. /* harmony default export */ var with_select = (withSelect);
  3831. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js
  3832. /**
  3833. * WordPress dependencies
  3834. */
  3835. /**
  3836. * Internal dependencies
  3837. */
  3838. /**
  3839. * Custom react hook for returning aggregate dispatch actions using the provided
  3840. * dispatchMap.
  3841. *
  3842. * Currently this is an internal api only and is implemented by `withDispatch`
  3843. *
  3844. * @param {Function} dispatchMap Receives the `registry.dispatch` function as
  3845. * the first argument and the `registry` object
  3846. * as the second argument. Should return an
  3847. * object mapping props to functions.
  3848. * @param {Array} deps An array of dependencies for the hook.
  3849. * @return {Object} An object mapping props to functions created by the passed
  3850. * in dispatchMap.
  3851. */
  3852. const useDispatchWithMap = (dispatchMap, deps) => {
  3853. const registry = useRegistry();
  3854. const currentDispatchMap = (0,external_wp_element_namespaceObject.useRef)(dispatchMap);
  3855. (0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
  3856. currentDispatchMap.current = dispatchMap;
  3857. });
  3858. return (0,external_wp_element_namespaceObject.useMemo)(() => {
  3859. const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry);
  3860. return Object.fromEntries(Object.entries(currentDispatchProps).map(([propName, dispatcher]) => {
  3861. if (typeof dispatcher !== 'function') {
  3862. // eslint-disable-next-line no-console
  3863. console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`);
  3864. }
  3865. return [propName, (...args) => currentDispatchMap.current(registry.dispatch, registry)[propName](...args)];
  3866. }));
  3867. }, [registry, ...deps]);
  3868. };
  3869. /* harmony default export */ var use_dispatch_with_map = (useDispatchWithMap);
  3870. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js
  3871. /**
  3872. * WordPress dependencies
  3873. */
  3874. /**
  3875. * Internal dependencies
  3876. */
  3877. /** @typedef {import('@wordpress/element').WPComponent} WPComponent */
  3878. /**
  3879. * Higher-order component used to add dispatch props using registered action
  3880. * creators.
  3881. *
  3882. * @param {Function} mapDispatchToProps A function of returning an object of
  3883. * prop names where value is a
  3884. * dispatch-bound action creator, or a
  3885. * function to be called with the
  3886. * component's props and returning an
  3887. * action creator.
  3888. *
  3889. * @example
  3890. * ```jsx
  3891. * function Button( { onClick, children } ) {
  3892. * return <button type="button" onClick={ onClick }>{ children }</button>;
  3893. * }
  3894. *
  3895. * import { withDispatch } from '@wordpress/data';
  3896. * import { store as myCustomStore } from 'my-custom-store';
  3897. *
  3898. * const SaleButton = withDispatch( ( dispatch, ownProps ) => {
  3899. * const { startSale } = dispatch( myCustomStore );
  3900. * const { discountPercent } = ownProps;
  3901. *
  3902. * return {
  3903. * onClick() {
  3904. * startSale( discountPercent );
  3905. * },
  3906. * };
  3907. * } )( Button );
  3908. *
  3909. * // Rendered in the application:
  3910. * //
  3911. * // <SaleButton discountPercent="20">Start Sale!</SaleButton>
  3912. * ```
  3913. *
  3914. * @example
  3915. * In the majority of cases, it will be sufficient to use only two first params
  3916. * passed to `mapDispatchToProps` as illustrated in the previous example.
  3917. * However, there might be some very advanced use cases where using the
  3918. * `registry` object might be used as a tool to optimize the performance of
  3919. * your component. Using `select` function from the registry might be useful
  3920. * when you need to fetch some dynamic data from the store at the time when the
  3921. * event is fired, but at the same time, you never use it to render your
  3922. * component. In such scenario, you can avoid using the `withSelect` higher
  3923. * order component to compute such prop, which might lead to unnecessary
  3924. * re-renders of your component caused by its frequent value change.
  3925. * Keep in mind, that `mapDispatchToProps` must return an object with functions
  3926. * only.
  3927. *
  3928. * ```jsx
  3929. * function Button( { onClick, children } ) {
  3930. * return <button type="button" onClick={ onClick }>{ children }</button>;
  3931. * }
  3932. *
  3933. * import { withDispatch } from '@wordpress/data';
  3934. * import { store as myCustomStore } from 'my-custom-store';
  3935. *
  3936. * const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
  3937. * // Stock number changes frequently.
  3938. * const { getStockNumber } = select( myCustomStore );
  3939. * const { startSale } = dispatch( myCustomStore );
  3940. * return {
  3941. * onClick() {
  3942. * const discountPercent = getStockNumber() > 50 ? 10 : 20;
  3943. * startSale( discountPercent );
  3944. * },
  3945. * };
  3946. * } )( Button );
  3947. *
  3948. * // Rendered in the application:
  3949. * //
  3950. * // <SaleButton>Start Sale!</SaleButton>
  3951. * ```
  3952. *
  3953. * _Note:_ It is important that the `mapDispatchToProps` function always
  3954. * returns an object with the same keys. For example, it should not contain
  3955. * conditions under which a different value would be returned.
  3956. *
  3957. * @return {WPComponent} Enhanced component with merged dispatcher props.
  3958. */
  3959. const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => {
  3960. const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry);
  3961. const dispatchProps = use_dispatch_with_map(mapDispatch, []);
  3962. return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, {
  3963. ...ownProps,
  3964. ...dispatchProps
  3965. });
  3966. }, 'withDispatch');
  3967. /* harmony default export */ var with_dispatch = (withDispatch);
  3968. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js
  3969. /**
  3970. * WordPress dependencies
  3971. */
  3972. /**
  3973. * Internal dependencies
  3974. */
  3975. /**
  3976. * Higher-order component which renders the original component with the current
  3977. * registry context passed as its `registry` prop.
  3978. *
  3979. * @param {WPComponent} OriginalComponent Original component.
  3980. *
  3981. * @return {WPComponent} Enhanced component.
  3982. */
  3983. const withRegistry = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => props => (0,external_wp_element_namespaceObject.createElement)(RegistryConsumer, null, registry => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, {
  3984. ...props,
  3985. registry: registry
  3986. })), 'withRegistry');
  3987. /* harmony default export */ var with_registry = (withRegistry);
  3988. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch.js
  3989. /**
  3990. * Internal dependencies
  3991. */
  3992. /**
  3993. * @typedef {import('../../types').StoreDescriptor<StoreConfig>} StoreDescriptor
  3994. * @template {import('../../types').AnyConfig} StoreConfig
  3995. */
  3996. /**
  3997. * @typedef {import('../../types').UseDispatchReturn<StoreNameOrDescriptor>} UseDispatchReturn
  3998. * @template StoreNameOrDescriptor
  3999. */
  4000. /**
  4001. * A custom react hook returning the current registry dispatch actions creators.
  4002. *
  4003. * Note: The component using this hook must be within the context of a
  4004. * RegistryProvider.
  4005. *
  4006. * @template {undefined | string | StoreDescriptor<any>} StoreNameOrDescriptor
  4007. * @param {StoreNameOrDescriptor} [storeNameOrDescriptor] Optionally provide the name of the
  4008. * store or its descriptor from which to
  4009. * retrieve action creators. If not
  4010. * provided, the registry.dispatch
  4011. * function is returned instead.
  4012. *
  4013. * @example
  4014. * This illustrates a pattern where you may need to retrieve dynamic data from
  4015. * the server via the `useSelect` hook to use in combination with the dispatch
  4016. * action.
  4017. *
  4018. * ```jsx
  4019. * import { useDispatch, useSelect } from '@wordpress/data';
  4020. * import { useCallback } from '@wordpress/element';
  4021. * import { store as myCustomStore } from 'my-custom-store';
  4022. *
  4023. * function Button( { onClick, children } ) {
  4024. * return <button type="button" onClick={ onClick }>{ children }</button>
  4025. * }
  4026. *
  4027. * const SaleButton = ( { children } ) => {
  4028. * const { stockNumber } = useSelect(
  4029. * ( select ) => select( myCustomStore ).getStockNumber(),
  4030. * []
  4031. * );
  4032. * const { startSale } = useDispatch( myCustomStore );
  4033. * const onClick = useCallback( () => {
  4034. * const discountPercent = stockNumber > 50 ? 10: 20;
  4035. * startSale( discountPercent );
  4036. * }, [ stockNumber ] );
  4037. * return <Button onClick={ onClick }>{ children }</Button>
  4038. * }
  4039. *
  4040. * // Rendered somewhere in the application:
  4041. * //
  4042. * // <SaleButton>Start Sale!</SaleButton>
  4043. * ```
  4044. * @return {UseDispatchReturn<StoreNameOrDescriptor>} A custom react hook.
  4045. */
  4046. const useDispatch = storeNameOrDescriptor => {
  4047. const {
  4048. dispatch
  4049. } = useRegistry();
  4050. return storeNameOrDescriptor === void 0 ? dispatch : dispatch(storeNameOrDescriptor);
  4051. };
  4052. /* harmony default export */ var use_dispatch = (useDispatch);
  4053. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/dispatch.js
  4054. /**
  4055. * Internal dependencies
  4056. */
  4057. /**
  4058. * Given a store descriptor, returns an object of the store's action creators.
  4059. * Calling an action creator will cause it to be dispatched, updating the state value accordingly.
  4060. *
  4061. * Note: Action creators returned by the dispatch will return a promise when
  4062. * they are called.
  4063. *
  4064. * @param storeNameOrDescriptor The store descriptor. The legacy calling convention of passing
  4065. * the store name is also supported.
  4066. *
  4067. * @example
  4068. * ```js
  4069. * import { dispatch } from '@wordpress/data';
  4070. * import { store as myCustomStore } from 'my-custom-store';
  4071. *
  4072. * dispatch( myCustomStore ).setPrice( 'hammer', 9.75 );
  4073. * ```
  4074. * @return Object containing the action creators.
  4075. */
  4076. function dispatch_dispatch(storeNameOrDescriptor) {
  4077. return default_registry.dispatch(storeNameOrDescriptor);
  4078. }
  4079. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/select.js
  4080. /**
  4081. * Internal dependencies
  4082. */
  4083. /**
  4084. * Given a store descriptor, returns an object of the store's selectors.
  4085. * The selector functions are been pre-bound to pass the current state automatically.
  4086. * As a consumer, you need only pass arguments of the selector, if applicable.
  4087. *
  4088. *
  4089. * @param storeNameOrDescriptor The store descriptor. The legacy calling convention
  4090. * of passing the store name is also supported.
  4091. *
  4092. * @example
  4093. * ```js
  4094. * import { select } from '@wordpress/data';
  4095. * import { store as myCustomStore } from 'my-custom-store';
  4096. *
  4097. * select( myCustomStore ).getPrice( 'hammer' );
  4098. * ```
  4099. *
  4100. * @return Object containing the store's selectors.
  4101. */
  4102. function select_select(storeNameOrDescriptor) {
  4103. return default_registry.select(storeNameOrDescriptor);
  4104. }
  4105. ;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/index.js
  4106. /**
  4107. * External dependencies
  4108. */
  4109. /**
  4110. * Internal dependencies
  4111. */
  4112. /** @typedef {import('./types').StoreDescriptor} StoreDescriptor */
  4113. /**
  4114. * Object of available plugins to use with a registry.
  4115. *
  4116. * @see [use](#use)
  4117. *
  4118. * @type {Object}
  4119. */
  4120. /**
  4121. * The combineReducers helper function turns an object whose values are different
  4122. * reducing functions into a single reducing function you can pass to registerReducer.
  4123. *
  4124. * @type {import('./types').combineReducers}
  4125. * @param {Object} reducers An object whose values correspond to different reducing
  4126. * functions that need to be combined into one.
  4127. *
  4128. * @example
  4129. * ```js
  4130. * import { combineReducers, createReduxStore, register } from '@wordpress/data';
  4131. *
  4132. * const prices = ( state = {}, action ) => {
  4133. * return action.type === 'SET_PRICE' ?
  4134. * {
  4135. * ...state,
  4136. * [ action.item ]: action.price,
  4137. * } :
  4138. * state;
  4139. * };
  4140. *
  4141. * const discountPercent = ( state = 0, action ) => {
  4142. * return action.type === 'START_SALE' ?
  4143. * action.discountPercent :
  4144. * state;
  4145. * };
  4146. *
  4147. * const store = createReduxStore( 'my-shop', {
  4148. * reducer: combineReducers( {
  4149. * prices,
  4150. * discountPercent,
  4151. * } ),
  4152. * } );
  4153. * register( store );
  4154. * ```
  4155. *
  4156. * @return {Function} A reducer that invokes every reducer inside the reducers
  4157. * object, and constructs a state object with the same shape.
  4158. */
  4159. const build_module_combineReducers = (turbo_combine_reducers_default());
  4160. /**
  4161. * Given a store descriptor, returns an object containing the store's selectors pre-bound to state
  4162. * so that you only need to supply additional arguments, and modified so that they return promises
  4163. * that resolve to their eventual values, after any resolvers have ran.
  4164. *
  4165. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  4166. * convention of passing the store name is
  4167. * also supported.
  4168. *
  4169. * @example
  4170. * ```js
  4171. * import { resolveSelect } from '@wordpress/data';
  4172. * import { store as myCustomStore } from 'my-custom-store';
  4173. *
  4174. * resolveSelect( myCustomStore ).getPrice( 'hammer' ).then(console.log)
  4175. * ```
  4176. *
  4177. * @return {Object} Object containing the store's promise-wrapped selectors.
  4178. */
  4179. const build_module_resolveSelect = default_registry.resolveSelect;
  4180. /**
  4181. * Given a store descriptor, returns an object containing the store's selectors pre-bound to state
  4182. * so that you only need to supply additional arguments, and modified so that they throw promises
  4183. * in case the selector is not resolved yet.
  4184. *
  4185. * @param {StoreDescriptor|string} storeNameOrDescriptor The store descriptor. The legacy calling
  4186. * convention of passing the store name is
  4187. * also supported.
  4188. *
  4189. * @return {Object} Object containing the store's suspense-wrapped selectors.
  4190. */
  4191. const suspendSelect = default_registry.suspendSelect;
  4192. /**
  4193. * Given a listener function, the function will be called any time the state value
  4194. * of one of the registered stores has changed. If you specify the optional
  4195. * `storeNameOrDescriptor` parameter, the listener function will be called only
  4196. * on updates on that one specific registered store.
  4197. *
  4198. * This function returns an `unsubscribe` function used to stop the subscription.
  4199. *
  4200. * @param {Function} listener Callback function.
  4201. * @param {string|StoreDescriptor?} storeNameOrDescriptor Optional store name.
  4202. *
  4203. * @example
  4204. * ```js
  4205. * import { subscribe } from '@wordpress/data';
  4206. *
  4207. * const unsubscribe = subscribe( () => {
  4208. * // You could use this opportunity to test whether the derived result of a
  4209. * // selector has subsequently changed as the result of a state update.
  4210. * } );
  4211. *
  4212. * // Later, if necessary...
  4213. * unsubscribe();
  4214. * ```
  4215. */
  4216. const subscribe = default_registry.subscribe;
  4217. /**
  4218. * Registers a generic store instance.
  4219. *
  4220. * @deprecated Use `register( storeDescriptor )` instead.
  4221. *
  4222. * @param {string} name Store registry name.
  4223. * @param {Object} store Store instance (`{ getSelectors, getActions, subscribe }`).
  4224. */
  4225. const registerGenericStore = default_registry.registerGenericStore;
  4226. /**
  4227. * Registers a standard `@wordpress/data` store.
  4228. *
  4229. * @deprecated Use `register` instead.
  4230. *
  4231. * @param {string} storeName Unique namespace identifier for the store.
  4232. * @param {Object} options Store description (reducer, actions, selectors, resolvers).
  4233. *
  4234. * @return {Object} Registered store object.
  4235. */
  4236. const registerStore = default_registry.registerStore;
  4237. /**
  4238. * Extends a registry to inherit functionality provided by a given plugin. A
  4239. * plugin is an object with properties aligning to that of a registry, merged
  4240. * to extend the default registry behavior.
  4241. *
  4242. * @param {Object} plugin Plugin object.
  4243. */
  4244. const use = default_registry.use;
  4245. /**
  4246. * Registers a standard `@wordpress/data` store descriptor.
  4247. *
  4248. * @example
  4249. * ```js
  4250. * import { createReduxStore, register } from '@wordpress/data';
  4251. *
  4252. * const store = createReduxStore( 'demo', {
  4253. * reducer: ( state = 'OK' ) => state,
  4254. * selectors: {
  4255. * getValue: ( state ) => state,
  4256. * },
  4257. * } );
  4258. * register( store );
  4259. * ```
  4260. *
  4261. * @param {StoreDescriptor} store Store descriptor.
  4262. */
  4263. const register = default_registry.register;
  4264. }();
  4265. (window.wp = window.wp || {}).data = __webpack_exports__;
  4266. /******/ })()
  4267. ;