wp/wp-includes/js/dist/core-data.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
     1 /******/ (() => { // webpackBootstrap
     1 /******/ (() => { // webpackBootstrap
     2 /******/ 	"use strict";
     2 /******/ 	"use strict";
     3 /******/ 	var __webpack_modules__ = ({
     3 /******/ 	var __webpack_modules__ = ({
     4 
       
     5 /***/ 6689:
       
     6 /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
       
     7 
       
     8 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
       
     9 /* harmony export */   createUndoManager: () => (/* binding */ createUndoManager)
       
    10 /* harmony export */ });
       
    11 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(923);
       
    12 /* harmony import */ var _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0__);
       
    13 /**
       
    14  * WordPress dependencies
       
    15  */
       
    16 
       
    17 
       
    18 /** @typedef {import('./types').HistoryRecord}  HistoryRecord */
       
    19 /** @typedef {import('./types').HistoryChange}  HistoryChange */
       
    20 /** @typedef {import('./types').HistoryChanges} HistoryChanges */
       
    21 /** @typedef {import('./types').UndoManager} UndoManager */
       
    22 
       
    23 /**
       
    24  * Merge changes for a single item into a record of changes.
       
    25  *
       
    26  * @param {Record< string, HistoryChange >} changes1 Previous changes
       
    27  * @param {Record< string, HistoryChange >} changes2 NextChanges
       
    28  *
       
    29  * @return {Record< string, HistoryChange >} Merged changes
       
    30  */
       
    31 function mergeHistoryChanges(changes1, changes2) {
       
    32   /**
       
    33    * @type {Record< string, HistoryChange >}
       
    34    */
       
    35   const newChanges = {
       
    36     ...changes1
       
    37   };
       
    38   Object.entries(changes2).forEach(([key, value]) => {
       
    39     if (newChanges[key]) {
       
    40       newChanges[key] = {
       
    41         ...newChanges[key],
       
    42         to: value.to
       
    43       };
       
    44     } else {
       
    45       newChanges[key] = value;
       
    46     }
       
    47   });
       
    48   return newChanges;
       
    49 }
       
    50 
       
    51 /**
       
    52  * Adds history changes for a single item into a record of changes.
       
    53  *
       
    54  * @param {HistoryRecord}  record  The record to merge into.
       
    55  * @param {HistoryChanges} changes The changes to merge.
       
    56  */
       
    57 const addHistoryChangesIntoRecord = (record, changes) => {
       
    58   const existingChangesIndex = record?.findIndex(({
       
    59     id: recordIdentifier
       
    60   }) => {
       
    61     return typeof recordIdentifier === 'string' ? recordIdentifier === changes.id : _wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(recordIdentifier, changes.id);
       
    62   });
       
    63   const nextRecord = [...record];
       
    64   if (existingChangesIndex !== -1) {
       
    65     // If the edit is already in the stack leave the initial "from" value.
       
    66     nextRecord[existingChangesIndex] = {
       
    67       id: changes.id,
       
    68       changes: mergeHistoryChanges(nextRecord[existingChangesIndex].changes, changes.changes)
       
    69     };
       
    70   } else {
       
    71     nextRecord.push(changes);
       
    72   }
       
    73   return nextRecord;
       
    74 };
       
    75 
       
    76 /**
       
    77  * Creates an undo manager.
       
    78  *
       
    79  * @return {UndoManager} Undo manager.
       
    80  */
       
    81 function createUndoManager() {
       
    82   /**
       
    83    * @type {HistoryRecord[]}
       
    84    */
       
    85   let history = [];
       
    86   /**
       
    87    * @type {HistoryRecord}
       
    88    */
       
    89   let stagedRecord = [];
       
    90   /**
       
    91    * @type {number}
       
    92    */
       
    93   let offset = 0;
       
    94   const dropPendingRedos = () => {
       
    95     history = history.slice(0, offset || undefined);
       
    96     offset = 0;
       
    97   };
       
    98   const appendStagedRecordToLatestHistoryRecord = () => {
       
    99     var _history$index;
       
   100     const index = history.length === 0 ? 0 : history.length - 1;
       
   101     let latestRecord = (_history$index = history[index]) !== null && _history$index !== void 0 ? _history$index : [];
       
   102     stagedRecord.forEach(changes => {
       
   103       latestRecord = addHistoryChangesIntoRecord(latestRecord, changes);
       
   104     });
       
   105     stagedRecord = [];
       
   106     history[index] = latestRecord;
       
   107   };
       
   108 
       
   109   /**
       
   110    * Checks whether a record is empty.
       
   111    * A record is considered empty if it the changes keep the same values.
       
   112    * Also updates to function values are ignored.
       
   113    *
       
   114    * @param {HistoryRecord} record
       
   115    * @return {boolean} Whether the record is empty.
       
   116    */
       
   117   const isRecordEmpty = record => {
       
   118     const filteredRecord = record.filter(({
       
   119       changes
       
   120     }) => {
       
   121       return Object.values(changes).some(({
       
   122         from,
       
   123         to
       
   124       }) => typeof from !== 'function' && typeof to !== 'function' && !_wordpress_is_shallow_equal__WEBPACK_IMPORTED_MODULE_0___default()(from, to));
       
   125     });
       
   126     return !filteredRecord.length;
       
   127   };
       
   128   return {
       
   129     /**
       
   130      * Record changes into the history.
       
   131      *
       
   132      * @param {HistoryRecord=} record   A record of changes to record.
       
   133      * @param {boolean}        isStaged Whether to immediately create an undo point or not.
       
   134      */
       
   135     addRecord(record, isStaged = false) {
       
   136       const isEmpty = !record || isRecordEmpty(record);
       
   137       if (isStaged) {
       
   138         if (isEmpty) {
       
   139           return;
       
   140         }
       
   141         record.forEach(changes => {
       
   142           stagedRecord = addHistoryChangesIntoRecord(stagedRecord, changes);
       
   143         });
       
   144       } else {
       
   145         dropPendingRedos();
       
   146         if (stagedRecord.length) {
       
   147           appendStagedRecordToLatestHistoryRecord();
       
   148         }
       
   149         if (isEmpty) {
       
   150           return;
       
   151         }
       
   152         history.push(record);
       
   153       }
       
   154     },
       
   155     undo() {
       
   156       if (stagedRecord.length) {
       
   157         dropPendingRedos();
       
   158         appendStagedRecordToLatestHistoryRecord();
       
   159       }
       
   160       const undoRecord = history[history.length - 1 + offset];
       
   161       if (!undoRecord) {
       
   162         return;
       
   163       }
       
   164       offset -= 1;
       
   165       return undoRecord;
       
   166     },
       
   167     redo() {
       
   168       const redoRecord = history[history.length + offset];
       
   169       if (!redoRecord) {
       
   170         return;
       
   171       }
       
   172       offset += 1;
       
   173       return redoRecord;
       
   174     },
       
   175     hasUndo() {
       
   176       return !!history[history.length - 1 + offset];
       
   177     },
       
   178     hasRedo() {
       
   179       return !!history[history.length + offset];
       
   180     }
       
   181   };
       
   182 }
       
   183 
       
   184 
       
   185 /***/ }),
       
   186 
     4 
   187 /***/ 3249:
     5 /***/ 3249:
   188 /***/ ((module) => {
     6 /***/ ((module) => {
   189 
     7 
   190 
     8 
   572 
   390 
   573   // true if both NaN, false otherwise
   391   // true if both NaN, false otherwise
   574   return a!==a && b!==b;
   392   return a!==a && b!==b;
   575 };
   393 };
   576 
   394 
   577 
       
   578 /***/ }),
       
   579 
       
   580 /***/ 923:
       
   581 /***/ ((module) => {
       
   582 
       
   583 module.exports = window["wp"]["isShallowEqual"];
       
   584 
   395 
   585 /***/ })
   396 /***/ })
   586 
   397 
   587 /******/ 	});
   398 /******/ 	});
   588 /************************************************************************/
   399 /************************************************************************/
   651 /******/ 		};
   462 /******/ 		};
   652 /******/ 	})();
   463 /******/ 	})();
   653 /******/ 	
   464 /******/ 	
   654 /************************************************************************/
   465 /************************************************************************/
   655 var __webpack_exports__ = {};
   466 var __webpack_exports__ = {};
   656 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
       
   657 (() => {
       
   658 // ESM COMPAT FLAG
   467 // ESM COMPAT FLAG
   659 __webpack_require__.r(__webpack_exports__);
   468 __webpack_require__.r(__webpack_exports__);
   660 
   469 
   661 // EXPORTS
   470 // EXPORTS
   662 __webpack_require__.d(__webpack_exports__, {
   471 __webpack_require__.d(__webpack_exports__, {
   663   EntityProvider: () => (/* reexport */ EntityProvider),
   472   EntityProvider: () => (/* reexport */ EntityProvider),
   664   __experimentalFetchLinkSuggestions: () => (/* reexport */ _experimental_fetch_link_suggestions),
   473   __experimentalFetchLinkSuggestions: () => (/* reexport */ fetchLinkSuggestions),
   665   __experimentalFetchUrlData: () => (/* reexport */ _experimental_fetch_url_data),
   474   __experimentalFetchUrlData: () => (/* reexport */ _experimental_fetch_url_data),
   666   __experimentalUseEntityRecord: () => (/* reexport */ __experimentalUseEntityRecord),
   475   __experimentalUseEntityRecord: () => (/* reexport */ __experimentalUseEntityRecord),
   667   __experimentalUseEntityRecords: () => (/* reexport */ __experimentalUseEntityRecords),
   476   __experimentalUseEntityRecords: () => (/* reexport */ __experimentalUseEntityRecords),
   668   __experimentalUseResourcePermissions: () => (/* reexport */ __experimentalUseResourcePermissions),
   477   __experimentalUseResourcePermissions: () => (/* reexport */ __experimentalUseResourcePermissions),
   669   fetchBlockPatterns: () => (/* reexport */ fetchBlockPatterns),
   478   fetchBlockPatterns: () => (/* reexport */ fetchBlockPatterns),
       
   479   privateApis: () => (/* reexport */ privateApis),
   670   store: () => (/* binding */ store),
   480   store: () => (/* binding */ store),
   671   useEntityBlockEditor: () => (/* reexport */ useEntityBlockEditor),
   481   useEntityBlockEditor: () => (/* reexport */ useEntityBlockEditor),
   672   useEntityId: () => (/* reexport */ useEntityId),
   482   useEntityId: () => (/* reexport */ useEntityId),
   673   useEntityProp: () => (/* reexport */ useEntityProp),
   483   useEntityProp: () => (/* reexport */ useEntityProp),
   674   useEntityRecord: () => (/* reexport */ useEntityRecord),
   484   useEntityRecord: () => (/* reexport */ useEntityRecord),
   675   useEntityRecords: () => (/* reexport */ useEntityRecords),
   485   useEntityRecords: () => (/* reexport */ useEntityRecords),
   676   useResourcePermissions: () => (/* reexport */ useResourcePermissions)
   486   useResourcePermissions: () => (/* reexport */ use_resource_permissions)
   677 });
       
   678 
       
   679 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/actions.js
       
   680 var build_module_actions_namespaceObject = {};
       
   681 __webpack_require__.r(build_module_actions_namespaceObject);
       
   682 __webpack_require__.d(build_module_actions_namespaceObject, {
       
   683   __experimentalBatch: () => (__experimentalBatch),
       
   684   __experimentalReceiveCurrentGlobalStylesId: () => (__experimentalReceiveCurrentGlobalStylesId),
       
   685   __experimentalReceiveThemeBaseGlobalStyles: () => (__experimentalReceiveThemeBaseGlobalStyles),
       
   686   __experimentalReceiveThemeGlobalStyleVariations: () => (__experimentalReceiveThemeGlobalStyleVariations),
       
   687   __experimentalSaveSpecifiedEntityEdits: () => (__experimentalSaveSpecifiedEntityEdits),
       
   688   __unstableCreateUndoLevel: () => (__unstableCreateUndoLevel),
       
   689   addEntities: () => (addEntities),
       
   690   deleteEntityRecord: () => (deleteEntityRecord),
       
   691   editEntityRecord: () => (editEntityRecord),
       
   692   receiveAutosaves: () => (receiveAutosaves),
       
   693   receiveCurrentTheme: () => (receiveCurrentTheme),
       
   694   receiveCurrentUser: () => (receiveCurrentUser),
       
   695   receiveDefaultTemplateId: () => (receiveDefaultTemplateId),
       
   696   receiveEmbedPreview: () => (receiveEmbedPreview),
       
   697   receiveEntityRecords: () => (receiveEntityRecords),
       
   698   receiveNavigationFallbackId: () => (receiveNavigationFallbackId),
       
   699   receiveRevisions: () => (receiveRevisions),
       
   700   receiveThemeGlobalStyleRevisions: () => (receiveThemeGlobalStyleRevisions),
       
   701   receiveThemeSupports: () => (receiveThemeSupports),
       
   702   receiveUploadPermissions: () => (receiveUploadPermissions),
       
   703   receiveUserPermission: () => (receiveUserPermission),
       
   704   receiveUserQuery: () => (receiveUserQuery),
       
   705   redo: () => (redo),
       
   706   saveEditedEntityRecord: () => (saveEditedEntityRecord),
       
   707   saveEntityRecord: () => (saveEntityRecord),
       
   708   undo: () => (undo)
       
   709 });
   487 });
   710 
   488 
   711 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/selectors.js
   489 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/selectors.js
   712 var build_module_selectors_namespaceObject = {};
   490 var build_module_selectors_namespaceObject = {};
   713 __webpack_require__.r(build_module_selectors_namespaceObject);
   491 __webpack_require__.r(build_module_selectors_namespaceObject);
   716   __experimentalGetCurrentThemeBaseGlobalStyles: () => (__experimentalGetCurrentThemeBaseGlobalStyles),
   494   __experimentalGetCurrentThemeBaseGlobalStyles: () => (__experimentalGetCurrentThemeBaseGlobalStyles),
   717   __experimentalGetCurrentThemeGlobalStylesVariations: () => (__experimentalGetCurrentThemeGlobalStylesVariations),
   495   __experimentalGetCurrentThemeGlobalStylesVariations: () => (__experimentalGetCurrentThemeGlobalStylesVariations),
   718   __experimentalGetDirtyEntityRecords: () => (__experimentalGetDirtyEntityRecords),
   496   __experimentalGetDirtyEntityRecords: () => (__experimentalGetDirtyEntityRecords),
   719   __experimentalGetEntitiesBeingSaved: () => (__experimentalGetEntitiesBeingSaved),
   497   __experimentalGetEntitiesBeingSaved: () => (__experimentalGetEntitiesBeingSaved),
   720   __experimentalGetEntityRecordNoResolver: () => (__experimentalGetEntityRecordNoResolver),
   498   __experimentalGetEntityRecordNoResolver: () => (__experimentalGetEntityRecordNoResolver),
   721   __experimentalGetTemplateForLink: () => (__experimentalGetTemplateForLink),
       
   722   canUser: () => (canUser),
   499   canUser: () => (canUser),
   723   canUserEditEntityRecord: () => (canUserEditEntityRecord),
   500   canUserEditEntityRecord: () => (canUserEditEntityRecord),
   724   getAuthors: () => (getAuthors),
   501   getAuthors: () => (getAuthors),
   725   getAutosave: () => (getAutosave),
   502   getAutosave: () => (getAutosave),
   726   getAutosaves: () => (getAutosaves),
   503   getAutosaves: () => (getAutosaves),
   768 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/private-selectors.js
   545 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/private-selectors.js
   769 var private_selectors_namespaceObject = {};
   546 var private_selectors_namespaceObject = {};
   770 __webpack_require__.r(private_selectors_namespaceObject);
   547 __webpack_require__.r(private_selectors_namespaceObject);
   771 __webpack_require__.d(private_selectors_namespaceObject, {
   548 __webpack_require__.d(private_selectors_namespaceObject, {
   772   getBlockPatternsForPostType: () => (getBlockPatternsForPostType),
   549   getBlockPatternsForPostType: () => (getBlockPatternsForPostType),
       
   550   getEntityRecordPermissions: () => (getEntityRecordPermissions),
       
   551   getEntityRecordsPermissions: () => (getEntityRecordsPermissions),
       
   552   getHomePage: () => (getHomePage),
   773   getNavigationFallbackId: () => (getNavigationFallbackId),
   553   getNavigationFallbackId: () => (getNavigationFallbackId),
       
   554   getPostsPageId: () => (getPostsPageId),
       
   555   getRegisteredPostMeta: () => (getRegisteredPostMeta),
       
   556   getTemplateId: () => (getTemplateId),
   774   getUndoManager: () => (getUndoManager)
   557   getUndoManager: () => (getUndoManager)
       
   558 });
       
   559 
       
   560 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/actions.js
       
   561 var build_module_actions_namespaceObject = {};
       
   562 __webpack_require__.r(build_module_actions_namespaceObject);
       
   563 __webpack_require__.d(build_module_actions_namespaceObject, {
       
   564   __experimentalBatch: () => (__experimentalBatch),
       
   565   __experimentalReceiveCurrentGlobalStylesId: () => (__experimentalReceiveCurrentGlobalStylesId),
       
   566   __experimentalReceiveThemeBaseGlobalStyles: () => (__experimentalReceiveThemeBaseGlobalStyles),
       
   567   __experimentalReceiveThemeGlobalStyleVariations: () => (__experimentalReceiveThemeGlobalStyleVariations),
       
   568   __experimentalSaveSpecifiedEntityEdits: () => (__experimentalSaveSpecifiedEntityEdits),
       
   569   __unstableCreateUndoLevel: () => (__unstableCreateUndoLevel),
       
   570   addEntities: () => (addEntities),
       
   571   deleteEntityRecord: () => (deleteEntityRecord),
       
   572   editEntityRecord: () => (editEntityRecord),
       
   573   receiveAutosaves: () => (receiveAutosaves),
       
   574   receiveCurrentTheme: () => (receiveCurrentTheme),
       
   575   receiveCurrentUser: () => (receiveCurrentUser),
       
   576   receiveDefaultTemplateId: () => (receiveDefaultTemplateId),
       
   577   receiveEmbedPreview: () => (receiveEmbedPreview),
       
   578   receiveEntityRecords: () => (receiveEntityRecords),
       
   579   receiveNavigationFallbackId: () => (receiveNavigationFallbackId),
       
   580   receiveRevisions: () => (receiveRevisions),
       
   581   receiveThemeGlobalStyleRevisions: () => (receiveThemeGlobalStyleRevisions),
       
   582   receiveThemeSupports: () => (receiveThemeSupports),
       
   583   receiveUploadPermissions: () => (receiveUploadPermissions),
       
   584   receiveUserPermission: () => (receiveUserPermission),
       
   585   receiveUserPermissions: () => (receiveUserPermissions),
       
   586   receiveUserQuery: () => (receiveUserQuery),
       
   587   redo: () => (redo),
       
   588   saveEditedEntityRecord: () => (saveEditedEntityRecord),
       
   589   saveEntityRecord: () => (saveEntityRecord),
       
   590   undo: () => (undo)
       
   591 });
       
   592 
       
   593 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/private-actions.js
       
   594 var private_actions_namespaceObject = {};
       
   595 __webpack_require__.r(private_actions_namespaceObject);
       
   596 __webpack_require__.d(private_actions_namespaceObject, {
       
   597   receiveRegisteredPostMeta: () => (receiveRegisteredPostMeta)
   775 });
   598 });
   776 
   599 
   777 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/resolvers.js
   600 // NAMESPACE OBJECT: ./node_modules/@wordpress/core-data/build-module/resolvers.js
   778 var resolvers_namespaceObject = {};
   601 var resolvers_namespaceObject = {};
   779 __webpack_require__.r(resolvers_namespaceObject);
   602 __webpack_require__.r(resolvers_namespaceObject);
   780 __webpack_require__.d(resolvers_namespaceObject, {
   603 __webpack_require__.d(resolvers_namespaceObject, {
   781   __experimentalGetCurrentGlobalStylesId: () => (resolvers_experimentalGetCurrentGlobalStylesId),
   604   __experimentalGetCurrentGlobalStylesId: () => (resolvers_experimentalGetCurrentGlobalStylesId),
   782   __experimentalGetCurrentThemeBaseGlobalStyles: () => (resolvers_experimentalGetCurrentThemeBaseGlobalStyles),
   605   __experimentalGetCurrentThemeBaseGlobalStyles: () => (resolvers_experimentalGetCurrentThemeBaseGlobalStyles),
   783   __experimentalGetCurrentThemeGlobalStylesVariations: () => (resolvers_experimentalGetCurrentThemeGlobalStylesVariations),
   606   __experimentalGetCurrentThemeGlobalStylesVariations: () => (resolvers_experimentalGetCurrentThemeGlobalStylesVariations),
   784   __experimentalGetTemplateForLink: () => (resolvers_experimentalGetTemplateForLink),
       
   785   canUser: () => (resolvers_canUser),
   607   canUser: () => (resolvers_canUser),
   786   canUserEditEntityRecord: () => (resolvers_canUserEditEntityRecord),
   608   canUserEditEntityRecord: () => (resolvers_canUserEditEntityRecord),
   787   getAuthors: () => (resolvers_getAuthors),
   609   getAuthors: () => (resolvers_getAuthors),
   788   getAutosave: () => (resolvers_getAutosave),
   610   getAutosave: () => (resolvers_getAutosave),
   789   getAutosaves: () => (resolvers_getAutosaves),
   611   getAutosaves: () => (resolvers_getAutosaves),
   793   getCurrentThemeGlobalStylesRevisions: () => (resolvers_getCurrentThemeGlobalStylesRevisions),
   615   getCurrentThemeGlobalStylesRevisions: () => (resolvers_getCurrentThemeGlobalStylesRevisions),
   794   getCurrentUser: () => (resolvers_getCurrentUser),
   616   getCurrentUser: () => (resolvers_getCurrentUser),
   795   getDefaultTemplateId: () => (resolvers_getDefaultTemplateId),
   617   getDefaultTemplateId: () => (resolvers_getDefaultTemplateId),
   796   getEditedEntityRecord: () => (resolvers_getEditedEntityRecord),
   618   getEditedEntityRecord: () => (resolvers_getEditedEntityRecord),
   797   getEmbedPreview: () => (resolvers_getEmbedPreview),
   619   getEmbedPreview: () => (resolvers_getEmbedPreview),
       
   620   getEntitiesConfig: () => (resolvers_getEntitiesConfig),
   798   getEntityRecord: () => (resolvers_getEntityRecord),
   621   getEntityRecord: () => (resolvers_getEntityRecord),
   799   getEntityRecords: () => (resolvers_getEntityRecords),
   622   getEntityRecords: () => (resolvers_getEntityRecords),
   800   getNavigationFallbackId: () => (resolvers_getNavigationFallbackId),
   623   getNavigationFallbackId: () => (resolvers_getNavigationFallbackId),
   801   getRawEntityRecord: () => (resolvers_getRawEntityRecord),
   624   getRawEntityRecord: () => (resolvers_getRawEntityRecord),
       
   625   getRegisteredPostMeta: () => (resolvers_getRegisteredPostMeta),
   802   getRevision: () => (resolvers_getRevision),
   626   getRevision: () => (resolvers_getRevision),
   803   getRevisions: () => (resolvers_getRevisions),
   627   getRevisions: () => (resolvers_getRevisions),
   804   getThemeSupports: () => (resolvers_getThemeSupports),
   628   getThemeSupports: () => (resolvers_getThemeSupports),
   805   getUserPatternCategories: () => (resolvers_getUserPatternCategories)
   629   getUserPatternCategories: () => (resolvers_getUserPatternCategories)
   806 });
   630 });
   807 
   631 
   808 ;// CONCATENATED MODULE: external ["wp","data"]
   632 ;// external ["wp","data"]
   809 const external_wp_data_namespaceObject = window["wp"]["data"];
   633 const external_wp_data_namespaceObject = window["wp"]["data"];
   810 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
   634 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
   811 var es6 = __webpack_require__(7734);
   635 var es6 = __webpack_require__(7734);
   812 var es6_default = /*#__PURE__*/__webpack_require__.n(es6);
   636 var es6_default = /*#__PURE__*/__webpack_require__.n(es6);
   813 ;// CONCATENATED MODULE: external ["wp","compose"]
   637 ;// external ["wp","compose"]
   814 const external_wp_compose_namespaceObject = window["wp"]["compose"];
   638 const external_wp_compose_namespaceObject = window["wp"]["compose"];
   815 // EXTERNAL MODULE: ./node_modules/@wordpress/undo-manager/build-module/index.js
   639 ;// external ["wp","isShallowEqual"]
   816 var build_module = __webpack_require__(6689);
   640 const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
   817 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js
   641 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
       
   642 ;// ./node_modules/@wordpress/undo-manager/build-module/index.js
       
   643 /**
       
   644  * WordPress dependencies
       
   645  */
       
   646 
       
   647 
       
   648 /** @typedef {import('./types').HistoryRecord}  HistoryRecord */
       
   649 /** @typedef {import('./types').HistoryChange}  HistoryChange */
       
   650 /** @typedef {import('./types').HistoryChanges} HistoryChanges */
       
   651 /** @typedef {import('./types').UndoManager} UndoManager */
       
   652 
       
   653 /**
       
   654  * Merge changes for a single item into a record of changes.
       
   655  *
       
   656  * @param {Record< string, HistoryChange >} changes1 Previous changes
       
   657  * @param {Record< string, HistoryChange >} changes2 NextChanges
       
   658  *
       
   659  * @return {Record< string, HistoryChange >} Merged changes
       
   660  */
       
   661 function mergeHistoryChanges(changes1, changes2) {
       
   662   /**
       
   663    * @type {Record< string, HistoryChange >}
       
   664    */
       
   665   const newChanges = {
       
   666     ...changes1
       
   667   };
       
   668   Object.entries(changes2).forEach(([key, value]) => {
       
   669     if (newChanges[key]) {
       
   670       newChanges[key] = {
       
   671         ...newChanges[key],
       
   672         to: value.to
       
   673       };
       
   674     } else {
       
   675       newChanges[key] = value;
       
   676     }
       
   677   });
       
   678   return newChanges;
       
   679 }
       
   680 
       
   681 /**
       
   682  * Adds history changes for a single item into a record of changes.
       
   683  *
       
   684  * @param {HistoryRecord}  record  The record to merge into.
       
   685  * @param {HistoryChanges} changes The changes to merge.
       
   686  */
       
   687 const addHistoryChangesIntoRecord = (record, changes) => {
       
   688   const existingChangesIndex = record?.findIndex(({
       
   689     id: recordIdentifier
       
   690   }) => {
       
   691     return typeof recordIdentifier === 'string' ? recordIdentifier === changes.id : external_wp_isShallowEqual_default()(recordIdentifier, changes.id);
       
   692   });
       
   693   const nextRecord = [...record];
       
   694   if (existingChangesIndex !== -1) {
       
   695     // If the edit is already in the stack leave the initial "from" value.
       
   696     nextRecord[existingChangesIndex] = {
       
   697       id: changes.id,
       
   698       changes: mergeHistoryChanges(nextRecord[existingChangesIndex].changes, changes.changes)
       
   699     };
       
   700   } else {
       
   701     nextRecord.push(changes);
       
   702   }
       
   703   return nextRecord;
       
   704 };
       
   705 
       
   706 /**
       
   707  * Creates an undo manager.
       
   708  *
       
   709  * @return {UndoManager} Undo manager.
       
   710  */
       
   711 function createUndoManager() {
       
   712   /**
       
   713    * @type {HistoryRecord[]}
       
   714    */
       
   715   let history = [];
       
   716   /**
       
   717    * @type {HistoryRecord}
       
   718    */
       
   719   let stagedRecord = [];
       
   720   /**
       
   721    * @type {number}
       
   722    */
       
   723   let offset = 0;
       
   724   const dropPendingRedos = () => {
       
   725     history = history.slice(0, offset || undefined);
       
   726     offset = 0;
       
   727   };
       
   728   const appendStagedRecordToLatestHistoryRecord = () => {
       
   729     var _history$index;
       
   730     const index = history.length === 0 ? 0 : history.length - 1;
       
   731     let latestRecord = (_history$index = history[index]) !== null && _history$index !== void 0 ? _history$index : [];
       
   732     stagedRecord.forEach(changes => {
       
   733       latestRecord = addHistoryChangesIntoRecord(latestRecord, changes);
       
   734     });
       
   735     stagedRecord = [];
       
   736     history[index] = latestRecord;
       
   737   };
       
   738 
       
   739   /**
       
   740    * Checks whether a record is empty.
       
   741    * A record is considered empty if it the changes keep the same values.
       
   742    * Also updates to function values are ignored.
       
   743    *
       
   744    * @param {HistoryRecord} record
       
   745    * @return {boolean} Whether the record is empty.
       
   746    */
       
   747   const isRecordEmpty = record => {
       
   748     const filteredRecord = record.filter(({
       
   749       changes
       
   750     }) => {
       
   751       return Object.values(changes).some(({
       
   752         from,
       
   753         to
       
   754       }) => typeof from !== 'function' && typeof to !== 'function' && !external_wp_isShallowEqual_default()(from, to));
       
   755     });
       
   756     return !filteredRecord.length;
       
   757   };
       
   758   return {
       
   759     /**
       
   760      * Record changes into the history.
       
   761      *
       
   762      * @param {HistoryRecord=} record   A record of changes to record.
       
   763      * @param {boolean}        isStaged Whether to immediately create an undo point or not.
       
   764      */
       
   765     addRecord(record, isStaged = false) {
       
   766       const isEmpty = !record || isRecordEmpty(record);
       
   767       if (isStaged) {
       
   768         if (isEmpty) {
       
   769           return;
       
   770         }
       
   771         record.forEach(changes => {
       
   772           stagedRecord = addHistoryChangesIntoRecord(stagedRecord, changes);
       
   773         });
       
   774       } else {
       
   775         dropPendingRedos();
       
   776         if (stagedRecord.length) {
       
   777           appendStagedRecordToLatestHistoryRecord();
       
   778         }
       
   779         if (isEmpty) {
       
   780           return;
       
   781         }
       
   782         history.push(record);
       
   783       }
       
   784     },
       
   785     undo() {
       
   786       if (stagedRecord.length) {
       
   787         dropPendingRedos();
       
   788         appendStagedRecordToLatestHistoryRecord();
       
   789       }
       
   790       const undoRecord = history[history.length - 1 + offset];
       
   791       if (!undoRecord) {
       
   792         return;
       
   793       }
       
   794       offset -= 1;
       
   795       return undoRecord;
       
   796     },
       
   797     redo() {
       
   798       const redoRecord = history[history.length + offset];
       
   799       if (!redoRecord) {
       
   800         return;
       
   801       }
       
   802       offset += 1;
       
   803       return redoRecord;
       
   804     },
       
   805     hasUndo() {
       
   806       return !!history[history.length - 1 + offset];
       
   807     },
       
   808     hasRedo() {
       
   809       return !!history[history.length + offset];
       
   810     }
       
   811   };
       
   812 }
       
   813 
       
   814 ;// ./node_modules/@wordpress/core-data/build-module/utils/if-matching-action.js
   818 /** @typedef {import('../types').AnyFunction} AnyFunction */
   815 /** @typedef {import('../types').AnyFunction} AnyFunction */
   819 
   816 
   820 /**
   817 /**
   821  * A higher-order reducer creator which invokes the original reducer only if
   818  * A higher-order reducer creator which invokes the original reducer only if
   822  * the dispatching action matches the given predicate, **OR** if state is
   819  * the dispatching action matches the given predicate, **OR** if state is
   832   }
   829   }
   833   return state;
   830   return state;
   834 };
   831 };
   835 /* harmony default export */ const if_matching_action = (ifMatchingAction);
   832 /* harmony default export */ const if_matching_action = (ifMatchingAction);
   836 
   833 
   837 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js
   834 ;// ./node_modules/@wordpress/core-data/build-module/utils/replace-action.js
   838 /** @typedef {import('../types').AnyFunction} AnyFunction */
   835 /** @typedef {import('../types').AnyFunction} AnyFunction */
   839 
   836 
   840 /**
   837 /**
   841  * Higher-order reducer creator which substitutes the action object before
   838  * Higher-order reducer creator which substitutes the action object before
   842  * passing to the original reducer.
   839  * passing to the original reducer.
   848 const replaceAction = replacer => reducer => (state, action) => {
   845 const replaceAction = replacer => reducer => (state, action) => {
   849   return reducer(state, replacer(action));
   846   return reducer(state, replacer(action));
   850 };
   847 };
   851 /* harmony default export */ const replace_action = (replaceAction);
   848 /* harmony default export */ const replace_action = (replaceAction);
   852 
   849 
   853 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js
   850 ;// ./node_modules/@wordpress/core-data/build-module/utils/conservative-map-item.js
   854 /**
   851 /**
   855  * External dependencies
   852  * External dependencies
   856  */
   853  */
   857 
   854 
   858 
   855 
   894     }
   891     }
   895   }
   892   }
   896   return result;
   893   return result;
   897 }
   894 }
   898 
   895 
   899 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js
   896 ;// ./node_modules/@wordpress/core-data/build-module/utils/on-sub-key.js
   900 /** @typedef {import('../types').AnyFunction} AnyFunction */
   897 /** @typedef {import('../types').AnyFunction} AnyFunction */
   901 
   898 
   902 /**
   899 /**
   903  * Higher-order reducer creator which creates a combined reducer object, keyed
   900  * Higher-order reducer creator which creates a combined reducer object, keyed
   904  * by a property on the action object.
   901  * by a property on the action object.
   926     [key]: nextKeyState
   923     [key]: nextKeyState
   927   };
   924   };
   928 };
   925 };
   929 /* harmony default export */ const on_sub_key = (onSubKey);
   926 /* harmony default export */ const on_sub_key = (onSubKey);
   930 
   927 
   931 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
   928 ;// ./node_modules/tslib/tslib.es6.mjs
   932 /******************************************************************************
   929 /******************************************************************************
   933 Copyright (c) Microsoft Corporation.
   930 Copyright (c) Microsoft Corporation.
   934 
   931 
   935 Permission to use, copy, modify, and/or distribute this software for any
   932 Permission to use, copy, modify, and/or distribute this software for any
   936 purpose with or without fee is hereby granted.
   933 purpose with or without fee is hereby granted.
   941 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
   938 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
   942 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
   939 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
   943 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
   940 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
   944 PERFORMANCE OF THIS SOFTWARE.
   941 PERFORMANCE OF THIS SOFTWARE.
   945 ***************************************************************************** */
   942 ***************************************************************************** */
   946 /* global Reflect, Promise, SuppressedError, Symbol */
   943 /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
   947 
   944 
   948 var extendStatics = function(d, b) {
   945 var extendStatics = function(d, b) {
   949   extendStatics = Object.setPrototypeOf ||
   946   extendStatics = Object.setPrototypeOf ||
   950       ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
   947       ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
   951       function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
   948       function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1052       step((generator = generator.apply(thisArg, _arguments || [])).next());
  1049       step((generator = generator.apply(thisArg, _arguments || [])).next());
  1053   });
  1050   });
  1054 }
  1051 }
  1055 
  1052 
  1056 function __generator(thisArg, body) {
  1053 function __generator(thisArg, body) {
  1057   var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1054   var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
  1058   return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1055   return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1059   function verb(n) { return function (v) { return step([n, v]); }; }
  1056   function verb(n) { return function (v) { return step([n, v]); }; }
  1060   function step(op) {
  1057   function step(op) {
  1061       if (f) throw new TypeError("Generator is already executing.");
  1058       if (f) throw new TypeError("Generator is already executing.");
  1062       while (g && (g = 0, op[0] && (_ = 0)), _) try {
  1059       while (g && (g = 0, op[0] && (_ = 0)), _) try {
  1063           if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1060           if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1157 }
  1154 }
  1158 
  1155 
  1159 function __asyncGenerator(thisArg, _arguments, generator) {
  1156 function __asyncGenerator(thisArg, _arguments, generator) {
  1160   if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  1157   if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  1161   var g = generator.apply(thisArg, _arguments || []), i, q = [];
  1158   var g = generator.apply(thisArg, _arguments || []), i, q = [];
  1162   return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  1159   return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
  1163   function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  1160   function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
       
  1161   function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
  1164   function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  1162   function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  1165   function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  1163   function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  1166   function fulfill(value) { resume("next", value); }
  1164   function fulfill(value) { resume("next", value); }
  1167   function reject(value) { resume("throw", value); }
  1165   function reject(value) { resume("throw", value); }
  1168   function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  1166   function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  1191   Object.defineProperty(o, "default", { enumerable: true, value: v });
  1189   Object.defineProperty(o, "default", { enumerable: true, value: v });
  1192 }) : function(o, v) {
  1190 }) : function(o, v) {
  1193   o["default"] = v;
  1191   o["default"] = v;
  1194 };
  1192 };
  1195 
  1193 
       
  1194 var ownKeys = function(o) {
       
  1195   ownKeys = Object.getOwnPropertyNames || function (o) {
       
  1196     var ar = [];
       
  1197     for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
       
  1198     return ar;
       
  1199   };
       
  1200   return ownKeys(o);
       
  1201 };
       
  1202 
  1196 function __importStar(mod) {
  1203 function __importStar(mod) {
  1197   if (mod && mod.__esModule) return mod;
  1204   if (mod && mod.__esModule) return mod;
  1198   var result = {};
  1205   var result = {};
  1199   if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  1206   if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
  1200   __setModuleDefault(result, mod);
  1207   __setModuleDefault(result, mod);
  1201   return result;
  1208   return result;
  1202 }
  1209 }
  1203 
  1210 
  1204 function __importDefault(mod) {
  1211 function __importDefault(mod) {
  1224 }
  1231 }
  1225 
  1232 
  1226 function __addDisposableResource(env, value, async) {
  1233 function __addDisposableResource(env, value, async) {
  1227   if (value !== null && value !== void 0) {
  1234   if (value !== null && value !== void 0) {
  1228     if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
  1235     if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
  1229     var dispose;
  1236     var dispose, inner;
  1230     if (async) {
  1237     if (async) {
  1231         if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
  1238       if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
  1232         dispose = value[Symbol.asyncDispose];
  1239       dispose = value[Symbol.asyncDispose];
  1233     }
  1240     }
  1234     if (dispose === void 0) {
  1241     if (dispose === void 0) {
  1235         if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
  1242       if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
  1236         dispose = value[Symbol.dispose];
  1243       dispose = value[Symbol.dispose];
       
  1244       if (async) inner = dispose;
  1237     }
  1245     }
  1238     if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
  1246     if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
       
  1247     if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
  1239     env.stack.push({ value: value, dispose: dispose, async: async });
  1248     env.stack.push({ value: value, dispose: dispose, async: async });
  1240   }
  1249   }
  1241   else if (async) {
  1250   else if (async) {
  1242     env.stack.push({ async: true });
  1251     env.stack.push({ async: true });
  1243   }
  1252   }
  1252 function __disposeResources(env) {
  1261 function __disposeResources(env) {
  1253   function fail(e) {
  1262   function fail(e) {
  1254     env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
  1263     env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
  1255     env.hasError = true;
  1264     env.hasError = true;
  1256   }
  1265   }
       
  1266   var r, s = 0;
  1257   function next() {
  1267   function next() {
  1258     while (env.stack.length) {
  1268     while (r = env.stack.pop()) {
  1259       var rec = env.stack.pop();
       
  1260       try {
  1269       try {
  1261         var result = rec.dispose && rec.dispose.call(rec.value);
  1270         if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
  1262         if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
  1271         if (r.dispose) {
       
  1272           var result = r.dispose.call(r.value);
       
  1273           if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
       
  1274         }
       
  1275         else s |= 1;
  1263       }
  1276       }
  1264       catch (e) {
  1277       catch (e) {
  1265           fail(e);
  1278         fail(e);
  1266       }
  1279       }
  1267     }
  1280     }
       
  1281     if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
  1268     if (env.hasError) throw env.error;
  1282     if (env.hasError) throw env.error;
  1269   }
  1283   }
  1270   return next();
  1284   return next();
       
  1285 }
       
  1286 
       
  1287 function __rewriteRelativeImportExtension(path, preserveJsx) {
       
  1288   if (typeof path === "string" && /^\.\.?\//.test(path)) {
       
  1289       return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
       
  1290           return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
       
  1291       });
       
  1292   }
       
  1293   return path;
  1271 }
  1294 }
  1272 
  1295 
  1273 /* harmony default export */ const tslib_es6 = ({
  1296 /* harmony default export */ const tslib_es6 = ({
  1274   __extends,
  1297   __extends,
  1275   __assign,
  1298   __assign,
  1276   __rest,
  1299   __rest,
  1277   __decorate,
  1300   __decorate,
  1278   __param,
  1301   __param,
       
  1302   __esDecorate,
       
  1303   __runInitializers,
       
  1304   __propKey,
       
  1305   __setFunctionName,
  1279   __metadata,
  1306   __metadata,
  1280   __awaiter,
  1307   __awaiter,
  1281   __generator,
  1308   __generator,
  1282   __createBinding,
  1309   __createBinding,
  1283   __exportStar,
  1310   __exportStar,
  1296   __classPrivateFieldGet,
  1323   __classPrivateFieldGet,
  1297   __classPrivateFieldSet,
  1324   __classPrivateFieldSet,
  1298   __classPrivateFieldIn,
  1325   __classPrivateFieldIn,
  1299   __addDisposableResource,
  1326   __addDisposableResource,
  1300   __disposeResources,
  1327   __disposeResources,
       
  1328   __rewriteRelativeImportExtension,
  1301 });
  1329 });
  1302 
  1330 
  1303 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
  1331 ;// ./node_modules/lower-case/dist.es2015/index.js
  1304 /**
  1332 /**
  1305  * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  1333  * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  1306  */
  1334  */
  1307 var SUPPORTED_LOCALE = {
  1335 var SUPPORTED_LOCALE = {
  1308     tr: {
  1336     tr: {
  1347  */
  1375  */
  1348 function lowerCase(str) {
  1376 function lowerCase(str) {
  1349     return str.toLowerCase();
  1377     return str.toLowerCase();
  1350 }
  1378 }
  1351 
  1379 
  1352 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
  1380 ;// ./node_modules/no-case/dist.es2015/index.js
  1353 
  1381 
  1354 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
  1382 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
  1355 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
  1383 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
  1356 // Remove all non-word characters.
  1384 // Remove all non-word characters.
  1357 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
  1385 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
  1379     if (re instanceof RegExp)
  1407     if (re instanceof RegExp)
  1380         return input.replace(re, value);
  1408         return input.replace(re, value);
  1381     return re.reduce(function (input, re) { return input.replace(re, value); }, input);
  1409     return re.reduce(function (input, re) { return input.replace(re, value); }, input);
  1382 }
  1410 }
  1383 
  1411 
  1384 ;// CONCATENATED MODULE: ./node_modules/upper-case-first/dist.es2015/index.js
  1412 ;// ./node_modules/upper-case-first/dist.es2015/index.js
  1385 /**
  1413 /**
  1386  * Upper case the first character of an input string.
  1414  * Upper case the first character of an input string.
  1387  */
  1415  */
  1388 function upperCaseFirst(input) {
  1416 function upperCaseFirst(input) {
  1389     return input.charAt(0).toUpperCase() + input.substr(1);
  1417     return input.charAt(0).toUpperCase() + input.substr(1);
  1390 }
  1418 }
  1391 
  1419 
  1392 ;// CONCATENATED MODULE: ./node_modules/capital-case/dist.es2015/index.js
  1420 ;// ./node_modules/capital-case/dist.es2015/index.js
  1393 
  1421 
  1394 
  1422 
  1395 
  1423 
  1396 function capitalCaseTransform(input) {
  1424 function capitalCaseTransform(input) {
  1397     return upperCaseFirst(input.toLowerCase());
  1425     return upperCaseFirst(input.toLowerCase());
  1399 function capitalCase(input, options) {
  1427 function capitalCase(input, options) {
  1400     if (options === void 0) { options = {}; }
  1428     if (options === void 0) { options = {}; }
  1401     return noCase(input, __assign({ delimiter: " ", transform: capitalCaseTransform }, options));
  1429     return noCase(input, __assign({ delimiter: " ", transform: capitalCaseTransform }, options));
  1402 }
  1430 }
  1403 
  1431 
  1404 ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
  1432 ;// ./node_modules/pascal-case/dist.es2015/index.js
  1405 
  1433 
  1406 
  1434 
  1407 function pascalCaseTransform(input, index) {
  1435 function pascalCaseTransform(input, index) {
  1408     var firstChar = input.charAt(0);
  1436     var firstChar = input.charAt(0);
  1409     var lowerChars = input.substr(1).toLowerCase();
  1437     var lowerChars = input.substr(1).toLowerCase();
  1418 function pascalCase(input, options) {
  1446 function pascalCase(input, options) {
  1419     if (options === void 0) { options = {}; }
  1447     if (options === void 0) { options = {}; }
  1420     return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
  1448     return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
  1421 }
  1449 }
  1422 
  1450 
  1423 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
  1451 ;// external ["wp","apiFetch"]
  1424 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  1452 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
  1425 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  1453 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
  1426 ;// CONCATENATED MODULE: external ["wp","i18n"]
  1454 ;// external ["wp","i18n"]
  1427 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  1455 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  1428 ;// CONCATENATED MODULE: external ["wp","richText"]
  1456 ;// external ["wp","richText"]
  1429 const external_wp_richText_namespaceObject = window["wp"]["richText"];
  1457 const external_wp_richText_namespaceObject = window["wp"]["richText"];
  1430 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js
  1458 ;// ./node_modules/@wordpress/core-data/build-module/entities.js
  1431 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
  1459 /**
  1432 /* harmony default export */ const esm_browser_native = ({
  1460  * External dependencies
  1433   randomUUID
  1461  */
  1434 });
  1462 
  1435 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
  1463 
  1436 // Unique ID creation requires a high quality random # generator. In the browser we therefore
       
  1437 // require the crypto API and do not support built-in fallback to lower quality random number
       
  1438 // generators (like Math.random()).
       
  1439 let getRandomValues;
       
  1440 const rnds8 = new Uint8Array(16);
       
  1441 function rng() {
       
  1442   // lazy load so that environments that need to polyfill have a chance to do so
       
  1443   if (!getRandomValues) {
       
  1444     // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
       
  1445     getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
       
  1446 
       
  1447     if (!getRandomValues) {
       
  1448       throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
       
  1449     }
       
  1450   }
       
  1451 
       
  1452   return getRandomValues(rnds8);
       
  1453 }
       
  1454 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
       
  1455 
       
  1456 /**
       
  1457  * Convert array of 16 byte values to UUID string format of the form:
       
  1458  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
       
  1459  */
       
  1460 
       
  1461 const byteToHex = [];
       
  1462 
       
  1463 for (let i = 0; i < 256; ++i) {
       
  1464   byteToHex.push((i + 0x100).toString(16).slice(1));
       
  1465 }
       
  1466 
       
  1467 function unsafeStringify(arr, offset = 0) {
       
  1468   // Note: Be careful editing this code!  It's been tuned for performance
       
  1469   // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
       
  1470   return 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]];
       
  1471 }
       
  1472 
       
  1473 function stringify(arr, offset = 0) {
       
  1474   const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID.  If this throws, it's likely due to one
       
  1475   // of the following:
       
  1476   // - One or more input array values don't map to a hex octet (leading to
       
  1477   // "undefined" in the uuid)
       
  1478   // - Invalid input values for the RFC `version` or `variant` fields
       
  1479 
       
  1480   if (!validate(uuid)) {
       
  1481     throw TypeError('Stringified UUID is invalid');
       
  1482   }
       
  1483 
       
  1484   return uuid;
       
  1485 }
       
  1486 
       
  1487 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
       
  1488 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
       
  1489 
       
  1490 
       
  1491 
       
  1492 
       
  1493 function v4(options, buf, offset) {
       
  1494   if (esm_browser_native.randomUUID && !buf && !options) {
       
  1495     return esm_browser_native.randomUUID();
       
  1496   }
       
  1497 
       
  1498   options = options || {};
       
  1499   const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
       
  1500 
       
  1501   rnds[6] = rnds[6] & 0x0f | 0x40;
       
  1502   rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
       
  1503 
       
  1504   if (buf) {
       
  1505     offset = offset || 0;
       
  1506 
       
  1507     for (let i = 0; i < 16; ++i) {
       
  1508       buf[offset + i] = rnds[i];
       
  1509     }
       
  1510 
       
  1511     return buf;
       
  1512   }
       
  1513 
       
  1514   return unsafeStringify(rnds);
       
  1515 }
       
  1516 
       
  1517 /* harmony default export */ const esm_browser_v4 = (v4);
       
  1518 ;// CONCATENATED MODULE: external ["wp","url"]
       
  1519 const external_wp_url_namespaceObject = window["wp"]["url"];
       
  1520 ;// CONCATENATED MODULE: external ["wp","deprecated"]
       
  1521 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
       
  1522 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
       
  1523 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/set-nested-value.js
       
  1524 /**
       
  1525  * Sets the value at path of object.
       
  1526  * If a portion of path doesn’t exist, it’s created.
       
  1527  * Arrays are created for missing index properties while objects are created
       
  1528  * for all other missing properties.
       
  1529  *
       
  1530  * Path is specified as either:
       
  1531  * - a string of properties, separated by dots, for example: "x.y".
       
  1532  * - an array of properties, for example `[ 'x', 'y' ]`.
       
  1533  *
       
  1534  * This function intentionally mutates the input object.
       
  1535  *
       
  1536  * Inspired by _.set().
       
  1537  *
       
  1538  * @see https://lodash.com/docs/4.17.15#set
       
  1539  *
       
  1540  * @todo Needs to be deduplicated with its copy in `@wordpress/edit-site`.
       
  1541  *
       
  1542  * @param {Object}       object Object to modify
       
  1543  * @param {Array|string} path   Path of the property to set.
       
  1544  * @param {*}            value  Value to set.
       
  1545  */
       
  1546 function setNestedValue(object, path, value) {
       
  1547   if (!object || typeof object !== 'object') {
       
  1548     return object;
       
  1549   }
       
  1550   const normalizedPath = Array.isArray(path) ? path : path.split('.');
       
  1551   normalizedPath.reduce((acc, key, idx) => {
       
  1552     if (acc[key] === undefined) {
       
  1553       if (Number.isInteger(normalizedPath[idx + 1])) {
       
  1554         acc[key] = [];
       
  1555       } else {
       
  1556         acc[key] = {};
       
  1557       }
       
  1558     }
       
  1559     if (idx === normalizedPath.length - 1) {
       
  1560       acc[key] = value;
       
  1561     }
       
  1562     return acc[key];
       
  1563   }, object);
       
  1564   return object;
       
  1565 }
       
  1566 
       
  1567 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/get-nested-value.js
       
  1568 /**
       
  1569  * Helper util to return a value from a certain path of the object.
       
  1570  * Path is specified as either:
       
  1571  * - a string of properties, separated by dots, for example: "x.y".
       
  1572  * - an array of properties, for example `[ 'x', 'y' ]`.
       
  1573  * You can also specify a default value in case the result is nullish.
       
  1574  *
       
  1575  * @param {Object}       object       Input object.
       
  1576  * @param {string|Array} path         Path to the object property.
       
  1577  * @param {*}            defaultValue Default value if the value at the specified path is undefined.
       
  1578  * @return {*} Value of the object property at the specified path.
       
  1579  */
       
  1580 function getNestedValue(object, path, defaultValue) {
       
  1581   if (!object || typeof object !== 'object' || typeof path !== 'string' && !Array.isArray(path)) {
       
  1582     return object;
       
  1583   }
       
  1584   const normalizedPath = Array.isArray(path) ? path : path.split('.');
       
  1585   let value = object;
       
  1586   normalizedPath.forEach(fieldName => {
       
  1587     value = value?.[fieldName];
       
  1588   });
       
  1589   return value !== undefined ? value : defaultValue;
       
  1590 }
       
  1591 
       
  1592 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js
       
  1593 /**
       
  1594  * Returns an action object used in signalling that items have been received.
       
  1595  *
       
  1596  * @param {Array}   items Items received.
       
  1597  * @param {?Object} edits Optional edits to reset.
       
  1598  * @param {?Object} meta  Meta information about pagination.
       
  1599  *
       
  1600  * @return {Object} Action object.
       
  1601  */
       
  1602 function receiveItems(items, edits, meta) {
       
  1603   return {
       
  1604     type: 'RECEIVE_ITEMS',
       
  1605     items: Array.isArray(items) ? items : [items],
       
  1606     persistedEdits: edits,
       
  1607     meta
       
  1608   };
       
  1609 }
       
  1610 
       
  1611 /**
       
  1612  * Returns an action object used in signalling that entity records have been
       
  1613  * deleted and they need to be removed from entities state.
       
  1614  *
       
  1615  * @param {string}              kind            Kind of the removed entities.
       
  1616  * @param {string}              name            Name of the removed entities.
       
  1617  * @param {Array|number|string} records         Record IDs of the removed entities.
       
  1618  * @param {boolean}             invalidateCache Controls whether we want to invalidate the cache.
       
  1619  * @return {Object} Action object.
       
  1620  */
       
  1621 function removeItems(kind, name, records, invalidateCache = false) {
       
  1622   return {
       
  1623     type: 'REMOVE_ITEMS',
       
  1624     itemIds: Array.isArray(records) ? records : [records],
       
  1625     kind,
       
  1626     name,
       
  1627     invalidateCache
       
  1628   };
       
  1629 }
       
  1630 
       
  1631 /**
       
  1632  * Returns an action object used in signalling that queried data has been
       
  1633  * received.
       
  1634  *
       
  1635  * @param {Array}   items Queried items received.
       
  1636  * @param {?Object} query Optional query object.
       
  1637  * @param {?Object} edits Optional edits to reset.
       
  1638  * @param {?Object} meta  Meta information about pagination.
       
  1639  *
       
  1640  * @return {Object} Action object.
       
  1641  */
       
  1642 function receiveQueriedItems(items, query = {}, edits, meta) {
       
  1643   return {
       
  1644     ...receiveItems(items, edits, meta),
       
  1645     query
       
  1646   };
       
  1647 }
       
  1648 
       
  1649 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/default-processor.js
       
  1650 /**
  1464 /**
  1651  * WordPress dependencies
  1465  * WordPress dependencies
  1652  */
  1466  */
  1653 
  1467 
  1654 
       
  1655 /**
       
  1656  * Maximum number of requests to place in a single batch request. Obtained by
       
  1657  * sending a preflight OPTIONS request to /batch/v1/.
       
  1658  *
       
  1659  * @type {number?}
       
  1660  */
       
  1661 let maxItems = null;
       
  1662 function chunk(arr, chunkSize) {
       
  1663   const tmp = [...arr];
       
  1664   const cache = [];
       
  1665   while (tmp.length) {
       
  1666     cache.push(tmp.splice(0, chunkSize));
       
  1667   }
       
  1668   return cache;
       
  1669 }
       
  1670 
       
  1671 /**
       
  1672  * Default batch processor. Sends its input requests to /batch/v1.
       
  1673  *
       
  1674  * @param {Array} requests List of API requests to perform at once.
       
  1675  *
       
  1676  * @return {Promise} Promise that resolves to a list of objects containing
       
  1677  *                   either `output` (if that request was successful) or `error`
       
  1678  *                   (if not ).
       
  1679  */
       
  1680 async function defaultProcessor(requests) {
       
  1681   if (maxItems === null) {
       
  1682     const preflightResponse = await external_wp_apiFetch_default()({
       
  1683       path: '/batch/v1',
       
  1684       method: 'OPTIONS'
       
  1685     });
       
  1686     maxItems = preflightResponse.endpoints[0].args.requests.maxItems;
       
  1687   }
       
  1688   const results = [];
       
  1689 
       
  1690   // @ts-ignore We would have crashed or never gotten to this point if we hadn't received the maxItems count.
       
  1691   for (const batchRequests of chunk(requests, maxItems)) {
       
  1692     const batchResponse = await external_wp_apiFetch_default()({
       
  1693       path: '/batch/v1',
       
  1694       method: 'POST',
       
  1695       data: {
       
  1696         validation: 'require-all-validate',
       
  1697         requests: batchRequests.map(request => ({
       
  1698           path: request.path,
       
  1699           body: request.data,
       
  1700           // Rename 'data' to 'body'.
       
  1701           method: request.method,
       
  1702           headers: request.headers
       
  1703         }))
       
  1704       }
       
  1705     });
       
  1706     let batchResults;
       
  1707     if (batchResponse.failed) {
       
  1708       batchResults = batchResponse.responses.map(response => ({
       
  1709         error: response?.body
       
  1710       }));
       
  1711     } else {
       
  1712       batchResults = batchResponse.responses.map(response => {
       
  1713         const result = {};
       
  1714         if (response.status >= 200 && response.status < 300) {
       
  1715           result.output = response.body;
       
  1716         } else {
       
  1717           result.error = response.body;
       
  1718         }
       
  1719         return result;
       
  1720       });
       
  1721     }
       
  1722     results.push(...batchResults);
       
  1723   }
       
  1724   return results;
       
  1725 }
       
  1726 
       
  1727 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/batch/create-batch.js
       
  1728 /**
       
  1729  * Internal dependencies
       
  1730  */
       
  1731 
       
  1732 
       
  1733 /**
       
  1734  * Creates a batch, which can be used to combine multiple API requests into one
       
  1735  * API request using the WordPress batch processing API (/v1/batch).
       
  1736  *
       
  1737  * ```
       
  1738  * const batch = createBatch();
       
  1739  * const dunePromise = batch.add( {
       
  1740  *   path: '/v1/books',
       
  1741  *   method: 'POST',
       
  1742  *   data: { title: 'Dune' }
       
  1743  * } );
       
  1744  * const lotrPromise = batch.add( {
       
  1745  *   path: '/v1/books',
       
  1746  *   method: 'POST',
       
  1747  *   data: { title: 'Lord of the Rings' }
       
  1748  * } );
       
  1749  * const isSuccess = await batch.run(); // Sends one POST to /v1/batch.
       
  1750  * if ( isSuccess ) {
       
  1751  *   console.log(
       
  1752  *     'Saved two books:',
       
  1753  *     await dunePromise,
       
  1754  *     await lotrPromise
       
  1755  *   );
       
  1756  * }
       
  1757  * ```
       
  1758  *
       
  1759  * @param {Function} [processor] Processor function. Can be used to replace the
       
  1760  *                               default functionality which is to send an API
       
  1761  *                               request to /v1/batch. Is given an array of
       
  1762  *                               inputs and must return a promise that
       
  1763  *                               resolves to an array of objects containing
       
  1764  *                               either `output` or `error`.
       
  1765  */
       
  1766 function createBatch(processor = defaultProcessor) {
       
  1767   let lastId = 0;
       
  1768   /** @type {Array<{ input: any; resolve: ( value: any ) => void; reject: ( error: any ) => void }>} */
       
  1769   let queue = [];
       
  1770   const pending = new ObservableSet();
       
  1771   return {
       
  1772     /**
       
  1773      * Adds an input to the batch and returns a promise that is resolved or
       
  1774      * rejected when the input is processed by `batch.run()`.
       
  1775      *
       
  1776      * You may also pass a thunk which allows inputs to be added
       
  1777      * asychronously.
       
  1778      *
       
  1779      * ```
       
  1780      * // Both are allowed:
       
  1781      * batch.add( { path: '/v1/books', ... } );
       
  1782      * batch.add( ( add ) => add( { path: '/v1/books', ... } ) );
       
  1783      * ```
       
  1784      *
       
  1785      * If a thunk is passed, `batch.run()` will pause until either:
       
  1786      *
       
  1787      * - The thunk calls its `add` argument, or;
       
  1788      * - The thunk returns a promise and that promise resolves, or;
       
  1789      * - The thunk returns a non-promise.
       
  1790      *
       
  1791      * @param {any|Function} inputOrThunk Input to add or thunk to execute.
       
  1792      *
       
  1793      * @return {Promise|any} If given an input, returns a promise that
       
  1794      *                       is resolved or rejected when the batch is
       
  1795      *                       processed. If given a thunk, returns the return
       
  1796      *                       value of that thunk.
       
  1797      */
       
  1798     add(inputOrThunk) {
       
  1799       const id = ++lastId;
       
  1800       pending.add(id);
       
  1801       const add = input => new Promise((resolve, reject) => {
       
  1802         queue.push({
       
  1803           input,
       
  1804           resolve,
       
  1805           reject
       
  1806         });
       
  1807         pending.delete(id);
       
  1808       });
       
  1809       if (typeof inputOrThunk === 'function') {
       
  1810         return Promise.resolve(inputOrThunk(add)).finally(() => {
       
  1811           pending.delete(id);
       
  1812         });
       
  1813       }
       
  1814       return add(inputOrThunk);
       
  1815     },
       
  1816     /**
       
  1817      * Runs the batch. This calls `batchProcessor` and resolves or rejects
       
  1818      * all promises returned by `add()`.
       
  1819      *
       
  1820      * @return {Promise<boolean>} A promise that resolves to a boolean that is true
       
  1821      *                   if the processor returned no errors.
       
  1822      */
       
  1823     async run() {
       
  1824       if (pending.size) {
       
  1825         await new Promise(resolve => {
       
  1826           const unsubscribe = pending.subscribe(() => {
       
  1827             if (!pending.size) {
       
  1828               unsubscribe();
       
  1829               resolve(undefined);
       
  1830             }
       
  1831           });
       
  1832         });
       
  1833       }
       
  1834       let results;
       
  1835       try {
       
  1836         results = await processor(queue.map(({
       
  1837           input
       
  1838         }) => input));
       
  1839         if (results.length !== queue.length) {
       
  1840           throw new Error('run: Array returned by processor must be same size as input array.');
       
  1841         }
       
  1842       } catch (error) {
       
  1843         for (const {
       
  1844           reject
       
  1845         } of queue) {
       
  1846           reject(error);
       
  1847         }
       
  1848         throw error;
       
  1849       }
       
  1850       let isSuccess = true;
       
  1851       results.forEach((result, key) => {
       
  1852         const queueItem = queue[key];
       
  1853         if (result?.error) {
       
  1854           queueItem?.reject(result.error);
       
  1855           isSuccess = false;
       
  1856         } else {
       
  1857           var _result$output;
       
  1858           queueItem?.resolve((_result$output = result?.output) !== null && _result$output !== void 0 ? _result$output : result);
       
  1859         }
       
  1860       });
       
  1861       queue = [];
       
  1862       return isSuccess;
       
  1863     }
       
  1864   };
       
  1865 }
       
  1866 class ObservableSet {
       
  1867   constructor(...args) {
       
  1868     this.set = new Set(...args);
       
  1869     this.subscribers = new Set();
       
  1870   }
       
  1871   get size() {
       
  1872     return this.set.size;
       
  1873   }
       
  1874   add(value) {
       
  1875     this.set.add(value);
       
  1876     this.subscribers.forEach(subscriber => subscriber());
       
  1877     return this;
       
  1878   }
       
  1879   delete(value) {
       
  1880     const isSuccess = this.set.delete(value);
       
  1881     this.subscribers.forEach(subscriber => subscriber());
       
  1882     return isSuccess;
       
  1883   }
       
  1884   subscribe(subscriber) {
       
  1885     this.subscribers.add(subscriber);
       
  1886     return () => {
       
  1887       this.subscribers.delete(subscriber);
       
  1888     };
       
  1889   }
       
  1890 }
       
  1891 
       
  1892 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/name.js
       
  1893 /**
       
  1894  * The reducer key used by core data in store registration.
       
  1895  * This is defined in a separate file to avoid cycle-dependency
       
  1896  *
       
  1897  * @type {string}
       
  1898  */
       
  1899 const STORE_NAME = 'core';
       
  1900 
       
  1901 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/actions.js
       
  1902 /**
       
  1903  * External dependencies
       
  1904  */
       
  1905 
       
  1906 
       
  1907 
       
  1908 /**
       
  1909  * WordPress dependencies
       
  1910  */
       
  1911 
       
  1912 
       
  1913 
       
  1914 
       
  1915 /**
       
  1916  * Internal dependencies
       
  1917  */
       
  1918 
       
  1919 
       
  1920 
       
  1921 
       
  1922 
       
  1923 
       
  1924 
       
  1925 /**
       
  1926  * Returns an action object used in signalling that authors have been received.
       
  1927  * Ignored from documentation as it's internal to the data store.
       
  1928  *
       
  1929  * @ignore
       
  1930  *
       
  1931  * @param {string}       queryID Query ID.
       
  1932  * @param {Array|Object} users   Users received.
       
  1933  *
       
  1934  * @return {Object} Action object.
       
  1935  */
       
  1936 function receiveUserQuery(queryID, users) {
       
  1937   return {
       
  1938     type: 'RECEIVE_USER_QUERY',
       
  1939     users: Array.isArray(users) ? users : [users],
       
  1940     queryID
       
  1941   };
       
  1942 }
       
  1943 
       
  1944 /**
       
  1945  * Returns an action used in signalling that the current user has been received.
       
  1946  * Ignored from documentation as it's internal to the data store.
       
  1947  *
       
  1948  * @ignore
       
  1949  *
       
  1950  * @param {Object} currentUser Current user object.
       
  1951  *
       
  1952  * @return {Object} Action object.
       
  1953  */
       
  1954 function receiveCurrentUser(currentUser) {
       
  1955   return {
       
  1956     type: 'RECEIVE_CURRENT_USER',
       
  1957     currentUser
       
  1958   };
       
  1959 }
       
  1960 
       
  1961 /**
       
  1962  * Returns an action object used in adding new entities.
       
  1963  *
       
  1964  * @param {Array} entities Entities received.
       
  1965  *
       
  1966  * @return {Object} Action object.
       
  1967  */
       
  1968 function addEntities(entities) {
       
  1969   return {
       
  1970     type: 'ADD_ENTITIES',
       
  1971     entities
       
  1972   };
       
  1973 }
       
  1974 
       
  1975 /**
       
  1976  * Returns an action object used in signalling that entity records have been received.
       
  1977  *
       
  1978  * @param {string}       kind            Kind of the received entity record.
       
  1979  * @param {string}       name            Name of the received entity record.
       
  1980  * @param {Array|Object} records         Records received.
       
  1981  * @param {?Object}      query           Query Object.
       
  1982  * @param {?boolean}     invalidateCache Should invalidate query caches.
       
  1983  * @param {?Object}      edits           Edits to reset.
       
  1984  * @param {?Object}      meta            Meta information about pagination.
       
  1985  * @return {Object} Action object.
       
  1986  */
       
  1987 function receiveEntityRecords(kind, name, records, query, invalidateCache = false, edits, meta) {
       
  1988   // Auto drafts should not have titles, but some plugins rely on them so we can't filter this
       
  1989   // on the server.
       
  1990   if (kind === 'postType') {
       
  1991     records = (Array.isArray(records) ? records : [records]).map(record => record.status === 'auto-draft' ? {
       
  1992       ...record,
       
  1993       title: ''
       
  1994     } : record);
       
  1995   }
       
  1996   let action;
       
  1997   if (query) {
       
  1998     action = receiveQueriedItems(records, query, edits, meta);
       
  1999   } else {
       
  2000     action = receiveItems(records, edits, meta);
       
  2001   }
       
  2002   return {
       
  2003     ...action,
       
  2004     kind,
       
  2005     name,
       
  2006     invalidateCache
       
  2007   };
       
  2008 }
       
  2009 
       
  2010 /**
       
  2011  * Returns an action object used in signalling that the current theme has been received.
       
  2012  * Ignored from documentation as it's internal to the data store.
       
  2013  *
       
  2014  * @ignore
       
  2015  *
       
  2016  * @param {Object} currentTheme The current theme.
       
  2017  *
       
  2018  * @return {Object} Action object.
       
  2019  */
       
  2020 function receiveCurrentTheme(currentTheme) {
       
  2021   return {
       
  2022     type: 'RECEIVE_CURRENT_THEME',
       
  2023     currentTheme
       
  2024   };
       
  2025 }
       
  2026 
       
  2027 /**
       
  2028  * Returns an action object used in signalling that the current global styles id has been received.
       
  2029  * Ignored from documentation as it's internal to the data store.
       
  2030  *
       
  2031  * @ignore
       
  2032  *
       
  2033  * @param {string} currentGlobalStylesId The current global styles id.
       
  2034  *
       
  2035  * @return {Object} Action object.
       
  2036  */
       
  2037 function __experimentalReceiveCurrentGlobalStylesId(currentGlobalStylesId) {
       
  2038   return {
       
  2039     type: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',
       
  2040     id: currentGlobalStylesId
       
  2041   };
       
  2042 }
       
  2043 
       
  2044 /**
       
  2045  * Returns an action object used in signalling that the theme base global styles have been received
       
  2046  * Ignored from documentation as it's internal to the data store.
       
  2047  *
       
  2048  * @ignore
       
  2049  *
       
  2050  * @param {string} stylesheet   The theme's identifier
       
  2051  * @param {Object} globalStyles The global styles object.
       
  2052  *
       
  2053  * @return {Object} Action object.
       
  2054  */
       
  2055 function __experimentalReceiveThemeBaseGlobalStyles(stylesheet, globalStyles) {
       
  2056   return {
       
  2057     type: 'RECEIVE_THEME_GLOBAL_STYLES',
       
  2058     stylesheet,
       
  2059     globalStyles
       
  2060   };
       
  2061 }
       
  2062 
       
  2063 /**
       
  2064  * Returns an action object used in signalling that the theme global styles variations have been received.
       
  2065  * Ignored from documentation as it's internal to the data store.
       
  2066  *
       
  2067  * @ignore
       
  2068  *
       
  2069  * @param {string} stylesheet The theme's identifier
       
  2070  * @param {Array}  variations The global styles variations.
       
  2071  *
       
  2072  * @return {Object} Action object.
       
  2073  */
       
  2074 function __experimentalReceiveThemeGlobalStyleVariations(stylesheet, variations) {
       
  2075   return {
       
  2076     type: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',
       
  2077     stylesheet,
       
  2078     variations
       
  2079   };
       
  2080 }
       
  2081 
       
  2082 /**
       
  2083  * Returns an action object used in signalling that the index has been received.
       
  2084  *
       
  2085  * @deprecated since WP 5.9, this is not useful anymore, use the selector direclty.
       
  2086  *
       
  2087  * @return {Object} Action object.
       
  2088  */
       
  2089 function receiveThemeSupports() {
       
  2090   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeSupports", {
       
  2091     since: '5.9'
       
  2092   });
       
  2093   return {
       
  2094     type: 'DO_NOTHING'
       
  2095   };
       
  2096 }
       
  2097 
       
  2098 /**
       
  2099  * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.
       
  2100  * Ignored from documentation as it's internal to the data store.
       
  2101  *
       
  2102  * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.
       
  2103  *
       
  2104  * @ignore
       
  2105  *
       
  2106  * @param {number} currentId The post id.
       
  2107  * @param {Array}  revisions The global styles revisions.
       
  2108  *
       
  2109  * @return {Object} Action object.
       
  2110  */
       
  2111 function receiveThemeGlobalStyleRevisions(currentId, revisions) {
       
  2112   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()", {
       
  2113     since: '6.5.0',
       
  2114     alternative: "wp.data.dispatch( 'core' ).receiveRevisions"
       
  2115   });
       
  2116   return {
       
  2117     type: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',
       
  2118     currentId,
       
  2119     revisions
       
  2120   };
       
  2121 }
       
  2122 
       
  2123 /**
       
  2124  * Returns an action object used in signalling that the preview data for
       
  2125  * a given URl has been received.
       
  2126  * Ignored from documentation as it's internal to the data store.
       
  2127  *
       
  2128  * @ignore
       
  2129  *
       
  2130  * @param {string} url     URL to preview the embed for.
       
  2131  * @param {*}      preview Preview data.
       
  2132  *
       
  2133  * @return {Object} Action object.
       
  2134  */
       
  2135 function receiveEmbedPreview(url, preview) {
       
  2136   return {
       
  2137     type: 'RECEIVE_EMBED_PREVIEW',
       
  2138     url,
       
  2139     preview
       
  2140   };
       
  2141 }
       
  2142 
       
  2143 /**
       
  2144  * Action triggered to delete an entity record.
       
  2145  *
       
  2146  * @param {string}   kind                         Kind of the deleted entity.
       
  2147  * @param {string}   name                         Name of the deleted entity.
       
  2148  * @param {string}   recordId                     Record ID of the deleted entity.
       
  2149  * @param {?Object}  query                        Special query parameters for the
       
  2150  *                                                DELETE API call.
       
  2151  * @param {Object}   [options]                    Delete options.
       
  2152  * @param {Function} [options.__unstableFetch]    Internal use only. Function to
       
  2153  *                                                call instead of `apiFetch()`.
       
  2154  *                                                Must return a promise.
       
  2155  * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all
       
  2156  *                                                the exceptions. Defaults to false.
       
  2157  */
       
  2158 const deleteEntityRecord = (kind, name, recordId, query, {
       
  2159   __unstableFetch = (external_wp_apiFetch_default()),
       
  2160   throwOnError = false
       
  2161 } = {}) => async ({
       
  2162   dispatch
       
  2163 }) => {
       
  2164   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  2165   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  2166   let error;
       
  2167   let deletedRecord = false;
       
  2168   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
       
  2169     return;
       
  2170   }
       
  2171   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId], {
       
  2172     exclusive: true
       
  2173   });
       
  2174   try {
       
  2175     dispatch({
       
  2176       type: 'DELETE_ENTITY_RECORD_START',
       
  2177       kind,
       
  2178       name,
       
  2179       recordId
       
  2180     });
       
  2181     let hasError = false;
       
  2182     try {
       
  2183       let path = `${entityConfig.baseURL}/${recordId}`;
       
  2184       if (query) {
       
  2185         path = (0,external_wp_url_namespaceObject.addQueryArgs)(path, query);
       
  2186       }
       
  2187       deletedRecord = await __unstableFetch({
       
  2188         path,
       
  2189         method: 'DELETE'
       
  2190       });
       
  2191       await dispatch(removeItems(kind, name, recordId, true));
       
  2192     } catch (_error) {
       
  2193       hasError = true;
       
  2194       error = _error;
       
  2195     }
       
  2196     dispatch({
       
  2197       type: 'DELETE_ENTITY_RECORD_FINISH',
       
  2198       kind,
       
  2199       name,
       
  2200       recordId,
       
  2201       error
       
  2202     });
       
  2203     if (hasError && throwOnError) {
       
  2204       throw error;
       
  2205     }
       
  2206     return deletedRecord;
       
  2207   } finally {
       
  2208     dispatch.__unstableReleaseStoreLock(lock);
       
  2209   }
       
  2210 };
       
  2211 
       
  2212 /**
       
  2213  * Returns an action object that triggers an
       
  2214  * edit to an entity record.
       
  2215  *
       
  2216  * @param {string}        kind                 Kind of the edited entity record.
       
  2217  * @param {string}        name                 Name of the edited entity record.
       
  2218  * @param {number|string} recordId             Record ID of the edited entity record.
       
  2219  * @param {Object}        edits                The edits.
       
  2220  * @param {Object}        options              Options for the edit.
       
  2221  * @param {boolean}       [options.undoIgnore] Whether to ignore the edit in undo history or not.
       
  2222  *
       
  2223  * @return {Object} Action object.
       
  2224  */
       
  2225 const editEntityRecord = (kind, name, recordId, edits, options = {}) => ({
       
  2226   select,
       
  2227   dispatch
       
  2228 }) => {
       
  2229   const entityConfig = select.getEntityConfig(kind, name);
       
  2230   if (!entityConfig) {
       
  2231     throw new Error(`The entity being edited (${kind}, ${name}) does not have a loaded config.`);
       
  2232   }
       
  2233   const {
       
  2234     mergedEdits = {}
       
  2235   } = entityConfig;
       
  2236   const record = select.getRawEntityRecord(kind, name, recordId);
       
  2237   const editedRecord = select.getEditedEntityRecord(kind, name, recordId);
       
  2238   const edit = {
       
  2239     kind,
       
  2240     name,
       
  2241     recordId,
       
  2242     // Clear edits when they are equal to their persisted counterparts
       
  2243     // so that the property is not considered dirty.
       
  2244     edits: Object.keys(edits).reduce((acc, key) => {
       
  2245       const recordValue = record[key];
       
  2246       const editedRecordValue = editedRecord[key];
       
  2247       const value = mergedEdits[key] ? {
       
  2248         ...editedRecordValue,
       
  2249         ...edits[key]
       
  2250       } : edits[key];
       
  2251       acc[key] = es6_default()(recordValue, value) ? undefined : value;
       
  2252       return acc;
       
  2253     }, {})
       
  2254   };
       
  2255   if (window.__experimentalEnableSync && entityConfig.syncConfig) {
       
  2256     if (false) {}
       
  2257   } else {
       
  2258     if (!options.undoIgnore) {
       
  2259       select.getUndoManager().addRecord([{
       
  2260         id: {
       
  2261           kind,
       
  2262           name,
       
  2263           recordId
       
  2264         },
       
  2265         changes: Object.keys(edits).reduce((acc, key) => {
       
  2266           acc[key] = {
       
  2267             from: editedRecord[key],
       
  2268             to: edits[key]
       
  2269           };
       
  2270           return acc;
       
  2271         }, {})
       
  2272       }], options.isCached);
       
  2273     }
       
  2274     dispatch({
       
  2275       type: 'EDIT_ENTITY_RECORD',
       
  2276       ...edit
       
  2277     });
       
  2278   }
       
  2279 };
       
  2280 
       
  2281 /**
       
  2282  * Action triggered to undo the last edit to
       
  2283  * an entity record, if any.
       
  2284  */
       
  2285 const undo = () => ({
       
  2286   select,
       
  2287   dispatch
       
  2288 }) => {
       
  2289   const undoRecord = select.getUndoManager().undo();
       
  2290   if (!undoRecord) {
       
  2291     return;
       
  2292   }
       
  2293   dispatch({
       
  2294     type: 'UNDO',
       
  2295     record: undoRecord
       
  2296   });
       
  2297 };
       
  2298 
       
  2299 /**
       
  2300  * Action triggered to redo the last undoed
       
  2301  * edit to an entity record, if any.
       
  2302  */
       
  2303 const redo = () => ({
       
  2304   select,
       
  2305   dispatch
       
  2306 }) => {
       
  2307   const redoRecord = select.getUndoManager().redo();
       
  2308   if (!redoRecord) {
       
  2309     return;
       
  2310   }
       
  2311   dispatch({
       
  2312     type: 'REDO',
       
  2313     record: redoRecord
       
  2314   });
       
  2315 };
       
  2316 
       
  2317 /**
       
  2318  * Forces the creation of a new undo level.
       
  2319  *
       
  2320  * @return {Object} Action object.
       
  2321  */
       
  2322 const __unstableCreateUndoLevel = () => ({
       
  2323   select
       
  2324 }) => {
       
  2325   select.getUndoManager().addRecord();
       
  2326 };
       
  2327 
       
  2328 /**
       
  2329  * Action triggered to save an entity record.
       
  2330  *
       
  2331  * @param {string}   kind                         Kind of the received entity.
       
  2332  * @param {string}   name                         Name of the received entity.
       
  2333  * @param {Object}   record                       Record to be saved.
       
  2334  * @param {Object}   options                      Saving options.
       
  2335  * @param {boolean}  [options.isAutosave=false]   Whether this is an autosave.
       
  2336  * @param {Function} [options.__unstableFetch]    Internal use only. Function to
       
  2337  *                                                call instead of `apiFetch()`.
       
  2338  *                                                Must return a promise.
       
  2339  * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all
       
  2340  *                                                the exceptions. Defaults to false.
       
  2341  */
       
  2342 const saveEntityRecord = (kind, name, record, {
       
  2343   isAutosave = false,
       
  2344   __unstableFetch = (external_wp_apiFetch_default()),
       
  2345   throwOnError = false
       
  2346 } = {}) => async ({
       
  2347   select,
       
  2348   resolveSelect,
       
  2349   dispatch
       
  2350 }) => {
       
  2351   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  2352   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  2353   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
       
  2354     return;
       
  2355   }
       
  2356   const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
       
  2357   const recordId = record[entityIdKey];
       
  2358   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId || esm_browser_v4()], {
       
  2359     exclusive: true
       
  2360   });
       
  2361   try {
       
  2362     // Evaluate optimized edits.
       
  2363     // (Function edits that should be evaluated on save to avoid expensive computations on every edit.)
       
  2364     for (const [key, value] of Object.entries(record)) {
       
  2365       if (typeof value === 'function') {
       
  2366         const evaluatedValue = value(select.getEditedEntityRecord(kind, name, recordId));
       
  2367         dispatch.editEntityRecord(kind, name, recordId, {
       
  2368           [key]: evaluatedValue
       
  2369         }, {
       
  2370           undoIgnore: true
       
  2371         });
       
  2372         record[key] = evaluatedValue;
       
  2373       }
       
  2374     }
       
  2375     dispatch({
       
  2376       type: 'SAVE_ENTITY_RECORD_START',
       
  2377       kind,
       
  2378       name,
       
  2379       recordId,
       
  2380       isAutosave
       
  2381     });
       
  2382     let updatedRecord;
       
  2383     let error;
       
  2384     let hasError = false;
       
  2385     try {
       
  2386       const path = `${entityConfig.baseURL}${recordId ? '/' + recordId : ''}`;
       
  2387       const persistedRecord = select.getRawEntityRecord(kind, name, recordId);
       
  2388       if (isAutosave) {
       
  2389         // Most of this autosave logic is very specific to posts.
       
  2390         // This is fine for now as it is the only supported autosave,
       
  2391         // but ideally this should all be handled in the back end,
       
  2392         // so the client just sends and receives objects.
       
  2393         const currentUser = select.getCurrentUser();
       
  2394         const currentUserId = currentUser ? currentUser.id : undefined;
       
  2395         const autosavePost = await resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId);
       
  2396         // Autosaves need all expected fields to be present.
       
  2397         // So we fallback to the previous autosave and then
       
  2398         // to the actual persisted entity if the edits don't
       
  2399         // have a value.
       
  2400         let data = {
       
  2401           ...persistedRecord,
       
  2402           ...autosavePost,
       
  2403           ...record
       
  2404         };
       
  2405         data = Object.keys(data).reduce((acc, key) => {
       
  2406           if (['title', 'excerpt', 'content', 'meta'].includes(key)) {
       
  2407             acc[key] = data[key];
       
  2408           }
       
  2409           return acc;
       
  2410         }, {
       
  2411           // Do not update the `status` if we have edited it when auto saving.
       
  2412           // It's very important to let the user explicitly save this change,
       
  2413           // because it can lead to unexpected results. An example would be to
       
  2414           // have a draft post and change the status to publish.
       
  2415           status: data.status === 'auto-draft' ? 'draft' : undefined
       
  2416         });
       
  2417         updatedRecord = await __unstableFetch({
       
  2418           path: `${path}/autosaves`,
       
  2419           method: 'POST',
       
  2420           data
       
  2421         });
       
  2422 
       
  2423         // An autosave may be processed by the server as a regular save
       
  2424         // when its update is requested by the author and the post had
       
  2425         // draft or auto-draft status.
       
  2426         if (persistedRecord.id === updatedRecord.id) {
       
  2427           let newRecord = {
       
  2428             ...persistedRecord,
       
  2429             ...data,
       
  2430             ...updatedRecord
       
  2431           };
       
  2432           newRecord = Object.keys(newRecord).reduce((acc, key) => {
       
  2433             // These properties are persisted in autosaves.
       
  2434             if (['title', 'excerpt', 'content'].includes(key)) {
       
  2435               acc[key] = newRecord[key];
       
  2436             } else if (key === 'status') {
       
  2437               // Status is only persisted in autosaves when going from
       
  2438               // "auto-draft" to "draft".
       
  2439               acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status;
       
  2440             } else {
       
  2441               // These properties are not persisted in autosaves.
       
  2442               acc[key] = persistedRecord[key];
       
  2443             }
       
  2444             return acc;
       
  2445           }, {});
       
  2446           dispatch.receiveEntityRecords(kind, name, newRecord, undefined, true);
       
  2447         } else {
       
  2448           dispatch.receiveAutosaves(persistedRecord.id, updatedRecord);
       
  2449         }
       
  2450       } else {
       
  2451         let edits = record;
       
  2452         if (entityConfig.__unstablePrePersist) {
       
  2453           edits = {
       
  2454             ...edits,
       
  2455             ...entityConfig.__unstablePrePersist(persistedRecord, edits)
       
  2456           };
       
  2457         }
       
  2458         updatedRecord = await __unstableFetch({
       
  2459           path,
       
  2460           method: recordId ? 'PUT' : 'POST',
       
  2461           data: edits
       
  2462         });
       
  2463         dispatch.receiveEntityRecords(kind, name, updatedRecord, undefined, true, edits);
       
  2464       }
       
  2465     } catch (_error) {
       
  2466       hasError = true;
       
  2467       error = _error;
       
  2468     }
       
  2469     dispatch({
       
  2470       type: 'SAVE_ENTITY_RECORD_FINISH',
       
  2471       kind,
       
  2472       name,
       
  2473       recordId,
       
  2474       error,
       
  2475       isAutosave
       
  2476     });
       
  2477     if (hasError && throwOnError) {
       
  2478       throw error;
       
  2479     }
       
  2480     return updatedRecord;
       
  2481   } finally {
       
  2482     dispatch.__unstableReleaseStoreLock(lock);
       
  2483   }
       
  2484 };
       
  2485 
       
  2486 /**
       
  2487  * Runs multiple core-data actions at the same time using one API request.
       
  2488  *
       
  2489  * Example:
       
  2490  *
       
  2491  * ```
       
  2492  * const [ savedRecord, updatedRecord, deletedRecord ] =
       
  2493  *   await dispatch( 'core' ).__experimentalBatch( [
       
  2494  *     ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ),
       
  2495  *     ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ),
       
  2496  *     ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ),
       
  2497  *   ] );
       
  2498  * ```
       
  2499  *
       
  2500  * @param {Array} requests Array of functions which are invoked simultaneously.
       
  2501  *                         Each function is passed an object containing
       
  2502  *                         `saveEntityRecord`, `saveEditedEntityRecord`, and
       
  2503  *                         `deleteEntityRecord`.
       
  2504  *
       
  2505  * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return
       
  2506  *                                          values of each function given in `requests`.
       
  2507  */
       
  2508 const __experimentalBatch = requests => async ({
       
  2509   dispatch
       
  2510 }) => {
       
  2511   const batch = createBatch();
       
  2512   const api = {
       
  2513     saveEntityRecord(kind, name, record, options) {
       
  2514       return batch.add(add => dispatch.saveEntityRecord(kind, name, record, {
       
  2515         ...options,
       
  2516         __unstableFetch: add
       
  2517       }));
       
  2518     },
       
  2519     saveEditedEntityRecord(kind, name, recordId, options) {
       
  2520       return batch.add(add => dispatch.saveEditedEntityRecord(kind, name, recordId, {
       
  2521         ...options,
       
  2522         __unstableFetch: add
       
  2523       }));
       
  2524     },
       
  2525     deleteEntityRecord(kind, name, recordId, query, options) {
       
  2526       return batch.add(add => dispatch.deleteEntityRecord(kind, name, recordId, query, {
       
  2527         ...options,
       
  2528         __unstableFetch: add
       
  2529       }));
       
  2530     }
       
  2531   };
       
  2532   const resultPromises = requests.map(request => request(api));
       
  2533   const [, ...results] = await Promise.all([batch.run(), ...resultPromises]);
       
  2534   return results;
       
  2535 };
       
  2536 
       
  2537 /**
       
  2538  * Action triggered to save an entity record's edits.
       
  2539  *
       
  2540  * @param {string} kind     Kind of the entity.
       
  2541  * @param {string} name     Name of the entity.
       
  2542  * @param {Object} recordId ID of the record.
       
  2543  * @param {Object} options  Saving options.
       
  2544  */
       
  2545 const saveEditedEntityRecord = (kind, name, recordId, options) => async ({
       
  2546   select,
       
  2547   dispatch
       
  2548 }) => {
       
  2549   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
       
  2550     return;
       
  2551   }
       
  2552   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  2553   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  2554   if (!entityConfig) {
       
  2555     return;
       
  2556   }
       
  2557   const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
       
  2558   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
       
  2559   const record = {
       
  2560     [entityIdKey]: recordId,
       
  2561     ...edits
       
  2562   };
       
  2563   return await dispatch.saveEntityRecord(kind, name, record, options);
       
  2564 };
       
  2565 
       
  2566 /**
       
  2567  * Action triggered to save only specified properties for the entity.
       
  2568  *
       
  2569  * @param {string} kind        Kind of the entity.
       
  2570  * @param {string} name        Name of the entity.
       
  2571  * @param {Object} recordId    ID of the record.
       
  2572  * @param {Array}  itemsToSave List of entity properties or property paths to save.
       
  2573  * @param {Object} options     Saving options.
       
  2574  */
       
  2575 const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({
       
  2576   select,
       
  2577   dispatch
       
  2578 }) => {
       
  2579   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
       
  2580     return;
       
  2581   }
       
  2582   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
       
  2583   const editsToSave = {};
       
  2584   for (const item of itemsToSave) {
       
  2585     setNestedValue(editsToSave, item, getNestedValue(edits, item));
       
  2586   }
       
  2587   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  2588   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  2589   const entityIdKey = entityConfig?.key || DEFAULT_ENTITY_KEY;
       
  2590 
       
  2591   // If a record key is provided then update the existing record.
       
  2592   // This necessitates providing `recordKey` to saveEntityRecord as part of the
       
  2593   // `record` argument (here called `editsToSave`) to stop that action creating
       
  2594   // a new record and instead cause it to update the existing record.
       
  2595   if (recordId) {
       
  2596     editsToSave[entityIdKey] = recordId;
       
  2597   }
       
  2598   return await dispatch.saveEntityRecord(kind, name, editsToSave, options);
       
  2599 };
       
  2600 
       
  2601 /**
       
  2602  * Returns an action object used in signalling that Upload permissions have been received.
       
  2603  *
       
  2604  * @deprecated since WP 5.9, use receiveUserPermission instead.
       
  2605  *
       
  2606  * @param {boolean} hasUploadPermissions Does the user have permission to upload files?
       
  2607  *
       
  2608  * @return {Object} Action object.
       
  2609  */
       
  2610 function receiveUploadPermissions(hasUploadPermissions) {
       
  2611   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveUploadPermissions", {
       
  2612     since: '5.9',
       
  2613     alternative: 'receiveUserPermission'
       
  2614   });
       
  2615   return receiveUserPermission('create/media', hasUploadPermissions);
       
  2616 }
       
  2617 
       
  2618 /**
       
  2619  * Returns an action object used in signalling that the current user has
       
  2620  * permission to perform an action on a REST resource.
       
  2621  * Ignored from documentation as it's internal to the data store.
       
  2622  *
       
  2623  * @ignore
       
  2624  *
       
  2625  * @param {string}  key       A key that represents the action and REST resource.
       
  2626  * @param {boolean} isAllowed Whether or not the user can perform the action.
       
  2627  *
       
  2628  * @return {Object} Action object.
       
  2629  */
       
  2630 function receiveUserPermission(key, isAllowed) {
       
  2631   return {
       
  2632     type: 'RECEIVE_USER_PERMISSION',
       
  2633     key,
       
  2634     isAllowed
       
  2635   };
       
  2636 }
       
  2637 
       
  2638 /**
       
  2639  * Returns an action object used in signalling that the autosaves for a
       
  2640  * post have been received.
       
  2641  * Ignored from documentation as it's internal to the data store.
       
  2642  *
       
  2643  * @ignore
       
  2644  *
       
  2645  * @param {number}       postId    The id of the post that is parent to the autosave.
       
  2646  * @param {Array|Object} autosaves An array of autosaves or singular autosave object.
       
  2647  *
       
  2648  * @return {Object} Action object.
       
  2649  */
       
  2650 function receiveAutosaves(postId, autosaves) {
       
  2651   return {
       
  2652     type: 'RECEIVE_AUTOSAVES',
       
  2653     postId,
       
  2654     autosaves: Array.isArray(autosaves) ? autosaves : [autosaves]
       
  2655   };
       
  2656 }
       
  2657 
       
  2658 /**
       
  2659  * Returns an action object signalling that the fallback Navigation
       
  2660  * Menu id has been received.
       
  2661  *
       
  2662  * @param {integer} fallbackId the id of the fallback Navigation Menu
       
  2663  * @return {Object} Action object.
       
  2664  */
       
  2665 function receiveNavigationFallbackId(fallbackId) {
       
  2666   return {
       
  2667     type: 'RECEIVE_NAVIGATION_FALLBACK_ID',
       
  2668     fallbackId
       
  2669   };
       
  2670 }
       
  2671 
       
  2672 /**
       
  2673  * Returns an action object used to set the template for a given query.
       
  2674  *
       
  2675  * @param {Object} query      The lookup query.
       
  2676  * @param {string} templateId The resolved template id.
       
  2677  *
       
  2678  * @return {Object} Action object.
       
  2679  */
       
  2680 function receiveDefaultTemplateId(query, templateId) {
       
  2681   return {
       
  2682     type: 'RECEIVE_DEFAULT_TEMPLATE',
       
  2683     query,
       
  2684     templateId
       
  2685   };
       
  2686 }
       
  2687 
       
  2688 /**
       
  2689  * Action triggered to receive revision items.
       
  2690  *
       
  2691  * @param {string}        kind            Kind of the received entity record revisions.
       
  2692  * @param {string}        name            Name of the received entity record revisions.
       
  2693  * @param {number|string} recordKey       The key of the entity record whose revisions you want to fetch.
       
  2694  * @param {Array|Object}  records         Revisions received.
       
  2695  * @param {?Object}       query           Query Object.
       
  2696  * @param {?boolean}      invalidateCache Should invalidate query caches.
       
  2697  * @param {?Object}       meta            Meta information about pagination.
       
  2698  */
       
  2699 const receiveRevisions = (kind, name, recordKey, records, query, invalidateCache = false, meta) => async ({
       
  2700   dispatch
       
  2701 }) => {
       
  2702   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
       
  2703   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  2704   const key = entityConfig && entityConfig?.revisionKey ? entityConfig.revisionKey : DEFAULT_ENTITY_KEY;
       
  2705   dispatch({
       
  2706     type: 'RECEIVE_ITEM_REVISIONS',
       
  2707     key,
       
  2708     items: Array.isArray(records) ? records : [records],
       
  2709     recordKey,
       
  2710     meta,
       
  2711     query,
       
  2712     kind,
       
  2713     name,
       
  2714     invalidateCache
       
  2715   });
       
  2716 };
       
  2717 
       
  2718 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entities.js
       
  2719 /**
       
  2720  * External dependencies
       
  2721  */
       
  2722 
       
  2723 
       
  2724 /**
       
  2725  * WordPress dependencies
       
  2726  */
       
  2727 
       
  2728 
       
  2729 
       
  2730 
       
  2731 /**
       
  2732  * Internal dependencies
       
  2733  */
       
  2734 
  1468 
  2735 
  1469 
  2736 const DEFAULT_ENTITY_KEY = 'id';
  1470 const DEFAULT_ENTITY_KEY = 'id';
  2737 const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
  1471 const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
  2738 const rootEntitiesConfig = [{
  1472 const rootEntitiesConfig = [{
  2739   label: (0,external_wp_i18n_namespaceObject.__)('Base'),
  1473   label: (0,external_wp_i18n_namespaceObject.__)('Base'),
  2740   kind: 'root',
  1474   kind: 'root',
  2741   name: '__unstableBase',
  1475   name: '__unstableBase',
  2742   baseURL: '/',
  1476   baseURL: '/',
  2743   baseURLParams: {
  1477   baseURLParams: {
  2744     _fields: ['description', 'gmt_offset', 'home', 'name', 'site_icon', 'site_icon_url', 'site_logo', 'timezone_string', 'url'].join(',')
  1478     // Please also change the preload path when changing this.
       
  1479     // @see lib/compat/wordpress-6.8/preload.php
       
  1480     _fields: ['description', 'gmt_offset', 'home', 'name', 'site_icon', 'site_icon_url', 'site_logo', 'timezone_string', 'url', 'page_for_posts', 'page_on_front', 'show_on_front'].join(',')
  2745   },
  1481   },
  2746   // The entity doesn't support selecting multiple records.
  1482   // The entity doesn't support selecting multiple records.
  2747   // The property is maintained for backward compatibility.
  1483   // The property is maintained for backward compatibility.
  2748   plural: '__unstableBases',
  1484   plural: '__unstableBases',
  2749   syncConfig: {
  1485   syncConfig: {
  3171 const getMethodName = (kind, name, prefix = 'get') => {
  1907 const getMethodName = (kind, name, prefix = 'get') => {
  3172   const kindPrefix = kind === 'root' ? '' : pascalCase(kind);
  1908   const kindPrefix = kind === 'root' ? '' : pascalCase(kind);
  3173   const suffix = pascalCase(name);
  1909   const suffix = pascalCase(name);
  3174   return `${prefix}${kindPrefix}${suffix}`;
  1910   return `${prefix}${kindPrefix}${suffix}`;
  3175 };
  1911 };
  3176 function registerSyncConfigs(configs) {
  1912 
  3177   configs.forEach(({
  1913 ;// external ["wp","url"]
  3178     syncObjectType,
  1914 const external_wp_url_namespaceObject = window["wp"]["url"];
  3179     syncConfig
  1915 ;// ./node_modules/@wordpress/core-data/build-module/utils/get-normalized-comma-separable.js
  3180   }) => {
       
  3181     getSyncProvider().register(syncObjectType, syncConfig);
       
  3182     const editSyncConfig = {
       
  3183       ...syncConfig
       
  3184     };
       
  3185     delete editSyncConfig.fetch;
       
  3186     getSyncProvider().register(syncObjectType + '--edit', editSyncConfig);
       
  3187   });
       
  3188 }
       
  3189 
       
  3190 /**
       
  3191  * Loads the entities into the store.
       
  3192  *
       
  3193  * Note: The `name` argument is used for `root` entities requiring additional server data.
       
  3194  *
       
  3195  * @param {string} kind Kind
       
  3196  * @param {string} name Name
       
  3197  * @return {(thunkArgs: object) => Promise<Array>} Entities
       
  3198  */
       
  3199 const getOrLoadEntitiesConfig = (kind, name) => async ({
       
  3200   select,
       
  3201   dispatch
       
  3202 }) => {
       
  3203   let configs = select.getEntitiesConfig(kind);
       
  3204   const hasConfig = !!select.getEntityConfig(kind, name);
       
  3205   if (configs?.length > 0 && hasConfig) {
       
  3206     if (window.__experimentalEnableSync) {
       
  3207       if (false) {}
       
  3208     }
       
  3209     return configs;
       
  3210   }
       
  3211   const loader = additionalEntityConfigLoaders.find(l => {
       
  3212     if (!name || !l.name) {
       
  3213       return l.kind === kind;
       
  3214     }
       
  3215     return l.kind === kind && l.name === name;
       
  3216   });
       
  3217   if (!loader) {
       
  3218     return [];
       
  3219   }
       
  3220   configs = await loader.loadEntities();
       
  3221   if (window.__experimentalEnableSync) {
       
  3222     if (false) {}
       
  3223   }
       
  3224   dispatch(addEntities(configs));
       
  3225   return configs;
       
  3226 };
       
  3227 
       
  3228 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/get-normalized-comma-separable.js
       
  3229 /**
  1916 /**
  3230  * Given a value which can be specified as one or the other of a comma-separated
  1917  * Given a value which can be specified as one or the other of a comma-separated
  3231  * string or an array, returns a value normalized to an array of strings, or
  1918  * string or an array, returns a value normalized to an array of strings, or
  3232  * null if the value cannot be interpreted as either.
  1919  * null if the value cannot be interpreted as either.
  3233  *
  1920  *
  3243   }
  1930   }
  3244   return null;
  1931   return null;
  3245 }
  1932 }
  3246 /* harmony default export */ const get_normalized_comma_separable = (getNormalizedCommaSeparable);
  1933 /* harmony default export */ const get_normalized_comma_separable = (getNormalizedCommaSeparable);
  3247 
  1934 
  3248 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js
  1935 ;// ./node_modules/@wordpress/core-data/build-module/utils/with-weak-map-cache.js
  3249 /**
  1936 /**
  3250  * Given a function, returns an enhanced function which caches the result and
  1937  * Given a function, returns an enhanced function which caches the result and
  3251  * tracks in WeakMap. The result is only cached if the original function is
  1938  * tracks in WeakMap. The result is only cached if the original function is
  3252  * passed a valid object-like argument (requirement for WeakMap key).
  1939  * passed a valid object-like argument (requirement for WeakMap key).
  3253  *
  1940  *
  3274     return value;
  1961     return value;
  3275   };
  1962   };
  3276 }
  1963 }
  3277 /* harmony default export */ const with_weak_map_cache = (withWeakMapCache);
  1964 /* harmony default export */ const with_weak_map_cache = (withWeakMapCache);
  3278 
  1965 
  3279 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js
  1966 ;// ./node_modules/@wordpress/core-data/build-module/queried-data/get-query-parts.js
  3280 /**
  1967 /**
  3281  * WordPress dependencies
  1968  * WordPress dependencies
  3282  */
  1969  */
  3283 
  1970 
  3284 
  1971 
  3378   }
  2065   }
  3379   return parts;
  2066   return parts;
  3380 }
  2067 }
  3381 /* harmony default export */ const get_query_parts = (with_weak_map_cache(getQueryParts));
  2068 /* harmony default export */ const get_query_parts = (with_weak_map_cache(getQueryParts));
  3382 
  2069 
  3383 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js
  2070 ;// ./node_modules/@wordpress/core-data/build-module/queried-data/reducer.js
  3384 /**
  2071 /**
  3385  * WordPress dependencies
  2072  * WordPress dependencies
  3386  */
  2073  */
  3387 
  2074 
  3388 
  2075 
  3614   items,
  2301   items,
  3615   itemIsComplete,
  2302   itemIsComplete,
  3616   queries
  2303   queries
  3617 }));
  2304 }));
  3618 
  2305 
  3619 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/reducer.js
  2306 ;// ./node_modules/@wordpress/core-data/build-module/reducer.js
  3620 /**
  2307 /**
  3621  * External dependencies
  2308  * External dependencies
  3622  */
  2309  */
  3623 
  2310 
  3624 
  2311 
  4023 };
  2710 };
  4024 
  2711 
  4025 /**
  2712 /**
  4026  * @type {UndoManager}
  2713  * @type {UndoManager}
  4027  */
  2714  */
  4028 function undoManager(state = (0,build_module.createUndoManager)()) {
  2715 function undoManager(state = createUndoManager()) {
  4029   return state;
  2716   return state;
  4030 }
  2717 }
  4031 function editsReference(state = {}, action) {
  2718 function editsReference(state = {}, action) {
  4032   switch (action.type) {
  2719   switch (action.type) {
  4033     case 'EDIT_ENTITY_RECORD':
  2720     case 'EDIT_ENTITY_RECORD':
  4075     case 'RECEIVE_USER_PERMISSION':
  2762     case 'RECEIVE_USER_PERMISSION':
  4076       return {
  2763       return {
  4077         ...state,
  2764         ...state,
  4078         [action.key]: action.isAllowed
  2765         [action.key]: action.isAllowed
  4079       };
  2766       };
       
  2767     case 'RECEIVE_USER_PERMISSIONS':
       
  2768       return {
       
  2769         ...state,
       
  2770         ...action.permissions
       
  2771       };
  4080   }
  2772   }
  4081   return state;
  2773   return state;
  4082 }
  2774 }
  4083 
  2775 
  4084 /**
  2776 /**
  4163   switch (action.type) {
  2855   switch (action.type) {
  4164     case 'RECEIVE_DEFAULT_TEMPLATE':
  2856     case 'RECEIVE_DEFAULT_TEMPLATE':
  4165       return {
  2857       return {
  4166         ...state,
  2858         ...state,
  4167         [JSON.stringify(action.query)]: action.templateId
  2859         [JSON.stringify(action.query)]: action.templateId
       
  2860       };
       
  2861   }
       
  2862   return state;
       
  2863 }
       
  2864 
       
  2865 /**
       
  2866  * Reducer returning an object of registered post meta.
       
  2867  *
       
  2868  * @param {Object} state  Current state.
       
  2869  * @param {Object} action Dispatched action.
       
  2870  *
       
  2871  * @return {Object} Updated state.
       
  2872  */
       
  2873 function registeredPostMeta(state = {}, action) {
       
  2874   switch (action.type) {
       
  2875     case 'RECEIVE_REGISTERED_POST_META':
       
  2876       return {
       
  2877         ...state,
       
  2878         [action.postType]: action.registeredPostMeta
  4168       };
  2879       };
  4169   }
  2880   }
  4170   return state;
  2881   return state;
  4171 }
  2882 }
  4172 /* harmony default export */ const build_module_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  2883 /* harmony default export */ const build_module_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
  4187   autosaves,
  2898   autosaves,
  4188   blockPatterns,
  2899   blockPatterns,
  4189   blockPatternCategories,
  2900   blockPatternCategories,
  4190   userPatternCategories,
  2901   userPatternCategories,
  4191   navigationFallbackId,
  2902   navigationFallbackId,
  4192   defaultTemplates
  2903   defaultTemplates,
       
  2904   registeredPostMeta
  4193 }));
  2905 }));
       
  2906 
       
  2907 ;// external ["wp","deprecated"]
       
  2908 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
       
  2909 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
       
  2910 ;// ./node_modules/@wordpress/core-data/build-module/name.js
       
  2911 /**
       
  2912  * The reducer key used by core data in store registration.
       
  2913  * This is defined in a separate file to avoid cycle-dependency
       
  2914  *
       
  2915  * @type {string}
       
  2916  */
       
  2917 const STORE_NAME = 'core';
  4194 
  2918 
  4195 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  2919 // EXTERNAL MODULE: ./node_modules/equivalent-key-map/equivalent-key-map.js
  4196 var equivalent_key_map = __webpack_require__(3249);
  2920 var equivalent_key_map = __webpack_require__(3249);
  4197 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  2921 var equivalent_key_map_default = /*#__PURE__*/__webpack_require__.n(equivalent_key_map);
  4198 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js
  2922 ;// ./node_modules/@wordpress/core-data/build-module/utils/set-nested-value.js
       
  2923 /**
       
  2924  * Sets the value at path of object.
       
  2925  * If a portion of path doesn’t exist, it’s created.
       
  2926  * Arrays are created for missing index properties while objects are created
       
  2927  * for all other missing properties.
       
  2928  *
       
  2929  * Path is specified as either:
       
  2930  * - a string of properties, separated by dots, for example: "x.y".
       
  2931  * - an array of properties, for example `[ 'x', 'y' ]`.
       
  2932  *
       
  2933  * This function intentionally mutates the input object.
       
  2934  *
       
  2935  * Inspired by _.set().
       
  2936  *
       
  2937  * @see https://lodash.com/docs/4.17.15#set
       
  2938  *
       
  2939  * @todo Needs to be deduplicated with its copy in `@wordpress/edit-site`.
       
  2940  *
       
  2941  * @param {Object}       object Object to modify
       
  2942  * @param {Array|string} path   Path of the property to set.
       
  2943  * @param {*}            value  Value to set.
       
  2944  */
       
  2945 function setNestedValue(object, path, value) {
       
  2946   if (!object || typeof object !== 'object') {
       
  2947     return object;
       
  2948   }
       
  2949   const normalizedPath = Array.isArray(path) ? path : path.split('.');
       
  2950   normalizedPath.reduce((acc, key, idx) => {
       
  2951     if (acc[key] === undefined) {
       
  2952       if (Number.isInteger(normalizedPath[idx + 1])) {
       
  2953         acc[key] = [];
       
  2954       } else {
       
  2955         acc[key] = {};
       
  2956       }
       
  2957     }
       
  2958     if (idx === normalizedPath.length - 1) {
       
  2959       acc[key] = value;
       
  2960     }
       
  2961     return acc[key];
       
  2962   }, object);
       
  2963   return object;
       
  2964 }
       
  2965 
       
  2966 ;// ./node_modules/@wordpress/core-data/build-module/queried-data/selectors.js
  4199 /**
  2967 /**
  4200  * External dependencies
  2968  * External dependencies
  4201  */
  2969  */
  4202 
  2970 
  4203 
  2971 
  4328     context
  3096     context
  4329   } = get_query_parts(query);
  3097   } = get_query_parts(query);
  4330   return (_state$queries$contex2 = state.queries?.[context]?.[stableKey]?.meta?.totalPages) !== null && _state$queries$contex2 !== void 0 ? _state$queries$contex2 : null;
  3098   return (_state$queries$contex2 = state.queries?.[context]?.[stableKey]?.meta?.totalPages) !== null && _state$queries$contex2 !== void 0 ? _state$queries$contex2 : null;
  4331 }
  3099 }
  4332 
  3100 
  4333 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/is-numeric-id.js
  3101 ;// ./node_modules/@wordpress/core-data/build-module/utils/is-numeric-id.js
  4334 /**
  3102 /**
  4335  * Checks argument to determine if it's a numeric ID.
  3103  * Checks argument to determine if it's a numeric ID.
  4336  * For example, '123' is a numeric ID, but '123abc' is not.
  3104  * For example, '123' is a numeric ID, but '123abc' is not.
  4337  *
  3105  *
  4338  * @param {any} id the argument to determine if it's a numeric ID.
  3106  * @param {any} id the argument to determine if it's a numeric ID.
  4340  */
  3108  */
  4341 function isNumericID(id) {
  3109 function isNumericID(id) {
  4342   return /^\s*\d+\s*$/.test(id);
  3110   return /^\s*\d+\s*$/.test(id);
  4343 }
  3111 }
  4344 
  3112 
  4345 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/is-raw-attribute.js
  3113 ;// ./node_modules/@wordpress/core-data/build-module/utils/is-raw-attribute.js
  4346 /**
  3114 /**
  4347  * Checks whether the attribute is a "raw" attribute or not.
  3115  * Checks whether the attribute is a "raw" attribute or not.
  4348  *
  3116  *
  4349  * @param {Object} entity    Entity record.
  3117  * @param {Object} entity    Entity record.
  4350  * @param {string} attribute Attribute name.
  3118  * @param {string} attribute Attribute name.
  4353  */
  3121  */
  4354 function isRawAttribute(entity, attribute) {
  3122 function isRawAttribute(entity, attribute) {
  4355   return (entity.rawAttributes || []).includes(attribute);
  3123   return (entity.rawAttributes || []).includes(attribute);
  4356 }
  3124 }
  4357 
  3125 
  4358 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/selectors.js
  3126 ;// ./node_modules/@wordpress/core-data/build-module/utils/user-permissions.js
       
  3127 const ALLOWED_RESOURCE_ACTIONS = ['create', 'read', 'update', 'delete'];
       
  3128 function getUserPermissionsFromAllowHeader(allowedMethods) {
       
  3129   const permissions = {};
       
  3130   if (!allowedMethods) {
       
  3131     return permissions;
       
  3132   }
       
  3133   const methods = {
       
  3134     create: 'POST',
       
  3135     read: 'GET',
       
  3136     update: 'PUT',
       
  3137     delete: 'DELETE'
       
  3138   };
       
  3139   for (const [actionName, methodName] of Object.entries(methods)) {
       
  3140     permissions[actionName] = allowedMethods.includes(methodName);
       
  3141   }
       
  3142   return permissions;
       
  3143 }
       
  3144 function getUserPermissionCacheKey(action, resource, id) {
       
  3145   const key = (typeof resource === 'object' ? [action, resource.kind, resource.name, resource.id] : [action, resource, id]).filter(Boolean).join('/');
       
  3146   return key;
       
  3147 }
       
  3148 
       
  3149 ;// ./node_modules/@wordpress/core-data/build-module/selectors.js
  4359 /**
  3150 /**
  4360  * WordPress dependencies
  3151  * WordPress dependencies
  4361  */
  3152  */
  4362 
  3153 
  4363 
  3154 
  4473  * @param state Data state.
  3264  * @param state Data state.
  4474  * @param kind  Entity kind.
  3265  * @param kind  Entity kind.
  4475  *
  3266  *
  4476  * @return Array of entities with config matching kind.
  3267  * @return Array of entities with config matching kind.
  4477  */
  3268  */
  4478 const getEntitiesConfig = (0,external_wp_data_namespaceObject.createSelector)((state, kind) => state.entities.config.filter(entity => entity.kind === kind), (state, kind) => state.entities.config);
  3269 const getEntitiesConfig = (0,external_wp_data_namespaceObject.createSelector)((state, kind) => state.entities.config.filter(entity => entity.kind === kind), /* eslint-disable @typescript-eslint/no-unused-vars */
       
  3270 (state, kind) => state.entities.config
       
  3271 /* eslint-enable @typescript-eslint/no-unused-vars */);
  4479 /**
  3272 /**
  4480  * Returns the entity config given its kind and name.
  3273  * Returns the entity config given its kind and name.
  4481  *
  3274  *
  4482  * @deprecated since WordPress 6.0. Use getEntityConfig instead
  3275  * @deprecated since WordPress 6.0. Use getEntityConfig instead
  4483  * @param      state Data state.
  3276  * @param      state Data state.
  4538  * entity object if it exists and is received.
  3331  * entity object if it exists and is received.
  4539  *
  3332  *
  4540  * @param state State tree
  3333  * @param state State tree
  4541  * @param kind  Entity kind.
  3334  * @param kind  Entity kind.
  4542  * @param name  Entity name.
  3335  * @param name  Entity name.
  4543  * @param key   Record's key
  3336  * @param key   Optional record's key. If requesting a global record (e.g. site settings), the key can be omitted. If requesting a specific item, the key must always be included.
  4544  * @param query Optional query. If requesting specific
  3337  * @param query Optional query. If requesting specific
  4545  *              fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".
  3338  *              fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available "Retrieve a [Entity kind]".
  4546  *
  3339  *
  4547  * @return Record.
  3340  * @return Record.
  4548  */
  3341  */
  4624  */
  3417  */
  4625 const getRawEntityRecord = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, key) => {
  3418 const getRawEntityRecord = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, key) => {
  4626   const record = getEntityRecord(state, kind, name, key);
  3419   const record = getEntityRecord(state, kind, name, key);
  4627   return record && Object.keys(record).reduce((accumulator, _key) => {
  3420   return record && Object.keys(record).reduce((accumulator, _key) => {
  4628     if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
  3421     if (isRawAttribute(getEntityConfig(state, kind, name), _key)) {
  4629       var _record$_key$raw;
       
  4630       // Because edits are the "raw" attribute values,
  3422       // Because edits are the "raw" attribute values,
  4631       // we return those from record selectors to make rendering,
  3423       // we return those from record selectors to make rendering,
  4632       // comparisons, and joins with edits easier.
  3424       // comparisons, and joins with edits easier.
  4633       accumulator[_key] = (_record$_key$raw = record[_key]?.raw) !== null && _record$_key$raw !== void 0 ? _record$_key$raw : record[_key];
  3425       accumulator[_key] = record[_key]?.raw !== undefined ? record[_key]?.raw : record[_key];
  4634     } else {
  3426     } else {
  4635       accumulator[_key] = record[_key];
  3427       accumulator[_key] = record[_key];
  4636     }
  3428     }
  4637     return accumulator;
  3429     return accumulator;
  4638   }, {});
  3430   }, {});
  4979  */
  3771  */
  4980 function getLastEntityDeleteError(state, kind, name, recordId) {
  3772 function getLastEntityDeleteError(state, kind, name, recordId) {
  4981   return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
  3773   return state.entities.records?.[kind]?.[name]?.deleting?.[recordId]?.error;
  4982 }
  3774 }
  4983 
  3775 
       
  3776 /* eslint-disable @typescript-eslint/no-unused-vars */
  4984 /**
  3777 /**
  4985  * Returns the previous edit from the current undo offset
  3778  * Returns the previous edit from the current undo offset
  4986  * for the entity records edits history, if any.
  3779  * for the entity records edits history, if any.
  4987  *
  3780  *
  4988  * @deprecated since 6.3
  3781  * @deprecated since 6.3
  4995   external_wp_deprecated_default()("select( 'core' ).getUndoEdit()", {
  3788   external_wp_deprecated_default()("select( 'core' ).getUndoEdit()", {
  4996     since: '6.3'
  3789     since: '6.3'
  4997   });
  3790   });
  4998   return undefined;
  3791   return undefined;
  4999 }
  3792 }
  5000 
  3793 /* eslint-enable @typescript-eslint/no-unused-vars */
       
  3794 
       
  3795 /* eslint-disable @typescript-eslint/no-unused-vars */
  5001 /**
  3796 /**
  5002  * Returns the next edit from the current undo offset
  3797  * Returns the next edit from the current undo offset
  5003  * for the entity records edits history, if any.
  3798  * for the entity records edits history, if any.
  5004  *
  3799  *
  5005  * @deprecated since 6.3
  3800  * @deprecated since 6.3
  5012   external_wp_deprecated_default()("select( 'core' ).getRedoEdit()", {
  3807   external_wp_deprecated_default()("select( 'core' ).getRedoEdit()", {
  5013     since: '6.3'
  3808     since: '6.3'
  5014   });
  3809   });
  5015   return undefined;
  3810   return undefined;
  5016 }
  3811 }
       
  3812 /* eslint-enable @typescript-eslint/no-unused-vars */
  5017 
  3813 
  5018 /**
  3814 /**
  5019  * Returns true if there is a previous edit from the current undo offset
  3815  * Returns true if there is a previous edit from the current undo offset
  5020  * for the entity records edits history, and false otherwise.
  3816  * for the entity records edits history, and false otherwise.
  5021  *
  3817  *
  5118  *
  3914  *
  5119  * https://developer.wordpress.org/rest-api/reference/
  3915  * https://developer.wordpress.org/rest-api/reference/
  5120  *
  3916  *
  5121  * @param state    Data state.
  3917  * @param state    Data state.
  5122  * @param action   Action to check. One of: 'create', 'read', 'update', 'delete'.
  3918  * @param action   Action to check. One of: 'create', 'read', 'update', 'delete'.
  5123  * @param resource REST resource to check, e.g. 'media' or 'posts'.
  3919  * @param resource Entity resource to check. Accepts entity object `{ kind: 'root', name: 'media', id: 1 }`
       
  3920  *                 or REST base as a string - `media`.
  5124  * @param id       Optional ID of the rest resource to check.
  3921  * @param id       Optional ID of the rest resource to check.
  5125  *
  3922  *
  5126  * @return Whether or not the user can perform the action,
  3923  * @return Whether or not the user can perform the action,
  5127  *                             or `undefined` if the OPTIONS request is still being made.
  3924  *                             or `undefined` if the OPTIONS request is still being made.
  5128  */
  3925  */
  5129 function canUser(state, action, resource, id) {
  3926 function canUser(state, action, resource, id) {
  5130   const key = [action, resource, id].filter(Boolean).join('/');
  3927   const isEntity = typeof resource === 'object';
       
  3928   if (isEntity && (!resource.kind || !resource.name)) {
       
  3929     return false;
       
  3930   }
       
  3931   const key = getUserPermissionCacheKey(action, resource, id);
  5131   return state.userPermissions[key];
  3932   return state.userPermissions[key];
  5132 }
  3933 }
  5133 
  3934 
  5134 /**
  3935 /**
  5135  * Returns whether the current user can edit the given entity.
  3936  * Returns whether the current user can edit the given entity.
  5145  * @param recordId Record's id.
  3946  * @param recordId Record's id.
  5146  * @return Whether or not the user can edit,
  3947  * @return Whether or not the user can edit,
  5147  * or `undefined` if the OPTIONS request is still being made.
  3948  * or `undefined` if the OPTIONS request is still being made.
  5148  */
  3949  */
  5149 function canUserEditEntityRecord(state, kind, name, recordId) {
  3950 function canUserEditEntityRecord(state, kind, name, recordId) {
  5150   const entityConfig = getEntityConfig(state, kind, name);
  3951   external_wp_deprecated_default()(`wp.data.select( 'core' ).canUserEditEntityRecord()`, {
  5151   if (!entityConfig) {
  3952     since: '6.7',
  5152     return false;
  3953     alternative: `wp.data.select( 'core' ).canUser( 'update', { kind, name, id } )`
  5153   }
  3954   });
  5154   const resource = entityConfig.__unstable_rest_base;
  3955   return canUser(state, 'update', {
  5155   return canUser(state, 'update', resource, recordId);
  3956     kind,
       
  3957     name,
       
  3958     id: recordId
       
  3959   });
  5156 }
  3960 }
  5157 
  3961 
  5158 /**
  3962 /**
  5159  * Returns the latest autosaves for the post.
  3963  * Returns the latest autosaves for the post.
  5160  *
  3964  *
  5220  *
  4024  *
  5221  * @return A value whose reference will change only when an edit occurs.
  4025  * @return A value whose reference will change only when an edit occurs.
  5222  */
  4026  */
  5223 function getReferenceByDistinctEdits(state) {
  4027 function getReferenceByDistinctEdits(state) {
  5224   return state.editsReference;
  4028   return state.editsReference;
  5225 }
       
  5226 
       
  5227 /**
       
  5228  * Retrieve the frontend template used for a given link.
       
  5229  *
       
  5230  * @param state Editor state.
       
  5231  * @param link  Link.
       
  5232  *
       
  5233  * @return The template record.
       
  5234  */
       
  5235 function __experimentalGetTemplateForLink(state, link) {
       
  5236   const records = getEntityRecords(state, 'postType', 'wp_template', {
       
  5237     'find-template': link
       
  5238   });
       
  5239   if (records?.length) {
       
  5240     return getEditedEntityRecord(state, 'postType', 'wp_template', records[0].id);
       
  5241   }
       
  5242   return null;
       
  5243 }
  4029 }
  5244 
  4030 
  5245 /**
  4031 /**
  5246  * Retrieve the current theme's base global styles
  4032  * Retrieve the current theme's base global styles
  5247  *
  4033  *
  5406   var _query$context6;
  4192   var _query$context6;
  5407   const context = (_query$context6 = query?.context) !== null && _query$context6 !== void 0 ? _query$context6 : 'default';
  4193   const context = (_query$context6 = query?.context) !== null && _query$context6 !== void 0 ? _query$context6 : 'default';
  5408   return [state.entities.records?.[kind]?.[name]?.revisions?.[recordKey]?.items?.[context]?.[revisionKey], state.entities.records?.[kind]?.[name]?.revisions?.[recordKey]?.itemIsComplete?.[context]?.[revisionKey]];
  4194   return [state.entities.records?.[kind]?.[name]?.revisions?.[recordKey]?.items?.[context]?.[revisionKey], state.entities.records?.[kind]?.[name]?.revisions?.[recordKey]?.itemIsComplete?.[context]?.[revisionKey]];
  5409 });
  4195 });
  5410 
  4196 
  5411 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/private-selectors.js
  4197 ;// external ["wp","privateApis"]
       
  4198 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
       
  4199 ;// ./node_modules/@wordpress/core-data/build-module/lock-unlock.js
  5412 /**
  4200 /**
  5413  * WordPress dependencies
  4201  * WordPress dependencies
  5414  */
  4202  */
  5415 
  4203 
       
  4204 const {
       
  4205   lock,
       
  4206   unlock
       
  4207 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/core-data');
       
  4208 
       
  4209 ;// ./node_modules/@wordpress/core-data/build-module/private-selectors.js
       
  4210 /**
       
  4211  * WordPress dependencies
       
  4212  */
       
  4213 
  5416 
  4214 
  5417 /**
  4215 /**
  5418  * Internal dependencies
  4216  * Internal dependencies
  5419  */
  4217  */
       
  4218 
  5420 
  4219 
  5421 
  4220 
  5422 /**
  4221 /**
  5423  * Returns the previous edit from the current undo offset
  4222  * Returns the previous edit from the current undo offset
  5424  * for the entity records edits history, if any.
  4223  * for the entity records edits history, if any.
  5442 }
  4241 }
  5443 const getBlockPatternsForPostType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, postType) => select(STORE_NAME).getBlockPatterns().filter(({
  4242 const getBlockPatternsForPostType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, postType) => select(STORE_NAME).getBlockPatterns().filter(({
  5444   postTypes
  4243   postTypes
  5445 }) => !postTypes || Array.isArray(postTypes) && postTypes.includes(postType)), () => [select(STORE_NAME).getBlockPatterns()]));
  4244 }) => !postTypes || Array.isArray(postTypes) && postTypes.includes(postType)), () => [select(STORE_NAME).getBlockPatterns()]));
  5446 
  4245 
  5447 ;// CONCATENATED MODULE: ./node_modules/camel-case/dist.es2015/index.js
  4246 /**
       
  4247  * Returns the entity records permissions for the given entity record ids.
       
  4248  */
       
  4249 const getEntityRecordsPermissions = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)((state, kind, name, ids) => {
       
  4250   const normalizedIds = Array.isArray(ids) ? ids : [ids];
       
  4251   return normalizedIds.map(id => ({
       
  4252     delete: select(STORE_NAME).canUser('delete', {
       
  4253       kind,
       
  4254       name,
       
  4255       id
       
  4256     }),
       
  4257     update: select(STORE_NAME).canUser('update', {
       
  4258       kind,
       
  4259       name,
       
  4260       id
       
  4261     })
       
  4262   }));
       
  4263 }, state => [state.userPermissions]));
       
  4264 
       
  4265 /**
       
  4266  * Returns the entity record permissions for the given entity record id.
       
  4267  *
       
  4268  * @param state Data state.
       
  4269  * @param kind  Entity kind.
       
  4270  * @param name  Entity name.
       
  4271  * @param id    Entity record id.
       
  4272  *
       
  4273  * @return The entity record permissions.
       
  4274  */
       
  4275 function getEntityRecordPermissions(state, kind, name, id) {
       
  4276   return getEntityRecordsPermissions(state, kind, name, id)[0];
       
  4277 }
       
  4278 
       
  4279 /**
       
  4280  * Returns the registered post meta fields for a given post type.
       
  4281  *
       
  4282  * @param state    Data state.
       
  4283  * @param postType Post type.
       
  4284  *
       
  4285  * @return Registered post meta fields.
       
  4286  */
       
  4287 function getRegisteredPostMeta(state, postType) {
       
  4288   var _state$registeredPost;
       
  4289   return (_state$registeredPost = state.registeredPostMeta?.[postType]) !== null && _state$registeredPost !== void 0 ? _state$registeredPost : {};
       
  4290 }
       
  4291 function normalizePageId(value) {
       
  4292   if (!value || !['number', 'string'].includes(typeof value)) {
       
  4293     return null;
       
  4294   }
       
  4295 
       
  4296   // We also need to check if it's not zero (`'0'`).
       
  4297   if (Number(value) === 0) {
       
  4298     return null;
       
  4299   }
       
  4300   return value.toString();
       
  4301 }
       
  4302 const getHomePage = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(() => {
       
  4303   const siteData = select(STORE_NAME).getEntityRecord('root', '__unstableBase');
       
  4304   if (!siteData) {
       
  4305     return null;
       
  4306   }
       
  4307   const homepageId = siteData?.show_on_front === 'page' ? normalizePageId(siteData.page_on_front) : null;
       
  4308   if (homepageId) {
       
  4309     return {
       
  4310       postType: 'page',
       
  4311       postId: homepageId
       
  4312     };
       
  4313   }
       
  4314   const frontPageTemplateId = select(STORE_NAME).getDefaultTemplateId({
       
  4315     slug: 'front-page'
       
  4316   });
       
  4317   return {
       
  4318     postType: 'wp_template',
       
  4319     postId: frontPageTemplateId
       
  4320   };
       
  4321 }, state => [getEntityRecord(state, 'root', '__unstableBase'), getDefaultTemplateId(state, {
       
  4322   slug: 'front-page'
       
  4323 })]));
       
  4324 const getPostsPageId = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
       
  4325   const siteData = select(STORE_NAME).getEntityRecord('root', '__unstableBase');
       
  4326   return siteData?.show_on_front === 'page' ? normalizePageId(siteData.page_for_posts) : null;
       
  4327 });
       
  4328 const getTemplateId = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
       
  4329   const homepage = unlock(select(STORE_NAME)).getHomePage();
       
  4330   if (!homepage) {
       
  4331     return;
       
  4332   }
       
  4333 
       
  4334   // For the front page, we always use the front page template if existing.
       
  4335   if (postType === 'page' && postType === homepage?.postType && postId.toString() === homepage?.postId) {
       
  4336     // The /lookup endpoint cannot currently handle a lookup
       
  4337     // when a page is set as the front page, so specifically in
       
  4338     // that case, we want to check if there is a front page
       
  4339     // template, and instead of falling back to the home
       
  4340     // template, we want to fall back to the page template.
       
  4341     const templates = select(STORE_NAME).getEntityRecords('postType', 'wp_template', {
       
  4342       per_page: -1
       
  4343     });
       
  4344     if (!templates) {
       
  4345       return;
       
  4346     }
       
  4347     const id = templates.find(({
       
  4348       slug
       
  4349     }) => slug === 'front-page')?.id;
       
  4350     if (id) {
       
  4351       return id;
       
  4352     }
       
  4353     // If no front page template is found, continue with the
       
  4354     // logic below (fetching the page template).
       
  4355   }
       
  4356   const editedEntity = select(STORE_NAME).getEditedEntityRecord('postType', postType, postId);
       
  4357   if (!editedEntity) {
       
  4358     return;
       
  4359   }
       
  4360   const postsPageId = unlock(select(STORE_NAME)).getPostsPageId();
       
  4361   // Check if the current page is the posts page.
       
  4362   if (postType === 'page' && postsPageId === postId.toString()) {
       
  4363     return select(STORE_NAME).getDefaultTemplateId({
       
  4364       slug: 'home'
       
  4365     });
       
  4366   }
       
  4367   // First see if the post/page has an assigned template and fetch it.
       
  4368   const currentTemplateSlug = editedEntity.template;
       
  4369   if (currentTemplateSlug) {
       
  4370     const currentTemplate = select(STORE_NAME).getEntityRecords('postType', 'wp_template', {
       
  4371       per_page: -1
       
  4372     })?.find(({
       
  4373       slug
       
  4374     }) => slug === currentTemplateSlug);
       
  4375     if (currentTemplate) {
       
  4376       return currentTemplate.id;
       
  4377     }
       
  4378   }
       
  4379   // If no template is assigned, use the default template.
       
  4380   let slugToCheck;
       
  4381   // In `draft` status we might not have a slug available, so we use the `single`
       
  4382   // post type templates slug(ex page, single-post, single-product etc..).
       
  4383   // Pages do not need the `single` prefix in the slug to be prioritized
       
  4384   // through template hierarchy.
       
  4385   if (editedEntity.slug) {
       
  4386     slugToCheck = postType === 'page' ? `${postType}-${editedEntity.slug}` : `single-${postType}-${editedEntity.slug}`;
       
  4387   } else {
       
  4388     slugToCheck = postType === 'page' ? 'page' : `single-${postType}`;
       
  4389   }
       
  4390   return select(STORE_NAME).getDefaultTemplateId({
       
  4391     slug: slugToCheck
       
  4392   });
       
  4393 });
       
  4394 
       
  4395 ;// ./node_modules/@wordpress/core-data/node_modules/uuid/dist/esm-browser/native.js
       
  4396 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
       
  4397 /* harmony default export */ const esm_browser_native = ({
       
  4398   randomUUID
       
  4399 });
       
  4400 ;// ./node_modules/@wordpress/core-data/node_modules/uuid/dist/esm-browser/rng.js
       
  4401 // Unique ID creation requires a high quality random # generator. In the browser we therefore
       
  4402 // require the crypto API and do not support built-in fallback to lower quality random number
       
  4403 // generators (like Math.random()).
       
  4404 let getRandomValues;
       
  4405 const rnds8 = new Uint8Array(16);
       
  4406 function rng() {
       
  4407   // lazy load so that environments that need to polyfill have a chance to do so
       
  4408   if (!getRandomValues) {
       
  4409     // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
       
  4410     getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
       
  4411 
       
  4412     if (!getRandomValues) {
       
  4413       throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
       
  4414     }
       
  4415   }
       
  4416 
       
  4417   return getRandomValues(rnds8);
       
  4418 }
       
  4419 ;// ./node_modules/@wordpress/core-data/node_modules/uuid/dist/esm-browser/stringify.js
       
  4420 
       
  4421 /**
       
  4422  * Convert array of 16 byte values to UUID string format of the form:
       
  4423  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
       
  4424  */
       
  4425 
       
  4426 const byteToHex = [];
       
  4427 
       
  4428 for (let i = 0; i < 256; ++i) {
       
  4429   byteToHex.push((i + 0x100).toString(16).slice(1));
       
  4430 }
       
  4431 
       
  4432 function unsafeStringify(arr, offset = 0) {
       
  4433   // Note: Be careful editing this code!  It's been tuned for performance
       
  4434   // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
       
  4435   return 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]];
       
  4436 }
       
  4437 
       
  4438 function stringify(arr, offset = 0) {
       
  4439   const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID.  If this throws, it's likely due to one
       
  4440   // of the following:
       
  4441   // - One or more input array values don't map to a hex octet (leading to
       
  4442   // "undefined" in the uuid)
       
  4443   // - Invalid input values for the RFC `version` or `variant` fields
       
  4444 
       
  4445   if (!validate(uuid)) {
       
  4446     throw TypeError('Stringified UUID is invalid');
       
  4447   }
       
  4448 
       
  4449   return uuid;
       
  4450 }
       
  4451 
       
  4452 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
       
  4453 ;// ./node_modules/@wordpress/core-data/node_modules/uuid/dist/esm-browser/v4.js
       
  4454 
       
  4455 
       
  4456 
       
  4457 
       
  4458 function v4(options, buf, offset) {
       
  4459   if (esm_browser_native.randomUUID && !buf && !options) {
       
  4460     return esm_browser_native.randomUUID();
       
  4461   }
       
  4462 
       
  4463   options = options || {};
       
  4464   const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
       
  4465 
       
  4466   rnds[6] = rnds[6] & 0x0f | 0x40;
       
  4467   rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
       
  4468 
       
  4469   if (buf) {
       
  4470     offset = offset || 0;
       
  4471 
       
  4472     for (let i = 0; i < 16; ++i) {
       
  4473       buf[offset + i] = rnds[i];
       
  4474     }
       
  4475 
       
  4476     return buf;
       
  4477   }
       
  4478 
       
  4479   return unsafeStringify(rnds);
       
  4480 }
       
  4481 
       
  4482 /* harmony default export */ const esm_browser_v4 = (v4);
       
  4483 ;// ./node_modules/@wordpress/core-data/build-module/utils/get-nested-value.js
       
  4484 /**
       
  4485  * Helper util to return a value from a certain path of the object.
       
  4486  * Path is specified as either:
       
  4487  * - a string of properties, separated by dots, for example: "x.y".
       
  4488  * - an array of properties, for example `[ 'x', 'y' ]`.
       
  4489  * You can also specify a default value in case the result is nullish.
       
  4490  *
       
  4491  * @param {Object}       object       Input object.
       
  4492  * @param {string|Array} path         Path to the object property.
       
  4493  * @param {*}            defaultValue Default value if the value at the specified path is undefined.
       
  4494  * @return {*} Value of the object property at the specified path.
       
  4495  */
       
  4496 function getNestedValue(object, path, defaultValue) {
       
  4497   if (!object || typeof object !== 'object' || typeof path !== 'string' && !Array.isArray(path)) {
       
  4498     return object;
       
  4499   }
       
  4500   const normalizedPath = Array.isArray(path) ? path : path.split('.');
       
  4501   let value = object;
       
  4502   normalizedPath.forEach(fieldName => {
       
  4503     value = value?.[fieldName];
       
  4504   });
       
  4505   return value !== undefined ? value : defaultValue;
       
  4506 }
       
  4507 
       
  4508 ;// ./node_modules/@wordpress/core-data/build-module/queried-data/actions.js
       
  4509 /**
       
  4510  * Returns an action object used in signalling that items have been received.
       
  4511  *
       
  4512  * @param {Array}   items Items received.
       
  4513  * @param {?Object} edits Optional edits to reset.
       
  4514  * @param {?Object} meta  Meta information about pagination.
       
  4515  *
       
  4516  * @return {Object} Action object.
       
  4517  */
       
  4518 function receiveItems(items, edits, meta) {
       
  4519   return {
       
  4520     type: 'RECEIVE_ITEMS',
       
  4521     items: Array.isArray(items) ? items : [items],
       
  4522     persistedEdits: edits,
       
  4523     meta
       
  4524   };
       
  4525 }
       
  4526 
       
  4527 /**
       
  4528  * Returns an action object used in signalling that entity records have been
       
  4529  * deleted and they need to be removed from entities state.
       
  4530  *
       
  4531  * @param {string}              kind            Kind of the removed entities.
       
  4532  * @param {string}              name            Name of the removed entities.
       
  4533  * @param {Array|number|string} records         Record IDs of the removed entities.
       
  4534  * @param {boolean}             invalidateCache Controls whether we want to invalidate the cache.
       
  4535  * @return {Object} Action object.
       
  4536  */
       
  4537 function removeItems(kind, name, records, invalidateCache = false) {
       
  4538   return {
       
  4539     type: 'REMOVE_ITEMS',
       
  4540     itemIds: Array.isArray(records) ? records : [records],
       
  4541     kind,
       
  4542     name,
       
  4543     invalidateCache
       
  4544   };
       
  4545 }
       
  4546 
       
  4547 /**
       
  4548  * Returns an action object used in signalling that queried data has been
       
  4549  * received.
       
  4550  *
       
  4551  * @param {Array}   items Queried items received.
       
  4552  * @param {?Object} query Optional query object.
       
  4553  * @param {?Object} edits Optional edits to reset.
       
  4554  * @param {?Object} meta  Meta information about pagination.
       
  4555  *
       
  4556  * @return {Object} Action object.
       
  4557  */
       
  4558 function receiveQueriedItems(items, query = {}, edits, meta) {
       
  4559   return {
       
  4560     ...receiveItems(items, edits, meta),
       
  4561     query
       
  4562   };
       
  4563 }
       
  4564 
       
  4565 ;// ./node_modules/@wordpress/core-data/build-module/batch/default-processor.js
       
  4566 /**
       
  4567  * WordPress dependencies
       
  4568  */
       
  4569 
       
  4570 
       
  4571 /**
       
  4572  * Maximum number of requests to place in a single batch request. Obtained by
       
  4573  * sending a preflight OPTIONS request to /batch/v1/.
       
  4574  *
       
  4575  * @type {number?}
       
  4576  */
       
  4577 let maxItems = null;
       
  4578 function chunk(arr, chunkSize) {
       
  4579   const tmp = [...arr];
       
  4580   const cache = [];
       
  4581   while (tmp.length) {
       
  4582     cache.push(tmp.splice(0, chunkSize));
       
  4583   }
       
  4584   return cache;
       
  4585 }
       
  4586 
       
  4587 /**
       
  4588  * Default batch processor. Sends its input requests to /batch/v1.
       
  4589  *
       
  4590  * @param {Array} requests List of API requests to perform at once.
       
  4591  *
       
  4592  * @return {Promise} Promise that resolves to a list of objects containing
       
  4593  *                   either `output` (if that request was successful) or `error`
       
  4594  *                   (if not ).
       
  4595  */
       
  4596 async function defaultProcessor(requests) {
       
  4597   if (maxItems === null) {
       
  4598     const preflightResponse = await external_wp_apiFetch_default()({
       
  4599       path: '/batch/v1',
       
  4600       method: 'OPTIONS'
       
  4601     });
       
  4602     maxItems = preflightResponse.endpoints[0].args.requests.maxItems;
       
  4603   }
       
  4604   const results = [];
       
  4605 
       
  4606   // @ts-ignore We would have crashed or never gotten to this point if we hadn't received the maxItems count.
       
  4607   for (const batchRequests of chunk(requests, maxItems)) {
       
  4608     const batchResponse = await external_wp_apiFetch_default()({
       
  4609       path: '/batch/v1',
       
  4610       method: 'POST',
       
  4611       data: {
       
  4612         validation: 'require-all-validate',
       
  4613         requests: batchRequests.map(request => ({
       
  4614           path: request.path,
       
  4615           body: request.data,
       
  4616           // Rename 'data' to 'body'.
       
  4617           method: request.method,
       
  4618           headers: request.headers
       
  4619         }))
       
  4620       }
       
  4621     });
       
  4622     let batchResults;
       
  4623     if (batchResponse.failed) {
       
  4624       batchResults = batchResponse.responses.map(response => ({
       
  4625         error: response?.body
       
  4626       }));
       
  4627     } else {
       
  4628       batchResults = batchResponse.responses.map(response => {
       
  4629         const result = {};
       
  4630         if (response.status >= 200 && response.status < 300) {
       
  4631           result.output = response.body;
       
  4632         } else {
       
  4633           result.error = response.body;
       
  4634         }
       
  4635         return result;
       
  4636       });
       
  4637     }
       
  4638     results.push(...batchResults);
       
  4639   }
       
  4640   return results;
       
  4641 }
       
  4642 
       
  4643 ;// ./node_modules/@wordpress/core-data/build-module/batch/create-batch.js
       
  4644 /**
       
  4645  * Internal dependencies
       
  4646  */
       
  4647 
       
  4648 
       
  4649 /**
       
  4650  * Creates a batch, which can be used to combine multiple API requests into one
       
  4651  * API request using the WordPress batch processing API (/v1/batch).
       
  4652  *
       
  4653  * ```
       
  4654  * const batch = createBatch();
       
  4655  * const dunePromise = batch.add( {
       
  4656  *   path: '/v1/books',
       
  4657  *   method: 'POST',
       
  4658  *   data: { title: 'Dune' }
       
  4659  * } );
       
  4660  * const lotrPromise = batch.add( {
       
  4661  *   path: '/v1/books',
       
  4662  *   method: 'POST',
       
  4663  *   data: { title: 'Lord of the Rings' }
       
  4664  * } );
       
  4665  * const isSuccess = await batch.run(); // Sends one POST to /v1/batch.
       
  4666  * if ( isSuccess ) {
       
  4667  *   console.log(
       
  4668  *     'Saved two books:',
       
  4669  *     await dunePromise,
       
  4670  *     await lotrPromise
       
  4671  *   );
       
  4672  * }
       
  4673  * ```
       
  4674  *
       
  4675  * @param {Function} [processor] Processor function. Can be used to replace the
       
  4676  *                               default functionality which is to send an API
       
  4677  *                               request to /v1/batch. Is given an array of
       
  4678  *                               inputs and must return a promise that
       
  4679  *                               resolves to an array of objects containing
       
  4680  *                               either `output` or `error`.
       
  4681  */
       
  4682 function createBatch(processor = defaultProcessor) {
       
  4683   let lastId = 0;
       
  4684   /** @type {Array<{ input: any; resolve: ( value: any ) => void; reject: ( error: any ) => void }>} */
       
  4685   let queue = [];
       
  4686   const pending = new ObservableSet();
       
  4687   return {
       
  4688     /**
       
  4689      * Adds an input to the batch and returns a promise that is resolved or
       
  4690      * rejected when the input is processed by `batch.run()`.
       
  4691      *
       
  4692      * You may also pass a thunk which allows inputs to be added
       
  4693      * asynchronously.
       
  4694      *
       
  4695      * ```
       
  4696      * // Both are allowed:
       
  4697      * batch.add( { path: '/v1/books', ... } );
       
  4698      * batch.add( ( add ) => add( { path: '/v1/books', ... } ) );
       
  4699      * ```
       
  4700      *
       
  4701      * If a thunk is passed, `batch.run()` will pause until either:
       
  4702      *
       
  4703      * - The thunk calls its `add` argument, or;
       
  4704      * - The thunk returns a promise and that promise resolves, or;
       
  4705      * - The thunk returns a non-promise.
       
  4706      *
       
  4707      * @param {any|Function} inputOrThunk Input to add or thunk to execute.
       
  4708      *
       
  4709      * @return {Promise|any} If given an input, returns a promise that
       
  4710      *                       is resolved or rejected when the batch is
       
  4711      *                       processed. If given a thunk, returns the return
       
  4712      *                       value of that thunk.
       
  4713      */
       
  4714     add(inputOrThunk) {
       
  4715       const id = ++lastId;
       
  4716       pending.add(id);
       
  4717       const add = input => new Promise((resolve, reject) => {
       
  4718         queue.push({
       
  4719           input,
       
  4720           resolve,
       
  4721           reject
       
  4722         });
       
  4723         pending.delete(id);
       
  4724       });
       
  4725       if (typeof inputOrThunk === 'function') {
       
  4726         return Promise.resolve(inputOrThunk(add)).finally(() => {
       
  4727           pending.delete(id);
       
  4728         });
       
  4729       }
       
  4730       return add(inputOrThunk);
       
  4731     },
       
  4732     /**
       
  4733      * Runs the batch. This calls `batchProcessor` and resolves or rejects
       
  4734      * all promises returned by `add()`.
       
  4735      *
       
  4736      * @return {Promise<boolean>} A promise that resolves to a boolean that is true
       
  4737      *                   if the processor returned no errors.
       
  4738      */
       
  4739     async run() {
       
  4740       if (pending.size) {
       
  4741         await new Promise(resolve => {
       
  4742           const unsubscribe = pending.subscribe(() => {
       
  4743             if (!pending.size) {
       
  4744               unsubscribe();
       
  4745               resolve(undefined);
       
  4746             }
       
  4747           });
       
  4748         });
       
  4749       }
       
  4750       let results;
       
  4751       try {
       
  4752         results = await processor(queue.map(({
       
  4753           input
       
  4754         }) => input));
       
  4755         if (results.length !== queue.length) {
       
  4756           throw new Error('run: Array returned by processor must be same size as input array.');
       
  4757         }
       
  4758       } catch (error) {
       
  4759         for (const {
       
  4760           reject
       
  4761         } of queue) {
       
  4762           reject(error);
       
  4763         }
       
  4764         throw error;
       
  4765       }
       
  4766       let isSuccess = true;
       
  4767       results.forEach((result, key) => {
       
  4768         const queueItem = queue[key];
       
  4769         if (result?.error) {
       
  4770           queueItem?.reject(result.error);
       
  4771           isSuccess = false;
       
  4772         } else {
       
  4773           var _result$output;
       
  4774           queueItem?.resolve((_result$output = result?.output) !== null && _result$output !== void 0 ? _result$output : result);
       
  4775         }
       
  4776       });
       
  4777       queue = [];
       
  4778       return isSuccess;
       
  4779     }
       
  4780   };
       
  4781 }
       
  4782 class ObservableSet {
       
  4783   constructor(...args) {
       
  4784     this.set = new Set(...args);
       
  4785     this.subscribers = new Set();
       
  4786   }
       
  4787   get size() {
       
  4788     return this.set.size;
       
  4789   }
       
  4790   add(value) {
       
  4791     this.set.add(value);
       
  4792     this.subscribers.forEach(subscriber => subscriber());
       
  4793     return this;
       
  4794   }
       
  4795   delete(value) {
       
  4796     const isSuccess = this.set.delete(value);
       
  4797     this.subscribers.forEach(subscriber => subscriber());
       
  4798     return isSuccess;
       
  4799   }
       
  4800   subscribe(subscriber) {
       
  4801     this.subscribers.add(subscriber);
       
  4802     return () => {
       
  4803       this.subscribers.delete(subscriber);
       
  4804     };
       
  4805   }
       
  4806 }
       
  4807 
       
  4808 ;// ./node_modules/@wordpress/core-data/build-module/actions.js
       
  4809 /**
       
  4810  * External dependencies
       
  4811  */
       
  4812 
       
  4813 
       
  4814 
       
  4815 /**
       
  4816  * WordPress dependencies
       
  4817  */
       
  4818 
       
  4819 
       
  4820 
       
  4821 
       
  4822 /**
       
  4823  * Internal dependencies
       
  4824  */
       
  4825 
       
  4826 
       
  4827 
       
  4828 
       
  4829 
       
  4830 
       
  4831 
       
  4832 /**
       
  4833  * Returns an action object used in signalling that authors have been received.
       
  4834  * Ignored from documentation as it's internal to the data store.
       
  4835  *
       
  4836  * @ignore
       
  4837  *
       
  4838  * @param {string}       queryID Query ID.
       
  4839  * @param {Array|Object} users   Users received.
       
  4840  *
       
  4841  * @return {Object} Action object.
       
  4842  */
       
  4843 function receiveUserQuery(queryID, users) {
       
  4844   return {
       
  4845     type: 'RECEIVE_USER_QUERY',
       
  4846     users: Array.isArray(users) ? users : [users],
       
  4847     queryID
       
  4848   };
       
  4849 }
       
  4850 
       
  4851 /**
       
  4852  * Returns an action used in signalling that the current user has been received.
       
  4853  * Ignored from documentation as it's internal to the data store.
       
  4854  *
       
  4855  * @ignore
       
  4856  *
       
  4857  * @param {Object} currentUser Current user object.
       
  4858  *
       
  4859  * @return {Object} Action object.
       
  4860  */
       
  4861 function receiveCurrentUser(currentUser) {
       
  4862   return {
       
  4863     type: 'RECEIVE_CURRENT_USER',
       
  4864     currentUser
       
  4865   };
       
  4866 }
       
  4867 
       
  4868 /**
       
  4869  * Returns an action object used in adding new entities.
       
  4870  *
       
  4871  * @param {Array} entities Entities received.
       
  4872  *
       
  4873  * @return {Object} Action object.
       
  4874  */
       
  4875 function addEntities(entities) {
       
  4876   return {
       
  4877     type: 'ADD_ENTITIES',
       
  4878     entities
       
  4879   };
       
  4880 }
       
  4881 
       
  4882 /**
       
  4883  * Returns an action object used in signalling that entity records have been received.
       
  4884  *
       
  4885  * @param {string}       kind            Kind of the received entity record.
       
  4886  * @param {string}       name            Name of the received entity record.
       
  4887  * @param {Array|Object} records         Records received.
       
  4888  * @param {?Object}      query           Query Object.
       
  4889  * @param {?boolean}     invalidateCache Should invalidate query caches.
       
  4890  * @param {?Object}      edits           Edits to reset.
       
  4891  * @param {?Object}      meta            Meta information about pagination.
       
  4892  * @return {Object} Action object.
       
  4893  */
       
  4894 function receiveEntityRecords(kind, name, records, query, invalidateCache = false, edits, meta) {
       
  4895   // Auto drafts should not have titles, but some plugins rely on them so we can't filter this
       
  4896   // on the server.
       
  4897   if (kind === 'postType') {
       
  4898     records = (Array.isArray(records) ? records : [records]).map(record => record.status === 'auto-draft' ? {
       
  4899       ...record,
       
  4900       title: ''
       
  4901     } : record);
       
  4902   }
       
  4903   let action;
       
  4904   if (query) {
       
  4905     action = receiveQueriedItems(records, query, edits, meta);
       
  4906   } else {
       
  4907     action = receiveItems(records, edits, meta);
       
  4908   }
       
  4909   return {
       
  4910     ...action,
       
  4911     kind,
       
  4912     name,
       
  4913     invalidateCache
       
  4914   };
       
  4915 }
       
  4916 
       
  4917 /**
       
  4918  * Returns an action object used in signalling that the current theme has been received.
       
  4919  * Ignored from documentation as it's internal to the data store.
       
  4920  *
       
  4921  * @ignore
       
  4922  *
       
  4923  * @param {Object} currentTheme The current theme.
       
  4924  *
       
  4925  * @return {Object} Action object.
       
  4926  */
       
  4927 function receiveCurrentTheme(currentTheme) {
       
  4928   return {
       
  4929     type: 'RECEIVE_CURRENT_THEME',
       
  4930     currentTheme
       
  4931   };
       
  4932 }
       
  4933 
       
  4934 /**
       
  4935  * Returns an action object used in signalling that the current global styles id has been received.
       
  4936  * Ignored from documentation as it's internal to the data store.
       
  4937  *
       
  4938  * @ignore
       
  4939  *
       
  4940  * @param {string} currentGlobalStylesId The current global styles id.
       
  4941  *
       
  4942  * @return {Object} Action object.
       
  4943  */
       
  4944 function __experimentalReceiveCurrentGlobalStylesId(currentGlobalStylesId) {
       
  4945   return {
       
  4946     type: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',
       
  4947     id: currentGlobalStylesId
       
  4948   };
       
  4949 }
       
  4950 
       
  4951 /**
       
  4952  * Returns an action object used in signalling that the theme base global styles have been received
       
  4953  * Ignored from documentation as it's internal to the data store.
       
  4954  *
       
  4955  * @ignore
       
  4956  *
       
  4957  * @param {string} stylesheet   The theme's identifier
       
  4958  * @param {Object} globalStyles The global styles object.
       
  4959  *
       
  4960  * @return {Object} Action object.
       
  4961  */
       
  4962 function __experimentalReceiveThemeBaseGlobalStyles(stylesheet, globalStyles) {
       
  4963   return {
       
  4964     type: 'RECEIVE_THEME_GLOBAL_STYLES',
       
  4965     stylesheet,
       
  4966     globalStyles
       
  4967   };
       
  4968 }
       
  4969 
       
  4970 /**
       
  4971  * Returns an action object used in signalling that the theme global styles variations have been received.
       
  4972  * Ignored from documentation as it's internal to the data store.
       
  4973  *
       
  4974  * @ignore
       
  4975  *
       
  4976  * @param {string} stylesheet The theme's identifier
       
  4977  * @param {Array}  variations The global styles variations.
       
  4978  *
       
  4979  * @return {Object} Action object.
       
  4980  */
       
  4981 function __experimentalReceiveThemeGlobalStyleVariations(stylesheet, variations) {
       
  4982   return {
       
  4983     type: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',
       
  4984     stylesheet,
       
  4985     variations
       
  4986   };
       
  4987 }
       
  4988 
       
  4989 /**
       
  4990  * Returns an action object used in signalling that the index has been received.
       
  4991  *
       
  4992  * @deprecated since WP 5.9, this is not useful anymore, use the selector directly.
       
  4993  *
       
  4994  * @return {Object} Action object.
       
  4995  */
       
  4996 function receiveThemeSupports() {
       
  4997   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeSupports", {
       
  4998     since: '5.9'
       
  4999   });
       
  5000   return {
       
  5001     type: 'DO_NOTHING'
       
  5002   };
       
  5003 }
       
  5004 
       
  5005 /**
       
  5006  * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.
       
  5007  * Ignored from documentation as it's internal to the data store.
       
  5008  *
       
  5009  * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.
       
  5010  *
       
  5011  * @ignore
       
  5012  *
       
  5013  * @param {number} currentId The post id.
       
  5014  * @param {Array}  revisions The global styles revisions.
       
  5015  *
       
  5016  * @return {Object} Action object.
       
  5017  */
       
  5018 function receiveThemeGlobalStyleRevisions(currentId, revisions) {
       
  5019   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()", {
       
  5020     since: '6.5.0',
       
  5021     alternative: "wp.data.dispatch( 'core' ).receiveRevisions"
       
  5022   });
       
  5023   return {
       
  5024     type: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',
       
  5025     currentId,
       
  5026     revisions
       
  5027   };
       
  5028 }
       
  5029 
       
  5030 /**
       
  5031  * Returns an action object used in signalling that the preview data for
       
  5032  * a given URl has been received.
       
  5033  * Ignored from documentation as it's internal to the data store.
       
  5034  *
       
  5035  * @ignore
       
  5036  *
       
  5037  * @param {string} url     URL to preview the embed for.
       
  5038  * @param {*}      preview Preview data.
       
  5039  *
       
  5040  * @return {Object} Action object.
       
  5041  */
       
  5042 function receiveEmbedPreview(url, preview) {
       
  5043   return {
       
  5044     type: 'RECEIVE_EMBED_PREVIEW',
       
  5045     url,
       
  5046     preview
       
  5047   };
       
  5048 }
       
  5049 
       
  5050 /**
       
  5051  * Action triggered to delete an entity record.
       
  5052  *
       
  5053  * @param {string}        kind                         Kind of the deleted entity.
       
  5054  * @param {string}        name                         Name of the deleted entity.
       
  5055  * @param {number|string} recordId                     Record ID of the deleted entity.
       
  5056  * @param {?Object}       query                        Special query parameters for the
       
  5057  *                                                     DELETE API call.
       
  5058  * @param {Object}        [options]                    Delete options.
       
  5059  * @param {Function}      [options.__unstableFetch]    Internal use only. Function to
       
  5060  *                                                     call instead of `apiFetch()`.
       
  5061  *                                                     Must return a promise.
       
  5062  * @param {boolean}       [options.throwOnError=false] If false, this action suppresses all
       
  5063  *                                                     the exceptions. Defaults to false.
       
  5064  */
       
  5065 const deleteEntityRecord = (kind, name, recordId, query, {
       
  5066   __unstableFetch = (external_wp_apiFetch_default()),
       
  5067   throwOnError = false
       
  5068 } = {}) => async ({
       
  5069   dispatch,
       
  5070   resolveSelect
       
  5071 }) => {
       
  5072   const configs = await resolveSelect.getEntitiesConfig(kind);
       
  5073   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  5074   let error;
       
  5075   let deletedRecord = false;
       
  5076   if (!entityConfig) {
       
  5077     return;
       
  5078   }
       
  5079   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId], {
       
  5080     exclusive: true
       
  5081   });
       
  5082   try {
       
  5083     dispatch({
       
  5084       type: 'DELETE_ENTITY_RECORD_START',
       
  5085       kind,
       
  5086       name,
       
  5087       recordId
       
  5088     });
       
  5089     let hasError = false;
       
  5090     try {
       
  5091       let path = `${entityConfig.baseURL}/${recordId}`;
       
  5092       if (query) {
       
  5093         path = (0,external_wp_url_namespaceObject.addQueryArgs)(path, query);
       
  5094       }
       
  5095       deletedRecord = await __unstableFetch({
       
  5096         path,
       
  5097         method: 'DELETE'
       
  5098       });
       
  5099       await dispatch(removeItems(kind, name, recordId, true));
       
  5100     } catch (_error) {
       
  5101       hasError = true;
       
  5102       error = _error;
       
  5103     }
       
  5104     dispatch({
       
  5105       type: 'DELETE_ENTITY_RECORD_FINISH',
       
  5106       kind,
       
  5107       name,
       
  5108       recordId,
       
  5109       error
       
  5110     });
       
  5111     if (hasError && throwOnError) {
       
  5112       throw error;
       
  5113     }
       
  5114     return deletedRecord;
       
  5115   } finally {
       
  5116     dispatch.__unstableReleaseStoreLock(lock);
       
  5117   }
       
  5118 };
       
  5119 
       
  5120 /**
       
  5121  * Returns an action object that triggers an
       
  5122  * edit to an entity record.
       
  5123  *
       
  5124  * @param {string}        kind                 Kind of the edited entity record.
       
  5125  * @param {string}        name                 Name of the edited entity record.
       
  5126  * @param {number|string} recordId             Record ID of the edited entity record.
       
  5127  * @param {Object}        edits                The edits.
       
  5128  * @param {Object}        options              Options for the edit.
       
  5129  * @param {boolean}       [options.undoIgnore] Whether to ignore the edit in undo history or not.
       
  5130  *
       
  5131  * @return {Object} Action object.
       
  5132  */
       
  5133 const editEntityRecord = (kind, name, recordId, edits, options = {}) => ({
       
  5134   select,
       
  5135   dispatch
       
  5136 }) => {
       
  5137   const entityConfig = select.getEntityConfig(kind, name);
       
  5138   if (!entityConfig) {
       
  5139     throw new Error(`The entity being edited (${kind}, ${name}) does not have a loaded config.`);
       
  5140   }
       
  5141   const {
       
  5142     mergedEdits = {}
       
  5143   } = entityConfig;
       
  5144   const record = select.getRawEntityRecord(kind, name, recordId);
       
  5145   const editedRecord = select.getEditedEntityRecord(kind, name, recordId);
       
  5146   const edit = {
       
  5147     kind,
       
  5148     name,
       
  5149     recordId,
       
  5150     // Clear edits when they are equal to their persisted counterparts
       
  5151     // so that the property is not considered dirty.
       
  5152     edits: Object.keys(edits).reduce((acc, key) => {
       
  5153       const recordValue = record[key];
       
  5154       const editedRecordValue = editedRecord[key];
       
  5155       const value = mergedEdits[key] ? {
       
  5156         ...editedRecordValue,
       
  5157         ...edits[key]
       
  5158       } : edits[key];
       
  5159       acc[key] = es6_default()(recordValue, value) ? undefined : value;
       
  5160       return acc;
       
  5161     }, {})
       
  5162   };
       
  5163   if (window.__experimentalEnableSync && entityConfig.syncConfig) {
       
  5164     if (false) {}
       
  5165   } else {
       
  5166     if (!options.undoIgnore) {
       
  5167       select.getUndoManager().addRecord([{
       
  5168         id: {
       
  5169           kind,
       
  5170           name,
       
  5171           recordId
       
  5172         },
       
  5173         changes: Object.keys(edits).reduce((acc, key) => {
       
  5174           acc[key] = {
       
  5175             from: editedRecord[key],
       
  5176             to: edits[key]
       
  5177           };
       
  5178           return acc;
       
  5179         }, {})
       
  5180       }], options.isCached);
       
  5181     }
       
  5182     dispatch({
       
  5183       type: 'EDIT_ENTITY_RECORD',
       
  5184       ...edit
       
  5185     });
       
  5186   }
       
  5187 };
       
  5188 
       
  5189 /**
       
  5190  * Action triggered to undo the last edit to
       
  5191  * an entity record, if any.
       
  5192  */
       
  5193 const undo = () => ({
       
  5194   select,
       
  5195   dispatch
       
  5196 }) => {
       
  5197   const undoRecord = select.getUndoManager().undo();
       
  5198   if (!undoRecord) {
       
  5199     return;
       
  5200   }
       
  5201   dispatch({
       
  5202     type: 'UNDO',
       
  5203     record: undoRecord
       
  5204   });
       
  5205 };
       
  5206 
       
  5207 /**
       
  5208  * Action triggered to redo the last undone
       
  5209  * edit to an entity record, if any.
       
  5210  */
       
  5211 const redo = () => ({
       
  5212   select,
       
  5213   dispatch
       
  5214 }) => {
       
  5215   const redoRecord = select.getUndoManager().redo();
       
  5216   if (!redoRecord) {
       
  5217     return;
       
  5218   }
       
  5219   dispatch({
       
  5220     type: 'REDO',
       
  5221     record: redoRecord
       
  5222   });
       
  5223 };
       
  5224 
       
  5225 /**
       
  5226  * Forces the creation of a new undo level.
       
  5227  *
       
  5228  * @return {Object} Action object.
       
  5229  */
       
  5230 const __unstableCreateUndoLevel = () => ({
       
  5231   select
       
  5232 }) => {
       
  5233   select.getUndoManager().addRecord();
       
  5234 };
       
  5235 
       
  5236 /**
       
  5237  * Action triggered to save an entity record.
       
  5238  *
       
  5239  * @param {string}   kind                         Kind of the received entity.
       
  5240  * @param {string}   name                         Name of the received entity.
       
  5241  * @param {Object}   record                       Record to be saved.
       
  5242  * @param {Object}   options                      Saving options.
       
  5243  * @param {boolean}  [options.isAutosave=false]   Whether this is an autosave.
       
  5244  * @param {Function} [options.__unstableFetch]    Internal use only. Function to
       
  5245  *                                                call instead of `apiFetch()`.
       
  5246  *                                                Must return a promise.
       
  5247  * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all
       
  5248  *                                                the exceptions. Defaults to false.
       
  5249  */
       
  5250 const saveEntityRecord = (kind, name, record, {
       
  5251   isAutosave = false,
       
  5252   __unstableFetch = (external_wp_apiFetch_default()),
       
  5253   throwOnError = false
       
  5254 } = {}) => async ({
       
  5255   select,
       
  5256   resolveSelect,
       
  5257   dispatch
       
  5258 }) => {
       
  5259   const configs = await resolveSelect.getEntitiesConfig(kind);
       
  5260   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  5261   if (!entityConfig) {
       
  5262     return;
       
  5263   }
       
  5264   const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
       
  5265   const recordId = record[entityIdKey];
       
  5266   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, recordId || esm_browser_v4()], {
       
  5267     exclusive: true
       
  5268   });
       
  5269   try {
       
  5270     // Evaluate optimized edits.
       
  5271     // (Function edits that should be evaluated on save to avoid expensive computations on every edit.)
       
  5272     for (const [key, value] of Object.entries(record)) {
       
  5273       if (typeof value === 'function') {
       
  5274         const evaluatedValue = value(select.getEditedEntityRecord(kind, name, recordId));
       
  5275         dispatch.editEntityRecord(kind, name, recordId, {
       
  5276           [key]: evaluatedValue
       
  5277         }, {
       
  5278           undoIgnore: true
       
  5279         });
       
  5280         record[key] = evaluatedValue;
       
  5281       }
       
  5282     }
       
  5283     dispatch({
       
  5284       type: 'SAVE_ENTITY_RECORD_START',
       
  5285       kind,
       
  5286       name,
       
  5287       recordId,
       
  5288       isAutosave
       
  5289     });
       
  5290     let updatedRecord;
       
  5291     let error;
       
  5292     let hasError = false;
       
  5293     try {
       
  5294       const path = `${entityConfig.baseURL}${recordId ? '/' + recordId : ''}`;
       
  5295       const persistedRecord = select.getRawEntityRecord(kind, name, recordId);
       
  5296       if (isAutosave) {
       
  5297         // Most of this autosave logic is very specific to posts.
       
  5298         // This is fine for now as it is the only supported autosave,
       
  5299         // but ideally this should all be handled in the back end,
       
  5300         // so the client just sends and receives objects.
       
  5301         const currentUser = select.getCurrentUser();
       
  5302         const currentUserId = currentUser ? currentUser.id : undefined;
       
  5303         const autosavePost = await resolveSelect.getAutosave(persistedRecord.type, persistedRecord.id, currentUserId);
       
  5304         // Autosaves need all expected fields to be present.
       
  5305         // So we fallback to the previous autosave and then
       
  5306         // to the actual persisted entity if the edits don't
       
  5307         // have a value.
       
  5308         let data = {
       
  5309           ...persistedRecord,
       
  5310           ...autosavePost,
       
  5311           ...record
       
  5312         };
       
  5313         data = Object.keys(data).reduce((acc, key) => {
       
  5314           if (['title', 'excerpt', 'content', 'meta'].includes(key)) {
       
  5315             acc[key] = data[key];
       
  5316           }
       
  5317           return acc;
       
  5318         }, {
       
  5319           // Do not update the `status` if we have edited it when auto saving.
       
  5320           // It's very important to let the user explicitly save this change,
       
  5321           // because it can lead to unexpected results. An example would be to
       
  5322           // have a draft post and change the status to publish.
       
  5323           status: data.status === 'auto-draft' ? 'draft' : undefined
       
  5324         });
       
  5325         updatedRecord = await __unstableFetch({
       
  5326           path: `${path}/autosaves`,
       
  5327           method: 'POST',
       
  5328           data
       
  5329         });
       
  5330 
       
  5331         // An autosave may be processed by the server as a regular save
       
  5332         // when its update is requested by the author and the post had
       
  5333         // draft or auto-draft status.
       
  5334         if (persistedRecord.id === updatedRecord.id) {
       
  5335           let newRecord = {
       
  5336             ...persistedRecord,
       
  5337             ...data,
       
  5338             ...updatedRecord
       
  5339           };
       
  5340           newRecord = Object.keys(newRecord).reduce((acc, key) => {
       
  5341             // These properties are persisted in autosaves.
       
  5342             if (['title', 'excerpt', 'content'].includes(key)) {
       
  5343               acc[key] = newRecord[key];
       
  5344             } else if (key === 'status') {
       
  5345               // Status is only persisted in autosaves when going from
       
  5346               // "auto-draft" to "draft".
       
  5347               acc[key] = persistedRecord.status === 'auto-draft' && newRecord.status === 'draft' ? newRecord.status : persistedRecord.status;
       
  5348             } else {
       
  5349               // These properties are not persisted in autosaves.
       
  5350               acc[key] = persistedRecord[key];
       
  5351             }
       
  5352             return acc;
       
  5353           }, {});
       
  5354           dispatch.receiveEntityRecords(kind, name, newRecord, undefined, true);
       
  5355         } else {
       
  5356           dispatch.receiveAutosaves(persistedRecord.id, updatedRecord);
       
  5357         }
       
  5358       } else {
       
  5359         let edits = record;
       
  5360         if (entityConfig.__unstablePrePersist) {
       
  5361           edits = {
       
  5362             ...edits,
       
  5363             ...entityConfig.__unstablePrePersist(persistedRecord, edits)
       
  5364           };
       
  5365         }
       
  5366         updatedRecord = await __unstableFetch({
       
  5367           path,
       
  5368           method: recordId ? 'PUT' : 'POST',
       
  5369           data: edits
       
  5370         });
       
  5371         dispatch.receiveEntityRecords(kind, name, updatedRecord, undefined, true, edits);
       
  5372       }
       
  5373     } catch (_error) {
       
  5374       hasError = true;
       
  5375       error = _error;
       
  5376     }
       
  5377     dispatch({
       
  5378       type: 'SAVE_ENTITY_RECORD_FINISH',
       
  5379       kind,
       
  5380       name,
       
  5381       recordId,
       
  5382       error,
       
  5383       isAutosave
       
  5384     });
       
  5385     if (hasError && throwOnError) {
       
  5386       throw error;
       
  5387     }
       
  5388     return updatedRecord;
       
  5389   } finally {
       
  5390     dispatch.__unstableReleaseStoreLock(lock);
       
  5391   }
       
  5392 };
       
  5393 
       
  5394 /**
       
  5395  * Runs multiple core-data actions at the same time using one API request.
       
  5396  *
       
  5397  * Example:
       
  5398  *
       
  5399  * ```
       
  5400  * const [ savedRecord, updatedRecord, deletedRecord ] =
       
  5401  *   await dispatch( 'core' ).__experimentalBatch( [
       
  5402  *     ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ),
       
  5403  *     ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ),
       
  5404  *     ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ),
       
  5405  *   ] );
       
  5406  * ```
       
  5407  *
       
  5408  * @param {Array} requests Array of functions which are invoked simultaneously.
       
  5409  *                         Each function is passed an object containing
       
  5410  *                         `saveEntityRecord`, `saveEditedEntityRecord`, and
       
  5411  *                         `deleteEntityRecord`.
       
  5412  *
       
  5413  * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return
       
  5414  *                                          values of each function given in `requests`.
       
  5415  */
       
  5416 const __experimentalBatch = requests => async ({
       
  5417   dispatch
       
  5418 }) => {
       
  5419   const batch = createBatch();
       
  5420   const api = {
       
  5421     saveEntityRecord(kind, name, record, options) {
       
  5422       return batch.add(add => dispatch.saveEntityRecord(kind, name, record, {
       
  5423         ...options,
       
  5424         __unstableFetch: add
       
  5425       }));
       
  5426     },
       
  5427     saveEditedEntityRecord(kind, name, recordId, options) {
       
  5428       return batch.add(add => dispatch.saveEditedEntityRecord(kind, name, recordId, {
       
  5429         ...options,
       
  5430         __unstableFetch: add
       
  5431       }));
       
  5432     },
       
  5433     deleteEntityRecord(kind, name, recordId, query, options) {
       
  5434       return batch.add(add => dispatch.deleteEntityRecord(kind, name, recordId, query, {
       
  5435         ...options,
       
  5436         __unstableFetch: add
       
  5437       }));
       
  5438     }
       
  5439   };
       
  5440   const resultPromises = requests.map(request => request(api));
       
  5441   const [, ...results] = await Promise.all([batch.run(), ...resultPromises]);
       
  5442   return results;
       
  5443 };
       
  5444 
       
  5445 /**
       
  5446  * Action triggered to save an entity record's edits.
       
  5447  *
       
  5448  * @param {string}  kind     Kind of the entity.
       
  5449  * @param {string}  name     Name of the entity.
       
  5450  * @param {Object}  recordId ID of the record.
       
  5451  * @param {Object=} options  Saving options.
       
  5452  */
       
  5453 const saveEditedEntityRecord = (kind, name, recordId, options) => async ({
       
  5454   select,
       
  5455   dispatch,
       
  5456   resolveSelect
       
  5457 }) => {
       
  5458   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
       
  5459     return;
       
  5460   }
       
  5461   const configs = await resolveSelect.getEntitiesConfig(kind);
       
  5462   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  5463   if (!entityConfig) {
       
  5464     return;
       
  5465   }
       
  5466   const entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;
       
  5467   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
       
  5468   const record = {
       
  5469     [entityIdKey]: recordId,
       
  5470     ...edits
       
  5471   };
       
  5472   return await dispatch.saveEntityRecord(kind, name, record, options);
       
  5473 };
       
  5474 
       
  5475 /**
       
  5476  * Action triggered to save only specified properties for the entity.
       
  5477  *
       
  5478  * @param {string}        kind        Kind of the entity.
       
  5479  * @param {string}        name        Name of the entity.
       
  5480  * @param {number|string} recordId    ID of the record.
       
  5481  * @param {Array}         itemsToSave List of entity properties or property paths to save.
       
  5482  * @param {Object}        options     Saving options.
       
  5483  */
       
  5484 const __experimentalSaveSpecifiedEntityEdits = (kind, name, recordId, itemsToSave, options) => async ({
       
  5485   select,
       
  5486   dispatch,
       
  5487   resolveSelect
       
  5488 }) => {
       
  5489   if (!select.hasEditsForEntityRecord(kind, name, recordId)) {
       
  5490     return;
       
  5491   }
       
  5492   const edits = select.getEntityRecordNonTransientEdits(kind, name, recordId);
       
  5493   const editsToSave = {};
       
  5494   for (const item of itemsToSave) {
       
  5495     setNestedValue(editsToSave, item, getNestedValue(edits, item));
       
  5496   }
       
  5497   const configs = await resolveSelect.getEntitiesConfig(kind);
       
  5498   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  5499   const entityIdKey = entityConfig?.key || DEFAULT_ENTITY_KEY;
       
  5500 
       
  5501   // If a record key is provided then update the existing record.
       
  5502   // This necessitates providing `recordKey` to saveEntityRecord as part of the
       
  5503   // `record` argument (here called `editsToSave`) to stop that action creating
       
  5504   // a new record and instead cause it to update the existing record.
       
  5505   if (recordId) {
       
  5506     editsToSave[entityIdKey] = recordId;
       
  5507   }
       
  5508   return await dispatch.saveEntityRecord(kind, name, editsToSave, options);
       
  5509 };
       
  5510 
       
  5511 /**
       
  5512  * Returns an action object used in signalling that Upload permissions have been received.
       
  5513  *
       
  5514  * @deprecated since WP 5.9, use receiveUserPermission instead.
       
  5515  *
       
  5516  * @param {boolean} hasUploadPermissions Does the user have permission to upload files?
       
  5517  *
       
  5518  * @return {Object} Action object.
       
  5519  */
       
  5520 function receiveUploadPermissions(hasUploadPermissions) {
       
  5521   external_wp_deprecated_default()("wp.data.dispatch( 'core' ).receiveUploadPermissions", {
       
  5522     since: '5.9',
       
  5523     alternative: 'receiveUserPermission'
       
  5524   });
       
  5525   return receiveUserPermission('create/media', hasUploadPermissions);
       
  5526 }
       
  5527 
       
  5528 /**
       
  5529  * Returns an action object used in signalling that the current user has
       
  5530  * permission to perform an action on a REST resource.
       
  5531  * Ignored from documentation as it's internal to the data store.
       
  5532  *
       
  5533  * @ignore
       
  5534  *
       
  5535  * @param {string}  key       A key that represents the action and REST resource.
       
  5536  * @param {boolean} isAllowed Whether or not the user can perform the action.
       
  5537  *
       
  5538  * @return {Object} Action object.
       
  5539  */
       
  5540 function receiveUserPermission(key, isAllowed) {
       
  5541   return {
       
  5542     type: 'RECEIVE_USER_PERMISSION',
       
  5543     key,
       
  5544     isAllowed
       
  5545   };
       
  5546 }
       
  5547 
       
  5548 /**
       
  5549  * Returns an action object used in signalling that the current user has
       
  5550  * permission to perform an action on a REST resource. Ignored from
       
  5551  * documentation as it's internal to the data store.
       
  5552  *
       
  5553  * @ignore
       
  5554  *
       
  5555  * @param {Object<string, boolean>} permissions An object where keys represent
       
  5556  *                                              actions and REST resources, and
       
  5557  *                                              values indicate whether the user
       
  5558  *                                              is allowed to perform the
       
  5559  *                                              action.
       
  5560  *
       
  5561  * @return {Object} Action object.
       
  5562  */
       
  5563 function receiveUserPermissions(permissions) {
       
  5564   return {
       
  5565     type: 'RECEIVE_USER_PERMISSIONS',
       
  5566     permissions
       
  5567   };
       
  5568 }
       
  5569 
       
  5570 /**
       
  5571  * Returns an action object used in signalling that the autosaves for a
       
  5572  * post have been received.
       
  5573  * Ignored from documentation as it's internal to the data store.
       
  5574  *
       
  5575  * @ignore
       
  5576  *
       
  5577  * @param {number}       postId    The id of the post that is parent to the autosave.
       
  5578  * @param {Array|Object} autosaves An array of autosaves or singular autosave object.
       
  5579  *
       
  5580  * @return {Object} Action object.
       
  5581  */
       
  5582 function receiveAutosaves(postId, autosaves) {
       
  5583   return {
       
  5584     type: 'RECEIVE_AUTOSAVES',
       
  5585     postId,
       
  5586     autosaves: Array.isArray(autosaves) ? autosaves : [autosaves]
       
  5587   };
       
  5588 }
       
  5589 
       
  5590 /**
       
  5591  * Returns an action object signalling that the fallback Navigation
       
  5592  * Menu id has been received.
       
  5593  *
       
  5594  * @param {integer} fallbackId the id of the fallback Navigation Menu
       
  5595  * @return {Object} Action object.
       
  5596  */
       
  5597 function receiveNavigationFallbackId(fallbackId) {
       
  5598   return {
       
  5599     type: 'RECEIVE_NAVIGATION_FALLBACK_ID',
       
  5600     fallbackId
       
  5601   };
       
  5602 }
       
  5603 
       
  5604 /**
       
  5605  * Returns an action object used to set the template for a given query.
       
  5606  *
       
  5607  * @param {Object} query      The lookup query.
       
  5608  * @param {string} templateId The resolved template id.
       
  5609  *
       
  5610  * @return {Object} Action object.
       
  5611  */
       
  5612 function receiveDefaultTemplateId(query, templateId) {
       
  5613   return {
       
  5614     type: 'RECEIVE_DEFAULT_TEMPLATE',
       
  5615     query,
       
  5616     templateId
       
  5617   };
       
  5618 }
       
  5619 
       
  5620 /**
       
  5621  * Action triggered to receive revision items.
       
  5622  *
       
  5623  * @param {string}        kind            Kind of the received entity record revisions.
       
  5624  * @param {string}        name            Name of the received entity record revisions.
       
  5625  * @param {number|string} recordKey       The key of the entity record whose revisions you want to fetch.
       
  5626  * @param {Array|Object}  records         Revisions received.
       
  5627  * @param {?Object}       query           Query Object.
       
  5628  * @param {?boolean}      invalidateCache Should invalidate query caches.
       
  5629  * @param {?Object}       meta            Meta information about pagination.
       
  5630  */
       
  5631 const receiveRevisions = (kind, name, recordKey, records, query, invalidateCache = false, meta) => async ({
       
  5632   dispatch,
       
  5633   resolveSelect
       
  5634 }) => {
       
  5635   const configs = await resolveSelect.getEntitiesConfig(kind);
       
  5636   const entityConfig = configs.find(config => config.kind === kind && config.name === name);
       
  5637   const key = entityConfig && entityConfig?.revisionKey ? entityConfig.revisionKey : DEFAULT_ENTITY_KEY;
       
  5638   dispatch({
       
  5639     type: 'RECEIVE_ITEM_REVISIONS',
       
  5640     key,
       
  5641     items: Array.isArray(records) ? records : [records],
       
  5642     recordKey,
       
  5643     meta,
       
  5644     query,
       
  5645     kind,
       
  5646     name,
       
  5647     invalidateCache
       
  5648   });
       
  5649 };
       
  5650 
       
  5651 ;// ./node_modules/@wordpress/core-data/build-module/private-actions.js
       
  5652 /**
       
  5653  * Returns an action object used in signalling that the registered post meta
       
  5654  * fields for a post type have been received.
       
  5655  *
       
  5656  * @param {string} postType           Post type slug.
       
  5657  * @param {Object} registeredPostMeta Registered post meta.
       
  5658  *
       
  5659  * @return {Object} Action object.
       
  5660  */
       
  5661 function receiveRegisteredPostMeta(postType, registeredPostMeta) {
       
  5662   return {
       
  5663     type: 'RECEIVE_REGISTERED_POST_META',
       
  5664     postType,
       
  5665     registeredPostMeta
       
  5666   };
       
  5667 }
       
  5668 
       
  5669 ;// ./node_modules/camel-case/dist.es2015/index.js
  5448 
  5670 
  5449 
  5671 
  5450 function camelCaseTransform(input, index) {
  5672 function camelCaseTransform(input, index) {
  5451     if (index === 0)
  5673     if (index === 0)
  5452         return input.toLowerCase();
  5674         return input.toLowerCase();
  5460 function camelCase(input, options) {
  5682 function camelCase(input, options) {
  5461     if (options === void 0) { options = {}; }
  5683     if (options === void 0) { options = {}; }
  5462     return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
  5684     return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
  5463 }
  5685 }
  5464 
  5686 
  5465 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  5687 ;// external ["wp","htmlEntities"]
  5466 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  5688 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  5467 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/utils/forward-resolver.js
  5689 ;// ./node_modules/@wordpress/core-data/build-module/utils/forward-resolver.js
  5468 /**
  5690 /**
  5469  * Higher-order function which forward the resolution to another resolver with the same arguments.
  5691  * Higher-order function which forward the resolution to another resolver with the same arguments.
  5470  *
  5692  *
  5471  * @param {string} resolverName forwarded resolver.
  5693  * @param {string} resolverName forwarded resolver.
  5472  *
  5694  *
  5477 }) => {
  5699 }) => {
  5478   await resolveSelect[resolverName](...args);
  5700   await resolveSelect[resolverName](...args);
  5479 };
  5701 };
  5480 /* harmony default export */ const forward_resolver = (forwardResolver);
  5702 /* harmony default export */ const forward_resolver = (forwardResolver);
  5481 
  5703 
  5482 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-link-suggestions.js
  5704 ;// ./node_modules/@wordpress/core-data/build-module/utils/receive-intermediate-results.js
       
  5705 const RECEIVE_INTERMEDIATE_RESULTS = Symbol('RECEIVE_INTERMEDIATE_RESULTS');
       
  5706 
       
  5707 ;// ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-link-suggestions.js
  5483 /**
  5708 /**
  5484  * WordPress dependencies
  5709  * WordPress dependencies
  5485  */
  5710  */
  5486 
  5711 
  5487 
  5712 
  5488 
  5713 
  5489 
  5714 
  5490 
  5715 /**
  5491 /**
  5716  * Fetches link suggestions from the WordPress API.
  5492  * Filters the search by type
  5717  *
  5493  *
  5718  * WordPress does not support searching multiple tables at once, e.g. posts and terms, so we
  5494  * @typedef { 'attachment' | 'post' | 'term' | 'post-format' } WPLinkSearchType
  5719  * perform multiple queries at the same time and then merge the results together.
  5495  */
  5720  *
  5496 
  5721  * @param search
  5497 /**
  5722  * @param searchOptions
  5498  * A link with an id may be of kind post-type or taxonomy
  5723  * @param editorSettings
  5499  *
       
  5500  * @typedef { 'post-type' | 'taxonomy' } WPKind
       
  5501  */
       
  5502 
       
  5503 /**
       
  5504  * @typedef WPLinkSearchOptions
       
  5505  *
       
  5506  * @property {boolean}          [isInitialSuggestions] Displays initial search suggestions, when true.
       
  5507  * @property {WPLinkSearchType} [type]                 Filters by search type.
       
  5508  * @property {string}           [subtype]              Slug of the post-type or taxonomy.
       
  5509  * @property {number}           [page]                 Which page of results to return.
       
  5510  * @property {number}           [perPage]              Search results per page.
       
  5511  */
       
  5512 
       
  5513 /**
       
  5514  * @typedef WPLinkSearchResult
       
  5515  *
       
  5516  * @property {number} id     Post or term id.
       
  5517  * @property {string} url    Link url.
       
  5518  * @property {string} title  Title of the link.
       
  5519  * @property {string} type   The taxonomy or post type slug or type URL.
       
  5520  * @property {WPKind} [kind] Link kind of post-type or taxonomy
       
  5521  */
       
  5522 
       
  5523 /**
       
  5524  * @typedef WPLinkSearchResultAugments
       
  5525  *
       
  5526  * @property {{kind: WPKind}} [meta]    Contains kind information.
       
  5527  * @property {WPKind}         [subtype] Optional subtype if it exists.
       
  5528  */
       
  5529 
       
  5530 /**
       
  5531  * @typedef {WPLinkSearchResult & WPLinkSearchResultAugments} WPLinkSearchResultAugmented
       
  5532  */
       
  5533 
       
  5534 /**
       
  5535  * @typedef WPEditorSettings
       
  5536  *
       
  5537  * @property {boolean} [ disablePostFormats ] Disables post formats, when true.
       
  5538  */
       
  5539 
       
  5540 /**
       
  5541  * Fetches link suggestions from the API.
       
  5542  *
       
  5543  * @async
       
  5544  * @param {string}              search
       
  5545  * @param {WPLinkSearchOptions} [searchOptions]
       
  5546  * @param {WPEditorSettings}    [settings]
       
  5547  *
  5724  *
  5548  * @example
  5725  * @example
  5549  * ```js
  5726  * ```js
  5550  * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
  5727  * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
  5551  *
  5728  *
  5556  * settings.__experimentalFetchLinkSuggestions = (
  5733  * settings.__experimentalFetchLinkSuggestions = (
  5557  *     search,
  5734  *     search,
  5558  *     searchOptions
  5735  *     searchOptions
  5559  * ) => fetchLinkSuggestions( search, searchOptions, settings );
  5736  * ) => fetchLinkSuggestions( search, searchOptions, settings );
  5560  * ```
  5737  * ```
  5561  * @return {Promise< WPLinkSearchResult[] >} List of search suggestions
  5738  */
  5562  */
  5739 async function fetchLinkSuggestions(search, searchOptions = {}, editorSettings = {}) {
  5563 const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) => {
  5740   const searchOptionsToUse = searchOptions.isInitialSuggestions && searchOptions.initialSuggestionsSearchOptions ? {
       
  5741     ...searchOptions,
       
  5742     ...searchOptions.initialSuggestionsSearchOptions
       
  5743   } : searchOptions;
  5564   const {
  5744   const {
  5565     isInitialSuggestions = false,
  5745     type,
  5566     initialSuggestionsSearchOptions = undefined
  5746     subtype,
  5567   } = searchOptions;
  5747     page,
       
  5748     perPage = searchOptions.isInitialSuggestions ? 3 : 20
       
  5749   } = searchOptionsToUse;
  5568   const {
  5750   const {
  5569     disablePostFormats = false
  5751     disablePostFormats = false
  5570   } = settings;
  5752   } = editorSettings;
  5571   let {
       
  5572     type = undefined,
       
  5573     subtype = undefined,
       
  5574     page = undefined,
       
  5575     perPage = isInitialSuggestions ? 3 : 20
       
  5576   } = searchOptions;
       
  5577 
       
  5578   /** @type {Promise<WPLinkSearchResult>[]} */
       
  5579   const queries = [];
  5753   const queries = [];
  5580   if (isInitialSuggestions && initialSuggestionsSearchOptions) {
       
  5581     type = initialSuggestionsSearchOptions.type || type;
       
  5582     subtype = initialSuggestionsSearchOptions.subtype || subtype;
       
  5583     page = initialSuggestionsSearchOptions.page || page;
       
  5584     perPage = initialSuggestionsSearchOptions.perPage || perPage;
       
  5585   }
       
  5586   if (!type || type === 'post') {
  5754   if (!type || type === 'post') {
  5587     queries.push(external_wp_apiFetch_default()({
  5755     queries.push(external_wp_apiFetch_default()({
  5588       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
  5756       path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/search', {
  5589         search,
  5757         search,
  5590         page,
  5758         page,
  5593         subtype
  5761         subtype
  5594       })
  5762       })
  5595     }).then(results => {
  5763     }).then(results => {
  5596       return results.map(result => {
  5764       return results.map(result => {
  5597         return {
  5765         return {
  5598           ...result,
  5766           id: result.id,
  5599           meta: {
  5767           url: result.url,
  5600             kind: 'post-type',
  5768           title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(result.title || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
  5601             subtype
  5769           type: result.subtype || result.type,
  5602           }
  5770           kind: 'post-type'
  5603         };
  5771         };
  5604       });
  5772       });
  5605     }).catch(() => []) // Fail by returning no results.
  5773     }).catch(() => []) // Fail by returning no results.
  5606     );
  5774     );
  5607   }
  5775   }
  5615         subtype
  5783         subtype
  5616       })
  5784       })
  5617     }).then(results => {
  5785     }).then(results => {
  5618       return results.map(result => {
  5786       return results.map(result => {
  5619         return {
  5787         return {
  5620           ...result,
  5788           id: result.id,
  5621           meta: {
  5789           url: result.url,
  5622             kind: 'taxonomy',
  5790           title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(result.title || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
  5623             subtype
  5791           type: result.subtype || result.type,
  5624           }
  5792           kind: 'taxonomy'
  5625         };
  5793         };
  5626       });
  5794       });
  5627     }).catch(() => []) // Fail by returning no results.
  5795     }).catch(() => []) // Fail by returning no results.
  5628     );
  5796     );
  5629   }
  5797   }
  5637         subtype
  5805         subtype
  5638       })
  5806       })
  5639     }).then(results => {
  5807     }).then(results => {
  5640       return results.map(result => {
  5808       return results.map(result => {
  5641         return {
  5809         return {
  5642           ...result,
  5810           id: result.id,
  5643           meta: {
  5811           url: result.url,
  5644             kind: 'taxonomy',
  5812           title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(result.title || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
  5645             subtype
  5813           type: result.subtype || result.type,
  5646           }
  5814           kind: 'taxonomy'
  5647         };
  5815         };
  5648       });
  5816       });
  5649     }).catch(() => []) // Fail by returning no results.
  5817     }).catch(() => []) // Fail by returning no results.
  5650     );
  5818     );
  5651   }
  5819   }
  5657         per_page: perPage
  5825         per_page: perPage
  5658       })
  5826       })
  5659     }).then(results => {
  5827     }).then(results => {
  5660       return results.map(result => {
  5828       return results.map(result => {
  5661         return {
  5829         return {
  5662           ...result,
  5830           id: result.id,
  5663           meta: {
  5831           url: result.source_url,
  5664             kind: 'media'
  5832           title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(result.title.rendered || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
  5665           }
  5833           type: result.type,
       
  5834           kind: 'media'
  5666         };
  5835         };
  5667       });
  5836       });
  5668     }).catch(() => []) // Fail by returning no results.
  5837     }).catch(() => []) // Fail by returning no results.
  5669     );
  5838     );
  5670   }
  5839   }
  5671   return Promise.all(queries).then(results => {
  5840   const responses = await Promise.all(queries);
  5672     return results.reduce(( /** @type {WPLinkSearchResult[]} */accumulator, current) => accumulator.concat(current),
  5841   let results = responses.flat();
  5673     // Flatten list.
  5842   results = results.filter(result => !!result.id);
  5674     []).filter(
  5843   results = sortResults(results, search);
  5675     /**
  5844   results = results.slice(0, perPage);
  5676      * @param {{ id: number }} result
  5845   return results;
  5677      */
  5846 }
  5678     result => {
  5847 
  5679       return !!result.id;
  5848 /**
  5680     }).slice(0, perPage).map(( /** @type {WPLinkSearchResultAugmented} */result) => {
  5849  * Sort search results by relevance to the given query.
  5681       const isMedia = result.type === 'attachment';
  5850  *
  5682       return {
  5851  * Sorting is necessary as we're querying multiple endpoints and merging the results. For example
  5683         id: result.id,
  5852  * a taxonomy title might be more relevant than a post title, but by default taxonomy results will
  5684         // @ts-ignore fix when we make this a TS file
  5853  * be ordered after all the (potentially irrelevant) post results.
  5685         url: isMedia ? result.source_url : result.url,
  5854  *
  5686         title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(isMedia ?
  5855  * We sort by scoring each result, where the score is the number of tokens in the title that are
  5687         // @ts-ignore fix when we make this a TS file
  5856  * also in the search query, divided by the total number of tokens in the title. This gives us a
  5688         result.title.rendered : result.title || '') || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
  5857  * score between 0 and 1, where 1 is a perfect match.
  5689         type: result.subtype || result.type,
  5858  *
  5690         kind: result?.meta?.kind
  5859  * @param results
  5691       };
  5860  * @param search
  5692     });
  5861  */
  5693   });
  5862 function sortResults(results, search) {
  5694 };
  5863   const searchTokens = tokenize(search);
  5695 /* harmony default export */ const _experimental_fetch_link_suggestions = (fetchLinkSuggestions);
  5864   const scores = {};
  5696 
  5865   for (const result of results) {
  5697 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-url-data.js
  5866     if (result.title) {
       
  5867       const titleTokens = tokenize(result.title);
       
  5868       const exactMatchingTokens = titleTokens.filter(titleToken => searchTokens.some(searchToken => titleToken === searchToken));
       
  5869       const subMatchingTokens = titleTokens.filter(titleToken => searchTokens.some(searchToken => titleToken !== searchToken && titleToken.includes(searchToken)));
       
  5870 
       
  5871       // The score is a combination of exact matches and sub-matches.
       
  5872       // More weight is given to exact matches, as they are more relevant (e.g. "cat" vs "caterpillar").
       
  5873       // Diving by the total number of tokens in the title normalizes the score and skews
       
  5874       // the results towards shorter titles.
       
  5875       const exactMatchScore = exactMatchingTokens.length / titleTokens.length * 10;
       
  5876       const subMatchScore = subMatchingTokens.length / titleTokens.length;
       
  5877       scores[result.id] = exactMatchScore + subMatchScore;
       
  5878     } else {
       
  5879       scores[result.id] = 0;
       
  5880     }
       
  5881   }
       
  5882   return results.sort((a, b) => scores[b.id] - scores[a.id]);
       
  5883 }
       
  5884 
       
  5885 /**
       
  5886  * Turns text into an array of tokens, with whitespace and punctuation removed.
       
  5887  *
       
  5888  * For example, `"I'm having a ball."` becomes `[ "im", "having", "a", "ball" ]`.
       
  5889  *
       
  5890  * @param text
       
  5891  */
       
  5892 function tokenize(text) {
       
  5893   // \p{L} matches any kind of letter from any language.
       
  5894   // \p{N} matches any kind of numeric character.
       
  5895   return text.toLowerCase().match(/[\p{L}\p{N}]+/gu) || [];
       
  5896 }
       
  5897 
       
  5898 ;// ./node_modules/@wordpress/core-data/build-module/fetch/__experimental-fetch-url-data.js
  5698 /**
  5899 /**
  5699  * WordPress dependencies
  5900  * WordPress dependencies
  5700  */
  5901  */
  5701 
  5902 
  5702 
  5903 
  5718  * Fetches data about a remote URL.
  5919  * Fetches data about a remote URL.
  5719  * eg: <title> tag, favicon...etc.
  5920  * eg: <title> tag, favicon...etc.
  5720  *
  5921  *
  5721  * @async
  5922  * @async
  5722  * @param {string}  url     the URL to request details from.
  5923  * @param {string}  url     the URL to request details from.
  5723  * @param {Object?} options any options to pass to the underlying fetch.
  5924  * @param {?Object} options any options to pass to the underlying fetch.
  5724  * @example
  5925  * @example
  5725  * ```js
  5926  * ```js
  5726  * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
  5927  * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
  5727  *
  5928  *
  5728  * //...
  5929  * //...
  5761     return res;
  5962     return res;
  5762   });
  5963   });
  5763 };
  5964 };
  5764 /* harmony default export */ const _experimental_fetch_url_data = (fetchUrlData);
  5965 /* harmony default export */ const _experimental_fetch_url_data = (fetchUrlData);
  5765 
  5966 
  5766 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/fetch/index.js
  5967 ;// ./node_modules/@wordpress/core-data/build-module/fetch/index.js
  5767 /**
  5968 /**
  5768  * External dependencies
  5969  * External dependencies
  5769  */
  5970  */
  5770 
  5971 
  5771 
  5972 
  5783     return [];
  5984     return [];
  5784   }
  5985   }
  5785   return restPatterns.map(pattern => Object.fromEntries(Object.entries(pattern).map(([key, value]) => [camelCase(key), value])));
  5986   return restPatterns.map(pattern => Object.fromEntries(Object.entries(pattern).map(([key, value]) => [camelCase(key), value])));
  5786 }
  5987 }
  5787 
  5988 
  5788 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/resolvers.js
  5989 ;// ./node_modules/@wordpress/core-data/build-module/resolvers.js
  5789 /**
  5990 /**
  5790  * External dependencies
  5991  * External dependencies
  5791  */
  5992  */
  5792 
  5993 
  5793 
  5994 
  5845  *                                 include with request. If requesting specific
  6046  *                                 include with request. If requesting specific
  5846  *                                 fields, fields must always include the ID.
  6047  *                                 fields, fields must always include the ID.
  5847  */
  6048  */
  5848 const resolvers_getEntityRecord = (kind, name, key = '', query) => async ({
  6049 const resolvers_getEntityRecord = (kind, name, key = '', query) => async ({
  5849   select,
  6050   select,
  5850   dispatch
  6051   dispatch,
       
  6052   registry,
       
  6053   resolveSelect
  5851 }) => {
  6054 }) => {
  5852   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  6055   const configs = await resolveSelect.getEntitiesConfig(kind);
  5853   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  6056   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  5854   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  6057   if (!entityConfig) {
  5855     return;
  6058     return;
  5856   }
  6059   }
  5857   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, key], {
  6060   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name, key], {
  5858     exclusive: false
  6061     exclusive: false
  5859   });
  6062   });
  5882       // eslint-disable-next-line @wordpress/no-unused-vars-before-return
  6085       // eslint-disable-next-line @wordpress/no-unused-vars-before-return
  5883       const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL + (key ? '/' + key : ''), {
  6086       const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL + (key ? '/' + key : ''), {
  5884         ...entityConfig.baseURLParams,
  6087         ...entityConfig.baseURLParams,
  5885         ...query
  6088         ...query
  5886       });
  6089       });
  5887       if (query !== undefined) {
  6090       if (query !== undefined && query._fields) {
  5888         query = {
  6091         query = {
  5889           ...query,
  6092           ...query,
  5890           include: [key]
  6093           include: [key]
  5891         };
  6094         };
  5892 
  6095 
  5896         const hasRecords = select.hasEntityRecords(kind, name, query);
  6099         const hasRecords = select.hasEntityRecords(kind, name, query);
  5897         if (hasRecords) {
  6100         if (hasRecords) {
  5898           return;
  6101           return;
  5899         }
  6102         }
  5900       }
  6103       }
  5901       const record = await external_wp_apiFetch_default()({
  6104       const response = await external_wp_apiFetch_default()({
  5902         path
  6105         path,
       
  6106         parse: false
  5903       });
  6107       });
  5904       dispatch.receiveEntityRecords(kind, name, record, query);
  6108       const record = await response.json();
       
  6109       const permissions = getUserPermissionsFromAllowHeader(response.headers?.get('allow'));
       
  6110       const canUserResolutionsArgs = [];
       
  6111       const receiveUserPermissionArgs = {};
       
  6112       for (const action of ALLOWED_RESOURCE_ACTIONS) {
       
  6113         receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
       
  6114           kind,
       
  6115           name,
       
  6116           id: key
       
  6117         })] = permissions[action];
       
  6118         canUserResolutionsArgs.push([action, {
       
  6119           kind,
       
  6120           name,
       
  6121           id: key
       
  6122         }]);
       
  6123       }
       
  6124       registry.batch(() => {
       
  6125         dispatch.receiveEntityRecords(kind, name, record, query);
       
  6126         dispatch.receiveUserPermissions(receiveUserPermissionArgs);
       
  6127         dispatch.finishResolutions('canUser', canUserResolutionsArgs);
       
  6128       });
  5905     }
  6129     }
  5906   } finally {
  6130   } finally {
  5907     dispatch.__unstableReleaseStoreLock(lock);
  6131     dispatch.__unstableReleaseStoreLock(lock);
  5908   }
  6132   }
  5909 };
  6133 };
  5921 /**
  6145 /**
  5922  * Requests the entity's records from the REST API.
  6146  * Requests the entity's records from the REST API.
  5923  *
  6147  *
  5924  * @param {string}  kind  Entity kind.
  6148  * @param {string}  kind  Entity kind.
  5925  * @param {string}  name  Entity name.
  6149  * @param {string}  name  Entity name.
  5926  * @param {Object?} query Query Object. If requesting specific fields, fields
  6150  * @param {?Object} query Query Object. If requesting specific fields, fields
  5927  *                        must always include the ID.
  6151  *                        must always include the ID.
  5928  */
  6152  */
  5929 const resolvers_getEntityRecords = (kind, name, query = {}) => async ({
  6153 const resolvers_getEntityRecords = (kind, name, query = {}) => async ({
  5930   dispatch,
  6154   dispatch,
  5931   registry
  6155   registry,
       
  6156   resolveSelect
  5932 }) => {
  6157 }) => {
  5933   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  6158   const configs = await resolveSelect.getEntitiesConfig(kind);
  5934   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  6159   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  5935   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  6160   if (!entityConfig) {
  5936     return;
  6161     return;
  5937   }
  6162   }
  5938   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name], {
  6163   const lock = await dispatch.__unstableAcquireStoreLock(STORE_NAME, ['entities', 'records', kind, name], {
  5939     exclusive: false
  6164     exclusive: false
  5940   });
  6165   });
       
  6166   const key = entityConfig.key || DEFAULT_ENTITY_KEY;
       
  6167   function getResolutionsArgs(records) {
       
  6168     return records.filter(record => record?.[key]).map(record => [kind, name, record[key]]);
       
  6169   }
  5941   try {
  6170   try {
  5942     if (query._fields) {
  6171     if (query._fields) {
  5943       // If requesting specific fields, items and query association to said
  6172       // If requesting specific fields, items and query association to said
  5944       // records are stored by ID reference. Thus, fields must always include
  6173       // records are stored by ID reference. Thus, fields must always include
  5945       // the ID.
  6174       // the ID.
  5950     }
  6179     }
  5951     const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL, {
  6180     const path = (0,external_wp_url_namespaceObject.addQueryArgs)(entityConfig.baseURL, {
  5952       ...entityConfig.baseURLParams,
  6181       ...entityConfig.baseURLParams,
  5953       ...query
  6182       ...query
  5954     });
  6183     });
  5955     let records, meta;
  6184     let records = [],
       
  6185       meta;
  5956     if (entityConfig.supportsPagination && query.per_page !== -1) {
  6186     if (entityConfig.supportsPagination && query.per_page !== -1) {
  5957       const response = await external_wp_apiFetch_default()({
  6187       const response = await external_wp_apiFetch_default()({
  5958         path,
  6188         path,
  5959         parse: false
  6189         parse: false
  5960       });
  6190       });
  5961       records = Object.values(await response.json());
  6191       records = Object.values(await response.json());
  5962       meta = {
  6192       meta = {
  5963         totalItems: parseInt(response.headers.get('X-WP-Total')),
  6193         totalItems: parseInt(response.headers.get('X-WP-Total')),
  5964         totalPages: parseInt(response.headers.get('X-WP-TotalPages'))
  6194         totalPages: parseInt(response.headers.get('X-WP-TotalPages'))
  5965       };
  6195       };
       
  6196     } else if (query.per_page === -1 && query[RECEIVE_INTERMEDIATE_RESULTS] === true) {
       
  6197       let page = 1;
       
  6198       let totalPages;
       
  6199       do {
       
  6200         const response = await external_wp_apiFetch_default()({
       
  6201           path: (0,external_wp_url_namespaceObject.addQueryArgs)(path, {
       
  6202             page,
       
  6203             per_page: 100
       
  6204           }),
       
  6205           parse: false
       
  6206         });
       
  6207         const pageRecords = Object.values(await response.json());
       
  6208         totalPages = parseInt(response.headers.get('X-WP-TotalPages'));
       
  6209         records.push(...pageRecords);
       
  6210         registry.batch(() => {
       
  6211           dispatch.receiveEntityRecords(kind, name, records, query);
       
  6212           dispatch.finishResolutions('getEntityRecord', getResolutionsArgs(pageRecords));
       
  6213         });
       
  6214         page++;
       
  6215       } while (page <= totalPages);
       
  6216       meta = {
       
  6217         totalItems: records.length,
       
  6218         totalPages: 1
       
  6219       };
  5966     } else {
  6220     } else {
  5967       records = Object.values(await external_wp_apiFetch_default()({
  6221       records = Object.values(await external_wp_apiFetch_default()({
  5968         path
  6222         path
  5969       }));
  6223       }));
       
  6224       meta = {
       
  6225         totalItems: records.length,
       
  6226         totalPages: 1
       
  6227       };
  5970     }
  6228     }
  5971 
  6229 
  5972     // If we request fields but the result doesn't contain the fields,
  6230     // If we request fields but the result doesn't contain the fields,
  5973     // explicitly set these fields as "undefined"
  6231     // explicitly set these fields as "undefined"
  5974     // that way we consider the query "fulfilled".
  6232     // that way we consider the query "fulfilled".
  5983       });
  6241       });
  5984     }
  6242     }
  5985     registry.batch(() => {
  6243     registry.batch(() => {
  5986       dispatch.receiveEntityRecords(kind, name, records, query, false, undefined, meta);
  6244       dispatch.receiveEntityRecords(kind, name, records, query, false, undefined, meta);
  5987 
  6245 
  5988       // When requesting all fields, the list of results can be used to
  6246       // When requesting all fields, the list of results can be used to resolve
  5989       // resolve the `getEntityRecord` selector in addition to `getEntityRecords`.
  6247       // the `getEntityRecord` and `canUser` selectors in addition to `getEntityRecords`.
  5990       // See https://github.com/WordPress/gutenberg/pull/26575
  6248       // See https://github.com/WordPress/gutenberg/pull/26575
       
  6249       // See https://github.com/WordPress/gutenberg/pull/64504
  5991       if (!query?._fields && !query.context) {
  6250       if (!query?._fields && !query.context) {
  5992         const key = entityConfig.key || DEFAULT_ENTITY_KEY;
  6251         const targetHints = records.filter(record => record?.[key]).map(record => ({
  5993         const resolutionsArgs = records.filter(record => record?.[key]).map(record => [kind, name, record[key]]);
  6252           id: record[key],
  5994         dispatch({
  6253           permissions: getUserPermissionsFromAllowHeader(record?._links?.self?.[0].targetHints.allow)
  5995           type: 'START_RESOLUTIONS',
  6254         }));
  5996           selectorName: 'getEntityRecord',
  6255         const canUserResolutionsArgs = [];
  5997           args: resolutionsArgs
  6256         const receiveUserPermissionArgs = {};
  5998         });
  6257         for (const targetHint of targetHints) {
  5999         dispatch({
  6258           for (const action of ALLOWED_RESOURCE_ACTIONS) {
  6000           type: 'FINISH_RESOLUTIONS',
  6259             canUserResolutionsArgs.push([action, {
  6001           selectorName: 'getEntityRecord',
  6260               kind,
  6002           args: resolutionsArgs
  6261               name,
  6003         });
  6262               id: targetHint.id
       
  6263             }]);
       
  6264             receiveUserPermissionArgs[getUserPermissionCacheKey(action, {
       
  6265               kind,
       
  6266               name,
       
  6267               id: targetHint.id
       
  6268             })] = targetHint.permissions[action];
       
  6269           }
       
  6270         }
       
  6271         dispatch.receiveUserPermissions(receiveUserPermissionArgs);
       
  6272         dispatch.finishResolutions('getEntityRecord', getResolutionsArgs(records));
       
  6273         dispatch.finishResolutions('canUser', canUserResolutionsArgs);
  6004       }
  6274       }
  6005       dispatch.__unstableReleaseStoreLock(lock);
  6275       dispatch.__unstableReleaseStoreLock(lock);
  6006     });
  6276     });
  6007   } catch (e) {
  6277   } catch (e) {
  6008     dispatch.__unstableReleaseStoreLock(lock);
  6278     dispatch.__unstableReleaseStoreLock(lock);
  6053 
  6323 
  6054 /**
  6324 /**
  6055  * Checks whether the current user can perform the given action on the given
  6325  * Checks whether the current user can perform the given action on the given
  6056  * REST resource.
  6326  * REST resource.
  6057  *
  6327  *
  6058  * @param {string}  requestedAction Action to check. One of: 'create', 'read', 'update',
  6328  * @param {string}        requestedAction Action to check. One of: 'create', 'read', 'update',
  6059  *                                  'delete'.
  6329  *                                        'delete'.
  6060  * @param {string}  resource        REST resource to check, e.g. 'media' or 'posts'.
  6330  * @param {string|Object} resource        Entity resource to check. Accepts entity object `{ kind: 'root', name: 'media', id: 1 }`
  6061  * @param {?string} id              ID of the rest resource to check.
  6331  *                                        or REST base as a string - `media`.
       
  6332  * @param {?string}       id              ID of the rest resource to check.
  6062  */
  6333  */
  6063 const resolvers_canUser = (requestedAction, resource, id) => async ({
  6334 const resolvers_canUser = (requestedAction, resource, id) => async ({
  6064   dispatch,
  6335   dispatch,
  6065   registry
  6336   registry,
       
  6337   resolveSelect
  6066 }) => {
  6338 }) => {
       
  6339   if (!ALLOWED_RESOURCE_ACTIONS.includes(requestedAction)) {
       
  6340     throw new Error(`'${requestedAction}' is not a valid action.`);
       
  6341   }
  6067   const {
  6342   const {
  6068     hasStartedResolution
  6343     hasStartedResolution
  6069   } = registry.select(STORE_NAME);
  6344   } = registry.select(STORE_NAME);
  6070   const resourcePath = id ? `${resource}/${id}` : resource;
       
  6071   const retrievedActions = ['create', 'read', 'update', 'delete'];
       
  6072   if (!retrievedActions.includes(requestedAction)) {
       
  6073     throw new Error(`'${requestedAction}' is not a valid action.`);
       
  6074   }
       
  6075 
  6345 
  6076   // Prevent resolving the same resource twice.
  6346   // Prevent resolving the same resource twice.
  6077   for (const relatedAction of retrievedActions) {
  6347   for (const relatedAction of ALLOWED_RESOURCE_ACTIONS) {
  6078     if (relatedAction === requestedAction) {
  6348     if (relatedAction === requestedAction) {
  6079       continue;
  6349       continue;
  6080     }
  6350     }
  6081     const isAlreadyResolving = hasStartedResolution('canUser', [relatedAction, resource, id]);
  6351     const isAlreadyResolving = hasStartedResolution('canUser', [relatedAction, resource, id]);
  6082     if (isAlreadyResolving) {
  6352     if (isAlreadyResolving) {
  6083       return;
  6353       return;
  6084     }
  6354     }
  6085   }
  6355   }
       
  6356   let resourcePath = null;
       
  6357   if (typeof resource === 'object') {
       
  6358     if (!resource.kind || !resource.name) {
       
  6359       throw new Error('The entity resource object is not valid.');
       
  6360     }
       
  6361     const configs = await resolveSelect.getEntitiesConfig(resource.kind);
       
  6362     const entityConfig = configs.find(config => config.name === resource.name && config.kind === resource.kind);
       
  6363     if (!entityConfig) {
       
  6364       return;
       
  6365     }
       
  6366     resourcePath = entityConfig.baseURL + (resource.id ? '/' + resource.id : '');
       
  6367   } else {
       
  6368     resourcePath = `/wp/v2/${resource}` + (id ? '/' + id : '');
       
  6369   }
  6086   let response;
  6370   let response;
  6087   try {
  6371   try {
  6088     response = await external_wp_apiFetch_default()({
  6372     response = await external_wp_apiFetch_default()({
  6089       path: `/wp/v2/${resourcePath}`,
  6373       path: resourcePath,
  6090       method: 'OPTIONS',
  6374       method: 'OPTIONS',
  6091       parse: false
  6375       parse: false
  6092     });
  6376     });
  6093   } catch (error) {
  6377   } catch (error) {
  6094     // Do nothing if our OPTIONS request comes back with an API error (4xx or
  6378     // Do nothing if our OPTIONS request comes back with an API error (4xx or
  6095     // 5xx). The previously determined isAllowed value will remain in the store.
  6379     // 5xx). The previously determined isAllowed value will remain in the store.
  6096     return;
  6380     return;
  6097   }
  6381   }
  6098 
  6382 
  6099   // Optional chaining operator is used here because the API requests don't
  6383   // Optional chaining operator is used here because the API requests don't
  6100   // return the expected result in the native version. Instead, API requests
  6384   // return the expected result in the React native version. Instead, API requests
  6101   // only return the result, without including response properties like the headers.
  6385   // only return the result, without including response properties like the headers.
  6102   const allowHeader = response.headers?.get('allow');
  6386   const permissions = getUserPermissionsFromAllowHeader(response.headers?.get('allow'));
  6103   const allowedMethods = allowHeader?.allow || allowHeader || '';
  6387   registry.batch(() => {
  6104   const permissions = {};
  6388     for (const action of ALLOWED_RESOURCE_ACTIONS) {
  6105   const methods = {
  6389       const key = getUserPermissionCacheKey(action, resource, id);
  6106     create: 'POST',
  6390       dispatch.receiveUserPermission(key, permissions[action]);
  6107     read: 'GET',
  6391 
  6108     update: 'PUT',
  6392       // Mark related action resolutions as finished.
  6109     delete: 'DELETE'
  6393       if (action !== requestedAction) {
  6110   };
  6394         dispatch.finishResolution('canUser', [action, resource, id]);
  6111   for (const [actionName, methodName] of Object.entries(methods)) {
  6395       }
  6112     permissions[actionName] = allowedMethods.includes(methodName);
  6396     }
  6113   }
  6397   });
  6114   for (const action of retrievedActions) {
       
  6115     dispatch.receiveUserPermission(`${action}/${resourcePath}`, permissions[action]);
       
  6116   }
       
  6117 };
  6398 };
  6118 
  6399 
  6119 /**
  6400 /**
  6120  * Checks whether the current user can perform the given action on the given
  6401  * Checks whether the current user can perform the given action on the given
  6121  * REST resource.
  6402  * REST resource.
  6122  *
  6403  *
  6123  * @param {string} kind     Entity kind.
  6404  * @param {string}        kind     Entity kind.
  6124  * @param {string} name     Entity name.
  6405  * @param {string}        name     Entity name.
  6125  * @param {string} recordId Record's id.
  6406  * @param {number|string} recordId Record's id.
  6126  */
  6407  */
  6127 const resolvers_canUserEditEntityRecord = (kind, name, recordId) => async ({
  6408 const resolvers_canUserEditEntityRecord = (kind, name, recordId) => async ({
  6128   dispatch
  6409   dispatch
  6129 }) => {
  6410 }) => {
  6130   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  6411   await dispatch(resolvers_canUser('update', {
  6131   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  6412     kind,
  6132   if (!entityConfig) {
  6413     name,
  6133     return;
  6414     id: recordId
  6134   }
  6415   }));
  6135   const resource = entityConfig.__unstable_rest_base;
       
  6136   await dispatch(resolvers_canUser('update', resource, recordId));
       
  6137 };
  6416 };
  6138 
  6417 
  6139 /**
  6418 /**
  6140  * Request autosave data from the REST API.
  6419  * Request autosave data from the REST API.
  6141  *
  6420  *
  6146   dispatch,
  6425   dispatch,
  6147   resolveSelect
  6426   resolveSelect
  6148 }) => {
  6427 }) => {
  6149   const {
  6428   const {
  6150     rest_base: restBase,
  6429     rest_base: restBase,
  6151     rest_namespace: restNamespace = 'wp/v2'
  6430     rest_namespace: restNamespace = 'wp/v2',
       
  6431     supports
  6152   } = await resolveSelect.getPostType(postType);
  6432   } = await resolveSelect.getPostType(postType);
       
  6433   if (!supports?.autosave) {
       
  6434     return;
       
  6435   }
  6153   const autosaves = await external_wp_apiFetch_default()({
  6436   const autosaves = await external_wp_apiFetch_default()({
  6154     path: `/${restNamespace}/${restBase}/${postId}/autosaves?context=edit`
  6437     path: `/${restNamespace}/${restBase}/${postId}/autosaves?context=edit`
  6155   });
  6438   });
  6156   if (autosaves && autosaves.length) {
  6439   if (autosaves && autosaves.length) {
  6157     dispatch.receiveAutosaves(postId, autosaves);
  6440     dispatch.receiveAutosaves(postId, autosaves);
  6169  */
  6452  */
  6170 const resolvers_getAutosave = (postType, postId) => async ({
  6453 const resolvers_getAutosave = (postType, postId) => async ({
  6171   resolveSelect
  6454   resolveSelect
  6172 }) => {
  6455 }) => {
  6173   await resolveSelect.getAutosaves(postType, postId);
  6456   await resolveSelect.getAutosaves(postType, postId);
  6174 };
       
  6175 
       
  6176 /**
       
  6177  * Retrieve the frontend template used for a given link.
       
  6178  *
       
  6179  * @param {string} link Link.
       
  6180  */
       
  6181 const resolvers_experimentalGetTemplateForLink = link => async ({
       
  6182   dispatch,
       
  6183   resolveSelect
       
  6184 }) => {
       
  6185   let template;
       
  6186   try {
       
  6187     // This is NOT calling a REST endpoint but rather ends up with a response from
       
  6188     // an Ajax function which has a different shape from a WP_REST_Response.
       
  6189     template = await external_wp_apiFetch_default()({
       
  6190       url: (0,external_wp_url_namespaceObject.addQueryArgs)(link, {
       
  6191         '_wp-find-template': true
       
  6192       })
       
  6193     }).then(({
       
  6194       data
       
  6195     }) => data);
       
  6196   } catch (e) {
       
  6197     // For non-FSE themes, it is possible that this request returns an error.
       
  6198   }
       
  6199   if (!template) {
       
  6200     return;
       
  6201   }
       
  6202   const record = await resolveSelect.getEntityRecord('postType', 'wp_template', template.id);
       
  6203   if (record) {
       
  6204     dispatch.receiveEntityRecords('postType', 'wp_template', [record], {
       
  6205       'find-template': link
       
  6206     });
       
  6207   }
       
  6208 };
       
  6209 resolvers_experimentalGetTemplateForLink.shouldInvalidate = action => {
       
  6210   return (action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS') && action.invalidateCache && action.kind === 'postType' && action.name === 'wp_template';
       
  6211 };
  6457 };
  6212 const resolvers_experimentalGetCurrentGlobalStylesId = () => async ({
  6458 const resolvers_experimentalGetCurrentGlobalStylesId = () => async ({
  6213   dispatch,
  6459   dispatch,
  6214   resolveSelect
  6460   resolveSelect
  6215 }) => {
  6461 }) => {
  6232 const resolvers_experimentalGetCurrentThemeBaseGlobalStyles = () => async ({
  6478 const resolvers_experimentalGetCurrentThemeBaseGlobalStyles = () => async ({
  6233   resolveSelect,
  6479   resolveSelect,
  6234   dispatch
  6480   dispatch
  6235 }) => {
  6481 }) => {
  6236   const currentTheme = await resolveSelect.getCurrentTheme();
  6482   const currentTheme = await resolveSelect.getCurrentTheme();
       
  6483   // Please adjust the preloaded requests if this changes!
  6237   const themeGlobalStyles = await external_wp_apiFetch_default()({
  6484   const themeGlobalStyles = await external_wp_apiFetch_default()({
  6238     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}`
  6485     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}?context=view`
  6239   });
  6486   });
  6240   dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
  6487   dispatch.__experimentalReceiveThemeBaseGlobalStyles(currentTheme.stylesheet, themeGlobalStyles);
  6241 };
  6488 };
  6242 const resolvers_experimentalGetCurrentThemeGlobalStylesVariations = () => async ({
  6489 const resolvers_experimentalGetCurrentThemeGlobalStylesVariations = () => async ({
  6243   resolveSelect,
  6490   resolveSelect,
  6244   dispatch
  6491   dispatch
  6245 }) => {
  6492 }) => {
  6246   const currentTheme = await resolveSelect.getCurrentTheme();
  6493   const currentTheme = await resolveSelect.getCurrentTheme();
       
  6494   // Please adjust the preloaded requests if this changes!
  6247   const variations = await external_wp_apiFetch_default()({
  6495   const variations = await external_wp_apiFetch_default()({
  6248     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}/variations`
  6496     path: `/wp/v2/global-styles/themes/${currentTheme.stylesheet}/variations?context=view`
  6249   });
  6497   });
  6250   dispatch.__experimentalReceiveThemeGlobalStyleVariations(currentTheme.stylesheet, variations);
  6498   dispatch.__experimentalReceiveThemeGlobalStyleVariations(currentTheme.stylesheet, variations);
  6251 };
  6499 };
  6252 
  6500 
  6253 /**
  6501 /**
  6310     patternCategories: mappedPatternCategories
  6558     patternCategories: mappedPatternCategories
  6311   });
  6559   });
  6312 };
  6560 };
  6313 const resolvers_getNavigationFallbackId = () => async ({
  6561 const resolvers_getNavigationFallbackId = () => async ({
  6314   dispatch,
  6562   dispatch,
  6315   select
  6563   select,
       
  6564   registry
  6316 }) => {
  6565 }) => {
  6317   const fallback = await external_wp_apiFetch_default()({
  6566   const fallback = await external_wp_apiFetch_default()({
  6318     path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp-block-editor/v1/navigation-fallback', {
  6567     path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp-block-editor/v1/navigation-fallback', {
  6319       _embed: true
  6568       _embed: true
  6320     })
  6569     })
  6321   });
  6570   });
  6322   const record = fallback?._embedded?.self;
  6571   const record = fallback?._embedded?.self;
  6323   dispatch.receiveNavigationFallbackId(fallback?.id);
  6572   registry.batch(() => {
  6324   if (record) {
  6573     dispatch.receiveNavigationFallbackId(fallback?.id);
       
  6574     if (!record) {
       
  6575       return;
       
  6576     }
       
  6577 
  6325     // If the fallback is already in the store, don't invalidate navigation queries.
  6578     // If the fallback is already in the store, don't invalidate navigation queries.
  6326     // Otherwise, invalidate the cache for the scenario where there were no Navigation
  6579     // Otherwise, invalidate the cache for the scenario where there were no Navigation
  6327     // posts in the state and the fallback created one.
  6580     // posts in the state and the fallback created one.
  6328     const existingFallbackEntityRecord = select.getEntityRecord('postType', 'wp_navigation', fallback.id);
  6581     const existingFallbackEntityRecord = select.getEntityRecord('postType', 'wp_navigation', fallback.id);
  6329     const invalidateNavigationQueries = !existingFallbackEntityRecord;
  6582     const invalidateNavigationQueries = !existingFallbackEntityRecord;
  6330     dispatch.receiveEntityRecords('postType', 'wp_navigation', record, undefined, invalidateNavigationQueries);
  6583     dispatch.receiveEntityRecords('postType', 'wp_navigation', record, undefined, invalidateNavigationQueries);
  6331 
  6584 
  6332     // Resolve to avoid further network requests.
  6585     // Resolve to avoid further network requests.
  6333     dispatch.finishResolution('getEntityRecord', ['postType', 'wp_navigation', fallback.id]);
  6586     dispatch.finishResolution('getEntityRecord', ['postType', 'wp_navigation', fallback.id]);
  6334   }
  6587   });
  6335 };
  6588 };
  6336 const resolvers_getDefaultTemplateId = query => async ({
  6589 const resolvers_getDefaultTemplateId = query => async ({
  6337   dispatch
  6590   dispatch,
       
  6591   registry,
       
  6592   resolveSelect
  6338 }) => {
  6593 }) => {
  6339   const template = await external_wp_apiFetch_default()({
  6594   const template = await external_wp_apiFetch_default()({
  6340     path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/templates/lookup', query)
  6595     path: (0,external_wp_url_namespaceObject.addQueryArgs)('/wp/v2/templates/lookup', query)
  6341   });
  6596   });
       
  6597   // Wait for the the entities config to be loaded, otherwise receiving
       
  6598   // the template as an entity will not work.
       
  6599   await resolveSelect.getEntitiesConfig('postType');
  6342   // Endpoint may return an empty object if no template is found.
  6600   // Endpoint may return an empty object if no template is found.
  6343   if (template?.id) {
  6601   if (template?.id) {
  6344     dispatch.receiveDefaultTemplateId(query, template.id);
  6602     registry.batch(() => {
       
  6603       dispatch.receiveDefaultTemplateId(query, template.id);
       
  6604       dispatch.receiveEntityRecords('postType', 'wp_template', [template]);
       
  6605       // Avoid further network requests.
       
  6606       dispatch.finishResolution('getEntityRecord', ['postType', 'wp_template', template.id]);
       
  6607     });
  6345   }
  6608   }
  6346 };
  6609 };
  6347 
  6610 
  6348 /**
  6611 /**
  6349  * Requests an entity's revisions from the REST API.
  6612  * Requests an entity's revisions from the REST API.
  6354  * @param {Object|undefined} query     Optional object of query parameters to
  6617  * @param {Object|undefined} query     Optional object of query parameters to
  6355  *                                     include with request. If requesting specific
  6618  *                                     include with request. If requesting specific
  6356  *                                     fields, fields must always include the ID.
  6619  *                                     fields, fields must always include the ID.
  6357  */
  6620  */
  6358 const resolvers_getRevisions = (kind, name, recordKey, query = {}) => async ({
  6621 const resolvers_getRevisions = (kind, name, recordKey, query = {}) => async ({
  6359   dispatch
  6622   dispatch,
       
  6623   registry,
       
  6624   resolveSelect
  6360 }) => {
  6625 }) => {
  6361   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  6626   const configs = await resolveSelect.getEntitiesConfig(kind);
  6362   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  6627   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  6363   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  6628   if (!entityConfig) {
  6364     return;
  6629     return;
  6365   }
  6630   }
  6366   if (query._fields) {
  6631   if (query._fields) {
  6367     // If requesting specific fields, items and query association to said
  6632     // If requesting specific fields, items and query association to said
  6368     // records are stored by ID reference. Thus, fields must always include
  6633     // records are stored by ID reference. Thus, fields must always include
  6404           }
  6669           }
  6405         });
  6670         });
  6406         return record;
  6671         return record;
  6407       });
  6672       });
  6408     }
  6673     }
  6409     dispatch.receiveRevisions(kind, name, recordKey, records, query, false, meta);
  6674     registry.batch(() => {
  6410 
  6675       dispatch.receiveRevisions(kind, name, recordKey, records, query, false, meta);
  6411     // When requesting all fields, the list of results can be used to
  6676 
  6412     // resolve the `getRevision` selector in addition to `getRevisions`.
  6677       // When requesting all fields, the list of results can be used to
  6413     if (!query?._fields && !query.context) {
  6678       // resolve the `getRevision` selector in addition to `getRevisions`.
  6414       const key = entityConfig.key || DEFAULT_ENTITY_KEY;
  6679       if (!query?._fields && !query.context) {
  6415       const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, recordKey, record[key]]);
  6680         const key = entityConfig.key || DEFAULT_ENTITY_KEY;
  6416       dispatch({
  6681         const resolutionsArgs = records.filter(record => record[key]).map(record => [kind, name, recordKey, record[key]]);
  6417         type: 'START_RESOLUTIONS',
  6682         dispatch.finishResolutions('getRevision', resolutionsArgs);
  6418         selectorName: 'getRevision',
  6683       }
  6419         args: resolutionsArgs
  6684     });
  6420       });
       
  6421       dispatch({
       
  6422         type: 'FINISH_RESOLUTIONS',
       
  6423         selectorName: 'getRevision',
       
  6424         args: resolutionsArgs
       
  6425       });
       
  6426     }
       
  6427   }
  6685   }
  6428 };
  6686 };
  6429 
  6687 
  6430 // Invalidate cache when a new revision is created.
  6688 // Invalidate cache when a new revision is created.
  6431 resolvers_getRevisions.shouldInvalidate = (action, kind, name, recordKey) => action.type === 'SAVE_ENTITY_RECORD_FINISH' && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
  6689 resolvers_getRevisions.shouldInvalidate = (action, kind, name, recordKey) => action.type === 'SAVE_ENTITY_RECORD_FINISH' && name === action.name && kind === action.kind && !action.error && recordKey === action.recordId;
  6440  * @param {Object|undefined} query       Optional object of query parameters to
  6698  * @param {Object|undefined} query       Optional object of query parameters to
  6441  *                                       include with request. If requesting specific
  6699  *                                       include with request. If requesting specific
  6442  *                                       fields, fields must always include the ID.
  6700  *                                       fields, fields must always include the ID.
  6443  */
  6701  */
  6444 const resolvers_getRevision = (kind, name, recordKey, revisionKey, query) => async ({
  6702 const resolvers_getRevision = (kind, name, recordKey, revisionKey, query) => async ({
  6445   dispatch
  6703   dispatch,
       
  6704   resolveSelect
  6446 }) => {
  6705 }) => {
  6447   const configs = await dispatch(getOrLoadEntitiesConfig(kind, name));
  6706   const configs = await resolveSelect.getEntitiesConfig(kind);
  6448   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  6707   const entityConfig = configs.find(config => config.name === name && config.kind === kind);
  6449   if (!entityConfig || entityConfig?.__experimentalNoFetch) {
  6708   if (!entityConfig) {
  6450     return;
  6709     return;
  6451   }
  6710   }
  6452   if (query !== undefined && query._fields) {
  6711   if (query !== undefined && query._fields) {
  6453     // If requesting specific fields, items and query association to said
  6712     // If requesting specific fields, items and query association to said
  6454     // records are stored by ID reference. Thus, fields must always include
  6713     // records are stored by ID reference. Thus, fields must always include
  6471   if (record) {
  6730   if (record) {
  6472     dispatch.receiveRevisions(kind, name, recordKey, record, query);
  6731     dispatch.receiveRevisions(kind, name, recordKey, record, query);
  6473   }
  6732   }
  6474 };
  6733 };
  6475 
  6734 
  6476 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/utils.js
  6735 /**
       
  6736  * Requests a specific post type options from the REST API.
       
  6737  *
       
  6738  * @param {string} postType Post type slug.
       
  6739  */
       
  6740 const resolvers_getRegisteredPostMeta = postType => async ({
       
  6741   dispatch,
       
  6742   resolveSelect
       
  6743 }) => {
       
  6744   let options;
       
  6745   try {
       
  6746     const {
       
  6747       rest_namespace: restNamespace = 'wp/v2',
       
  6748       rest_base: restBase
       
  6749     } = (await resolveSelect.getPostType(postType)) || {};
       
  6750     options = await external_wp_apiFetch_default()({
       
  6751       path: `${restNamespace}/${restBase}/?context=edit`,
       
  6752       method: 'OPTIONS'
       
  6753     });
       
  6754   } catch (error) {
       
  6755     // Do nothing if the request comes back with an API error.
       
  6756     return;
       
  6757   }
       
  6758   if (options) {
       
  6759     dispatch.receiveRegisteredPostMeta(postType, options?.schema?.properties?.meta?.properties);
       
  6760   }
       
  6761 };
       
  6762 
       
  6763 /**
       
  6764  * Requests entity configs for the given kind from the REST API.
       
  6765  *
       
  6766  * @param {string} kind Entity kind.
       
  6767  */
       
  6768 const resolvers_getEntitiesConfig = kind => async ({
       
  6769   dispatch
       
  6770 }) => {
       
  6771   const loader = additionalEntityConfigLoaders.find(l => l.kind === kind);
       
  6772   if (!loader) {
       
  6773     return;
       
  6774   }
       
  6775   try {
       
  6776     const configs = await loader.loadEntities();
       
  6777     if (!configs.length) {
       
  6778       return;
       
  6779     }
       
  6780     dispatch.addEntities(configs);
       
  6781   } catch {
       
  6782     // Do nothing if the request comes back with an API error.
       
  6783   }
       
  6784 };
       
  6785 
       
  6786 ;// ./node_modules/@wordpress/core-data/build-module/locks/utils.js
  6477 function deepCopyLocksTreePath(tree, path) {
  6787 function deepCopyLocksTreePath(tree, path) {
  6478   const newTree = {
  6788   const newTree = {
  6479     ...tree
  6789     ...tree
  6480   };
  6790   };
  6481   let currentNode = newTree;
  6791   let currentNode = newTree;
  6533     return true;
  6843     return true;
  6534   }
  6844   }
  6535   return false;
  6845   return false;
  6536 }
  6846 }
  6537 
  6847 
  6538 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/reducer.js
  6848 ;// ./node_modules/@wordpress/core-data/build-module/locks/reducer.js
  6539 /**
  6849 /**
  6540  * Internal dependencies
  6850  * Internal dependencies
  6541  */
  6851  */
  6542 
  6852 
  6543 const DEFAULT_STATE = {
  6853 const DEFAULT_STATE = {
  6604       }
  6914       }
  6605   }
  6915   }
  6606   return state;
  6916   return state;
  6607 }
  6917 }
  6608 
  6918 
  6609 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/selectors.js
  6919 ;// ./node_modules/@wordpress/core-data/build-module/locks/selectors.js
  6610 /**
  6920 /**
  6611  * Internal dependencies
  6921  * Internal dependencies
  6612  */
  6922  */
  6613 
  6923 
  6614 function getPendingLockRequests(state) {
  6924 function getPendingLockRequests(state) {
  6645     }
  6955     }
  6646   }
  6956   }
  6647   return true;
  6957   return true;
  6648 }
  6958 }
  6649 
  6959 
  6650 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/engine.js
  6960 ;// ./node_modules/@wordpress/core-data/build-module/locks/engine.js
  6651 /**
  6961 /**
  6652  * Internal dependencies
  6962  * Internal dependencies
  6653  */
  6963  */
  6654 
  6964 
  6655 
  6965 
  6707     acquire,
  7017     acquire,
  6708     release
  7018     release
  6709   };
  7019   };
  6710 }
  7020 }
  6711 
  7021 
  6712 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/locks/actions.js
  7022 ;// ./node_modules/@wordpress/core-data/build-module/locks/actions.js
  6713 /**
  7023 /**
  6714  * Internal dependencies
  7024  * Internal dependencies
  6715  */
  7025  */
  6716 
  7026 
  6717 function createLocksActions() {
  7027 function createLocksActions() {
  6728     __unstableAcquireStoreLock,
  7038     __unstableAcquireStoreLock,
  6729     __unstableReleaseStoreLock
  7039     __unstableReleaseStoreLock
  6730   };
  7040   };
  6731 }
  7041 }
  6732 
  7042 
  6733 ;// CONCATENATED MODULE: external ["wp","privateApis"]
  7043 ;// ./node_modules/@wordpress/core-data/build-module/dynamic-entities.js
  6734 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
  7044 /**
  6735 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/private-apis.js
  7045  * Internal dependencies
       
  7046  */
       
  7047 
       
  7048 /**
       
  7049  * A simple utility that pluralizes a string.
       
  7050  * Converts:
       
  7051  * - "post" to "posts"
       
  7052  * - "taxonomy" to "taxonomies"
       
  7053  * - "media" to "mediaItems"
       
  7054  * - "status" to "statuses"
       
  7055  *
       
  7056  * It does not pluralize "GlobalStyles" due to lack of clarity about it at time of writing.
       
  7057  */
       
  7058 
       
  7059 /**
       
  7060  * A simple utility that singularizes a string.
       
  7061  *
       
  7062  * Converts:
       
  7063  * - "posts" to "post"
       
  7064  * - "taxonomies" to "taxonomy"
       
  7065  * - "mediaItems" to "media"
       
  7066  * - "statuses" to "status"
       
  7067  */
       
  7068 
       
  7069 let dynamicActions;
       
  7070 let dynamicSelectors;
       
  7071 
       
  7072 ;// external ["wp","element"]
       
  7073 const external_wp_element_namespaceObject = window["wp"]["element"];
       
  7074 ;// ./node_modules/@wordpress/core-data/build-module/entity-context.js
  6736 /**
  7075 /**
  6737  * WordPress dependencies
  7076  * WordPress dependencies
  6738  */
  7077  */
  6739 
  7078 
  6740 const {
  7079 const EntityContext = (0,external_wp_element_namespaceObject.createContext)({});
  6741   lock,
  7080 
  6742   unlock
  7081 ;// external "ReactJSXRuntime"
  6743 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/core-data');
  7082 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
  6744 
  7083 ;// ./node_modules/@wordpress/core-data/build-module/entity-provider.js
  6745 ;// CONCATENATED MODULE: external ["wp","element"]
       
  6746 const external_wp_element_namespaceObject = window["wp"]["element"];
       
  6747 ;// CONCATENATED MODULE: external ["wp","blocks"]
       
  6748 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
       
  6749 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
       
  6750 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
       
  6751 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/footnotes/get-rich-text-values-cached.js
       
  6752 /**
  7084 /**
  6753  * WordPress dependencies
  7085  * WordPress dependencies
  6754  */
  7086  */
  6755 
  7087 
  6756 
  7088 
  6757 /**
  7089 /**
  6758  * Internal dependencies
  7090  * Internal dependencies
  6759  */
  7091  */
  6760 
  7092 
  6761 
       
  6762 // TODO: The following line should have been:
       
  6763 //
       
  6764 //   const unlockedApis = unlock( blockEditorPrivateApis );
       
  6765 //
       
  6766 // But there are hidden circular dependencies in RNMobile code, specifically in
       
  6767 // certain native components in the `components` package that depend on
       
  6768 // `block-editor`. What follows is a workaround that defers the `unlock` call
       
  6769 // to prevent native code from failing.
       
  6770 //
       
  6771 // Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.
       
  6772 let unlockedApis;
       
  6773 const cache = new WeakMap();
       
  6774 function getRichTextValuesCached(block) {
       
  6775   if (!unlockedApis) {
       
  6776     unlockedApis = unlock(external_wp_blockEditor_namespaceObject.privateApis);
       
  6777   }
       
  6778   if (!cache.has(block)) {
       
  6779     const values = unlockedApis.getRichTextValues([block]);
       
  6780     cache.set(block, values);
       
  6781   }
       
  6782   return cache.get(block);
       
  6783 }
       
  6784 
       
  6785 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/footnotes/get-footnotes-order.js
       
  6786 /**
       
  6787  * Internal dependencies
       
  6788  */
       
  6789 
       
  6790 const get_footnotes_order_cache = new WeakMap();
       
  6791 function getBlockFootnotesOrder(block) {
       
  6792   if (!get_footnotes_order_cache.has(block)) {
       
  6793     const order = [];
       
  6794     for (const value of getRichTextValuesCached(block)) {
       
  6795       if (!value) {
       
  6796         continue;
       
  6797       }
       
  6798 
       
  6799       // replacements is a sparse array, use forEach to skip empty slots.
       
  6800       value.replacements.forEach(({
       
  6801         type,
       
  6802         attributes
       
  6803       }) => {
       
  6804         if (type === 'core/footnote') {
       
  6805           order.push(attributes['data-fn']);
       
  6806         }
       
  6807       });
       
  6808     }
       
  6809     get_footnotes_order_cache.set(block, order);
       
  6810   }
       
  6811   return get_footnotes_order_cache.get(block);
       
  6812 }
       
  6813 function getFootnotesOrder(blocks) {
       
  6814   // We can only separate getting order from blocks at the root level. For
       
  6815   // deeper inner blocks, this will not work since it's possible to have both
       
  6816   // inner blocks and block attributes, so order needs to be computed from the
       
  6817   // Edit functions as a whole.
       
  6818   return blocks.flatMap(getBlockFootnotesOrder);
       
  6819 }
       
  6820 
       
  6821 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/footnotes/index.js
       
  6822 /**
       
  6823  * WordPress dependencies
       
  6824  */
       
  6825 
       
  6826 
       
  6827 /**
       
  6828  * Internal dependencies
       
  6829  */
       
  6830 
       
  6831 let oldFootnotes = {};
       
  6832 function updateFootnotesFromMeta(blocks, meta) {
       
  6833   const output = {
       
  6834     blocks
       
  6835   };
       
  6836   if (!meta) {
       
  6837     return output;
       
  6838   }
       
  6839 
       
  6840   // If meta.footnotes is empty, it means the meta is not registered.
       
  6841   if (meta.footnotes === undefined) {
       
  6842     return output;
       
  6843   }
       
  6844   const newOrder = getFootnotesOrder(blocks);
       
  6845   const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
       
  6846   const currentOrder = footnotes.map(fn => fn.id);
       
  6847   if (currentOrder.join('') === newOrder.join('')) {
       
  6848     return output;
       
  6849   }
       
  6850   const newFootnotes = newOrder.map(fnId => footnotes.find(fn => fn.id === fnId) || oldFootnotes[fnId] || {
       
  6851     id: fnId,
       
  6852     content: ''
       
  6853   });
       
  6854   function updateAttributes(attributes) {
       
  6855     // Only attempt to update attributes, if attributes is an object.
       
  6856     if (!attributes || Array.isArray(attributes) || typeof attributes !== 'object') {
       
  6857       return attributes;
       
  6858     }
       
  6859     attributes = {
       
  6860       ...attributes
       
  6861     };
       
  6862     for (const key in attributes) {
       
  6863       const value = attributes[key];
       
  6864       if (Array.isArray(value)) {
       
  6865         attributes[key] = value.map(updateAttributes);
       
  6866         continue;
       
  6867       }
       
  6868 
       
  6869       // To do, remove support for string values?
       
  6870       if (typeof value !== 'string' && !(value instanceof external_wp_richText_namespaceObject.RichTextData)) {
       
  6871         continue;
       
  6872       }
       
  6873       const richTextValue = typeof value === 'string' ? external_wp_richText_namespaceObject.RichTextData.fromHTMLString(value) : new external_wp_richText_namespaceObject.RichTextData(value);
       
  6874       richTextValue.replacements.forEach(replacement => {
       
  6875         if (replacement.type === 'core/footnote') {
       
  6876           const id = replacement.attributes['data-fn'];
       
  6877           const index = newOrder.indexOf(id);
       
  6878           // The innerHTML contains the count wrapped in a link.
       
  6879           const countValue = (0,external_wp_richText_namespaceObject.create)({
       
  6880             html: replacement.innerHTML
       
  6881           });
       
  6882           countValue.text = String(index + 1);
       
  6883           countValue.formats = Array.from({
       
  6884             length: countValue.text.length
       
  6885           }, () => countValue.formats[0]);
       
  6886           countValue.replacements = Array.from({
       
  6887             length: countValue.text.length
       
  6888           }, () => countValue.replacements[0]);
       
  6889           replacement.innerHTML = (0,external_wp_richText_namespaceObject.toHTMLString)({
       
  6890             value: countValue
       
  6891           });
       
  6892         }
       
  6893       });
       
  6894       attributes[key] = typeof value === 'string' ? richTextValue.toHTMLString() : richTextValue;
       
  6895     }
       
  6896     return attributes;
       
  6897   }
       
  6898   function updateBlocksAttributes(__blocks) {
       
  6899     return __blocks.map(block => {
       
  6900       return {
       
  6901         ...block,
       
  6902         attributes: updateAttributes(block.attributes),
       
  6903         innerBlocks: updateBlocksAttributes(block.innerBlocks)
       
  6904       };
       
  6905     });
       
  6906   }
       
  6907 
       
  6908   // We need to go through all block attributes deeply and update the
       
  6909   // footnote anchor numbering (textContent) to match the new order.
       
  6910   const newBlocks = updateBlocksAttributes(blocks);
       
  6911   oldFootnotes = {
       
  6912     ...oldFootnotes,
       
  6913     ...footnotes.reduce((acc, fn) => {
       
  6914       if (!newOrder.includes(fn.id)) {
       
  6915         acc[fn.id] = fn;
       
  6916       }
       
  6917       return acc;
       
  6918     }, {})
       
  6919   };
       
  6920   return {
       
  6921     meta: {
       
  6922       ...meta,
       
  6923       footnotes: JSON.stringify(newFootnotes)
       
  6924     },
       
  6925     blocks: newBlocks
       
  6926   };
       
  6927 }
       
  6928 
       
  6929 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
       
  6930 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
       
  6931 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/entity-provider.js
       
  6932 /**
       
  6933  * WordPress dependencies
       
  6934  */
       
  6935 
       
  6936 
       
  6937 
       
  6938 
       
  6939 /**
       
  6940  * Internal dependencies
       
  6941  */
       
  6942 
       
  6943 
       
  6944 
       
  6945 /** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */
       
  6946 
       
  6947 const EMPTY_ARRAY = [];
       
  6948 const EntityContext = (0,external_wp_element_namespaceObject.createContext)({});
       
  6949 
  7093 
  6950 /**
  7094 /**
  6951  * Context provider component for providing
  7095  * Context provider component for providing
  6952  * an entity for a specific entity.
  7096  * an entity for a specific entity.
  6953  *
  7097  *
  6958  * @param {*}      props.children The children to wrap.
  7102  * @param {*}      props.children The children to wrap.
  6959  *
  7103  *
  6960  * @return {Object} The provided children, wrapped with
  7104  * @return {Object} The provided children, wrapped with
  6961  *                   the entity's context provider.
  7105  *                   the entity's context provider.
  6962  */
  7106  */
       
  7107 
  6963 function EntityProvider({
  7108 function EntityProvider({
  6964   kind,
  7109   kind,
  6965   type: name,
  7110   type: name,
  6966   id,
  7111   id,
  6967   children
  7112   children
  6978     value: childContext,
  7123     value: childContext,
  6979     children: children
  7124     children: children
  6980   });
  7125   });
  6981 }
  7126 }
  6982 
  7127 
  6983 /**
  7128 ;// ./node_modules/memize/dist/index.js
  6984  * Hook that returns the ID for the nearest
       
  6985  * provided entity of the specified type.
       
  6986  *
       
  6987  * @param {string} kind The entity kind.
       
  6988  * @param {string} name The entity name.
       
  6989  */
       
  6990 function useEntityId(kind, name) {
       
  6991   const context = (0,external_wp_element_namespaceObject.useContext)(EntityContext);
       
  6992   return context?.[kind]?.[name];
       
  6993 }
       
  6994 
       
  6995 /**
       
  6996  * Hook that returns the value and a setter for the
       
  6997  * specified property of the nearest provided
       
  6998  * entity of the specified type.
       
  6999  *
       
  7000  * @param {string} kind  The entity kind.
       
  7001  * @param {string} name  The entity name.
       
  7002  * @param {string} prop  The property name.
       
  7003  * @param {string} [_id] An entity ID to use instead of the context-provided one.
       
  7004  *
       
  7005  * @return {[*, Function, *]} An array where the first item is the
       
  7006  *                            property value, the second is the
       
  7007  *                            setter and the third is the full value
       
  7008  * 							  object from REST API containing more
       
  7009  * 							  information like `raw`, `rendered` and
       
  7010  * 							  `protected` props.
       
  7011  */
       
  7012 function useEntityProp(kind, name, prop, _id) {
       
  7013   const providerId = useEntityId(kind, name);
       
  7014   const id = _id !== null && _id !== void 0 ? _id : providerId;
       
  7015   const {
       
  7016     value,
       
  7017     fullValue
       
  7018   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  7019     const {
       
  7020       getEntityRecord,
       
  7021       getEditedEntityRecord
       
  7022     } = select(STORE_NAME);
       
  7023     const record = getEntityRecord(kind, name, id); // Trigger resolver.
       
  7024     const editedRecord = getEditedEntityRecord(kind, name, id);
       
  7025     return record && editedRecord ? {
       
  7026       value: editedRecord[prop],
       
  7027       fullValue: record[prop]
       
  7028     } : {};
       
  7029   }, [kind, name, id, prop]);
       
  7030   const {
       
  7031     editEntityRecord
       
  7032   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
       
  7033   const setValue = (0,external_wp_element_namespaceObject.useCallback)(newValue => {
       
  7034     editEntityRecord(kind, name, id, {
       
  7035       [prop]: newValue
       
  7036     });
       
  7037   }, [editEntityRecord, kind, name, id, prop]);
       
  7038   return [value, setValue, fullValue];
       
  7039 }
       
  7040 const parsedBlocksCache = new WeakMap();
       
  7041 
       
  7042 /**
       
  7043  * Hook that returns block content getters and setters for
       
  7044  * the nearest provided entity of the specified type.
       
  7045  *
       
  7046  * The return value has the shape `[ blocks, onInput, onChange ]`.
       
  7047  * `onInput` is for block changes that don't create undo levels
       
  7048  * or dirty the post, non-persistent changes, and `onChange` is for
       
  7049  * persistent changes. They map directly to the props of a
       
  7050  * `BlockEditorProvider` and are intended to be used with it,
       
  7051  * or similar components or hooks.
       
  7052  *
       
  7053  * @param {string} kind         The entity kind.
       
  7054  * @param {string} name         The entity name.
       
  7055  * @param {Object} options
       
  7056  * @param {string} [options.id] An entity ID to use instead of the context-provided one.
       
  7057  *
       
  7058  * @return {[WPBlock[], Function, Function]} The block array and setters.
       
  7059  */
       
  7060 function useEntityBlockEditor(kind, name, {
       
  7061   id: _id
       
  7062 } = {}) {
       
  7063   const providerId = useEntityId(kind, name);
       
  7064   const id = _id !== null && _id !== void 0 ? _id : providerId;
       
  7065   const {
       
  7066     getEntityRecord,
       
  7067     getEntityRecordEdits
       
  7068   } = (0,external_wp_data_namespaceObject.useSelect)(STORE_NAME);
       
  7069   const {
       
  7070     content,
       
  7071     editedBlocks,
       
  7072     meta
       
  7073   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  7074     if (!id) {
       
  7075       return {};
       
  7076     }
       
  7077     const {
       
  7078       getEditedEntityRecord
       
  7079     } = select(STORE_NAME);
       
  7080     const editedRecord = getEditedEntityRecord(kind, name, id);
       
  7081     return {
       
  7082       editedBlocks: editedRecord.blocks,
       
  7083       content: editedRecord.content,
       
  7084       meta: editedRecord.meta
       
  7085     };
       
  7086   }, [kind, name, id]);
       
  7087   const {
       
  7088     __unstableCreateUndoLevel,
       
  7089     editEntityRecord
       
  7090   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
       
  7091   const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
       
  7092     if (!id) {
       
  7093       return undefined;
       
  7094     }
       
  7095     if (editedBlocks) {
       
  7096       return editedBlocks;
       
  7097     }
       
  7098     if (!content || typeof content !== 'string') {
       
  7099       return EMPTY_ARRAY;
       
  7100     }
       
  7101 
       
  7102     // If there's an edit, cache the parsed blocks by the edit.
       
  7103     // If not, cache by the original enity record.
       
  7104     const edits = getEntityRecordEdits(kind, name, id);
       
  7105     const isUnedited = !edits || !Object.keys(edits).length;
       
  7106     const cackeKey = isUnedited ? getEntityRecord(kind, name, id) : edits;
       
  7107     let _blocks = parsedBlocksCache.get(cackeKey);
       
  7108     if (!_blocks) {
       
  7109       _blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
       
  7110       parsedBlocksCache.set(cackeKey, _blocks);
       
  7111     }
       
  7112     return _blocks;
       
  7113   }, [kind, name, id, editedBlocks, content, getEntityRecord, getEntityRecordEdits]);
       
  7114   const updateFootnotes = (0,external_wp_element_namespaceObject.useCallback)(_blocks => updateFootnotesFromMeta(_blocks, meta), [meta]);
       
  7115   const onChange = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
       
  7116     const noChange = blocks === newBlocks;
       
  7117     if (noChange) {
       
  7118       return __unstableCreateUndoLevel(kind, name, id);
       
  7119     }
       
  7120     const {
       
  7121       selection,
       
  7122       ...rest
       
  7123     } = options;
       
  7124 
       
  7125     // We create a new function here on every persistent edit
       
  7126     // to make sure the edit makes the post dirty and creates
       
  7127     // a new undo level.
       
  7128     const edits = {
       
  7129       selection,
       
  7130       content: ({
       
  7131         blocks: blocksForSerialization = []
       
  7132       }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization),
       
  7133       ...updateFootnotes(newBlocks)
       
  7134     };
       
  7135     editEntityRecord(kind, name, id, edits, {
       
  7136       isCached: false,
       
  7137       ...rest
       
  7138     });
       
  7139   }, [kind, name, id, blocks, updateFootnotes, __unstableCreateUndoLevel, editEntityRecord]);
       
  7140   const onInput = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
       
  7141     const {
       
  7142       selection,
       
  7143       ...rest
       
  7144     } = options;
       
  7145     const footnotesChanges = updateFootnotes(newBlocks);
       
  7146     const edits = {
       
  7147       selection,
       
  7148       ...footnotesChanges
       
  7149     };
       
  7150     editEntityRecord(kind, name, id, edits, {
       
  7151       isCached: true,
       
  7152       ...rest
       
  7153     });
       
  7154   }, [kind, name, id, updateFootnotes, editEntityRecord]);
       
  7155   return [blocks, onInput, onChange];
       
  7156 }
       
  7157 
       
  7158 ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
       
  7159 /**
  7129 /**
  7160  * Memize options object.
  7130  * Memize options object.
  7161  *
  7131  *
  7162  * @typedef MemizeOptions
  7132  * @typedef MemizeOptions
  7163  *
  7133  *
  7315 	return memoized;
  7285 	return memoized;
  7316 }
  7286 }
  7317 
  7287 
  7318 
  7288 
  7319 
  7289 
  7320 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/memoize.js
  7290 ;// ./node_modules/@wordpress/core-data/build-module/hooks/memoize.js
  7321 /**
  7291 /**
  7322  * External dependencies
  7292  * External dependencies
  7323  */
  7293  */
  7324 
  7294 
  7325 
  7295 
  7326 // re-export due to restrictive esModuleInterop setting
  7296 // re-export due to restrictive esModuleInterop setting
  7327 /* harmony default export */ const memoize = (memize);
  7297 /* harmony default export */ const memoize = (memize);
  7328 
  7298 
  7329 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/constants.js
  7299 ;// ./node_modules/@wordpress/core-data/build-module/hooks/constants.js
  7330 let Status = /*#__PURE__*/function (Status) {
  7300 let Status = /*#__PURE__*/function (Status) {
  7331   Status["Idle"] = "IDLE";
  7301   Status["Idle"] = "IDLE";
  7332   Status["Resolving"] = "RESOLVING";
  7302   Status["Resolving"] = "RESOLVING";
  7333   Status["Error"] = "ERROR";
  7303   Status["Error"] = "ERROR";
  7334   Status["Success"] = "SUCCESS";
  7304   Status["Success"] = "SUCCESS";
  7335   return Status;
  7305   return Status;
  7336 }({});
  7306 }({});
  7337 
  7307 
  7338 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-query-select.js
  7308 ;// ./node_modules/@wordpress/core-data/build-module/hooks/use-query-select.js
  7339 /**
  7309 /**
  7340  * WordPress dependencies
  7310  * WordPress dependencies
  7341  */
  7311  */
  7342 
  7312 
  7343 
  7313 
  7439     });
  7409     });
  7440   }
  7410   }
  7441   return resolvers;
  7411   return resolvers;
  7442 });
  7412 });
  7443 
  7413 
  7444 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-record.js
  7414 ;// ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-record.js
  7445 /**
  7415 /**
  7446  * WordPress dependencies
  7416  * WordPress dependencies
  7447  */
  7417  */
  7448 
  7418 
  7449 
  7419 
  7522  * 	}
  7492  * 	}
  7523  *
  7493  *
  7524  * 	return (
  7494  * 	return (
  7525  * 		<form onSubmit={ onRename }>
  7495  * 		<form onSubmit={ onRename }>
  7526  * 			<TextControl
  7496  * 			<TextControl
       
  7497  *				__nextHasNoMarginBottom
       
  7498  *				__next40pxDefaultSize
  7527  * 				label={ __( 'Name' ) }
  7499  * 				label={ __( 'Name' ) }
  7528  * 				value={ page.editedRecord.title }
  7500  * 				value={ page.editedRecord.title }
  7529  * 				onChange={ setTitle }
  7501  * 				onChange={ setTitle }
  7530  * 			/>
  7502  * 			/>
  7531  * 			<button type="submit">{ __( 'Save' ) }</button>
  7503  * 			<button type="submit">{ __( 'Save' ) }</button>
  7602     since: '6.1'
  7574     since: '6.1'
  7603   });
  7575   });
  7604   return useEntityRecord(kind, name, recordId, options);
  7576   return useEntityRecord(kind, name, recordId, options);
  7605 }
  7577 }
  7606 
  7578 
  7607 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-records.js
  7579 ;// ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-records.js
  7608 /**
  7580 /**
  7609  * WordPress dependencies
  7581  * WordPress dependencies
  7610  */
  7582  */
  7611 
  7583 
  7612 
  7584 
  7613 
  7585 
  7614 
  7586 
       
  7587 
  7615 /**
  7588 /**
  7616  * Internal dependencies
  7589  * Internal dependencies
  7617  */
  7590  */
  7618 
  7591 
  7619 
  7592 
  7620 const use_entity_records_EMPTY_ARRAY = [];
  7593 
       
  7594 const EMPTY_ARRAY = [];
  7621 
  7595 
  7622 /**
  7596 /**
  7623  * Resolves the specified entity records.
  7597  * Resolves the specified entity records.
  7624  *
  7598  *
  7625  * @since 6.1.0 Introduced in WordPress core.
  7599  * @since 6.1.0 Introduced in WordPress core.
  7672     ...rest
  7646     ...rest
  7673   } = useQuerySelect(query => {
  7647   } = useQuerySelect(query => {
  7674     if (!options.enabled) {
  7648     if (!options.enabled) {
  7675       return {
  7649       return {
  7676         // Avoiding returning a new reference on every execution.
  7650         // Avoiding returning a new reference on every execution.
  7677         data: use_entity_records_EMPTY_ARRAY
  7651         data: EMPTY_ARRAY
  7678       };
  7652       };
  7679     }
  7653     }
  7680     return query(store).getEntityRecords(kind, name, queryArgs);
  7654     return query(store).getEntityRecords(kind, name, queryArgs);
  7681   }, [kind, name, queryAsString, options.enabled]);
  7655   }, [kind, name, queryAsString, options.enabled]);
  7682   const {
  7656   const {
  7706     alternative: 'wp.data.useEntityRecords',
  7680     alternative: 'wp.data.useEntityRecords',
  7707     since: '6.1'
  7681     since: '6.1'
  7708   });
  7682   });
  7709   return useEntityRecords(kind, name, queryArgs, options);
  7683   return useEntityRecords(kind, name, queryArgs, options);
  7710 }
  7684 }
  7711 
  7685 function useEntityRecordsWithPermissions(kind, name, queryArgs = {}, options = {
  7712 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/use-resource-permissions.js
  7686   enabled: true
       
  7687 }) {
       
  7688   const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getEntityConfig(kind, name), [kind, name]);
       
  7689   const {
       
  7690     records: data,
       
  7691     ...ret
       
  7692   } = useEntityRecords(kind, name, queryArgs, options);
       
  7693   const ids = (0,external_wp_element_namespaceObject.useMemo)(() => {
       
  7694     var _data$map;
       
  7695     return (_data$map = data?.map(
       
  7696     // @ts-ignore
       
  7697     record => {
       
  7698       var _entityConfig$key;
       
  7699       return record[(_entityConfig$key = entityConfig?.key) !== null && _entityConfig$key !== void 0 ? _entityConfig$key : 'id'];
       
  7700     })) !== null && _data$map !== void 0 ? _data$map : [];
       
  7701   }, [data, entityConfig?.key]);
       
  7702   const permissions = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  7703     const {
       
  7704       getEntityRecordsPermissions
       
  7705     } = unlock(select(store));
       
  7706     return getEntityRecordsPermissions(kind, name, ids);
       
  7707   }, [ids, kind, name]);
       
  7708   const dataWithPermissions = (0,external_wp_element_namespaceObject.useMemo)(() => {
       
  7709     var _data$map2;
       
  7710     return (_data$map2 = data?.map((record, index) => ({
       
  7711       // @ts-ignore
       
  7712       ...record,
       
  7713       permissions: permissions[index]
       
  7714     }))) !== null && _data$map2 !== void 0 ? _data$map2 : [];
       
  7715   }, [data, permissions]);
       
  7716   return {
       
  7717     records: dataWithPermissions,
       
  7718     ...ret
       
  7719   };
       
  7720 }
       
  7721 
       
  7722 ;// external ["wp","warning"]
       
  7723 const external_wp_warning_namespaceObject = window["wp"]["warning"];
       
  7724 var external_wp_warning_default = /*#__PURE__*/__webpack_require__.n(external_wp_warning_namespaceObject);
       
  7725 ;// ./node_modules/@wordpress/core-data/build-module/hooks/use-resource-permissions.js
  7713 /**
  7726 /**
  7714  * WordPress dependencies
  7727  * WordPress dependencies
  7715  */
  7728  */
  7716 
  7729 
  7717 
  7730 
       
  7731 
  7718 /**
  7732 /**
  7719  * Internal dependencies
  7733  * Internal dependencies
  7720  */
  7734  */
  7721 
  7735 
  7722 
  7736 
  7729 /**
  7743 /**
  7730  * Resolves resource permissions.
  7744  * Resolves resource permissions.
  7731  *
  7745  *
  7732  * @since 6.1.0 Introduced in WordPress core.
  7746  * @since 6.1.0 Introduced in WordPress core.
  7733  *
  7747  *
  7734  * @param    resource The resource in question, e.g. media.
  7748  * @param    resource Entity resource to check. Accepts entity object `{ kind: 'root', name: 'media', id: 1 }`
  7735  * @param    id       ID of a specific resource entry, if needed, e.g. 10.
  7749  *                    or REST base as a string - `media`.
       
  7750  * @param    id       Optional ID of the resource to check, e.g. 10. Note: This argument is discouraged
       
  7751  *                    when using an entity object as a resource to check permissions and will be ignored.
  7736  *
  7752  *
  7737  * @example
  7753  * @example
  7738  * ```js
  7754  * ```js
  7739  * import { useResourcePermissions } from '@wordpress/core-data';
  7755  * import { useResourcePermissions } from '@wordpress/core-data';
  7740  *
  7756  *
  7741  * function PagesList() {
  7757  * function PagesList() {
  7742  *   const { canCreate, isResolving } = useResourcePermissions( 'pages' );
  7758  *   const { canCreate, isResolving } = useResourcePermissions( { kind: 'postType', name: 'page' } );
  7743  *
  7759  *
  7744  *   if ( isResolving ) {
  7760  *   if ( isResolving ) {
  7745  *     return 'Loading ...';
  7761  *     return 'Loading ...';
  7746  *   }
  7762  *   }
  7747  *
  7763  *
  7765  *   const {
  7781  *   const {
  7766  *     canCreate,
  7782  *     canCreate,
  7767  *     canUpdate,
  7783  *     canUpdate,
  7768  *     canDelete,
  7784  *     canDelete,
  7769  *     isResolving
  7785  *     isResolving
  7770  *   } = useResourcePermissions( 'pages', pageId );
  7786  *   } = useResourcePermissions( { kind: 'postType', name: 'page', id: pageId } );
  7771  *
  7787  *
  7772  *   if ( isResolving ) {
  7788  *   if ( isResolving ) {
  7773  *     return 'Loading ...';
  7789  *     return 'Loading ...';
  7774  *   }
  7790  *   }
  7775  *
  7791  *
  7793  *
  7809  *
  7794  * @return Entity records data.
  7810  * @return Entity records data.
  7795  * @template IdType
  7811  * @template IdType
  7796  */
  7812  */
  7797 function useResourcePermissions(resource, id) {
  7813 function useResourcePermissions(resource, id) {
       
  7814   // Serialize `resource` to a string that can be safely used as a React dep.
       
  7815   // We can't just pass `resource` as one of the deps, because if it is passed
       
  7816   // as an object literal, then it will be a different object on each call even
       
  7817   // if the values remain the same.
       
  7818   const isEntity = typeof resource === 'object';
       
  7819   const resourceAsString = isEntity ? JSON.stringify(resource) : resource;
       
  7820   if (isEntity && typeof id !== 'undefined') {
       
  7821      true ? external_wp_warning_default()(`When 'resource' is an entity object, passing 'id' as a separate argument isn't supported.`) : 0;
       
  7822   }
  7798   return useQuerySelect(resolve => {
  7823   return useQuerySelect(resolve => {
       
  7824     const hasId = isEntity ? !!resource.id : !!id;
  7799     const {
  7825     const {
  7800       canUser
  7826       canUser
  7801     } = resolve(store);
  7827     } = resolve(store);
  7802     const create = canUser('create', resource);
  7828     const create = canUser('create', isEntity ? {
  7803     if (!id) {
  7829       kind: resource.kind,
       
  7830       name: resource.name
       
  7831     } : resource);
       
  7832     if (!hasId) {
  7804       const read = canUser('read', resource);
  7833       const read = canUser('read', resource);
  7805       const isResolving = create.isResolving || read.isResolving;
  7834       const isResolving = create.isResolving || read.isResolving;
  7806       const hasResolved = create.hasResolved && read.hasResolved;
  7835       const hasResolved = create.hasResolved && read.hasResolved;
  7807       let status = Status.Idle;
  7836       let status = Status.Idle;
  7808       if (isResolving) {
  7837       if (isResolving) {
  7836       canRead: hasResolved && read.data,
  7865       canRead: hasResolved && read.data,
  7837       canCreate: hasResolved && create.data,
  7866       canCreate: hasResolved && create.data,
  7838       canUpdate: hasResolved && update.data,
  7867       canUpdate: hasResolved && update.data,
  7839       canDelete: hasResolved && _delete.data
  7868       canDelete: hasResolved && _delete.data
  7840     };
  7869     };
  7841   }, [resource, id]);
  7870   }, [resourceAsString, id]);
  7842 }
  7871 }
       
  7872 /* harmony default export */ const use_resource_permissions = (useResourcePermissions);
  7843 function __experimentalUseResourcePermissions(resource, id) {
  7873 function __experimentalUseResourcePermissions(resource, id) {
  7844   external_wp_deprecated_default()(`wp.data.__experimentalUseResourcePermissions`, {
  7874   external_wp_deprecated_default()(`wp.data.__experimentalUseResourcePermissions`, {
  7845     alternative: 'wp.data.useResourcePermissions',
  7875     alternative: 'wp.data.useResourcePermissions',
  7846     since: '6.1'
  7876     since: '6.1'
  7847   });
  7877   });
  7848   return useResourcePermissions(resource, id);
  7878   return useResourcePermissions(resource, id);
  7849 }
  7879 }
  7850 
  7880 
  7851 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/hooks/index.js
  7881 ;// external ["wp","blocks"]
  7852 
  7882 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
  7853 
  7883 ;// ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-id.js
  7854 
       
  7855 
       
  7856 ;// CONCATENATED MODULE: ./node_modules/@wordpress/core-data/build-module/index.js
       
  7857 /**
  7884 /**
  7858  * WordPress dependencies
  7885  * WordPress dependencies
  7859  */
  7886  */
  7860 
  7887 
  7861 
  7888 
  7862 /**
  7889 /**
  7863  * Internal dependencies
  7890  * Internal dependencies
  7864  */
  7891  */
       
  7892 
       
  7893 
       
  7894 /**
       
  7895  * Hook that returns the ID for the nearest
       
  7896  * provided entity of the specified type.
       
  7897  *
       
  7898  * @param {string} kind The entity kind.
       
  7899  * @param {string} name The entity name.
       
  7900  */
       
  7901 function useEntityId(kind, name) {
       
  7902   const context = (0,external_wp_element_namespaceObject.useContext)(EntityContext);
       
  7903   return context?.[kind]?.[name];
       
  7904 }
       
  7905 
       
  7906 ;// external ["wp","blockEditor"]
       
  7907 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
       
  7908 ;// ./node_modules/@wordpress/core-data/build-module/footnotes/get-rich-text-values-cached.js
       
  7909 /**
       
  7910  * WordPress dependencies
       
  7911  */
       
  7912 
       
  7913 
       
  7914 /**
       
  7915  * Internal dependencies
       
  7916  */
       
  7917 
       
  7918 
       
  7919 // TODO: The following line should have been:
       
  7920 //
       
  7921 //   const unlockedApis = unlock( blockEditorPrivateApis );
       
  7922 //
       
  7923 // But there are hidden circular dependencies in RNMobile code, specifically in
       
  7924 // certain native components in the `components` package that depend on
       
  7925 // `block-editor`. What follows is a workaround that defers the `unlock` call
       
  7926 // to prevent native code from failing.
       
  7927 //
       
  7928 // Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.
       
  7929 let unlockedApis;
       
  7930 const cache = new WeakMap();
       
  7931 function getRichTextValuesCached(block) {
       
  7932   if (!unlockedApis) {
       
  7933     unlockedApis = unlock(external_wp_blockEditor_namespaceObject.privateApis);
       
  7934   }
       
  7935   if (!cache.has(block)) {
       
  7936     const values = unlockedApis.getRichTextValues([block]);
       
  7937     cache.set(block, values);
       
  7938   }
       
  7939   return cache.get(block);
       
  7940 }
       
  7941 
       
  7942 ;// ./node_modules/@wordpress/core-data/build-module/footnotes/get-footnotes-order.js
       
  7943 /**
       
  7944  * Internal dependencies
       
  7945  */
       
  7946 
       
  7947 const get_footnotes_order_cache = new WeakMap();
       
  7948 function getBlockFootnotesOrder(block) {
       
  7949   if (!get_footnotes_order_cache.has(block)) {
       
  7950     const order = [];
       
  7951     for (const value of getRichTextValuesCached(block)) {
       
  7952       if (!value) {
       
  7953         continue;
       
  7954       }
       
  7955 
       
  7956       // replacements is a sparse array, use forEach to skip empty slots.
       
  7957       value.replacements.forEach(({
       
  7958         type,
       
  7959         attributes
       
  7960       }) => {
       
  7961         if (type === 'core/footnote') {
       
  7962           order.push(attributes['data-fn']);
       
  7963         }
       
  7964       });
       
  7965     }
       
  7966     get_footnotes_order_cache.set(block, order);
       
  7967   }
       
  7968   return get_footnotes_order_cache.get(block);
       
  7969 }
       
  7970 function getFootnotesOrder(blocks) {
       
  7971   // We can only separate getting order from blocks at the root level. For
       
  7972   // deeper inner blocks, this will not work since it's possible to have both
       
  7973   // inner blocks and block attributes, so order needs to be computed from the
       
  7974   // Edit functions as a whole.
       
  7975   return blocks.flatMap(getBlockFootnotesOrder);
       
  7976 }
       
  7977 
       
  7978 ;// ./node_modules/@wordpress/core-data/build-module/footnotes/index.js
       
  7979 /**
       
  7980  * WordPress dependencies
       
  7981  */
       
  7982 
       
  7983 
       
  7984 /**
       
  7985  * Internal dependencies
       
  7986  */
       
  7987 
       
  7988 let oldFootnotes = {};
       
  7989 function updateFootnotesFromMeta(blocks, meta) {
       
  7990   const output = {
       
  7991     blocks
       
  7992   };
       
  7993   if (!meta) {
       
  7994     return output;
       
  7995   }
       
  7996 
       
  7997   // If meta.footnotes is empty, it means the meta is not registered.
       
  7998   if (meta.footnotes === undefined) {
       
  7999     return output;
       
  8000   }
       
  8001   const newOrder = getFootnotesOrder(blocks);
       
  8002   const footnotes = meta.footnotes ? JSON.parse(meta.footnotes) : [];
       
  8003   const currentOrder = footnotes.map(fn => fn.id);
       
  8004   if (currentOrder.join('') === newOrder.join('')) {
       
  8005     return output;
       
  8006   }
       
  8007   const newFootnotes = newOrder.map(fnId => footnotes.find(fn => fn.id === fnId) || oldFootnotes[fnId] || {
       
  8008     id: fnId,
       
  8009     content: ''
       
  8010   });
       
  8011   function updateAttributes(attributes) {
       
  8012     // Only attempt to update attributes, if attributes is an object.
       
  8013     if (!attributes || Array.isArray(attributes) || typeof attributes !== 'object') {
       
  8014       return attributes;
       
  8015     }
       
  8016     attributes = {
       
  8017       ...attributes
       
  8018     };
       
  8019     for (const key in attributes) {
       
  8020       const value = attributes[key];
       
  8021       if (Array.isArray(value)) {
       
  8022         attributes[key] = value.map(updateAttributes);
       
  8023         continue;
       
  8024       }
       
  8025 
       
  8026       // To do, remove support for string values?
       
  8027       if (typeof value !== 'string' && !(value instanceof external_wp_richText_namespaceObject.RichTextData)) {
       
  8028         continue;
       
  8029       }
       
  8030       const richTextValue = typeof value === 'string' ? external_wp_richText_namespaceObject.RichTextData.fromHTMLString(value) : new external_wp_richText_namespaceObject.RichTextData(value);
       
  8031       let hasFootnotes = false;
       
  8032       richTextValue.replacements.forEach(replacement => {
       
  8033         if (replacement.type === 'core/footnote') {
       
  8034           const id = replacement.attributes['data-fn'];
       
  8035           const index = newOrder.indexOf(id);
       
  8036           // The innerHTML contains the count wrapped in a link.
       
  8037           const countValue = (0,external_wp_richText_namespaceObject.create)({
       
  8038             html: replacement.innerHTML
       
  8039           });
       
  8040           countValue.text = String(index + 1);
       
  8041           countValue.formats = Array.from({
       
  8042             length: countValue.text.length
       
  8043           }, () => countValue.formats[0]);
       
  8044           countValue.replacements = Array.from({
       
  8045             length: countValue.text.length
       
  8046           }, () => countValue.replacements[0]);
       
  8047           replacement.innerHTML = (0,external_wp_richText_namespaceObject.toHTMLString)({
       
  8048             value: countValue
       
  8049           });
       
  8050           hasFootnotes = true;
       
  8051         }
       
  8052       });
       
  8053       if (hasFootnotes) {
       
  8054         attributes[key] = typeof value === 'string' ? richTextValue.toHTMLString() : richTextValue;
       
  8055       }
       
  8056     }
       
  8057     return attributes;
       
  8058   }
       
  8059   function updateBlocksAttributes(__blocks) {
       
  8060     return __blocks.map(block => {
       
  8061       return {
       
  8062         ...block,
       
  8063         attributes: updateAttributes(block.attributes),
       
  8064         innerBlocks: updateBlocksAttributes(block.innerBlocks)
       
  8065       };
       
  8066     });
       
  8067   }
       
  8068 
       
  8069   // We need to go through all block attributes deeply and update the
       
  8070   // footnote anchor numbering (textContent) to match the new order.
       
  8071   const newBlocks = updateBlocksAttributes(blocks);
       
  8072   oldFootnotes = {
       
  8073     ...oldFootnotes,
       
  8074     ...footnotes.reduce((acc, fn) => {
       
  8075       if (!newOrder.includes(fn.id)) {
       
  8076         acc[fn.id] = fn;
       
  8077       }
       
  8078       return acc;
       
  8079     }, {})
       
  8080   };
       
  8081   return {
       
  8082     meta: {
       
  8083       ...meta,
       
  8084       footnotes: JSON.stringify(newFootnotes)
       
  8085     },
       
  8086     blocks: newBlocks
       
  8087   };
       
  8088 }
       
  8089 
       
  8090 ;// ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-block-editor.js
       
  8091 /**
       
  8092  * WordPress dependencies
       
  8093  */
       
  8094 
       
  8095 
       
  8096 
       
  8097 
       
  8098 /**
       
  8099  * Internal dependencies
       
  8100  */
       
  8101 
       
  8102 
       
  8103 
       
  8104 const use_entity_block_editor_EMPTY_ARRAY = [];
       
  8105 const parsedBlocksCache = new WeakMap();
       
  8106 
       
  8107 /**
       
  8108  * Hook that returns block content getters and setters for
       
  8109  * the nearest provided entity of the specified type.
       
  8110  *
       
  8111  * The return value has the shape `[ blocks, onInput, onChange ]`.
       
  8112  * `onInput` is for block changes that don't create undo levels
       
  8113  * or dirty the post, non-persistent changes, and `onChange` is for
       
  8114  * persistent changes. They map directly to the props of a
       
  8115  * `BlockEditorProvider` and are intended to be used with it,
       
  8116  * or similar components or hooks.
       
  8117  *
       
  8118  * @param {string} kind         The entity kind.
       
  8119  * @param {string} name         The entity name.
       
  8120  * @param {Object} options
       
  8121  * @param {string} [options.id] An entity ID to use instead of the context-provided one.
       
  8122  *
       
  8123  * @return {[unknown[], Function, Function]} The block array and setters.
       
  8124  */
       
  8125 function useEntityBlockEditor(kind, name, {
       
  8126   id: _id
       
  8127 } = {}) {
       
  8128   const providerId = useEntityId(kind, name);
       
  8129   const id = _id !== null && _id !== void 0 ? _id : providerId;
       
  8130   const {
       
  8131     getEntityRecord,
       
  8132     getEntityRecordEdits
       
  8133   } = (0,external_wp_data_namespaceObject.useSelect)(STORE_NAME);
       
  8134   const {
       
  8135     content,
       
  8136     editedBlocks,
       
  8137     meta
       
  8138   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  8139     if (!id) {
       
  8140       return {};
       
  8141     }
       
  8142     const {
       
  8143       getEditedEntityRecord
       
  8144     } = select(STORE_NAME);
       
  8145     const editedRecord = getEditedEntityRecord(kind, name, id);
       
  8146     return {
       
  8147       editedBlocks: editedRecord.blocks,
       
  8148       content: editedRecord.content,
       
  8149       meta: editedRecord.meta
       
  8150     };
       
  8151   }, [kind, name, id]);
       
  8152   const {
       
  8153     __unstableCreateUndoLevel,
       
  8154     editEntityRecord
       
  8155   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
       
  8156   const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
       
  8157     if (!id) {
       
  8158       return undefined;
       
  8159     }
       
  8160     if (editedBlocks) {
       
  8161       return editedBlocks;
       
  8162     }
       
  8163     if (!content || typeof content !== 'string') {
       
  8164       return use_entity_block_editor_EMPTY_ARRAY;
       
  8165     }
       
  8166 
       
  8167     // If there's an edit, cache the parsed blocks by the edit.
       
  8168     // If not, cache by the original entity record.
       
  8169     const edits = getEntityRecordEdits(kind, name, id);
       
  8170     const isUnedited = !edits || !Object.keys(edits).length;
       
  8171     const cackeKey = isUnedited ? getEntityRecord(kind, name, id) : edits;
       
  8172     let _blocks = parsedBlocksCache.get(cackeKey);
       
  8173     if (!_blocks) {
       
  8174       _blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
       
  8175       parsedBlocksCache.set(cackeKey, _blocks);
       
  8176     }
       
  8177     return _blocks;
       
  8178   }, [kind, name, id, editedBlocks, content, getEntityRecord, getEntityRecordEdits]);
       
  8179   const onChange = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
       
  8180     const noChange = blocks === newBlocks;
       
  8181     if (noChange) {
       
  8182       return __unstableCreateUndoLevel(kind, name, id);
       
  8183     }
       
  8184     const {
       
  8185       selection,
       
  8186       ...rest
       
  8187     } = options;
       
  8188 
       
  8189     // We create a new function here on every persistent edit
       
  8190     // to make sure the edit makes the post dirty and creates
       
  8191     // a new undo level.
       
  8192     const edits = {
       
  8193       selection,
       
  8194       content: ({
       
  8195         blocks: blocksForSerialization = []
       
  8196       }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization),
       
  8197       ...updateFootnotesFromMeta(newBlocks, meta)
       
  8198     };
       
  8199     editEntityRecord(kind, name, id, edits, {
       
  8200       isCached: false,
       
  8201       ...rest
       
  8202     });
       
  8203   }, [kind, name, id, blocks, meta, __unstableCreateUndoLevel, editEntityRecord]);
       
  8204   const onInput = (0,external_wp_element_namespaceObject.useCallback)((newBlocks, options) => {
       
  8205     const {
       
  8206       selection,
       
  8207       ...rest
       
  8208     } = options;
       
  8209     const footnotesChanges = updateFootnotesFromMeta(newBlocks, meta);
       
  8210     const edits = {
       
  8211       selection,
       
  8212       ...footnotesChanges
       
  8213     };
       
  8214     editEntityRecord(kind, name, id, edits, {
       
  8215       isCached: true,
       
  8216       ...rest
       
  8217     });
       
  8218   }, [kind, name, id, meta, editEntityRecord]);
       
  8219   return [blocks, onInput, onChange];
       
  8220 }
       
  8221 
       
  8222 ;// ./node_modules/@wordpress/core-data/build-module/hooks/use-entity-prop.js
       
  8223 /**
       
  8224  * WordPress dependencies
       
  8225  */
       
  8226 
       
  8227 
       
  8228 
       
  8229 /**
       
  8230  * Internal dependencies
       
  8231  */
       
  8232 
       
  8233 
       
  8234 
       
  8235 /**
       
  8236  * Hook that returns the value and a setter for the
       
  8237  * specified property of the nearest provided
       
  8238  * entity of the specified type.
       
  8239  *
       
  8240  * @param {string}        kind  The entity kind.
       
  8241  * @param {string}        name  The entity name.
       
  8242  * @param {string}        prop  The property name.
       
  8243  * @param {number|string} [_id] An entity ID to use instead of the context-provided one.
       
  8244  *
       
  8245  * @return {[*, Function, *]} An array where the first item is the
       
  8246  *                            property value, the second is the
       
  8247  *                            setter and the third is the full value
       
  8248  * 							  object from REST API containing more
       
  8249  * 							  information like `raw`, `rendered` and
       
  8250  * 							  `protected` props.
       
  8251  */
       
  8252 function useEntityProp(kind, name, prop, _id) {
       
  8253   const providerId = useEntityId(kind, name);
       
  8254   const id = _id !== null && _id !== void 0 ? _id : providerId;
       
  8255   const {
       
  8256     value,
       
  8257     fullValue
       
  8258   } = (0,external_wp_data_namespaceObject.useSelect)(select => {
       
  8259     const {
       
  8260       getEntityRecord,
       
  8261       getEditedEntityRecord
       
  8262     } = select(STORE_NAME);
       
  8263     const record = getEntityRecord(kind, name, id); // Trigger resolver.
       
  8264     const editedRecord = getEditedEntityRecord(kind, name, id);
       
  8265     return record && editedRecord ? {
       
  8266       value: editedRecord[prop],
       
  8267       fullValue: record[prop]
       
  8268     } : {};
       
  8269   }, [kind, name, id, prop]);
       
  8270   const {
       
  8271     editEntityRecord
       
  8272   } = (0,external_wp_data_namespaceObject.useDispatch)(STORE_NAME);
       
  8273   const setValue = (0,external_wp_element_namespaceObject.useCallback)(newValue => {
       
  8274     editEntityRecord(kind, name, id, {
       
  8275       [prop]: newValue
       
  8276     });
       
  8277   }, [editEntityRecord, kind, name, id, prop]);
       
  8278   return [value, setValue, fullValue];
       
  8279 }
       
  8280 
       
  8281 ;// ./node_modules/@wordpress/core-data/build-module/hooks/index.js
       
  8282 
       
  8283 
       
  8284 
       
  8285 
       
  8286 
       
  8287 
       
  8288 
       
  8289 ;// ./node_modules/@wordpress/core-data/build-module/private-apis.js
       
  8290 /**
       
  8291  * Internal dependencies
       
  8292  */
       
  8293 
       
  8294 
       
  8295 
       
  8296 const privateApis = {};
       
  8297 lock(privateApis, {
       
  8298   useEntityRecordsWithPermissions: useEntityRecordsWithPermissions,
       
  8299   RECEIVE_INTERMEDIATE_RESULTS: RECEIVE_INTERMEDIATE_RESULTS
       
  8300 });
       
  8301 
       
  8302 ;// ./node_modules/@wordpress/core-data/build-module/index.js
       
  8303 /**
       
  8304  * WordPress dependencies
       
  8305  */
       
  8306 
       
  8307 
       
  8308 /**
       
  8309  * Internal dependencies
       
  8310  */
       
  8311 
       
  8312 
  7865 
  8313 
  7866 
  8314 
  7867 
  8315 
  7868 
  8316 
  7869 
  8317 
  7913   return result;
  8361   return result;
  7914 }, {});
  8362 }, {});
  7915 const storeConfig = () => ({
  8363 const storeConfig = () => ({
  7916   reducer: build_module_reducer,
  8364   reducer: build_module_reducer,
  7917   actions: {
  8365   actions: {
       
  8366     ...dynamicActions,
  7918     ...build_module_actions_namespaceObject,
  8367     ...build_module_actions_namespaceObject,
  7919     ...entityActions,
  8368     ...entityActions,
  7920     ...createLocksActions()
  8369     ...createLocksActions()
  7921   },
  8370   },
  7922   selectors: {
  8371   selectors: {
       
  8372     ...dynamicSelectors,
  7923     ...build_module_selectors_namespaceObject,
  8373     ...build_module_selectors_namespaceObject,
  7924     ...entitySelectors
  8374     ...entitySelectors
  7925   },
  8375   },
  7926   resolvers: {
  8376   resolvers: {
  7927     ...resolvers_namespaceObject,
  8377     ...resolvers_namespaceObject,
  7934  *
  8384  *
  7935  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  8385  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  7936  */
  8386  */
  7937 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig());
  8387 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig());
  7938 unlock(store).registerPrivateSelectors(private_selectors_namespaceObject);
  8388 unlock(store).registerPrivateSelectors(private_selectors_namespaceObject);
       
  8389 unlock(store).registerPrivateActions(private_actions_namespaceObject);
  7939 (0,external_wp_data_namespaceObject.register)(store); // Register store after unlocking private selectors to allow resolvers to use them.
  8390 (0,external_wp_data_namespaceObject.register)(store); // Register store after unlocking private selectors to allow resolvers to use them.
  7940 
  8391 
  7941 
  8392 
  7942 
  8393 
  7943 
  8394 
  7944 
  8395 
  7945 
  8396 
  7946 
  8397 
  7947 })();
       
  7948 
  8398 
  7949 (window.wp = window.wp || {}).coreData = __webpack_exports__;
  8399 (window.wp = window.wp || {}).coreData = __webpack_exports__;
  7950 /******/ })()
  8400 /******/ })()
  7951 ;
  8401 ;