core-data.js (164873B)
1 this["wp"] = this["wp"] || {}; this["wp"]["coreData"] = 2 /******/ (function(modules) { // webpackBootstrap 3 /******/ // The module cache 4 /******/ var installedModules = {}; 5 /******/ 6 /******/ // The require function 7 /******/ function __webpack_require__(moduleId) { 8 /******/ 9 /******/ // Check if module is in cache 10 /******/ if(installedModules[moduleId]) { 11 /******/ return installedModules[moduleId].exports; 12 /******/ } 13 /******/ // Create a new module (and put it into the cache) 14 /******/ var module = installedModules[moduleId] = { 15 /******/ i: moduleId, 16 /******/ l: false, 17 /******/ exports: {} 18 /******/ }; 19 /******/ 20 /******/ // Execute the module function 21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 22 /******/ 23 /******/ // Flag the module as loaded 24 /******/ module.l = true; 25 /******/ 26 /******/ // Return the exports of the module 27 /******/ return module.exports; 28 /******/ } 29 /******/ 30 /******/ 31 /******/ // expose the modules object (__webpack_modules__) 32 /******/ __webpack_require__.m = modules; 33 /******/ 34 /******/ // expose the module cache 35 /******/ __webpack_require__.c = installedModules; 36 /******/ 37 /******/ // define getter function for harmony exports 38 /******/ __webpack_require__.d = function(exports, name, getter) { 39 /******/ if(!__webpack_require__.o(exports, name)) { 40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 41 /******/ } 42 /******/ }; 43 /******/ 44 /******/ // define __esModule on exports 45 /******/ __webpack_require__.r = function(exports) { 46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 48 /******/ } 49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 50 /******/ }; 51 /******/ 52 /******/ // create a fake namespace object 53 /******/ // mode & 1: value is a module id, require it 54 /******/ // mode & 2: merge all properties of value into the ns 55 /******/ // mode & 4: return value when already ns object 56 /******/ // mode & 8|1: behave like require 57 /******/ __webpack_require__.t = function(value, mode) { 58 /******/ if(mode & 1) value = __webpack_require__(value); 59 /******/ if(mode & 8) return value; 60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 61 /******/ var ns = Object.create(null); 62 /******/ __webpack_require__.r(ns); 63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 65 /******/ return ns; 66 /******/ }; 67 /******/ 68 /******/ // getDefaultExport function for compatibility with non-harmony modules 69 /******/ __webpack_require__.n = function(module) { 70 /******/ var getter = module && module.__esModule ? 71 /******/ function getDefault() { return module['default']; } : 72 /******/ function getModuleExports() { return module; }; 73 /******/ __webpack_require__.d(getter, 'a', getter); 74 /******/ return getter; 75 /******/ }; 76 /******/ 77 /******/ // Object.prototype.hasOwnProperty.call 78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 79 /******/ 80 /******/ // __webpack_public_path__ 81 /******/ __webpack_require__.p = ""; 82 /******/ 83 /******/ 84 /******/ // Load entry module and return exports 85 /******/ return __webpack_require__(__webpack_require__.s = "dsJ0"); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ "1ZqX": 91 /***/ (function(module, exports) { 92 93 (function() { module.exports = window["wp"]["data"]; }()); 94 95 /***/ }), 96 97 /***/ "51Zz": 98 /***/ (function(module, exports) { 99 100 (function() { module.exports = window["wp"]["dataControls"]; }()); 101 102 /***/ }), 103 104 /***/ "7Cbv": 105 /***/ (function(module, __webpack_exports__, __webpack_require__) { 106 107 "use strict"; 108 109 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js 110 // Unique ID creation requires a high quality random # generator. In the browser we therefore 111 // require the crypto API and do not support built-in fallback to lower quality random number 112 // generators (like Math.random()). 113 var getRandomValues; 114 var rnds8 = new Uint8Array(16); 115 function rng() { 116 // lazy load so that environments that need to polyfill have a chance to do so 117 if (!getRandomValues) { 118 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, 119 // find the complete implementation of crypto (msCrypto) on IE11. 120 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); 121 122 if (!getRandomValues) { 123 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); 124 } 125 } 126 127 return getRandomValues(rnds8); 128 } 129 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js 130 /* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); 131 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js 132 133 134 function validate(uuid) { 135 return typeof uuid === 'string' && regex.test(uuid); 136 } 137 138 /* harmony default export */ var esm_browser_validate = (validate); 139 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js 140 141 /** 142 * Convert array of 16 byte values to UUID string format of the form: 143 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 144 */ 145 146 var byteToHex = []; 147 148 for (var stringify_i = 0; stringify_i < 256; ++stringify_i) { 149 byteToHex.push((stringify_i + 0x100).toString(16).substr(1)); 150 } 151 152 function stringify(arr) { 153 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 154 // Note: Be careful editing this code! It's been tuned for performance 155 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 156 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one 157 // of the following: 158 // - One or more input array values don't map to a hex octet (leading to 159 // "undefined" in the uuid) 160 // - Invalid input values for the RFC `version` or `variant` fields 161 162 if (!esm_browser_validate(uuid)) { 163 throw TypeError('Stringified UUID is invalid'); 164 } 165 166 return uuid; 167 } 168 169 /* harmony default export */ var esm_browser_stringify = (stringify); 170 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js 171 172 173 174 function v4(options, buf, offset) { 175 options = options || {}; 176 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` 177 178 rnds[6] = rnds[6] & 0x0f | 0x40; 179 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided 180 181 if (buf) { 182 offset = offset || 0; 183 184 for (var i = 0; i < 16; ++i) { 185 buf[offset + i] = rnds[i]; 186 } 187 188 return buf; 189 } 190 191 return esm_browser_stringify(rnds); 192 } 193 194 /* harmony default export */ var esm_browser_v4 = __webpack_exports__["a"] = (v4); 195 196 /***/ }), 197 198 /***/ "FtRg": 199 /***/ (function(module, exports, __webpack_require__) { 200 201 "use strict"; 202 203 204 function _typeof(obj) { 205 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 206 _typeof = function (obj) { 207 return typeof obj; 208 }; 209 } else { 210 _typeof = function (obj) { 211 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 212 }; 213 } 214 215 return _typeof(obj); 216 } 217 218 function _classCallCheck(instance, Constructor) { 219 if (!(instance instanceof Constructor)) { 220 throw new TypeError("Cannot call a class as a function"); 221 } 222 } 223 224 function _defineProperties(target, props) { 225 for (var i = 0; i < props.length; i++) { 226 var descriptor = props[i]; 227 descriptor.enumerable = descriptor.enumerable || false; 228 descriptor.configurable = true; 229 if ("value" in descriptor) descriptor.writable = true; 230 Object.defineProperty(target, descriptor.key, descriptor); 231 } 232 } 233 234 function _createClass(Constructor, protoProps, staticProps) { 235 if (protoProps) _defineProperties(Constructor.prototype, protoProps); 236 if (staticProps) _defineProperties(Constructor, staticProps); 237 return Constructor; 238 } 239 240 /** 241 * Given an instance of EquivalentKeyMap, returns its internal value pair tuple 242 * for a key, if one exists. The tuple members consist of the last reference 243 * value for the key (used in efficient subsequent lookups) and the value 244 * assigned for the key at the leaf node. 245 * 246 * @param {EquivalentKeyMap} instance EquivalentKeyMap instance. 247 * @param {*} key The key for which to return value pair. 248 * 249 * @return {?Array} Value pair, if exists. 250 */ 251 function getValuePair(instance, key) { 252 var _map = instance._map, 253 _arrayTreeMap = instance._arrayTreeMap, 254 _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the 255 // value, which can be used to shortcut immediately to the value. 256 257 if (_map.has(key)) { 258 return _map.get(key); 259 } // Sort keys to ensure stable retrieval from tree. 260 261 262 var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value. 263 264 var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap; 265 266 for (var i = 0; i < properties.length; i++) { 267 var property = properties[i]; 268 map = map.get(property); 269 270 if (map === undefined) { 271 return; 272 } 273 274 var propertyValue = key[property]; 275 map = map.get(propertyValue); 276 277 if (map === undefined) { 278 return; 279 } 280 } 281 282 var valuePair = map.get('_ekm_value'); 283 284 if (!valuePair) { 285 return; 286 } // If reached, it implies that an object-like key was set with another 287 // reference, so delete the reference and replace with the current. 288 289 290 _map.delete(valuePair[0]); 291 292 valuePair[0] = key; 293 map.set('_ekm_value', valuePair); 294 295 _map.set(key, valuePair); 296 297 return valuePair; 298 } 299 /** 300 * Variant of a Map object which enables lookup by equivalent (deeply equal) 301 * object and array keys. 302 */ 303 304 305 var EquivalentKeyMap = 306 /*#__PURE__*/ 307 function () { 308 /** 309 * Constructs a new instance of EquivalentKeyMap. 310 * 311 * @param {Iterable.<*>} iterable Initial pair of key, value for map. 312 */ 313 function EquivalentKeyMap(iterable) { 314 _classCallCheck(this, EquivalentKeyMap); 315 316 this.clear(); 317 318 if (iterable instanceof EquivalentKeyMap) { 319 // Map#forEach is only means of iterating with support for IE11. 320 var iterablePairs = []; 321 iterable.forEach(function (value, key) { 322 iterablePairs.push([key, value]); 323 }); 324 iterable = iterablePairs; 325 } 326 327 if (iterable != null) { 328 for (var i = 0; i < iterable.length; i++) { 329 this.set(iterable[i][0], iterable[i][1]); 330 } 331 } 332 } 333 /** 334 * Accessor property returning the number of elements. 335 * 336 * @return {number} Number of elements. 337 */ 338 339 340 _createClass(EquivalentKeyMap, [{ 341 key: "set", 342 343 /** 344 * Add or update an element with a specified key and value. 345 * 346 * @param {*} key The key of the element to add. 347 * @param {*} value The value of the element to add. 348 * 349 * @return {EquivalentKeyMap} Map instance. 350 */ 351 value: function set(key, value) { 352 // Shortcut non-object-like to set on internal Map. 353 if (key === null || _typeof(key) !== 'object') { 354 this._map.set(key, value); 355 356 return this; 357 } // Sort keys to ensure stable assignment into tree. 358 359 360 var properties = Object.keys(key).sort(); 361 var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value. 362 363 var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap; 364 365 for (var i = 0; i < properties.length; i++) { 366 var property = properties[i]; 367 368 if (!map.has(property)) { 369 map.set(property, new EquivalentKeyMap()); 370 } 371 372 map = map.get(property); 373 var propertyValue = key[property]; 374 375 if (!map.has(propertyValue)) { 376 map.set(propertyValue, new EquivalentKeyMap()); 377 } 378 379 map = map.get(propertyValue); 380 } // If an _ekm_value exists, there was already an equivalent key. Before 381 // overriding, ensure that the old key reference is removed from map to 382 // avoid memory leak of accumulating equivalent keys. This is, in a 383 // sense, a poor man's WeakMap, while still enabling iterability. 384 385 386 var previousValuePair = map.get('_ekm_value'); 387 388 if (previousValuePair) { 389 this._map.delete(previousValuePair[0]); 390 } 391 392 map.set('_ekm_value', valuePair); 393 394 this._map.set(key, valuePair); 395 396 return this; 397 } 398 /** 399 * Returns a specified element. 400 * 401 * @param {*} key The key of the element to return. 402 * 403 * @return {?*} The element associated with the specified key or undefined 404 * if the key can't be found. 405 */ 406 407 }, { 408 key: "get", 409 value: function get(key) { 410 // Shortcut non-object-like to get from internal Map. 411 if (key === null || _typeof(key) !== 'object') { 412 return this._map.get(key); 413 } 414 415 var valuePair = getValuePair(this, key); 416 417 if (valuePair) { 418 return valuePair[1]; 419 } 420 } 421 /** 422 * Returns a boolean indicating whether an element with the specified key 423 * exists or not. 424 * 425 * @param {*} key The key of the element to test for presence. 426 * 427 * @return {boolean} Whether an element with the specified key exists. 428 */ 429 430 }, { 431 key: "has", 432 value: function has(key) { 433 if (key === null || _typeof(key) !== 'object') { 434 return this._map.has(key); 435 } // Test on the _presence_ of the pair, not its value, as even undefined 436 // can be a valid member value for a key. 437 438 439 return getValuePair(this, key) !== undefined; 440 } 441 /** 442 * Removes the specified element. 443 * 444 * @param {*} key The key of the element to remove. 445 * 446 * @return {boolean} Returns true if an element existed and has been 447 * removed, or false if the element does not exist. 448 */ 449 450 }, { 451 key: "delete", 452 value: function _delete(key) { 453 if (!this.has(key)) { 454 return false; 455 } // This naive implementation will leave orphaned child trees. A better 456 // implementation should traverse and remove orphans. 457 458 459 this.set(key, undefined); 460 return true; 461 } 462 /** 463 * Executes a provided function once per each key/value pair, in insertion 464 * order. 465 * 466 * @param {Function} callback Function to execute for each element. 467 * @param {*} thisArg Value to use as `this` when executing 468 * `callback`. 469 */ 470 471 }, { 472 key: "forEach", 473 value: function forEach(callback) { 474 var _this = this; 475 476 var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this; 477 478 this._map.forEach(function (value, key) { 479 // Unwrap value from object-like value pair. 480 if (key !== null && _typeof(key) === 'object') { 481 value = value[1]; 482 } 483 484 callback.call(thisArg, value, key, _this); 485 }); 486 } 487 /** 488 * Removes all elements. 489 */ 490 491 }, { 492 key: "clear", 493 value: function clear() { 494 this._map = new Map(); 495 this._arrayTreeMap = new Map(); 496 this._objectTreeMap = new Map(); 497 } 498 }, { 499 key: "size", 500 get: function get() { 501 return this._map.size; 502 } 503 }]); 504 505 return EquivalentKeyMap; 506 }(); 507 508 module.exports = EquivalentKeyMap; 509 510 511 /***/ }), 512 513 /***/ "GRId": 514 /***/ (function(module, exports) { 515 516 (function() { module.exports = window["wp"]["element"]; }()); 517 518 /***/ }), 519 520 /***/ "HSyU": 521 /***/ (function(module, exports) { 522 523 (function() { module.exports = window["wp"]["blocks"]; }()); 524 525 /***/ }), 526 527 /***/ "Mmq9": 528 /***/ (function(module, exports) { 529 530 (function() { module.exports = window["wp"]["url"]; }()); 531 532 /***/ }), 533 534 /***/ "YLtl": 535 /***/ (function(module, exports) { 536 537 (function() { module.exports = window["lodash"]; }()); 538 539 /***/ }), 540 541 /***/ "dsJ0": 542 /***/ (function(module, __webpack_exports__, __webpack_require__) { 543 544 "use strict"; 545 // ESM COMPAT FLAG 546 __webpack_require__.r(__webpack_exports__); 547 548 // EXPORTS 549 __webpack_require__.d(__webpack_exports__, "store", function() { return /* binding */ build_module_store; }); 550 __webpack_require__.d(__webpack_exports__, "EntityProvider", function() { return /* reexport */ EntityProvider; }); 551 __webpack_require__.d(__webpack_exports__, "useEntityId", function() { return /* reexport */ useEntityId; }); 552 __webpack_require__.d(__webpack_exports__, "useEntityProp", function() { return /* reexport */ useEntityProp; }); 553 __webpack_require__.d(__webpack_exports__, "useEntityBlockEditor", function() { return /* reexport */ useEntityBlockEditor; }); 554 __webpack_require__.d(__webpack_exports__, "__experimentalFetchLinkSuggestions", function() { return /* reexport */ _experimental_fetch_link_suggestions; }); 555 __webpack_require__.d(__webpack_exports__, "__experimentalFetchRemoteUrlData", function() { return /* reexport */ _experimental_fetch_remote_url_data; }); 556 557 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/locks/actions.js 558 var locks_actions_namespaceObject = {}; 559 __webpack_require__.r(locks_actions_namespaceObject); 560 __webpack_require__.d(locks_actions_namespaceObject, "__unstableAcquireStoreLock", function() { return __unstableAcquireStoreLock; }); 561 __webpack_require__.d(locks_actions_namespaceObject, "__unstableEnqueueLockRequest", function() { return __unstableEnqueueLockRequest; }); 562 __webpack_require__.d(locks_actions_namespaceObject, "__unstableReleaseStoreLock", function() { return __unstableReleaseStoreLock; }); 563 __webpack_require__.d(locks_actions_namespaceObject, "__unstableProcessPendingLockRequests", function() { return __unstableProcessPendingLockRequests; }); 564 565 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/actions.js 566 var build_module_actions_namespaceObject = {}; 567 __webpack_require__.r(build_module_actions_namespaceObject); 568 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserQuery", function() { return receiveUserQuery; }); 569 __webpack_require__.d(build_module_actions_namespaceObject, "receiveCurrentUser", function() { return receiveCurrentUser; }); 570 __webpack_require__.d(build_module_actions_namespaceObject, "addEntities", function() { return addEntities; }); 571 __webpack_require__.d(build_module_actions_namespaceObject, "receiveEntityRecords", function() { return receiveEntityRecords; }); 572 __webpack_require__.d(build_module_actions_namespaceObject, "receiveCurrentTheme", function() { return receiveCurrentTheme; }); 573 __webpack_require__.d(build_module_actions_namespaceObject, "receiveThemeSupports", function() { return receiveThemeSupports; }); 574 __webpack_require__.d(build_module_actions_namespaceObject, "receiveEmbedPreview", function() { return receiveEmbedPreview; }); 575 __webpack_require__.d(build_module_actions_namespaceObject, "deleteEntityRecord", function() { return deleteEntityRecord; }); 576 __webpack_require__.d(build_module_actions_namespaceObject, "editEntityRecord", function() { return actions_editEntityRecord; }); 577 __webpack_require__.d(build_module_actions_namespaceObject, "undo", function() { return undo; }); 578 __webpack_require__.d(build_module_actions_namespaceObject, "redo", function() { return redo; }); 579 __webpack_require__.d(build_module_actions_namespaceObject, "__unstableCreateUndoLevel", function() { return actions_unstableCreateUndoLevel; }); 580 __webpack_require__.d(build_module_actions_namespaceObject, "saveEntityRecord", function() { return saveEntityRecord; }); 581 __webpack_require__.d(build_module_actions_namespaceObject, "__experimentalBatch", function() { return __experimentalBatch; }); 582 __webpack_require__.d(build_module_actions_namespaceObject, "saveEditedEntityRecord", function() { return saveEditedEntityRecord; }); 583 __webpack_require__.d(build_module_actions_namespaceObject, "__experimentalSaveSpecifiedEntityEdits", function() { return __experimentalSaveSpecifiedEntityEdits; }); 584 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUploadPermissions", function() { return receiveUploadPermissions; }); 585 __webpack_require__.d(build_module_actions_namespaceObject, "receiveUserPermission", function() { return receiveUserPermission; }); 586 __webpack_require__.d(build_module_actions_namespaceObject, "receiveAutosaves", function() { return receiveAutosaves; }); 587 588 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/selectors.js 589 var build_module_selectors_namespaceObject = {}; 590 __webpack_require__.r(build_module_selectors_namespaceObject); 591 __webpack_require__.d(build_module_selectors_namespaceObject, "isRequestingEmbedPreview", function() { return isRequestingEmbedPreview; }); 592 __webpack_require__.d(build_module_selectors_namespaceObject, "getAuthors", function() { return getAuthors; }); 593 __webpack_require__.d(build_module_selectors_namespaceObject, "__unstableGetAuthor", function() { return __unstableGetAuthor; }); 594 __webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentUser", function() { return getCurrentUser; }); 595 __webpack_require__.d(build_module_selectors_namespaceObject, "getUserQueryResults", function() { return getUserQueryResults; }); 596 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntitiesByKind", function() { return getEntitiesByKind; }); 597 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntity", function() { return getEntity; }); 598 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecord", function() { return getEntityRecord; }); 599 __webpack_require__.d(build_module_selectors_namespaceObject, "__experimentalGetEntityRecordNoResolver", function() { return __experimentalGetEntityRecordNoResolver; }); 600 __webpack_require__.d(build_module_selectors_namespaceObject, "getRawEntityRecord", function() { return getRawEntityRecord; }); 601 __webpack_require__.d(build_module_selectors_namespaceObject, "hasEntityRecords", function() { return hasEntityRecords; }); 602 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecords", function() { return getEntityRecords; }); 603 __webpack_require__.d(build_module_selectors_namespaceObject, "__experimentalGetDirtyEntityRecords", function() { return __experimentalGetDirtyEntityRecords; }); 604 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordEdits", function() { return getEntityRecordEdits; }); 605 __webpack_require__.d(build_module_selectors_namespaceObject, "getEntityRecordNonTransientEdits", function() { return getEntityRecordNonTransientEdits; }); 606 __webpack_require__.d(build_module_selectors_namespaceObject, "hasEditsForEntityRecord", function() { return hasEditsForEntityRecord; }); 607 __webpack_require__.d(build_module_selectors_namespaceObject, "getEditedEntityRecord", function() { return getEditedEntityRecord; }); 608 __webpack_require__.d(build_module_selectors_namespaceObject, "isAutosavingEntityRecord", function() { return isAutosavingEntityRecord; }); 609 __webpack_require__.d(build_module_selectors_namespaceObject, "isSavingEntityRecord", function() { return isSavingEntityRecord; }); 610 __webpack_require__.d(build_module_selectors_namespaceObject, "isDeletingEntityRecord", function() { return isDeletingEntityRecord; }); 611 __webpack_require__.d(build_module_selectors_namespaceObject, "getLastEntitySaveError", function() { return getLastEntitySaveError; }); 612 __webpack_require__.d(build_module_selectors_namespaceObject, "getLastEntityDeleteError", function() { return getLastEntityDeleteError; }); 613 __webpack_require__.d(build_module_selectors_namespaceObject, "getUndoEdit", function() { return getUndoEdit; }); 614 __webpack_require__.d(build_module_selectors_namespaceObject, "getRedoEdit", function() { return getRedoEdit; }); 615 __webpack_require__.d(build_module_selectors_namespaceObject, "hasUndo", function() { return hasUndo; }); 616 __webpack_require__.d(build_module_selectors_namespaceObject, "hasRedo", function() { return hasRedo; }); 617 __webpack_require__.d(build_module_selectors_namespaceObject, "getCurrentTheme", function() { return getCurrentTheme; }); 618 __webpack_require__.d(build_module_selectors_namespaceObject, "getThemeSupports", function() { return getThemeSupports; }); 619 __webpack_require__.d(build_module_selectors_namespaceObject, "getEmbedPreview", function() { return getEmbedPreview; }); 620 __webpack_require__.d(build_module_selectors_namespaceObject, "isPreviewEmbedFallback", function() { return isPreviewEmbedFallback; }); 621 __webpack_require__.d(build_module_selectors_namespaceObject, "canUser", function() { return canUser; }); 622 __webpack_require__.d(build_module_selectors_namespaceObject, "canUserEditEntityRecord", function() { return canUserEditEntityRecord; }); 623 __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosaves", function() { return getAutosaves; }); 624 __webpack_require__.d(build_module_selectors_namespaceObject, "getAutosave", function() { return getAutosave; }); 625 __webpack_require__.d(build_module_selectors_namespaceObject, "hasFetchedAutosaves", function() { return hasFetchedAutosaves; }); 626 __webpack_require__.d(build_module_selectors_namespaceObject, "getReferenceByDistinctEdits", function() { return getReferenceByDistinctEdits; }); 627 __webpack_require__.d(build_module_selectors_namespaceObject, "__experimentalGetTemplateForLink", function() { return __experimentalGetTemplateForLink; }); 628 629 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/resolvers.js 630 var resolvers_namespaceObject = {}; 631 __webpack_require__.r(resolvers_namespaceObject); 632 __webpack_require__.d(resolvers_namespaceObject, "getAuthors", function() { return resolvers_getAuthors; }); 633 __webpack_require__.d(resolvers_namespaceObject, "__unstableGetAuthor", function() { return resolvers_unstableGetAuthor; }); 634 __webpack_require__.d(resolvers_namespaceObject, "getCurrentUser", function() { return resolvers_getCurrentUser; }); 635 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecord", function() { return resolvers_getEntityRecord; }); 636 __webpack_require__.d(resolvers_namespaceObject, "getRawEntityRecord", function() { return resolvers_getRawEntityRecord; }); 637 __webpack_require__.d(resolvers_namespaceObject, "getEditedEntityRecord", function() { return resolvers_getEditedEntityRecord; }); 638 __webpack_require__.d(resolvers_namespaceObject, "getEntityRecords", function() { return resolvers_getEntityRecords; }); 639 __webpack_require__.d(resolvers_namespaceObject, "getCurrentTheme", function() { return resolvers_getCurrentTheme; }); 640 __webpack_require__.d(resolvers_namespaceObject, "getThemeSupports", function() { return resolvers_getThemeSupports; }); 641 __webpack_require__.d(resolvers_namespaceObject, "getEmbedPreview", function() { return resolvers_getEmbedPreview; }); 642 __webpack_require__.d(resolvers_namespaceObject, "canUser", function() { return resolvers_canUser; }); 643 __webpack_require__.d(resolvers_namespaceObject, "canUserEditEntityRecord", function() { return resolvers_canUserEditEntityRecord; }); 644 __webpack_require__.d(resolvers_namespaceObject, "getAutosaves", function() { return resolvers_getAutosaves; }); 645 __webpack_require__.d(resolvers_namespaceObject, "getAutosave", function() { return resolvers_getAutosave; }); 646 __webpack_require__.d(resolvers_namespaceObject, "__experimentalGetTemplateForLink", function() { return resolvers_experimentalGetTemplateForLink; }); 647 648 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/locks/selectors.js 649 var locks_selectors_namespaceObject = {}; 650 __webpack_require__.r(locks_selectors_namespaceObject); 651 __webpack_require__.d(locks_selectors_namespaceObject, "__unstableGetPendingLockRequests", function() { return __unstableGetPendingLockRequests; }); 652 __webpack_require__.d(locks_selectors_namespaceObject, "__unstableIsLockAvailable", function() { return __unstableIsLockAvailable; }); 653 654 // EXTERNAL MODULE: external ["wp","data"] 655 var external_wp_data_ = __webpack_require__("1ZqX"); 656 657 // EXTERNAL MODULE: external ["wp","dataControls"] 658 var external_wp_dataControls_ = __webpack_require__("51Zz"); 659 660 // EXTERNAL MODULE: external "lodash" 661 var external_lodash_ = __webpack_require__("YLtl"); 662 663 // EXTERNAL MODULE: external ["wp","isShallowEqual"] 664 var external_wp_isShallowEqual_ = __webpack_require__("rl8x"); 665 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); 666 667 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js 668 /** 669 * A higher-order reducer creator which invokes the original reducer only if 670 * the dispatching action matches the given predicate, **OR** if state is 671 * initializing (undefined). 672 * 673 * @param {Function} isMatch Function predicate for allowing reducer call. 674 * 675 * @return {Function} Higher-order reducer. 676 */ 677 const ifMatchingAction = isMatch => reducer => (state, action) => { 678 if (state === undefined || isMatch(action)) { 679 return reducer(state, action); 680 } 681 682 return state; 683 }; 684 685 /* harmony default export */ var if_matching_action = (ifMatchingAction); 686 687 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js 688 /** 689 * Higher-order reducer creator which substitutes the action object before 690 * passing to the original reducer. 691 * 692 * @param {Function} replacer Function mapping original action to replacement. 693 * 694 * @return {Function} Higher-order reducer. 695 */ 696 const replaceAction = replacer => reducer => (state, action) => { 697 return reducer(state, replacer(action)); 698 }; 699 700 /* harmony default export */ var replace_action = (replaceAction); 701 702 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js 703 /** 704 * External dependencies 705 */ 706 707 /** 708 * Given the current and next item entity, returns the minimally "modified" 709 * result of the next item, preferring value references from the original item 710 * if equal. If all values match, the original item is returned. 711 * 712 * @param {Object} item Original item. 713 * @param {Object} nextItem Next item. 714 * 715 * @return {Object} Minimally modified merged item. 716 */ 717 718 function conservativeMapItem(item, nextItem) { 719 // Return next item in its entirety if there is no original item. 720 if (!item) { 721 return nextItem; 722 } 723 724 let hasChanges = false; 725 const result = {}; 726 727 for (const key in nextItem) { 728 if (Object(external_lodash_["isEqual"])(item[key], nextItem[key])) { 729 result[key] = item[key]; 730 } else { 731 hasChanges = true; 732 result[key] = nextItem[key]; 733 } 734 } 735 736 if (!hasChanges) { 737 return item; 738 } // Only at this point, backfill properties from the original item which 739 // weren't explicitly set into the result above. This is an optimization 740 // to allow `hasChanges` to return early. 741 742 743 for (const key in item) { 744 if (!result.hasOwnProperty(key)) { 745 result[key] = item[key]; 746 } 747 } 748 749 return result; 750 } 751 752 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js 753 /** 754 * Higher-order reducer creator which creates a combined reducer object, keyed 755 * by a property on the action object. 756 * 757 * @param {string} actionProperty Action property by which to key object. 758 * 759 * @return {Function} Higher-order reducer. 760 */ 761 const onSubKey = actionProperty => reducer => (state = {}, action) => { 762 // Retrieve subkey from action. Do not track if undefined; useful for cases 763 // where reducer is scoped by action shape. 764 const key = action[actionProperty]; 765 766 if (key === undefined) { 767 return state; 768 } // Avoid updating state if unchanged. Note that this also accounts for a 769 // reducer which returns undefined on a key which is not yet tracked. 770 771 772 const nextKeyState = reducer(state[key], action); 773 774 if (nextKeyState === state[key]) { 775 return state; 776 } 777 778 return { ...state, 779 [key]: nextKeyState 780 }; 781 }; 782 /* harmony default export */ var on_sub_key = (onSubKey); 783 784 // EXTERNAL MODULE: external ["wp","i18n"] 785 var external_wp_i18n_ = __webpack_require__("l3Sj"); 786 787 // EXTERNAL MODULE: ./node_modules/uuid/dist/esm-browser/v4.js + 4 modules 788 var v4 = __webpack_require__("7Cbv"); 789 790 // EXTERNAL MODULE: external ["wp","url"] 791 var external_wp_url_ = __webpack_require__("Mmq9"); 792 793 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js 794 /** 795 * External dependencies 796 */ 797 798 /** 799 * Returns an action object used in signalling that items have been received. 800 * 801 * @param {Array} items Items received. 802 * @param {?Object} edits Optional edits to reset. 803 * 804 * @return {Object} Action object. 805 */ 806 807 function receiveItems(items, edits) { 808 return { 809 type: 'RECEIVE_ITEMS', 810 items: Object(external_lodash_["castArray"])(items), 811 persistedEdits: edits 812 }; 813 } 814 /** 815 * Returns an action object used in signalling that entity records have been 816 * deleted and they need to be removed from entities state. 817 * 818 * @param {string} kind Kind of the removed entities. 819 * @param {string} name Name of the removed entities. 820 * @param {Array|number} records Record IDs of the removed entities. 821 * @param {boolean} invalidateCache Controls whether we want to invalidate the cache. 822 * @return {Object} Action object. 823 */ 824 825 function removeItems(kind, name, records, invalidateCache = false) { 826 return { 827 type: 'REMOVE_ITEMS', 828 itemIds: Object(external_lodash_["castArray"])(records), 829 kind, 830 name, 831 invalidateCache 832 }; 833 } 834 /** 835 * Returns an action object used in signalling that queried data has been 836 * received. 837 * 838 * @param {Array} items Queried items received. 839 * @param {?Object} query Optional query object. 840 * @param {?Object} edits Optional edits to reset. 841 * 842 * @return {Object} Action object. 843 */ 844 845 function receiveQueriedItems(items, query = {}, edits) { 846 return { ...receiveItems(items, edits), 847 query 848 }; 849 } 850 851 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/actions.js 852 /** 853 * WordPress dependencies 854 */ 855 856 857 function* __unstableAcquireStoreLock(store, path, { 858 exclusive 859 }) { 860 const promise = yield* __unstableEnqueueLockRequest(store, path, { 861 exclusive 862 }); 863 yield* __unstableProcessPendingLockRequests(); 864 return yield Object(external_wp_dataControls_["__unstableAwaitPromise"])(promise); 865 } 866 function* __unstableEnqueueLockRequest(store, path, { 867 exclusive 868 }) { 869 let notifyAcquired; 870 const promise = new Promise(resolve => { 871 notifyAcquired = resolve; 872 }); 873 yield { 874 type: 'ENQUEUE_LOCK_REQUEST', 875 request: { 876 store, 877 path, 878 exclusive, 879 notifyAcquired 880 } 881 }; 882 return promise; 883 } 884 function* __unstableReleaseStoreLock(lock) { 885 yield { 886 type: 'RELEASE_LOCK', 887 lock 888 }; 889 yield* __unstableProcessPendingLockRequests(); 890 } 891 function* __unstableProcessPendingLockRequests() { 892 yield { 893 type: 'PROCESS_PENDING_LOCK_REQUESTS' 894 }; 895 const lockRequests = yield external_wp_data_["controls"].select('core', '__unstableGetPendingLockRequests'); 896 897 for (const request of lockRequests) { 898 const { 899 store, 900 path, 901 exclusive, 902 notifyAcquired 903 } = request; 904 const isAvailable = yield external_wp_data_["controls"].select('core', '__unstableIsLockAvailable', store, path, { 905 exclusive 906 }); 907 908 if (isAvailable) { 909 const lock = { 910 store, 911 path, 912 exclusive 913 }; 914 yield { 915 type: 'GRANT_LOCK_REQUEST', 916 lock, 917 request 918 }; 919 notifyAcquired(lock); 920 } 921 } 922 } 923 924 // EXTERNAL MODULE: external ["wp","apiFetch"] 925 var external_wp_apiFetch_ = __webpack_require__("ywyh"); 926 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_); 927 928 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/default-processor.js 929 /** 930 * External dependencies 931 */ 932 933 /** 934 * WordPress dependencies 935 */ 936 937 938 /** 939 * Maximum number of requests to place in a single batch request. Obtained by 940 * sending a preflight OPTIONS request to /batch/v1/. 941 * 942 * @type {number?} 943 */ 944 945 let maxItems = null; 946 /** 947 * Default batch processor. Sends its input requests to /batch/v1. 948 * 949 * @param {Array} requests List of API requests to perform at once. 950 * 951 * @return {Promise} Promise that resolves to a list of objects containing 952 * either `output` (if that request was succesful) or `error` 953 * (if not ). 954 */ 955 956 async function defaultProcessor(requests) { 957 if (maxItems === null) { 958 const preflightResponse = await external_wp_apiFetch_default()({ 959 path: '/batch/v1', 960 method: 'OPTIONS' 961 }); 962 maxItems = preflightResponse.endpoints[0].args.requests.maxItems; 963 } 964 965 const results = []; 966 967 for (const batchRequests of Object(external_lodash_["chunk"])(requests, maxItems)) { 968 const batchResponse = await external_wp_apiFetch_default()({ 969 path: '/batch/v1', 970 method: 'POST', 971 data: { 972 validation: 'require-all-validate', 973 requests: batchRequests.map(request => ({ 974 path: request.path, 975 body: request.data, 976 // Rename 'data' to 'body'. 977 method: request.method, 978 headers: request.headers 979 })) 980 } 981 }); 982 let batchResults; 983 984 if (batchResponse.failed) { 985 batchResults = batchResponse.responses.map(response => ({ 986 error: response === null || response === void 0 ? void 0 : response.body 987 })); 988 } else { 989 batchResults = batchResponse.responses.map(response => { 990 const result = {}; 991 992 if (response.status >= 200 && response.status < 300) { 993 result.output = response.body; 994 } else { 995 result.error = response.body; 996 } 997 998 return result; 999 }); 1000 } 1001 1002 results.push(...batchResults); 1003 } 1004 1005 return results; 1006 } 1007 1008 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/create-batch.js 1009 /** 1010 * External dependencies 1011 */ 1012 1013 /** 1014 * Internal dependencies 1015 */ 1016 1017 1018 /** 1019 * Creates a batch, which can be used to combine multiple API requests into one 1020 * API request using the WordPress batch processing API (/v1/batch). 1021 * 1022 * ``` 1023 * const batch = createBatch(); 1024 * const dunePromise = batch.add( { 1025 * path: '/v1/books', 1026 * method: 'POST', 1027 * data: { title: 'Dune' } 1028 * } ); 1029 * const lotrPromise = batch.add( { 1030 * path: '/v1/books', 1031 * method: 'POST', 1032 * data: { title: 'Lord of the Rings' } 1033 * } ); 1034 * const isSuccess = await batch.run(); // Sends one POST to /v1/batch. 1035 * if ( isSuccess ) { 1036 * console.log( 1037 * 'Saved two books:', 1038 * await dunePromise, 1039 * await lotrPromise 1040 * ); 1041 * } 1042 * ``` 1043 * 1044 * @param {Function} [processor] Processor function. Can be used to replace the 1045 * default functionality which is to send an API 1046 * request to /v1/batch. Is given an array of 1047 * inputs and must return a promise that 1048 * resolves to an array of objects containing 1049 * either `output` or `error`. 1050 */ 1051 1052 function createBatch(processor = defaultProcessor) { 1053 let lastId = 0; 1054 let queue = []; 1055 const pending = new ObservableSet(); 1056 return { 1057 /** 1058 * Adds an input to the batch and returns a promise that is resolved or 1059 * rejected when the input is processed by `batch.run()`. 1060 * 1061 * You may also pass a thunk which allows inputs to be added 1062 * asychronously. 1063 * 1064 * ``` 1065 * // Both are allowed: 1066 * batch.add( { path: '/v1/books', ... } ); 1067 * batch.add( ( add ) => add( { path: '/v1/books', ... } ) ); 1068 * ``` 1069 * 1070 * If a thunk is passed, `batch.run()` will pause until either: 1071 * 1072 * - The thunk calls its `add` argument, or; 1073 * - The thunk returns a promise and that promise resolves, or; 1074 * - The thunk returns a non-promise. 1075 * 1076 * @param {any|Function} inputOrThunk Input to add or thunk to execute. 1077 1078 * @return {Promise|any} If given an input, returns a promise that 1079 * is resolved or rejected when the batch is 1080 * processed. If given a thunk, returns the return 1081 * value of that thunk. 1082 */ 1083 add(inputOrThunk) { 1084 const id = ++lastId; 1085 pending.add(id); 1086 1087 const add = input => new Promise((resolve, reject) => { 1088 queue.push({ 1089 input, 1090 resolve, 1091 reject 1092 }); 1093 pending.delete(id); 1094 }); 1095 1096 if (Object(external_lodash_["isFunction"])(inputOrThunk)) { 1097 return Promise.resolve(inputOrThunk(add)).finally(() => { 1098 pending.delete(id); 1099 }); 1100 } 1101 1102 return add(inputOrThunk); 1103 }, 1104 1105 /** 1106 * Runs the batch. This calls `batchProcessor` and resolves or rejects 1107 * all promises returned by `add()`. 1108 * 1109 * @return {Promise} A promise that resolves to a boolean that is true 1110 * if the processor returned no errors. 1111 */ 1112 async run() { 1113 if (pending.size) { 1114 await new Promise(resolve => { 1115 const unsubscribe = pending.subscribe(() => { 1116 if (!pending.size) { 1117 unsubscribe(); 1118 resolve(); 1119 } 1120 }); 1121 }); 1122 } 1123 1124 let results; 1125 1126 try { 1127 results = await processor(queue.map(({ 1128 input 1129 }) => input)); 1130 1131 if (results.length !== queue.length) { 1132 throw new Error('run: Array returned by processor must be same size as input array.'); 1133 } 1134 } catch (error) { 1135 for (const { 1136 reject 1137 } of queue) { 1138 reject(error); 1139 } 1140 1141 throw error; 1142 } 1143 1144 let isSuccess = true; 1145 1146 for (const [result, { 1147 resolve, 1148 reject 1149 }] of Object(external_lodash_["zip"])(results, queue)) { 1150 if (result !== null && result !== void 0 && result.error) { 1151 reject(result.error); 1152 isSuccess = false; 1153 } else { 1154 var _result$output; 1155 1156 resolve((_result$output = result === null || result === void 0 ? void 0 : result.output) !== null && _result$output !== void 0 ? _result$output : result); 1157 } 1158 } 1159 1160 queue = []; 1161 return isSuccess; 1162 } 1163 1164 }; 1165 } 1166 1167 class ObservableSet { 1168 constructor(...args) { 1169 this.set = new Set(...args); 1170 this.subscribers = new Set(); 1171 } 1172 1173 get size() { 1174 return this.set.size; 1175 } 1176 1177 add(...args) { 1178 this.set.add(...args); 1179 this.subscribers.forEach(subscriber => subscriber()); 1180 return this; 1181 } 1182 1183 delete(...args) { 1184 const isSuccess = this.set.delete(...args); 1185 this.subscribers.forEach(subscriber => subscriber()); 1186 return isSuccess; 1187 } 1188 1189 subscribe(subscriber) { 1190 this.subscribers.add(subscriber); 1191 return () => { 1192 this.subscribers.delete(subscriber); 1193 }; 1194 } 1195 1196 } 1197 1198 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/controls.js 1199 /** 1200 * WordPress dependencies 1201 */ 1202 1203 function regularFetch(url) { 1204 return { 1205 type: 'REGULAR_FETCH', 1206 url 1207 }; 1208 } 1209 function getDispatch() { 1210 return { 1211 type: 'GET_DISPATCH' 1212 }; 1213 } 1214 const controls = { 1215 async REGULAR_FETCH({ 1216 url 1217 }) { 1218 const { 1219 data 1220 } = await window.fetch(url).then(res => res.json()); 1221 return data; 1222 }, 1223 1224 GET_DISPATCH: Object(external_wp_data_["createRegistryControl"])(({ 1225 dispatch 1226 }) => () => dispatch) 1227 }; 1228 /* harmony default export */ var build_module_controls = (controls); 1229 1230 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/actions.js 1231 /** 1232 * External dependencies 1233 */ 1234 1235 1236 /** 1237 * WordPress dependencies 1238 */ 1239 1240 1241 1242 1243 /** 1244 * Internal dependencies 1245 */ 1246 1247 1248 1249 1250 1251 1252 /** 1253 * Returns an action object used in signalling that authors have been received. 1254 * 1255 * @param {string} queryID Query ID. 1256 * @param {Array|Object} users Users received. 1257 * 1258 * @return {Object} Action object. 1259 */ 1260 1261 function receiveUserQuery(queryID, users) { 1262 return { 1263 type: 'RECEIVE_USER_QUERY', 1264 users: Object(external_lodash_["castArray"])(users), 1265 queryID 1266 }; 1267 } 1268 /** 1269 * Returns an action used in signalling that the current user has been received. 1270 * 1271 * @param {Object} currentUser Current user object. 1272 * 1273 * @return {Object} Action object. 1274 */ 1275 1276 function receiveCurrentUser(currentUser) { 1277 return { 1278 type: 'RECEIVE_CURRENT_USER', 1279 currentUser 1280 }; 1281 } 1282 /** 1283 * Returns an action object used in adding new entities. 1284 * 1285 * @param {Array} entities Entities received. 1286 * 1287 * @return {Object} Action object. 1288 */ 1289 1290 function addEntities(entities) { 1291 return { 1292 type: 'ADD_ENTITIES', 1293 entities 1294 }; 1295 } 1296 /** 1297 * Returns an action object used in signalling that entity records have been received. 1298 * 1299 * @param {string} kind Kind of the received entity. 1300 * @param {string} name Name of the received entity. 1301 * @param {Array|Object} records Records received. 1302 * @param {?Object} query Query Object. 1303 * @param {?boolean} invalidateCache Should invalidate query caches. 1304 * @param {?Object} edits Edits to reset. 1305 * @return {Object} Action object. 1306 */ 1307 1308 function receiveEntityRecords(kind, name, records, query, invalidateCache = false, edits) { 1309 // Auto drafts should not have titles, but some plugins rely on them so we can't filter this 1310 // on the server. 1311 if (kind === 'postType') { 1312 records = Object(external_lodash_["castArray"])(records).map(record => record.status === 'auto-draft' ? { ...record, 1313 title: '' 1314 } : record); 1315 } 1316 1317 let action; 1318 1319 if (query) { 1320 action = receiveQueriedItems(records, query, edits); 1321 } else { 1322 action = receiveItems(records, edits); 1323 } 1324 1325 return { ...action, 1326 kind, 1327 name, 1328 invalidateCache 1329 }; 1330 } 1331 /** 1332 * Returns an action object used in signalling that the current theme has been received. 1333 * 1334 * @param {Object} currentTheme The current theme. 1335 * 1336 * @return {Object} Action object. 1337 */ 1338 1339 function receiveCurrentTheme(currentTheme) { 1340 return { 1341 type: 'RECEIVE_CURRENT_THEME', 1342 currentTheme 1343 }; 1344 } 1345 /** 1346 * Returns an action object used in signalling that the index has been received. 1347 * 1348 * @param {Object} themeSupports Theme support for the current theme. 1349 * 1350 * @return {Object} Action object. 1351 */ 1352 1353 function receiveThemeSupports(themeSupports) { 1354 return { 1355 type: 'RECEIVE_THEME_SUPPORTS', 1356 themeSupports 1357 }; 1358 } 1359 /** 1360 * Returns an action object used in signalling that the preview data for 1361 * a given URl has been received. 1362 * 1363 * @param {string} url URL to preview the embed for. 1364 * @param {*} preview Preview data. 1365 * 1366 * @return {Object} Action object. 1367 */ 1368 1369 function receiveEmbedPreview(url, preview) { 1370 return { 1371 type: 'RECEIVE_EMBED_PREVIEW', 1372 url, 1373 preview 1374 }; 1375 } 1376 /** 1377 * Action triggered to delete an entity record. 1378 * 1379 * @param {string} kind Kind of the deleted entity. 1380 * @param {string} name Name of the deleted entity. 1381 * @param {string} recordId Record ID of the deleted entity. 1382 * @param {?Object} query Special query parameters for the 1383 * DELETE API call. 1384 * @param {Object} [options] Delete options. 1385 * @param {Function} [options.__unstableFetch] Internal use only. Function to 1386 * call instead of `apiFetch()`. 1387 * Must return a control descriptor. 1388 */ 1389 1390 function* deleteEntityRecord(kind, name, recordId, query, { 1391 __unstableFetch = null 1392 } = {}) { 1393 const entities = yield getKindEntities(kind); 1394 const entity = Object(external_lodash_["find"])(entities, { 1395 kind, 1396 name 1397 }); 1398 let error; 1399 let deletedRecord = false; 1400 1401 if (!entity) { 1402 return; 1403 } 1404 1405 const lock = yield* __unstableAcquireStoreLock('core', ['entities', 'data', kind, name, recordId], { 1406 exclusive: true 1407 }); 1408 1409 try { 1410 yield { 1411 type: 'DELETE_ENTITY_RECORD_START', 1412 kind, 1413 name, 1414 recordId 1415 }; 1416 1417 try { 1418 let path = `${entity.baseURL}/${recordId}`; 1419 1420 if (query) { 1421 path = Object(external_wp_url_["addQueryArgs"])(path, query); 1422 } 1423 1424 const options = { 1425 path, 1426 method: 'DELETE' 1427 }; 1428 1429 if (__unstableFetch) { 1430 deletedRecord = yield Object(external_wp_dataControls_["__unstableAwaitPromise"])(__unstableFetch(options)); 1431 } else { 1432 deletedRecord = yield Object(external_wp_dataControls_["apiFetch"])(options); 1433 } 1434 1435 yield removeItems(kind, name, recordId, true); 1436 } catch (_error) { 1437 error = _error; 1438 } 1439 1440 yield { 1441 type: 'DELETE_ENTITY_RECORD_FINISH', 1442 kind, 1443 name, 1444 recordId, 1445 error 1446 }; 1447 return deletedRecord; 1448 } finally { 1449 yield* __unstableReleaseStoreLock(lock); 1450 } 1451 } 1452 /** 1453 * Returns an action object that triggers an 1454 * edit to an entity record. 1455 * 1456 * @param {string} kind Kind of the edited entity record. 1457 * @param {string} name Name of the edited entity record. 1458 * @param {number} recordId Record ID of the edited entity record. 1459 * @param {Object} edits The edits. 1460 * @param {Object} options Options for the edit. 1461 * @param {boolean} options.undoIgnore Whether to ignore the edit in undo history or not. 1462 * 1463 * @return {Object} Action object. 1464 */ 1465 1466 function* actions_editEntityRecord(kind, name, recordId, edits, options = {}) { 1467 const entity = yield external_wp_data_["controls"].select('core', 'getEntity', kind, name); 1468 1469 if (!entity) { 1470 throw new Error(`The entity being edited (${kind}, ${name}) does not have a loaded config.`); 1471 } 1472 1473 const { 1474 transientEdits = {}, 1475 mergedEdits = {} 1476 } = entity; 1477 const record = yield external_wp_data_["controls"].select('core', 'getRawEntityRecord', kind, name, recordId); 1478 const editedRecord = yield external_wp_data_["controls"].select('core', 'getEditedEntityRecord', kind, name, recordId); 1479 const edit = { 1480 kind, 1481 name, 1482 recordId, 1483 // Clear edits when they are equal to their persisted counterparts 1484 // so that the property is not considered dirty. 1485 edits: Object.keys(edits).reduce((acc, key) => { 1486 const recordValue = record[key]; 1487 const editedRecordValue = editedRecord[key]; 1488 const value = mergedEdits[key] ? { ...editedRecordValue, 1489 ...edits[key] 1490 } : edits[key]; 1491 acc[key] = Object(external_lodash_["isEqual"])(recordValue, value) ? undefined : value; 1492 return acc; 1493 }, {}), 1494 transientEdits 1495 }; 1496 return { 1497 type: 'EDIT_ENTITY_RECORD', 1498 ...edit, 1499 meta: { 1500 undo: !options.undoIgnore && { ...edit, 1501 // Send the current values for things like the first undo stack entry. 1502 edits: Object.keys(edits).reduce((acc, key) => { 1503 acc[key] = editedRecord[key]; 1504 return acc; 1505 }, {}) 1506 } 1507 } 1508 }; 1509 } 1510 /** 1511 * Action triggered to undo the last edit to 1512 * an entity record, if any. 1513 */ 1514 1515 function* undo() { 1516 const undoEdit = yield external_wp_data_["controls"].select('core', 'getUndoEdit'); 1517 1518 if (!undoEdit) { 1519 return; 1520 } 1521 1522 yield { 1523 type: 'EDIT_ENTITY_RECORD', 1524 ...undoEdit, 1525 meta: { 1526 isUndo: true 1527 } 1528 }; 1529 } 1530 /** 1531 * Action triggered to redo the last undoed 1532 * edit to an entity record, if any. 1533 */ 1534 1535 function* redo() { 1536 const redoEdit = yield external_wp_data_["controls"].select('core', 'getRedoEdit'); 1537 1538 if (!redoEdit) { 1539 return; 1540 } 1541 1542 yield { 1543 type: 'EDIT_ENTITY_RECORD', 1544 ...redoEdit, 1545 meta: { 1546 isRedo: true 1547 } 1548 }; 1549 } 1550 /** 1551 * Forces the creation of a new undo level. 1552 * 1553 * @return {Object} Action object. 1554 */ 1555 1556 function actions_unstableCreateUndoLevel() { 1557 return { 1558 type: 'CREATE_UNDO_LEVEL' 1559 }; 1560 } 1561 /** 1562 * Action triggered to save an entity record. 1563 * 1564 * @param {string} kind Kind of the received entity. 1565 * @param {string} name Name of the received entity. 1566 * @param {Object} record Record to be saved. 1567 * @param {Object} options Saving options. 1568 * @param {boolean} [options.isAutosave=false] Whether this is an autosave. 1569 * @param {Function} [options.__unstableFetch] Internal use only. Function to 1570 * call instead of `apiFetch()`. 1571 * Must return a control 1572 * descriptor. 1573 */ 1574 1575 function* saveEntityRecord(kind, name, record, { 1576 isAutosave = false, 1577 __unstableFetch = null 1578 } = {}) { 1579 const entities = yield getKindEntities(kind); 1580 const entity = Object(external_lodash_["find"])(entities, { 1581 kind, 1582 name 1583 }); 1584 1585 if (!entity) { 1586 return; 1587 } 1588 1589 const entityIdKey = entity.key || DEFAULT_ENTITY_KEY; 1590 const recordId = record[entityIdKey]; 1591 const lock = yield* __unstableAcquireStoreLock('core', ['entities', 'data', kind, name, recordId || Object(v4["a" /* default */])()], { 1592 exclusive: true 1593 }); 1594 1595 try { 1596 // Evaluate optimized edits. 1597 // (Function edits that should be evaluated on save to avoid expensive computations on every edit.) 1598 for (const [key, value] of Object.entries(record)) { 1599 if (typeof value === 'function') { 1600 const evaluatedValue = value(yield external_wp_data_["controls"].select('core', 'getEditedEntityRecord', kind, name, recordId)); 1601 yield actions_editEntityRecord(kind, name, recordId, { 1602 [key]: evaluatedValue 1603 }, { 1604 undoIgnore: true 1605 }); 1606 record[key] = evaluatedValue; 1607 } 1608 } 1609 1610 yield { 1611 type: 'SAVE_ENTITY_RECORD_START', 1612 kind, 1613 name, 1614 recordId, 1615 isAutosave 1616 }; 1617 let updatedRecord; 1618 let error; 1619 1620 try { 1621 const path = `${entity.baseURL}${recordId ? '/' + recordId : ''}`; 1622 const persistedRecord = yield external_wp_data_["controls"].select('core', 'getRawEntityRecord', kind, name, recordId); 1623 1624 if (isAutosave) { 1625 // Most of this autosave logic is very specific to posts. 1626 // This is fine for now as it is the only supported autosave, 1627 // but ideally this should all be handled in the back end, 1628 // so the client just sends and receives objects. 1629 const currentUser = yield external_wp_data_["controls"].select('core', 'getCurrentUser'); 1630 const currentUserId = currentUser ? currentUser.id : undefined; 1631 const autosavePost = yield external_wp_data_["controls"].select('core', 'getAutosave', persistedRecord.type, persistedRecord.id, currentUserId); // Autosaves need all expected fields to be present. 1632 // So we fallback to the previous autosave and then 1633 // to the actual persisted entity if the edits don't 1634 // have a value. 1635 1636 let data = { ...persistedRecord, 1637 ...autosavePost, 1638 ...record 1639 }; 1640 data = Object.keys(data).reduce((acc, key) => { 1641 if (['title', 'excerpt', 'content'].includes(key)) { 1642 // Edits should be the "raw" attribute values. 1643 acc[key] = Object(external_lodash_["get"])(data[key], 'raw', data[key]); 1644 } 1645 1646 return acc; 1647 }, { 1648 status: data.status === 'auto-draft' ? 'draft' : data.status 1649 }); 1650 const options = { 1651 path: `${path}/autosaves`, 1652 method: 'POST', 1653 data 1654 }; 1655 1656 if (__unstableFetch) { 1657 updatedRecord = yield Object(external_wp_dataControls_["__unstableAwaitPromise"])(__unstableFetch(options)); 1658 } else { 1659 updatedRecord = yield Object(external_wp_dataControls_["apiFetch"])(options); 1660 } // An autosave may be processed by the server as a regular save 1661 // when its update is requested by the author and the post had 1662 // draft or auto-draft status. 1663 1664 1665 if (persistedRecord.id === updatedRecord.id) { 1666 let newRecord = { ...persistedRecord, 1667 ...data, 1668 ...updatedRecord 1669 }; 1670 newRecord = Object.keys(newRecord).reduce((acc, key) => { 1671 // These properties are persisted in autosaves. 1672 if (['title', 'excerpt', 'content'].includes(key)) { 1673 // Edits should be the "raw" attribute values. 1674 acc[key] = Object(external_lodash_["get"])(newRecord[key], 'raw', newRecord[key]); 1675 } else if (key === 'status') { 1676 // Status is only persisted in autosaves when going from 1677 // "auto-draft" to "draft". 1678 acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status; 1679 } else { 1680 // These properties are not persisted in autosaves. 1681 acc[key] = Object(external_lodash_["get"])(persistedRecord[key], 'raw', persistedRecord[key]); 1682 } 1683 1684 return acc; 1685 }, {}); 1686 yield receiveEntityRecords(kind, name, newRecord, undefined, true); 1687 } else { 1688 yield receiveAutosaves(persistedRecord.id, updatedRecord); 1689 } 1690 } else { 1691 let edits = record; 1692 1693 if (entity.__unstablePrePersist) { 1694 edits = { ...edits, 1695 ...entity.__unstablePrePersist(persistedRecord, edits) 1696 }; 1697 } 1698 1699 const options = { 1700 path, 1701 method: recordId ? 'PUT' : 'POST', 1702 data: edits 1703 }; 1704 1705 if (__unstableFetch) { 1706 updatedRecord = yield Object(external_wp_dataControls_["__unstableAwaitPromise"])(__unstableFetch(options)); 1707 } else { 1708 updatedRecord = yield Object(external_wp_dataControls_["apiFetch"])(options); 1709 } 1710 1711 yield receiveEntityRecords(kind, name, updatedRecord, undefined, true, edits); 1712 } 1713 } catch (_error) { 1714 error = _error; 1715 } 1716 1717 yield { 1718 type: 'SAVE_ENTITY_RECORD_FINISH', 1719 kind, 1720 name, 1721 recordId, 1722 error, 1723 isAutosave 1724 }; 1725 return updatedRecord; 1726 } finally { 1727 yield* __unstableReleaseStoreLock(lock); 1728 } 1729 } 1730 /** 1731 * Runs multiple core-data actions at the same time using one API request. 1732 * 1733 * Example: 1734 * 1735 * ``` 1736 * const [ savedRecord, updatedRecord, deletedRecord ] = 1737 * await dispatch( 'core' ).__experimentalBatch( [ 1738 * ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ), 1739 * ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ), 1740 * ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ), 1741 * ] ); 1742 * ``` 1743 * 1744 * @param {Array} requests Array of functions which are invoked simultaneously. 1745 * Each function is passed an object containing 1746 * `saveEntityRecord`, `saveEditedEntityRecord`, and 1747 * `deleteEntityRecord`. 1748 * 1749 * @return {Promise} A promise that resolves to an array containing the return 1750 * values of each function given in `requests`. 1751 */ 1752 1753 function* __experimentalBatch(requests) { 1754 const batch = createBatch(); 1755 const dispatch = yield getDispatch(); 1756 const api = { 1757 saveEntityRecord(kind, name, record, options) { 1758 return batch.add(add => dispatch('core').saveEntityRecord(kind, name, record, { ...options, 1759 __unstableFetch: add 1760 })); 1761 }, 1762 1763 saveEditedEntityRecord(kind, name, recordId, options) { 1764 return batch.add(add => dispatch('core').saveEditedEntityRecord(kind, name, recordId, { ...options, 1765 __unstableFetch: add 1766 })); 1767 }, 1768 1769 deleteEntityRecord(kind, name, recordId, query, options) { 1770 return batch.add(add => dispatch('core').deleteEntityRecord(kind, name, recordId, query, { ...options, 1771 __unstableFetch: add 1772 })); 1773 } 1774 1775 }; 1776 const resultPromises = requests.map(request => request(api)); 1777 const [, ...results] = yield Object(external_wp_dataControls_["__unstableAwaitPromise"])(Promise.all([batch.run(), ...resultPromises])); 1778 return results; 1779 } 1780 /** 1781 * Action triggered to save an entity record's edits. 1782 * 1783 * @param {string} kind Kind of the entity. 1784 * @param {string} name Name of the entity. 1785 * @param {Object} recordId ID of the record. 1786 * @param {Object} options Saving options. 1787 */ 1788 1789 function* saveEditedEntityRecord(kind, name, recordId, options) { 1790 if (!(yield external_wp_data_["controls"].select('core', 'hasEditsForEntityRecord', kind, name, recordId))) { 1791 return; 1792 } 1793 1794 const edits = yield external_wp_data_["controls"].select('core', 'getEntityRecordNonTransientEdits', kind, name, recordId); 1795 const record = { 1796 id: recordId, 1797 ...edits 1798 }; 1799 return yield* saveEntityRecord(kind, name, record, options); 1800 } 1801 /** 1802 * Action triggered to save only specified properties for the entity. 1803 * 1804 * @param {string} kind Kind of the entity. 1805 * @param {string} name Name of the entity. 1806 * @param {Object} recordId ID of the record. 1807 * @param {Array} itemsToSave List of entity properties to save. 1808 * @param {Object} options Saving options. 1809 */ 1810 1811 function* __experimentalSaveSpecifiedEntityEdits(kind, name, recordId, itemsToSave, options) { 1812 if (!(yield external_wp_data_["controls"].select('core', 'hasEditsForEntityRecord', kind, name, recordId))) { 1813 return; 1814 } 1815 1816 const edits = yield external_wp_data_["controls"].select('core', 'getEntityRecordNonTransientEdits', kind, name, recordId); 1817 const editsToSave = {}; 1818 1819 for (const edit in edits) { 1820 if (itemsToSave.some(item => item === edit)) { 1821 editsToSave[edit] = edits[edit]; 1822 } 1823 } 1824 1825 return yield* saveEntityRecord(kind, name, editsToSave, options); 1826 } 1827 /** 1828 * Returns an action object used in signalling that Upload permissions have been received. 1829 * 1830 * @param {boolean} hasUploadPermissions Does the user have permission to upload files? 1831 * 1832 * @return {Object} Action object. 1833 */ 1834 1835 function receiveUploadPermissions(hasUploadPermissions) { 1836 return { 1837 type: 'RECEIVE_USER_PERMISSION', 1838 key: 'create/media', 1839 isAllowed: hasUploadPermissions 1840 }; 1841 } 1842 /** 1843 * Returns an action object used in signalling that the current user has 1844 * permission to perform an action on a REST resource. 1845 * 1846 * @param {string} key A key that represents the action and REST resource. 1847 * @param {boolean} isAllowed Whether or not the user can perform the action. 1848 * 1849 * @return {Object} Action object. 1850 */ 1851 1852 function receiveUserPermission(key, isAllowed) { 1853 return { 1854 type: 'RECEIVE_USER_PERMISSION', 1855 key, 1856 isAllowed 1857 }; 1858 } 1859 /** 1860 * Returns an action object used in signalling that the autosaves for a 1861 * post have been received. 1862 * 1863 * @param {number} postId The id of the post that is parent to the autosave. 1864 * @param {Array|Object} autosaves An array of autosaves or singular autosave object. 1865 * 1866 * @return {Object} Action object. 1867 */ 1868 1869 function receiveAutosaves(postId, autosaves) { 1870 return { 1871 type: 'RECEIVE_AUTOSAVES', 1872 postId, 1873 autosaves: Object(external_lodash_["castArray"])(autosaves) 1874 }; 1875 } 1876 1877 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js 1878 /** 1879 * External dependencies 1880 */ 1881 1882 /** 1883 * WordPress dependencies 1884 */ 1885 1886 1887 1888 1889 /** 1890 * Internal dependencies 1891 */ 1892 1893 1894 const DEFAULT_ENTITY_KEY = 'id'; 1895 const defaultEntities = [{ 1896 label: Object(external_wp_i18n_["__"])('Base'), 1897 name: '__unstableBase', 1898 kind: 'root', 1899 baseURL: '' 1900 }, { 1901 label: Object(external_wp_i18n_["__"])('Site'), 1902 name: 'site', 1903 kind: 'root', 1904 baseURL: '/wp/v2/settings', 1905 getTitle: record => { 1906 return Object(external_lodash_["get"])(record, ['title'], Object(external_wp_i18n_["__"])('Site Title')); 1907 } 1908 }, { 1909 label: Object(external_wp_i18n_["__"])('Post Type'), 1910 name: 'postType', 1911 kind: 'root', 1912 key: 'slug', 1913 baseURL: '/wp/v2/types', 1914 baseURLParams: { 1915 context: 'edit' 1916 } 1917 }, { 1918 name: 'media', 1919 kind: 'root', 1920 baseURL: '/wp/v2/media', 1921 baseURLParams: { 1922 context: 'edit' 1923 }, 1924 plural: 'mediaItems', 1925 label: Object(external_wp_i18n_["__"])('Media') 1926 }, { 1927 name: 'taxonomy', 1928 kind: 'root', 1929 key: 'slug', 1930 baseURL: '/wp/v2/taxonomies', 1931 baseURLParams: { 1932 context: 'edit' 1933 }, 1934 plural: 'taxonomies', 1935 label: Object(external_wp_i18n_["__"])('Taxonomy') 1936 }, { 1937 name: 'sidebar', 1938 kind: 'root', 1939 baseURL: '/wp/v2/sidebars', 1940 plural: 'sidebars', 1941 transientEdits: { 1942 blocks: true 1943 }, 1944 label: Object(external_wp_i18n_["__"])('Widget areas') 1945 }, { 1946 name: 'widget', 1947 kind: 'root', 1948 baseURL: '/wp/v2/widgets', 1949 baseURLParams: { 1950 context: 'edit' 1951 }, 1952 plural: 'widgets', 1953 transientEdits: { 1954 blocks: true 1955 }, 1956 label: Object(external_wp_i18n_["__"])('Widgets') 1957 }, { 1958 name: 'widgetType', 1959 kind: 'root', 1960 baseURL: '/wp/v2/widget-types', 1961 baseURLParams: { 1962 context: 'edit' 1963 }, 1964 plural: 'widgetTypes', 1965 label: Object(external_wp_i18n_["__"])('Widget types') 1966 }, { 1967 label: Object(external_wp_i18n_["__"])('User'), 1968 name: 'user', 1969 kind: 'root', 1970 baseURL: '/wp/v2/users', 1971 baseURLParams: { 1972 context: 'edit' 1973 }, 1974 plural: 'users' 1975 }, { 1976 name: 'comment', 1977 kind: 'root', 1978 baseURL: '/wp/v2/comments', 1979 baseURLParams: { 1980 context: 'edit' 1981 }, 1982 plural: 'comments', 1983 label: Object(external_wp_i18n_["__"])('Comment') 1984 }, { 1985 name: 'menu', 1986 kind: 'root', 1987 baseURL: '/__experimental/menus', 1988 baseURLParams: { 1989 context: 'edit' 1990 }, 1991 plural: 'menus', 1992 label: Object(external_wp_i18n_["__"])('Menu') 1993 }, { 1994 name: 'menuItem', 1995 kind: 'root', 1996 baseURL: '/__experimental/menu-items', 1997 baseURLParams: { 1998 context: 'edit' 1999 }, 2000 plural: 'menuItems', 2001 label: Object(external_wp_i18n_["__"])('Menu Item') 2002 }, { 2003 name: 'menuLocation', 2004 kind: 'root', 2005 baseURL: '/__experimental/menu-locations', 2006 baseURLParams: { 2007 context: 'edit' 2008 }, 2009 plural: 'menuLocations', 2010 label: Object(external_wp_i18n_["__"])('Menu Location'), 2011 key: 'name' 2012 }]; 2013 const kinds = [{ 2014 name: 'postType', 2015 loadEntities: loadPostTypeEntities 2016 }, { 2017 name: 'taxonomy', 2018 loadEntities: loadTaxonomyEntities 2019 }]; 2020 /** 2021 * Returns a function to be used to retrieve extra edits to apply before persisting a post type. 2022 * 2023 * @param {Object} persistedRecord Already persisted Post 2024 * @param {Object} edits Edits. 2025 * @return {Object} Updated edits. 2026 */ 2027 2028 const prePersistPostType = (persistedRecord, edits) => { 2029 const newEdits = {}; 2030 2031 if ((persistedRecord === null || persistedRecord === void 0 ? void 0 : persistedRecord.status) === 'auto-draft') { 2032 // Saving an auto-draft should create a draft by default. 2033 if (!edits.status && !newEdits.status) { 2034 newEdits.status = 'draft'; 2035 } // Fix the auto-draft default title. 2036 2037 2038 if ((!edits.title || edits.title === 'Auto Draft') && !newEdits.title && (!(persistedRecord !== null && persistedRecord !== void 0 && persistedRecord.title) || (persistedRecord === null || persistedRecord === void 0 ? void 0 : persistedRecord.title) === 'Auto Draft')) { 2039 newEdits.title = ''; 2040 } 2041 } 2042 2043 return newEdits; 2044 }; 2045 /** 2046 * Returns the list of post type entities. 2047 * 2048 * @return {Promise} Entities promise 2049 */ 2050 2051 function* loadPostTypeEntities() { 2052 const postTypes = yield Object(external_wp_dataControls_["apiFetch"])({ 2053 path: '/wp/v2/types?context=edit' 2054 }); 2055 return Object(external_lodash_["map"])(postTypes, (postType, name) => { 2056 const isTemplate = ['wp_template', 'wp_template_part'].includes(name); 2057 return { 2058 kind: 'postType', 2059 baseURL: '/wp/v2/' + postType.rest_base, 2060 baseURLParams: { 2061 context: 'edit' 2062 }, 2063 name, 2064 label: postType.labels.singular_name, 2065 transientEdits: { 2066 blocks: true, 2067 selection: true 2068 }, 2069 mergedEdits: { 2070 meta: true 2071 }, 2072 getTitle: record => { 2073 var _record$title; 2074 2075 return (record === null || record === void 0 ? void 0 : (_record$title = record.title) === null || _record$title === void 0 ? void 0 : _record$title.rendered) || (record === null || record === void 0 ? void 0 : record.title) || (isTemplate ? Object(external_lodash_["startCase"])(record.slug) : String(record.id)); 2076 }, 2077 __unstablePrePersist: isTemplate ? undefined : prePersistPostType, 2078 __unstable_rest_base: postType.rest_base 2079 }; 2080 }); 2081 } 2082 /** 2083 * Returns the list of the taxonomies entities. 2084 * 2085 * @return {Promise} Entities promise 2086 */ 2087 2088 2089 function* loadTaxonomyEntities() { 2090 const taxonomies = yield Object(external_wp_dataControls_["apiFetch"])({ 2091 path: '/wp/v2/taxonomies?context=edit' 2092 }); 2093 return Object(external_lodash_["map"])(taxonomies, (taxonomy, name) => { 2094 return { 2095 kind: 'taxonomy', 2096 baseURL: '/wp/v2/' + taxonomy.rest_base, 2097 baseURLParams: { 2098 context: 'edit' 2099 }, 2100 name, 2101 label: taxonomy.labels.singular_name 2102 }; 2103 }); 2104 } 2105 /** 2106 * Returns the entity's getter method name given its kind and name. 2107 * 2108 * @param {string} kind Entity kind. 2109 * @param {string} name Entity name. 2110 * @param {string} prefix Function prefix. 2111 * @param {boolean} usePlural Whether to use the plural form or not. 2112 * 2113 * @return {string} Method name 2114 */ 2115 2116 2117 const getMethodName = (kind, name, prefix = 'get', usePlural = false) => { 2118 const entity = Object(external_lodash_["find"])(defaultEntities, { 2119 kind, 2120 name 2121 }); 2122 const kindPrefix = kind === 'root' ? '' : Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(kind)); 2123 const nameSuffix = Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(name)) + (usePlural ? 's' : ''); 2124 const suffix = usePlural && entity.plural ? Object(external_lodash_["upperFirst"])(Object(external_lodash_["camelCase"])(entity.plural)) : nameSuffix; 2125 return `${prefix}${kindPrefix}${suffix}`; 2126 }; 2127 /** 2128 * Loads the kind entities into the store. 2129 * 2130 * @param {string} kind Kind 2131 * 2132 * @return {Array} Entities 2133 */ 2134 2135 function* getKindEntities(kind) { 2136 let entities = yield external_wp_data_["controls"].select('core', 'getEntitiesByKind', kind); 2137 2138 if (entities && entities.length !== 0) { 2139 return entities; 2140 } 2141 2142 const kindConfig = Object(external_lodash_["find"])(kinds, { 2143 name: kind 2144 }); 2145 2146 if (!kindConfig) { 2147 return []; 2148 } 2149 2150 entities = yield kindConfig.loadEntities(); 2151 yield addEntities(entities); 2152 return entities; 2153 } 2154 2155 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/get-normalized-comma-separable.js 2156 /** 2157 * Given a value which can be specified as one or the other of a comma-separated 2158 * string or an array, returns a value normalized to an array of strings, or 2159 * null if the value cannot be interpreted as either. 2160 * 2161 * @param {string|string[]|*} value 2162 * 2163 * @return {?(string[])} Normalized field value. 2164 */ 2165 function getNormalizedCommaSeparable(value) { 2166 if (typeof value === 'string') { 2167 return value.split(','); 2168 } else if (Array.isArray(value)) { 2169 return value; 2170 } 2171 2172 return null; 2173 } 2174 2175 /* harmony default export */ var get_normalized_comma_separable = (getNormalizedCommaSeparable); 2176 2177 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js 2178 /** 2179 * External dependencies 2180 */ 2181 2182 /** 2183 * Given a function, returns an enhanced function which caches the result and 2184 * tracks in WeakMap. The result is only cached if the original function is 2185 * passed a valid object-like argument (requirement for WeakMap key). 2186 * 2187 * @param {Function} fn Original function. 2188 * 2189 * @return {Function} Enhanced caching function. 2190 */ 2191 2192 function withWeakMapCache(fn) { 2193 const cache = new WeakMap(); 2194 return key => { 2195 let value; 2196 2197 if (cache.has(key)) { 2198 value = cache.get(key); 2199 } else { 2200 value = fn(key); // Can reach here if key is not valid for WeakMap, since `has` 2201 // will return false for invalid key. Since `set` will throw, 2202 // ensure that key is valid before setting into cache. 2203 2204 if (Object(external_lodash_["isObjectLike"])(key)) { 2205 cache.set(key, value); 2206 } 2207 } 2208 2209 return value; 2210 }; 2211 } 2212 2213 /* harmony default export */ var with_weak_map_cache = (withWeakMapCache); 2214 2215 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js 2216 /** 2217 * WordPress dependencies 2218 */ 2219 2220 /** 2221 * Internal dependencies 2222 */ 2223 2224 2225 /** 2226 * An object of properties describing a specific query. 2227 * 2228 * @typedef {Object} WPQueriedDataQueryParts 2229 * 2230 * @property {number} page The query page (1-based index, default 1). 2231 * @property {number} perPage Items per page for query (default 10). 2232 * @property {string} stableKey An encoded stable string of all non- 2233 * pagination, non-fields query parameters. 2234 * @property {?(string[])} fields Target subset of fields to derive from 2235 * item objects. 2236 * @property {?(number[])} include Specific item IDs to include. 2237 */ 2238 2239 /** 2240 * Given a query object, returns an object of parts, including pagination 2241 * details (`page` and `perPage`, or default values). All other properties are 2242 * encoded into a stable (idempotent) `stableKey` value. 2243 * 2244 * @param {Object} query Optional query object. 2245 * 2246 * @return {WPQueriedDataQueryParts} Query parts. 2247 */ 2248 2249 function getQueryParts(query) { 2250 /** 2251 * @type {WPQueriedDataQueryParts} 2252 */ 2253 const parts = { 2254 stableKey: '', 2255 page: 1, 2256 perPage: 10, 2257 fields: null, 2258 include: null, 2259 context: 'default' 2260 }; // Ensure stable key by sorting keys. Also more efficient for iterating. 2261 2262 const keys = Object.keys(query).sort(); 2263 2264 for (let i = 0; i < keys.length; i++) { 2265 const key = keys[i]; 2266 let value = query[key]; 2267 2268 switch (key) { 2269 case 'page': 2270 parts[key] = Number(value); 2271 break; 2272 2273 case 'per_page': 2274 parts.perPage = Number(value); 2275 break; 2276 2277 case 'include': 2278 parts.include = get_normalized_comma_separable(value).map(Number); 2279 break; 2280 2281 case 'context': 2282 parts.context = value; 2283 break; 2284 2285 default: 2286 // While in theory, we could exclude "_fields" from the stableKey 2287 // because two request with different fields have the same results 2288 // We're not able to ensure that because the server can decide to omit 2289 // fields from the response even if we explicitely asked for it. 2290 // Example: Asking for titles in posts without title support. 2291 if (key === '_fields') { 2292 parts.fields = get_normalized_comma_separable(value); // Make sure to normalize value for `stableKey` 2293 2294 value = parts.fields.join(); 2295 } // While it could be any deterministic string, for simplicity's 2296 // sake mimic querystring encoding for stable key. 2297 // 2298 // TODO: For consistency with PHP implementation, addQueryArgs 2299 // should accept a key value pair, which may optimize its 2300 // implementation for our use here, vs. iterating an object 2301 // with only a single key. 2302 2303 2304 parts.stableKey += (parts.stableKey ? '&' : '') + Object(external_wp_url_["addQueryArgs"])('', { 2305 [key]: value 2306 }).slice(1); 2307 } 2308 } 2309 2310 return parts; 2311 } 2312 /* harmony default export */ var get_query_parts = (with_weak_map_cache(getQueryParts)); 2313 2314 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js 2315 /** 2316 * External dependencies 2317 */ 2318 2319 /** 2320 * WordPress dependencies 2321 */ 2322 2323 2324 /** 2325 * Internal dependencies 2326 */ 2327 2328 2329 2330 2331 2332 function getContextFromAction(action) { 2333 const { 2334 query 2335 } = action; 2336 2337 if (!query) { 2338 return 'default'; 2339 } 2340 2341 const queryParts = get_query_parts(query); 2342 return queryParts.context; 2343 } 2344 /** 2345 * Returns a merged array of item IDs, given details of the received paginated 2346 * items. The array is sparse-like with `undefined` entries where holes exist. 2347 * 2348 * @param {?Array<number>} itemIds Original item IDs (default empty array). 2349 * @param {number[]} nextItemIds Item IDs to merge. 2350 * @param {number} page Page of items merged. 2351 * @param {number} perPage Number of items per page. 2352 * 2353 * @return {number[]} Merged array of item IDs. 2354 */ 2355 2356 2357 function getMergedItemIds(itemIds, nextItemIds, page, perPage) { 2358 const receivedAllIds = page === 1 && perPage === -1; 2359 2360 if (receivedAllIds) { 2361 return nextItemIds; 2362 } 2363 2364 const nextItemIdsStartIndex = (page - 1) * perPage; // If later page has already been received, default to the larger known 2365 // size of the existing array, else calculate as extending the existing. 2366 2367 const size = Math.max(itemIds.length, nextItemIdsStartIndex + nextItemIds.length); // Preallocate array since size is known. 2368 2369 const mergedItemIds = new Array(size); 2370 2371 for (let i = 0; i < size; i++) { 2372 // Preserve existing item ID except for subset of range of next items. 2373 const isInNextItemsRange = i >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + nextItemIds.length; 2374 mergedItemIds[i] = isInNextItemsRange ? nextItemIds[i - nextItemIdsStartIndex] : itemIds[i]; 2375 } 2376 2377 return mergedItemIds; 2378 } 2379 /** 2380 * Reducer tracking items state, keyed by ID. Items are assumed to be normal, 2381 * where identifiers are common across all queries. 2382 * 2383 * @param {Object} state Current state. 2384 * @param {Object} action Dispatched action. 2385 * 2386 * @return {Object} Next state. 2387 */ 2388 2389 function reducer_items(state = {}, action) { 2390 switch (action.type) { 2391 case 'RECEIVE_ITEMS': 2392 { 2393 const context = getContextFromAction(action); 2394 const key = action.key || DEFAULT_ENTITY_KEY; 2395 return { ...state, 2396 [context]: { ...state[context], 2397 ...action.items.reduce((accumulator, value) => { 2398 var _state$context; 2399 2400 const itemId = value[key]; 2401 accumulator[itemId] = conservativeMapItem(state === null || state === void 0 ? void 0 : (_state$context = state[context]) === null || _state$context === void 0 ? void 0 : _state$context[itemId], value); 2402 return accumulator; 2403 }, {}) 2404 } 2405 }; 2406 } 2407 2408 case 'REMOVE_ITEMS': 2409 return Object(external_lodash_["mapValues"])(state, contextState => Object(external_lodash_["omit"])(contextState, action.itemIds)); 2410 } 2411 2412 return state; 2413 } 2414 /** 2415 * Reducer tracking item completeness, keyed by ID. A complete item is one for 2416 * which all fields are known. This is used in supporting `_fields` queries, 2417 * where not all properties associated with an entity are necessarily returned. 2418 * In such cases, completeness is used as an indication of whether it would be 2419 * safe to use queried data for a non-`_fields`-limited request. 2420 * 2421 * @param {Object<string,boolean>} state Current state. 2422 * @param {Object} action Dispatched action. 2423 * 2424 * @return {Object<string,boolean>} Next state. 2425 */ 2426 2427 function itemIsComplete(state = {}, action) { 2428 switch (action.type) { 2429 case 'RECEIVE_ITEMS': 2430 { 2431 const context = getContextFromAction(action); 2432 const { 2433 query, 2434 key = DEFAULT_ENTITY_KEY 2435 } = action; // An item is considered complete if it is received without an associated 2436 // fields query. Ideally, this would be implemented in such a way where the 2437 // complete aggregate of all fields would satisfy completeness. Since the 2438 // fields are not consistent across all entity types, this would require 2439 // introspection on the REST schema for each entity to know which fields 2440 // compose a complete item for that entity. 2441 2442 const queryParts = query ? get_query_parts(query) : {}; 2443 const isCompleteQuery = !query || !Array.isArray(queryParts.fields); 2444 return { ...state, 2445 [context]: { ...state[context], 2446 ...action.items.reduce((result, item) => { 2447 var _state$context2; 2448 2449 const itemId = item[key]; // Defer to completeness if already assigned. Technically the 2450 // data may be outdated if receiving items for a field subset. 2451 2452 result[itemId] = (state === null || state === void 0 ? void 0 : (_state$context2 = state[context]) === null || _state$context2 === void 0 ? void 0 : _state$context2[itemId]) || isCompleteQuery; 2453 return result; 2454 }, {}) 2455 } 2456 }; 2457 } 2458 2459 case 'REMOVE_ITEMS': 2460 return Object(external_lodash_["mapValues"])(state, contextState => Object(external_lodash_["omit"])(contextState, action.itemIds)); 2461 } 2462 2463 return state; 2464 } 2465 /** 2466 * Reducer tracking queries state, keyed by stable query key. Each reducer 2467 * query object includes `itemIds` and `requestingPageByPerPage`. 2468 * 2469 * @param {Object} state Current state. 2470 * @param {Object} action Dispatched action. 2471 * 2472 * @return {Object} Next state. 2473 */ 2474 2475 const receiveQueries = Object(external_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on 2476 // an unhandled action. 2477 if_matching_action(action => 'query' in action), // Inject query parts into action for use both in `onSubKey` and reducer. 2478 replace_action(action => { 2479 // `ifMatchingAction` still passes on initialization, where state is 2480 // undefined and a query is not assigned. Avoid attempting to parse 2481 // parts. `onSubKey` will omit by lack of `stableKey`. 2482 if (action.query) { 2483 return { ...action, 2484 ...get_query_parts(action.query) 2485 }; 2486 } 2487 2488 return action; 2489 }), on_sub_key('context'), // Queries shape is shared, but keyed by query `stableKey` part. Original 2490 // reducer tracks only a single query object. 2491 on_sub_key('stableKey')])((state = null, action) => { 2492 const { 2493 type, 2494 page, 2495 perPage, 2496 key = DEFAULT_ENTITY_KEY 2497 } = action; 2498 2499 if (type !== 'RECEIVE_ITEMS') { 2500 return state; 2501 } 2502 2503 return getMergedItemIds(state || [], Object(external_lodash_["map"])(action.items, key), page, perPage); 2504 }); 2505 /** 2506 * Reducer tracking queries state. 2507 * 2508 * @param {Object} state Current state. 2509 * @param {Object} action Dispatched action. 2510 * 2511 * @return {Object} Next state. 2512 */ 2513 2514 const reducer_queries = (state = {}, action) => { 2515 switch (action.type) { 2516 case 'RECEIVE_ITEMS': 2517 return receiveQueries(state, action); 2518 2519 case 'REMOVE_ITEMS': 2520 const removedItems = action.itemIds.reduce((result, itemId) => { 2521 result[itemId] = true; 2522 return result; 2523 }, {}); 2524 return Object(external_lodash_["mapValues"])(state, contextQueries => { 2525 return Object(external_lodash_["mapValues"])(contextQueries, queryItems => { 2526 return Object(external_lodash_["filter"])(queryItems, queryId => { 2527 return !removedItems[queryId]; 2528 }); 2529 }); 2530 }); 2531 2532 default: 2533 return state; 2534 } 2535 }; 2536 2537 /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({ 2538 items: reducer_items, 2539 itemIsComplete, 2540 queries: reducer_queries 2541 })); 2542 2543 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/utils.js 2544 function deepCopyLocksTreePath(tree, path) { 2545 const newTree = { ...tree 2546 }; 2547 let currentNode = newTree; 2548 2549 for (const branchName of path) { 2550 currentNode.children = { ...currentNode.children, 2551 [branchName]: { 2552 locks: [], 2553 children: {}, 2554 ...currentNode.children[branchName] 2555 } 2556 }; 2557 currentNode = currentNode.children[branchName]; 2558 } 2559 2560 return newTree; 2561 } 2562 function getNode(tree, path) { 2563 let currentNode = tree; 2564 2565 for (const branchName of path) { 2566 const nextNode = currentNode.children[branchName]; 2567 2568 if (!nextNode) { 2569 return null; 2570 } 2571 2572 currentNode = nextNode; 2573 } 2574 2575 return currentNode; 2576 } 2577 function* iteratePath(tree, path) { 2578 let currentNode = tree; 2579 yield currentNode; 2580 2581 for (const branchName of path) { 2582 const nextNode = currentNode.children[branchName]; 2583 2584 if (!nextNode) { 2585 break; 2586 } 2587 2588 yield nextNode; 2589 currentNode = nextNode; 2590 } 2591 } 2592 function* iterateDescendants(node) { 2593 const stack = Object.values(node.children); 2594 2595 while (stack.length) { 2596 const childNode = stack.pop(); 2597 yield childNode; 2598 stack.push(...Object.values(childNode.children)); 2599 } 2600 } 2601 function hasConflictingLock({ 2602 exclusive 2603 }, locks) { 2604 if (exclusive && locks.length) { 2605 return true; 2606 } 2607 2608 if (!exclusive && locks.filter(lock => lock.exclusive).length) { 2609 return true; 2610 } 2611 2612 return false; 2613 } 2614 2615 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/reducer.js 2616 /** 2617 * Internal dependencies 2618 */ 2619 2620 const DEFAULT_STATE = { 2621 requests: [], 2622 tree: { 2623 locks: [], 2624 children: {} 2625 } 2626 }; 2627 /** 2628 * Reducer returning locks. 2629 * 2630 * @param {Object} state Current state. 2631 * @param {Object} action Dispatched action. 2632 * 2633 * @return {Object} Updated state. 2634 */ 2635 2636 function reducer_locks(state = DEFAULT_STATE, action) { 2637 switch (action.type) { 2638 case 'ENQUEUE_LOCK_REQUEST': 2639 { 2640 const { 2641 request 2642 } = action; 2643 return { ...state, 2644 requests: [request, ...state.requests] 2645 }; 2646 } 2647 2648 case 'GRANT_LOCK_REQUEST': 2649 { 2650 const { 2651 lock, 2652 request 2653 } = action; 2654 const { 2655 store, 2656 path 2657 } = request; 2658 const storePath = [store, ...path]; 2659 const newTree = deepCopyLocksTreePath(state.tree, storePath); 2660 const node = getNode(newTree, storePath); 2661 node.locks = [...node.locks, lock]; 2662 return { ...state, 2663 requests: state.requests.filter(r => r !== request), 2664 tree: newTree 2665 }; 2666 } 2667 2668 case 'RELEASE_LOCK': 2669 { 2670 const { 2671 lock 2672 } = action; 2673 const storePath = [lock.store, ...lock.path]; 2674 const newTree = deepCopyLocksTreePath(state.tree, storePath); 2675 const node = getNode(newTree, storePath); 2676 node.locks = node.locks.filter(l => l !== lock); 2677 return { ...state, 2678 tree: newTree 2679 }; 2680 } 2681 } 2682 2683 return state; 2684 } 2685 /* harmony default export */ var locks_reducer = (reducer_locks); 2686 2687 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/reducer.js 2688 /** 2689 * External dependencies 2690 */ 2691 2692 /** 2693 * WordPress dependencies 2694 */ 2695 2696 2697 2698 /** 2699 * Internal dependencies 2700 */ 2701 2702 2703 2704 2705 2706 /** 2707 * Reducer managing terms state. Keyed by taxonomy slug, the value is either 2708 * undefined (if no request has been made for given taxonomy), null (if a 2709 * request is in-flight for given taxonomy), or the array of terms for the 2710 * taxonomy. 2711 * 2712 * @param {Object} state Current state. 2713 * @param {Object} action Dispatched action. 2714 * 2715 * @return {Object} Updated state. 2716 */ 2717 2718 function terms(state = {}, action) { 2719 switch (action.type) { 2720 case 'RECEIVE_TERMS': 2721 return { ...state, 2722 [action.taxonomy]: action.terms 2723 }; 2724 } 2725 2726 return state; 2727 } 2728 /** 2729 * Reducer managing authors state. Keyed by id. 2730 * 2731 * @param {Object} state Current state. 2732 * @param {Object} action Dispatched action. 2733 * 2734 * @return {Object} Updated state. 2735 */ 2736 2737 function reducer_users(state = { 2738 byId: {}, 2739 queries: {} 2740 }, action) { 2741 switch (action.type) { 2742 case 'RECEIVE_USER_QUERY': 2743 return { 2744 byId: { ...state.byId, 2745 ...Object(external_lodash_["keyBy"])(action.users, 'id') 2746 }, 2747 queries: { ...state.queries, 2748 [action.queryID]: Object(external_lodash_["map"])(action.users, user => user.id) 2749 } 2750 }; 2751 } 2752 2753 return state; 2754 } 2755 /** 2756 * Reducer managing current user state. 2757 * 2758 * @param {Object} state Current state. 2759 * @param {Object} action Dispatched action. 2760 * 2761 * @return {Object} Updated state. 2762 */ 2763 2764 function reducer_currentUser(state = {}, action) { 2765 switch (action.type) { 2766 case 'RECEIVE_CURRENT_USER': 2767 return action.currentUser; 2768 } 2769 2770 return state; 2771 } 2772 /** 2773 * Reducer managing taxonomies. 2774 * 2775 * @param {Object} state Current state. 2776 * @param {Object} action Dispatched action. 2777 * 2778 * @return {Object} Updated state. 2779 */ 2780 2781 function reducer_taxonomies(state = [], action) { 2782 switch (action.type) { 2783 case 'RECEIVE_TAXONOMIES': 2784 return action.taxonomies; 2785 } 2786 2787 return state; 2788 } 2789 /** 2790 * Reducer managing the current theme. 2791 * 2792 * @param {string} state Current state. 2793 * @param {Object} action Dispatched action. 2794 * 2795 * @return {string} Updated state. 2796 */ 2797 2798 function currentTheme(state = undefined, action) { 2799 switch (action.type) { 2800 case 'RECEIVE_CURRENT_THEME': 2801 return action.currentTheme.stylesheet; 2802 } 2803 2804 return state; 2805 } 2806 /** 2807 * Reducer managing installed themes. 2808 * 2809 * @param {Object} state Current state. 2810 * @param {Object} action Dispatched action. 2811 * 2812 * @return {Object} Updated state. 2813 */ 2814 2815 function themes(state = {}, action) { 2816 switch (action.type) { 2817 case 'RECEIVE_CURRENT_THEME': 2818 return { ...state, 2819 [action.currentTheme.stylesheet]: action.currentTheme 2820 }; 2821 } 2822 2823 return state; 2824 } 2825 /** 2826 * Reducer managing theme supports data. 2827 * 2828 * @param {Object} state Current state. 2829 * @param {Object} action Dispatched action. 2830 * 2831 * @return {Object} Updated state. 2832 */ 2833 2834 function themeSupports(state = {}, action) { 2835 switch (action.type) { 2836 case 'RECEIVE_THEME_SUPPORTS': 2837 return { ...state, 2838 ...action.themeSupports 2839 }; 2840 } 2841 2842 return state; 2843 } 2844 /** 2845 * Higher Order Reducer for a given entity config. It supports: 2846 * 2847 * - Fetching 2848 * - Editing 2849 * - Saving 2850 * 2851 * @param {Object} entityConfig Entity config. 2852 * 2853 * @return {Function} Reducer. 2854 */ 2855 2856 function reducer_entity(entityConfig) { 2857 return Object(external_lodash_["flowRight"])([// Limit to matching action type so we don't attempt to replace action on 2858 // an unhandled action. 2859 if_matching_action(action => action.name && action.kind && action.name === entityConfig.name && action.kind === entityConfig.kind), // Inject the entity config into the action. 2860 replace_action(action => { 2861 return { ...action, 2862 key: entityConfig.key || DEFAULT_ENTITY_KEY 2863 }; 2864 })])(Object(external_wp_data_["combineReducers"])({ 2865 queriedData: reducer, 2866 edits: (state = {}, action) => { 2867 var _action$query$context, _action$query; 2868 2869 switch (action.type) { 2870 case 'RECEIVE_ITEMS': 2871 const context = (_action$query$context = action === null || action === void 0 ? void 0 : (_action$query = action.query) === null || _action$query === void 0 ? void 0 : _action$query.context) !== null && _action$query$context !== void 0 ? _action$query$context : 'default'; 2872 2873 if (context !== 'default') { 2874 return state; 2875 } 2876 2877 const nextState = { ...state 2878 }; 2879 2880 for (const record of action.items) { 2881 const recordId = record[action.key]; 2882 const edits = nextState[recordId]; 2883 2884 if (!edits) { 2885 continue; 2886 } 2887 2888 const nextEdits = Object.keys(edits).reduce((acc, key) => { 2889 // If the edited value is still different to the persisted value, 2890 // keep the edited value in edits. 2891 if ( // Edits are the "raw" attribute values, but records may have 2892 // objects with more properties, so we use `get` here for the 2893 // comparison. 2894 !Object(external_lodash_["isEqual"])(edits[key], Object(external_lodash_["get"])(record[key], 'raw', record[key])) && ( // Sometimes the server alters the sent value which means 2895 // we need to also remove the edits before the api request. 2896 !action.persistedEdits || !Object(external_lodash_["isEqual"])(edits[key], action.persistedEdits[key]))) { 2897 acc[key] = edits[key]; 2898 } 2899 2900 return acc; 2901 }, {}); 2902 2903 if (Object.keys(nextEdits).length) { 2904 nextState[recordId] = nextEdits; 2905 } else { 2906 delete nextState[recordId]; 2907 } 2908 } 2909 2910 return nextState; 2911 2912 case 'EDIT_ENTITY_RECORD': 2913 const nextEdits = { ...state[action.recordId], 2914 ...action.edits 2915 }; 2916 Object.keys(nextEdits).forEach(key => { 2917 // Delete cleared edits so that the properties 2918 // are not considered dirty. 2919 if (nextEdits[key] === undefined) { 2920 delete nextEdits[key]; 2921 } 2922 }); 2923 return { ...state, 2924 [action.recordId]: nextEdits 2925 }; 2926 } 2927 2928 return state; 2929 }, 2930 saving: (state = {}, action) => { 2931 switch (action.type) { 2932 case 'SAVE_ENTITY_RECORD_START': 2933 case 'SAVE_ENTITY_RECORD_FINISH': 2934 return { ...state, 2935 [action.recordId]: { 2936 pending: action.type === 'SAVE_ENTITY_RECORD_START', 2937 error: action.error, 2938 isAutosave: action.isAutosave 2939 } 2940 }; 2941 } 2942 2943 return state; 2944 }, 2945 deleting: (state = {}, action) => { 2946 switch (action.type) { 2947 case 'DELETE_ENTITY_RECORD_START': 2948 case 'DELETE_ENTITY_RECORD_FINISH': 2949 return { ...state, 2950 [action.recordId]: { 2951 pending: action.type === 'DELETE_ENTITY_RECORD_START', 2952 error: action.error 2953 } 2954 }; 2955 } 2956 2957 return state; 2958 } 2959 })); 2960 } 2961 /** 2962 * Reducer keeping track of the registered entities. 2963 * 2964 * @param {Object} state Current state. 2965 * @param {Object} action Dispatched action. 2966 * 2967 * @return {Object} Updated state. 2968 */ 2969 2970 2971 function entitiesConfig(state = defaultEntities, action) { 2972 switch (action.type) { 2973 case 'ADD_ENTITIES': 2974 return [...state, ...action.entities]; 2975 } 2976 2977 return state; 2978 } 2979 /** 2980 * Reducer keeping track of the registered entities config and data. 2981 * 2982 * @param {Object} state Current state. 2983 * @param {Object} action Dispatched action. 2984 * 2985 * @return {Object} Updated state. 2986 */ 2987 2988 const reducer_entities = (state = {}, action) => { 2989 const newConfig = entitiesConfig(state.config, action); // Generates a dynamic reducer for the entities 2990 2991 let entitiesDataReducer = state.reducer; 2992 2993 if (!entitiesDataReducer || newConfig !== state.config) { 2994 const entitiesByKind = Object(external_lodash_["groupBy"])(newConfig, 'kind'); 2995 entitiesDataReducer = Object(external_wp_data_["combineReducers"])(Object.entries(entitiesByKind).reduce((memo, [kind, subEntities]) => { 2996 const kindReducer = Object(external_wp_data_["combineReducers"])(subEntities.reduce((kindMemo, entityConfig) => ({ ...kindMemo, 2997 [entityConfig.name]: reducer_entity(entityConfig) 2998 }), {})); 2999 memo[kind] = kindReducer; 3000 return memo; 3001 }, {})); 3002 } 3003 3004 const newData = entitiesDataReducer(state.data, action); 3005 3006 if (newData === state.data && newConfig === state.config && entitiesDataReducer === state.reducer) { 3007 return state; 3008 } 3009 3010 return { 3011 reducer: entitiesDataReducer, 3012 data: newData, 3013 config: newConfig 3014 }; 3015 }; 3016 /** 3017 * Reducer keeping track of entity edit undo history. 3018 * 3019 * @param {Object} state Current state. 3020 * @param {Object} action Dispatched action. 3021 * 3022 * @return {Object} Updated state. 3023 */ 3024 3025 const UNDO_INITIAL_STATE = []; 3026 UNDO_INITIAL_STATE.offset = 0; 3027 let lastEditAction; 3028 function reducer_undo(state = UNDO_INITIAL_STATE, action) { 3029 switch (action.type) { 3030 case 'EDIT_ENTITY_RECORD': 3031 case 'CREATE_UNDO_LEVEL': 3032 let isCreateUndoLevel = action.type === 'CREATE_UNDO_LEVEL'; 3033 const isUndoOrRedo = !isCreateUndoLevel && (action.meta.isUndo || action.meta.isRedo); 3034 3035 if (isCreateUndoLevel) { 3036 action = lastEditAction; 3037 } else if (!isUndoOrRedo) { 3038 // Don't lose the last edit cache if the new one only has transient edits. 3039 // Transient edits don't create new levels so updating the cache would make 3040 // us skip an edit later when creating levels explicitly. 3041 if (Object.keys(action.edits).some(key => !action.transientEdits[key])) { 3042 lastEditAction = action; 3043 } else { 3044 lastEditAction = { ...action, 3045 edits: { ...(lastEditAction && lastEditAction.edits), 3046 ...action.edits 3047 } 3048 }; 3049 } 3050 } 3051 3052 let nextState; 3053 3054 if (isUndoOrRedo) { 3055 nextState = [...state]; 3056 nextState.offset = state.offset + (action.meta.isUndo ? -1 : 1); 3057 3058 if (state.flattenedUndo) { 3059 // The first undo in a sequence of undos might happen while we have 3060 // flattened undos in state. If this is the case, we want execution 3061 // to continue as if we were creating an explicit undo level. This 3062 // will result in an extra undo level being appended with the flattened 3063 // undo values. 3064 isCreateUndoLevel = true; 3065 action = lastEditAction; 3066 } else { 3067 return nextState; 3068 } 3069 } 3070 3071 if (!action.meta.undo) { 3072 return state; 3073 } // Transient edits don't create an undo level, but are 3074 // reachable in the next meaningful edit to which they 3075 // are merged. They are defined in the entity's config. 3076 3077 3078 if (!isCreateUndoLevel && !Object.keys(action.edits).some(key => !action.transientEdits[key])) { 3079 nextState = [...state]; 3080 nextState.flattenedUndo = { ...state.flattenedUndo, 3081 ...action.edits 3082 }; 3083 nextState.offset = state.offset; 3084 return nextState; 3085 } // Clear potential redos, because this only supports linear history. 3086 3087 3088 nextState = nextState || state.slice(0, state.offset || undefined); 3089 nextState.offset = nextState.offset || 0; 3090 nextState.pop(); 3091 3092 if (!isCreateUndoLevel) { 3093 nextState.push({ 3094 kind: action.meta.undo.kind, 3095 name: action.meta.undo.name, 3096 recordId: action.meta.undo.recordId, 3097 edits: { ...state.flattenedUndo, 3098 ...action.meta.undo.edits 3099 } 3100 }); 3101 } // When an edit is a function it's an optimization to avoid running some expensive operation. 3102 // We can't rely on the function references being the same so we opt out of comparing them here. 3103 3104 3105 const comparisonUndoEdits = Object.values(action.meta.undo.edits).filter(edit => typeof edit !== 'function'); 3106 const comparisonEdits = Object.values(action.edits).filter(edit => typeof edit !== 'function'); 3107 3108 if (!external_wp_isShallowEqual_default()(comparisonUndoEdits, comparisonEdits)) { 3109 nextState.push({ 3110 kind: action.kind, 3111 name: action.name, 3112 recordId: action.recordId, 3113 edits: isCreateUndoLevel ? { ...state.flattenedUndo, 3114 ...action.edits 3115 } : action.edits 3116 }); 3117 } 3118 3119 return nextState; 3120 } 3121 3122 return state; 3123 } 3124 /** 3125 * Reducer managing embed preview data. 3126 * 3127 * @param {Object} state Current state. 3128 * @param {Object} action Dispatched action. 3129 * 3130 * @return {Object} Updated state. 3131 */ 3132 3133 function embedPreviews(state = {}, action) { 3134 switch (action.type) { 3135 case 'RECEIVE_EMBED_PREVIEW': 3136 const { 3137 url, 3138 preview 3139 } = action; 3140 return { ...state, 3141 [url]: preview 3142 }; 3143 } 3144 3145 return state; 3146 } 3147 /** 3148 * State which tracks whether the user can perform an action on a REST 3149 * resource. 3150 * 3151 * @param {Object} state Current state. 3152 * @param {Object} action Dispatched action. 3153 * 3154 * @return {Object} Updated state. 3155 */ 3156 3157 function userPermissions(state = {}, action) { 3158 switch (action.type) { 3159 case 'RECEIVE_USER_PERMISSION': 3160 return { ...state, 3161 [action.key]: action.isAllowed 3162 }; 3163 } 3164 3165 return state; 3166 } 3167 /** 3168 * Reducer returning autosaves keyed by their parent's post id. 3169 * 3170 * @param {Object} state Current state. 3171 * @param {Object} action Dispatched action. 3172 * 3173 * @return {Object} Updated state. 3174 */ 3175 3176 function reducer_autosaves(state = {}, action) { 3177 switch (action.type) { 3178 case 'RECEIVE_AUTOSAVES': 3179 const { 3180 postId, 3181 autosaves: autosavesData 3182 } = action; 3183 return { ...state, 3184 [postId]: autosavesData 3185 }; 3186 } 3187 3188 return state; 3189 } 3190 /* harmony default export */ var build_module_reducer = (Object(external_wp_data_["combineReducers"])({ 3191 terms, 3192 users: reducer_users, 3193 currentTheme, 3194 currentUser: reducer_currentUser, 3195 taxonomies: reducer_taxonomies, 3196 themes, 3197 themeSupports, 3198 entities: reducer_entities, 3199 undo: reducer_undo, 3200 embedPreviews, 3201 userPermissions, 3202 autosaves: reducer_autosaves, 3203 locks: locks_reducer 3204 })); 3205 3206 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js 3207 var rememo = __webpack_require__("pPDe"); 3208 3209 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/name.js 3210 /** 3211 * The reducer key used by core data in store registration. 3212 * This is defined in a separate file to avoid cycle-dependency 3213 * 3214 * @type {string} 3215 */ 3216 const STORE_NAME = 'core'; 3217 3218 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js 3219 var equivalent_key_map = __webpack_require__("FtRg"); 3220 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map); 3221 3222 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js 3223 /** 3224 * External dependencies 3225 */ 3226 3227 3228 3229 /** 3230 * Internal dependencies 3231 */ 3232 3233 3234 /** 3235 * Cache of state keys to EquivalentKeyMap where the inner map tracks queries 3236 * to their resulting items set. WeakMap allows garbage collection on expired 3237 * state references. 3238 * 3239 * @type {WeakMap<Object,EquivalentKeyMap>} 3240 */ 3241 3242 const queriedItemsCacheByState = new WeakMap(); 3243 /** 3244 * Returns items for a given query, or null if the items are not known. 3245 * 3246 * @param {Object} state State object. 3247 * @param {?Object} query Optional query. 3248 * 3249 * @return {?Array} Query items. 3250 */ 3251 3252 function getQueriedItemsUncached(state, query) { 3253 var _state$queries, _state$queries$contex; 3254 3255 const { 3256 stableKey, 3257 page, 3258 perPage, 3259 include, 3260 fields, 3261 context 3262 } = get_query_parts(query); 3263 let itemIds; 3264 3265 if (Array.isArray(include) && !stableKey) { 3266 // If the parsed query yields a set of IDs, but otherwise no filtering, 3267 // it's safe to consider targeted item IDs as the include set. This 3268 // doesn't guarantee that those objects have been queried, which is 3269 // accounted for below in the loop `null` return. 3270 itemIds = include; // TODO: Avoid storing the empty stable string in reducer, since it 3271 // can be computed dynamically here always. 3272 } else if ((_state$queries = state.queries) !== null && _state$queries !== void 0 && (_state$queries$contex = _state$queries[context]) !== null && _state$queries$contex !== void 0 && _state$queries$contex[stableKey]) { 3273 itemIds = state.queries[context][stableKey]; 3274 } 3275 3276 if (!itemIds) { 3277 return null; 3278 } 3279 3280 const startOffset = perPage === -1 ? 0 : (page - 1) * perPage; 3281 const endOffset = perPage === -1 ? itemIds.length : Math.min(startOffset + perPage, itemIds.length); 3282 const items = []; 3283 3284 for (let i = startOffset; i < endOffset; i++) { 3285 var _state$items$context; 3286 3287 const itemId = itemIds[i]; 3288 3289 if (Array.isArray(include) && !include.includes(itemId)) { 3290 continue; 3291 } 3292 3293 if (!((_state$items$context = state.items[context]) !== null && _state$items$context !== void 0 && _state$items$context.hasOwnProperty(itemId))) { 3294 return null; 3295 } 3296 3297 const item = state.items[context][itemId]; 3298 let filteredItem; 3299 3300 if (Array.isArray(fields)) { 3301 filteredItem = {}; 3302 3303 for (let f = 0; f < fields.length; f++) { 3304 const field = fields[f].split('.'); 3305 const value = Object(external_lodash_["get"])(item, field); 3306 Object(external_lodash_["set"])(filteredItem, field, value); 3307 } 3308 } else { 3309 var _state$itemIsComplete; 3310 3311 // If expecting a complete item, validate that completeness, or 3312 // otherwise abort. 3313 if (!((_state$itemIsComplete = state.itemIsComplete[context]) !== null && _state$itemIsComplete !== void 0 && _state$itemIsComplete[itemId])) { 3314 return null; 3315 } 3316 3317 filteredItem = item; 3318 } 3319 3320 items.push(filteredItem); 3321 } 3322 3323 return items; 3324 } 3325 /** 3326 * Returns items for a given query, or null if the items are not known. Caches 3327 * result both per state (by reference) and per query (by deep equality). 3328 * The caching approach is intended to be durable to query objects which are 3329 * deeply but not referentially equal, since otherwise: 3330 * 3331 * `getQueriedItems( state, {} ) !== getQueriedItems( state, {} )` 3332 * 3333 * @param {Object} state State object. 3334 * @param {?Object} query Optional query. 3335 * 3336 * @return {?Array} Query items. 3337 */ 3338 3339 3340 const getQueriedItems = Object(rememo["a" /* default */])((state, query = {}) => { 3341 let queriedItemsCache = queriedItemsCacheByState.get(state); 3342 3343 if (queriedItemsCache) { 3344 const queriedItems = queriedItemsCache.get(query); 3345 3346 if (queriedItems !== undefined) { 3347 return queriedItems; 3348 } 3349 } else { 3350 queriedItemsCache = new equivalent_key_map_default.a(); 3351 queriedItemsCacheByState.set(state, queriedItemsCache); 3352 } 3353 3354 const items = getQueriedItemsUncached(state, query); 3355 queriedItemsCache.set(query, items); 3356 return items; 3357 }); 3358 3359 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/selectors.js 3360 /** 3361 * External dependencies 3362 */ 3363 3364 3365 /** 3366 * WordPress dependencies 3367 */ 3368 3369 3370 3371 /** 3372 * Internal dependencies 3373 */ 3374 3375 3376 3377 3378 3379 /** 3380 * Shared reference to an empty array for cases where it is important to avoid 3381 * returning a new array reference on every invocation, as in a connected or 3382 * other pure component which performs `shouldComponentUpdate` check on props. 3383 * This should be used as a last resort, since the normalized data should be 3384 * maintained by the reducer result in state. 3385 * 3386 * @type {Array} 3387 */ 3388 3389 const EMPTY_ARRAY = []; 3390 /** 3391 * Returns true if a request is in progress for embed preview data, or false 3392 * otherwise. 3393 * 3394 * @param {Object} state Data state. 3395 * @param {string} url URL the preview would be for. 3396 * 3397 * @return {boolean} Whether a request is in progress for an embed preview. 3398 */ 3399 3400 const isRequestingEmbedPreview = Object(external_wp_data_["createRegistrySelector"])(select => (state, url) => { 3401 return select('core/data').isResolving(STORE_NAME, 'getEmbedPreview', [url]); 3402 }); 3403 /** 3404 * Returns all available authors. 3405 * 3406 * @param {Object} state Data state. 3407 * @param {Object|undefined} query Optional object of query parameters to 3408 * include with request. 3409 * @return {Array} Authors list. 3410 */ 3411 3412 function getAuthors(state, query) { 3413 const path = Object(external_wp_url_["addQueryArgs"])('/wp/v2/users/?who=authors&per_page=100', query); 3414 return getUserQueryResults(state, path); 3415 } 3416 /** 3417 * Returns all available authors. 3418 * 3419 * @param {Object} state Data state. 3420 * @param {number} id The author id. 3421 * 3422 * @return {Array} Authors list. 3423 */ 3424 3425 function __unstableGetAuthor(state, id) { 3426 return Object(external_lodash_["get"])(state, ['users', 'byId', id], null); 3427 } 3428 /** 3429 * Returns the current user. 3430 * 3431 * @param {Object} state Data state. 3432 * 3433 * @return {Object} Current user object. 3434 */ 3435 3436 function getCurrentUser(state) { 3437 return state.currentUser; 3438 } 3439 /** 3440 * Returns all the users returned by a query ID. 3441 * 3442 * @param {Object} state Data state. 3443 * @param {string} queryID Query ID. 3444 * 3445 * @return {Array} Users list. 3446 */ 3447 3448 const getUserQueryResults = Object(rememo["a" /* default */])((state, queryID) => { 3449 const queryResults = state.users.queries[queryID]; 3450 return Object(external_lodash_["map"])(queryResults, id => state.users.byId[id]); 3451 }, (state, queryID) => [state.users.queries[queryID], state.users.byId]); 3452 /** 3453 * Returns whether the entities for the give kind are loaded. 3454 * 3455 * @param {Object} state Data state. 3456 * @param {string} kind Entity kind. 3457 * 3458 * @return {Array<Object>} Array of entities with config matching kind. 3459 */ 3460 3461 function getEntitiesByKind(state, kind) { 3462 return Object(external_lodash_["filter"])(state.entities.config, { 3463 kind 3464 }); 3465 } 3466 /** 3467 * Returns the entity object given its kind and name. 3468 * 3469 * @param {Object} state Data state. 3470 * @param {string} kind Entity kind. 3471 * @param {string} name Entity name. 3472 * 3473 * @return {Object} Entity 3474 */ 3475 3476 function getEntity(state, kind, name) { 3477 return Object(external_lodash_["find"])(state.entities.config, { 3478 kind, 3479 name 3480 }); 3481 } 3482 /** 3483 * Returns the Entity's record object by key. Returns `null` if the value is not 3484 * yet received, undefined if the value entity is known to not exist, or the 3485 * entity object if it exists and is received. 3486 * 3487 * @param {Object} state State tree 3488 * @param {string} kind Entity kind. 3489 * @param {string} name Entity name. 3490 * @param {number} key Record's key 3491 * @param {?Object} query Optional query. 3492 * 3493 * @return {Object?} Record. 3494 */ 3495 3496 function getEntityRecord(state, kind, name, key, query) { 3497 var _query$context, _queriedState$items$c; 3498 3499 const queriedState = Object(external_lodash_["get"])(state.entities.data, [kind, name, 'queriedData']); 3500 3501 if (!queriedState) { 3502 return undefined; 3503 } 3504 3505 const context = (_query$context = query === null || query === void 0 ? void 0 : query.context) !== null && _query$context !== void 0 ? _query$context : 'default'; 3506 3507 if (query === undefined) { 3508 var _queriedState$itemIsC; 3509 3510 // If expecting a complete item, validate that completeness. 3511 if (!((_queriedState$itemIsC = queriedState.itemIsComplete[context]) !== null && _queriedState$itemIsC !== void 0 && _queriedState$itemIsC[key])) { 3512 return undefined; 3513 } 3514 3515 return queriedState.items[context][key]; 3516 } 3517 3518 const item = (_queriedState$items$c = queriedState.items[context]) === null || _queriedState$items$c === void 0 ? void 0 : _queriedState$items$c[key]; 3519 3520 if (item && query._fields) { 3521 const filteredItem = {}; 3522 const fields = get_normalized_comma_separable(query._fields); 3523 3524 for (let f = 0; f < fields.length; f++) { 3525 const field = fields[f].split('.'); 3526 const value = Object(external_lodash_["get"])(item, field); 3527 Object(external_lodash_["set"])(filteredItem, field, value); 3528 } 3529 3530 return filteredItem; 3531 } 3532 3533 return item; 3534 } 3535 /** 3536 * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity from the API if the entity record isn't available in the local state. 3537 * 3538 * @param {Object} state State tree 3539 * @param {string} kind Entity kind. 3540 * @param {string} name Entity name. 3541 * @param {number} key Record's key 3542 * 3543 * @return {Object|null} Record. 3544 */ 3545 3546 function __experimentalGetEntityRecordNoResolver(state, kind, name, key) { 3547 return getEntityRecord(state, kind, name, key); 3548 } 3549 /** 3550 * Returns the entity's record object by key, 3551 * with its attributes mapped to their raw values. 3552 * 3553 * @param {Object} state State tree. 3554 * @param {string} kind Entity kind. 3555 * @param {string} name Entity name. 3556 * @param {number} key Record's key. 3557 * 3558 * @return {Object?} Object with the entity's raw attributes. 3559 */ 3560 3561 const getRawEntityRecord = Object(rememo["a" /* default */])((state, kind, name, key) => { 3562 const record = getEntityRecord(state, kind, name, key); 3563 return record && Object.keys(record).reduce((accumulator, _key) => { 3564 // Because edits are the "raw" attribute values, 3565 // we return those from record selectors to make rendering, 3566 // comparisons, and joins with edits easier. 3567 accumulator[_key] = Object(external_lodash_["get"])(record[_key], 'raw', record[_key]); 3568 return accumulator; 3569 }, {}); 3570 }, state => [state.entities.data]); 3571 /** 3572 * Returns true if records have been received for the given set of parameters, 3573 * or false otherwise. 3574 * 3575 * @param {Object} state State tree 3576 * @param {string} kind Entity kind. 3577 * @param {string} name Entity name. 3578 * @param {?Object} query Optional terms query. 3579 * 3580 * @return {boolean} Whether entity records have been received. 3581 */ 3582 3583 function hasEntityRecords(state, kind, name, query) { 3584 return Array.isArray(getEntityRecords(state, kind, name, query)); 3585 } 3586 /** 3587 * Returns the Entity's records. 3588 * 3589 * @param {Object} state State tree 3590 * @param {string} kind Entity kind. 3591 * @param {string} name Entity name. 3592 * @param {?Object} query Optional terms query. 3593 * 3594 * @return {?Array} Records. 3595 */ 3596 3597 function getEntityRecords(state, kind, name, query) { 3598 // Queried data state is prepopulated for all known entities. If this is not 3599 // assigned for the given parameters, then it is known to not exist. Thus, a 3600 // return value of an empty array is used instead of `null` (where `null` is 3601 // otherwise used to represent an unknown state). 3602 const queriedState = Object(external_lodash_["get"])(state.entities.data, [kind, name, 'queriedData']); 3603 3604 if (!queriedState) { 3605 return EMPTY_ARRAY; 3606 } 3607 3608 return getQueriedItems(queriedState, query); 3609 } 3610 /** 3611 * Returns the list of dirty entity records. 3612 * 3613 * @param {Object} state State tree. 3614 * 3615 * @return {[{ title: string, key: string, name: string, kind: string }]} The list of updated records 3616 */ 3617 3618 const __experimentalGetDirtyEntityRecords = Object(rememo["a" /* default */])(state => { 3619 const { 3620 entities: { 3621 data 3622 } 3623 } = state; 3624 const dirtyRecords = []; 3625 Object.keys(data).forEach(kind => { 3626 Object.keys(data[kind]).forEach(name => { 3627 const primaryKeys = Object.keys(data[kind][name].edits).filter(primaryKey => hasEditsForEntityRecord(state, kind, name, primaryKey)); 3628 3629 if (primaryKeys.length) { 3630 const entity = getEntity(state, kind, name); 3631 primaryKeys.forEach(primaryKey => { 3632 var _entity$getTitle; 3633 3634 const entityRecord = getEditedEntityRecord(state, kind, name, primaryKey); 3635 dirtyRecords.push({ 3636 // We avoid using primaryKey because it's transformed into a string 3637 // when it's used as an object key. 3638 key: entityRecord[entity.key || DEFAULT_ENTITY_KEY], 3639 title: (entity === null || entity === void 0 ? void 0 : (_entity$getTitle = entity.getTitle) === null || _entity$getTitle === void 0 ? void 0 : _entity$getTitle.call(entity, entityRecord)) || '', 3640 name, 3641 kind 3642 }); 3643 }); 3644 } 3645 }); 3646 }); 3647 return dirtyRecords; 3648 }, state => [state.entities.data]); 3649 /** 3650 * Returns the specified entity record's edits. 3651 * 3652 * @param {Object} state State tree. 3653 * @param {string} kind Entity kind. 3654 * @param {string} name Entity name. 3655 * @param {number} recordId Record ID. 3656 * 3657 * @return {Object?} The entity record's edits. 3658 */ 3659 3660 function getEntityRecordEdits(state, kind, name, recordId) { 3661 return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'edits', recordId]); 3662 } 3663 /** 3664 * Returns the specified entity record's non transient edits. 3665 * 3666 * Transient edits don't create an undo level, and 3667 * are not considered for change detection. 3668 * They are defined in the entity's config. 3669 * 3670 * @param {Object} state State tree. 3671 * @param {string} kind Entity kind. 3672 * @param {string} name Entity name. 3673 * @param {number} recordId Record ID. 3674 * 3675 * @return {Object?} The entity record's non transient edits. 3676 */ 3677 3678 const getEntityRecordNonTransientEdits = Object(rememo["a" /* default */])((state, kind, name, recordId) => { 3679 const { 3680 transientEdits 3681 } = getEntity(state, kind, name) || {}; 3682 const edits = getEntityRecordEdits(state, kind, name, recordId) || {}; 3683 3684 if (!transientEdits) { 3685 return edits; 3686 } 3687 3688 return Object.keys(edits).reduce((acc, key) => { 3689 if (!transientEdits[key]) { 3690 acc[key] = edits[key]; 3691 } 3692 3693 return acc; 3694 }, {}); 3695 }, state => [state.entities.config, state.entities.data]); 3696 /** 3697 * Returns true if the specified entity record has edits, 3698 * and false otherwise. 3699 * 3700 * @param {Object} state State tree. 3701 * @param {string} kind Entity kind. 3702 * @param {string} name Entity name. 3703 * @param {number} recordId Record ID. 3704 * 3705 * @return {boolean} Whether the entity record has edits or not. 3706 */ 3707 3708 function hasEditsForEntityRecord(state, kind, name, recordId) { 3709 return isSavingEntityRecord(state, kind, name, recordId) || Object.keys(getEntityRecordNonTransientEdits(state, kind, name, recordId)).length > 0; 3710 } 3711 /** 3712 * Returns the specified entity record, merged with its edits. 3713 * 3714 * @param {Object} state State tree. 3715 * @param {string} kind Entity kind. 3716 * @param {string} name Entity name. 3717 * @param {number} recordId Record ID. 3718 * 3719 * @return {Object?} The entity record, merged with its edits. 3720 */ 3721 3722 const getEditedEntityRecord = Object(rememo["a" /* default */])((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId), 3723 ...getEntityRecordEdits(state, kind, name, recordId) 3724 }), state => [state.entities.data]); 3725 /** 3726 * Returns true if the specified entity record is autosaving, and false otherwise. 3727 * 3728 * @param {Object} state State tree. 3729 * @param {string} kind Entity kind. 3730 * @param {string} name Entity name. 3731 * @param {number} recordId Record ID. 3732 * 3733 * @return {boolean} Whether the entity record is autosaving or not. 3734 */ 3735 3736 function isAutosavingEntityRecord(state, kind, name, recordId) { 3737 const { 3738 pending, 3739 isAutosave 3740 } = Object(external_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId], {}); 3741 return Boolean(pending && isAutosave); 3742 } 3743 /** 3744 * Returns true if the specified entity record is saving, and false otherwise. 3745 * 3746 * @param {Object} state State tree. 3747 * @param {string} kind Entity kind. 3748 * @param {string} name Entity name. 3749 * @param {number} recordId Record ID. 3750 * 3751 * @return {boolean} Whether the entity record is saving or not. 3752 */ 3753 3754 function isSavingEntityRecord(state, kind, name, recordId) { 3755 return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'pending'], false); 3756 } 3757 /** 3758 * Returns true if the specified entity record is deleting, and false otherwise. 3759 * 3760 * @param {Object} state State tree. 3761 * @param {string} kind Entity kind. 3762 * @param {string} name Entity name. 3763 * @param {number} recordId Record ID. 3764 * 3765 * @return {boolean} Whether the entity record is deleting or not. 3766 */ 3767 3768 function isDeletingEntityRecord(state, kind, name, recordId) { 3769 return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'deleting', recordId, 'pending'], false); 3770 } 3771 /** 3772 * Returns the specified entity record's last save error. 3773 * 3774 * @param {Object} state State tree. 3775 * @param {string} kind Entity kind. 3776 * @param {string} name Entity name. 3777 * @param {number} recordId Record ID. 3778 * 3779 * @return {Object?} The entity record's save error. 3780 */ 3781 3782 function getLastEntitySaveError(state, kind, name, recordId) { 3783 return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'saving', recordId, 'error']); 3784 } 3785 /** 3786 * Returns the specified entity record's last delete error. 3787 * 3788 * @param {Object} state State tree. 3789 * @param {string} kind Entity kind. 3790 * @param {string} name Entity name. 3791 * @param {number} recordId Record ID. 3792 * 3793 * @return {Object?} The entity record's save error. 3794 */ 3795 3796 function getLastEntityDeleteError(state, kind, name, recordId) { 3797 return Object(external_lodash_["get"])(state.entities.data, [kind, name, 'deleting', recordId, 'error']); 3798 } 3799 /** 3800 * Returns the current undo offset for the 3801 * entity records edits history. The offset 3802 * represents how many items from the end 3803 * of the history stack we are at. 0 is the 3804 * last edit, -1 is the second last, and so on. 3805 * 3806 * @param {Object} state State tree. 3807 * 3808 * @return {number} The current undo offset. 3809 */ 3810 3811 function getCurrentUndoOffset(state) { 3812 return state.undo.offset; 3813 } 3814 /** 3815 * Returns the previous edit from the current undo offset 3816 * for the entity records edits history, if any. 3817 * 3818 * @param {Object} state State tree. 3819 * 3820 * @return {Object?} The edit. 3821 */ 3822 3823 3824 function getUndoEdit(state) { 3825 return state.undo[state.undo.length - 2 + getCurrentUndoOffset(state)]; 3826 } 3827 /** 3828 * Returns the next edit from the current undo offset 3829 * for the entity records edits history, if any. 3830 * 3831 * @param {Object} state State tree. 3832 * 3833 * @return {Object?} The edit. 3834 */ 3835 3836 function getRedoEdit(state) { 3837 return state.undo[state.undo.length + getCurrentUndoOffset(state)]; 3838 } 3839 /** 3840 * Returns true if there is a previous edit from the current undo offset 3841 * for the entity records edits history, and false otherwise. 3842 * 3843 * @param {Object} state State tree. 3844 * 3845 * @return {boolean} Whether there is a previous edit or not. 3846 */ 3847 3848 function hasUndo(state) { 3849 return Boolean(getUndoEdit(state)); 3850 } 3851 /** 3852 * Returns true if there is a next edit from the current undo offset 3853 * for the entity records edits history, and false otherwise. 3854 * 3855 * @param {Object} state State tree. 3856 * 3857 * @return {boolean} Whether there is a next edit or not. 3858 */ 3859 3860 function hasRedo(state) { 3861 return Boolean(getRedoEdit(state)); 3862 } 3863 /** 3864 * Return the current theme. 3865 * 3866 * @param {Object} state Data state. 3867 * 3868 * @return {Object} The current theme. 3869 */ 3870 3871 function getCurrentTheme(state) { 3872 return state.themes[state.currentTheme]; 3873 } 3874 /** 3875 * Return theme supports data in the index. 3876 * 3877 * @param {Object} state Data state. 3878 * 3879 * @return {*} Index data. 3880 */ 3881 3882 function getThemeSupports(state) { 3883 return state.themeSupports; 3884 } 3885 /** 3886 * Returns the embed preview for the given URL. 3887 * 3888 * @param {Object} state Data state. 3889 * @param {string} url Embedded URL. 3890 * 3891 * @return {*} Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API. 3892 */ 3893 3894 function getEmbedPreview(state, url) { 3895 return state.embedPreviews[url]; 3896 } 3897 /** 3898 * Determines if the returned preview is an oEmbed link fallback. 3899 * 3900 * WordPress can be configured to return a simple link to a URL if it is not embeddable. 3901 * We need to be able to determine if a URL is embeddable or not, based on what we 3902 * get back from the oEmbed preview API. 3903 * 3904 * @param {Object} state Data state. 3905 * @param {string} url Embedded URL. 3906 * 3907 * @return {boolean} Is the preview for the URL an oEmbed link fallback. 3908 */ 3909 3910 function isPreviewEmbedFallback(state, url) { 3911 const preview = state.embedPreviews[url]; 3912 const oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>'; 3913 3914 if (!preview) { 3915 return false; 3916 } 3917 3918 return preview.html === oEmbedLinkCheck; 3919 } 3920 /** 3921 * Returns whether the current user can perform the given action on the given 3922 * REST resource. 3923 * 3924 * Calling this may trigger an OPTIONS request to the REST API via the 3925 * `canUser()` resolver. 3926 * 3927 * https://developer.wordpress.org/rest-api/reference/ 3928 * 3929 * @param {Object} state Data state. 3930 * @param {string} action Action to check. One of: 'create', 'read', 'update', 'delete'. 3931 * @param {string} resource REST resource to check, e.g. 'media' or 'posts'. 3932 * @param {string=} id Optional ID of the rest resource to check. 3933 * 3934 * @return {boolean|undefined} Whether or not the user can perform the action, 3935 * or `undefined` if the OPTIONS request is still being made. 3936 */ 3937 3938 function canUser(state, action, resource, id) { 3939 const key = Object(external_lodash_["compact"])([action, resource, id]).join('/'); 3940 return Object(external_lodash_["get"])(state, ['userPermissions', key]); 3941 } 3942 /** 3943 * Returns whether the current user can edit the given entity. 3944 * 3945 * Calling this may trigger an OPTIONS request to the REST API via the 3946 * `canUser()` resolver. 3947 * 3948 * https://developer.wordpress.org/rest-api/reference/ 3949 * 3950 * @param {Object} state Data state. 3951 * @param {string} kind Entity kind. 3952 * @param {string} name Entity name. 3953 * @param {string} recordId Record's id. 3954 * @return {boolean|undefined} Whether or not the user can edit, 3955 * or `undefined` if the OPTIONS request is still being made. 3956 */ 3957 3958 function canUserEditEntityRecord(state, kind, name, recordId) { 3959 const entity = getEntity(state, kind, name); 3960 3961 if (!entity) { 3962 return false; 3963 } 3964 3965 const resource = entity.__unstable_rest_base; 3966 return canUser(state, 'update', resource, recordId); 3967 } 3968 /** 3969 * Returns the latest autosaves for the post. 3970 * 3971 * May return multiple autosaves since the backend stores one autosave per 3972 * author for each post. 3973 * 3974 * @param {Object} state State tree. 3975 * @param {string} postType The type of the parent post. 3976 * @param {number} postId The id of the parent post. 3977 * 3978 * @return {?Array} An array of autosaves for the post, or undefined if there is none. 3979 */ 3980 3981 function getAutosaves(state, postType, postId) { 3982 return state.autosaves[postId]; 3983 } 3984 /** 3985 * Returns the autosave for the post and author. 3986 * 3987 * @param {Object} state State tree. 3988 * @param {string} postType The type of the parent post. 3989 * @param {number} postId The id of the parent post. 3990 * @param {number} authorId The id of the author. 3991 * 3992 * @return {?Object} The autosave for the post and author. 3993 */ 3994 3995 function getAutosave(state, postType, postId, authorId) { 3996 if (authorId === undefined) { 3997 return; 3998 } 3999 4000 const autosaves = state.autosaves[postId]; 4001 return Object(external_lodash_["find"])(autosaves, { 4002 author: authorId 4003 }); 4004 } 4005 /** 4006 * Returns true if the REST request for autosaves has completed. 4007 * 4008 * @param {Object} state State tree. 4009 * @param {string} postType The type of the parent post. 4010 * @param {number} postId The id of the parent post. 4011 * 4012 * @return {boolean} True if the REST request was completed. False otherwise. 4013 */ 4014 4015 const hasFetchedAutosaves = Object(external_wp_data_["createRegistrySelector"])(select => (state, postType, postId) => { 4016 return select(STORE_NAME).hasFinishedResolution('getAutosaves', [postType, postId]); 4017 }); 4018 /** 4019 * Returns a new reference when edited values have changed. This is useful in 4020 * inferring where an edit has been made between states by comparison of the 4021 * return values using strict equality. 4022 * 4023 * @example 4024 * 4025 * ``` 4026 * const hasEditOccurred = ( 4027 * getReferenceByDistinctEdits( beforeState ) !== 4028 * getReferenceByDistinctEdits( afterState ) 4029 * ); 4030 * ``` 4031 * 4032 * @param {Object} state Editor state. 4033 * 4034 * @return {*} A value whose reference will change only when an edit occurs. 4035 */ 4036 4037 const getReferenceByDistinctEdits = Object(rememo["a" /* default */])(() => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]); 4038 /** 4039 * Retrieve the frontend template used for a given link. 4040 * 4041 * @param {Object} state Editor state. 4042 * @param {string} link Link. 4043 * 4044 * @return {Object?} The template record. 4045 */ 4046 4047 function __experimentalGetTemplateForLink(state, link) { 4048 const records = getEntityRecords(state, 'postType', 'wp_template', { 4049 'find-template': link 4050 }); 4051 const template = records !== null && records !== void 0 && records.length ? records[0] : null; 4052 4053 if (template) { 4054 return getEditedEntityRecord(state, 'postType', 'wp_template', template.id); 4055 } 4056 4057 return template; 4058 } 4059 4060 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-not-resolved.js 4061 /** 4062 * WordPress dependencies 4063 */ 4064 4065 /** 4066 * Higher-order function which invokes the given resolver only if it has not 4067 * already been resolved with the arguments passed to the enhanced function. 4068 * 4069 * This only considers resolution state, and notably does not support resolver 4070 * custom `isFulfilled` behavior. 4071 * 4072 * @param {Function} resolver Original resolver. 4073 * @param {string} selectorName Selector name associated with resolver. 4074 * 4075 * @return {Function} Enhanced resolver. 4076 */ 4077 4078 const ifNotResolved = (resolver, selectorName) => 4079 /** 4080 * @param {...any} args Original resolver arguments. 4081 */ 4082 function* resolveIfNotResolved(...args) { 4083 const hasStartedResolution = yield external_wp_data_["controls"].select('core', 'hasStartedResolution', selectorName, args); 4084 4085 if (!hasStartedResolution) { 4086 yield* resolver(...args); 4087 } 4088 }; 4089 4090 /* harmony default export */ var if_not_resolved = (ifNotResolved); 4091 4092 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/resolvers.js 4093 /** 4094 * External dependencies 4095 */ 4096 4097 /** 4098 * WordPress dependencies 4099 */ 4100 4101 4102 4103 4104 /** 4105 * Internal dependencies 4106 */ 4107 4108 4109 /** 4110 * Internal dependencies 4111 */ 4112 4113 4114 4115 4116 4117 /** 4118 * Requests authors from the REST API. 4119 * 4120 * @param {Object|undefined} query Optional object of query parameters to 4121 * include with request. 4122 */ 4123 4124 function* resolvers_getAuthors(query) { 4125 const path = Object(external_wp_url_["addQueryArgs"])('/wp/v2/users/?who=authors&per_page=100', query); 4126 const users = yield Object(external_wp_dataControls_["apiFetch"])({ 4127 path 4128 }); 4129 yield receiveUserQuery(path, users); 4130 } 4131 /** 4132 * Temporary approach to resolving editor access to author queries. 4133 * 4134 * @param {number} id The author id. 4135 */ 4136 4137 function* resolvers_unstableGetAuthor(id) { 4138 const path = `/wp/v2/users?who=authors&include=${id}`; 4139 const users = yield Object(external_wp_dataControls_["apiFetch"])({ 4140 path 4141 }); 4142 yield receiveUserQuery('author', users); 4143 } 4144 /** 4145 * Requests the current user from the REST API. 4146 */ 4147 4148 function* resolvers_getCurrentUser() { 4149 const currentUser = yield Object(external_wp_dataControls_["apiFetch"])({ 4150 path: '/wp/v2/users/me' 4151 }); 4152 yield receiveCurrentUser(currentUser); 4153 } 4154 /** 4155 * Requests an entity's record from the REST API. 4156 * 4157 * @param {string} kind Entity kind. 4158 * @param {string} name Entity name. 4159 * @param {number|string} key Record's key 4160 * @param {Object|undefined} query Optional object of query parameters to 4161 * include with request. 4162 */ 4163 4164 function* resolvers_getEntityRecord(kind, name, key = '', query) { 4165 const entities = yield getKindEntities(kind); 4166 const entity = Object(external_lodash_["find"])(entities, { 4167 kind, 4168 name 4169 }); 4170 4171 if (!entity) { 4172 return; 4173 } 4174 4175 const lock = yield* __unstableAcquireStoreLock('core', ['entities', 'data', kind, name, key], { 4176 exclusive: false 4177 }); 4178 4179 try { 4180 if (query !== undefined && query._fields) { 4181 // If requesting specific fields, items and query assocation to said 4182 // records are stored by ID reference. Thus, fields must always include 4183 // the ID. 4184 query = { ...query, 4185 _fields: Object(external_lodash_["uniq"])([...(get_normalized_comma_separable(query._fields) || []), entity.key || DEFAULT_ENTITY_KEY]).join() 4186 }; 4187 } // Disable reason: While true that an early return could leave `path` 4188 // unused, it's important that path is derived using the query prior to 4189 // additional query modifications in the condition below, since those 4190 // modifications are relevant to how the data is tracked in state, and not 4191 // for how the request is made to the REST API. 4192 // eslint-disable-next-line @wordpress/no-unused-vars-before-return 4193 4194 4195 const path = Object(external_wp_url_["addQueryArgs"])(entity.baseURL + '/' + key, { ...entity.baseURLParams, 4196 ...query 4197 }); 4198 4199 if (query !== undefined) { 4200 query = { ...query, 4201 include: [key] 4202 }; // The resolution cache won't consider query as reusable based on the 4203 // fields, so it's tested here, prior to initiating the REST request, 4204 // and without causing `getEntityRecords` resolution to occur. 4205 4206 const hasRecords = yield external_wp_data_["controls"].select('core', 'hasEntityRecords', kind, name, query); 4207 4208 if (hasRecords) { 4209 return; 4210 } 4211 } 4212 4213 const record = yield Object(external_wp_dataControls_["apiFetch"])({ 4214 path 4215 }); 4216 yield receiveEntityRecords(kind, name, record, query); 4217 } catch (error) {// We need a way to handle and access REST API errors in state 4218 // Until then, catching the error ensures the resolver is marked as resolved. 4219 } finally { 4220 yield* __unstableReleaseStoreLock(lock); 4221 } 4222 } 4223 /** 4224 * Requests an entity's record from the REST API. 4225 */ 4226 4227 const resolvers_getRawEntityRecord = if_not_resolved(resolvers_getEntityRecord, 'getEntityRecord'); 4228 /** 4229 * Requests an entity's record from the REST API. 4230 */ 4231 4232 const resolvers_getEditedEntityRecord = if_not_resolved(resolvers_getRawEntityRecord, 'getRawEntityRecord'); 4233 /** 4234 * Requests the entity's records from the REST API. 4235 * 4236 * @param {string} kind Entity kind. 4237 * @param {string} name Entity name. 4238 * @param {Object?} query Query Object. 4239 */ 4240 4241 function* resolvers_getEntityRecords(kind, name, query = {}) { 4242 const entities = yield getKindEntities(kind); 4243 const entity = Object(external_lodash_["find"])(entities, { 4244 kind, 4245 name 4246 }); 4247 4248 if (!entity) { 4249 return; 4250 } 4251 4252 const lock = yield* __unstableAcquireStoreLock('core', ['entities', 'data', kind, name], { 4253 exclusive: false 4254 }); 4255 4256 try { 4257 var _query; 4258 4259 if (query._fields) { 4260 // If requesting specific fields, items and query assocation to said 4261 // records are stored by ID reference. Thus, fields must always include 4262 // the ID. 4263 query = { ...query, 4264 _fields: Object(external_lodash_["uniq"])([...(get_normalized_comma_separable(query._fields) || []), entity.key || DEFAULT_ENTITY_KEY]).join() 4265 }; 4266 } 4267 4268 const path = Object(external_wp_url_["addQueryArgs"])(entity.baseURL, { ...entity.baseURLParams, 4269 ...query 4270 }); 4271 let records = Object.values(yield Object(external_wp_dataControls_["apiFetch"])({ 4272 path 4273 })); // If we request fields but the result doesn't contain the fields, 4274 // explicitely set these fields as "undefined" 4275 // that way we consider the query "fullfilled". 4276 4277 if (query._fields) { 4278 records = records.map(record => { 4279 query._fields.split(',').forEach(field => { 4280 if (!record.hasOwnProperty(field)) { 4281 record[field] = undefined; 4282 } 4283 }); 4284 4285 return record; 4286 }); 4287 } 4288 4289 yield receiveEntityRecords(kind, name, records, query); // When requesting all fields, the list of results can be used to 4290 // resolve the `getEntityRecord` selector in addition to `getEntityRecords`. 4291 // See https://github.com/WordPress/gutenberg/pull/26575 4292 4293 if (!((_query = query) !== null && _query !== void 0 && _query._fields) && !query.context) { 4294 const key = entity.key || DEFAULT_ENTITY_KEY; 4295 const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, record[key]]); 4296 yield { 4297 type: 'START_RESOLUTIONS', 4298 selectorName: 'getEntityRecord', 4299 args: resolutionsArgs 4300 }; 4301 yield { 4302 type: 'FINISH_RESOLUTIONS', 4303 selectorName: 'getEntityRecord', 4304 args: resolutionsArgs 4305 }; 4306 } 4307 } finally { 4308 yield* __unstableReleaseStoreLock(lock); 4309 } 4310 } 4311 4312 resolvers_getEntityRecords.shouldInvalidate = (action, kind, name) => { 4313 return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && kind === action.kind && name === action.name; 4314 }; 4315 /** 4316 * Requests the current theme. 4317 */ 4318 4319 4320 function* resolvers_getCurrentTheme() { 4321 const activeThemes = yield Object(external_wp_dataControls_["apiFetch"])({ 4322 path: '/wp/v2/themes?status=active' 4323 }); 4324 yield receiveCurrentTheme(activeThemes[0]); 4325 } 4326 /** 4327 * Requests theme supports data from the index. 4328 */ 4329 4330 function* resolvers_getThemeSupports() { 4331 const activeThemes = yield Object(external_wp_dataControls_["apiFetch"])({ 4332 path: '/wp/v2/themes?status=active' 4333 }); 4334 yield receiveThemeSupports(activeThemes[0].theme_supports); 4335 } 4336 /** 4337 * Requests a preview from the from the Embed API. 4338 * 4339 * @param {string} url URL to get the preview for. 4340 */ 4341 4342 function* resolvers_getEmbedPreview(url) { 4343 try { 4344 const embedProxyResponse = yield Object(external_wp_dataControls_["apiFetch"])({ 4345 path: Object(external_wp_url_["addQueryArgs"])('/oembed/1.0/proxy', { 4346 url 4347 }) 4348 }); 4349 yield receiveEmbedPreview(url, embedProxyResponse); 4350 } catch (error) { 4351 // Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here. 4352 yield receiveEmbedPreview(url, false); 4353 } 4354 } 4355 /** 4356 * Checks whether the current user can perform the given action on the given 4357 * REST resource. 4358 * 4359 * @param {string} action Action to check. One of: 'create', 'read', 'update', 4360 * 'delete'. 4361 * @param {string} resource REST resource to check, e.g. 'media' or 'posts'. 4362 * @param {?string} id ID of the rest resource to check. 4363 */ 4364 4365 function* resolvers_canUser(action, resource, id) { 4366 const methods = { 4367 create: 'POST', 4368 read: 'GET', 4369 update: 'PUT', 4370 delete: 'DELETE' 4371 }; 4372 const method = methods[action]; 4373 4374 if (!method) { 4375 throw new Error(`'${action}' is not a valid action.`); 4376 } 4377 4378 const path = id ? `/wp/v2/${resource}/${id}` : `/wp/v2/${resource}`; 4379 let response; 4380 4381 try { 4382 response = yield Object(external_wp_dataControls_["apiFetch"])({ 4383 path, 4384 // Ideally this would always be an OPTIONS request, but unfortunately there's 4385 // a bug in the REST API which causes the Allow header to not be sent on 4386 // OPTIONS requests to /posts/:id routes. 4387 // https://core.trac.wordpress.org/ticket/45753 4388 method: id ? 'GET' : 'OPTIONS', 4389 parse: false 4390 }); 4391 } catch (error) { 4392 // Do nothing if our OPTIONS request comes back with an API error (4xx or 4393 // 5xx). The previously determined isAllowed value will remain in the store. 4394 return; 4395 } 4396 4397 let allowHeader; 4398 4399 if (Object(external_lodash_["hasIn"])(response, ['headers', 'get'])) { 4400 // If the request is fetched using the fetch api, the header can be 4401 // retrieved using the 'get' method. 4402 allowHeader = response.headers.get('allow'); 4403 } else { 4404 // If the request was preloaded server-side and is returned by the 4405 // preloading middleware, the header will be a simple property. 4406 allowHeader = Object(external_lodash_["get"])(response, ['headers', 'Allow'], ''); 4407 } 4408 4409 const key = Object(external_lodash_["compact"])([action, resource, id]).join('/'); 4410 const isAllowed = Object(external_lodash_["includes"])(allowHeader, method); 4411 yield receiveUserPermission(key, isAllowed); 4412 } 4413 /** 4414 * Checks whether the current user can perform the given action on the given 4415 * REST resource. 4416 * 4417 * @param {string} kind Entity kind. 4418 * @param {string} name Entity name. 4419 * @param {string} recordId Record's id. 4420 */ 4421 4422 function* resolvers_canUserEditEntityRecord(kind, name, recordId) { 4423 const entities = yield getKindEntities(kind); 4424 const entity = Object(external_lodash_["find"])(entities, { 4425 kind, 4426 name 4427 }); 4428 4429 if (!entity) { 4430 return; 4431 } 4432 4433 const resource = entity.__unstable_rest_base; 4434 yield resolvers_canUser('update', resource, recordId); 4435 } 4436 /** 4437 * Request autosave data from the REST API. 4438 * 4439 * @param {string} postType The type of the parent post. 4440 * @param {number} postId The id of the parent post. 4441 */ 4442 4443 function* resolvers_getAutosaves(postType, postId) { 4444 const { 4445 rest_base: restBase 4446 } = yield external_wp_data_["controls"].resolveSelect('core', 'getPostType', postType); 4447 const autosaves = yield Object(external_wp_dataControls_["apiFetch"])({ 4448 path: `/wp/v2/${restBase}/${postId}/autosaves?context=edit` 4449 }); 4450 4451 if (autosaves && autosaves.length) { 4452 yield receiveAutosaves(postId, autosaves); 4453 } 4454 } 4455 /** 4456 * Request autosave data from the REST API. 4457 * 4458 * This resolver exists to ensure the underlying autosaves are fetched via 4459 * `getAutosaves` when a call to the `getAutosave` selector is made. 4460 * 4461 * @param {string} postType The type of the parent post. 4462 * @param {number} postId The id of the parent post. 4463 */ 4464 4465 function* resolvers_getAutosave(postType, postId) { 4466 yield external_wp_data_["controls"].resolveSelect('core', 'getAutosaves', postType, postId); 4467 } 4468 /** 4469 * Retrieve the frontend template used for a given link. 4470 * 4471 * @param {string} link Link. 4472 */ 4473 4474 function* resolvers_experimentalGetTemplateForLink(link) { 4475 // Ideally this should be using an apiFetch call 4476 // We could potentially do so by adding a "filter" to the `wp_template` end point. 4477 // Also it seems the returned object is not a regular REST API post type. 4478 let template; 4479 4480 try { 4481 template = yield regularFetch(Object(external_wp_url_["addQueryArgs"])(link, { 4482 '_wp-find-template': true 4483 })); 4484 } catch (e) {// For non-FSE themes, it is possible that this request returns an error. 4485 } 4486 4487 if (!template) { 4488 return; 4489 } 4490 4491 yield resolvers_getEntityRecord('postType', 'wp_template', template.id); 4492 const record = yield external_wp_data_["controls"].select('core', 'getEntityRecord', 'postType', 'wp_template', template.id); 4493 4494 if (record) { 4495 yield receiveEntityRecords('postType', 'wp_template', [record], { 4496 'find-template': link 4497 }); 4498 } 4499 } 4500 4501 resolvers_experimentalGetTemplateForLink.shouldInvalidate = action => { 4502 return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && action.kind === 'postType' && action.name === 'wp_template'; 4503 }; 4504 4505 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/selectors.js 4506 /** 4507 * Internal dependencies 4508 */ 4509 4510 function __unstableGetPendingLockRequests(state) { 4511 return state.locks.requests; 4512 } 4513 function __unstableIsLockAvailable(state, store, path, { 4514 exclusive 4515 }) { 4516 const storePath = [store, ...path]; 4517 const locks = state.locks.tree; // Validate all parents and the node itself 4518 4519 for (const node of iteratePath(locks, storePath)) { 4520 if (hasConflictingLock({ 4521 exclusive 4522 }, node.locks)) { 4523 return false; 4524 } 4525 } // iteratePath terminates early if path is unreachable, let's 4526 // re-fetch the node and check it exists in the tree. 4527 4528 4529 const node = getNode(locks, storePath); 4530 4531 if (!node) { 4532 return true; 4533 } // Validate all nested nodes 4534 4535 4536 for (const descendant of iterateDescendants(node)) { 4537 if (hasConflictingLock({ 4538 exclusive 4539 }, descendant.locks)) { 4540 return false; 4541 } 4542 } 4543 4544 return true; 4545 } 4546 4547 // EXTERNAL MODULE: external ["wp","element"] 4548 var external_wp_element_ = __webpack_require__("GRId"); 4549 4550 // EXTERNAL MODULE: external ["wp","blocks"] 4551 var external_wp_blocks_ = __webpack_require__("HSyU"); 4552 4553 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entity-provider.js 4554 4555 4556 /** 4557 * WordPress dependencies 4558 */ 4559 4560 4561 4562 const entity_provider_EMPTY_ARRAY = []; 4563 /** 4564 * Internal dependencies 4565 */ 4566 4567 4568 const entity_provider_entities = { ...defaultEntities.reduce((acc, entity) => { 4569 if (!acc[entity.kind]) { 4570 acc[entity.kind] = {}; 4571 } 4572 4573 acc[entity.kind][entity.name] = { 4574 context: Object(external_wp_element_["createContext"])() 4575 }; 4576 return acc; 4577 }, {}), 4578 ...kinds.reduce((acc, kind) => { 4579 acc[kind.name] = {}; 4580 return acc; 4581 }, {}) 4582 }; 4583 4584 const entity_provider_getEntity = (kind, type) => { 4585 if (!entity_provider_entities[kind]) { 4586 throw new Error(`Missing entity config for kind: ${kind}.`); 4587 } 4588 4589 if (!entity_provider_entities[kind][type]) { 4590 entity_provider_entities[kind][type] = { 4591 context: Object(external_wp_element_["createContext"])() 4592 }; 4593 } 4594 4595 return entity_provider_entities[kind][type]; 4596 }; 4597 /** 4598 * Context provider component for providing 4599 * an entity for a specific entity type. 4600 * 4601 * @param {Object} props The component's props. 4602 * @param {string} props.kind The entity kind. 4603 * @param {string} props.type The entity type. 4604 * @param {number} props.id The entity ID. 4605 * @param {*} props.children The children to wrap. 4606 * 4607 * @return {Object} The provided children, wrapped with 4608 * the entity's context provider. 4609 */ 4610 4611 4612 function EntityProvider({ 4613 kind, 4614 type, 4615 id, 4616 children 4617 }) { 4618 const Provider = entity_provider_getEntity(kind, type).context.Provider; 4619 return Object(external_wp_element_["createElement"])(Provider, { 4620 value: id 4621 }, children); 4622 } 4623 /** 4624 * Hook that returns the ID for the nearest 4625 * provided entity of the specified type. 4626 * 4627 * @param {string} kind The entity kind. 4628 * @param {string} type The entity type. 4629 */ 4630 4631 function useEntityId(kind, type) { 4632 return Object(external_wp_element_["useContext"])(entity_provider_getEntity(kind, type).context); 4633 } 4634 /** 4635 * Hook that returns the value and a setter for the 4636 * specified property of the nearest provided 4637 * entity of the specified type. 4638 * 4639 * @param {string} kind The entity kind. 4640 * @param {string} type The entity type. 4641 * @param {string} prop The property name. 4642 * @param {string} [_id] An entity ID to use instead of the context-provided one. 4643 * 4644 * @return {[*, Function, *]} An array where the first item is the 4645 * property value, the second is the 4646 * setter and the third is the full value 4647 * object from REST API containing more 4648 * information like `raw`, `rendered` and 4649 * `protected` props. 4650 */ 4651 4652 function useEntityProp(kind, type, prop, _id) { 4653 const providerId = useEntityId(kind, type); 4654 const id = _id !== null && _id !== void 0 ? _id : providerId; 4655 const { 4656 value, 4657 fullValue 4658 } = Object(external_wp_data_["useSelect"])(select => { 4659 const { 4660 getEntityRecord, 4661 getEditedEntityRecord 4662 } = select('core'); 4663 const entity = getEntityRecord(kind, type, id); // Trigger resolver. 4664 4665 const editedEntity = getEditedEntityRecord(kind, type, id); 4666 return entity && editedEntity ? { 4667 value: editedEntity[prop], 4668 fullValue: entity[prop] 4669 } : {}; 4670 }, [kind, type, id, prop]); 4671 const { 4672 editEntityRecord 4673 } = Object(external_wp_data_["useDispatch"])('core'); 4674 const setValue = Object(external_wp_element_["useCallback"])(newValue => { 4675 editEntityRecord(kind, type, id, { 4676 [prop]: newValue 4677 }); 4678 }, [kind, type, id, prop]); 4679 return [value, setValue, fullValue]; 4680 } 4681 /** 4682 * Hook that returns block content getters and setters for 4683 * the nearest provided entity of the specified type. 4684 * 4685 * The return value has the shape `[ blocks, onInput, onChange ]`. 4686 * `onInput` is for block changes that don't create undo levels 4687 * or dirty the post, non-persistent changes, and `onChange` is for 4688 * peristent changes. They map directly to the props of a 4689 * `BlockEditorProvider` and are intended to be used with it, 4690 * or similar components or hooks. 4691 * 4692 * @param {string} kind The entity kind. 4693 * @param {string} type The entity type. 4694 * @param {Object} options 4695 * @param {string} [options.id] An entity ID to use instead of the context-provided one. 4696 * 4697 * @return {[WPBlock[], Function, Function]} The block array and setters. 4698 */ 4699 4700 function useEntityBlockEditor(kind, type, { 4701 id: _id 4702 } = {}) { 4703 const providerId = useEntityId(kind, type); 4704 const id = _id !== null && _id !== void 0 ? _id : providerId; 4705 const { 4706 content, 4707 blocks 4708 } = Object(external_wp_data_["useSelect"])(select => { 4709 const { 4710 getEditedEntityRecord 4711 } = select('core'); 4712 const editedEntity = getEditedEntityRecord(kind, type, id); 4713 return { 4714 blocks: editedEntity.blocks, 4715 content: editedEntity.content 4716 }; 4717 }, [kind, type, id]); 4718 const { 4719 __unstableCreateUndoLevel, 4720 editEntityRecord 4721 } = Object(external_wp_data_["useDispatch"])('core'); 4722 Object(external_wp_element_["useEffect"])(() => { 4723 // Load the blocks from the content if not already in state 4724 // Guard against other instances that might have 4725 // set content to a function already or the blocks are already in state. 4726 if (content && typeof content !== 'function' && !blocks) { 4727 const parsedContent = Object(external_wp_blocks_["parse"])(content); 4728 editEntityRecord(kind, type, id, { 4729 blocks: parsedContent 4730 }, { 4731 undoIgnore: true 4732 }); 4733 } 4734 }, [content]); 4735 const onChange = Object(external_wp_element_["useCallback"])((newBlocks, options) => { 4736 const { 4737 selection 4738 } = options; 4739 const edits = { 4740 blocks: newBlocks, 4741 selection 4742 }; 4743 const noChange = blocks === edits.blocks; 4744 4745 if (noChange) { 4746 return __unstableCreateUndoLevel(kind, type, id); 4747 } // We create a new function here on every persistent edit 4748 // to make sure the edit makes the post dirty and creates 4749 // a new undo level. 4750 4751 4752 edits.content = ({ 4753 blocks: blocksForSerialization = [] 4754 }) => Object(external_wp_blocks_["__unstableSerializeAndClean"])(blocksForSerialization); 4755 4756 editEntityRecord(kind, type, id, edits); 4757 }, [kind, type, id, blocks]); 4758 const onInput = Object(external_wp_element_["useCallback"])((newBlocks, options) => { 4759 const { 4760 selection 4761 } = options; 4762 const edits = { 4763 blocks: newBlocks, 4764 selection 4765 }; 4766 editEntityRecord(kind, type, id, edits); 4767 }, [kind, type, id]); 4768 return [blocks !== null && blocks !== void 0 ? blocks : entity_provider_EMPTY_ARRAY, onInput, onChange]; 4769 } 4770 4771 // EXTERNAL MODULE: external ["wp","htmlEntities"] 4772 var external_wp_htmlEntities_ = __webpack_require__("rmEH"); 4773 4774 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-link-suggestions.js 4775 /** 4776 * WordPress dependencies 4777 */ 4778 4779 4780 4781 4782 /** 4783 * Filters the search by type 4784 * 4785 * @typedef { 'post' | 'term' | 'post-format' } WPLinkSearchType 4786 */ 4787 4788 /** 4789 * A link with an id may be of kind post-type or taxonomy 4790 * 4791 * @typedef { 'post-type' | 'taxonomy' } WPKind 4792 */ 4793 4794 /** 4795 * @typedef WPLinkSearchOptions 4796 * 4797 * @property {boolean} [isInitialSuggestions] Displays initial search suggestions, when true. 4798 * @property {WPLinkSearchType} [type] Filters by search type. 4799 * @property {string} [subtype] Slug of the post-type or taxonomy. 4800 * @property {number} [page] Which page of results to return. 4801 * @property {number} [perPage] Search results per page. 4802 */ 4803 4804 /** 4805 * @typedef WPLinkSearchResult 4806 * 4807 * @property {number} id Post or term id. 4808 * @property {string} url Link url. 4809 * @property {string} title Title of the link. 4810 * @property {string} type The taxonomy or post type slug or type URL. 4811 * @property {WPKind} [kind] Link kind of post-type or taxonomy 4812 */ 4813 4814 /** 4815 * @typedef WPEditorSettings 4816 * 4817 * @property {boolean} [ disablePostFormats ] Disables post formats, when true. 4818 */ 4819 4820 /** 4821 * Fetches link suggestions from the API. 4822 * 4823 * @async 4824 * @param {string} search 4825 * @param {WPLinkSearchOptions} [searchOptions] 4826 * @param {WPEditorSettings} [settings] 4827 * 4828 * @example 4829 * ```js 4830 * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data'; 4831 * 4832 * //... 4833 * 4834 * export function initialize( id, settings ) { 4835 * 4836 * settings.__experimentalFetchLinkSuggestions = ( 4837 * search, 4838 * searchOptions 4839 * ) => fetchLinkSuggestions( search, searchOptions, settings ); 4840 * ``` 4841 * @return {Promise< WPLinkSearchResult[] >} List of search suggestions 4842 */ 4843 4844 const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) => { 4845 const { 4846 isInitialSuggestions = false, 4847 type = undefined, 4848 subtype = undefined, 4849 page = undefined, 4850 perPage = isInitialSuggestions ? 3 : 20 4851 } = searchOptions; 4852 const { 4853 disablePostFormats = false 4854 } = settings; 4855 const queries = []; 4856 4857 if (!type || type === 'post') { 4858 queries.push(external_wp_apiFetch_default()({ 4859 path: Object(external_wp_url_["addQueryArgs"])('/wp/v2/search', { 4860 search, 4861 page, 4862 per_page: perPage, 4863 type: 'post', 4864 subtype 4865 }) 4866 }).then(results => { 4867 return results.map(result => { 4868 return { ...result, 4869 meta: { 4870 kind: 'post-type', 4871 subtype 4872 } 4873 }; 4874 }); 4875 }).catch(() => []) // fail by returning no results 4876 ); 4877 } 4878 4879 if (!type || type === 'term') { 4880 queries.push(external_wp_apiFetch_default()({ 4881 path: Object(external_wp_url_["addQueryArgs"])('/wp/v2/search', { 4882 search, 4883 page, 4884 per_page: perPage, 4885 type: 'term', 4886 subtype 4887 }) 4888 }).then(results => { 4889 return results.map(result => { 4890 return { ...result, 4891 meta: { 4892 kind: 'taxonomy', 4893 subtype 4894 } 4895 }; 4896 }); 4897 }).catch(() => [])); 4898 } 4899 4900 if (!disablePostFormats && (!type || type === 'post-format')) { 4901 queries.push(external_wp_apiFetch_default()({ 4902 path: Object(external_wp_url_["addQueryArgs"])('/wp/v2/search', { 4903 search, 4904 page, 4905 per_page: perPage, 4906 type: 'post-format', 4907 subtype 4908 }) 4909 }).then(results => { 4910 return results.map(result => { 4911 return { ...result, 4912 meta: { 4913 kind: 'taxonomy', 4914 subtype 4915 } 4916 }; 4917 }); 4918 }).catch(() => [])); 4919 } 4920 4921 return Promise.all(queries).then(results => { 4922 return results.reduce((accumulator, current) => accumulator.concat(current), //flatten list 4923 []).filter( 4924 /** 4925 * @param {{ id: number }} result 4926 */ 4927 result => { 4928 return !!result.id; 4929 }).slice(0, perPage).map( 4930 /** 4931 * @param {{ id: number, url:string, title?:string, subtype?: string, type?: string }} result 4932 */ 4933 result => { 4934 var _result$meta; 4935 4936 return { 4937 id: result.id, 4938 url: result.url, 4939 title: Object(external_wp_htmlEntities_["decodeEntities"])(result.title || '') || Object(external_wp_i18n_["__"])('(no title)'), 4940 type: result.subtype || result.type, 4941 kind: result === null || result === void 0 ? void 0 : (_result$meta = result.meta) === null || _result$meta === void 0 ? void 0 : _result$meta.kind 4942 }; 4943 }); 4944 }); 4945 }; 4946 4947 /* harmony default export */ var _experimental_fetch_link_suggestions = (fetchLinkSuggestions); 4948 4949 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-remote-url-data.js 4950 /** 4951 * WordPress dependencies 4952 */ 4953 4954 4955 /** 4956 * @typedef WPRemoteUrlData 4957 * 4958 * @property {string} title contents of the remote URL's `<title>` tag. 4959 */ 4960 4961 /** 4962 * Fetches data about a remote URL. 4963 * eg: <title> tag, favicon...etc. 4964 * 4965 * @async 4966 * @param {string} url 4967 * 4968 * @example 4969 * ```js 4970 * import { __experimentalFetchRemoteUrlData as fetchRemoteUrlData } from '@wordpress/core-data'; 4971 * 4972 * //... 4973 * 4974 * export function initialize( id, settings ) { 4975 * 4976 * settings.__experimentalFetchRemoteUrlData = ( 4977 * url 4978 * ) => fetchRemoteUrlData( url ); 4979 * ``` 4980 * @return {Promise< WPRemoteUrlData[] >} Remote URL data. 4981 */ 4982 4983 const fetchRemoteUrlData = async url => { 4984 const endpoint = '/__experimental/url-details'; 4985 const args = { 4986 url: Object(external_wp_url_["prependHTTP"])(url) 4987 }; 4988 return external_wp_apiFetch_default()({ 4989 path: Object(external_wp_url_["addQueryArgs"])(endpoint, args) 4990 }); 4991 }; 4992 4993 /* harmony default export */ var _experimental_fetch_remote_url_data = (fetchRemoteUrlData); 4994 4995 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/index.js 4996 4997 4998 4999 // CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js 5000 /** 5001 * WordPress dependencies 5002 */ 5003 5004 5005 /** 5006 * Internal dependencies 5007 */ 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 // The entity selectors/resolvers and actions are shortcuts to their generic equivalents 5018 // (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecordss) 5019 // Instead of getEntityRecord, the consumer could use more user-frieldly named selector: getPostType, getTaxonomy... 5020 // The "kind" and the "name" of the entity are combined to generate these shortcuts. 5021 5022 const entitySelectors = defaultEntities.reduce((result, entity) => { 5023 const { 5024 kind, 5025 name 5026 } = entity; 5027 5028 result[getMethodName(kind, name)] = (state, key) => getEntityRecord(state, kind, name, key); 5029 5030 result[getMethodName(kind, name, 'get', true)] = (state, ...args) => getEntityRecords(state, kind, name, ...args); 5031 5032 return result; 5033 }, {}); 5034 const entityResolvers = defaultEntities.reduce((result, entity) => { 5035 const { 5036 kind, 5037 name 5038 } = entity; 5039 5040 result[getMethodName(kind, name)] = key => resolvers_getEntityRecord(kind, name, key); 5041 5042 const pluralMethodName = getMethodName(kind, name, 'get', true); 5043 5044 result[pluralMethodName] = (...args) => resolvers_getEntityRecords(kind, name, ...args); 5045 5046 result[pluralMethodName].shouldInvalidate = (action, ...args) => resolvers_getEntityRecords.shouldInvalidate(action, kind, name, ...args); 5047 5048 return result; 5049 }, {}); 5050 const entityActions = defaultEntities.reduce((result, entity) => { 5051 const { 5052 kind, 5053 name 5054 } = entity; 5055 5056 result[getMethodName(kind, name, 'save')] = key => saveEntityRecord(kind, name, key); 5057 5058 result[getMethodName(kind, name, 'delete')] = (key, query) => deleteEntityRecord(kind, name, key, query); 5059 5060 return result; 5061 }, {}); 5062 const storeConfig = { 5063 reducer: build_module_reducer, 5064 controls: { ...build_module_controls, 5065 ...external_wp_dataControls_["controls"] 5066 }, 5067 actions: { ...build_module_actions_namespaceObject, 5068 ...entityActions, 5069 ...locks_actions_namespaceObject 5070 }, 5071 selectors: { ...build_module_selectors_namespaceObject, 5072 ...entitySelectors, 5073 ...locks_selectors_namespaceObject 5074 }, 5075 resolvers: { ...resolvers_namespaceObject, 5076 ...entityResolvers 5077 } 5078 }; 5079 /** 5080 * Store definition for the code data namespace. 5081 * 5082 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 5083 * 5084 * @type {Object} 5085 */ 5086 5087 const build_module_store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, storeConfig); 5088 Object(external_wp_data_["register"])(build_module_store); 5089 5090 5091 5092 5093 5094 /***/ }), 5095 5096 /***/ "l3Sj": 5097 /***/ (function(module, exports) { 5098 5099 (function() { module.exports = window["wp"]["i18n"]; }()); 5100 5101 /***/ }), 5102 5103 /***/ "pPDe": 5104 /***/ (function(module, __webpack_exports__, __webpack_require__) { 5105 5106 "use strict"; 5107 5108 5109 var LEAF_KEY, hasWeakMap; 5110 5111 /** 5112 * Arbitrary value used as key for referencing cache object in WeakMap tree. 5113 * 5114 * @type {Object} 5115 */ 5116 LEAF_KEY = {}; 5117 5118 /** 5119 * Whether environment supports WeakMap. 5120 * 5121 * @type {boolean} 5122 */ 5123 hasWeakMap = typeof WeakMap !== 'undefined'; 5124 5125 /** 5126 * Returns the first argument as the sole entry in an array. 5127 * 5128 * @param {*} value Value to return. 5129 * 5130 * @return {Array} Value returned as entry in array. 5131 */ 5132 function arrayOf( value ) { 5133 return [ value ]; 5134 } 5135 5136 /** 5137 * Returns true if the value passed is object-like, or false otherwise. A value 5138 * is object-like if it can support property assignment, e.g. object or array. 5139 * 5140 * @param {*} value Value to test. 5141 * 5142 * @return {boolean} Whether value is object-like. 5143 */ 5144 function isObjectLike( value ) { 5145 return !! value && 'object' === typeof value; 5146 } 5147 5148 /** 5149 * Creates and returns a new cache object. 5150 * 5151 * @return {Object} Cache object. 5152 */ 5153 function createCache() { 5154 var cache = { 5155 clear: function() { 5156 cache.head = null; 5157 }, 5158 }; 5159 5160 return cache; 5161 } 5162 5163 /** 5164 * Returns true if entries within the two arrays are strictly equal by 5165 * reference from a starting index. 5166 * 5167 * @param {Array} a First array. 5168 * @param {Array} b Second array. 5169 * @param {number} fromIndex Index from which to start comparison. 5170 * 5171 * @return {boolean} Whether arrays are shallowly equal. 5172 */ 5173 function isShallowEqual( a, b, fromIndex ) { 5174 var i; 5175 5176 if ( a.length !== b.length ) { 5177 return false; 5178 } 5179 5180 for ( i = fromIndex; i < a.length; i++ ) { 5181 if ( a[ i ] !== b[ i ] ) { 5182 return false; 5183 } 5184 } 5185 5186 return true; 5187 } 5188 5189 /** 5190 * Returns a memoized selector function. The getDependants function argument is 5191 * called before the memoized selector and is expected to return an immutable 5192 * reference or array of references on which the selector depends for computing 5193 * its own return value. The memoize cache is preserved only as long as those 5194 * dependant references remain the same. If getDependants returns a different 5195 * reference(s), the cache is cleared and the selector value regenerated. 5196 * 5197 * @param {Function} selector Selector function. 5198 * @param {Function} getDependants Dependant getter returning an immutable 5199 * reference or array of reference used in 5200 * cache bust consideration. 5201 * 5202 * @return {Function} Memoized selector. 5203 */ 5204 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { 5205 var rootCache, getCache; 5206 5207 // Use object source as dependant if getter not provided 5208 if ( ! getDependants ) { 5209 getDependants = arrayOf; 5210 } 5211 5212 /** 5213 * Returns the root cache. If WeakMap is supported, this is assigned to the 5214 * root WeakMap cache set, otherwise it is a shared instance of the default 5215 * cache object. 5216 * 5217 * @return {(WeakMap|Object)} Root cache object. 5218 */ 5219 function getRootCache() { 5220 return rootCache; 5221 } 5222 5223 /** 5224 * Returns the cache for a given dependants array. When possible, a WeakMap 5225 * will be used to create a unique cache for each set of dependants. This 5226 * is feasible due to the nature of WeakMap in allowing garbage collection 5227 * to occur on entries where the key object is no longer referenced. Since 5228 * WeakMap requires the key to be an object, this is only possible when the 5229 * dependant is object-like. The root cache is created as a hierarchy where 5230 * each top-level key is the first entry in a dependants set, the value a 5231 * WeakMap where each key is the next dependant, and so on. This continues 5232 * so long as the dependants are object-like. If no dependants are object- 5233 * like, then the cache is shared across all invocations. 5234 * 5235 * @see isObjectLike 5236 * 5237 * @param {Array} dependants Selector dependants. 5238 * 5239 * @return {Object} Cache object. 5240 */ 5241 function getWeakMapCache( dependants ) { 5242 var caches = rootCache, 5243 isUniqueByDependants = true, 5244 i, dependant, map, cache; 5245 5246 for ( i = 0; i < dependants.length; i++ ) { 5247 dependant = dependants[ i ]; 5248 5249 // Can only compose WeakMap from object-like key. 5250 if ( ! isObjectLike( dependant ) ) { 5251 isUniqueByDependants = false; 5252 break; 5253 } 5254 5255 // Does current segment of cache already have a WeakMap? 5256 if ( caches.has( dependant ) ) { 5257 // Traverse into nested WeakMap. 5258 caches = caches.get( dependant ); 5259 } else { 5260 // Create, set, and traverse into a new one. 5261 map = new WeakMap(); 5262 caches.set( dependant, map ); 5263 caches = map; 5264 } 5265 } 5266 5267 // We use an arbitrary (but consistent) object as key for the last item 5268 // in the WeakMap to serve as our running cache. 5269 if ( ! caches.has( LEAF_KEY ) ) { 5270 cache = createCache(); 5271 cache.isUniqueByDependants = isUniqueByDependants; 5272 caches.set( LEAF_KEY, cache ); 5273 } 5274 5275 return caches.get( LEAF_KEY ); 5276 } 5277 5278 // Assign cache handler by availability of WeakMap 5279 getCache = hasWeakMap ? getWeakMapCache : getRootCache; 5280 5281 /** 5282 * Resets root memoization cache. 5283 */ 5284 function clear() { 5285 rootCache = hasWeakMap ? new WeakMap() : createCache(); 5286 } 5287 5288 // eslint-disable-next-line jsdoc/check-param-names 5289 /** 5290 * The augmented selector call, considering first whether dependants have 5291 * changed before passing it to underlying memoize function. 5292 * 5293 * @param {Object} source Source object for derivation. 5294 * @param {...*} extraArgs Additional arguments to pass to selector. 5295 * 5296 * @return {*} Selector result. 5297 */ 5298 function callSelector( /* source, ...extraArgs */ ) { 5299 var len = arguments.length, 5300 cache, node, i, args, dependants; 5301 5302 // Create copy of arguments (avoid leaking deoptimization). 5303 args = new Array( len ); 5304 for ( i = 0; i < len; i++ ) { 5305 args[ i ] = arguments[ i ]; 5306 } 5307 5308 dependants = getDependants.apply( null, args ); 5309 cache = getCache( dependants ); 5310 5311 // If not guaranteed uniqueness by dependants (primitive type or lack 5312 // of WeakMap support), shallow compare against last dependants and, if 5313 // references have changed, destroy cache to recalculate result. 5314 if ( ! cache.isUniqueByDependants ) { 5315 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { 5316 cache.clear(); 5317 } 5318 5319 cache.lastDependants = dependants; 5320 } 5321 5322 node = cache.head; 5323 while ( node ) { 5324 // Check whether node arguments match arguments 5325 if ( ! isShallowEqual( node.args, args, 1 ) ) { 5326 node = node.next; 5327 continue; 5328 } 5329 5330 // At this point we can assume we've found a match 5331 5332 // Surface matched node to head if not already 5333 if ( node !== cache.head ) { 5334 // Adjust siblings to point to each other. 5335 node.prev.next = node.next; 5336 if ( node.next ) { 5337 node.next.prev = node.prev; 5338 } 5339 5340 node.next = cache.head; 5341 node.prev = null; 5342 cache.head.prev = node; 5343 cache.head = node; 5344 } 5345 5346 // Return immediately 5347 return node.val; 5348 } 5349 5350 // No cached value found. Continue to insertion phase: 5351 5352 node = { 5353 // Generate the result from original function 5354 val: selector.apply( null, args ), 5355 }; 5356 5357 // Avoid including the source object in the cache. 5358 args[ 0 ] = null; 5359 node.args = args; 5360 5361 // Don't need to check whether node is already head, since it would 5362 // have been returned above already if it was 5363 5364 // Shift existing head down list 5365 if ( cache.head ) { 5366 cache.head.prev = node; 5367 node.next = cache.head; 5368 } 5369 5370 cache.head = node; 5371 5372 return node.val; 5373 } 5374 5375 callSelector.getDependants = getDependants; 5376 callSelector.clear = clear; 5377 clear(); 5378 5379 return callSelector; 5380 }); 5381 5382 5383 /***/ }), 5384 5385 /***/ "rl8x": 5386 /***/ (function(module, exports) { 5387 5388 (function() { module.exports = window["wp"]["isShallowEqual"]; }()); 5389 5390 /***/ }), 5391 5392 /***/ "rmEH": 5393 /***/ (function(module, exports) { 5394 5395 (function() { module.exports = window["wp"]["htmlEntities"]; }()); 5396 5397 /***/ }), 5398 5399 /***/ "ywyh": 5400 /***/ (function(module, exports) { 5401 5402 (function() { module.exports = window["wp"]["apiFetch"]; }()); 5403 5404 /***/ }) 5405 5406 /******/ });