* Arbitrary value used as key for referencing cache object in WeakMap tree.
* Whether environment supports WeakMap.
hasWeakMap = typeof WeakMap !== 'undefined';
* Returns the first argument as the sole entry in an array.
* @param {*} value Value to return.
* @return {Array} Value returned as entry in array.
function arrayOf( value ) {
* Returns true if the value passed is object-like, or false otherwise. A value
* is object-like if it can support property assignment, e.g. object or array.
* @param {*} value Value to test.
* @return {boolean} Whether value is object-like.
function isObjectLike( value ) {
return !! value && 'object' === typeof value;
* Creates and returns a new cache object.
* @return {Object} Cache object.
* Returns true if entries within the two arrays are strictly equal by
* reference from a starting index.
* @param {Array} a First array.
* @param {Array} b Second array.
* @param {number} fromIndex Index from which to start comparison.
* @return {boolean} Whether arrays are shallowly equal.
function isShallowEqual( a, b, fromIndex ) {
if ( a.length !== b.length ) {
for ( i = fromIndex; i < a.length; i++ ) {
if ( a[ i ] !== b[ i ] ) {
* Returns a memoized selector function. The getDependants function argument is
* called before the memoized selector and is expected to return an immutable
* reference or array of references on which the selector depends for computing
* its own return value. The memoize cache is preserved only as long as those
* dependant references remain the same. If getDependants returns a different
* reference(s), the cache is cleared and the selector value regenerated.
* @param {Function} selector Selector function.
* @param {Function} getDependants Dependant getter returning an immutable
* reference or array of reference used in
* cache bust consideration.
* @return {Function} Memoized selector.
/* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
// Use object source as dependant if getter not provided
* Returns the root cache. If WeakMap is supported, this is assigned to the
* root WeakMap cache set, otherwise it is a shared instance of the default
* @return {(WeakMap|Object)} Root cache object.
function getRootCache() {
* Returns the cache for a given dependants array. When possible, a WeakMap
* will be used to create a unique cache for each set of dependants. This
* is feasible due to the nature of WeakMap in allowing garbage collection
* to occur on entries where the key object is no longer referenced. Since
* WeakMap requires the key to be an object, this is only possible when the
* dependant is object-like. The root cache is created as a hierarchy where
* each top-level key is the first entry in a dependants set, the value a
* WeakMap where each key is the next dependant, and so on. This continues
* so long as the dependants are object-like. If no dependants are object-
* like, then the cache is shared across all invocations.
* @param {Array} dependants Selector dependants.
* @return {Object} Cache object.
function getWeakMapCache( dependants ) {
isUniqueByDependants = true,
i, dependant, map, cache;
for ( i = 0; i < dependants.length; i++ ) {
dependant = dependants[ i ];
// Can only compose WeakMap from object-like key.
if ( ! isObjectLike( dependant ) ) {
isUniqueByDependants = false;
// Does current segment of cache already have a WeakMap?
if ( caches.has( dependant ) ) {
// Traverse into nested WeakMap.
caches = caches.get( dependant );
// Create, set, and traverse into a new one.
caches.set( dependant, map );
// We use an arbitrary (but consistent) object as key for the last item
// in the WeakMap to serve as our running cache.
if ( ! caches.has( LEAF_KEY ) ) {
cache.isUniqueByDependants = isUniqueByDependants;
caches.set( LEAF_KEY, cache );
return caches.get( LEAF_KEY );
// Assign cache handler by availability of WeakMap
getCache = hasWeakMap ? getWeakMapCache : getRootCache;
* Resets root memoization cache.
rootCache = hasWeakMap ? new WeakMap() : createCache();
// eslint-disable-next-line jsdoc/check-param-names
* The augmented selector call, considering first whether dependants have
* changed before passing it to underlying memoize function.
* @param {Object} source Source object for derivation.
* @param {...*} extraArgs Additional arguments to pass to selector.
* @return {*} Selector result.
function callSelector( /* source, ...extraArgs */ ) {
var len = arguments.length,
cache, node, i, args, dependants;
// Create copy of arguments (avoid leaking deoptimization).
for ( i = 0; i < len; i++ ) {
args[ i ] = arguments[ i ];
dependants = getDependants.apply( null, args );
cache = getCache( dependants );
// If not guaranteed uniqueness by dependants (primitive type or lack
// of WeakMap support), shallow compare against last dependants and, if
// references have changed, destroy cache to recalculate result.
if ( ! cache.isUniqueByDependants ) {
if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
cache.lastDependants = dependants;
// Check whether node arguments match arguments
if ( ! isShallowEqual( node.args, args, 1 ) ) {
// At this point we can assume we've found a match
// Surface matched node to head if not already
if ( node !== cache.head ) {
// Adjust siblings to point to each other.
node.prev.next = node.next;
node.next.prev = node.prev;
// No cached value found. Continue to insertion phase:
// Generate the result from original function
val: selector.apply( null, args ),
// Avoid including the source object in the cache.
// Don't need to check whether node is already head, since it would
// have been returned above already if it was
// Shift existing head down list
callSelector.getDependants = getDependants;
callSelector.clear = clear;
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
function _defineProperty(obj, key, value) {
Object.defineProperty(obj, key, {
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["isShallowEqual"]; }());
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["htmlEntities"]; }());
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
return _extends.apply(this, arguments);
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["blob"]; }());