Hunter Black Hat SEO
Server:LiteSpeed
System:Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64
User:gazetufm (1431)
PHP:8.1.35
Disabled:NONE
Upload Files
File: //home2/gazetufm/www/wp/wp-content/plugins/gutenberg/build/scripts/core-data/index.min.js.map
{
  "version": 3,
  "sources": ["package-external:@wordpress/data", "../../../node_modules/fast-deep-equal/es6/index.js", "package-external:@wordpress/compose", "package-external:@wordpress/undo-manager", "../../../node_modules/equivalent-key-map/equivalent-key-map.js", "package-external:@wordpress/url", "package-external:@wordpress/api-fetch", "package-external:@wordpress/blocks", "package-external:@wordpress/i18n", "package-external:@wordpress/sync", "package-external:@wordpress/block-editor", "package-external:@wordpress/rich-text", "package-external:@wordpress/private-apis", "package-external:@wordpress/deprecated", "package-external:@wordpress/html-entities", "package-external:@wordpress/element", "vendor-external:react/jsx-runtime", "package-external:@wordpress/warning", "../../../packages/core-data/src/index.js", "../../../packages/core-data/src/reducer.js", "../../../packages/core-data/src/utils/conservative-map-item.js", "../../../packages/core-data/src/utils/get-normalized-comma-separable.js", "../../../packages/core-data/src/utils/if-matching-action.js", "../../../packages/core-data/src/utils/forward-resolver.js", "../../../packages/core-data/src/utils/on-sub-key.js", "../../../packages/core-data/src/utils/replace-action.js", "../../../packages/core-data/src/utils/with-weak-map-cache.js", "../../../packages/core-data/src/utils/is-raw-attribute.js", "../../../packages/core-data/src/utils/set-nested-value.js", "../../../packages/core-data/src/utils/get-nested-value.js", "../../../packages/core-data/src/utils/is-numeric-id.js", "../../../packages/core-data/src/utils/user-permissions.js", "../../../packages/core-data/src/utils/receive-intermediate-results.js", "../../../packages/core-data/src/utils/normalize-query-for-resolution.js", "../../../packages/core-data/src/queried-data/actions.js", "../../../packages/core-data/src/queried-data/selectors.js", "../../../packages/core-data/src/queried-data/get-query-parts.js", "../../../packages/core-data/src/queried-data/reducer.js", "../../../node_modules/tslib/tslib.es6.mjs", "../../../node_modules/lower-case/src/index.ts", "../../../node_modules/no-case/src/index.ts", "../../../node_modules/pascal-case/src/index.ts", "../../../node_modules/camel-case/src/index.ts", "../../../node_modules/upper-case-first/src/index.ts", "../../../node_modules/capital-case/src/index.ts", "../../../packages/core-data/src/entities.js", "../../../packages/core-data/src/awareness/post-editor-awareness.ts", "../../../packages/core-data/src/awareness/base-awareness.ts", "../../../packages/core-data/src/awareness/config.ts", "../../../packages/core-data/src/awareness/typed-awareness.ts", "../../../packages/core-data/src/awareness/utils.ts", "../../../packages/core-data/src/awareness/awareness-state.ts", "../../../packages/core-data/src/name.js", "../../../packages/core-data/src/awareness/block-lookup.ts", "../../../packages/core-data/src/utils/crdt-utils.ts", "../../../packages/core-data/src/sync.ts", "../../../packages/core-data/src/lock-unlock.ts", "../../../packages/core-data/src/utils/crdt-user-selections.ts", "../../../packages/core-data/src/types.ts", "../../../packages/core-data/src/utils/crdt.ts", "../../../node_modules/uuid/dist/esm-browser/rng.js", "../../../node_modules/uuid/dist/esm-browser/stringify.js", "../../../node_modules/uuid/dist/esm-browser/native.js", "../../../node_modules/uuid/dist/esm-browser/v4.js", "../../../packages/core-data/src/utils/crdt-blocks.ts", "../../../packages/core-data/src/utils/crdt-text.ts", "../../../packages/core-data/src/utils/crdt-selection.ts", "../../../packages/core-data/src/utils/block-selection-history.ts", "../../../packages/core-data/src/selectors.ts", "../../../packages/core-data/src/private-selectors.ts", "../../../packages/core-data/src/utils/log-entity-deprecation.ts", "../../../packages/core-data/src/actions.js", "../../../packages/core-data/src/batch/default-processor.js", "../../../packages/core-data/src/batch/create-batch.js", "../../../packages/core-data/src/private-actions.js", "../../../packages/core-data/src/resolvers.js", "../../../packages/core-data/src/fetch/index.js", "../../../packages/core-data/src/fetch/__experimental-fetch-link-suggestions.ts", "../../../packages/core-data/src/fetch/__experimental-fetch-url-data.js", "../../../packages/core-data/src/locks/utils.js", "../../../packages/core-data/src/locks/reducer.js", "../../../packages/core-data/src/locks/selectors.js", "../../../packages/core-data/src/locks/engine.js", "../../../packages/core-data/src/locks/actions.js", "../../../packages/core-data/src/dynamic-entities.ts", "../../../packages/core-data/src/entity-provider.js", "../../../packages/core-data/src/entity-context.js", "../../../packages/core-data/src/hooks/use-entity-record.ts", "../../../packages/core-data/src/hooks/use-query-select.ts", "../../../node_modules/memize/dist/index.js", "../../../packages/core-data/src/hooks/memoize.js", "../../../packages/core-data/src/hooks/constants.ts", "../../../packages/core-data/src/hooks/use-entity-records.ts", "../../../packages/core-data/src/hooks/use-resource-permissions.ts", "../../../packages/core-data/src/hooks/use-entity-block-editor.js", "../../../packages/core-data/src/hooks/use-entity-id.js", "../../../packages/core-data/src/footnotes/index.js", "../../../packages/core-data/src/footnotes/get-rich-text-values-cached.js", "../../../packages/core-data/src/footnotes/get-footnotes-order.js", "../../../packages/core-data/src/hooks/use-entity-prop.js", "../../../packages/core-data/src/hooks/use-post-editor-awareness-state.ts", "../../../packages/core-data/src/private-apis.js"],
  "sourcesContent": ["module.exports = window.wp.data;", "'use strict';\n\n// do not edit .js files directly - edit src/index.jst\n\n\n  var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';\n\n\nmodule.exports = function equal(a, b) {\n  if (a === b) return true;\n\n  if (a && b && typeof a == 'object' && typeof b == 'object') {\n    if (a.constructor !== b.constructor) return false;\n\n    var length, i, keys;\n    if (Array.isArray(a)) {\n      length = a.length;\n      if (length != b.length) return false;\n      for (i = length; i-- !== 0;)\n        if (!equal(a[i], b[i])) return false;\n      return true;\n    }\n\n\n    if ((a instanceof Map) && (b instanceof Map)) {\n      if (a.size !== b.size) return false;\n      for (i of a.entries())\n        if (!b.has(i[0])) return false;\n      for (i of a.entries())\n        if (!equal(i[1], b.get(i[0]))) return false;\n      return true;\n    }\n\n    if ((a instanceof Set) && (b instanceof Set)) {\n      if (a.size !== b.size) return false;\n      for (i of a.entries())\n        if (!b.has(i[0])) return false;\n      return true;\n    }\n\n    if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {\n      length = a.length;\n      if (length != b.length) return false;\n      for (i = length; i-- !== 0;)\n        if (a[i] !== b[i]) return false;\n      return true;\n    }\n\n\n    if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n    if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n    if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n    keys = Object.keys(a);\n    length = keys.length;\n    if (length !== Object.keys(b).length) return false;\n\n    for (i = length; i-- !== 0;)\n      if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n\n    for (i = length; i-- !== 0;) {\n      var key = keys[i];\n\n      if (!equal(a[key], b[key])) return false;\n    }\n\n    return true;\n  }\n\n  // true if both NaN, false otherwise\n  return a!==a && b!==b;\n};\n", "module.exports = window.wp.compose;", "module.exports = window.wp.undoManager;", "'use strict';\n\nfunction _typeof(obj) {\n  if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n    _typeof = function (obj) {\n      return typeof obj;\n    };\n  } else {\n    _typeof = function (obj) {\n      return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n    };\n  }\n\n  return _typeof(obj);\n}\n\nfunction _classCallCheck(instance, Constructor) {\n  if (!(instance instanceof Constructor)) {\n    throw new TypeError(\"Cannot call a class as a function\");\n  }\n}\n\nfunction _defineProperties(target, props) {\n  for (var i = 0; i < props.length; i++) {\n    var descriptor = props[i];\n    descriptor.enumerable = descriptor.enumerable || false;\n    descriptor.configurable = true;\n    if (\"value\" in descriptor) descriptor.writable = true;\n    Object.defineProperty(target, descriptor.key, descriptor);\n  }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n  if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n  if (staticProps) _defineProperties(Constructor, staticProps);\n  return Constructor;\n}\n\n/**\n * Given an instance of EquivalentKeyMap, returns its internal value pair tuple\n * for a key, if one exists. The tuple members consist of the last reference\n * value for the key (used in efficient subsequent lookups) and the value\n * assigned for the key at the leaf node.\n *\n * @param {EquivalentKeyMap} instance EquivalentKeyMap instance.\n * @param {*} key                     The key for which to return value pair.\n *\n * @return {?Array} Value pair, if exists.\n */\nfunction getValuePair(instance, key) {\n  var _map = instance._map,\n      _arrayTreeMap = instance._arrayTreeMap,\n      _objectTreeMap = instance._objectTreeMap; // Map keeps a reference to the last object-like key used to set the\n  // value, which can be used to shortcut immediately to the value.\n\n  if (_map.has(key)) {\n    return _map.get(key);\n  } // Sort keys to ensure stable retrieval from tree.\n\n\n  var properties = Object.keys(key).sort(); // Tree by type to avoid conflicts on numeric object keys, empty value.\n\n  var map = Array.isArray(key) ? _arrayTreeMap : _objectTreeMap;\n\n  for (var i = 0; i < properties.length; i++) {\n    var property = properties[i];\n    map = map.get(property);\n\n    if (map === undefined) {\n      return;\n    }\n\n    var propertyValue = key[property];\n    map = map.get(propertyValue);\n\n    if (map === undefined) {\n      return;\n    }\n  }\n\n  var valuePair = map.get('_ekm_value');\n\n  if (!valuePair) {\n    return;\n  } // If reached, it implies that an object-like key was set with another\n  // reference, so delete the reference and replace with the current.\n\n\n  _map.delete(valuePair[0]);\n\n  valuePair[0] = key;\n  map.set('_ekm_value', valuePair);\n\n  _map.set(key, valuePair);\n\n  return valuePair;\n}\n/**\n * Variant of a Map object which enables lookup by equivalent (deeply equal)\n * object and array keys.\n */\n\n\nvar EquivalentKeyMap =\n/*#__PURE__*/\nfunction () {\n  /**\n   * Constructs a new instance of EquivalentKeyMap.\n   *\n   * @param {Iterable.<*>} iterable Initial pair of key, value for map.\n   */\n  function EquivalentKeyMap(iterable) {\n    _classCallCheck(this, EquivalentKeyMap);\n\n    this.clear();\n\n    if (iterable instanceof EquivalentKeyMap) {\n      // Map#forEach is only means of iterating with support for IE11.\n      var iterablePairs = [];\n      iterable.forEach(function (value, key) {\n        iterablePairs.push([key, value]);\n      });\n      iterable = iterablePairs;\n    }\n\n    if (iterable != null) {\n      for (var i = 0; i < iterable.length; i++) {\n        this.set(iterable[i][0], iterable[i][1]);\n      }\n    }\n  }\n  /**\n   * Accessor property returning the number of elements.\n   *\n   * @return {number} Number of elements.\n   */\n\n\n  _createClass(EquivalentKeyMap, [{\n    key: \"set\",\n\n    /**\n     * Add or update an element with a specified key and value.\n     *\n     * @param {*} key   The key of the element to add.\n     * @param {*} value The value of the element to add.\n     *\n     * @return {EquivalentKeyMap} Map instance.\n     */\n    value: function set(key, value) {\n      // Shortcut non-object-like to set on internal Map.\n      if (key === null || _typeof(key) !== 'object') {\n        this._map.set(key, value);\n\n        return this;\n      } // Sort keys to ensure stable assignment into tree.\n\n\n      var properties = Object.keys(key).sort();\n      var valuePair = [key, value]; // Tree by type to avoid conflicts on numeric object keys, empty value.\n\n      var map = Array.isArray(key) ? this._arrayTreeMap : this._objectTreeMap;\n\n      for (var i = 0; i < properties.length; i++) {\n        var property = properties[i];\n\n        if (!map.has(property)) {\n          map.set(property, new EquivalentKeyMap());\n        }\n\n        map = map.get(property);\n        var propertyValue = key[property];\n\n        if (!map.has(propertyValue)) {\n          map.set(propertyValue, new EquivalentKeyMap());\n        }\n\n        map = map.get(propertyValue);\n      } // If an _ekm_value exists, there was already an equivalent key. Before\n      // overriding, ensure that the old key reference is removed from map to\n      // avoid memory leak of accumulating equivalent keys. This is, in a\n      // sense, a poor man's WeakMap, while still enabling iterability.\n\n\n      var previousValuePair = map.get('_ekm_value');\n\n      if (previousValuePair) {\n        this._map.delete(previousValuePair[0]);\n      }\n\n      map.set('_ekm_value', valuePair);\n\n      this._map.set(key, valuePair);\n\n      return this;\n    }\n    /**\n     * Returns a specified element.\n     *\n     * @param {*} key The key of the element to return.\n     *\n     * @return {?*} The element associated with the specified key or undefined\n     *              if the key can't be found.\n     */\n\n  }, {\n    key: \"get\",\n    value: function get(key) {\n      // Shortcut non-object-like to get from internal Map.\n      if (key === null || _typeof(key) !== 'object') {\n        return this._map.get(key);\n      }\n\n      var valuePair = getValuePair(this, key);\n\n      if (valuePair) {\n        return valuePair[1];\n      }\n    }\n    /**\n     * Returns a boolean indicating whether an element with the specified key\n     * exists or not.\n     *\n     * @param {*} key The key of the element to test for presence.\n     *\n     * @return {boolean} Whether an element with the specified key exists.\n     */\n\n  }, {\n    key: \"has\",\n    value: function has(key) {\n      if (key === null || _typeof(key) !== 'object') {\n        return this._map.has(key);\n      } // Test on the _presence_ of the pair, not its value, as even undefined\n      // can be a valid member value for a key.\n\n\n      return getValuePair(this, key) !== undefined;\n    }\n    /**\n     * Removes the specified element.\n     *\n     * @param {*} key The key of the element to remove.\n     *\n     * @return {boolean} Returns true if an element existed and has been\n     *                   removed, or false if the element does not exist.\n     */\n\n  }, {\n    key: \"delete\",\n    value: function _delete(key) {\n      if (!this.has(key)) {\n        return false;\n      } // This naive implementation will leave orphaned child trees. A better\n      // implementation should traverse and remove orphans.\n\n\n      this.set(key, undefined);\n      return true;\n    }\n    /**\n     * Executes a provided function once per each key/value pair, in insertion\n     * order.\n     *\n     * @param {Function} callback Function to execute for each element.\n     * @param {*}        thisArg  Value to use as `this` when executing\n     *                            `callback`.\n     */\n\n  }, {\n    key: \"forEach\",\n    value: function forEach(callback) {\n      var _this = this;\n\n      var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this;\n\n      this._map.forEach(function (value, key) {\n        // Unwrap value from object-like value pair.\n        if (key !== null && _typeof(key) === 'object') {\n          value = value[1];\n        }\n\n        callback.call(thisArg, value, key, _this);\n      });\n    }\n    /**\n     * Removes all elements.\n     */\n\n  }, {\n    key: \"clear\",\n    value: function clear() {\n      this._map = new Map();\n      this._arrayTreeMap = new Map();\n      this._objectTreeMap = new Map();\n    }\n  }, {\n    key: \"size\",\n    get: function get() {\n      return this._map.size;\n    }\n  }]);\n\n  return EquivalentKeyMap;\n}();\n\nmodule.exports = EquivalentKeyMap;\n", "module.exports = window.wp.url;", "module.exports = window.wp.apiFetch;", "module.exports = window.wp.blocks;", "module.exports = window.wp.i18n;", "module.exports = window.wp.sync;", "module.exports = window.wp.blockEditor;", "module.exports = window.wp.richText;", "module.exports = window.wp.privateApis;", "module.exports = window.wp.deprecated;", "module.exports = window.wp.htmlEntities;", "module.exports = window.wp.element;", "module.exports = window.ReactJSXRuntime;", "module.exports = window.wp.warning;", "/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport * as actions from './actions';\nimport * as privateActions from './private-actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport {\n\trootEntitiesConfig,\n\tadditionalEntityConfigLoaders,\n\tgetMethodName,\n} from './entities';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\nimport { dynamicActions, dynamicSelectors } from './dynamic-entities';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)\n// Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\nconst entitiesConfig = [\n\t...rootEntitiesConfig,\n\t...additionalEntityConfigLoaders.filter( ( config ) => !! config.name ),\n];\n\nconst entitySelectors = entitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name, plural } = entity;\n\n\tconst getEntityRecordMethodName = getMethodName( kind, name );\n\tresult[ getEntityRecordMethodName ] = ( state, key, query ) => {\n\t\tlogEntityDeprecation( kind, name, getEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'getEntityRecord',\n\t\t} );\n\t\treturn selectors.getEntityRecord( state, kind, name, key, query );\n\t};\n\n\tif ( plural ) {\n\t\tconst getEntityRecordsMethodName = getMethodName( kind, plural, 'get' );\n\t\tresult[ getEntityRecordsMethodName ] = ( state, query ) => {\n\t\t\tlogEntityDeprecation( kind, name, getEntityRecordsMethodName, {\n\t\t\t\tisShorthandSelector: true,\n\t\t\t\talternativeFunctionName: 'getEntityRecords',\n\t\t\t} );\n\t\t\treturn selectors.getEntityRecords( state, kind, name, query );\n\t\t};\n\t}\n\treturn result;\n}, {} );\n\nconst entityResolvers = entitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name, plural } = entity;\n\tconst getEntityRecordMethodName = getMethodName( kind, name );\n\tresult[ getEntityRecordMethodName ] = ( key, query ) => {\n\t\tlogEntityDeprecation( kind, name, getEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'getEntityRecord',\n\t\t} );\n\t\treturn resolvers.getEntityRecord( kind, name, key, query );\n\t};\n\n\tif ( plural ) {\n\t\tconst getEntityRecordsMethodName = getMethodName( kind, plural, 'get' );\n\t\tresult[ getEntityRecordsMethodName ] = ( ...args ) => {\n\t\t\tlogEntityDeprecation( kind, plural, getEntityRecordsMethodName, {\n\t\t\t\tisShorthandSelector: true,\n\t\t\t\talternativeFunctionName: 'getEntityRecords',\n\t\t\t} );\n\t\t\treturn resolvers.getEntityRecords( kind, name, ...args );\n\t\t};\n\t\tresult[ getEntityRecordsMethodName ].shouldInvalidate = ( action ) =>\n\t\t\tresolvers.getEntityRecords.shouldInvalidate( action, kind, name );\n\t}\n\treturn result;\n}, {} );\n\nconst entityActions = entitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\n\tconst saveEntityRecordMethodName = getMethodName( kind, name, 'save' );\n\tresult[ saveEntityRecordMethodName ] = ( record, options ) => {\n\t\tlogEntityDeprecation( kind, name, saveEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'saveEntityRecord',\n\t\t} );\n\t\treturn actions.saveEntityRecord( kind, name, record, options );\n\t};\n\n\tconst deleteEntityRecordMethodName = getMethodName( kind, name, 'delete' );\n\tresult[ deleteEntityRecordMethodName ] = ( key, query, options ) => {\n\t\tlogEntityDeprecation( kind, name, deleteEntityRecordMethodName, {\n\t\t\tisShorthandSelector: true,\n\t\t\talternativeFunctionName: 'deleteEntityRecord',\n\t\t} );\n\t\treturn actions.deleteEntityRecord( kind, name, key, query, options );\n\t};\n\n\treturn result;\n}, {} );\n\nconst storeConfig = () => ( {\n\treducer,\n\tactions: {\n\t\t...dynamicActions,\n\t\t...actions,\n\t\t...entityActions,\n\t\t...createLocksActions(),\n\t},\n\tselectors: {\n\t\t...dynamicSelectors,\n\t\t...selectors,\n\t\t...entitySelectors,\n\t},\n\tresolvers: { ...resolvers, ...entityResolvers },\n} );\n\n/**\n * Store definition for the code data namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig() );\nunlock( store ).registerPrivateSelectors( privateSelectors );\nunlock( store ).registerPrivateActions( privateActions );\nregister( store ); // Register store after unlocking private selectors to allow resolvers to use them.\n\n/**\n * Enums cannot be exported private without losing the ability to narrow types\n * based on their values (they blur to string type).\n */\nexport { SelectionType } from './utils/crdt-user-selections';\nexport { SelectionDirection } from './types';\n\nexport { default as EntityProvider } from './entity-provider';\nexport * from './entity-provider';\nexport * from './entity-types';\nexport * from './awareness/types';\nexport * from './fetch';\nexport * from './hooks';\nexport * from './private-apis';\nexport * from './types';\n", "/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport { combineReducers } from '@wordpress/data';\nimport { createUndoManager } from '@wordpress/undo-manager';\n\n/**\n * Internal dependencies\n */\nimport { ifMatchingAction, replaceAction } from './utils';\nimport { reducer as queriedDataReducer } from './queried-data';\nimport { rootEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';\nimport { ConnectionErrorCode } from './sync';\n\n/** @typedef {import('./types').AnyFunction} AnyFunction */\n\n/**\n * Reducer managing authors state. Keyed by id.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function users( state = { byId: {}, queries: {} }, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_QUERY':\n\t\t\treturn {\n\t\t\t\tbyId: {\n\t\t\t\t\t...state.byId,\n\t\t\t\t\t// Key users by their ID.\n\t\t\t\t\t...action.users.reduce(\n\t\t\t\t\t\t( newUsers, user ) => ( {\n\t\t\t\t\t\t\t...newUsers,\n\t\t\t\t\t\t\t[ user.id ]: user,\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\tqueries: {\n\t\t\t\t\t...state.queries,\n\t\t\t\t\t[ action.queryID ]: action.users.map( ( user ) => user.id ),\n\t\t\t\t},\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing current user state.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function currentUser( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_USER':\n\t\t\treturn action.currentUser;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current theme.\n *\n * @param {string|undefined} state  Current state.\n * @param {Object}           action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentTheme( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_THEME':\n\t\t\treturn action.currentTheme.stylesheet;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the current global styles id.\n *\n * @param {string|undefined} state  Current state.\n * @param {Object}           action Dispatched action.\n *\n * @return {string|undefined} Updated state.\n */\nexport function currentGlobalStylesId( state = undefined, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_CURRENT_GLOBAL_STYLES_ID':\n\t\t\treturn action.id;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme base global styles.\n *\n * @param {Record<string, object>} state  Current state.\n * @param {Object}                 action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeBaseGlobalStyles( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLES':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.globalStyles,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles variations.\n *\n * @param {Record<string, object>} state  Current state.\n * @param {Object}                 action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleVariations( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.stylesheet ]: action.variations,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nconst withMultiEntityRecordEdits = ( reducer ) => ( state, action ) => {\n\tif ( action.type === 'UNDO' || action.type === 'REDO' ) {\n\t\tconst { record } = action;\n\n\t\tlet newState = state;\n\t\trecord.forEach( ( { id: { kind, name, recordId }, changes } ) => {\n\t\t\tnewState = reducer( newState, {\n\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tedits: Object.entries( changes ).reduce(\n\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\taction.type === 'UNDO' ? value.from : value.to;\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t),\n\t\t\t} );\n\t\t} );\n\t\treturn newState;\n\t}\n\n\treturn reducer( state, action );\n};\n\n/**\n * Higher Order Reducer for a given entity config. It supports:\n *\n *  - Fetching\n *  - Editing\n *  - Saving\n *\n * @param {Object} entityConfig Entity config.\n *\n * @return {AnyFunction} Reducer.\n */\nfunction entity( entityConfig ) {\n\treturn compose( [\n\t\twithMultiEntityRecordEdits,\n\n\t\t// Limit to matching action type so we don't attempt to replace action on\n\t\t// an unhandled action.\n\t\tifMatchingAction(\n\t\t\t( action ) =>\n\t\t\t\taction.name &&\n\t\t\t\taction.kind &&\n\t\t\t\taction.name === entityConfig.name &&\n\t\t\t\taction.kind === entityConfig.kind\n\t\t),\n\n\t\t// Inject the entity config into the action.\n\t\treplaceAction( ( action ) => {\n\t\t\treturn {\n\t\t\t\tkey: entityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t...action,\n\t\t\t};\n\t\t} ),\n\t] )(\n\t\tcombineReducers( {\n\t\t\tqueriedData: queriedDataReducer,\n\t\t\tedits: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'RECEIVE_ITEMS':\n\t\t\t\t\t\tconst context = action?.query?.context ?? 'default';\n\t\t\t\t\t\tif ( context !== 'default' ) {\n\t\t\t\t\t\t\treturn state;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst nextState = { ...state };\n\t\t\t\t\t\tconst itemsList = Array.isArray( action.items )\n\t\t\t\t\t\t\t? action.items\n\t\t\t\t\t\t\t: [ action.items ];\n\n\t\t\t\t\t\tfor ( const record of itemsList ) {\n\t\t\t\t\t\t\tconst recordId = record?.[ action.key ];\n\t\t\t\t\t\t\tconst edits = nextState[ recordId ];\n\t\t\t\t\t\t\tif ( ! edits ) {\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst nextEdits = Object.keys( edits ).reduce(\n\t\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t\t// If the edited value is still different to the persisted value,\n\t\t\t\t\t\t\t\t\t// keep the edited value in edits.\n\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t// Edits are the \"raw\" attribute values, but records may have\n\t\t\t\t\t\t\t\t\t\t// objects with more properties, so we use `get` here for the\n\t\t\t\t\t\t\t\t\t\t// comparison.\n\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\trecord[ key ]?.raw ?? record[ key ]\n\t\t\t\t\t\t\t\t\t\t) &&\n\t\t\t\t\t\t\t\t\t\t// Sometimes the server alters the sent value which means\n\t\t\t\t\t\t\t\t\t\t// we need to also remove the edits before the api request.\n\t\t\t\t\t\t\t\t\t\t( ! action.persistedEdits ||\n\t\t\t\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\t\t\t\tedits[ key ],\n\t\t\t\t\t\t\t\t\t\t\t\taction.persistedEdits[ key ]\n\t\t\t\t\t\t\t\t\t\t\t) )\n\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( Object.keys( nextEdits ).length ) {\n\t\t\t\t\t\t\t\tnextState[ recordId ] = nextEdits;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tdelete nextState[ recordId ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn nextState;\n\n\t\t\t\t\tcase 'EDIT_ENTITY_RECORD':\n\t\t\t\t\t\tconst nextEdits = {\n\t\t\t\t\t\t\t...state[ action.recordId ],\n\t\t\t\t\t\t\t...action.edits,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tObject.keys( nextEdits ).forEach( ( key ) => {\n\t\t\t\t\t\t\t// Delete cleared edits so that the properties\n\t\t\t\t\t\t\t// are not considered dirty.\n\t\t\t\t\t\t\tif ( nextEdits[ key ] === undefined ) {\n\t\t\t\t\t\t\t\tdelete nextEdits[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: nextEdits,\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tsaving: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'SAVE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type === 'SAVE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t\tisAutosave: action.isAutosave,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\tdeleting: ( state = {}, action ) => {\n\t\t\t\tswitch ( action.type ) {\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_START':\n\t\t\t\t\tcase 'DELETE_ENTITY_RECORD_FINISH':\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...state,\n\t\t\t\t\t\t\t[ action.recordId ]: {\n\t\t\t\t\t\t\t\tpending:\n\t\t\t\t\t\t\t\t\taction.type ===\n\t\t\t\t\t\t\t\t\t'DELETE_ENTITY_RECORD_START',\n\t\t\t\t\t\t\t\terror: action.error,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\n\t\t\trevisions: ( state = {}, action ) => {\n\t\t\t\t// Use the same queriedDataReducer shape for revisions.\n\t\t\t\tif ( action.type === 'RECEIVE_ITEM_REVISIONS' ) {\n\t\t\t\t\tconst recordKey = action.recordKey;\n\t\t\t\t\tdelete action.recordKey;\n\t\t\t\t\tconst newState = queriedDataReducer( state[ recordKey ], {\n\t\t\t\t\t\t...action,\n\t\t\t\t\t\ttype: 'RECEIVE_ITEMS',\n\t\t\t\t\t} );\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\t[ recordKey ]: newState,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif ( action.type === 'REMOVE_ITEMS' ) {\n\t\t\t\t\treturn Object.fromEntries(\n\t\t\t\t\t\tObject.entries( state ).filter(\n\t\t\t\t\t\t\t( [ id ] ) =>\n\t\t\t\t\t\t\t\t! action.itemIds.some( ( itemId ) => {\n\t\t\t\t\t\t\t\t\tif ( Number.isInteger( itemId ) ) {\n\t\t\t\t\t\t\t\t\t\treturn itemId === +id;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn itemId === id;\n\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn state;\n\t\t\t},\n\t\t} )\n\t);\n}\n\n/**\n * Reducer keeping track of the registered entities.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function entitiesConfig( state = rootEntitiesConfig, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ADD_ENTITIES':\n\t\t\treturn [ ...state, ...action.entities ];\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer keeping track of the registered entities config and data.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport const entities = ( state = {}, action ) => {\n\tconst newConfig = entitiesConfig( state.config, action );\n\n\t// Generates a reducer for the entities nested by `kind` and `name`.\n\t// A config array with shape:\n\t// ```\n\t// [\n\t//   { kind: 'taxonomy', name: 'category' },\n\t//   { kind: 'taxonomy', name: 'post_tag' },\n\t//   { kind: 'postType', name: 'post' },\n\t//   { kind: 'postType', name: 'page' },\n\t// ]\n\t// ```\n\t// generates a reducer for state tree with shape:\n\t// ```\n\t// {\n\t//   taxonomy: {\n\t//     category,\n\t//     post_tag,\n\t//   },\n\t//   postType: {\n\t//     post,\n\t//     page,\n\t//   },\n\t// }\n\t// ```\n\tlet entitiesDataReducer = state.reducer;\n\tif ( ! entitiesDataReducer || newConfig !== state.config ) {\n\t\tconst entitiesByKind = newConfig.reduce( ( acc, record ) => {\n\t\t\tconst { kind } = record;\n\t\t\tif ( ! acc[ kind ] ) {\n\t\t\t\tacc[ kind ] = [];\n\t\t\t}\n\t\t\tacc[ kind ].push( record );\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\tentitiesDataReducer = combineReducers(\n\t\t\tObject.fromEntries(\n\t\t\t\tObject.entries( entitiesByKind ).map(\n\t\t\t\t\t( [ kind, subEntities ] ) => {\n\t\t\t\t\t\tconst kindReducer = combineReducers(\n\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\tsubEntities.map( ( entityConfig ) => [\n\t\t\t\t\t\t\t\t\tentityConfig.name,\n\t\t\t\t\t\t\t\t\tentity( entityConfig ),\n\t\t\t\t\t\t\t\t] )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn [ kind, kindReducer ];\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\tconst newData = entitiesDataReducer( state.records, action );\n\n\tif (\n\t\tnewData === state.records &&\n\t\tnewConfig === state.config &&\n\t\tentitiesDataReducer === state.reducer\n\t) {\n\t\treturn state;\n\t}\n\n\treturn {\n\t\treducer: entitiesDataReducer,\n\t\trecords: newData,\n\t\tconfig: newConfig,\n\t};\n};\n\n/**\n * @type {UndoManager}\n */\nexport function undoManager( state = createUndoManager() ) {\n\treturn state;\n}\n\nexport function editsReference( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'EDIT_ENTITY_RECORD':\n\t\tcase 'UNDO':\n\t\tcase 'REDO':\n\t\t\treturn {};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer managing embed preview data.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function embedPreviews( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EMBED_PREVIEW':\n\t\t\tconst { url, preview } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ url ]: preview,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * State which tracks whether the user can perform an action on a REST\n * resource.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function userPermissions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PERMISSION':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.key ]: action.isAllowed,\n\t\t\t};\n\t\tcase 'RECEIVE_USER_PERMISSIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t...action.permissions,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning autosaves keyed by their parent's post id.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function autosaves( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_AUTOSAVES':\n\t\t\tconst { postId, autosaves: autosavesData } = action;\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ postId ]: autosavesData,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\nexport function blockPatterns( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERNS':\n\t\t\treturn action.patterns;\n\t}\n\n\treturn state;\n}\n\nexport function blockPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_BLOCK_PATTERN_CATEGORIES':\n\t\t\treturn action.categories;\n\t}\n\n\treturn state;\n}\n\nexport function userPatternCategories( state = [], action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_USER_PATTERN_CATEGORIES':\n\t\t\treturn action.patternCategories;\n\t}\n\treturn state;\n}\n\nexport function navigationFallbackId( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_NAVIGATION_FALLBACK_ID':\n\t\t\treturn action.fallbackId;\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the theme global styles revisions.\n *\n * @param {Record<string, object>} state  Current state.\n * @param {Object}                 action Dispatched action.\n *\n * @return {Record<string, object>} Updated state.\n */\nexport function themeGlobalStyleRevisions( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.currentId ]: action.revisions,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer managing the template lookup per query.\n *\n * @param {Record<string, string>} state  Current state.\n * @param {Object}                 action Dispatched action.\n *\n * @return {Record<string, string>} Updated state.\n */\nexport function defaultTemplates( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_DEFAULT_TEMPLATE':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ JSON.stringify( action.query ) ]: action.templateId,\n\t\t\t};\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer returning an object of registered post meta.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function registeredPostMeta( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_REGISTERED_POST_META':\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ action.postType ]: action.registeredPostMeta,\n\t\t\t};\n\t}\n\treturn state;\n}\n\n/**\n * Reducer managing editor settings.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Action object.\n *\n * @return {Object} Updated state.\n */\nexport function editorSettings( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EDITOR_SETTINGS':\n\t\t\treturn action.settings;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer managing editor assets.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Action object.\n *\n * @return {Object} Updated state.\n */\nexport function editorAssets( state = null, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_EDITOR_ASSETS':\n\t\t\treturn action.assets;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer managing sync connection states for entities.\n * Keyed by \"kind/name:id\" (e.g., \"postType/post:123\").\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function syncConnectionStatuses( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_SYNC_CONNECTION_STATUS': {\n\t\t\tconst key = `${ action.kind }/${ action.name }:${ action.key }`;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ key ]: action.status,\n\t\t\t};\n\t\t}\n\t\tcase 'CLEAR_SYNC_CONNECTION_STATUS': {\n\t\t\tconst key = `${ action.kind }/${ action.name }:${ action.key }`;\n\t\t\tconst { [ key ]: _, ...rest } = state;\n\t\t\treturn rest;\n\t\t}\n\t}\n\treturn state;\n}\n\n/**\n * Reducer managing whether collaboration is supported.\n *\n * Default to true, as collaboration is supported by default\n * unless explicitly disabled due to unsupported conditions\n * such as metaboxes.\n *\n * @param {boolean} state  Current state.\n * @param {Object}  action Dispatched action.\n *\n * @return {boolean} Updated state.\n */\nexport function collaborationSupported( state = true, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_COLLABORATION_SUPPORTED':\n\t\t\treturn action.supported;\n\n\t\tcase 'SET_SYNC_CONNECTION_STATUS':\n\t\t\tif (\n\t\t\t\tConnectionErrorCode.DOCUMENT_SIZE_LIMIT_EXCEEDED ===\n\t\t\t\taction.status?.error?.code\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn state;\n\t}\n\treturn state;\n}\n\nexport default combineReducers( {\n\tusers,\n\tcurrentTheme,\n\tcurrentGlobalStylesId,\n\tcurrentUser,\n\tthemeGlobalStyleVariations,\n\tthemeBaseGlobalStyles,\n\tthemeGlobalStyleRevisions,\n\tentities,\n\teditsReference,\n\tundoManager,\n\tembedPreviews,\n\tuserPermissions,\n\tautosaves,\n\tblockPatterns,\n\tblockPatternCategories,\n\tuserPatternCategories,\n\tnavigationFallbackId,\n\tdefaultTemplates,\n\tregisteredPostMeta,\n\teditorSettings,\n\teditorAssets,\n\tsyncConnectionStatuses,\n\tcollaborationSupported,\n} );\n", "/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * Given the current and next item entity record, returns the minimally \"modified\"\n * result of the next item, preferring value references from the original item\n * if equal. If all values match, the original item is returned.\n *\n * @param {Object} item     Original item.\n * @param {Object} nextItem Next item.\n *\n * @return {Object} Minimally modified merged item.\n */\nexport default function conservativeMapItem( item, nextItem ) {\n\t// Return next item in its entirety if there is no original item.\n\tif ( ! item ) {\n\t\treturn nextItem;\n\t}\n\n\tlet hasChanges = false;\n\tconst result = {};\n\tfor ( const key in nextItem ) {\n\t\tif ( fastDeepEqual( item[ key ], nextItem[ key ] ) ) {\n\t\t\tresult[ key ] = item[ key ];\n\t\t} else {\n\t\t\thasChanges = true;\n\t\t\tresult[ key ] = nextItem[ key ];\n\t\t}\n\t}\n\n\tif ( ! hasChanges ) {\n\t\treturn item;\n\t}\n\n\t// Only at this point, backfill properties from the original item which\n\t// weren't explicitly set into the result above. This is an optimization\n\t// to allow `hasChanges` to return early.\n\tfor ( const key in item ) {\n\t\tif ( ! result.hasOwnProperty( key ) ) {\n\t\t\tresult[ key ] = item[ key ];\n\t\t}\n\t}\n\n\treturn result;\n}\n", "/**\n * Given a value which can be specified as one or the other of a comma-separated\n * string or an array, returns a value normalized to an array of strings, or\n * null if the value cannot be interpreted as either.\n *\n * @param {string|string[]|*} value\n *\n * @return {?(string[])} Normalized field value.\n */\nfunction getNormalizedCommaSeparable( value ) {\n\tif ( typeof value === 'string' ) {\n\t\treturn value.split( ',' );\n\t} else if ( Array.isArray( value ) ) {\n\t\treturn value;\n\t}\n\n\treturn null;\n}\n\nexport default getNormalizedCommaSeparable;\n", "/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * A higher-order reducer creator which invokes the original reducer only if\n * the dispatching action matches the given predicate, **OR** if state is\n * initializing (undefined).\n *\n * @param {AnyFunction} isMatch Function predicate for allowing reducer call.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nconst ifMatchingAction = ( isMatch ) => ( reducer ) => ( state, action ) => {\n\tif ( state === undefined || isMatch( action ) ) {\n\t\treturn reducer( state, action );\n\t}\n\n\treturn state;\n};\n\nexport default ifMatchingAction;\n", "/**\n * Higher-order function which forward the resolution to another resolver with the same arguments.\n *\n * @param {string} resolverName forwarded resolver.\n *\n * @return {Function} Enhanced resolver.\n */\nconst forwardResolver =\n\t( resolverName ) =>\n\t( ...args ) =>\n\tasync ( { resolveSelect } ) => {\n\t\tawait resolveSelect[ resolverName ]( ...args );\n\t};\n\nexport default forwardResolver;\n", "/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * Higher-order reducer creator which creates a combined reducer object, keyed\n * by a property on the action object.\n *\n * @param {string} actionProperty Action property by which to key object.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nexport const onSubKey =\n\t( actionProperty ) =>\n\t( reducer ) =>\n\t( state = {}, action ) => {\n\t\t// Retrieve subkey from action. Do not track if undefined; useful for cases\n\t\t// where reducer is scoped by action shape.\n\t\tconst key = action[ actionProperty ];\n\t\tif ( key === undefined ) {\n\t\t\treturn state;\n\t\t}\n\n\t\t// Avoid updating state if unchanged. Note that this also accounts for a\n\t\t// reducer which returns undefined on a key which is not yet tracked.\n\t\tconst nextKeyState = reducer( state[ key ], action );\n\t\tif ( nextKeyState === state[ key ] ) {\n\t\t\treturn state;\n\t\t}\n\n\t\treturn {\n\t\t\t...state,\n\t\t\t[ key ]: nextKeyState,\n\t\t};\n\t};\n\nexport default onSubKey;\n", "/** @typedef {import('../types').AnyFunction} AnyFunction */\n\n/**\n * Higher-order reducer creator which substitutes the action object before\n * passing to the original reducer.\n *\n * @param {AnyFunction} replacer Function mapping original action to replacement.\n *\n * @return {AnyFunction} Higher-order reducer.\n */\nconst replaceAction = ( replacer ) => ( reducer ) => ( state, action ) => {\n\treturn reducer( state, replacer( action ) );\n};\n\nexport default replaceAction;\n", "/**\n * Given a function, returns an enhanced function which caches the result and\n * tracks in WeakMap. The result is only cached if the original function is\n * passed a valid object-like argument (requirement for WeakMap key).\n *\n * @param {Function} fn Original function.\n *\n * @return {Function} Enhanced caching function.\n */\nfunction withWeakMapCache( fn ) {\n\tconst cache = new WeakMap();\n\n\treturn ( key ) => {\n\t\tlet value;\n\t\tif ( cache.has( key ) ) {\n\t\t\tvalue = cache.get( key );\n\t\t} else {\n\t\t\tvalue = fn( key );\n\n\t\t\t// Can reach here if key is not valid for WeakMap, since `has`\n\t\t\t// will return false for invalid key. Since `set` will throw,\n\t\t\t// ensure that key is valid before setting into cache.\n\t\t\tif ( key !== null && typeof key === 'object' ) {\n\t\t\t\tcache.set( key, value );\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t};\n}\n\nexport default withWeakMapCache;\n", "/**\n * Checks whether the attribute is a \"raw\" attribute or not.\n *\n * @param {Object} entity    Entity record.\n * @param {string} attribute Attribute name.\n *\n * @return {boolean} Is the attribute raw\n */\nexport default function isRawAttribute( entity, attribute ) {\n\treturn ( entity.rawAttributes || [] ).includes( attribute );\n}\n", "/**\n * Sets the value at path of object.\n * If a portion of path doesn\u2019t exist, it\u2019s created.\n * Arrays are created for missing index properties while objects are created\n * for all other missing properties.\n *\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n *\n * This function intentionally mutates the input object.\n *\n * Inspired by _.set().\n *\n * @see https://lodash.com/docs/4.17.15#set\n *\n * @todo Needs to be deduplicated with its copy in `@wordpress/edit-site`.\n *\n * @param {Object}       object Object to modify\n * @param {Array|string} path   Path of the property to set.\n * @param {*}            value  Value to set.\n */\nexport default function setNestedValue( object, path, value ) {\n\tif ( ! object || typeof object !== 'object' ) {\n\t\treturn object;\n\t}\n\n\tconst normalizedPath = Array.isArray( path ) ? path : path.split( '.' );\n\n\tnormalizedPath.reduce( ( acc, key, idx ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tif ( Number.isInteger( normalizedPath[ idx + 1 ] ) ) {\n\t\t\t\tacc[ key ] = [];\n\t\t\t} else {\n\t\t\t\tacc[ key ] = {};\n\t\t\t}\n\t\t}\n\t\tif ( idx === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, object );\n\n\treturn object;\n}\n", "/**\n * Helper util to return a value from a certain path of the object.\n * Path is specified as either:\n * - a string of properties, separated by dots, for example: \"x.y\".\n * - an array of properties, for example `[ 'x', 'y' ]`.\n * You can also specify a default value in case the result is nullish.\n *\n * @param {Object}       object       Input object.\n * @param {string|Array} path         Path to the object property.\n * @param {*}            defaultValue Default value if the value at the specified path is undefined.\n * @return {*} Value of the object property at the specified path.\n */\nexport default function getNestedValue( object, path, defaultValue ) {\n\tif (\n\t\t! object ||\n\t\ttypeof object !== 'object' ||\n\t\t( typeof path !== 'string' && ! Array.isArray( path ) )\n\t) {\n\t\treturn object;\n\t}\n\tconst normalizedPath = Array.isArray( path ) ? path : path.split( '.' );\n\tlet value = object;\n\tnormalizedPath.forEach( ( fieldName ) => {\n\t\tvalue = value?.[ fieldName ];\n\t} );\n\treturn value !== undefined ? value : defaultValue;\n}\n", "/**\n * Checks argument to determine if it's a numeric ID.\n * For example, '123' is a numeric ID, but '123abc' is not.\n *\n * @param {any} id the argument to determine if it's a numeric ID.\n * @return {boolean} true if the string is a numeric ID, false otherwise.\n */\nexport default function isNumericID( id ) {\n\treturn /^\\s*\\d+\\s*$/.test( id );\n}\n", "export const ALLOWED_RESOURCE_ACTIONS = [\n\t'create',\n\t'read',\n\t'update',\n\t'delete',\n];\n\nexport function getUserPermissionsFromAllowHeader( allowedMethods ) {\n\tconst permissions = {};\n\tconst methods = {\n\t\tcreate: 'POST',\n\t\tread: 'GET',\n\t\tupdate: 'PUT',\n\t\tdelete: 'DELETE',\n\t};\n\n\tfor ( const [ actionName, methodName ] of Object.entries( methods ) ) {\n\t\tpermissions[ actionName ] = allowedMethods\n\t\t\t? allowedMethods.includes( methodName )\n\t\t\t: false;\n\t}\n\n\treturn permissions;\n}\n\nexport function getUserPermissionCacheKey( action, resource, id ) {\n\tconst key = (\n\t\ttypeof resource === 'object'\n\t\t\t? [ action, resource.kind, resource.name, resource.id ]\n\t\t\t: [ action, resource, id ]\n\t)\n\t\t.filter( Boolean )\n\t\t.join( '/' );\n\n\treturn key;\n}\n", "export const RECEIVE_INTERMEDIATE_RESULTS = Symbol(\n\t'RECEIVE_INTERMEDIATE_RESULTS'\n);\n", "/**\n * Returns a copy of `query` filtered to only the keys that affect resolution\n * identity (`context` and `_fields`), or `undefined` when none are present.\n * This mirrors the normalisation that the data store applies when keying\n * resolved records, so that `finishResolutions` receives args that match the\n * keys used by callers who omit pagination params.\n *\n * @param {Object} query The raw query object.\n * @return {Object|undefined} Normalised query or undefined.\n */\nexport default function normalizeQueryForResolution( query ) {\n\tif ( ! query ) {\n\t\treturn undefined;\n\t}\n\n\tconst entries = Object.entries( query ).filter(\n\t\t( [ k, v ] ) =>\n\t\t\t( k === 'context' || k === '_fields' ) &&\n\t\t\tv !== undefined &&\n\t\t\tv !== null\n\t);\n\treturn entries.length > 0 ? Object.fromEntries( entries ) : undefined;\n}\n", "/**\n * Returns an action object used in signalling that items have been received.\n *\n * @param {Array}   items Items received.\n * @param {?Object} edits Optional edits to reset.\n * @param {?Object} meta  Meta information about pagination.\n *\n * @return {Object} Action object.\n */\nexport function receiveItems( items, edits, meta ) {\n\treturn {\n\t\ttype: 'RECEIVE_ITEMS',\n\t\titems,\n\t\tpersistedEdits: edits,\n\t\tmeta,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been\n * deleted and they need to be removed from entities state.\n *\n * @param {string}              kind            Kind of the removed entities.\n * @param {string}              name            Name of the removed entities.\n * @param {Array|number|string} records         Record IDs of the removed entities.\n * @param {boolean}             invalidateCache Controls whether we want to invalidate the cache.\n * @return {Object} Action object.\n */\nexport function removeItems( kind, name, records, invalidateCache = false ) {\n\treturn {\n\t\ttype: 'REMOVE_ITEMS',\n\t\titemIds: Array.isArray( records ) ? records : [ records ],\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that queried data has been\n * received.\n *\n * @param {Array}   items Queried items received.\n * @param {?Object} query Optional query object.\n * @param {?Object} edits Optional edits to reset.\n * @param {?Object} meta  Meta information about pagination.\n *\n * @return {Object} Action object.\n */\nexport function receiveQueriedItems( items, query = {}, edits, meta ) {\n\treturn {\n\t\t...receiveItems( items, edits, meta ),\n\t\tquery,\n\t};\n}\n", "/**\n * External dependencies\n */\nimport EquivalentKeyMap from 'equivalent-key-map';\n\n/**\n * WordPress dependencies\n */\nimport { createSelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport getQueryParts from './get-query-parts';\nimport { setNestedValue } from '../utils';\n\n/**\n * Cache of state keys to EquivalentKeyMap where the inner map tracks queries\n * to their resulting items set. WeakMap allows garbage collection on expired\n * state references.\n *\n * @type {WeakMap<Object,EquivalentKeyMap>}\n */\nconst queriedItemsCacheByState = new WeakMap();\n\n/**\n * Returns items for a given query, or null if the items are not known.\n *\n * @param {Object}  state State object.\n * @param {?Object} query Optional query.\n *\n * @return {?Array} Query items.\n */\nfunction getQueriedItemsUncached( state, query ) {\n\tconst {\n\t\tstableKey,\n\t\tpage,\n\t\tperPage,\n\t\toffset: queryOffset,\n\t\tinclude,\n\t\tfields,\n\t\tcontext,\n\t} = getQueryParts( query );\n\n\tconst itemIds = state.queries?.[ context ]?.[ stableKey ]?.itemIds;\n\tif ( ! itemIds ) {\n\t\treturn null;\n\t}\n\n\tconst startOffset = perPage === -1 ? 0 : ( page - 1 ) * perPage;\n\tconst endOffset =\n\t\tperPage === -1\n\t\t\t? itemIds.length\n\t\t\t: Math.min( startOffset + perPage, itemIds.length );\n\n\t// If the requested page range exceeds the stored itemIds, the data for\n\t// this specific pagination window may not have been fetched yet. Return\n\t// null unless totalItems confirms we already have all available items.\n\tif ( perPage !== -1 && itemIds.length < startOffset + perPage ) {\n\t\tconst totalItems =\n\t\t\tstate.queries[ context ][ stableKey ].meta?.totalItems;\n\t\tif ( Number.isFinite( totalItems ) ) {\n\t\t\t// For offset-based queries, totalItems (from X-WP-Total)\n\t\t\t// reflects the global count of all matching items, not the\n\t\t\t// count remaining after the offset. The number of items\n\t\t\t// available for this query is (totalItems - offset), so a\n\t\t\t// partial last page is expected and valid.\n\t\t\tconst effectiveTotal =\n\t\t\t\tqueryOffset !== undefined\n\t\t\t\t\t? totalItems - queryOffset\n\t\t\t\t\t: totalItems;\n\t\t\tif ( itemIds.length < effectiveTotal ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst items = [];\n\tfor ( let i = startOffset; i < endOffset; i++ ) {\n\t\tconst itemId = itemIds[ i ];\n\t\tif ( Array.isArray( include ) && ! include.includes( itemId ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( itemId === undefined ) {\n\t\t\tcontinue;\n\t\t}\n\t\t// Having a target item ID doesn't guarantee that this object has been queried.\n\t\tif ( ! state.items[ context ]?.hasOwnProperty( itemId ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst item = state.items[ context ][ itemId ];\n\n\t\tlet filteredItem;\n\t\tif ( Array.isArray( fields ) ) {\n\t\t\tfilteredItem = {};\n\n\t\t\tfor ( let f = 0; f < fields.length; f++ ) {\n\t\t\t\tconst field = fields[ f ].split( '.' );\n\t\t\t\tlet value = item;\n\t\t\t\tfield.forEach( ( fieldName ) => {\n\t\t\t\t\tvalue = value?.[ fieldName ];\n\t\t\t\t} );\n\n\t\t\t\tsetNestedValue( filteredItem, field, value );\n\t\t\t}\n\t\t} else {\n\t\t\t// If expecting a complete item, validate that completeness, or\n\t\t\t// otherwise abort.\n\t\t\tif ( ! state.itemIsComplete[ context ]?.[ itemId ] ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tfilteredItem = item;\n\t\t}\n\n\t\titems.push( filteredItem );\n\t}\n\n\treturn items;\n}\n\n/**\n * Returns items for a given query, or null if the items are not known. Caches\n * result both per state (by reference) and per query (by deep equality).\n * The caching approach is intended to be durable to query objects which are\n * deeply but not referentially equal, since otherwise:\n *\n * `getQueriedItems( state, {} ) !== getQueriedItems( state, {} )`\n *\n * @param {Object}  state State object.\n * @param {?Object} query Optional query.\n *\n * @return {?Array} Query items.\n */\nexport const getQueriedItems = createSelector( ( state, query = {} ) => {\n\tlet queriedItemsCache = queriedItemsCacheByState.get( state );\n\tif ( queriedItemsCache ) {\n\t\tconst queriedItems = queriedItemsCache.get( query );\n\t\tif ( queriedItems !== undefined ) {\n\t\t\treturn queriedItems;\n\t\t}\n\t} else {\n\t\tqueriedItemsCache = new EquivalentKeyMap();\n\t\tqueriedItemsCacheByState.set( state, queriedItemsCache );\n\t}\n\n\tconst items = getQueriedItemsUncached( state, query );\n\tqueriedItemsCache.set( query, items );\n\treturn items;\n} );\n\nexport function getQueriedTotalItems( state, query = {} ) {\n\tconst { stableKey, context } = getQueryParts( query );\n\n\treturn state.queries?.[ context ]?.[ stableKey ]?.meta?.totalItems ?? null;\n}\n\nexport function getQueriedTotalPages( state, query = {} ) {\n\tconst { stableKey, context } = getQueryParts( query );\n\n\treturn state.queries?.[ context ]?.[ stableKey ]?.meta?.totalPages ?? null;\n}\n", "/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { withWeakMapCache, getNormalizedCommaSeparable } from '../utils';\n\n/**\n * An object of properties describing a specific query.\n *\n * @typedef {Object} WPQueriedDataQueryParts\n *\n * @property {number}      page      The query page (1-based index, default 1).\n * @property {number}      perPage   Items per page for query (default 10).\n * @property {number}      offset    Absolute item offset (default undefined).\n *                                   When present, also encoded into stableKey.\n * @property {string}      stableKey An encoded stable string of all non-\n *                                   pagination, non-fields query parameters.\n * @property {?(string[])} fields    Target subset of fields to derive from\n *                                   item objects.\n * @property {?(number[])} include   Specific item IDs to include.\n * @property {string}      context   Scope under which the request is made;\n *                                   determines returned fields in response.\n */\n\n/**\n * Given a query object, returns an object of parts, including pagination\n * details (`page` and `perPage`, or default values). All other properties are\n * encoded into a stable (idempotent) `stableKey` value.\n *\n * @param {Object} query Optional query object.\n *\n * @return {WPQueriedDataQueryParts} Query parts.\n */\nexport function getQueryParts( query ) {\n\t/**\n\t * @type {WPQueriedDataQueryParts}\n\t */\n\tconst parts = {\n\t\tstableKey: '',\n\t\tpage: 1,\n\t\tperPage: 10,\n\t\toffset: undefined,\n\t\tfields: null,\n\t\tinclude: null,\n\t\tcontext: 'default',\n\t};\n\n\t// Ensure stable key by sorting keys. Also more efficient for iterating.\n\tconst keys = Object.keys( query ).sort();\n\n\tfor ( let i = 0; i < keys.length; i++ ) {\n\t\tconst key = keys[ i ];\n\t\tlet value = query[ key ];\n\n\t\tswitch ( key ) {\n\t\t\tcase 'page':\n\t\t\t\tparts[ key ] = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'per_page':\n\t\t\t\tparts.perPage = Number( value );\n\t\t\t\tbreak;\n\n\t\t\tcase 'context':\n\t\t\t\tparts.context = value;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// Extract offset for use in pagination calculations while\n\t\t\t\t// still including it in the stableKey (different offsets\n\t\t\t\t// produce different result sets).\n\t\t\t\tif ( key === 'offset' ) {\n\t\t\t\t\tconst numericOffset = Number( value );\n\t\t\t\t\tif ( Number.isFinite( numericOffset ) ) {\n\t\t\t\t\t\tparts.offset = numericOffset;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// While in theory, we could exclude \"_fields\" from the stableKey\n\t\t\t\t// because two request with different fields have the same results\n\t\t\t\t// We're not able to ensure that because the server can decide to omit\n\t\t\t\t// fields from the response even if we explicitly asked for it.\n\t\t\t\t// Example: Asking for titles in posts without title support.\n\t\t\t\tif ( key === '_fields' ) {\n\t\t\t\t\tparts.fields = getNormalizedCommaSeparable( value ) ?? [];\n\t\t\t\t\t// Make sure to normalize value for `stableKey`\n\t\t\t\t\tvalue = parts.fields.join();\n\t\t\t\t}\n\n\t\t\t\t// Two requests with different include values cannot have same results.\n\t\t\t\tif ( key === 'include' ) {\n\t\t\t\t\tif ( typeof value === 'number' ) {\n\t\t\t\t\t\tvalue = value.toString();\n\t\t\t\t\t}\n\t\t\t\t\tparts.include = (\n\t\t\t\t\t\tgetNormalizedCommaSeparable( value ) ?? []\n\t\t\t\t\t).map( Number );\n\t\t\t\t\t// Normalize value for `stableKey`.\n\t\t\t\t\tvalue = parts.include.join();\n\t\t\t\t}\n\n\t\t\t\t// While it could be any deterministic string, for simplicity's\n\t\t\t\t// sake mimic querystring encoding for stable key.\n\t\t\t\t//\n\t\t\t\t// TODO: For consistency with PHP implementation, addQueryArgs\n\t\t\t\t// should accept a key value pair, which may optimize its\n\t\t\t\t// implementation for our use here, vs. iterating an object\n\t\t\t\t// with only a single key.\n\t\t\t\tparts.stableKey +=\n\t\t\t\t\t( parts.stableKey ? '&' : '' ) +\n\t\t\t\t\taddQueryArgs( '', { [ key ]: value } ).slice( 1 );\n\t\t}\n\t}\n\n\treturn parts;\n}\n\nexport default withWeakMapCache( getQueryParts );\n", "/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tconservativeMapItem,\n\tifMatchingAction,\n\treplaceAction,\n\tonSubKey,\n} from '../utils';\nimport { DEFAULT_ENTITY_KEY } from '../entities';\nimport getQueryParts from './get-query-parts';\n\nfunction getContextFromAction( action ) {\n\tconst { query } = action;\n\tif ( ! query ) {\n\t\treturn 'default';\n\t}\n\n\tconst queryParts = getQueryParts( query );\n\treturn queryParts.context;\n}\n\n/**\n * Returns a merged array of item IDs, given details of the received paginated\n * items. The array is sparse-like with `undefined` entries where holes exist.\n *\n * @param {?Array<number>} itemIds     Original item IDs (default empty array).\n * @param {number[]}       nextItemIds Item IDs to merge.\n * @param {number}         page        Page of items merged.\n * @param {number}         perPage     Number of items per page.\n *\n * @return {number[]} Merged array of item IDs.\n */\nexport function getMergedItemIds( itemIds, nextItemIds, page, perPage ) {\n\tconst receivedAllIds = page === 1 && perPage === -1;\n\tif ( receivedAllIds ) {\n\t\treturn nextItemIds;\n\t}\n\tconst nextItemIdsStartIndex = ( page - 1 ) * perPage;\n\n\t// If later page has already been received, default to the larger known\n\t// size of the existing array, else calculate as extending the existing.\n\tconst size = Math.max(\n\t\titemIds?.length ?? 0,\n\t\tnextItemIdsStartIndex + nextItemIds.length\n\t);\n\n\t// Preallocate array since size is known.\n\tconst mergedItemIds = new Array( size );\n\n\tfor ( let i = 0; i < size; i++ ) {\n\t\t// Preserve existing item ID except for subset of range of next items.\n\t\t// We need to check against the possible maximum upper boundary because\n\t\t// a page could receive fewer than what was previously stored.\n\t\tconst isInNextItemsRange =\n\t\t\ti >= nextItemIdsStartIndex && i < nextItemIdsStartIndex + perPage;\n\t\tmergedItemIds[ i ] = isInNextItemsRange\n\t\t\t? nextItemIds[ i - nextItemIdsStartIndex ]\n\t\t\t: itemIds?.[ i ];\n\t}\n\n\treturn mergedItemIds;\n}\n\n/**\n * Helper function to filter out entities with certain IDs.\n * Entities are keyed by their ID.\n *\n * @param {Object} entities Entity objects, keyed by entity ID.\n * @param {Array}  ids      Entity IDs to filter out.\n *\n * @return {Object} Filtered entities.\n */\nfunction removeEntitiesById( entities, ids ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( entities ).filter(\n\t\t\t( [ id ] ) =>\n\t\t\t\t! ids.some( ( itemId ) => {\n\t\t\t\t\tif ( Number.isInteger( itemId ) ) {\n\t\t\t\t\t\treturn itemId === +id;\n\t\t\t\t\t}\n\t\t\t\t\treturn itemId === id;\n\t\t\t\t} )\n\t\t)\n\t);\n}\n\n/**\n * Reducer tracking items state, keyed by ID. Items are assumed to be normal,\n * where identifiers are common across all queries.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nexport function items( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS': {\n\t\t\tconst context = getContextFromAction( action );\n\t\t\tconst key = action.key || DEFAULT_ENTITY_KEY;\n\t\t\tconst itemsList = Array.isArray( action.items )\n\t\t\t\t? action.items\n\t\t\t\t: [ action.items ];\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ context ]: {\n\t\t\t\t\t...state[ context ],\n\t\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t\titemsList.map( ( item ) => [\n\t\t\t\t\t\t\titem?.[ key ],\n\t\t\t\t\t\t\tconservativeMapItem(\n\t\t\t\t\t\t\t\tstate?.[ context ]?.[ item?.[ key ] ],\n\t\t\t\t\t\t\t\titem\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t] )\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase 'REMOVE_ITEMS':\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map( ( [ itemId, contextState ] ) => [\n\t\t\t\t\titemId,\n\t\t\t\t\tremoveEntitiesById( contextState, action.itemIds ),\n\t\t\t\t] )\n\t\t\t);\n\t}\n\treturn state;\n}\n\n/**\n * Reducer tracking item completeness, keyed by ID. A complete item is one for\n * which all fields are known. This is used in supporting `_fields` queries,\n * where not all properties associated with an entity are necessarily returned.\n * In such cases, completeness is used as an indication of whether it would be\n * safe to use queried data for a non-`_fields`-limited request.\n *\n * @param {Object<string,Object<string,boolean>>} state  Current state.\n * @param {Object}                                action Dispatched action.\n *\n * @return {Object<string,Object<string,boolean>>} Next state.\n */\nexport function itemIsComplete( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS': {\n\t\t\tconst context = getContextFromAction( action );\n\t\t\tconst { query, key = DEFAULT_ENTITY_KEY } = action;\n\t\t\tconst itemsList = Array.isArray( action.items )\n\t\t\t\t? action.items\n\t\t\t\t: [ action.items ];\n\n\t\t\t// An item is considered complete if it is received without an associated\n\t\t\t// fields query. Ideally, this would be implemented in such a way where the\n\t\t\t// complete aggregate of all fields would satisfy completeness. Since the\n\t\t\t// fields are not consistent across all entities, this would require\n\t\t\t// introspection on the REST schema for each entity to know which fields\n\t\t\t// compose a complete item for that entity.\n\t\t\tconst queryParts = query ? getQueryParts( query ) : {};\n\t\t\tconst isCompleteQuery =\n\t\t\t\t! query || ! Array.isArray( queryParts.fields );\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ context ]: {\n\t\t\t\t\t...state[ context ],\n\t\t\t\t\t...itemsList.reduce( ( result, item ) => {\n\t\t\t\t\t\tconst itemId = item?.[ key ];\n\n\t\t\t\t\t\t// Defer to completeness if already assigned. Technically the\n\t\t\t\t\t\t// data may be outdated if receiving items for a field subset.\n\t\t\t\t\t\tresult[ itemId ] =\n\t\t\t\t\t\t\tstate?.[ context ]?.[ itemId ] || isCompleteQuery;\n\n\t\t\t\t\t\treturn result;\n\t\t\t\t\t}, {} ),\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tcase 'REMOVE_ITEMS':\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map( ( [ itemId, contextState ] ) => [\n\t\t\t\t\titemId,\n\t\t\t\t\tremoveEntitiesById( contextState, action.itemIds ),\n\t\t\t\t] )\n\t\t\t);\n\t}\n\n\treturn state;\n}\n\n/**\n * Reducer tracking queries state, keyed by stable query key. Each reducer\n * query object includes `itemIds` and `requestingPageByPerPage`.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nconst receiveQueries = compose( [\n\t// Limit to matching action type so we don't attempt to replace action on\n\t// an unhandled action.\n\tifMatchingAction( ( action ) => 'query' in action ),\n\n\t// Inject query parts into action for use both in `onSubKey` and reducer.\n\treplaceAction( ( action ) => {\n\t\t// `ifMatchingAction` still passes on initialization, where state is\n\t\t// undefined and a query is not assigned. Avoid attempting to parse\n\t\t// parts. `onSubKey` will omit by lack of `stableKey`.\n\t\tif ( action.query ) {\n\t\t\treturn {\n\t\t\t\t...action,\n\t\t\t\t...getQueryParts( action.query ),\n\t\t\t};\n\t\t}\n\n\t\treturn action;\n\t} ),\n\n\tonSubKey( 'context' ),\n\n\t// Queries shape is shared, but keyed by query `stableKey` part. Original\n\t// reducer tracks only a single query object.\n\tonSubKey( 'stableKey' ),\n] )( ( state = {}, action ) => {\n\tif ( action.type !== 'RECEIVE_ITEMS' ) {\n\t\treturn state;\n\t}\n\n\t// Single items don't have page or total count metadata\n\t// (only collection query responses do), so skip updating itemIds.\n\tif ( ! Array.isArray( action.items ) ) {\n\t\treturn state;\n\t}\n\n\tconst key = action.key ?? DEFAULT_ENTITY_KEY;\n\n\treturn {\n\t\titemIds: getMergedItemIds(\n\t\t\tstate?.itemIds || [],\n\t\t\taction.items.map( ( item ) => item?.[ key ] ).filter( Boolean ),\n\t\t\taction.page,\n\t\t\taction.perPage\n\t\t),\n\t\tmeta: action.meta,\n\t};\n} );\n\n/**\n * Reducer tracking queries state.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Next state.\n */\nconst queries = ( state = {}, action ) => {\n\tswitch ( action.type ) {\n\t\tcase 'RECEIVE_ITEMS':\n\t\t\treturn receiveQueries( state, action );\n\t\tcase 'REMOVE_ITEMS':\n\t\t\tconst removedItems = action.itemIds.reduce( ( result, itemId ) => {\n\t\t\t\tresult[ itemId ] = true;\n\t\t\t\treturn result;\n\t\t\t}, {} );\n\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries( state ).map(\n\t\t\t\t\t( [ queryGroup, contextQueries ] ) => [\n\t\t\t\t\t\tqueryGroup,\n\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\tObject.entries( contextQueries ).map(\n\t\t\t\t\t\t\t\t( [ query, queryItems ] ) => [\n\t\t\t\t\t\t\t\t\tquery,\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t...queryItems,\n\t\t\t\t\t\t\t\t\t\titemIds: queryItems.itemIds.filter(\n\t\t\t\t\t\t\t\t\t\t\t( queryId ) =>\n\t\t\t\t\t\t\t\t\t\t\t\t! removedItems[ queryId ]\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t)\n\t\t\t);\n\t\tdefault:\n\t\t\treturn state;\n\t}\n};\n\nexport default combineReducers( {\n\titems,\n\titemIsComplete,\n\tqueries,\n} );\n", "/******************************************************************************\nCopyright (c) Microsoft Corporation.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n***************************************************************************** */\n/* global Reflect, Promise, SuppressedError, Symbol, Iterator */\n\nvar extendStatics = function(d, b) {\n  extendStatics = Object.setPrototypeOf ||\n      ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n      function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n  return extendStatics(d, b);\n};\n\nexport function __extends(d, b) {\n  if (typeof b !== \"function\" && b !== null)\n      throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n  extendStatics(d, b);\n  function __() { this.constructor = d; }\n  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n}\n\nexport var __assign = function() {\n  __assign = Object.assign || function __assign(t) {\n      for (var s, i = 1, n = arguments.length; i < n; i++) {\n          s = arguments[i];\n          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n      }\n      return t;\n  }\n  return __assign.apply(this, arguments);\n}\n\nexport function __rest(s, e) {\n  var t = {};\n  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n      t[p] = s[p];\n  if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n      for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n          if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n              t[p[i]] = s[p[i]];\n      }\n  return t;\n}\n\nexport function __decorate(decorators, target, key, desc) {\n  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n  if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n  return c > 3 && r && Object.defineProperty(target, key, r), r;\n}\n\nexport function __param(paramIndex, decorator) {\n  return function (target, key) { decorator(target, key, paramIndex); }\n}\n\nexport function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {\n  function accept(f) { if (f !== void 0 && typeof f !== \"function\") throw new TypeError(\"Function expected\"); return f; }\n  var kind = contextIn.kind, key = kind === \"getter\" ? \"get\" : kind === \"setter\" ? \"set\" : \"value\";\n  var target = !descriptorIn && ctor ? contextIn[\"static\"] ? ctor : ctor.prototype : null;\n  var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});\n  var _, done = false;\n  for (var i = decorators.length - 1; i >= 0; i--) {\n      var context = {};\n      for (var p in contextIn) context[p] = p === \"access\" ? {} : contextIn[p];\n      for (var p in contextIn.access) context.access[p] = contextIn.access[p];\n      context.addInitializer = function (f) { if (done) throw new TypeError(\"Cannot add initializers after decoration has completed\"); extraInitializers.push(accept(f || null)); };\n      var result = (0, decorators[i])(kind === \"accessor\" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);\n      if (kind === \"accessor\") {\n          if (result === void 0) continue;\n          if (result === null || typeof result !== \"object\") throw new TypeError(\"Object expected\");\n          if (_ = accept(result.get)) descriptor.get = _;\n          if (_ = accept(result.set)) descriptor.set = _;\n          if (_ = accept(result.init)) initializers.unshift(_);\n      }\n      else if (_ = accept(result)) {\n          if (kind === \"field\") initializers.unshift(_);\n          else descriptor[key] = _;\n      }\n  }\n  if (target) Object.defineProperty(target, contextIn.name, descriptor);\n  done = true;\n};\n\nexport function __runInitializers(thisArg, initializers, value) {\n  var useValue = arguments.length > 2;\n  for (var i = 0; i < initializers.length; i++) {\n      value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);\n  }\n  return useValue ? value : void 0;\n};\n\nexport function __propKey(x) {\n  return typeof x === \"symbol\" ? x : \"\".concat(x);\n};\n\nexport function __setFunctionName(f, name, prefix) {\n  if (typeof name === \"symbol\") name = name.description ? \"[\".concat(name.description, \"]\") : \"\";\n  return Object.defineProperty(f, \"name\", { configurable: true, value: prefix ? \"\".concat(prefix, \" \", name) : name });\n};\n\nexport function __metadata(metadataKey, metadataValue) {\n  if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\n}\n\nexport function __awaiter(thisArg, _arguments, P, generator) {\n  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n  return new (P || (P = Promise))(function (resolve, reject) {\n      function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n      function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n      function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n      step((generator = generator.apply(thisArg, _arguments || [])).next());\n  });\n}\n\nexport function __generator(thisArg, body) {\n  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);\n  return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n  function verb(n) { return function (v) { return step([n, v]); }; }\n  function step(op) {\n      if (f) throw new TypeError(\"Generator is already executing.\");\n      while (g && (g = 0, op[0] && (_ = 0)), _) try {\n          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;\n          if (y = 0, t) op = [op[0] & 2, t.value];\n          switch (op[0]) {\n              case 0: case 1: t = op; break;\n              case 4: _.label++; return { value: op[1], done: false };\n              case 5: _.label++; y = op[1]; op = [0]; continue;\n              case 7: op = _.ops.pop(); _.trys.pop(); continue;\n              default:\n                  if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n                  if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n                  if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n                  if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n                  if (t[2]) _.ops.pop();\n                  _.trys.pop(); continue;\n          }\n          op = body.call(thisArg, _);\n      } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n      if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n  }\n}\n\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\n  if (k2 === undefined) k2 = k;\n  var desc = Object.getOwnPropertyDescriptor(m, k);\n  if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n      desc = { enumerable: true, get: function() { return m[k]; } };\n  }\n  Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n  if (k2 === undefined) k2 = k;\n  o[k2] = m[k];\n});\n\nexport function __exportStar(m, o) {\n  for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\n}\n\nexport function __values(o) {\n  var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\n  if (m) return m.call(o);\n  if (o && typeof o.length === \"number\") return {\n      next: function () {\n          if (o && i >= o.length) o = void 0;\n          return { value: o && o[i++], done: !o };\n      }\n  };\n  throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\n}\n\nexport function __read(o, n) {\n  var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n  if (!m) return o;\n  var i = m.call(o), r, ar = [], e;\n  try {\n      while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n  }\n  catch (error) { e = { error: error }; }\n  finally {\n      try {\n          if (r && !r.done && (m = i[\"return\"])) m.call(i);\n      }\n      finally { if (e) throw e.error; }\n  }\n  return ar;\n}\n\n/** @deprecated */\nexport function __spread() {\n  for (var ar = [], i = 0; i < arguments.length; i++)\n      ar = ar.concat(__read(arguments[i]));\n  return ar;\n}\n\n/** @deprecated */\nexport function __spreadArrays() {\n  for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n  for (var r = Array(s), k = 0, i = 0; i < il; i++)\n      for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n          r[k] = a[j];\n  return r;\n}\n\nexport function __spreadArray(to, from, pack) {\n  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n      if (ar || !(i in from)) {\n          if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n          ar[i] = from[i];\n      }\n  }\n  return to.concat(ar || Array.prototype.slice.call(from));\n}\n\nexport function __await(v) {\n  return this instanceof __await ? (this.v = v, this) : new __await(v);\n}\n\nexport function __asyncGenerator(thisArg, _arguments, generator) {\n  if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n  var g = generator.apply(thisArg, _arguments || []), i, q = [];\n  return i = Object.create((typeof AsyncIterator === \"function\" ? AsyncIterator : Object).prototype), verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n  function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n  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]); } }\n  function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n  function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n  function fulfill(value) { resume(\"next\", value); }\n  function reject(value) { resume(\"throw\", value); }\n  function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n}\n\nexport function __asyncDelegator(o) {\n  var i, p;\n  return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n  function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n}\n\nexport function __asyncValues(o) {\n  if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n  var m = o[Symbol.asyncIterator], i;\n  return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n}\n\nexport function __makeTemplateObject(cooked, raw) {\n  if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n  return cooked;\n};\n\nvar __setModuleDefault = Object.create ? (function(o, v) {\n  Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n  o[\"default\"] = v;\n};\n\nvar ownKeys = function(o) {\n  ownKeys = Object.getOwnPropertyNames || function (o) {\n    var ar = [];\n    for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;\n    return ar;\n  };\n  return ownKeys(o);\n};\n\nexport function __importStar(mod) {\n  if (mod && mod.__esModule) return mod;\n  var result = {};\n  if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== \"default\") __createBinding(result, mod, k[i]);\n  __setModuleDefault(result, mod);\n  return result;\n}\n\nexport function __importDefault(mod) {\n  return (mod && mod.__esModule) ? mod : { default: mod };\n}\n\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\n  if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n  if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n  return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n}\n\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\n  if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n  if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n  if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n  return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n}\n\nexport function __classPrivateFieldIn(state, receiver) {\n  if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\n  return typeof state === \"function\" ? receiver === state : state.has(receiver);\n}\n\nexport function __addDisposableResource(env, value, async) {\n  if (value !== null && value !== void 0) {\n    if (typeof value !== \"object\" && typeof value !== \"function\") throw new TypeError(\"Object expected.\");\n    var dispose, inner;\n    if (async) {\n      if (!Symbol.asyncDispose) throw new TypeError(\"Symbol.asyncDispose is not defined.\");\n      dispose = value[Symbol.asyncDispose];\n    }\n    if (dispose === void 0) {\n      if (!Symbol.dispose) throw new TypeError(\"Symbol.dispose is not defined.\");\n      dispose = value[Symbol.dispose];\n      if (async) inner = dispose;\n    }\n    if (typeof dispose !== \"function\") throw new TypeError(\"Object not disposable.\");\n    if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };\n    env.stack.push({ value: value, dispose: dispose, async: async });\n  }\n  else if (async) {\n    env.stack.push({ async: true });\n  }\n  return value;\n}\n\nvar _SuppressedError = typeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\n  var e = new Error(message);\n  return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\n};\n\nexport function __disposeResources(env) {\n  function fail(e) {\n    env.error = env.hasError ? new _SuppressedError(e, env.error, \"An error was suppressed during disposal.\") : e;\n    env.hasError = true;\n  }\n  var r, s = 0;\n  function next() {\n    while (r = env.stack.pop()) {\n      try {\n        if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);\n        if (r.dispose) {\n          var result = r.dispose.call(r.value);\n          if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });\n        }\n        else s |= 1;\n      }\n      catch (e) {\n        fail(e);\n      }\n    }\n    if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();\n    if (env.hasError) throw env.error;\n  }\n  return next();\n}\n\nexport function __rewriteRelativeImportExtension(path, preserveJsx) {\n  if (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) {\n      return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {\n          return tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : (d + ext + \".\" + cm.toLowerCase() + \"js\");\n      });\n  }\n  return path;\n}\n\nexport default {\n  __extends,\n  __assign,\n  __rest,\n  __decorate,\n  __param,\n  __esDecorate,\n  __runInitializers,\n  __propKey,\n  __setFunctionName,\n  __metadata,\n  __awaiter,\n  __generator,\n  __createBinding,\n  __exportStar,\n  __values,\n  __read,\n  __spread,\n  __spreadArrays,\n  __spreadArray,\n  __await,\n  __asyncGenerator,\n  __asyncDelegator,\n  __asyncValues,\n  __makeTemplateObject,\n  __importStar,\n  __importDefault,\n  __classPrivateFieldGet,\n  __classPrivateFieldSet,\n  __classPrivateFieldIn,\n  __addDisposableResource,\n  __disposeResources,\n  __rewriteRelativeImportExtension,\n};\n", "/**\n * Locale character mapping rules.\n */\ninterface Locale {\n  regexp: RegExp;\n  map: Record<string, string>;\n}\n\n/**\n * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt\n */\nconst SUPPORTED_LOCALE: Record<string, Locale> = {\n  tr: {\n    regexp: /\\u0130|\\u0049|\\u0049\\u0307/g,\n    map: {\n      İ: \"\\u0069\",\n      I: \"\\u0131\",\n      İ: \"\\u0069\",\n    },\n  },\n  az: {\n    regexp: /\\u0130/g,\n    map: {\n      İ: \"\\u0069\",\n      I: \"\\u0131\",\n      İ: \"\\u0069\",\n    },\n  },\n  lt: {\n    regexp: /\\u0049|\\u004A|\\u012E|\\u00CC|\\u00CD|\\u0128/g,\n    map: {\n      I: \"\\u0069\\u0307\",\n      J: \"\\u006A\\u0307\",\n      Į: \"\\u012F\\u0307\",\n      Ì: \"\\u0069\\u0307\\u0300\",\n      Í: \"\\u0069\\u0307\\u0301\",\n      Ĩ: \"\\u0069\\u0307\\u0303\",\n    },\n  },\n};\n\n/**\n * Localized lower case.\n */\nexport function localeLowerCase(str: string, locale: string) {\n  const lang = SUPPORTED_LOCALE[locale.toLowerCase()];\n  if (lang) return lowerCase(str.replace(lang.regexp, (m) => lang.map[m]));\n  return lowerCase(str);\n}\n\n/**\n * Lower case as a function.\n */\nexport function lowerCase(str: string) {\n  return str.toLowerCase();\n}\n", "import { lowerCase } from \"lower-case\";\n\nexport interface Options {\n  splitRegexp?: RegExp | RegExp[];\n  stripRegexp?: RegExp | RegExp[];\n  delimiter?: string;\n  transform?: (part: string, index: number, parts: string[]) => string;\n}\n\n// Support camel case (\"camelCase\" -> \"camel Case\" and \"CAMELCase\" -> \"CAMEL Case\").\nconst DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];\n\n// Remove all non-word characters.\nconst DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;\n\n/**\n * Normalize the string into something other libraries can manipulate easier.\n */\nexport function noCase(input: string, options: Options = {}) {\n  const {\n    splitRegexp = DEFAULT_SPLIT_REGEXP,\n    stripRegexp = DEFAULT_STRIP_REGEXP,\n    transform = lowerCase,\n    delimiter = \" \",\n  } = options;\n\n  let result = replace(\n    replace(input, splitRegexp, \"$1\\0$2\"),\n    stripRegexp,\n    \"\\0\"\n  );\n  let start = 0;\n  let end = result.length;\n\n  // Trim the delimiter from around the output string.\n  while (result.charAt(start) === \"\\0\") start++;\n  while (result.charAt(end - 1) === \"\\0\") end--;\n\n  // Transform each token independently.\n  return result.slice(start, end).split(\"\\0\").map(transform).join(delimiter);\n}\n\n/**\n * Replace `re` in the input string with the replacement value.\n */\nfunction replace(input: string, re: RegExp | RegExp[], value: string) {\n  if (re instanceof RegExp) return input.replace(re, value);\n  return re.reduce((input, re) => input.replace(re, value), input);\n}\n", "import { noCase, Options } from \"no-case\";\n\nexport { Options };\n\nexport function pascalCaseTransform(input: string, index: number) {\n  const firstChar = input.charAt(0);\n  const lowerChars = input.substr(1).toLowerCase();\n  if (index > 0 && firstChar >= \"0\" && firstChar <= \"9\") {\n    return `_${firstChar}${lowerChars}`;\n  }\n  return `${firstChar.toUpperCase()}${lowerChars}`;\n}\n\nexport function pascalCaseTransformMerge(input: string) {\n  return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();\n}\n\nexport function pascalCase(input: string, options: Options = {}) {\n  return noCase(input, {\n    delimiter: \"\",\n    transform: pascalCaseTransform,\n    ...options,\n  });\n}\n", "import {\n  pascalCase,\n  pascalCaseTransform,\n  pascalCaseTransformMerge,\n  Options,\n} from \"pascal-case\";\n\nexport { Options };\n\nexport function camelCaseTransform(input: string, index: number) {\n  if (index === 0) return input.toLowerCase();\n  return pascalCaseTransform(input, index);\n}\n\nexport function camelCaseTransformMerge(input: string, index: number) {\n  if (index === 0) return input.toLowerCase();\n  return pascalCaseTransformMerge(input);\n}\n\nexport function camelCase(input: string, options: Options = {}) {\n  return pascalCase(input, {\n    transform: camelCaseTransform,\n    ...options,\n  });\n}\n", "/**\n * Upper case the first character of an input string.\n */\nexport function upperCaseFirst(input: string) {\n  return input.charAt(0).toUpperCase() + input.substr(1);\n}\n", "import { noCase, Options } from \"no-case\";\nimport { upperCaseFirst } from \"upper-case-first\";\n\nexport { Options };\n\nexport function capitalCaseTransform(input: string) {\n  return upperCaseFirst(input.toLowerCase());\n}\n\nexport function capitalCase(input: string, options: Options = {}) {\n  return noCase(input, {\n    delimiter: \" \",\n    transform: capitalCaseTransform,\n    ...options,\n  });\n}\n", "/**\n * External dependencies\n */\nimport { capitalCase, pascalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { __unstableSerializeAndClean, parse } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { PostEditorAwareness } from './awareness/post-editor-awareness';\nimport { getSyncManager } from './sync';\nimport {\n\tapplyPostChangesToCRDTDoc,\n\tdefaultSyncConfig,\n\tgetPostChangesFromCRDTDoc,\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n} from './utils/crdt';\n\nexport const DEFAULT_ENTITY_KEY = 'id';\nconst POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];\n\nconst blocksTransientEdits = {\n\tblocks: {\n\t\tread: ( record ) => parse( record.content?.raw ?? '' ),\n\t\twrite: ( record ) => ( {\n\t\t\tcontent: __unstableSerializeAndClean( record.blocks ),\n\t\t} ),\n\t},\n};\n\nexport const rootEntitiesConfig = [\n\t{\n\t\tlabel: __( 'Base' ),\n\t\tkind: 'root',\n\t\tkey: false,\n\t\tname: '__unstableBase',\n\t\tbaseURL: '/',\n\t\tbaseURLParams: {\n\t\t\t// Please also change the preload path when changing this.\n\t\t\t// @see lib/compat/wordpress-7.0/preload.php\n\t\t\t_fields: [\n\t\t\t\t'description',\n\t\t\t\t'gmt_offset',\n\t\t\t\t'home',\n\t\t\t\t'image_sizes',\n\t\t\t\t'image_size_threshold',\n\t\t\t\t'image_output_formats',\n\t\t\t\t'jpeg_interlaced',\n\t\t\t\t'png_interlaced',\n\t\t\t\t'gif_interlaced',\n\t\t\t\t'name',\n\t\t\t\t'site_icon',\n\t\t\t\t'site_icon_url',\n\t\t\t\t'site_logo',\n\t\t\t\t'timezone_string',\n\t\t\t\t'url',\n\t\t\t\t'page_for_posts',\n\t\t\t\t'page_on_front',\n\t\t\t\t'show_on_front',\n\t\t\t].join( ',' ),\n\t\t},\n\t\t// The entity doesn't support selecting multiple records.\n\t\t// The property is maintained for backward compatibility.\n\t\tplural: '__unstableBases',\n\t},\n\t{\n\t\tlabel: __( 'Post Type' ),\n\t\tname: 'postType',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'postTypes',\n\t},\n\t{\n\t\tname: 'media',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/media',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'mediaItems',\n\t\tlabel: __( 'Media' ),\n\t\trawAttributes: [ 'caption', 'title', 'description' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'taxonomy',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/taxonomies',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'taxonomies',\n\t\tlabel: __( 'Taxonomy' ),\n\t},\n\t{\n\t\tname: 'sidebar',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/sidebars',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'sidebars',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widget areas' ),\n\t},\n\t{\n\t\tname: 'widget',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widgets',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgets',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widgets' ),\n\t},\n\t{\n\t\tname: 'widgetType',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widget-types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgetTypes',\n\t\tlabel: __( 'Widget types' ),\n\t},\n\t{\n\t\tlabel: __( 'User' ),\n\t\tname: 'user',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/users',\n\t\tgetTitle: ( record ) => record?.name || record?.slug,\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'users',\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'comment',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/comments',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'comments',\n\t\tlabel: __( 'Comment' ),\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menu',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menus',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menus',\n\t\tlabel: __( 'Menu' ),\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menuItem',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-items',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuItems',\n\t\tlabel: __( 'Menu Item' ),\n\t\trawAttributes: [ 'title' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'menuLocation',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-locations',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuLocations',\n\t\tlabel: __( 'Menu Location' ),\n\t\tkey: 'name',\n\t},\n\t{\n\t\tlabel: __( 'Global Styles' ),\n\t\tname: 'globalStyles',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/global-styles',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'globalStylesVariations', // Should be different from name.\n\t\tgetTitle: () => __( 'Custom Styles' ),\n\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t`/wp/v2/global-styles/${ parentId }/revisions${\n\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t}`,\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tlabel: __( 'Themes' ),\n\t\tname: 'theme',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/themes',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'themes',\n\t\tkey: 'stylesheet',\n\t},\n\t{\n\t\tlabel: __( 'Plugins' ),\n\t\tname: 'plugin',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/plugins',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'plugins',\n\t\tkey: 'plugin',\n\t},\n\t{\n\t\tlabel: __( 'Status' ),\n\t\tname: 'status',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/statuses',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'statuses',\n\t\tkey: 'slug',\n\t},\n\t{\n\t\tlabel: __( 'Registered Templates' ),\n\t\tname: 'registeredTemplate',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/registered-templates',\n\t\tkey: 'id',\n\t},\n\t{\n\t\tlabel: __( 'Font Collections' ),\n\t\tname: 'fontCollection',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/font-collections',\n\t\tbaseURLParams: { context: 'view' },\n\t\tplural: 'fontCollections',\n\t\tkey: 'slug',\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tlabel: __( 'Icons' ),\n\t\tname: 'icon',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/icons',\n\t\tbaseURLParams: { context: 'view' },\n\t\tplural: 'icons',\n\t\tkey: 'name',\n\t},\n].map( ( entity ) => {\n\tconst syncEnabledRootEntities = new Set( [ 'comment' ] );\n\n\tif ( syncEnabledRootEntities.has( entity.name ) ) {\n\t\tentity.syncConfig = defaultSyncConfig;\n\t}\n\treturn entity;\n} );\n\nexport const deprecatedEntities = {\n\troot: {\n\t\tmedia: {\n\t\t\tsince: '6.9',\n\t\t\talternative: {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'attachment',\n\t\t\t},\n\t\t},\n\t},\n};\n\nexport const additionalEntityConfigLoaders = [\n\t{ kind: 'postType', loadEntities: loadPostTypeEntities },\n\t{ kind: 'taxonomy', loadEntities: loadTaxonomyEntities },\n\t{\n\t\tkind: 'root',\n\t\tname: 'site',\n\t\tplural: 'sites',\n\t\tloadEntities: loadSiteEntity,\n\t},\n];\n\n/**\n * Apply extra edits before persisting a post type.\n *\n * @param {Object}  persistedRecord Already persisted Post\n * @param {Object}  edits           Edits.\n * @param {string}  name            Post type name.\n * @param {boolean} isTemplate      Whether the post type is a template.\n * @return {Promise< Object >} Updated edits.\n */\nexport const prePersistPostType = async (\n\tpersistedRecord,\n\tedits,\n\tname,\n\tisTemplate\n) => {\n\tconst newEdits = {};\n\n\tif ( ! isTemplate && persistedRecord?.status === 'auto-draft' ) {\n\t\t// Saving an auto-draft should create a draft by default.\n\t\tif ( ! edits.status && ! newEdits.status ) {\n\t\t\tnewEdits.status = 'draft';\n\t\t}\n\n\t\t// Fix the auto-draft default title.\n\t\tif (\n\t\t\t( ! edits.title || edits.title === 'Auto Draft' ) &&\n\t\t\t! newEdits.title &&\n\t\t\t( ! persistedRecord?.title ||\n\t\t\t\tpersistedRecord?.title === 'Auto Draft' )\n\t\t) {\n\t\t\tnewEdits.title = '';\n\t\t}\n\t}\n\n\t// Add meta for persisted CRDT document.\n\tif ( persistedRecord ) {\n\t\tconst objectType = `postType/${ name }`;\n\t\tconst objectId = persistedRecord.id;\n\t\tconst serializedDoc = await getSyncManager()?.createPersistedCRDTDoc(\n\t\t\tobjectType,\n\t\t\tobjectId\n\t\t);\n\n\t\tif ( serializedDoc ) {\n\t\t\tnewEdits.meta = {\n\t\t\t\t...edits.meta,\n\t\t\t\t[ POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE ]: serializedDoc,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn newEdits;\n};\n\n/**\n * Returns the list of post type entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadPostTypeEntities() {\n\tconst postTypesPromise = apiFetch( { path: '/wp/v2/types?context=view' } );\n\tconst taxonomiesPromise = window._wpCollaborationEnabled\n\t\t? apiFetch( { path: '/wp/v2/taxonomies?context=view' } )\n\t\t: Promise.resolve( {} );\n\tconst [ postTypes, taxonomies ] = await Promise.all( [\n\t\tpostTypesPromise,\n\t\ttaxonomiesPromise,\n\t] );\n\n\treturn Object.entries( postTypes ?? {} ).map( ( [ name, postType ] ) => {\n\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tname\n\t\t);\n\t\tconst namespace = postType?.rest_namespace ?? 'wp/v2';\n\n\t\tconst syncedProperties = new Set( [\n\t\t\t'author',\n\t\t\t'blocks',\n\t\t\t'content',\n\t\t\t'comment_status',\n\t\t\t'date',\n\t\t\t'excerpt',\n\t\t\t'featured_media',\n\t\t\t'format',\n\t\t\t'meta',\n\t\t\t'ping_status',\n\t\t\t'slug',\n\t\t\t'status',\n\t\t\t'sticky',\n\t\t\t'template',\n\t\t\t'title',\n\t\t\t...( postType.taxonomies\n\t\t\t\t?.map( ( taxonomy ) => taxonomies?.[ taxonomy ]?.rest_base )\n\t\t\t\t?.filter( Boolean ) ?? [] ),\n\t\t] );\n\n\t\tconst entity = {\n\t\t\tkind: 'postType',\n\t\t\tbaseURL: `/${ namespace }/${ postType.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: postType.name,\n\t\t\ttransientEdits: {\n\t\t\t\t...blocksTransientEdits,\n\t\t\t\tselection: true,\n\t\t\t},\n\t\t\tmergedEdits: { meta: true },\n\t\t\trawAttributes: POST_RAW_ATTRIBUTES,\n\t\t\tgetTitle: ( record ) =>\n\t\t\t\trecord?.title?.rendered ||\n\t\t\t\trecord?.title ||\n\t\t\t\t( isTemplate\n\t\t\t\t\t? capitalCase( record.slug ?? '' )\n\t\t\t\t\t: String( record.id ) ),\n\t\t\t__unstablePrePersist: ( persistedRecord, edits ) =>\n\t\t\t\tprePersistPostType( persistedRecord, edits, name, isTemplate ),\n\t\t\t__unstable_rest_base: postType.rest_base,\n\t\t\tsupportsPagination: true,\n\t\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t\t`/${ namespace }/${\n\t\t\t\t\tpostType.rest_base\n\t\t\t\t}/${ parentId }/revisions${\n\t\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t\t}`,\n\t\t\trevisionKey:\n\t\t\t\tisTemplate && ! window?.__experimentalTemplateActivate\n\t\t\t\t\t? 'wp_id'\n\t\t\t\t\t: DEFAULT_ENTITY_KEY,\n\t\t};\n\n\t\t/**\n\t\t * @type {import('@wordpress/sync').SyncConfig}\n\t\t */\n\t\tentity.syncConfig = {\n\t\t\t/**\n\t\t\t * Apply changes from the local editor to the local CRDT document so\n\t\t\t * that those changes can be synced to other peers (via the provider).\n\t\t\t *\n\t\t\t * @param {import('@wordpress/sync').CRDTDoc}               crdtDoc\n\t\t\t * @param {Partial< import('@wordpress/sync').ObjectData >} changes\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tapplyChangesToCRDTDoc: ( crdtDoc, changes ) =>\n\t\t\t\tapplyPostChangesToCRDTDoc( crdtDoc, changes, syncedProperties ),\n\n\t\t\t/**\n\t\t\t * Create the awareness instance for the entity's CRDT document.\n\t\t\t *\n\t\t\t * @param {import('@wordpress/sync').CRDTDoc}  ydoc\n\t\t\t * @param {import('@wordpress/sync').ObjectID} objectId\n\t\t\t * @return {import('@wordpress/sync').Awareness} Awareness instance\n\t\t\t */\n\t\t\tcreateAwareness: ( ydoc, objectId ) => {\n\t\t\t\tconst kind = 'postType';\n\t\t\t\tconst id = parseInt( objectId, 10 );\n\t\t\t\treturn new PostEditorAwareness( ydoc, kind, name, id );\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Extract changes from a CRDT document that can be used to update the\n\t\t\t * local editor state.\n\t\t\t *\n\t\t\t * @param {import('@wordpress/sync').CRDTDoc}    crdtDoc\n\t\t\t * @param {import('@wordpress/sync').ObjectData} editedRecord\n\t\t\t * @return {Partial< import('@wordpress/sync').ObjectData >} Changes to record\n\t\t\t */\n\t\t\tgetChangesFromCRDTDoc: ( crdtDoc, editedRecord ) =>\n\t\t\t\tgetPostChangesFromCRDTDoc(\n\t\t\t\t\tcrdtDoc,\n\t\t\t\t\teditedRecord,\n\t\t\t\t\tsyncedProperties\n\t\t\t\t),\n\n\t\t\t/**\n\t\t\t * Extract changes from a CRDT document that can be used to update the\n\t\t\t * local editor state.\n\t\t\t *\n\t\t\t * @param {import('@wordpress/sync').ObjectData} record\n\t\t\t * @return {Partial< import('@wordpress/sync').ObjectData >} Changes to record\n\t\t\t */\n\t\t\tgetPersistedCRDTDoc: ( record ) => {\n\t\t\t\treturn (\n\t\t\t\t\trecord?.meta?.[ POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE ] ||\n\t\t\t\t\tnull\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\n\t\treturn entity;\n\t} );\n}\n\n/**\n * Returns the list of the taxonomies entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadTaxonomyEntities() {\n\tconst taxonomies = await apiFetch( {\n\t\tpath: '/wp/v2/taxonomies?context=view',\n\t} );\n\treturn Object.entries( taxonomies ?? {} ).map( ( [ name, taxonomy ] ) => {\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\tconst entity = {\n\t\t\tkind: 'taxonomy',\n\t\t\tbaseURL: `/${ namespace }/${ taxonomy.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: taxonomy.name,\n\t\t\tgetTitle: ( record ) => record?.name,\n\t\t\tsupportsPagination: true,\n\t\t};\n\n\t\tentity.syncConfig = defaultSyncConfig;\n\n\t\treturn entity;\n\t} );\n}\n\n/**\n * Returns the Site entity.\n *\n * @return {Promise} Entity promise\n */\nasync function loadSiteEntity() {\n\tconst entity = {\n\t\tlabel: __( 'Site' ),\n\t\tname: 'site',\n\t\tkind: 'root',\n\t\tkey: false,\n\t\tbaseURL: '/wp/v2/settings',\n\t\tmeta: {},\n\t};\n\n\tconst site = await apiFetch( {\n\t\tpath: entity.baseURL,\n\t\tmethod: 'OPTIONS',\n\t} );\n\n\tconst labels = {};\n\tObject.entries( site?.schema?.properties ?? {} ).forEach(\n\t\t( [ key, value ] ) => {\n\t\t\t// Ignore properties `title` and `type` keys.\n\t\t\tif ( typeof value === 'object' && value.title ) {\n\t\t\t\tlabels[ key ] = value.title;\n\t\t\t}\n\t\t}\n\t);\n\n\treturn [ { ...entity, meta: { labels } } ];\n}\n\n/**\n * Returns the entity's getter method name given its kind and name or plural name.\n *\n * @example\n * ```js\n * const nameSingular = getMethodName( 'root', 'theme', 'get' );\n * // nameSingular is getRootTheme\n *\n * const namePlural = getMethodName( 'root', 'themes', 'set' );\n * // namePlural is setRootThemes\n * ```\n *\n * @param {string} kind   Entity kind.\n * @param {string} name   Entity name or plural name.\n * @param {string} prefix Function prefix.\n *\n * @return {string} Method name\n */\nexport const getMethodName = ( kind, name, prefix = 'get' ) => {\n\tconst kindPrefix = kind === 'root' ? '' : pascalCase( kind );\n\tconst suffix = pascalCase( name );\n\treturn `${ prefix }${ kindPrefix }${ suffix }`;\n};\n", "/**\n * WordPress dependencies\n */\nimport { dispatch, select, subscribe } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwarenessState, baseEqualityFieldChecks } from './base-awareness';\nimport { getBlockPathInYdoc, resolveBlockClientIdByPath } from './block-lookup';\nimport {\n\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS,\n\tLOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS,\n} from './config';\nimport { STORE_NAME as coreStore } from '../name';\nimport { htmlIndexToRichTextOffset } from '../utils/crdt-utils';\nimport {\n\tareSelectionsStatesEqual,\n\tgetSelectionState,\n\tSelectionType,\n} from '../utils/crdt-user-selections';\n\nimport { SelectionDirection } from '../types';\nimport type { SelectionState, WPBlockSelection } from '../types';\nimport type { YBlocks } from '../utils/crdt-blocks';\nimport type {\n\tDebugCollaboratorData,\n\tEditorState,\n\tPostEditorState,\n\tSerializableYItem,\n\tYDocDebugData,\n} from './types';\n\nexport class PostEditorAwareness extends BaseAwarenessState< PostEditorState > {\n\tprotected equalityFieldChecks = {\n\t\t...baseEqualityFieldChecks,\n\t\teditorState: this.areEditorStatesEqual,\n\t};\n\n\tpublic constructor(\n\t\tdoc: Y.Doc,\n\t\tprivate kind: string,\n\t\tprivate name: string,\n\t\tprivate postId: number\n\t) {\n\t\tsuper( doc );\n\t}\n\n\tprotected onSetUp(): void {\n\t\tsuper.onSetUp();\n\n\t\tthis.subscribeToCollaboratorSelectionChanges();\n\t}\n\n\t/**\n\t * Subscribe to collaborator selection changes and update the selection state.\n\t */\n\tprivate subscribeToCollaboratorSelectionChanges(): void {\n\t\tconst {\n\t\t\tgetSelectionStart,\n\t\t\tgetSelectionEnd,\n\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t} = select( blockEditorStore );\n\n\t\t// Keep track of the current selection in the outer scope so we can compare\n\t\t// in the subscription.\n\t\tlet selectionStart = getSelectionStart();\n\t\tlet selectionEnd = getSelectionEnd();\n\t\tlet localCursorTimeout: NodeJS.Timeout | null = null;\n\n\t\t// During rapid selection changes (e.g. undo restoring content and\n\t\t// selection), the debounce discards intermediate events. If we use the\n\t\t// last intermediate state instead of the overall change it can produce\n\t\t// the wrong direction.\n\t\t// Use selectionBeforeDebounce to capture the selection state from\n\t\t// before the debounce window so that direction is computed across the\n\t\t// full window when it fires.\n\t\tlet selectionBeforeDebounce: {\n\t\t\tstart: WPBlockSelection;\n\t\t\tend: WPBlockSelection;\n\t\t} | null = null;\n\n\t\tsubscribe( () => {\n\t\t\tconst newSelectionStart = getSelectionStart();\n\t\t\tconst newSelectionEnd = getSelectionEnd();\n\n\t\t\tif (\n\t\t\t\tnewSelectionStart === selectionStart &&\n\t\t\t\tnewSelectionEnd === selectionEnd\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// On the first change of a debounce window, snapshot the state\n\t\t\t// we're moving away from.\n\t\t\tif ( ! selectionBeforeDebounce ) {\n\t\t\t\tselectionBeforeDebounce = {\n\t\t\t\t\tstart: selectionStart,\n\t\t\t\t\tend: selectionEnd,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionStart = newSelectionStart;\n\t\t\tselectionEnd = newSelectionEnd;\n\n\t\t\t// Typically selection position is only persisted after typing in a block, which\n\t\t\t// can cause selection position to be reset by other users making block updates.\n\t\t\t// Ensure we update the controlled selection right away, persisting our cursor position locally.\n\t\t\tconst initialPosition = getSelectedBlocksInitialCaretPosition();\n\t\t\tvoid this.updateSelectionInEntityRecord(\n\t\t\t\tselectionStart,\n\t\t\t\tselectionEnd,\n\t\t\t\tinitialPosition\n\t\t\t);\n\n\t\t\t// We receive two selection changes in quick succession\n\t\t\t// from local selection events:\n\t\t\t//   { clientId: \"123...\", attributeKey: \"content\", offset: undefined }\n\t\t\t//   { clientId: \"123...\", attributeKey: \"content\", offset: 554 }\n\t\t\t// Add a short debounce to avoid sending the first selection change.\n\t\t\tif ( localCursorTimeout ) {\n\t\t\t\tclearTimeout( localCursorTimeout );\n\t\t\t}\n\n\t\t\tlocalCursorTimeout = setTimeout( () => {\n\t\t\t\t// Compute direction across the full debounce window.\n\t\t\t\tconst selectionStateOptions: {\n\t\t\t\t\tselectionDirection?: SelectionDirection;\n\t\t\t\t} = {};\n\n\t\t\t\tif ( selectionBeforeDebounce ) {\n\t\t\t\t\tselectionStateOptions.selectionDirection =\n\t\t\t\t\t\tdetectSelectionDirection(\n\t\t\t\t\t\t\tselectionBeforeDebounce.start,\n\t\t\t\t\t\t\tselectionBeforeDebounce.end,\n\t\t\t\t\t\t\tselectionStart,\n\t\t\t\t\t\t\tselectionEnd\n\t\t\t\t\t\t);\n\n\t\t\t\t\t// Reset debounced selection state.\n\t\t\t\t\tselectionBeforeDebounce = null;\n\t\t\t\t}\n\n\t\t\t\tconst selectionState = getSelectionState(\n\t\t\t\t\tselectionStart,\n\t\t\t\t\tselectionEnd,\n\t\t\t\t\tthis.doc,\n\t\t\t\t\tselectionStateOptions\n\t\t\t\t);\n\n\t\t\t\tthis.setThrottledLocalStateField(\n\t\t\t\t\t'editorState',\n\t\t\t\t\t{ selection: selectionState },\n\t\t\t\t\tAWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS\n\t\t\t\t);\n\t\t\t}, LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS );\n\t\t} );\n\t}\n\n\t/**\n\t * Update the entity record with the current collaborator's selection.\n\t *\n\t * @param selectionStart  - The start position of the selection.\n\t * @param selectionEnd    - The end position of the selection.\n\t * @param initialPosition - The initial position of the selection.\n\t */\n\tprivate async updateSelectionInEntityRecord(\n\t\tselectionStart: WPBlockSelection,\n\t\tselectionEnd: WPBlockSelection,\n\t\tinitialPosition: number | null\n\t): Promise< void > {\n\t\t// Send an entityRecord `selection` update if we have a selection.\n\t\t//\n\t\t// Normally WordPress updates the `selection` property of the post when changes are made to blocks.\n\t\t// In a multi-user setup, block changes can occur from other users. When an entity is updated from another\n\t\t// user's changes, useBlockSync() in Gutenberg will reset the user's selection to the last saved selection.\n\t\t//\n\t\t// Manually adding an edit for each movement ensures that other user's changes to the document will\n\t\t// not cause the local user's selection to reset to the last local change location.\n\t\tconst edits = {\n\t\t\tselection: { selectionStart, selectionEnd, initialPosition },\n\t\t};\n\n\t\tconst options = {\n\t\t\tundoIgnore: true,\n\t\t};\n\n\t\t// @ts-ignore Types are not provided when using store name instead of store instance.\n\t\tdispatch( coreStore ).editEntityRecord(\n\t\t\tthis.kind,\n\t\t\tthis.name,\n\t\t\tthis.postId,\n\t\t\tedits,\n\t\t\toptions\n\t\t);\n\t}\n\n\t/**\n\t * Check if two editor states are equal.\n\t *\n\t * @param state1 - The first editor state.\n\t * @param state2 - The second editor state.\n\t * @return True if the editor states are equal, false otherwise.\n\t */\n\tprivate areEditorStatesEqual(\n\t\tstate1?: EditorState,\n\t\tstate2?: EditorState\n\t): boolean {\n\t\tif ( ! state1 || ! state2 ) {\n\t\t\treturn state1 === state2;\n\t\t}\n\n\t\tif ( ! state1.selection || ! state2.selection ) {\n\t\t\treturn state1.selection === state2.selection;\n\t\t}\n\n\t\treturn areSelectionsStatesEqual( state1.selection, state2.selection );\n\t}\n\n\t/**\n\t * Resolve a selection state to a text index and block client ID.\n\t *\n\t * For text-based selections, navigates up from the resolved Y.Text via\n\t * AbstractType.parent to find the containing block, then resolves the\n\t * local clientId via the block's tree path.\n\t * For WholeBlock selections, resolves the block's relative position and\n\t * then finds the local clientId via tree path.\n\t *\n\t * Tree-path resolution is used instead of reading the clientId directly\n\t * from the Yjs block because the local block-editor store may use different\n\t * clientIds (e.g. in \"Show Template\" mode where blocks are cloned).\n\t *\n\t * @param selection - The selection state.\n\t * @return The rich-text offset and block client ID, or nulls if not resolvable.\n\t */\n\tpublic convertSelectionStateToAbsolute( selection: SelectionState ): {\n\t\trichTextOffset: number | null;\n\t\tlocalClientId: string | null;\n\t} {\n\t\tif ( selection.type === SelectionType.None ) {\n\t\t\treturn { richTextOffset: null, localClientId: null };\n\t\t}\n\n\t\tif ( selection.type === SelectionType.WholeBlock ) {\n\t\t\tconst absolutePos = Y.createAbsolutePositionFromRelativePosition(\n\t\t\t\tselection.blockPosition,\n\t\t\t\tthis.doc\n\t\t\t);\n\n\t\t\tlet localClientId: string | null = null;\n\n\t\t\tif ( absolutePos && absolutePos.type instanceof Y.Array ) {\n\t\t\t\tconst parentArray = absolutePos.type as YBlocks;\n\t\t\t\tconst block = parentArray.get( absolutePos.index );\n\n\t\t\t\tif ( block instanceof Y.Map ) {\n\t\t\t\t\tconst path = getBlockPathInYdoc( block );\n\t\t\t\t\tlocalClientId = path\n\t\t\t\t\t\t? resolveBlockClientIdByPath( path )\n\t\t\t\t\t\t: null;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn { richTextOffset: null, localClientId };\n\t\t}\n\n\t\t// Text-based selections: resolve cursor position and navigate up.\n\t\tconst cursorPos =\n\t\t\t'cursorPosition' in selection\n\t\t\t\t? selection.cursorPosition\n\t\t\t\t: selection.cursorStartPosition;\n\n\t\tconst absolutePosition = Y.createAbsolutePositionFromRelativePosition(\n\t\t\tcursorPos.relativePosition,\n\t\t\tthis.doc\n\t\t);\n\n\t\tif ( ! absolutePosition ) {\n\t\t\treturn { richTextOffset: null, localClientId: null };\n\t\t}\n\n\t\t// Navigate up: Y.Text -> attributes Y.Map -> block Y.Map\n\t\tconst yType = absolutePosition.type.parent?.parent;\n\t\tconst path =\n\t\t\tyType instanceof Y.Map ? getBlockPathInYdoc( yType ) : null;\n\t\tconst localClientId = path ? resolveBlockClientIdByPath( path ) : null;\n\n\t\treturn {\n\t\t\trichTextOffset: htmlIndexToRichTextOffset(\n\t\t\t\tabsolutePosition.type.toString(),\n\t\t\t\tabsolutePosition.index\n\t\t\t),\n\t\t\tlocalClientId,\n\t\t};\n\t}\n\n\t/**\n\t * Type guard to check if a struct is a Y.Item (not Y.GC)\n\t * @param struct - The struct to check.\n\t * @return True if the struct is a Y.Item, false otherwise.\n\t */\n\tprivate isYItem( struct: Y.Item | Y.GC ): struct is Y.Item {\n\t\treturn 'content' in struct;\n\t}\n\n\t/**\n\t * Get data for debugging, using the awareness state.\n\t *\n\t * @return {YDocDebugData} The debug data.\n\t */\n\tpublic getDebugData(): YDocDebugData {\n\t\tconst ydoc = this.doc;\n\n\t\t// Manually extract doc data to avoid deprecated toJSON method\n\t\tconst docData: Record< string, unknown > = Object.fromEntries(\n\t\t\tArray.from( ydoc.share, ( [ key, value ] ) => [\n\t\t\t\tkey,\n\t\t\t\tvalue.toJSON(),\n\t\t\t] )\n\t\t);\n\n\t\t// Build collaboratorMap from awareness store (all collaborators seen this session)\n\t\tconst collaboratorMapData = new Map< string, DebugCollaboratorData >(\n\t\t\tArray.from( this.getSeenStates().entries() ).map(\n\t\t\t\t( [ clientId, collaboratorState ] ) => [\n\t\t\t\t\tString( clientId ),\n\t\t\t\t\t{\n\t\t\t\t\t\tname: collaboratorState.collaboratorInfo.name,\n\t\t\t\t\t\twpUserId: collaboratorState.collaboratorInfo.id,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t)\n\t\t);\n\n\t\t// Serialize Yjs client items to avoid deep nesting\n\t\tconst serializableClientItems: Record<\n\t\t\tnumber,\n\t\t\tArray< SerializableYItem >\n\t\t> = {};\n\n\t\tydoc.store.clients.forEach( ( structs, clientId ) => {\n\t\t\t// Filter for Y.Item only (skip Y.GC garbage collection structs)\n\t\t\tconst items = structs.filter( this.isYItem );\n\n\t\t\tserializableClientItems[ clientId ] = items.map( ( item ) => {\n\t\t\t\tconst { left, right, ...rest } = item;\n\n\t\t\t\treturn {\n\t\t\t\t\t...rest,\n\t\t\t\t\tleft: left\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: left.id,\n\t\t\t\t\t\t\t\tlength: left.length,\n\t\t\t\t\t\t\t\torigin: left.origin,\n\t\t\t\t\t\t\t\tcontent: left.content,\n\t\t\t\t\t\t  }\n\t\t\t\t\t\t: null,\n\t\t\t\t\tright: right\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tid: right.id,\n\t\t\t\t\t\t\t\tlength: right.length,\n\t\t\t\t\t\t\t\torigin: right.origin,\n\t\t\t\t\t\t\t\tcontent: right.content,\n\t\t\t\t\t\t  }\n\t\t\t\t\t\t: null,\n\t\t\t\t};\n\t\t\t} );\n\t\t} );\n\n\t\treturn {\n\t\t\tdoc: docData,\n\t\t\tclients: serializableClientItems,\n\t\t\tcollaboratorMap: Object.fromEntries( collaboratorMapData ),\n\t\t};\n\t}\n}\n\n/**\n * Detect the direction of a selection change by comparing old and new edges.\n *\n * When the user extends a selection backward (e.g. Shift+Left), the\n * selectionStart edge moves while selectionEnd stays fixed, so the caret\n * is at the start.  The reverse is true for forward extension.\n *\n * @param prevStart - The previous selectionStart.\n * @param prevEnd   - The previous selectionEnd.\n * @param newStart  - The new selectionStart.\n * @param newEnd    - The new selectionEnd.\n * @return The detected direction, defaulting to Forward when indeterminate.\n */\nfunction detectSelectionDirection(\n\tprevStart: WPBlockSelection,\n\tprevEnd: WPBlockSelection,\n\tnewStart: WPBlockSelection,\n\tnewEnd: WPBlockSelection\n): SelectionDirection {\n\tconst startMoved = ! areBlockSelectionsEqual( prevStart, newStart );\n\tconst endMoved = ! areBlockSelectionsEqual( prevEnd, newEnd );\n\n\tif ( startMoved && ! endMoved ) {\n\t\treturn SelectionDirection.Backward;\n\t}\n\n\treturn SelectionDirection.Forward;\n}\n\n/**\n * Compare two WPBlockSelection objects by value.\n *\n * @param a - First selection.\n * @param b - Second selection.\n * @return True if all fields are equal.\n */\nfunction areBlockSelectionsEqual(\n\ta: WPBlockSelection,\n\tb: WPBlockSelection\n): boolean {\n\treturn (\n\t\ta.clientId === b.clientId &&\n\t\ta.attributeKey === b.attributeKey &&\n\t\ta.offset === b.offset\n\t);\n}\n", "/**\n * WordPress dependencies\n */\nimport { resolveSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { AwarenessState } from './awareness-state';\nimport { STORE_NAME as coreStore } from '../name';\nimport { generateCollaboratorInfo, areCollaboratorInfosEqual } from './utils';\n\nimport type { BaseState } from './types';\n\nexport abstract class BaseAwarenessState<\n\tState extends BaseState,\n> extends AwarenessState< State > {\n\tprotected onSetUp(): void {\n\t\tvoid this.setCurrentCollaboratorInfo();\n\t}\n\n\t/**\n\t * Set the current collaborator info in the local state.\n\t */\n\tprivate async setCurrentCollaboratorInfo(): Promise< void > {\n\t\tconst currentUser = await resolveSelect( coreStore ).getCurrentUser();\n\t\tconst collaboratorInfo = generateCollaboratorInfo( currentUser );\n\t\tthis.setLocalStateField( 'collaboratorInfo', collaboratorInfo );\n\t}\n}\n\nexport const baseEqualityFieldChecks = {\n\tcollaboratorInfo: areCollaboratorInfosEqual,\n};\n\nexport class BaseAwareness extends BaseAwarenessState< BaseState > {\n\tprotected equalityFieldChecks = baseEqualityFieldChecks;\n}\n", "/**\n * Delay in milliseconds before throttling the cursor position updates.\n */\nexport const AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS = 100;\n\n/**\n * Delay in milliseconds before updating the cursor position.\n */\nexport const LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS = 5;\n\n/**\n * Delay in milliseconds before removing a collaborator from presence indicators.\n */\nexport const REMOVAL_DELAY_IN_MS = 5000;\n", "/**\n * External dependencies\n */\nimport { Awareness } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { getRecordValue } from './utils';\n\n/**\n * Extended Awareness class with typed state accessors.\n */\nexport class TypedAwareness< State extends object > extends Awareness {\n\t/**\n\t * Get the states from an awareness document.\n\t */\n\tpublic getStates(): Map< number, State > {\n\t\treturn super.getStates() as Map< number, State >;\n\t}\n\n\t/**\n\t * Get a local state field from an awareness document.\n\t * @param field\n\t */\n\tpublic getLocalStateField< FieldName extends keyof State >(\n\t\tfield: FieldName\n\t): State[ FieldName ] | null {\n\t\tconst state: State | null = this.getLocalState() as State | null;\n\t\treturn getRecordValue< State, FieldName >( state, field );\n\t}\n\n\t/**\n\t * Set a local state field on an awareness document.\n\t * @param field\n\t * @param value\n\t */\n\tpublic setLocalStateField< FieldName extends string & keyof State >(\n\t\tfield: FieldName,\n\t\tvalue: State[ FieldName ]\n\t): void {\n\t\tsuper.setLocalStateField( field, value );\n\t}\n}\n", "/**\n * Internal dependencies\n */\nimport type { User } from '../entity-types';\nimport type { CollaboratorInfo } from './types';\n\n/**\n * Get the browser name from the user agent.\n * @return The browser name.\n */\nfunction getBrowserName(): string {\n\tconst userAgent = window.navigator.userAgent;\n\tlet browserName = 'Unknown';\n\n\tif ( userAgent.includes( 'Firefox' ) ) {\n\t\tbrowserName = 'Firefox';\n\t} else if ( userAgent.includes( 'Edg' ) ) {\n\t\tbrowserName = 'Microsoft Edge';\n\t} else if (\n\t\tuserAgent.includes( 'Chrome' ) &&\n\t\t! userAgent.includes( 'Edg' )\n\t) {\n\t\tbrowserName = 'Chrome';\n\t} else if (\n\t\tuserAgent.includes( 'Safari' ) &&\n\t\t! userAgent.includes( 'Chrome' )\n\t) {\n\t\tbrowserName = 'Safari';\n\t} else if (\n\t\tuserAgent.includes( 'MSIE' ) ||\n\t\tuserAgent.includes( 'Trident' )\n\t) {\n\t\tbrowserName = 'Internet Explorer';\n\t} else if ( userAgent.includes( 'Opera' ) || userAgent.includes( 'OPR' ) ) {\n\t\tbrowserName = 'Opera';\n\t}\n\n\treturn browserName;\n}\n\nexport function areMapsEqual< Key, Value >(\n\tmap1: Map< Key, Value >,\n\tmap2: Map< Key, Value >,\n\tcomparatorFn: ( value1: Value, value2: Value ) => boolean\n): boolean {\n\tif ( map1.size !== map2.size ) {\n\t\treturn false;\n\t}\n\n\tfor ( const [ key, value1 ] of map1.entries() ) {\n\t\tif ( ! map2.has( key ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( ! comparatorFn( value1, map2.get( key )! ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Check if two collaborator infos are equal.\n *\n * @param collaboratorInfo1 - The first collaborator info.\n * @param collaboratorInfo2 - The second collaborator info.\n * @return True if the collaborator infos are equal, false otherwise.\n */\nexport function areCollaboratorInfosEqual(\n\tcollaboratorInfo1?: CollaboratorInfo,\n\tcollaboratorInfo2?: CollaboratorInfo\n): boolean {\n\tif ( ! collaboratorInfo1 || ! collaboratorInfo2 ) {\n\t\treturn collaboratorInfo1 === collaboratorInfo2;\n\t}\n\n\tif (\n\t\tObject.keys( collaboratorInfo1 ).length !==\n\t\tObject.keys( collaboratorInfo2 ).length\n\t) {\n\t\treturn false;\n\t}\n\n\treturn Object.entries( collaboratorInfo1 ).every( ( [ key, value ] ) => {\n\t\t// Update this function with any non-primitive fields added to CollaboratorInfo.\n\t\treturn value === collaboratorInfo2[ key as keyof CollaboratorInfo ];\n\t} );\n}\n\n/**\n * Generate a collaborator info object from a current collaborator.\n *\n * @param currentCollaborator - The current collaborator.\n * @return The collaborator info object.\n */\nexport function generateCollaboratorInfo(\n\tcurrentCollaborator: User< 'view' >\n): CollaboratorInfo {\n\t// eslint-disable-next-line camelcase\n\tconst { avatar_urls, id, name, slug } = currentCollaborator;\n\treturn {\n\t\tavatar_urls, // eslint-disable-line camelcase\n\t\tbrowserType: getBrowserName(),\n\t\tenteredAt: Date.now(),\n\t\tid,\n\t\tname,\n\t\tslug,\n\t};\n}\n\nexport function getRecordValue< RecordType, Key extends keyof RecordType >(\n\tobj: unknown,\n\tkey: Key\n): RecordType[ Key ] | null {\n\tif ( 'object' === typeof obj && null !== obj && key in obj ) {\n\t\treturn ( obj as RecordType )[ key ];\n\t}\n\n\treturn null;\n}\n\nexport function getTypedKeys< T extends object >( obj: T ): Array< keyof T > {\n\treturn Object.keys( obj ) as Array< keyof T >;\n}\n", "/**\n * Internal dependencies\n */\nimport { REMOVAL_DELAY_IN_MS } from './config';\nimport { TypedAwareness } from './typed-awareness';\nimport type { EnhancedState, EqualityFieldCheck } from './types';\nimport { getTypedKeys, areMapsEqual } from './utils';\n\ntype AwarenessClientID = number;\n\ninterface AwarenessStateChange {\n\tadded: AwarenessClientID[];\n\tupdated: AwarenessClientID[];\n\tremoved: AwarenessClientID[];\n}\n\nabstract class AwarenessWithEqualityChecks<\n\tState extends object,\n> extends TypedAwareness< State > {\n\t/** OVERRIDDEN METHODS */\n\n\t/**\n\t * Set a local state field on an awareness document. Calling this method may\n\t * trigger rerenders of any subscribed components.\n\t *\n\t * Equality checks are provided by the abstract `equalityFieldChecks` property.\n\t * @param field - The field to set.\n\t * @param value - The value to set.\n\t */\n\tpublic setLocalStateField< FieldName extends string & keyof State >(\n\t\tfield: FieldName,\n\t\tvalue: State[ FieldName ]\n\t): void {\n\t\tif (\n\t\t\tthis.isFieldEqual(\n\t\t\t\tfield,\n\t\t\t\tvalue,\n\t\t\t\tthis.getLocalStateField( field ) ?? undefined\n\t\t\t)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tsuper.setLocalStateField( field, value );\n\t}\n\n\t/** ABSTRACT PROPERTIES */\n\n\t/**\n\t * Extending classes must implement equality checks for each awareness state\n\t * field they manage.\n\t */\n\tprotected abstract equalityFieldChecks: {\n\t\t[ FieldName in keyof State ]: EqualityFieldCheck< State, FieldName >;\n\t};\n\n\t/** CUSTOM METHODS */\n\n\t/**\n\t * Determine if a field value has changed using the provided equality checks.\n\t * @param field  - The field to check.\n\t * @param value1 - The first value to compare.\n\t * @param value2 - The second value to compare.\n\t */\n\tprotected isFieldEqual< FieldName extends keyof State >(\n\t\tfield: FieldName,\n\t\tvalue1?: State[ FieldName ],\n\t\tvalue2?: State[ FieldName ]\n\t): boolean {\n\t\tif (\n\t\t\t[ 'clientId', 'isConnected', 'isMe' ].includes( field as string )\n\t\t) {\n\t\t\treturn value1 === value2;\n\t\t}\n\n\t\tif ( field in this.equalityFieldChecks ) {\n\t\t\tconst fn = this.equalityFieldChecks[ field ];\n\t\t\treturn fn( value1, value2 );\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`No equality check implemented for awareness state field \"${ field.toString() }\".`\n\t\t);\n\t}\n\n\t/**\n\t * Determine if two states are equal by comparing each field using the\n\t * provided equality checks.\n\t * @param state1 - The first state to compare.\n\t * @param state2 - The second state to compare.\n\t */\n\tprotected isStateEqual( state1: State, state2: State ): boolean {\n\t\treturn [\n\t\t\t...new Set< keyof State >( [\n\t\t\t\t...getTypedKeys( state1 ),\n\t\t\t\t...getTypedKeys( state2 ),\n\t\t\t] ),\n\t\t].every( ( field ) => {\n\t\t\tconst value1 = state1[ field ];\n\t\t\tconst value2 = state2[ field ];\n\n\t\t\treturn this.isFieldEqual( field, value1, value2 );\n\t\t} );\n\t}\n}\n\n/**\n * Abstract class to manage awareness and allow external code to subscribe to\n * state updates.\n */\nexport abstract class AwarenessState<\n\tState extends object = {},\n> extends AwarenessWithEqualityChecks< State > {\n\t/** CUSTOM PROPERTIES */\n\n\t/**\n\t * Whether the setUp method has been called, to avoid running it multiple\n\t * times.\n\t */\n\tprivate hasSetupRun = false;\n\n\t/**\n\t * We keep track of all seen states during the current session for two reasons:\n\t *\n\t * 1. So that we can represent recently disconnected collaborators in our UI, even\n\t *    after they have been removed from the awareness document.\n\t * 2. So that we can provide debug information about all collaborators seen during\n\t *    the session.\n\t */\n\tprivate disconnectedCollaborators: Set< number > = new Set();\n\tprivate seenStates: Map< number, State > = new Map();\n\n\t/**\n\t * Hold a snapshot of the previous awareness state allows us to compare the\n\t * state values and avoid unnecessary updates to subscribers.\n\t */\n\tprivate previousSnapshot = new Map< number, EnhancedState< State > >();\n\tprivate stateSubscriptions: Array<\n\t\t( newState: EnhancedState< State >[] ) => void\n\t> = [];\n\n\t/**\n\t * In some cases, we may want to throttle setting local state fields to avoid\n\t * overwhelming the awareness document with rapid updates. At the same time, we\n\t * want to ensure that when we read our own state locally, we get the latest\n\t * value -- even if it hasn't yet been set on the awareness instance.\n\t */\n\tprivate myThrottledState: Partial< State > = {};\n\tprivate throttleTimeouts: Map< string, NodeJS.Timeout > = new Map();\n\n\t/** CUSTOM METHODS */\n\n\t/**\n\t * Set up the awareness state. This method is idempotent and will only run\n\t * once. Subclasses should override `onSetUp()` instead of this method to\n\t * add their own setup logic.\n\t *\n\t * This is defined as a readonly arrow function property to prevent\n\t * subclasses from overriding it.\n\t */\n\tpublic readonly setUp = (): void => {\n\t\tif ( this.hasSetupRun ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hasSetupRun = true;\n\n\t\tthis.onSetUp();\n\n\t\tthis.on(\n\t\t\t'change',\n\t\t\t( { added, removed, updated }: AwarenessStateChange ) => {\n\t\t\t\t[ ...added, ...updated ].forEach( ( id ) => {\n\t\t\t\t\tthis.disconnectedCollaborators.delete( id );\n\t\t\t\t} );\n\n\t\t\t\tremoved.forEach( ( id ) => {\n\t\t\t\t\tthis.disconnectedCollaborators.add( id );\n\n\t\t\t\t\tsetTimeout( () => {\n\t\t\t\t\t\tthis.disconnectedCollaborators.delete( id );\n\t\t\t\t\t\tthis.updateSubscribers( true /* force update */ );\n\t\t\t\t\t}, REMOVAL_DELAY_IN_MS );\n\t\t\t\t} );\n\n\t\t\t\t// Do not force-update the store here, since this change handler can be\n\t\t\t\t// called even when there are no actual state changes.\n\t\t\t\tthis.updateSubscribers();\n\t\t\t}\n\t\t);\n\t};\n\n\t/**\n\t * Hook method for subclasses to add their own setup logic. This is called\n\t * once after the base class setup completes. All subclasses must implement\n\t * this method. If extending a class that already implements `onSetUp()`,\n\t * call `super.onSetUp()` to ensure parent setup runs.\n\t */\n\tprotected abstract onSetUp(): void;\n\n\t/**\n\t * Get the most recent state from the last processed change event.\n\t *\n\t * @return An array of EnhancedState< State >.\n\t */\n\tpublic getCurrentState(): EnhancedState< State >[] {\n\t\treturn Array.from( this.previousSnapshot.values() );\n\t}\n\n\t/**\n\t * Get all seen states in this session to enable debug reporting.\n\t */\n\tpublic getSeenStates(): Map< number, State > {\n\t\treturn this.seenStates;\n\t}\n\n\t/**\n\t * Allow external code to subscribe to awareness state changes.\n\t * @param callback - The callback to subscribe to.\n\t */\n\tpublic onStateChange(\n\t\tcallback: ( newState: EnhancedState< State >[] ) => void\n\t): () => void {\n\t\tthis.stateSubscriptions.push( callback );\n\n\t\treturn () => {\n\t\t\tthis.stateSubscriptions = this.stateSubscriptions.filter(\n\t\t\t\t( cb ) => cb !== callback\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Set a local state field on an awareness document with throttle. See caveats\n\t * of this.setLocalStateField.\n\t * @param field - The field to set.\n\t * @param value - The value to set.\n\t * @param wait  - The wait time in milliseconds.\n\t */\n\tpublic setThrottledLocalStateField<\n\t\tFieldName extends string & keyof State,\n\t>( field: FieldName, value: State[ FieldName ], wait: number ): void {\n\t\tthis.setLocalStateField( field, value );\n\n\t\tthis.throttleTimeouts.set(\n\t\t\tfield,\n\t\t\tsetTimeout( () => {\n\t\t\t\tthis.throttleTimeouts.delete( field );\n\t\t\t\tif ( this.myThrottledState[ field ] ) {\n\t\t\t\t\tthis.setLocalStateField(\n\t\t\t\t\t\tfield,\n\t\t\t\t\t\tthis.myThrottledState[ field ]\n\t\t\t\t\t);\n\n\t\t\t\t\tdelete this.myThrottledState[ field ];\n\t\t\t\t}\n\t\t\t}, wait )\n\t\t);\n\t}\n\n\t/**\n\t * Set the current collaborator's connection status as awareness state.\n\t * @param isConnected - The connection status.\n\t */\n\tpublic setConnectionStatus( isConnected: boolean ): void {\n\t\tif ( isConnected ) {\n\t\t\tthis.disconnectedCollaborators.delete( this.clientID );\n\t\t} else {\n\t\t\tthis.disconnectedCollaborators.add( this.clientID );\n\t\t}\n\n\t\tthis.updateSubscribers( true /* force update */ );\n\t}\n\n\t/**\n\t * Update all subscribed listeners with the latest awareness state.\n\t * @param forceUpdate - Whether to force an update.\n\t */\n\tprotected updateSubscribers( forceUpdate = false ): void {\n\t\tif ( ! this.stateSubscriptions.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst states = this.getStates();\n\n\t\tthis.seenStates = new Map< number, State >( [\n\t\t\t...this.seenStates.entries(),\n\t\t\t...states.entries(),\n\t\t] );\n\n\t\tconst updatedStates = new Map< number, EnhancedState< State > >(\n\t\t\t[ ...this.disconnectedCollaborators, ...states.keys() ]\n\t\t\t\t.filter( ( clientId ) => {\n\t\t\t\t\t// Exclude any collaborators with empty awareness state. This can happen from\n\t\t\t\t\t// the Yjs inspector.\n\t\t\t\t\treturn (\n\t\t\t\t\t\tObject.keys( this.seenStates.get( clientId ) ?? {} )\n\t\t\t\t\t\t\t.length > 0\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t\t.map( ( clientId ) => {\n\t\t\t\t\t// The filter above ensures that seenStates has the clientId.\n\t\t\t\t\tconst rawState: State = this.seenStates.get( clientId )!;\n\n\t\t\t\t\tconst isConnected =\n\t\t\t\t\t\t! this.disconnectedCollaborators.has( clientId );\n\t\t\t\t\tconst isMe = clientId === this.clientID;\n\t\t\t\t\tconst myState: Partial< State > = isMe\n\t\t\t\t\t\t? this.myThrottledState\n\t\t\t\t\t\t: {};\n\t\t\t\t\tconst state: EnhancedState< State > = {\n\t\t\t\t\t\t...rawState,\n\t\t\t\t\t\t...myState,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tisConnected,\n\t\t\t\t\t\tisMe,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn [ clientId, state ];\n\t\t\t\t} )\n\t\t);\n\n\t\tif ( ! forceUpdate ) {\n\t\t\tif (\n\t\t\t\tareMapsEqual(\n\t\t\t\t\tthis.previousSnapshot,\n\t\t\t\t\tupdatedStates,\n\t\t\t\t\tthis.isStateEqual.bind( this )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\t// Awareness state unchanged, do not update subscribers.\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\t// Update subscribers.\n\t\tthis.previousSnapshot = updatedStates;\n\t\tthis.stateSubscriptions.forEach( ( callback ) => {\n\t\t\tcallback( Array.from( updatedStates.values() ) );\n\t\t} );\n\t}\n}\n", "/**\n * The reducer key used by core data in store registration.\n * This is defined in a separate file to avoid cycle-dependency\n *\n * @type {string}\n */\nexport const STORE_NAME = 'core';\n", "/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport type { AbsoluteBlockIndexPath } from '../types';\n\n/**\n * A block as represented in the block-editor store (from `getBlocks()`).\n *\n * This is a minimal interface covering only the fields used by RTC awareness.\n */\ninterface EditorStoreBlock {\n\tclientId: string;\n\tname: string;\n\tinnerBlocks: EditorStoreBlock[];\n}\n\n/**\n * Given a Y.Map within a Ydoc, traverse up the Yjs block tree to compute the\n * index path from the root.\n *\n * For example, the second inner block of the first root block returns [0, 1].\n *\n * @param yType - The Yjs block Y.Map to start from.\n * @return The index path from root, or null if traversal fails.\n */\nexport function getBlockPathInYdoc(\n\tyType: Y.Map< unknown >\n): AbsoluteBlockIndexPath | null {\n\tconst path: AbsoluteBlockIndexPath = [];\n\tlet current: Y.Map< unknown > = yType;\n\n\twhile ( current ) {\n\t\tconst parentArray = current.parent;\n\n\t\tif ( ! parentArray || ! ( parentArray instanceof Y.Array ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Find index of current block in its parent array.\n\t\tlet index = -1;\n\t\tfor ( let i = 0; i < parentArray.length; i++ ) {\n\t\t\tif ( parentArray.get( i ) === current ) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif ( index === -1 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tpath.unshift( index );\n\n\t\t// Walk up: is the parent array's parent a block Y.Map or the root?\n\t\tconst grandparent = parentArray.parent;\n\t\tif (\n\t\t\tgrandparent instanceof Y.Map &&\n\t\t\tgrandparent.get( 'clientId' ) !== undefined\n\t\t) {\n\t\t\tcurrent = grandparent; // It's a block, keep going.\n\t\t} else {\n\t\t\tbreak; // It's the root map, done.\n\t\t}\n\t}\n\n\treturn path;\n}\n\n/**\n * Navigate the block-editor store's block tree by an index path\n * and return the local block's clientId.\n *\n * In template mode, getBlocks() returns the full template tree, but Yjs\n * paths are relative to the post content. This method finds the\n * core/post-content block (if present) and uses its inner blocks as the\n * navigation root, so paths align with the Yjs document structure.\n *\n * @param path - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @return The local block clientId, or null if the path is invalid.\n */\nexport function resolveBlockClientIdByPath(\n\tpath: AbsoluteBlockIndexPath\n): string | null {\n\tif ( path.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst { getBlocks } = select( blockEditorStore );\n\tconst postContentBlocks = getPostContentBlocks( getBlocks(), getBlocks );\n\n\tlet blocks = postContentBlocks;\n\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tconst block = blocks[ path[ i ] ];\n\t\tif ( ! block ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn block.clientId;\n\t\t}\n\t\tblocks = block.innerBlocks;\n\t}\n\treturn null;\n}\n\n/**\n * Find the post content blocks to use as the navigation root.\n *\n * In template mode, the block tree contains template parts wrapping a\n * core/post-content block. The Yjs document only stores the post content\n * blocks, so we need to find the core/post-content block and use\n * getBlocks(clientId) to retrieve its inner blocks from the store.\n *\n * We must use getBlocks(clientId) rather than reading .innerBlocks from\n * the block object because useBlockSync() injects post content as\n * controlled inner blocks \u2014 they exist in the store's block order map\n * but are not populated in the .innerBlocks property of the tree\n * returned by getBlocks().\n *\n * @param rootBlocks - The root-level blocks from getBlocks().\n * @param getBlocks  - The getBlocks selector.\n * @return The blocks that correspond to the Yjs document root.\n */\nfunction getPostContentBlocks(\n\trootBlocks: EditorStoreBlock[],\n\tgetBlocks: ( rootClientId?: string ) => EditorStoreBlock[]\n): EditorStoreBlock[] {\n\tconst postContentBlock = findBlockByName( rootBlocks, 'core/post-content' );\n\tif ( postContentBlock ) {\n\t\t// Use getBlocks(clientId) to read controlled inner blocks from\n\t\t// the store, since postContentBlock.innerBlocks is empty.\n\t\treturn getBlocks( postContentBlock.clientId );\n\t}\n\n\treturn rootBlocks;\n}\n\n/**\n * Recursively search the block tree for a block with a given name.\n *\n * @param blocks - The blocks to search.\n * @param name   - The block name to find.\n * @return The first matching block, or null if not found.\n */\nfunction findBlockByName(\n\tblocks: EditorStoreBlock[],\n\tname: string\n): EditorStoreBlock | null {\n\tfor ( const block of blocks ) {\n\t\tif ( block.name === name ) {\n\t\t\treturn block;\n\t\t}\n\t\tif ( block.innerBlocks?.length ) {\n\t\t\tconst found = findBlockByName( block.innerBlocks, name );\n\t\t\tif ( found ) {\n\t\t\t\treturn found;\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n}\n", "/**\n * WordPress dependencies\n */\nimport { Y } from '@wordpress/sync';\nimport { create, insert, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport type { YPostRecord } from './crdt';\nimport { CRDT_RECORD_MAP_KEY } from '../sync';\n\n/**\n * A YMapRecord represents the shape of the data stored in a Y.Map.\n */\nexport type YMapRecord = Record< string, unknown >;\n\n/**\n * A wrapper around Y.Map to provide type safety. The generic type accepted by\n * Y.Map represents the union of possible values of the map, which are varied in\n * many cases. This type is accurate, but its non-specificity requires aggressive\n * type narrowing or type casting / destruction with `as`.\n *\n * This type provides type enhancements so that the correct value type can be\n * inferred based on the provided key. It is just a type wrap / overlay, and\n * does not change the runtime behavior of Y.Map.\n *\n * This interface cannot extend Y.Map directly due to the limitations of\n * TypeScript's structural typing. One negative consequence of this is that\n * `instanceof` checks against Y.Map continue to work at runtime but will blur\n * the type at compile time. To navigate this, use the `isYMap` function below.\n */\nexport interface YMapWrap< T extends YMapRecord > extends Y.AbstractType< T > {\n\tdelete: < K extends keyof T >( key: K ) => void;\n\tforEach: (\n\t\tcallback: (\n\t\t\tvalue: T[ keyof T ],\n\t\t\tkey: keyof T,\n\t\t\tmap: YMapWrap< T >\n\t\t) => void\n\t) => void;\n\thas: < K extends keyof T >( key: K ) => boolean;\n\tget: < K extends keyof T >( key: K ) => T[ K ] | undefined;\n\tset: < K extends keyof T >( key: K, value: T[ K ] ) => void;\n\ttoJSON: () => T;\n\t// add types for other Y.Map methods as needed\n}\n\n/**\n * Get or create a root-level Map for the given Y.Doc. Use this instead of\n * doc.getMap() for additional type safety.\n *\n * @param doc Y.Doc\n * @param key Map key\n */\nexport function getRootMap< T extends YMapRecord >(\n\tdoc: Y.Doc,\n\tkey: string\n): YMapWrap< T > {\n\treturn doc.getMap< T >( key ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Create a new Y.Map (provided with YMapWrap type), optionally initialized with\n * data. Use this instead of `new Y.Map()` for additional type safety.\n *\n * @param partial Partial data to initialize the map with.\n */\nexport function createYMap< T extends YMapRecord >(\n\tpartial: Partial< T > = {}\n): YMapWrap< T > {\n\treturn new Y.Map( Object.entries( partial ) ) as unknown as YMapWrap< T >;\n}\n\n/**\n * Type guard to check if a value is a Y.Map without losing type information.\n *\n * @param value Value to check.\n */\nexport function isYMap< T extends YMapRecord >(\n\tvalue: YMapWrap< T > | undefined\n): value is YMapWrap< T > {\n\treturn value instanceof Y.Map;\n}\n\n/**\n * Given a block ID and a Y.Doc, find the block in the document.\n *\n * @param blockId The block ID to find\n * @param ydoc    The Y.Doc to find the block in\n * @return The block, or null if the block is not found\n */\nexport function findBlockByClientIdInDoc(\n\tblockId: string,\n\tydoc: Y.Doc\n): YBlock | null {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\tconst blocks = ymap.get( 'blocks' );\n\n\tif ( ! ( blocks instanceof Y.Array ) ) {\n\t\treturn null;\n\t}\n\n\treturn findBlockByClientIdInBlocks( blockId, blocks );\n}\n\n// Marker for insertion.\nconst MARKER_START = 0xe000;\n\n/**\n * Pick a marker character that does not appear in `text`. Returns the marker\n * or `null` if all candidates are present (extremely unlikely in practice).\n *\n * @param text The string to check for existing marker characters.\n */\nfunction pickMarker( text: string ): string | null {\n\tconst tryCount = 0x10;\n\n\t// Scan the unicode private use area for the first code point not present\n\t// in the text.\n\tfor ( let code = MARKER_START; code < MARKER_START + tryCount; code++ ) {\n\t\tconst candidate = String.fromCharCode( code );\n\n\t\tif ( ! text.includes( candidate ) ) {\n\t\t\treturn candidate;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Convert an HTML character index (counting tag characters) to a rich-text\n * offset (counting only text characters). Used on read paths where Y.Text\n * resolves to an HTML index but the block editor expects a text offset.\n *\n * @param html      The full HTML string from Y.Text.\n * @param htmlIndex The HTML character index.\n * @return The corresponding rich-text offset.\n */\nexport function htmlIndexToRichTextOffset(\n\thtml: string,\n\thtmlIndex: number\n): number {\n\tif ( ! html.includes( '<' ) && ! html.includes( '&' ) ) {\n\t\treturn htmlIndex;\n\t}\n\n\tconst marker = pickMarker( html );\n\tif ( ! marker ) {\n\t\treturn htmlIndex;\n\t}\n\n\t// Insert marker and let create() do the parsing.\n\tconst withMarker =\n\t\thtml.slice( 0, htmlIndex ) + marker + html.slice( htmlIndex );\n\tconst value = create( { html: withMarker } );\n\tconst markerPos = value.text.indexOf( marker );\n\n\treturn markerPos === -1 ? htmlIndex : markerPos;\n}\n\n/**\n * Convert a rich-text offset (counting only text characters) to an HTML\n * character index (counting tag characters). Used on write paths where the\n * block editor provides a text offset but Y.Text expects an HTML index.\n *\n * @param html           The full HTML string from Y.Text.\n * @param richTextOffset The rich-text text offset.\n * @return The corresponding HTML character index.\n */\nexport function richTextOffsetToHtmlIndex(\n\thtml: string,\n\trichTextOffset: number\n): number {\n\tif ( ! html.includes( '<' ) && ! html.includes( '&' ) ) {\n\t\treturn richTextOffset;\n\t}\n\n\tconst marker = pickMarker( html );\n\tif ( ! marker ) {\n\t\treturn richTextOffset;\n\t}\n\n\tconst value = create( { html } );\n\tconst markerValue = create( { text: marker } );\n\t// The marker must inherit the formatting at the insertion point so that\n\t// toHTMLString does not split surrounding tags (e.g. <strong>) around it.\n\tif ( value.formats[ richTextOffset ] ) {\n\t\tmarkerValue.formats[ 0 ] = value.formats[ richTextOffset ];\n\t}\n\n\tconst withMarker = insert(\n\t\tvalue,\n\t\tmarkerValue,\n\t\trichTextOffset,\n\t\trichTextOffset\n\t);\n\n\tconst htmlWithMarker = toHTMLString( { value: withMarker } );\n\tconst markerIndex = htmlWithMarker.indexOf( marker );\n\treturn markerIndex === -1 ? richTextOffset : markerIndex;\n}\n\nfunction findBlockByClientIdInBlocks(\n\tblockId: string,\n\tblocks: YBlocks\n): YBlock | null {\n\tfor ( const block of blocks ) {\n\t\tif ( block.get( 'clientId' ) === blockId ) {\n\t\t\treturn block;\n\t\t}\n\n\t\tconst innerBlocks = block.get( 'innerBlocks' );\n\n\t\tif ( innerBlocks && innerBlocks.length > 0 ) {\n\t\t\tconst innerBlock = findBlockByClientIdInBlocks(\n\t\t\t\tblockId,\n\t\t\t\tinnerBlocks\n\t\t\t);\n\n\t\t\tif ( innerBlock ) {\n\t\t\t\treturn innerBlock;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn null;\n}\n", "/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as syncPrivateApis,\n\ttype SyncManager,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\n\nconst {\n\tConnectionErrorCode,\n\tcreateSyncManager,\n\tDelta,\n\tCRDT_DOC_META_PERSISTENCE_KEY,\n\tCRDT_RECORD_MAP_KEY,\n\tLOCAL_EDITOR_ORIGIN,\n\tLOCAL_UNDO_IGNORED_ORIGIN,\n\tretrySyncConnection,\n} = unlock( syncPrivateApis );\n\nexport {\n\tConnectionErrorCode,\n\tDelta,\n\tCRDT_DOC_META_PERSISTENCE_KEY,\n\tCRDT_RECORD_MAP_KEY,\n\tLOCAL_EDITOR_ORIGIN,\n\tLOCAL_UNDO_IGNORED_ORIGIN,\n\tretrySyncConnection,\n};\n\nlet syncManager: SyncManager;\n\nexport function getSyncManager(): SyncManager | undefined {\n\tif ( syncManager ) {\n\t\treturn syncManager;\n\t}\n\n\tsyncManager = createSyncManager();\n\n\treturn syncManager;\n}\n", "/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/core-data'\n\t);\n", "/**\n * WordPress dependencies\n */\nimport { select } from '@wordpress/data';\nimport { Y } from '@wordpress/sync';\n// @ts-ignore No exported types for block editor store selectors.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { YPostRecord } from './crdt';\nimport type { YBlock, YBlocks } from './crdt-blocks';\nimport { getRootMap, richTextOffsetToHtmlIndex } from './crdt-utils';\nimport type {\n\tAbsoluteBlockIndexPath,\n\tWPBlockSelection,\n\tSelectionState,\n\tSelectionNone,\n\tSelectionCursor,\n\tSelectionInOneBlock,\n\tSelectionInMultipleBlocks,\n\tSelectionWholeBlock,\n\tSelectionDirection,\n\tCursorPosition,\n} from '../types';\n\n/**\n * The type of selection.\n */\nexport enum SelectionType {\n\tNone = 'none',\n\tCursor = 'cursor',\n\tSelectionInOneBlock = 'selection-in-one-block',\n\tSelectionInMultipleBlocks = 'selection-in-multiple-blocks',\n\tWholeBlock = 'whole-block',\n}\n\n/**\n * Converts WordPress block editor selection to a SelectionState.\n *\n * Uses getBlockPathForLocalClientId to locate blocks in the Yjs document by\n * their tree position (index path) rather than clientId, since clientIds may\n * differ between the block-editor store and the Yjs document (e.g. in \"Show\n * Template\" mode).\n *\n * @param selectionStart             - The start position of the selection\n * @param selectionEnd               - The end position of the selection\n * @param yDoc                       - The Yjs document\n * @param options                    - Optional parameters\n * @param options.selectionDirection - The direction of the selection (forward or backward)\n * @return The SelectionState\n */\nexport function getSelectionState(\n\tselectionStart: WPBlockSelection,\n\tselectionEnd: WPBlockSelection,\n\tyDoc: Y.Doc,\n\toptions?: { selectionDirection?: SelectionDirection }\n): SelectionState {\n\tconst { selectionDirection } = options ?? {};\n\tconst ymap = getRootMap< YPostRecord >( yDoc, CRDT_RECORD_MAP_KEY );\n\tconst yBlocks = ymap.get( 'blocks' );\n\n\tconst isSelectionEmpty = Object.keys( selectionStart ).length === 0;\n\tconst noSelection: SelectionNone = {\n\t\ttype: SelectionType.None,\n\t};\n\n\tif ( isSelectionEmpty || ! yBlocks ) {\n\t\t// Case 1: No selection, or no blocks in the document.\n\t\treturn noSelection;\n\t}\n\n\t// When the page initially loads, selectionStart can contain an empty object `{}`.\n\tconst isSelectionInOneBlock =\n\t\tselectionStart.clientId === selectionEnd.clientId;\n\tconst isCursorOnly =\n\t\tisSelectionInOneBlock && selectionStart.offset === selectionEnd.offset;\n\tconst isSelectionAWholeBlock =\n\t\tisSelectionInOneBlock &&\n\t\tselectionStart.offset === undefined &&\n\t\tselectionEnd.offset === undefined;\n\n\tif ( isSelectionAWholeBlock ) {\n\t\t// Case 2: A whole block is selected.\n\t\tconst path = getBlockPathForLocalClientId( selectionStart.clientId );\n\t\tconst blockPosition = path\n\t\t\t? createRelativePositionForBlockPath( path, yBlocks )\n\t\t\t: null;\n\n\t\tif ( ! blockPosition ) {\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.WholeBlock,\n\t\t\tblockPosition,\n\t\t};\n\t} else if ( isCursorOnly ) {\n\t\t// Case 3: Cursor only, no text selected\n\t\tconst cursorPosition = getCursorPosition( selectionStart, yBlocks );\n\n\t\tif ( ! cursorPosition ) {\n\t\t\t// If we can't find the cursor position in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.Cursor,\n\t\t\tcursorPosition,\n\t\t};\n\t} else if ( isSelectionInOneBlock ) {\n\t\t// Case 4: Selection in a single block\n\t\tconst cursorStartPosition = getCursorPosition(\n\t\t\tselectionStart,\n\t\t\tyBlocks\n\t\t);\n\t\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\n\t\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\t\treturn noSelection;\n\t\t}\n\n\t\treturn {\n\t\t\ttype: SelectionType.SelectionInOneBlock,\n\t\t\tcursorStartPosition,\n\t\t\tcursorEndPosition,\n\t\t\tselectionDirection,\n\t\t};\n\t}\n\n\t// Case 5: Selection in multiple blocks\n\tconst cursorStartPosition = getCursorPosition( selectionStart, yBlocks );\n\tconst cursorEndPosition = getCursorPosition( selectionEnd, yBlocks );\n\tif ( ! cursorStartPosition || ! cursorEndPosition ) {\n\t\t// If we can't find the cursor positions in block text, treat it as a non-selection.\n\t\treturn noSelection;\n\t}\n\n\treturn {\n\t\ttype: SelectionType.SelectionInMultipleBlocks,\n\t\tcursorStartPosition,\n\t\tcursorEndPosition,\n\t\tselectionDirection,\n\t};\n}\n\n/**\n * Get the cursor position from a selection.\n *\n * @param selection - The selection.\n * @param blocks    - The blocks to search through.\n * @return The cursor position, or null if not found.\n */\nfunction getCursorPosition(\n\tselection: WPBlockSelection,\n\tblocks: YBlocks\n): CursorPosition | null {\n\tconst path = getBlockPathForLocalClientId( selection.clientId );\n\tconst block = path ? findBlockByPath( path, blocks ) : null;\n\tif (\n\t\t! block ||\n\t\t! selection.attributeKey ||\n\t\tundefined === selection.offset\n\t) {\n\t\treturn null;\n\t}\n\n\tconst attributes = block.get( 'attributes' );\n\tconst currentYText = attributes?.get( selection.attributeKey );\n\n\t// If the attribute is not a Y.Text, return null.\n\tif ( ! ( currentYText instanceof Y.Text ) ) {\n\t\treturn null;\n\t}\n\n\tconst relativePosition = Y.createRelativePositionFromTypeIndex(\n\t\tcurrentYText,\n\t\trichTextOffsetToHtmlIndex( currentYText.toString(), selection.offset )\n\t);\n\n\treturn {\n\t\trelativePosition,\n\t\tabsoluteOffset: selection.offset,\n\t};\n}\n\n/**\n * Resolves a local block-editor clientId to its index path relative to the\n * post content blocks. This allows finding the corresponding block in the Yjs\n * document even when clientIds differ (e.g. in \"Show Template\" mode where\n * blocks are cloned).\n *\n * In template mode, the block tree includes template parts and wrapper blocks\n * around a core/post-content block. The Yjs document only contains the post\n * content blocks, so we stop the upward walk when the parent is\n * core/post-content (its inner blocks correspond to the Yjs root blocks).\n *\n * @param clientId - The local block-editor clientId to resolve.\n * @return The index path from root, or null if not resolvable.\n */\nexport function getBlockPathForLocalClientId(\n\tclientId: string\n): AbsoluteBlockIndexPath | null {\n\tconst { getBlockIndex, getBlockRootClientId, getBlockName } =\n\t\tselect( blockEditorStore );\n\n\tconst path: AbsoluteBlockIndexPath = [];\n\tlet current: string | null = clientId;\n\twhile ( current ) {\n\t\tconst index = getBlockIndex( current );\n\t\tif ( index === -1 ) {\n\t\t\treturn null;\n\t\t}\n\t\tpath.unshift( index );\n\t\tconst parent = getBlockRootClientId( current );\n\t\tif ( ! parent ) {\n\t\t\tbreak;\n\t\t}\n\t\t// If the parent is core/post-content, stop here \u2014 the Yjs doc\n\t\t// root blocks correspond to post-content's inner blocks.\n\t\tconst parentName = getBlockName( parent );\n\t\tif ( parentName === 'core/post-content' ) {\n\t\t\tbreak;\n\t\t}\n\t\tcurrent = parent;\n\t}\n\treturn path.length > 0 ? path : null;\n}\n\n/**\n * Find a block by navigating a tree index path in the Yjs block hierarchy.\n *\n * @param path   - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return The block Y.Map if found, null otherwise.\n */\nfunction findBlockByPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): YBlock | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tif ( ! block ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn block;\n\t\t}\n\t\tcurrentBlocks =\n\t\t\tblock.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Create a Y.RelativePosition for a block by navigating a tree index path.\n *\n * @param path   - The index path, e.g. [0, 1] for blocks[0].innerBlocks[1].\n * @param blocks - The root-level Yjs blocks array.\n * @return A Y.RelativePosition for the block, or null if the path is invalid.\n */\nfunction createRelativePositionForBlockPath(\n\tpath: AbsoluteBlockIndexPath,\n\tblocks: YBlocks\n): Y.RelativePosition | null {\n\tlet currentBlocks = blocks;\n\tfor ( let i = 0; i < path.length; i++ ) {\n\t\tif ( path[ i ] >= currentBlocks.length ) {\n\t\t\treturn null;\n\t\t}\n\t\tif ( i === path.length - 1 ) {\n\t\t\treturn Y.createRelativePositionFromTypeIndex(\n\t\t\t\tcurrentBlocks,\n\t\t\t\tpath[ i ]\n\t\t\t);\n\t\t}\n\t\tconst block = currentBlocks.get( path[ i ] );\n\t\tcurrentBlocks =\n\t\t\tblock?.get( 'innerBlocks' ) ?? ( new Y.Array() as YBlocks );\n\t}\n\treturn null;\n}\n\n/**\n * Check if two selection states are equal.\n *\n * @param selection1 - The first selection state.\n * @param selection2 - The second selection state.\n * @return True if the selection states are equal, false otherwise.\n */\nexport function areSelectionsStatesEqual(\n\tselection1: SelectionState,\n\tselection2: SelectionState\n): boolean {\n\tif ( selection1.type !== selection2.type ) {\n\t\treturn false;\n\t}\n\n\tswitch ( selection1.type ) {\n\t\tcase SelectionType.None:\n\t\t\treturn true;\n\n\t\tcase SelectionType.Cursor:\n\t\t\treturn areCursorPositionsEqual(\n\t\t\t\tselection1.cursorPosition,\n\t\t\t\t( selection2 as SelectionCursor ).cursorPosition\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInOneBlock:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInOneBlock ).selectionDirection\n\t\t\t);\n\n\t\tcase SelectionType.SelectionInMultipleBlocks:\n\t\t\treturn (\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorStartPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorStartPosition\n\t\t\t\t) &&\n\t\t\t\tareCursorPositionsEqual(\n\t\t\t\t\tselection1.cursorEndPosition,\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.cursorEndPosition\n\t\t\t\t) &&\n\t\t\t\tselection1.selectionDirection ===\n\t\t\t\t\t( selection2 as SelectionInMultipleBlocks )\n\t\t\t\t\t\t.selectionDirection\n\t\t\t);\n\t\tcase SelectionType.WholeBlock:\n\t\t\treturn Y.compareRelativePositions(\n\t\t\t\tselection1.blockPosition,\n\t\t\t\t( selection2 as SelectionWholeBlock ).blockPosition\n\t\t\t);\n\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Check if two cursor positions are equal.\n *\n * @param cursorPosition1 - The first cursor position.\n * @param cursorPosition2 - The second cursor position.\n * @return True if the cursor positions are equal, false otherwise.\n */\nfunction areCursorPositionsEqual(\n\tcursorPosition1: CursorPosition,\n\tcursorPosition2: CursorPosition\n): boolean {\n\tconst isRelativePositionEqual = Y.compareRelativePositions(\n\t\tcursorPosition1.relativePosition,\n\t\tcursorPosition2.relativePosition\n\t);\n\n\t// Ensure a change in calculated absolute offset results in a treating the cursor as modified.\n\t// This is necessary because Y.Text relative positions can remain the same after text changes.\n\tconst isAbsoluteOffsetEqual =\n\t\tcursorPosition1.absoluteOffset === cursorPosition2.absoluteOffset;\n\n\treturn isRelativePositionEqual && isAbsoluteOffsetEqual;\n}\n", "/**\n * WordPress dependencies\n */\nimport type { ConnectionStatusDisconnected, Y } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport type { SelectionType } from './utils/crdt-user-selections';\n\nexport type { ConnectionStatus } from '@wordpress/sync';\n\nexport type ConnectionError = NonNullable<\n\tConnectionStatusDisconnected[ 'error' ]\n>;\n\nexport interface AnyFunction {\n\t( ...args: any[] ): any;\n}\n\n/**\n * An index path from the root of the block tree to a specific block.\n *\n * For example, `[0, 1]` refers to `blocks[0].innerBlocks[1]`.\n *\n * These paths are \"absolute\" in that they start from the post content root\n * (not from the template root when \"Show Template\" mode is active).\n * Both the Yjs document and the block-editor store share the same tree\n * structure for post content blocks, so the same path can be used to\n * navigate either tree.\n */\nexport type AbsoluteBlockIndexPath = number[];\n\n/**\n * Avoid a circular dependency with @wordpress/editor\n *\n * Additionaly, this type marks `attributeKey` and `offset` as possibly\n * `undefined`, which can happen in two known scenarios:\n *\n * 1. If a user has an entire block highlighted (e.g., a `core/image` block).\n * 2. If there's an intermediate selection state while inserting a block, those\n *    properties will be temporarily`undefined`.\n */\nexport interface WPBlockSelection {\n\tclientId: string;\n\tattributeKey?: string;\n\toffset?: number;\n}\n\nexport interface WPSelection {\n\tselectionEnd: WPBlockSelection;\n\tselectionStart: WPBlockSelection;\n\tinitialPosition?: number | null;\n}\n\n/**\n * The position of the cursor.\n */\nexport type CursorPosition = {\n\trelativePosition: Y.RelativePosition;\n\n\t// Also store the absolute offset index of the cursor from the perspective\n\t// of the user who is updating the selection.\n\t//\n\t// Do not use this value directly, instead use `createAbsolutePositionFromRelativePosition()`\n\t// on relativePosition for the most up-to-date positioning.\n\t//\n\t// This is used because local Y.Text changes (e.g. adding or deleting a character)\n\t// can result in the same relative position if it is pinned to an unchanged\n\t// character. With both of these values as editor state, a change in perceived\n\t// position will always result in a redraw.\n\tabsoluteOffset: number;\n};\n\n/**\n * The direction of a text selection, indicating where the caret sits.\n */\nexport enum SelectionDirection {\n\t/** The caret is at the end of the selection (default / left-to-right). */\n\tForward = 'f',\n\t/** The caret is at the start of the selection (right-to-left). */\n\tBackward = 'b',\n}\n\nexport type SelectionNone = {\n\t// The user has not made a selection.\n\ttype: SelectionType.None;\n};\n\nexport type SelectionCursor = {\n\t// The user has a cursor position in a block with no text highlighted.\n\t// The block is derived on the receiver side by navigating up from the\n\t// resolved cursorPosition via Y.AbstractType.parent.\n\ttype: SelectionType.Cursor;\n\tcursorPosition: CursorPosition;\n};\n\nexport type SelectionInOneBlock = {\n\t// The user has highlighted text in a single block.\n\t// The block is derived on the receiver side by navigating up from the\n\t// resolved cursorStartPosition via Y.AbstractType.parent.\n\ttype: SelectionType.SelectionInOneBlock;\n\tcursorStartPosition: CursorPosition;\n\tcursorEndPosition: CursorPosition;\n\t// The direction of the selection, indicating where the caret sits.\n\tselectionDirection?: SelectionDirection;\n};\n\nexport type SelectionInMultipleBlocks = {\n\t// The user has highlighted text over multiple blocks.\n\t// The blocks are derived on the receiver side by navigating up from the\n\t// resolved cursor positions via Y.AbstractType.parent.\n\ttype: SelectionType.SelectionInMultipleBlocks;\n\tcursorStartPosition: CursorPosition;\n\tcursorEndPosition: CursorPosition;\n\t// The direction of the selection, indicating where the caret sits.\n\tselectionDirection?: SelectionDirection;\n};\n\nexport type SelectionWholeBlock = {\n\t// The user has a non-text block selected, like an image block.\n\t// Uses a Y.RelativePosition pointing to the block in its parent Y.Array,\n\t// since there is no text cursor to navigate up from.\n\ttype: SelectionType.WholeBlock;\n\tblockPosition: Y.RelativePosition;\n};\n\nexport type SelectionState =\n\t| SelectionNone\n\t| SelectionCursor\n\t| SelectionInOneBlock\n\t| SelectionInMultipleBlocks\n\t| SelectionWholeBlock;\n\nexport interface ResolvedSelection {\n\trichTextOffset: number | null;\n\tlocalClientId: string | null;\n}\n", "/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\n// @ts-expect-error No exported types.\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport {\n\ttype CRDTDoc,\n\ttype ObjectData,\n\ttype SyncConfig,\n\tY,\n} from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { BaseAwareness } from '../awareness/base-awareness';\nimport {\n\tdeserializeBlockAttributes,\n\tmergeCrdtBlocks,\n\tmergeRichTextUpdate,\n\ttype Block,\n\ttype YBlock,\n\ttype YBlocks,\n} from './crdt-blocks';\nimport { type Post } from '../entity-types/post';\nimport { CRDT_DOC_META_PERSISTENCE_KEY, CRDT_RECORD_MAP_KEY } from '../sync';\nimport type { WPSelection } from '../types';\nimport {\n\tgetSelectionHistory,\n\tgetShiftedSelection,\n\tupdateSelectionHistory,\n} from './crdt-selection';\nimport {\n\tcreateYMap,\n\tgetRootMap,\n\tisYMap,\n\ttype YMapRecord,\n\ttype YMapWrap,\n} from './crdt-utils';\n\n// Changes that can be applied to a post entity record.\nexport type PostChanges = Partial< Post > & {\n\tblocks?: Block[];\n\tcontent?: Post[ 'content' ] | string;\n\texcerpt?: Post[ 'excerpt' ] | string;\n\tselection?: WPSelection;\n\ttitle?: Post[ 'title' ] | string;\n};\n\n// A post record as represented in the CRDT document (Y.Map).\nexport interface YPostRecord extends YMapRecord {\n\tauthor: number;\n\t// Blocks are undefined when they need to be re-parsed from content.\n\tblocks: YBlocks | undefined;\n\tcontent: Y.Text;\n\tcategories: number[];\n\tcomment_status: string;\n\tdate: string | null;\n\texcerpt: Y.Text;\n\tfeatured_media: number;\n\tformat: string;\n\tmeta: YMapWrap< YMapRecord >;\n\tping_status: string;\n\tslug: string;\n\tstatus: string;\n\tsticky: boolean;\n\ttags: number[];\n\ttemplate: string;\n\ttitle: Y.Text;\n}\n\nexport const POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE = '_crdt_document';\n\n// Post meta keys that should *not* be synced.\nconst disallowedPostMetaKeys = new Set< string >( [\n\tPOST_META_KEY_FOR_CRDT_DOC_PERSISTENCE,\n] );\n\n/**\n * Given a set of local changes to a generic entity record, apply those changes\n * to the local Y.Doc.\n *\n * @param {CRDTDoc}               ydoc\n * @param {Partial< ObjectData >} changes\n * @return {void}\n */\nfunction defaultApplyChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: ObjectData\n): void {\n\tconst ymap = getRootMap( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.entries( changes ).forEach( ( [ key, newValue ] ) => {\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\t// Add support for additional data types here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Given a set of local changes to a post record, apply those changes to the\n * local Y.Doc.\n *\n * @param {CRDTDoc}     ydoc\n * @param {PostChanges} changes\n * @param {Set<string>} syncedProperties\n * @return {void}\n */\nexport function applyPostChangesToCRDTDoc(\n\tydoc: CRDTDoc,\n\tchanges: PostChanges,\n\tsyncedProperties: Set< string >\n): void {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tObject.keys( changes ).forEach( ( key ) => {\n\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newValue = changes[ key ];\n\n\t\t// Cannot serialize function values, so cannot sync them.\n\t\tif ( 'function' === typeof newValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch ( key ) {\n\t\t\tcase 'blocks': {\n\t\t\t\t// Blocks are undefined when they need to be re-parsed from content.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\t// Set to undefined instead of deleting the key. This is important\n\t\t\t\t\t// since we iterate over the Y.Map keys in getPostChangesFromCRDTDoc.\n\t\t\t\t\tymap.set( key, undefined );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tlet currentBlocks = ymap.get( key );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! ( currentBlocks instanceof Y.Array ) ) {\n\t\t\t\t\tcurrentBlocks = new Y.Array< YBlock >();\n\t\t\t\t\tymap.set( key, currentBlocks );\n\t\t\t\t}\n\n\t\t\t\t// Block changes from typing are bundled with a 'selection' update.\n\t\t\t\t// Pass the resulting cursor position to the mergeCrdtBlocks function.\n\t\t\t\tconst cursorPosition =\n\t\t\t\t\tchanges.selection?.selectionStart?.offset ?? null;\n\n\t\t\t\t// Merge blocks does not need `setValue` because it is operating on a\n\t\t\t\t// Yjs type that is already in the Y.Doc.\n\t\t\t\tmergeCrdtBlocks( currentBlocks, newValue, cursorPosition );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'content':\n\t\t\tcase 'excerpt':\n\t\t\tcase 'title': {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tlet rawValue = getRawValue( newValue );\n\n\t\t\t\t// Copy logic from prePersistPostType to ensure that the \"Auto\n\t\t\t\t// Draft\" template title is not synced.\n\t\t\t\tif (\n\t\t\t\t\tkey === 'title' &&\n\t\t\t\t\t! currentValue?.toString() &&\n\t\t\t\t\t'Auto Draft' === rawValue\n\t\t\t\t) {\n\t\t\t\t\trawValue = '';\n\t\t\t\t}\n\n\t\t\t\tif ( currentValue instanceof Y.Text ) {\n\t\t\t\t\tmergeRichTextUpdate( currentValue, rawValue ?? '' );\n\t\t\t\t} else {\n\t\t\t\t\tconst newYText = new Y.Text( rawValue ?? '' );\n\t\t\t\t\tymap.set( key, newYText );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// \"Meta\" is overloaded term; here, it refers to post meta.\n\t\t\tcase 'meta': {\n\t\t\t\tlet metaMap = ymap.get( 'meta' );\n\n\t\t\t\t// Initialize.\n\t\t\t\tif ( ! isYMap( metaMap ) ) {\n\t\t\t\t\tmetaMap = createYMap< YMapRecord >();\n\t\t\t\t\tymap.set( 'meta', metaMap );\n\t\t\t\t}\n\n\t\t\t\t// Iterate over each meta property in the new value and merge it if it\n\t\t\t\t// should be synced.\n\t\t\t\tObject.entries( newValue ?? {} ).forEach(\n\t\t\t\t\t( [ metaKey, metaValue ] ) => {\n\t\t\t\t\t\tif ( disallowedPostMetaKeys.has( metaKey ) ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tupdateMapValue(\n\t\t\t\t\t\t\tmetaMap,\n\t\t\t\t\t\t\tmetaKey,\n\t\t\t\t\t\t\tmetaMap.get( metaKey ), // current value in CRDT\n\t\t\t\t\t\t\tmetaValue // new value from changes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase 'slug': {\n\t\t\t\t// Do not sync an empty slug. This indicates that the post is using\n\t\t\t\t// the default auto-generated slug.\n\t\t\t\tif ( ! newValue ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t// Add support for additional properties here.\n\n\t\t\tdefault: {\n\t\t\t\tconst currentValue = ymap.get( key );\n\t\t\t\tupdateMapValue( ymap, key, currentValue, newValue );\n\t\t\t}\n\t\t}\n\t} );\n\n\t// Process changes that we don't want to persist to the CRDT document.\n\tif ( changes.selection ) {\n\t\tconst selection = changes.selection;\n\t\t// Persist selection changes at the end of the current event loop.\n\t\t// This allows undo meta to be saved with the current selection before\n\t\t// it is overwritten by the new selection from Gutenberg.\n\t\t// Without this, selection history will already contain the latest\n\t\t// selection (after this change) when the undo stack is saved.\n\t\tsetTimeout( () => {\n\t\t\tupdateSelectionHistory( ydoc, selection );\n\t\t}, 0 );\n\t}\n}\n\nfunction defaultGetChangesFromCRDTDoc( crdtDoc: CRDTDoc ): ObjectData {\n\treturn getRootMap( crdtDoc, CRDT_RECORD_MAP_KEY ).toJSON();\n}\n\n/**\n * Given a local Y.Doc that *may* contain changes from remote peers, compare\n * against the local record and determine if there are changes (edits) we want\n * to dispatch.\n *\n * @param {CRDTDoc}     ydoc\n * @param {Post}        editedRecord\n * @param {Set<string>} syncedProperties\n * @return {Partial<PostChanges>} The changes that should be applied to the local record.\n */\nexport function getPostChangesFromCRDTDoc(\n\tydoc: CRDTDoc,\n\teditedRecord: Post,\n\tsyncedProperties: Set< string >\n): PostChanges {\n\tconst ymap = getRootMap< YPostRecord >( ydoc, CRDT_RECORD_MAP_KEY );\n\n\tlet allowedMetaChanges: Post[ 'meta' ] = {};\n\n\tconst changes = Object.fromEntries(\n\t\tObject.entries( ymap.toJSON() ).filter( ( [ key, newValue ] ) => {\n\t\t\tif ( ! syncedProperties.has( key ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst currentValue = editedRecord[ key ];\n\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'blocks': {\n\t\t\t\t\t// When we are passed a persisted CRDT document, make a special\n\t\t\t\t\t// comparison of the content and blocks.\n\t\t\t\t\t//\n\t\t\t\t\t// When other fields (besides `blocks`) are mutated outside the block\n\t\t\t\t\t// editor, the change is caught by an equality check (see other cases\n\t\t\t\t\t// in this `switch` statement). As a transient property, `blocks`\n\t\t\t\t\t// cannot be directly mutated outside the block editor -- only\n\t\t\t\t\t// `content` can.\n\t\t\t\t\t//\n\t\t\t\t\t// Therefore, for this special comparison, we serialize the `blocks`\n\t\t\t\t\t// from the persisted CRDT document and compare that to the content\n\t\t\t\t\t// from the persisted record. If they differ, we know that the content\n\t\t\t\t\t// in the database has changed, and therefore the blocks have changed.\n\t\t\t\t\t//\n\t\t\t\t\t// We cannot directly compare the `blocks` from the CRDT document to\n\t\t\t\t\t// the `blocks` derived from the `content` in the persisted record,\n\t\t\t\t\t// because the latter will have different client IDs.\n\t\t\t\t\tif (\n\t\t\t\t\t\tydoc.meta?.get( CRDT_DOC_META_PERSISTENCE_KEY ) &&\n\t\t\t\t\t\teditedRecord.content\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst blocksJson = ymap.get( 'blocks' )?.toJSON() ?? [];\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t__unstableSerializeAndClean( blocksJson ).trim() !==\n\t\t\t\t\t\t\tgetRawValue( editedRecord.content )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tcase 'date': {\n\t\t\t\t\t// Do not overwrite a \"floating\" date. Borrowing logic from the\n\t\t\t\t\t// isEditedPostDateFloating selector.\n\t\t\t\t\tconst currentDateIsFloating =\n\t\t\t\t\t\tnull === currentValue ||\n\t\t\t\t\t\teditedRecord.modified === currentValue;\n\n\t\t\t\t\tif ( currentDateIsFloating ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'meta': {\n\t\t\t\t\tallowedMetaChanges = Object.fromEntries(\n\t\t\t\t\t\tObject.entries( newValue ?? {} ).filter(\n\t\t\t\t\t\t\t( [ metaKey ] ) =>\n\t\t\t\t\t\t\t\t! disallowedPostMetaKeys.has( metaKey )\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\t// Merge the allowed meta changes with the current meta values since\n\t\t\t\t\t// not all meta properties are synced.\n\t\t\t\t\tconst mergedValue = {\n\t\t\t\t\t\t...( currentValue as PostChanges[ 'meta' ] ),\n\t\t\t\t\t\t...allowedMetaChanges,\n\t\t\t\t\t};\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, mergedValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'status': {\n\t\t\t\t\t// Do not sync an invalid status.\n\t\t\t\t\tif ( 'auto-draft' === newValue ) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\n\t\t\t\tcase 'content':\n\t\t\t\tcase 'excerpt':\n\t\t\t\tcase 'title': {\n\t\t\t\t\treturn haveValuesChanged(\n\t\t\t\t\t\tgetRawValue( currentValue ),\n\t\t\t\t\t\tnewValue\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// Add support for additional data types here.\n\n\t\t\t\tdefault: {\n\t\t\t\t\treturn haveValuesChanged( currentValue, newValue );\n\t\t\t\t}\n\t\t\t}\n\t\t} )\n\t);\n\n\t// Blocks extracted from the CRDT document have rich-text attributes as\n\t// plain strings (from Y.Text.toJSON()). Convert them back to RichTextData\n\t// so block edit components receive the same types as locally-created blocks.\n\tif ( changes.blocks ) {\n\t\tchanges.blocks = deserializeBlockAttributes(\n\t\t\tchanges.blocks as Block[]\n\t\t);\n\t}\n\n\t// Meta changes must be merged with the edited record since not all meta\n\t// properties are synced.\n\tif ( 'object' === typeof changes.meta ) {\n\t\tchanges.meta = {\n\t\t\t...editedRecord.meta,\n\t\t\t...allowedMetaChanges,\n\t\t};\n\t}\n\n\t// When remote content changes are detected, recalculate the local user's\n\t// selection using Y.RelativePosition to account for text shifts. The ydoc\n\t// has already been updated with remote content at this point, so converting\n\t// relative positions to absolute gives corrected offsets. Including the\n\t// selection in PostChanges ensures it dispatches atomically with content.\n\tconst selectionHistory = getSelectionHistory( ydoc );\n\tconst shiftedSelection = getShiftedSelection( ydoc, selectionHistory );\n\tif ( shiftedSelection ) {\n\t\tchanges.selection = {\n\t\t\t...shiftedSelection,\n\t\t\tinitialPosition: 0,\n\t\t};\n\t}\n\n\treturn changes;\n}\n\n/**\n * This default sync config can be used for entities that are flat maps of\n * primitive values and do not require custom logic to merge changes.\n */\nexport const defaultSyncConfig: SyncConfig = {\n\tapplyChangesToCRDTDoc: defaultApplyChangesToCRDTDoc,\n\tcreateAwareness: ( ydoc: CRDTDoc ) => new BaseAwareness( ydoc ),\n\tgetChangesFromCRDTDoc: defaultGetChangesFromCRDTDoc,\n};\n\n/**\n * Extract the raw string value from a property that may be a string or an object\n * with a `raw` property (`RenderedText`).\n *\n * @param {unknown} value The value to extract from.\n * @return {string|undefined} The raw string value, or undefined if it could not be determined.\n */\nfunction getRawValue( value?: unknown ): string | undefined {\n\t// Value may be a string property or a nested object with a `raw` property.\n\tif ( 'string' === typeof value ) {\n\t\treturn value;\n\t}\n\n\tif (\n\t\tvalue &&\n\t\t'object' === typeof value &&\n\t\t'raw' in value &&\n\t\t'string' === typeof value.raw\n\t) {\n\t\treturn value.raw;\n\t}\n\n\treturn undefined;\n}\n\nfunction haveValuesChanged< ValueType >(\n\tcurrentValue: ValueType | undefined,\n\tnewValue: ValueType | undefined\n): boolean {\n\treturn ! fastDeepEqual( currentValue, newValue );\n}\n\nfunction updateMapValue< T extends YMapRecord, K extends keyof T >(\n\tmap: YMapWrap< T >,\n\tkey: K,\n\tcurrentValue: T[ K ] | undefined,\n\tnewValue: T[ K ] | undefined\n): void {\n\tif ( undefined === newValue ) {\n\t\tmap.delete( key );\n\t\treturn;\n\t}\n\n\tif ( haveValuesChanged< T[ K ] >( currentValue, newValue ) ) {\n\t\tmap.set( key, newValue );\n\t}\n}\n", "// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n  // lazy load so that environments that need to polyfill have a chance to do so\n  if (!getRandomValues) {\n    // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n    getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n    if (!getRandomValues) {\n      throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n    }\n  }\n\n  return getRandomValues(rnds8);\n}", "import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n  byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n  // Note: Be careful editing this code!  It's been tuned for performance\n  // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n  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]];\n}\n\nfunction stringify(arr, offset = 0) {\n  const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID.  If this throws, it's likely due to one\n  // of the following:\n  // - One or more input array values don't map to a hex octet (leading to\n  // \"undefined\" in the uuid)\n  // - Invalid input values for the RFC `version` or `variant` fields\n\n  if (!validate(uuid)) {\n    throw TypeError('Stringified UUID is invalid');\n  }\n\n  return uuid;\n}\n\nexport default stringify;", "const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n  randomUUID\n};", "import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n  if (native.randomUUID && !buf && !options) {\n    return native.randomUUID();\n  }\n\n  options = options || {};\n  const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n  rnds[6] = rnds[6] & 0x0f | 0x40;\n  rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n  if (buf) {\n    offset = offset || 0;\n\n    for (let i = 0; i < 16; ++i) {\n      buf[offset + i] = rnds[i];\n    }\n\n    return buf;\n  }\n\n  return unsafeStringify(rnds);\n}\n\nexport default v4;", "/**\n * External dependencies\n */\nimport { v4 as uuidv4 } from 'uuid';\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\n\n/**\n * WordPress dependencies\n */\n// @ts-expect-error No exported types.\nimport { getBlockTypes } from '@wordpress/blocks';\nimport { RichTextData } from '@wordpress/rich-text';\nimport { Y } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { createYMap, type YMapRecord, type YMapWrap } from './crdt-utils';\nimport { getCachedRichTextData } from './crdt-text';\nimport { Delta } from '../sync';\n\ninterface BlockAttributes {\n\t[ key: string ]: unknown;\n}\n\ninterface BlockAttributeType {\n\trole?: string;\n\ttype?: string;\n\tquery?: Record< string, BlockAttributeType >;\n}\n\ninterface BlockType {\n\tattributes?: Record< string, BlockAttributeType >;\n\tname: string;\n}\n\n// A block as represented in Gutenberg's data store.\nexport interface Block {\n\tattributes: BlockAttributes;\n\tclientId?: string;\n\tinnerBlocks: Block[];\n\tisValid?: boolean;\n\tname: string;\n\toriginalContent?: string;\n\tvalidationIssues?: string[]; // unserializable\n}\n\n// A block as represented in the CRDT document (Y.Map).\nexport interface YBlockRecord extends YMapRecord {\n\tattributes: YBlockAttributes;\n\tclientId: string;\n\tinnerBlocks: YBlocks;\n\tisValid?: boolean;\n\toriginalContent?: string;\n\tname: string;\n}\n\nexport type YBlock = YMapWrap< YBlockRecord >;\nexport type YBlocks = Y.Array< YBlock >;\n\n// Block attribute schema cannot be known at compile time, so we use Y.Map.\n// Attribute values will be typed as the union of `Y.Text` and `unknown`.\nexport type YBlockAttributes = Y.Map< Y.Text | unknown >;\n\nconst serializableBlocksCache = new WeakMap< WeakKey, Block[] >();\n\n/**\n * Recursively walk an attribute value and convert any RichTextData instances\n * to their string (HTML) representation. This is necessary for array-type and\n * object-type attributes, which can contain nested RichTextData.\n *\n * @param value The attribute value to serialize.\n * @return The value with all RichTextData instances replaced by strings.\n */\nfunction serializeAttributeValue( value: unknown ): unknown {\n\tif ( value instanceof RichTextData ) {\n\t\treturn value.valueOf();\n\t}\n\n\t// e.g. core/table `body`: [ { cells: [ { content: RichTextData } ] } ]\n\tif ( Array.isArray( value ) ) {\n\t\treturn value.map( serializeAttributeValue );\n\t}\n\n\t// e.g. a single row inside core/table `body`: { cells: [ ... ] }\n\tif ( value && typeof value === 'object' ) {\n\t\tconst result: Record< string, unknown > = {};\n\n\t\tfor ( const [ k, v ] of Object.entries( value ) ) {\n\t\t\tresult[ k ] = serializeAttributeValue( v );\n\t\t}\n\t\treturn result;\n\t}\n\n\treturn value;\n}\n\nfunction makeBlockAttributesSerializable(\n\tblockName: string,\n\tattributes: BlockAttributes\n): BlockAttributes {\n\tconst newAttributes = { ...attributes };\n\tfor ( const [ key, value ] of Object.entries( attributes ) ) {\n\t\tif ( isLocalAttribute( blockName, key ) ) {\n\t\t\tdelete newAttributes[ key ];\n\t\t\tcontinue;\n\t\t}\n\n\t\tnewAttributes[ key ] = serializeAttributeValue( value );\n\t}\n\treturn newAttributes;\n}\n\nfunction makeBlocksSerializable( blocks: Block[] ): Block[] {\n\treturn blocks.map( ( block: Block ) => {\n\t\tconst { name, innerBlocks, attributes, ...rest } = block;\n\t\tdelete rest.validationIssues;\n\t\treturn {\n\t\t\t...rest,\n\t\t\tname,\n\t\t\tattributes: makeBlockAttributesSerializable( name, attributes ),\n\t\t\tinnerBlocks: makeBlocksSerializable( innerBlocks ),\n\t\t};\n\t} );\n}\n\n/**\n * Recursively walk an attribute value and convert any strings that correspond\n * to rich-text schema nodes into RichTextData instances. This is the inverse\n * of serializeAttributeValue and handles nested structures like table cells.\n *\n * @param schema The attribute type definition for this value.\n * @param value  The attribute value from CRDT (toJSON).\n * @return The value with rich-text strings replaced by RichTextData.\n */\nfunction deserializeAttributeValue(\n\tschema: BlockAttributeType | undefined,\n\tvalue: unknown\n): unknown {\n\tif ( schema?.type === 'rich-text' && typeof value === 'string' ) {\n\t\treturn getCachedRichTextData( value );\n\t}\n\n\t// e.g. core/table `body`: [ { cells: [ { content: RichTextData } ] } ]\n\tif ( Array.isArray( value ) ) {\n\t\treturn value.map( ( item ) =>\n\t\t\tdeserializeAttributeValue( schema, item )\n\t\t);\n\t}\n\n\t// e.g. a single row inside core/table `body`: { cells: [ ... ] }\n\tif ( value && typeof value === 'object' ) {\n\t\tconst result: Record< string, unknown > = {};\n\n\t\tfor ( const [ key, innerValue ] of Object.entries(\n\t\t\tvalue as Record< string, unknown >\n\t\t) ) {\n\t\t\tresult[ key ] = deserializeAttributeValue(\n\t\t\t\tschema?.query?.[ key ],\n\t\t\t\tinnerValue\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\treturn value;\n}\n\n/**\n * Convert blocks from their CRDT-serialized form back to the runtime form\n * expected by the block editor. Rich-text attributes are stored as Y.Text in\n * the CRDT document, which serializes to plain strings via toJSON(). This\n * function restores them to RichTextData instances so that block edit\n * components that rely on RichTextData methods (e.g. `.text`) work correctly.\n *\n * @param blocks Blocks as extracted from the CRDT document via toJSON().\n * @return Blocks with rich-text attributes restored to RichTextData.\n */\nexport function deserializeBlockAttributes( blocks: Block[] ): Block[] {\n\treturn blocks.map( ( block: Block ) => {\n\t\tconst { name, innerBlocks, attributes, ...rest } = block;\n\n\t\tconst newAttributes = { ...attributes };\n\n\t\tfor ( const [ key, value ] of Object.entries( attributes ) ) {\n\t\t\tconst schema = getBlockAttributeType( name, key );\n\n\t\t\tif ( schema ) {\n\t\t\t\tnewAttributes[ key ] = deserializeAttributeValue(\n\t\t\t\t\tschema,\n\t\t\t\t\tvalue\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\t...rest,\n\t\t\tname,\n\t\t\tattributes: newAttributes,\n\t\t\tinnerBlocks: deserializeBlockAttributes( innerBlocks ?? [] ),\n\t\t};\n\t} );\n}\n\n/**\n * @param {any}   gblock\n * @param {Y.Map} yblock\n */\nfunction areBlocksEqual( gblock: Block, yblock: YBlock ): boolean {\n\tconst yblockAsJson = yblock.toJSON();\n\n\t// we must not sync clientId, as this can't be generated consistently and\n\t// hence will lead to merge conflicts.\n\tconst overwrites = {\n\t\tinnerBlocks: null,\n\t\tclientId: null,\n\t};\n\tconst res = fastDeepEqual(\n\t\tObject.assign( {}, gblock, overwrites ),\n\t\tObject.assign( {}, yblockAsJson, overwrites )\n\t);\n\tconst inners = gblock.innerBlocks || [];\n\tconst yinners = yblock.get( 'innerBlocks' );\n\treturn (\n\t\tres &&\n\t\tinners.length === yinners?.length &&\n\t\tinners.every( ( block: Block, i: number ) =>\n\t\t\tareBlocksEqual( block, yinners.get( i ) )\n\t\t)\n\t);\n}\n\nfunction createNewYAttributeMap(\n\tblockName: string,\n\tattributes: BlockAttributes\n): YBlockAttributes {\n\treturn new Y.Map(\n\t\tObject.entries( attributes ).map(\n\t\t\t( [ attributeName, attributeValue ] ) => {\n\t\t\t\treturn [\n\t\t\t\t\tattributeName,\n\t\t\t\t\tcreateNewYAttributeValue(\n\t\t\t\t\t\tblockName,\n\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\tattributeValue\n\t\t\t\t\t),\n\t\t\t\t];\n\t\t\t}\n\t\t)\n\t);\n}\n\nfunction createNewYAttributeValue(\n\tblockName: string,\n\tattributeName: string,\n\tattributeValue: unknown\n): Y.Text | unknown {\n\tconst isRichText = isRichTextAttribute( blockName, attributeName );\n\n\tif ( isRichText ) {\n\t\treturn new Y.Text( attributeValue?.toString() ?? '' );\n\t}\n\n\treturn attributeValue;\n}\n\nfunction createNewYBlock( block: Block ): YBlock {\n\treturn createYMap< YBlockRecord >(\n\t\tObject.fromEntries(\n\t\t\tObject.entries( block ).map( ( [ key, value ] ) => {\n\t\t\t\tswitch ( key ) {\n\t\t\t\t\tcase 'attributes': {\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tcreateNewYAttributeMap( block.name, value ),\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\n\t\t\t\t\tcase 'innerBlocks': {\n\t\t\t\t\t\tconst innerBlocks = new Y.Array();\n\n\t\t\t\t\t\t// If not an array, set to empty Y.Array.\n\t\t\t\t\t\tif ( ! Array.isArray( value ) ) {\n\t\t\t\t\t\t\treturn [ key, innerBlocks ];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tinnerBlocks.insert(\n\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\tvalue.map( ( innerBlock: Block ) =>\n\t\t\t\t\t\t\t\tcreateNewYBlock( innerBlock )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn [ key, innerBlocks ];\n\t\t\t\t\t}\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn [ key, value ];\n\t\t\t\t}\n\t\t\t} )\n\t\t)\n\t);\n}\n\n/**\n * Merge incoming block data into the local Y.Doc.\n * This function is called to sync local block changes to a shared Y.Doc.\n *\n * @param yblocks        The blocks in the local Y.Doc.\n * @param incomingBlocks Gutenberg blocks being synced.\n * @param cursorPosition The position of the cursor after the change occurs.\n */\nexport function mergeCrdtBlocks(\n\tyblocks: YBlocks,\n\tincomingBlocks: Block[],\n\tcursorPosition: number | null\n): void {\n\t// Ensure we are working with serializable block data.\n\tif ( ! serializableBlocksCache.has( incomingBlocks ) ) {\n\t\tserializableBlocksCache.set(\n\t\t\tincomingBlocks,\n\t\t\tmakeBlocksSerializable( incomingBlocks )\n\t\t);\n\t}\n\tconst blocksToSync = serializableBlocksCache.get( incomingBlocks ) ?? [];\n\n\t// This is a rudimentary diff implementation similar to the y-prosemirror diffing\n\t// approach.\n\t// A better implementation would also diff the textual content and represent it\n\t// using a Y.Text type.\n\t// However, at this time it makes more sense to keep this algorithm generic to\n\t// support all kinds of block types.\n\t// Ideally, we ensure that block data structure have a consistent data format.\n\t// E.g.:\n\t//   - textual content (using rich-text formatting?) may always be stored under `block.text`\n\t//   - local information that shouldn't be shared (e.g. clientId or isDragging) is stored under `block.private`\n\t//\n\t// @credit Kevin Jahns (dmonad)\n\t// @link https://github.com/WordPress/gutenberg/pull/68483\n\tconst numOfCommonEntries = Math.min(\n\t\tblocksToSync.length ?? 0,\n\t\tyblocks.length\n\t);\n\n\tlet left = 0;\n\tlet right = 0;\n\n\t// skip equal blocks from left\n\tfor (\n\t\t;\n\t\tleft < numOfCommonEntries &&\n\t\tareBlocksEqual( blocksToSync[ left ], yblocks.get( left ) );\n\t\tleft++\n\t) {\n\t\t/* nop */\n\t}\n\n\t// skip equal blocks from right\n\tfor (\n\t\t;\n\t\tright < numOfCommonEntries - left &&\n\t\tareBlocksEqual(\n\t\t\tblocksToSync[ blocksToSync.length - right - 1 ],\n\t\t\tyblocks.get( yblocks.length - right - 1 )\n\t\t);\n\t\tright++\n\t) {\n\t\t/* nop */\n\t}\n\n\tconst numOfUpdatesNeeded = numOfCommonEntries - left - right;\n\tconst numOfInsertionsNeeded = Math.max(\n\t\t0,\n\t\tblocksToSync.length - yblocks.length\n\t);\n\tconst numOfDeletionsNeeded = Math.max(\n\t\t0,\n\t\tyblocks.length - blocksToSync.length\n\t);\n\n\t// updates\n\tfor ( let i = 0; i < numOfUpdatesNeeded; i++, left++ ) {\n\t\tconst block = blocksToSync[ left ];\n\t\tconst yblock = yblocks.get( left );\n\t\tObject.entries( block ).forEach( ( [ key, value ] ) => {\n\t\t\tswitch ( key ) {\n\t\t\t\tcase 'attributes': {\n\t\t\t\t\tconst currentAttributes = yblock.get( key );\n\n\t\t\t\t\t// If attributes are not set on the yblock, use the new values.\n\t\t\t\t\tif ( ! currentAttributes ) {\n\t\t\t\t\t\tyblock.set(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tcreateNewYAttributeMap( block.name, value )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tObject.entries( value ).forEach(\n\t\t\t\t\t\t( [ attributeName, attributeValue ] ) => {\n\t\t\t\t\t\t\tconst currentAttribute =\n\t\t\t\t\t\t\t\tcurrentAttributes?.get( attributeName );\n\n\t\t\t\t\t\t\tconst isExpectedType = isExpectedAttributeType(\n\t\t\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\t\tcurrentAttribute\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst isAttributeChanged =\n\t\t\t\t\t\t\t\t! isExpectedType ||\n\t\t\t\t\t\t\t\t! fastDeepEqual(\n\t\t\t\t\t\t\t\t\tcurrentAttribute,\n\t\t\t\t\t\t\t\t\tattributeValue\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif ( isAttributeChanged ) {\n\t\t\t\t\t\t\t\tupdateYBlockAttribute(\n\t\t\t\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\t\t\tattributeValue,\n\t\t\t\t\t\t\t\t\tcurrentAttributes,\n\t\t\t\t\t\t\t\t\tcursorPosition\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\t// Delete any attributes that are no longer present.\n\t\t\t\t\tcurrentAttributes.forEach(\n\t\t\t\t\t\t( _attrValue: unknown, attrName: string ) => {\n\t\t\t\t\t\t\tif ( ! value.hasOwnProperty( attrName ) ) {\n\t\t\t\t\t\t\t\tcurrentAttributes.delete( attrName );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'innerBlocks': {\n\t\t\t\t\t// Recursively merge innerBlocks\n\t\t\t\t\tlet yInnerBlocks = yblock.get( key );\n\n\t\t\t\t\tif ( ! ( yInnerBlocks instanceof Y.Array ) ) {\n\t\t\t\t\t\tyInnerBlocks = new Y.Array< YBlock >();\n\t\t\t\t\t\tyblock.set( key, yInnerBlocks );\n\t\t\t\t\t}\n\n\t\t\t\t\tmergeCrdtBlocks(\n\t\t\t\t\t\tyInnerBlocks,\n\t\t\t\t\t\tvalue ?? [],\n\t\t\t\t\t\tcursorPosition\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t\t\tif ( ! fastDeepEqual( block[ key ], yblock.get( key ) ) ) {\n\t\t\t\t\t\tyblock.set( key, value );\n\t\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t\tyblock.forEach( ( _v, k ) => {\n\t\t\tif ( ! block.hasOwnProperty( k ) ) {\n\t\t\t\tyblock.delete( k );\n\t\t\t}\n\t\t} );\n\t}\n\n\t// deletes\n\tyblocks.delete( left, numOfDeletionsNeeded );\n\n\t// inserts\n\tfor ( let i = 0; i < numOfInsertionsNeeded; i++, left++ ) {\n\t\tconst newBlock = [ createNewYBlock( blocksToSync[ left ] ) ];\n\n\t\tyblocks.insert( left, newBlock );\n\t}\n\n\t// remove duplicate clientids\n\tconst knownClientIds = new Set< string >();\n\tfor ( let j = 0; j < yblocks.length; j++ ) {\n\t\tconst yblock: YBlock = yblocks.get( j );\n\n\t\tlet clientId = yblock.get( 'clientId' );\n\n\t\tif ( ! clientId ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ( knownClientIds.has( clientId ) ) {\n\t\t\tclientId = uuidv4();\n\t\t\tyblock.set( 'clientId', clientId );\n\t\t}\n\t\tknownClientIds.add( clientId );\n\t}\n}\n\n/**\n * Update a single attribute on a Yjs block attributes map (currentAttributes).\n *\n * For rich-text attributes that already exist as Y.Text instances, the update\n * is applied as a delta merge so that concurrent edits are preserved. All\n * other attributes are replaced wholesale via `createNewYAttributeValue`.\n *\n * @param blockName         The block type name, e.g. 'core/paragraph'.\n * @param attributeName     The name of the attribute to update, e.g. 'content'.\n * @param attributeValue    The new value for the attribute.\n * @param currentAttributes The Y.Map holding the block's current attributes.\n * @param cursorPosition    The local cursor position, used when merging rich-text deltas.\n */\nfunction updateYBlockAttribute(\n\tblockName: string,\n\tattributeName: string,\n\tattributeValue: unknown,\n\tcurrentAttributes: YBlockAttributes,\n\tcursorPosition: number | null\n): void {\n\tconst isRichText = isRichTextAttribute( blockName, attributeName );\n\tconst currentAttribute = currentAttributes.get( attributeName );\n\n\tif (\n\t\tisRichText &&\n\t\t'string' === typeof attributeValue &&\n\t\tcurrentAttributes.has( attributeName ) &&\n\t\tcurrentAttribute instanceof Y.Text\n\t) {\n\t\t// Rich text values are stored as persistent Y.Text instances.\n\t\t// Update the value with a delta in place.\n\t\tmergeRichTextUpdate( currentAttribute, attributeValue, cursorPosition );\n\t} else {\n\t\tcurrentAttributes.set(\n\t\t\tattributeName,\n\t\t\tcreateNewYAttributeValue( blockName, attributeName, attributeValue )\n\t\t);\n\t}\n}\n\n// Cached block attribute types, populated once from getBlockTypes().\nlet cachedBlockAttributeTypes: Map< string, Map< string, BlockAttributeType > >;\n\n/**\n * Get the attribute type definition for a block attribute.\n *\n * @param blockName     The name of the block, e.g. 'core/paragraph'.\n * @param attributeName The name of the attribute, e.g. 'content'.\n * @return The type definition of the attribute.\n */\nfunction getBlockAttributeType(\n\tblockName: string,\n\tattributeName: string\n): BlockAttributeType | undefined {\n\tif ( ! cachedBlockAttributeTypes ) {\n\t\t// Parse the attributes for all blocks once.\n\t\tcachedBlockAttributeTypes = new Map();\n\n\t\tfor ( const blockType of getBlockTypes() as BlockType[] ) {\n\t\t\tcachedBlockAttributeTypes.set(\n\t\t\t\tblockType.name,\n\t\t\t\tnew Map< string, BlockAttributeType >(\n\t\t\t\t\tObject.entries( blockType.attributes ?? {} ).map(\n\t\t\t\t\t\t( [ name, definition ] ) => {\n\t\t\t\t\t\t\tconst { role, type, query } = definition;\n\t\t\t\t\t\t\treturn [ name, { role, type, query } ];\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\treturn cachedBlockAttributeTypes.get( blockName )?.get( attributeName );\n}\n\n/**\n * Check if an attribute value is the expected type.\n *\n * @param blockName      The name of the block, e.g. 'core/paragraph'.\n * @param attributeName  The name of the attribute, e.g. 'content'.\n * @param attributeValue The current attribute value.\n * @return True if the attribute type is expected, false otherwise.\n */\nfunction isExpectedAttributeType(\n\tblockName: string,\n\tattributeName: string,\n\tattributeValue: unknown\n): boolean {\n\tconst expectedAttributeType = getBlockAttributeType(\n\t\tblockName,\n\t\tattributeName\n\t)?.type;\n\n\tif ( expectedAttributeType === 'rich-text' ) {\n\t\treturn attributeValue instanceof Y.Text;\n\t}\n\n\tif ( expectedAttributeType === 'string' ) {\n\t\treturn typeof attributeValue === 'string';\n\t}\n\n\t// No other types comparisons use special logic.\n\treturn true;\n}\n\n/**\n * Given a block name and attribute key, return true if the attribute is local\n * and should not be synced.\n *\n * @param blockName     The name of the block, e.g. 'core/image'.\n * @param attributeName The name of the attribute to check, e.g. 'blob'.\n * @return True if the attribute is local, false otherwise.\n */\nfunction isLocalAttribute( blockName: string, attributeName: string ): boolean {\n\treturn 'local' === getBlockAttributeType( blockName, attributeName )?.role;\n}\n\n/**\n * Given a block name and attribute key, return true if the attribute is rich-text typed.\n *\n * @param blockName     The name of the block, e.g. 'core/paragraph'.\n * @param attributeName The name of the attribute to check, e.g. 'content'.\n * @return True if the attribute is rich-text typed, false otherwise.\n */\nfunction isRichTextAttribute(\n\tblockName: string,\n\tattributeName: string\n): boolean {\n\treturn (\n\t\t'rich-text' === getBlockAttributeType( blockName, attributeName )?.type\n\t);\n}\n\nlet localDoc: Y.Doc;\n\n/**\n * Given a Y.Text object and an updated string value, diff the new value and\n * apply the delta to the Y.Text.\n *\n * @param blockYText     The Y.Text to update.\n * @param updatedValue   The updated value.\n * @param cursorPosition The position of the cursor after the change occurs.\n */\nexport function mergeRichTextUpdate(\n\tblockYText: Y.Text,\n\tupdatedValue: string,\n\tcursorPosition: number | null = null\n): void {\n\t// Gutenberg does not use Yjs shared types natively, so we can only subscribe\n\t// to changes from store and apply them to Yjs types that we create and\n\t// manage. Crucially, for rich-text attributes, we do not receive granular\n\t// string updates; we get the new full string value on each change, even when\n\t// only a single character changed.\n\t//\n\t// The code below allows us to compute a delta between the current and new\n\t// value, then apply it to the Y.Text.\n\n\tif ( ! localDoc ) {\n\t\t// Y.Text must be attached to a Y.Doc to be able to do operations on it.\n\t\t// Create a temporary Y.Text attached to a local Y.Doc for delta computation.\n\t\tlocalDoc = new Y.Doc();\n\t}\n\n\tconst localYText = localDoc.getText( 'temporary-text' );\n\tlocalYText.delete( 0, localYText.length );\n\tlocalYText.insert( 0, updatedValue );\n\n\tconst currentValueAsDelta = new Delta( blockYText.toDelta() );\n\tconst updatedValueAsDelta = new Delta( localYText.toDelta() );\n\tconst deltaDiff = currentValueAsDelta.diffWithCursor(\n\t\tupdatedValueAsDelta,\n\t\tcursorPosition\n\t);\n\n\tblockYText.applyDelta( deltaDiff.ops );\n}\n", "/**\n * WordPress dependencies\n */\nimport { RichTextData } from '@wordpress/rich-text';\n\nconst RICH_TEXT_CACHE_MAX_SIZE = 500;\n\n/**\n * Returns a function that converts HTML strings to RichTextData instances,\n * using a FIFO cache bounded by `maxSize` to avoid re-parsing identical\n * strings. Repeated calls with the same string return the cached instance\n * without re-running the HTML parser and DOM traversal.\n *\n * @param maxSize Maximum number of entries to hold in the cache.\n * @return A cached version of RichTextData.fromHTMLString.\n */\nexport function createRichTextDataCache(\n\tmaxSize: number\n): ( value: string ) => RichTextData {\n\tconst cache = new Map< string, RichTextData >();\n\n\treturn function ( value: string ): RichTextData {\n\t\tconst cached = cache.get( value );\n\n\t\tif ( cached ) {\n\t\t\treturn cached;\n\t\t}\n\n\t\tconst result = RichTextData.fromHTMLString( value );\n\n\t\tif ( cache.size >= maxSize ) {\n\t\t\t// Evict the oldest entry (Map preserves insertion order).\n\t\t\tcache.delete( cache.keys().next().value! );\n\t\t}\n\n\t\tcache.set( value, result );\n\t\treturn result;\n\t};\n}\n\nexport const getCachedRichTextData = createRichTextDataCache(\n\tRICH_TEXT_CACHE_MAX_SIZE\n);\n", "/**\n * WordPress dependencies\n */\nimport { dispatch, select } from '@wordpress/data';\n// @ts-expect-error No exported types.\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n// @ts-expect-error No exported types.\nimport { isUnmodifiedBlock } from '@wordpress/blocks';\nimport { type CRDTDoc, Y } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcreateBlockSelectionHistory,\n\tYSelectionType,\n\ttype BlockSelectionHistory,\n\ttype YFullSelection,\n\ttype YSelection,\n} from './block-selection-history';\nimport {\n\tfindBlockByClientIdInDoc,\n\thtmlIndexToRichTextOffset,\n} from './crdt-utils';\nimport type { WPBlockSelection, WPSelection } from '../types';\n\n// WeakMap to store BlockSelectionHistory instances per Y.Doc\nconst selectionHistoryMap = new WeakMap< CRDTDoc, BlockSelectionHistory >();\n\n/**\n * Get or create a BlockSelectionHistory instance for a given Y.Doc.\n *\n * @param ydoc The Y.Doc to get the selection history for\n * @return The BlockSelectionHistory instance\n */\nfunction getBlockSelectionHistory( ydoc: CRDTDoc ): BlockSelectionHistory {\n\tlet history = selectionHistoryMap.get( ydoc );\n\n\tif ( ! history ) {\n\t\thistory = createBlockSelectionHistory( ydoc );\n\t\tselectionHistoryMap.set( ydoc, history );\n\t}\n\n\treturn history;\n}\n\nexport function getSelectionHistory( ydoc: CRDTDoc ): YFullSelection[] {\n\treturn getBlockSelectionHistory( ydoc ).getSelectionHistory();\n}\n\nexport function updateSelectionHistory(\n\tydoc: CRDTDoc,\n\twpSelection: WPSelection\n): void {\n\treturn getBlockSelectionHistory( ydoc ).updateSelection( wpSelection );\n}\n\n/**\n * Convert a YSelection to a WPBlockSelection.\n * @param ySelection The YSelection (relative) to convert\n * @param ydoc       The Y.Doc to convert the selection to a block selection for\n * @return The converted WPBlockSelection, or null if the conversion fails\n */\nfunction convertYSelectionToBlockSelection(\n\tySelection: YSelection,\n\tydoc: Y.Doc\n): WPBlockSelection | null {\n\tif ( ySelection.type === YSelectionType.RelativeSelection ) {\n\t\tconst { relativePosition, attributeKey, clientId } = ySelection;\n\n\t\tconst absolutePosition = Y.createAbsolutePositionFromRelativePosition(\n\t\t\trelativePosition,\n\t\t\tydoc\n\t\t);\n\n\t\tif ( absolutePosition ) {\n\t\t\treturn {\n\t\t\t\tclientId,\n\t\t\t\tattributeKey,\n\t\t\t\toffset: htmlIndexToRichTextOffset(\n\t\t\t\t\tabsolutePosition.type.toString(),\n\t\t\t\t\tabsolutePosition.index\n\t\t\t\t),\n\t\t\t};\n\t\t}\n\t} else if ( ySelection.type === YSelectionType.BlockSelection ) {\n\t\treturn {\n\t\t\tclientId: ySelection.clientId,\n\t\t\tattributeKey: undefined,\n\t\t\toffset: undefined,\n\t\t};\n\t}\n\n\treturn null;\n}\n\n/**\n * Convert a YFullSelection to a WPSelection by resolving relative positions\n * and verifying the blocks exist in the document.\n * @param yFullSelection The YFullSelection to convert\n * @param ydoc           The Y.Doc to resolve positions against\n * @return The converted WPSelection, or null if the conversion fails\n */\nfunction convertYFullSelectionToWPSelection(\n\tyFullSelection: YFullSelection,\n\tydoc: Y.Doc\n): WPSelection | null {\n\tconst { start, end } = yFullSelection;\n\tconst startBlock = findBlockByClientIdInDoc( start.clientId, ydoc );\n\tconst endBlock = findBlockByClientIdInDoc( end.clientId, ydoc );\n\n\tif ( ! startBlock || ! endBlock ) {\n\t\treturn null;\n\t}\n\n\tconst startBlockSelection = convertYSelectionToBlockSelection(\n\t\tstart,\n\t\tydoc\n\t);\n\tconst endBlockSelection = convertYSelectionToBlockSelection( end, ydoc );\n\n\tif ( startBlockSelection === null || endBlockSelection === null ) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tselectionStart: startBlockSelection,\n\t\tselectionEnd: endBlockSelection,\n\t};\n}\n\n/**\n * Given a Y.Doc and a selection history, find the most recent selection\n * that exists in the document. Skip any selections that are not in the document.\n * @param ydoc             The Y.Doc to find the selection in\n * @param selectionHistory The selection history to check\n * @return The most recent selection that exists in the document, or null if no selection exists.\n */\nfunction findSelectionFromHistory(\n\tydoc: Y.Doc,\n\tselectionHistory: YFullSelection[]\n): WPSelection | null {\n\tfor ( const positionToTry of selectionHistory ) {\n\t\tconst result = convertYFullSelectionToWPSelection(\n\t\t\tpositionToTry,\n\t\t\tydoc\n\t\t);\n\t\tif ( result !== null ) {\n\t\t\treturn result;\n\t\t}\n\t}\n\n\treturn null;\n}\n\n/**\n * Restore the selection to the most recent selection in history that is\n * available in the document.\n * @param selectionHistory The selection history to restore\n * @param ydoc             The Y.Doc where blocks are stored\n */\nexport function restoreSelection(\n\tselectionHistory: YFullSelection[],\n\tydoc: Y.Doc\n): void {\n\t// Find the most recent selection in history that is available in\n\t// the document.\n\tconst selectionToRestore = findSelectionFromHistory(\n\t\tydoc,\n\t\tselectionHistory\n\t);\n\n\tif ( selectionToRestore === null ) {\n\t\t// Case 1: No blocks in history are available for restoration.\n\t\t// Do nothing.\n\t\treturn;\n\t}\n\n\tconst { getBlock } = select( blockEditorStore );\n\tconst { resetSelection } = dispatch( blockEditorStore );\n\tconst { selectionStart, selectionEnd } = selectionToRestore;\n\tconst isSelectionInSameBlock =\n\t\tselectionStart.clientId === selectionEnd.clientId;\n\n\tif ( isSelectionInSameBlock ) {\n\t\t// Case 2: After content is restored, the selection is available\n\t\t// within the same block\n\n\t\tconst block = getBlock( selectionStart.clientId );\n\t\tconst isBlockEmpty = block && isUnmodifiedBlock( block );\n\t\tconst isBeginningOfEmptyBlock =\n\t\t\t0 === selectionStart.offset &&\n\t\t\t0 === selectionEnd.offset &&\n\t\t\tisBlockEmpty &&\n\t\t\t! selectionStart.attributeKey &&\n\t\t\t! selectionEnd.attributeKey;\n\n\t\tif ( isBeginningOfEmptyBlock ) {\n\t\t\t// Case 2a: When the content in a block has been removed after an\n\t\t\t// undo, WordPress will set the selection to the block's client ID\n\t\t\t// with an undefined startOffset and endOffset.\n\t\t\t//\n\t\t\t// To match the default behavior and tests, exclude the selection\n\t\t\t// offset when resetting to position 0.\n\t\t\tconst selectionStartWithoutOffset = {\n\t\t\t\tclientId: selectionStart.clientId,\n\t\t\t};\n\t\t\tconst selectionEndWithoutOffset = {\n\t\t\t\tclientId: selectionEnd.clientId,\n\t\t\t};\n\n\t\t\tresetSelection(\n\t\t\t\tselectionStartWithoutOffset,\n\t\t\t\tselectionEndWithoutOffset,\n\t\t\t\t0\n\t\t\t);\n\t\t} else {\n\t\t\t// Case 2b: Otherwise, reset including the saved selection offset.\n\t\t\tresetSelection( selectionStart, selectionEnd, 0 );\n\t\t}\n\t} else {\n\t\t// Case 3: A multi-block selection was made. resetSelection() can only\n\t\t// restore selections within the same block.\n\t\t// When a multi-block selection is made, selectionEnd represents\n\t\t// where the user's cursor ended.\n\t\tresetSelection( selectionEnd, selectionEnd, 0 );\n\t}\n}\n\n/**\n * If the latest selection has been shifted by remote edits, resolve and return\n * it as a WPSelection. Returns null when the history is empty or neither\n * endpoint has moved.\n *\n * @param ydoc             The Y.Doc to resolve positions against\n * @param selectionHistory The selection history to check\n * @return The shifted WPSelection, or null if nothing moved.\n */\nexport function getShiftedSelection(\n\tydoc: Y.Doc,\n\tselectionHistory: YFullSelection[]\n): WPSelection | null {\n\tif ( selectionHistory.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst { start, end } = selectionHistory[ 0 ];\n\n\t// Block-level selections have no offset that can shift.\n\tif (\n\t\tstart.type === YSelectionType.BlockSelection ||\n\t\tend.type === YSelectionType.BlockSelection\n\t) {\n\t\treturn null;\n\t}\n\n\tconst selectionStart = convertYSelectionToBlockSelection( start, ydoc );\n\tconst selectionEnd = convertYSelectionToBlockSelection( end, ydoc );\n\n\tif ( ! selectionStart || ! selectionEnd ) {\n\t\treturn null;\n\t}\n\n\t// Only dispatch if at least one endpoint actually moved.\n\tconst startShifted = selectionStart.offset !== start.offset;\n\tconst endShifted = selectionEnd.offset !== end.offset;\n\n\tif ( ! startShifted && ! endShifted ) {\n\t\treturn null;\n\t}\n\n\treturn { selectionStart, selectionEnd };\n}\n", "/**\n * External dependencies\n */\n/**\n * WordPress dependencies\n */\nimport { Y } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport {\n\tfindBlockByClientIdInDoc,\n\trichTextOffsetToHtmlIndex,\n} from './crdt-utils';\nimport type { WPBlockSelection, WPSelection } from '../types';\n\n// Default size for selection history (not including current selection)\nconst SELECTION_HISTORY_DEFAULT_SIZE = 5;\n\nexport enum YSelectionType {\n\tRelativeSelection = 'RelativeSelection',\n\tBlockSelection = 'BlockSelection',\n}\n\nexport interface YRelativeSelection {\n\ttype: YSelectionType.RelativeSelection;\n\tattributeKey: string;\n\trelativePosition: Y.RelativePosition;\n\tclientId: string;\n\toffset: number;\n}\n\nexport interface YBlockSelection {\n\ttype: YSelectionType.BlockSelection;\n\tclientId: string;\n}\n\nexport type YSelection = YRelativeSelection | YBlockSelection;\n\nexport type YFullSelection = {\n\tstart: YSelection;\n\tend: YSelection;\n};\n\nexport interface YSelectionHistory {\n\tselection: YFullSelection;\n\tbackupSelections?: YFullSelection[];\n}\n\nexport interface BlockSelectionHistory {\n\tgetSelectionHistory: () => YFullSelection[];\n\tupdateSelection: ( newSelection: WPSelection ) => void;\n}\n\n/**\n * This function is used to track recent block selections to help in restoring\n * a user's selection after an undo or redo operation.\n *\n * Maintains a history array for previous selections, which can be used for\n * backup restoration locations.\n * @param ydoc\n * @param historySize\n */\nexport function createBlockSelectionHistory(\n\tydoc: Y.Doc,\n\thistorySize: number = SELECTION_HISTORY_DEFAULT_SIZE\n): BlockSelectionHistory {\n\tlet history: YFullSelection[] = [];\n\n\t/**\n\t * Get the block history including current selection.\n\t */\n\tconst getSelectionHistory = (): YFullSelection[] => {\n\t\treturn history.slice( 0 );\n\t};\n\n\t/**\n\t * Update the selection history with a new selection.\n\t * @param newSelection\n\t */\n\tconst updateSelection = ( newSelection: WPSelection ): void => {\n\t\tif (\n\t\t\t! newSelection?.selectionStart?.clientId ||\n\t\t\t! newSelection?.selectionEnd?.clientId\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { selectionStart, selectionEnd } = newSelection;\n\t\tconst start = convertWPBlockSelectionToSelection(\n\t\t\tselectionStart,\n\t\t\tydoc\n\t\t);\n\t\tconst end = convertWPBlockSelectionToSelection( selectionEnd, ydoc );\n\n\t\taddToHistory( { start, end } );\n\t};\n\n\t/**\n\t * Add a selection to the history, maintaining only the last `historySize` unique selections.\n\t * New selections are added to the front.\n\t * Removes any existing entries with the same start and end block combination.\n\t * @param yFullSelection\n\t */\n\tconst addToHistory = ( yFullSelection: YFullSelection ): void => {\n\t\t// Remove any existing entries with the same start and end block combination\n\t\tconst startClientId = yFullSelection.start.clientId;\n\t\tconst endClientId = yFullSelection.end.clientId;\n\n\t\thistory = history.filter( ( entry ) => {\n\t\t\tconst isSameBlockCombination =\n\t\t\t\tentry.start.clientId === startClientId &&\n\t\t\t\tentry.end.clientId === endClientId;\n\n\t\t\treturn ! isSameBlockCombination;\n\t\t} );\n\n\t\t// Add the new selection to the front\n\t\thistory.unshift( yFullSelection );\n\n\t\t// Trim to max size (remove oldest entries from the back)\n\t\tif ( history.length > historySize + 1 ) {\n\t\t\thistory = history.slice( 0, historySize + 1 );\n\t\t}\n\t};\n\n\treturn {\n\t\tgetSelectionHistory,\n\t\tupdateSelection,\n\t};\n}\n\n/**\n * Convert a WPBlockSelection to a YSelection.\n * @param selection\n * @param ydoc\n * @return A YSelection object.\n */\nfunction convertWPBlockSelectionToSelection(\n\tselection: WPBlockSelection,\n\tydoc: Y.Doc\n): YSelection {\n\tconst clientId = selection.clientId;\n\tconst block = findBlockByClientIdInDoc( clientId, ydoc );\n\tconst attributes = block?.get( 'attributes' );\n\tconst attributeKey = selection.attributeKey;\n\n\tconst changedYText = attributeKey\n\t\t? attributes?.get( attributeKey )\n\t\t: undefined;\n\n\tconst isYText = changedYText instanceof Y.Text;\n\tconst isFullyDefinedSelection = attributeKey && clientId;\n\n\tif ( ! isYText || ! isFullyDefinedSelection ) {\n\t\t// We either don't have a valid YText (it's been deleted) or we've\n\t\t// been passed a selection that's just a block clientId.\n\t\t// Store as BlockSelection.\n\t\treturn {\n\t\t\ttype: YSelectionType.BlockSelection,\n\t\t\tclientId,\n\t\t};\n\t}\n\n\tconst offset = selection.offset ?? 0;\n\tconst relativePosition = Y.createRelativePositionFromTypeIndex(\n\t\tchangedYText,\n\t\trichTextOffsetToHtmlIndex( changedYText.toString(), offset )\n\t);\n\n\treturn {\n\t\ttype: YSelectionType.RelativeSelection,\n\t\tattributeKey,\n\t\trelativePosition,\n\t\tclientId,\n\t\toffset,\n\t};\n}\n", "/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport type { UndoManager } from '@wordpress/undo-manager';\nimport deprecated from '@wordpress/deprecated';\nimport type { ConnectionStatus } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport {\n\tgetQueriedItems,\n\tgetQueriedTotalItems,\n\tgetQueriedTotalPages,\n} from './queried-data';\nimport { DEFAULT_ENTITY_KEY } from './entities';\nimport { getUndoManager } from './private-selectors';\nimport {\n\tgetNormalizedCommaSeparable,\n\tisRawAttribute,\n\tsetNestedValue,\n\tisNumericID,\n\tgetUserPermissionCacheKey,\n} from './utils';\nimport type * as ET from './entity-types';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\n// This is an incomplete, high-level approximation of the State type.\n// It makes the selectors slightly more safe, but is intended to evolve\n// into a more detailed representation over time.\n// See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.\nexport interface State {\n\tautosaves: Record< string | number, Array< unknown > >;\n\tblockPatterns: Array< unknown >;\n\tblockPatternCategories: Array< unknown >;\n\tcurrentGlobalStylesId: string;\n\tcurrentTheme: string;\n\tcurrentUser: ET.User< 'view' >;\n\tembedPreviews: Record< string, { html: string } >;\n\tentities: EntitiesState;\n\tthemeBaseGlobalStyles: Record< string, Object >;\n\tthemeGlobalStyleVariations: Record< string, string >;\n\tthemeGlobalStyleRevisions: Record< number, Object >;\n\tundoManager: UndoManager;\n\tuserPermissions: Record< string, boolean >;\n\tusers: UserState;\n\tnavigationFallbackId: EntityRecordKey;\n\tuserPatternCategories: Array< UserPatternCategory >;\n\tdefaultTemplates: Record< string, string >;\n\tregisteredPostMeta: Record< string, Object >;\n\teditorSettings: Record< string, any > | null;\n\teditorAssets: Record< string, any > | null;\n\tsyncConnectionStatuses?: Record< string, ConnectionStatus >;\n\tcollaborationSupported: boolean;\n}\n\ntype EntityRecordKey = string | number;\n\ninterface EntitiesState {\n\tconfig: EntityConfig[];\n\trecords: Record< string, Record< string, EntityState< ET.EntityRecord > > >;\n}\n\ninterface QueriedData {\n\titems: Record< ET.Context, Record< number, ET.EntityRecord > >;\n\titemIsComplete: Record< ET.Context, Record< number, boolean > >;\n\tqueries: Record< ET.Context, Record< string, Array< number > > >;\n}\n\ntype RevisionRecord =\n\t| Record< ET.Context, Record< number, ET.PostRevision > >\n\t| Record< ET.Context, Record< number, ET.GlobalStylesRevision > >;\n\ninterface RevisionsQueriedData {\n\titems: RevisionRecord;\n\titemIsComplete: Record< ET.Context, Record< number, boolean > >;\n\tqueries: Record< ET.Context, Record< string, Array< number > > >;\n}\n\ninterface EntityState< EntityRecord extends ET.EntityRecord > {\n\tedits: Record< string, Partial< EntityRecord > >;\n\tsaving: Record<\n\t\tstring,\n\t\tPartial< { pending: boolean; isAutosave: boolean; error: Error } >\n\t>;\n\tdeleting: Record< string, Partial< { pending: boolean; error: Error } > >;\n\tqueriedData: QueriedData;\n\trevisions?: RevisionsQueriedData;\n}\n\ninterface EntityConfig {\n\tname: string;\n\tkind: string;\n}\n\ninterface UserState {\n\tqueries: Record< string, EntityRecordKey[] >;\n\tbyId: Record< EntityRecordKey, ET.User< 'edit' > >;\n}\n\ntype TemplateQuery = {\n\tslug?: string;\n\tis_custom?: boolean;\n\tignore_empty?: boolean;\n};\n\nexport interface UserPatternCategory {\n\tid: number;\n\tname: string;\n\tlabel: string;\n\tslug: string;\n\tdescription: string;\n}\n\ntype Optional< T > = T | undefined;\n\n/**\n * HTTP Query parameters sent with the API request to fetch the entity records.\n */\nexport type GetRecordsHttpQuery = Record< string, any >;\n\n/**\n * Arguments for EntityRecord selectors.\n */\ntype EntityRecordArgs =\n\t| [ string, string, EntityRecordKey ]\n\t| [ string, string, EntityRecordKey, GetRecordsHttpQuery ];\n\ntype EntityResource = { kind: string; name: string; id?: EntityRecordKey };\n\n/**\n * Shared reference to an empty object for cases where it is important to avoid\n * returning a new object reference on every invocation, as in a connected or\n * other pure component which performs `shouldComponentUpdate` check on props.\n * This should be used as a last resort, since the normalized data should be\n * maintained by the reducer result in state.\n */\nconst EMPTY_OBJECT = {};\n\n/**\n * Returns true if a request is in progress for embed preview data, or false\n * otherwise.\n *\n * @param state Data state.\n * @param url   URL the preview would be for.\n *\n * @return Whether a request is in progress for an embed preview.\n */\nexport const isRequestingEmbedPreview = createRegistrySelector(\n\t( select: any ) =>\n\t\t( state: State, url: string ): boolean => {\n\t\t\treturn select( STORE_NAME ).isResolving( 'getEmbedPreview', [\n\t\t\t\turl,\n\t\t\t] );\n\t\t}\n);\n\n/**\n * Returns all available authors.\n *\n * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.\n *\n * @param      state Data state.\n * @param      query Optional object of query parameters to\n *                   include with request. For valid query parameters see the [Users page](https://developer.wordpress.org/rest-api/reference/users/) in the REST API Handbook and see the arguments for [List Users](https://developer.wordpress.org/rest-api/reference/users/#list-users) and [Retrieve a User](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user).\n * @return Authors list.\n */\nexport function getAuthors(\n\tstate: State,\n\tquery?: GetRecordsHttpQuery\n): ET.User[] {\n\tdeprecated( \"select( 'core' ).getAuthors()\", {\n\t\tsince: '5.9',\n\t\talternative: \"select( 'core' ).getUsers({ who: 'authors' })\",\n\t} );\n\n\tconst path = addQueryArgs(\n\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\tquery\n\t);\n\treturn getUserQueryResults( state, path );\n}\n\n/**\n * Returns the current user.\n *\n * @param state Data state.\n *\n * @return Current user object.\n */\nexport function getCurrentUser( state: State ): ET.User< 'view' > {\n\treturn state.currentUser;\n}\n\n/**\n * Returns all the users returned by a query ID.\n *\n * @param state   Data state.\n * @param queryID Query ID.\n *\n * @return Users list.\n */\nexport const getUserQueryResults = createSelector(\n\t( state: State, queryID: string ): ET.User< 'edit' >[] => {\n\t\tconst queryResults = state.users.queries[ queryID ] ?? [];\n\n\t\treturn queryResults.map( ( id ) => state.users.byId[ id ] );\n\t},\n\t( state: State, queryID: string ) => [\n\t\tstate.users.queries[ queryID ],\n\t\tstate.users.byId,\n\t]\n);\n\n/**\n * Returns the loaded entities for the given kind.\n *\n * @deprecated since WordPress 6.0. Use getEntitiesConfig instead\n * @param      state Data state.\n * @param      kind  Entity kind.\n *\n * @return Array of entities with config matching kind.\n */\nexport function getEntitiesByKind( state: State, kind: string ): Array< any > {\n\tdeprecated( \"wp.data.select( 'core' ).getEntitiesByKind()\", {\n\t\tsince: '6.0',\n\t\talternative: \"wp.data.select( 'core' ).getEntitiesConfig()\",\n\t} );\n\treturn getEntitiesConfig( state, kind );\n}\n\n/**\n * Returns the loaded entities for the given kind.\n *\n * @param state Data state.\n * @param kind  Entity kind.\n *\n * @return Array of entities with config matching kind.\n */\nexport const getEntitiesConfig = createSelector(\n\t( state: State, kind: string ): Array< any > =>\n\t\tstate.entities.config.filter( ( entity ) => entity.kind === kind ),\n\t/* eslint-disable @typescript-eslint/no-unused-vars */\n\t( state: State, kind: string ) => state.entities.config\n\t/* eslint-enable @typescript-eslint/no-unused-vars */\n);\n/**\n * Returns the entity config given its kind and name.\n *\n * @deprecated since WordPress 6.0. Use getEntityConfig instead\n * @param      state Data state.\n * @param      kind  Entity kind.\n * @param      name  Entity name.\n *\n * @return Entity config\n */\nexport function getEntity( state: State, kind: string, name: string ): any {\n\tdeprecated( \"wp.data.select( 'core' ).getEntity()\", {\n\t\tsince: '6.0',\n\t\talternative: \"wp.data.select( 'core' ).getEntityConfig()\",\n\t} );\n\treturn getEntityConfig( state, kind, name );\n}\n\n/**\n * Returns the entity config given its kind and name.\n *\n * @param state Data state.\n * @param kind  Entity kind.\n * @param name  Entity name.\n *\n * @return Entity config\n */\nexport function getEntityConfig(\n\tstate: State,\n\tkind: string,\n\tname: string\n): any {\n\tlogEntityDeprecation( kind, name, 'getEntityConfig' );\n\n\treturn state.entities.config?.find(\n\t\t( config ) => config.kind === kind && config.name === name\n\t);\n}\n\n/**\n * GetEntityRecord is declared as a *callable interface* with\n * two signatures to work around the fact that TypeScript doesn't\n * allow currying generic functions:\n *\n * ```ts\n * \t\ttype CurriedState = F extends ( state: any, ...args: infer P ) => infer R\n * \t\t\t? ( ...args: P ) => R\n * \t\t\t: F;\n * \t\ttype Selector = <K extends string | number>(\n *         state: any,\n *         kind: K,\n *         key: K extends string ? 'string value' : false\n *    ) => K;\n * \t\ttype BadlyInferredSignature = CurriedState< Selector >\n *    // BadlyInferredSignature evaluates to:\n *    // (kind: string number, key: false | \"string value\") => string number\n * ```\n *\n * The signature without the state parameter shipped as CurriedSignature\n * is used in the return value of `select( coreStore )`.\n *\n * See https://github.com/WordPress/gutenberg/pull/41578 for more details.\n */\nexport interface GetEntityRecord {\n\t<\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey?: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord | undefined;\n\n\tCurriedSignature: <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tkind: string,\n\t\tname: string,\n\t\tkey?: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => EntityRecord | undefined;\n\t__unstableNormalizeArgs?: ( args: EntityRecordArgs ) => EntityRecordArgs;\n}\n\n/**\n * Returns the Entity's record object by key. Returns `null` if the value is not\n * yet received, undefined if the value entity is known to not exist, or the\n * entity object if it exists and is received.\n *\n * @param state State tree\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @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.\n * @param query Optional query. If requesting specific\n *              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]\".\n *\n * @return Record.\n */\nexport const getEntityRecord = createSelector(\n\t( <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey?: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord | undefined => {\n\t\tlogEntityDeprecation( kind, name, 'getEntityRecord' );\n\t\tconst queriedState =\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\t\tif ( ! queriedState ) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst context = query?.context ?? 'default';\n\n\t\tif ( ! query || ! query._fields ) {\n\t\t\t// If expecting a complete item, validate that completeness.\n\t\t\tif ( ! queriedState.itemIsComplete[ context ]?.[ key ] ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn queriedState.items[ context ][ key ];\n\t\t}\n\n\t\tconst item = queriedState.items[ context ]?.[ key ];\n\t\tif ( ! item ) {\n\t\t\treturn item;\n\t\t}\n\n\t\tconst filteredItem = {};\n\t\tconst fields = getNormalizedCommaSeparable( query._fields ) ?? [];\n\t\tfor ( let f = 0; f < fields.length; f++ ) {\n\t\t\tconst field = fields[ f ].split( '.' );\n\t\t\tlet value = item;\n\t\t\tfield.forEach( ( fieldName ) => {\n\t\t\t\tvalue = value?.[ fieldName ];\n\t\t\t} );\n\t\t\tsetNestedValue( filteredItem, field, value );\n\t\t}\n\t\treturn filteredItem as EntityRecord;\n\t} ) as GetEntityRecord,\n\t( state: State, kind, name, recordId, query ) => {\n\t\tconst context = query?.context ?? 'default';\n\t\tconst queriedState =\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\t\treturn [\n\t\t\tqueriedState?.items[ context ]?.[ recordId ],\n\t\t\tqueriedState?.itemIsComplete[ context ]?.[ recordId ],\n\t\t];\n\t}\n) as GetEntityRecord;\n\n/**\n * Normalizes `recordKey`s that look like numeric IDs to numbers.\n *\n * @param args EntityRecordArgs the selector arguments.\n * @return EntityRecordArgs the normalized arguments.\n */\ngetEntityRecord.__unstableNormalizeArgs = (\n\targs: EntityRecordArgs\n): EntityRecordArgs => {\n\tconst newArgs = [ ...args ] as EntityRecordArgs;\n\tconst recordKey = newArgs?.[ 2 ];\n\n\t// If recordKey looks to be a numeric ID then coerce to number.\n\tnewArgs[ 2 ] = isNumericID( recordKey ) ? Number( recordKey ) : recordKey;\n\n\treturn newArgs;\n};\n\n/**\n * Returns true if a record has been received for the given set of parameters, or false otherwise.\n *\n * Note: This action does not trigger a request for the entity record from the API\n * if it's not available in the local state.\n *\n * @param state State tree\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param key   Record's key.\n * @param query Optional query.\n *\n * @return Whether an entity record has been received.\n */\nexport function hasEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tkey?: EntityRecordKey,\n\tquery?: GetRecordsHttpQuery\n): boolean {\n\tconst queriedState =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\tif ( ! queriedState ) {\n\t\treturn false;\n\t}\n\tconst context = query?.context ?? 'default';\n\n\t// If expecting a complete item, validate that completeness.\n\tif ( ! query || ! query._fields ) {\n\t\treturn !! queriedState.itemIsComplete[ context ]?.[ key ];\n\t}\n\n\tconst item = queriedState.items[ context ]?.[ key ];\n\tif ( ! item ) {\n\t\treturn false;\n\t}\n\n\t// When `query._fields` is provided, check that each requested field exists,\n\t// including any nested paths, on the item; return false if any part is missing.\n\tconst fields = getNormalizedCommaSeparable( query._fields ) ?? [];\n\tfor ( let i = 0; i < fields.length; i++ ) {\n\t\tconst path = fields[ i ].split( '.' );\n\t\tlet value = item;\n\t\tfor ( let p = 0; p < path.length; p++ ) {\n\t\t\tconst part = path[ p ];\n\t\t\tif ( ! value || ! Object.hasOwn( value, part ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tvalue = value[ part ];\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.\n *\n * @param state State tree\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param key   Record's key\n *\n * @return Record.\n */\nexport function __experimentalGetEntityRecordNoResolver<\n\tEntityRecord extends ET.EntityRecord< any >,\n>( state: State, kind: string, name: string, key: EntityRecordKey ) {\n\treturn getEntityRecord< EntityRecord >( state, kind, name, key );\n}\n\n/**\n * Returns the entity's record object by key,\n * with its attributes mapped to their raw values.\n *\n * @param state State tree.\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param key   Record's key.\n *\n * @return Object with the entity's raw attributes.\n */\nexport const getRawEntityRecord = createSelector(\n\t< EntityRecord extends ET.EntityRecord< any > >(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey\n\t): EntityRecord | undefined => {\n\t\tlogEntityDeprecation( kind, name, 'getRawEntityRecord' );\n\n\t\tconst record = getEntityRecord< EntityRecord >(\n\t\t\tstate,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tkey\n\t\t);\n\t\treturn (\n\t\t\trecord &&\n\t\t\tObject.keys( record ).reduce( ( accumulator, _key ) => {\n\t\t\t\tif (\n\t\t\t\t\tisRawAttribute( getEntityConfig( state, kind, name ), _key )\n\t\t\t\t) {\n\t\t\t\t\t// Because edits are the \"raw\" attribute values,\n\t\t\t\t\t// we return those from record selectors to make rendering,\n\t\t\t\t\t// comparisons, and joins with edits easier.\n\t\t\t\t\taccumulator[ _key ] =\n\t\t\t\t\t\trecord[ _key ]?.raw !== undefined\n\t\t\t\t\t\t\t? record[ _key ]?.raw\n\t\t\t\t\t\t\t: record[ _key ];\n\t\t\t\t} else {\n\t\t\t\t\taccumulator[ _key ] = record[ _key ];\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, {} as any )\n\t\t);\n\t},\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.config,\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData?.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t?.itemIsComplete[ context ]?.[ recordId ],\n\t\t];\n\t}\n);\n\n/**\n * Returns true if records have been received for the given set of parameters,\n * or false otherwise.\n *\n * @param state State tree\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param query Optional terms query. 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 for \"List [Entity kind]s\".\n *\n * @return  Whether entity records have been received.\n */\nexport function hasEntityRecords(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery?: GetRecordsHttpQuery\n): boolean {\n\tlogEntityDeprecation( kind, name, 'hasEntityRecords' );\n\treturn Array.isArray( getEntityRecords( state, kind, name, query ) );\n}\n\n/**\n * GetEntityRecord is declared as a *callable interface* with\n * two signatures to work around the fact that TypeScript doesn't\n * allow currying generic functions.\n *\n * @see GetEntityRecord\n * @see https://github.com/WordPress/gutenberg/pull/41578\n */\nexport interface GetEntityRecords {\n\t<\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord[] | null;\n\n\tCurriedSignature: <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tkind: string,\n\t\tname: string,\n\t\tquery?: GetRecordsHttpQuery\n\t) => EntityRecord[] | null;\n\n\tPromiseCurriedSignature: <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tkind: string,\n\t\tname: string,\n\t\tquery?: GetRecordsHttpQuery\n\t) => Promise< EntityRecord[] | null >;\n}\n\n/**\n * Returns the Entity's records.\n *\n * @param state State tree\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param query Optional terms query. If requesting specific\n *              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 for \"List [Entity kind]s\".\n *\n * @return Records.\n */\nexport const getEntityRecords = ( <\n\tEntityRecord extends\n\t\t| ET.EntityRecord< any >\n\t\t| Partial< ET.EntityRecord< any > >,\n>(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery: GetRecordsHttpQuery\n): EntityRecord[] | null => {\n\tlogEntityDeprecation( kind, name, 'getEntityRecords' );\n\n\t// Queried data state is prepopulated for all known entities. If this is not\n\t// assigned for the given parameters, then it is known to not exist.\n\tconst queriedState =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\tif ( ! queriedState ) {\n\t\treturn null;\n\t}\n\treturn getQueriedItems( queriedState, query );\n} ) as GetEntityRecords;\n\n/**\n * Returns the Entity's total available records for a given query (ignoring pagination).\n *\n * @param state State tree\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param query Optional terms query. If requesting specific\n *              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 for \"List [Entity kind]s\".\n *\n * @return number | null.\n */\nexport const getEntityRecordsTotalItems = (\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery: GetRecordsHttpQuery\n): number | null => {\n\tlogEntityDeprecation( kind, name, 'getEntityRecordsTotalItems' );\n\n\t// Queried data state is prepopulated for all known entities. If this is not\n\t// assigned for the given parameters, then it is known to not exist.\n\tconst queriedState =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\tif ( ! queriedState ) {\n\t\treturn null;\n\t}\n\treturn getQueriedTotalItems( queriedState, query );\n};\n\n/**\n * Returns the number of available pages for the given query.\n *\n * @param state State tree\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param query Optional terms query. If requesting specific\n *              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 for \"List [Entity kind]s\".\n *\n * @return number | null.\n */\nexport const getEntityRecordsTotalPages = (\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery: GetRecordsHttpQuery\n): number | null => {\n\tlogEntityDeprecation( kind, name, 'getEntityRecordsTotalPages' );\n\n\t// Queried data state is prepopulated for all known entities. If this is not\n\t// assigned for the given parameters, then it is known to not exist.\n\tconst queriedState =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\tif ( ! queriedState ) {\n\t\treturn null;\n\t}\n\tif ( query?.per_page === -1 ) {\n\t\treturn 1;\n\t}\n\tconst totalItems = getQueriedTotalItems( queriedState, query );\n\tif ( ! totalItems ) {\n\t\treturn totalItems;\n\t}\n\t// If `per_page` is not set and the query relies on the defaults of the\n\t// REST endpoint, get the info from query's meta.\n\tif ( ! query?.per_page ) {\n\t\treturn getQueriedTotalPages( queriedState, query );\n\t}\n\treturn Math.ceil( totalItems / query.per_page );\n};\n\ntype DirtyEntityRecord = {\n\ttitle: string;\n\tkey: EntityRecordKey;\n\tname: string;\n\tkind: string;\n};\n/**\n * Returns the list of dirty entity records.\n *\n * @param state State tree.\n *\n * @return The list of updated records\n */\nexport const __experimentalGetDirtyEntityRecords = createSelector(\n\t( state: State ): Array< DirtyEntityRecord > => {\n\t\tconst {\n\t\t\tentities: { records },\n\t\t} = state;\n\t\tconst dirtyRecords: DirtyEntityRecord[] = [];\n\t\tObject.keys( records ).forEach( ( kind ) => {\n\t\t\tObject.keys( records[ kind ] ).forEach( ( name ) => {\n\t\t\t\tconst primaryKeys = (\n\t\t\t\t\tObject.keys( records[ kind ][ name ].edits ) as string[]\n\t\t\t\t ).filter(\n\t\t\t\t\t( primaryKey ) =>\n\t\t\t\t\t\t// The entity record must exist (not be deleted),\n\t\t\t\t\t\t// and it must have edits.\n\t\t\t\t\t\tgetEntityRecord( state, kind, name, primaryKey ) &&\n\t\t\t\t\t\thasEditsForEntityRecord( state, kind, name, primaryKey )\n\t\t\t\t);\n\n\t\t\t\tif ( primaryKeys.length ) {\n\t\t\t\t\tconst entityConfig = getEntityConfig( state, kind, name );\n\t\t\t\t\tprimaryKeys.forEach( ( primaryKey ) => {\n\t\t\t\t\t\tconst entityRecord = getEditedEntityRecord(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tprimaryKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdirtyRecords.push( {\n\t\t\t\t\t\t\t// We avoid using primaryKey because it's transformed into a string\n\t\t\t\t\t\t\t// when it's used as an object key.\n\t\t\t\t\t\t\tkey: entityRecord\n\t\t\t\t\t\t\t\t? entityRecord[\n\t\t\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY\n\t\t\t\t\t\t\t\t  ]\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tentityConfig?.getTitle?.( entityRecord ) || '',\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\n\t\treturn dirtyRecords;\n\t},\n\t( state ) => [ state.entities.records ]\n);\n\n/**\n * Returns the list of entities currently being saved.\n *\n * @param state State tree.\n *\n * @return The list of records being saved.\n */\nexport const __experimentalGetEntitiesBeingSaved = createSelector(\n\t( state: State ): Array< DirtyEntityRecord > => {\n\t\tconst {\n\t\t\tentities: { records },\n\t\t} = state;\n\t\tconst recordsBeingSaved: DirtyEntityRecord[] = [];\n\t\tObject.keys( records ).forEach( ( kind ) => {\n\t\t\tObject.keys( records[ kind ] ).forEach( ( name ) => {\n\t\t\t\tconst primaryKeys = (\n\t\t\t\t\tObject.keys( records[ kind ][ name ].saving ) as string[]\n\t\t\t\t ).filter( ( primaryKey ) =>\n\t\t\t\t\tisSavingEntityRecord( state, kind, name, primaryKey )\n\t\t\t\t);\n\n\t\t\t\tif ( primaryKeys.length ) {\n\t\t\t\t\tconst entityConfig = getEntityConfig( state, kind, name );\n\t\t\t\t\tprimaryKeys.forEach( ( primaryKey ) => {\n\t\t\t\t\t\tconst entityRecord = getEditedEntityRecord(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tprimaryKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\trecordsBeingSaved.push( {\n\t\t\t\t\t\t\t// We avoid using primaryKey because it's transformed into a string\n\t\t\t\t\t\t\t// when it's used as an object key.\n\t\t\t\t\t\t\tkey: entityRecord\n\t\t\t\t\t\t\t\t? entityRecord[\n\t\t\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY\n\t\t\t\t\t\t\t\t  ]\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tentityConfig?.getTitle?.( entityRecord ) || '',\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\t\treturn recordsBeingSaved;\n\t},\n\t( state ) => [ state.entities.records ]\n);\n\n/**\n * Returns the specified entity record's edits.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's edits.\n */\nexport function getEntityRecordEdits(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): Optional< any > {\n\tlogEntityDeprecation( kind, name, 'getEntityRecordEdits' );\n\treturn state.entities.records?.[ kind ]?.[ name ]?.edits?.[\n\t\trecordId as string | number\n\t];\n}\n\n/**\n * Returns the specified entity record's non transient edits.\n *\n * Transient edits don't create an undo level, and\n * are not considered for change detection.\n * They are defined in the entity's config.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's non transient edits.\n */\nexport const getEntityRecordNonTransientEdits = createSelector(\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey\n\t): Optional< any > => {\n\t\tlogEntityDeprecation( kind, name, 'getEntityRecordNonTransientEdits' );\n\t\tconst { transientEdits } = getEntityConfig( state, kind, name ) || {};\n\t\tconst edits = getEntityRecordEdits( state, kind, name, recordId ) || {};\n\t\tif ( ! transientEdits ) {\n\t\t\treturn edits;\n\t\t}\n\t\treturn Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\tif ( ! transientEdits[ key ] ) {\n\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t},\n\t( state: State, kind: string, name: string, recordId: EntityRecordKey ) => [\n\t\tstate.entities.config,\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.edits?.[ recordId ],\n\t]\n);\n\n/**\n * Returns true if the specified entity record has edits,\n * and false otherwise.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record has edits or not.\n */\nexport function hasEditsForEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\tlogEntityDeprecation( kind, name, 'hasEditsForEntityRecord' );\n\treturn (\n\t\tisSavingEntityRecord( state, kind, name, recordId ) ||\n\t\tObject.keys(\n\t\t\tgetEntityRecordNonTransientEdits( state, kind, name, recordId )\n\t\t).length > 0\n\t);\n}\n\n/**\n * Returns the specified entity record, merged with its edits.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record, merged with its edits.\n */\nexport const getEditedEntityRecord = createSelector(\n\t< EntityRecord extends ET.EntityRecord< any > >(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey\n\t): ET.Updatable< EntityRecord > | false => {\n\t\tlogEntityDeprecation( kind, name, 'getEditedEntityRecord' );\n\t\tconst raw = getRawEntityRecord( state, kind, name, recordId );\n\t\tconst edited = getEntityRecordEdits( state, kind, name, recordId );\n\t\t// Never return a non-falsy empty object. Unfortunately we can't return\n\t\t// undefined or null because we were previously returning an empty\n\t\t// object, so trying to read properties from the result would throw.\n\t\t// Using false here is a workaround to avoid breaking changes.\n\t\tif ( ! raw && ! edited ) {\n\t\t\treturn false;\n\t\t}\n\t\treturn {\n\t\t\t...raw,\n\t\t\t...edited,\n\t\t};\n\t},\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.config,\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t.itemIsComplete[ context ]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.edits?.[ recordId ],\n\t\t];\n\t}\n);\n\n/**\n * Returns true if the specified entity record is autosaving, and false otherwise.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is autosaving or not.\n */\nexport function isAutosavingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\tlogEntityDeprecation( kind, name, 'isAutosavingEntityRecord' );\n\tconst { pending, isAutosave } =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.saving?.[ recordId ] ?? {};\n\treturn Boolean( pending && isAutosave );\n}\n\n/**\n * Returns true if the specified entity record is saving, and false otherwise.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is saving or not.\n */\nexport function isSavingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\tlogEntityDeprecation( kind, name, 'isSavingEntityRecord' );\n\treturn (\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.saving?.[\n\t\t\trecordId as EntityRecordKey\n\t\t]?.pending ?? false\n\t);\n}\n\n/**\n * Returns true if the specified entity record is deleting, and false otherwise.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is deleting or not.\n */\nexport function isDeletingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\tlogEntityDeprecation( kind, name, 'isDeletingEntityRecord' );\n\treturn (\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.deleting?.[\n\t\t\trecordId as EntityRecordKey\n\t\t]?.pending ?? false\n\t);\n}\n\n/**\n * Returns the specified entity record's last save error.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's save error.\n */\nexport function getLastEntitySaveError(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): any {\n\tlogEntityDeprecation( kind, name, 'getLastEntitySaveError' );\n\treturn state.entities.records?.[ kind ]?.[ name ]?.saving?.[ recordId ]\n\t\t?.error;\n}\n\n/**\n * Returns the specified entity record's last delete error.\n *\n * @param state    State tree.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's save error.\n */\nexport function getLastEntityDeleteError(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): any {\n\tlogEntityDeprecation( kind, name, 'getLastEntityDeleteError' );\n\treturn state.entities.records?.[ kind ]?.[ name ]?.deleting?.[ recordId ]\n\t\t?.error;\n}\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @deprecated since 6.3\n *\n * @param      state State tree.\n *\n * @return The edit.\n */\nexport function getUndoEdit( state: State ): Optional< any > {\n\tdeprecated( \"select( 'core' ).getUndoEdit()\", {\n\t\tsince: '6.3',\n\t} );\n\treturn undefined;\n}\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/**\n * Returns the next edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @deprecated since 6.3\n *\n * @param      state State tree.\n *\n * @return The edit.\n */\nexport function getRedoEdit( state: State ): Optional< any > {\n\tdeprecated( \"select( 'core' ).getRedoEdit()\", {\n\t\tsince: '6.3',\n\t} );\n\treturn undefined;\n}\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\n/**\n * Returns true if there is a previous edit from the current undo offset\n * for the entity records edits history, and false otherwise.\n *\n * @param state State tree.\n *\n * @return Whether there is a previous edit or not.\n */\nexport function hasUndo( state: State ): boolean {\n\treturn getUndoManager( state ).hasUndo();\n}\n\n/**\n * Returns true if there is a next edit from the current undo offset\n * for the entity records edits history, and false otherwise.\n *\n * @param state State tree.\n *\n * @return Whether there is a next edit or not.\n */\nexport function hasRedo( state: State ): boolean {\n\treturn getUndoManager( state ).hasRedo();\n}\n\n/**\n * Return the current theme.\n *\n * @param state Data state.\n *\n * @return The current theme.\n */\nexport function getCurrentTheme( state: State ): any {\n\tif ( ! state.currentTheme ) {\n\t\treturn null;\n\t}\n\treturn getEntityRecord( state, 'root', 'theme', state.currentTheme );\n}\n\n/**\n * Return the ID of the current global styles object.\n *\n * @param state Data state.\n *\n * @return The current global styles ID.\n */\nexport function __experimentalGetCurrentGlobalStylesId( state: State ): string {\n\treturn state.currentGlobalStylesId;\n}\n\n/**\n * Return theme supports data in the index.\n *\n * @param state Data state.\n *\n * @return Index data.\n */\nexport function getThemeSupports( state: State ): any {\n\treturn getCurrentTheme( state )?.theme_supports ?? EMPTY_OBJECT;\n}\n\n/**\n * Returns the embed preview for the given URL.\n *\n * @param state Data state.\n * @param url   Embedded URL.\n *\n * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.\n */\nexport function getEmbedPreview( state: State, url: string ): any {\n\treturn state.embedPreviews[ url ];\n}\n\n/**\n * Determines if the returned preview is an oEmbed link fallback.\n *\n * WordPress can be configured to return a simple link to a URL if it is not embeddable.\n * We need to be able to determine if a URL is embeddable or not, based on what we\n * get back from the oEmbed preview API.\n *\n * @param state Data state.\n * @param url   Embedded URL.\n *\n * @return Is the preview for the URL an oEmbed link fallback.\n */\nexport function isPreviewEmbedFallback( state: State, url: string ): boolean {\n\tconst preview = state.embedPreviews[ url ];\n\tconst oEmbedLinkCheck = '<a href=\"' + url + '\">' + url + '</a>';\n\tif ( ! preview ) {\n\t\treturn false;\n\t}\n\treturn preview.html === oEmbedLinkCheck;\n}\n\n/**\n * Returns whether the current user can perform the given action on the given\n * REST resource.\n *\n * Calling this may trigger an OPTIONS request to the REST API via the\n * `canUser()` resolver.\n *\n * https://developer.wordpress.org/rest-api/reference/\n *\n * @param state    Data state.\n * @param action   Action to check. One of: 'create', 'read', 'update', 'delete'.\n * @param resource Entity resource to check. Accepts entity object `{ kind: 'postType', name: 'attachment', id: 1 }`\n *                 or REST base as a string - `media`.\n * @param id       Optional ID of the rest resource to check.\n *\n * @return Whether or not the user can perform the action,\n *                             or `undefined` if the OPTIONS request is still being made.\n */\nexport function canUser(\n\tstate: State,\n\taction: string,\n\tresource: string | EntityResource,\n\tid?: EntityRecordKey\n): boolean | undefined {\n\tconst isEntity = typeof resource === 'object';\n\tif ( isEntity && ( ! resource.kind || ! resource.name ) ) {\n\t\treturn false;\n\t}\n\tif ( isEntity ) {\n\t\tlogEntityDeprecation( resource.kind, resource.name, 'canUser' );\n\t}\n\n\tconst key = getUserPermissionCacheKey( action, resource, id );\n\n\treturn state.userPermissions[ key ];\n}\n\n/**\n * Returns whether the current user can edit the given entity.\n *\n * Calling this may trigger an OPTIONS request to the REST API via the\n * `canUser()` resolver.\n *\n * https://developer.wordpress.org/rest-api/reference/\n *\n * @param state    Data state.\n * @param kind     Entity kind.\n * @param name     Entity name.\n * @param recordId Record's id.\n * @return Whether or not the user can edit,\n * or `undefined` if the OPTIONS request is still being made.\n */\nexport function canUserEditEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean | undefined {\n\tdeprecated( `wp.data.select( 'core' ).canUserEditEntityRecord()`, {\n\t\tsince: '6.7',\n\t\talternative: `wp.data.select( 'core' ).canUser( 'update', { kind, name, id } )`,\n\t} );\n\n\treturn canUser( state, 'update', { kind, name, id: recordId } );\n}\n\n/**\n * Returns the latest autosaves for the post.\n *\n * May return multiple autosaves since the backend stores one autosave per\n * author for each post.\n *\n * @param state    State tree.\n * @param postType The type of the parent post.\n * @param postId   The id of the parent post.\n *\n * @return An array of autosaves for the post, or undefined if there is none.\n */\nexport function getAutosaves(\n\tstate: State,\n\tpostType: string,\n\tpostId: EntityRecordKey\n): Array< any > | undefined {\n\treturn state.autosaves[ postId ];\n}\n\n/**\n * Returns the autosave for the post and author.\n *\n * @param state    State tree.\n * @param postType The type of the parent post.\n * @param postId   The id of the parent post.\n * @param authorId The id of the author.\n *\n * @return The autosave for the post and author.\n */\nexport function getAutosave< EntityRecord extends ET.EntityRecord< any > >(\n\tstate: State,\n\tpostType: string,\n\tpostId: EntityRecordKey,\n\tauthorId: EntityRecordKey\n): EntityRecord | undefined {\n\tif ( authorId === undefined ) {\n\t\treturn;\n\t}\n\n\tconst autosaves = state.autosaves[ postId ];\n\n\treturn autosaves?.find(\n\t\t( autosave: any ) => autosave.author === authorId\n\t) as EntityRecord | undefined;\n}\n\n/**\n * Returns true if the REST request for autosaves has completed.\n *\n * @param state    State tree.\n * @param postType The type of the parent post.\n * @param postId   The id of the parent post.\n *\n * @return True if the REST request was completed. False otherwise.\n */\nexport const hasFetchedAutosaves = createRegistrySelector(\n\t( select ) =>\n\t\t(\n\t\t\tstate: State,\n\t\t\tpostType: string,\n\t\t\tpostId: EntityRecordKey\n\t\t): boolean => {\n\t\t\treturn select( STORE_NAME ).hasFinishedResolution( 'getAutosaves', [\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t] );\n\t\t}\n);\n\n/**\n * Returns a new reference when edited values have changed. This is useful in\n * inferring where an edit has been made between states by comparison of the\n * return values using strict equality.\n *\n * @example\n *\n * ```\n * const hasEditOccurred = (\n *    getReferenceByDistinctEdits( beforeState ) !==\n *    getReferenceByDistinctEdits( afterState )\n * );\n * ```\n *\n * @param state Editor state.\n *\n * @return A value whose reference will change only when an edit occurs.\n */\nexport function getReferenceByDistinctEdits( state ) {\n\treturn state.editsReference;\n}\n\n/**\n * Retrieve the current theme's base global styles\n *\n * @param state Editor state.\n *\n * @return The Global Styles object.\n */\nexport function __experimentalGetCurrentThemeBaseGlobalStyles(\n\tstate: State\n): any {\n\tconst currentTheme = getCurrentTheme( state );\n\tif ( ! currentTheme ) {\n\t\treturn null;\n\t}\n\treturn state.themeBaseGlobalStyles[ currentTheme.stylesheet ];\n}\n\n/**\n * Return the ID of the current global styles object.\n *\n * @param state Data state.\n *\n * @return The current global styles ID.\n */\nexport function __experimentalGetCurrentThemeGlobalStylesVariations(\n\tstate: State\n): string | null {\n\tconst currentTheme = getCurrentTheme( state );\n\tif ( ! currentTheme ) {\n\t\treturn null;\n\t}\n\treturn state.themeGlobalStyleVariations[ currentTheme.stylesheet ];\n}\n\n/**\n * Retrieve the list of registered block patterns.\n *\n * @param state Data state.\n *\n * @return Block pattern list.\n */\nexport function getBlockPatterns( state: State ): Array< any > {\n\treturn state.blockPatterns;\n}\n\n/**\n * Retrieve the list of registered block pattern categories.\n *\n * @param state Data state.\n *\n * @return Block pattern category list.\n */\nexport function getBlockPatternCategories( state: State ): Array< any > {\n\treturn state.blockPatternCategories;\n}\n\n/**\n * Retrieve the registered user pattern categories.\n *\n * @param state Data state.\n *\n * @return User patterns category array.\n */\n\nexport function getUserPatternCategories(\n\tstate: State\n): Array< UserPatternCategory > {\n\treturn state.userPatternCategories;\n}\n\n/**\n * Returns the revisions of the current global styles theme.\n *\n * @deprecated since WordPress 6.5.0. Callers should use `select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )` instead, where `recordKey` is the id of the global styles parent post.\n *\n * @param      state Data state.\n *\n * @return The current global styles.\n */\nexport function getCurrentThemeGlobalStylesRevisions(\n\tstate: State\n): Array< object > | null {\n\tdeprecated( \"select( 'core' ).getCurrentThemeGlobalStylesRevisions()\", {\n\t\tsince: '6.5.0',\n\t\talternative:\n\t\t\t\"select( 'core' ).getRevisions( 'root', 'globalStyles', ${ recordKey } )\",\n\t} );\n\tconst currentGlobalStylesId =\n\t\t__experimentalGetCurrentGlobalStylesId( state );\n\n\tif ( ! currentGlobalStylesId ) {\n\t\treturn null;\n\t}\n\n\treturn state.themeGlobalStyleRevisions[ currentGlobalStylesId ];\n}\n\n/**\n * Returns the default template use to render a given query.\n *\n * @param state Data state.\n * @param query Query.\n *\n * @return The default template id for the given query.\n */\nexport function getDefaultTemplateId(\n\tstate: State,\n\tquery: TemplateQuery\n): string {\n\treturn state.defaultTemplates[ JSON.stringify( query ) ];\n}\n\n/**\n * Returns an entity's revisions.\n *\n * @param state     State tree\n * @param kind      Entity kind.\n * @param name      Entity name.\n * @param recordKey The key of the entity record whose revisions you want to fetch.\n * @param query     Optional query. If requesting specific\n *                  fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available \"Retrieve a [Entity kind]\".\n *\n * @return Record.\n */\nexport const getRevisions = (\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordKey: EntityRecordKey,\n\tquery?: GetRecordsHttpQuery\n): RevisionRecord[] | null => {\n\tlogEntityDeprecation( kind, name, 'getRevisions' );\n\tconst queriedStateRevisions =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.revisions?.[ recordKey ];\n\tif ( ! queriedStateRevisions ) {\n\t\treturn null;\n\t}\n\n\treturn getQueriedItems( queriedStateRevisions, query );\n};\n\n/**\n * Returns true if a revision has been received for the given set of parameters,\n * or false otherwise.\n *\n * Note: This does not trigger a request for the revision from the API\n * if it's not available in the local state.\n *\n * @param state       State tree\n * @param kind        Entity kind.\n * @param name        Entity name.\n * @param recordKey   The key of the entity record whose revision you want to check.\n * @param revisionKey The revision's key.\n * @param query       Optional query.\n *\n * @return Whether a revision has been received.\n */\nexport function hasRevision(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordKey: EntityRecordKey,\n\trevisionKey: EntityRecordKey,\n\tquery?: GetRecordsHttpQuery\n): boolean {\n\tconst queriedState =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.revisions?.[ recordKey ];\n\tif ( ! queriedState ) {\n\t\treturn false;\n\t}\n\tconst context = query?.context ?? 'default';\n\n\tif ( ! query || ! query._fields ) {\n\t\treturn !! queriedState.itemIsComplete[ context ]?.[ revisionKey ];\n\t}\n\n\tconst item = queriedState.items[ context ]?.[ revisionKey ];\n\tif ( ! item ) {\n\t\treturn false;\n\t}\n\n\tconst fields = getNormalizedCommaSeparable( query._fields ) ?? [];\n\tfor ( let i = 0; i < fields.length; i++ ) {\n\t\tconst path = fields[ i ].split( '.' );\n\t\tlet value = item;\n\t\tfor ( let p = 0; p < path.length; p++ ) {\n\t\t\tconst part = path[ p ];\n\t\t\tif ( ! value || ! Object.hasOwn( value, part ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tvalue = value[ part ];\n\t\t}\n\t}\n\n\treturn true;\n}\n\n/**\n * Returns a single, specific revision of a parent entity.\n *\n * @param state       State tree\n * @param kind        Entity kind.\n * @param name        Entity name.\n * @param recordKey   The key of the entity record whose revisions you want to fetch.\n * @param revisionKey The revision's key.\n * @param query       Optional query. If requesting specific\n *                    fields, fields must always include the ID. For valid query parameters see revisions schema in [the REST API Handbook](https://developer.wordpress.org/rest-api/reference/). Then see the arguments available \"Retrieve a [entity kind]\".\n *\n * @return Record.\n */\nexport const getRevision = createSelector(\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordKey: EntityRecordKey,\n\t\trevisionKey: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t): RevisionRecord | Record< PropertyKey, never > | undefined => {\n\t\tlogEntityDeprecation( kind, name, 'getRevision' );\n\t\tconst queriedState =\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.revisions?.[\n\t\t\t\trecordKey\n\t\t\t];\n\n\t\tif ( ! queriedState ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst context = query?.context ?? 'default';\n\n\t\tif ( ! query || ! query._fields ) {\n\t\t\t// If expecting a complete item, validate that completeness.\n\t\t\tif ( ! queriedState.itemIsComplete[ context ]?.[ revisionKey ] ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn queriedState.items[ context ][ revisionKey ];\n\t\t}\n\n\t\tconst item = queriedState.items[ context ]?.[ revisionKey ];\n\t\tif ( ! item ) {\n\t\t\treturn item;\n\t\t}\n\n\t\tconst filteredItem = {};\n\t\tconst fields = getNormalizedCommaSeparable( query._fields ) ?? [];\n\n\t\tfor ( let f = 0; f < fields.length; f++ ) {\n\t\t\tconst field = fields[ f ].split( '.' );\n\t\t\tlet value = item;\n\t\t\tfield.forEach( ( fieldName ) => {\n\t\t\t\tvalue = value?.[ fieldName ];\n\t\t\t} );\n\t\t\tsetNestedValue( filteredItem, field, value );\n\t\t}\n\n\t\treturn filteredItem;\n\t},\n\t( state: State, kind, name, recordKey, revisionKey, query ) => {\n\t\tconst context = query?.context ?? 'default';\n\t\tconst queriedState =\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.revisions?.[\n\t\t\t\trecordKey\n\t\t\t];\n\t\treturn [\n\t\t\tqueriedState?.items?.[ context ]?.[ revisionKey ],\n\t\t\tqueriedState?.itemIsComplete?.[ context ]?.[ revisionKey ],\n\t\t];\n\t}\n);\n\n/**\n * Returns the current sync connection status across all entities. Prioritizes\n * disconnected states, then connecting, then connected.\n *\n * @param state Data state.\n *\n * @return The current sync connection state, prioritized by importance.\n */\nexport function getSyncConnectionStatus(\n\tstate: State\n): ConnectionStatus | undefined {\n\tif ( ! state.syncConnectionStatuses ) {\n\t\treturn undefined;\n\t}\n\n\tconst PRIORITIZED_STATUSES = [ 'disconnected', 'connecting', 'connected' ];\n\n\tlet coalesced: ConnectionStatus | undefined;\n\n\tfor ( const status of Object.values( state.syncConnectionStatuses ) ) {\n\t\tif (\n\t\t\t! coalesced ||\n\t\t\tPRIORITIZED_STATUSES.indexOf( status.status ) <\n\t\t\t\tPRIORITIZED_STATUSES.indexOf( coalesced.status )\n\t\t) {\n\t\t\tcoalesced = status;\n\t\t}\n\t}\n\n\treturn coalesced;\n}\n", "/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { getDefaultTemplateId, getEntityRecord, type State } from './selectors';\nimport { STORE_NAME } from './name';\nimport { unlock } from './lock-unlock';\nimport { getSyncManager } from './sync';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\ntype EntityRecordKey = string | number;\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * Known Issue: Every-time state.undoManager changes, the getUndoManager\n * private selector is called (if used within useSelect and things like that)\n * which ensures the UI is always properly reactive. But, it's not the case with\n * the custom \"sync\" undo manager.\n *\n * Assumption: When an undo/redo is created, other parts of the core-data state\n * are likely changing simultaneously, which will trigger the selectors again.\n *\n * This issue is acceptable based on the assumption above.\n *\n * @see https://github.com/WordPress/gutenberg/pull/72407/files#r2580214235 for more details.\n *\n * @param state State tree.\n *\n * @return The undo manager.\n */\nexport function getUndoManager( state: State ) {\n\t// undoManager is undefined until the first sync-enabled entity is loaded.\n\treturn getSyncManager()?.undoManager ?? state.undoManager;\n}\n\n/**\n * Retrieve the fallback Navigation.\n *\n * @param state Data state.\n * @return The ID for the fallback Navigation post.\n */\nexport function getNavigationFallbackId(\n\tstate: State\n): EntityRecordKey | undefined {\n\treturn state.navigationFallbackId;\n}\n\nexport const getBlockPatternsForPostType = createRegistrySelector(\n\t( select: any ) =>\n\t\tcreateSelector(\n\t\t\t( state, postType ) =>\n\t\t\t\tselect( STORE_NAME )\n\t\t\t\t\t.getBlockPatterns()\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( { postTypes } ) =>\n\t\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t),\n\t\t\t() => [ select( STORE_NAME ).getBlockPatterns() ]\n\t\t)\n);\n\n/**\n * Returns the entity records permissions for the given entity record ids.\n */\nexport const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t(\n\t\t\tstate: State,\n\t\t\tkind: string,\n\t\t\tname: string,\n\t\t\tids: string | string[]\n\t\t) => {\n\t\t\tconst normalizedIds = Array.isArray( ids ) ? ids : [ ids ];\n\t\t\treturn normalizedIds.map( ( id ) => ( {\n\t\t\t\tdelete: select( STORE_NAME ).canUser( 'delete', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t\tupdate: select( STORE_NAME ).canUser( 'update', {\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t} ),\n\t\t\t} ) );\n\t\t},\n\t\t( state ) => [ state.userPermissions ]\n\t)\n);\n\n/**\n * Returns the entity record permissions for the given entity record id.\n *\n * @param state Data state.\n * @param kind  Entity kind.\n * @param name  Entity name.\n * @param id    Entity record id.\n *\n * @return The entity record permissions.\n */\nexport function getEntityRecordPermissions(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tid: string\n) {\n\tlogEntityDeprecation( kind, name, 'getEntityRecordPermissions' );\n\treturn getEntityRecordsPermissions( state, kind, name, id )[ 0 ];\n}\n\n/**\n * Returns the registered post meta fields for a given post type.\n *\n * @param state    Data state.\n * @param postType Post type.\n *\n * @return Registered post meta fields.\n */\nexport function getRegisteredPostMeta( state: State, postType: string ) {\n\treturn state.registeredPostMeta?.[ postType ] ?? {};\n}\n\nfunction normalizePageId( value: number | string | undefined ): string | null {\n\tif ( ! value || ! [ 'number', 'string' ].includes( typeof value ) ) {\n\t\treturn null;\n\t}\n\n\t// We also need to check if it's not zero (`'0'`).\n\tif ( Number( value ) === 0 ) {\n\t\treturn null;\n\t}\n\n\treturn value.toString();\n}\n\ninterface SiteData {\n\tshow_on_front?: string;\n\tpage_on_front?: string | number;\n\tpage_for_posts?: string | number;\n}\n\nexport const getHomePage = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t() => {\n\t\t\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'__unstableBase'\n\t\t\t) as SiteData | undefined;\n\t\t\t// Still resolving getEntityRecord.\n\t\t\tif ( ! siteData ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst homepageId =\n\t\t\t\tsiteData?.show_on_front === 'page'\n\t\t\t\t\t? normalizePageId( siteData.page_on_front )\n\t\t\t\t\t: null;\n\t\t\tif ( homepageId ) {\n\t\t\t\treturn { postType: 'page', postId: homepageId };\n\t\t\t}\n\t\t\tconst frontPageTemplateId = select(\n\t\t\t\tSTORE_NAME\n\t\t\t).getDefaultTemplateId( {\n\t\t\t\tslug: 'front-page',\n\t\t\t} );\n\t\t\t// Still resolving getDefaultTemplateId.\n\t\t\tif ( ! frontPageTemplateId ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn { postType: 'wp_template', postId: frontPageTemplateId };\n\t\t},\n\t\t( state ) => [\n\t\t\t// Even though getDefaultTemplateId.shouldInvalidate returns true when root/site changes,\n\t\t\t// it doesn't seem to invalidate this cache, I'm not sure why.\n\t\t\tgetEntityRecord( state, 'root', 'site' ),\n\t\t\tgetEntityRecord( state, 'root', '__unstableBase' ),\n\t\t\tgetDefaultTemplateId( state, {\n\t\t\t\tslug: 'front-page',\n\t\t\t} ),\n\t\t]\n\t)\n);\n\nexport const getPostsPageId = createRegistrySelector( ( select ) => () => {\n\tconst siteData = select( STORE_NAME ).getEntityRecord(\n\t\t'root',\n\t\t'__unstableBase'\n\t) as SiteData | undefined;\n\treturn siteData?.show_on_front === 'page'\n\t\t? normalizePageId( siteData.page_for_posts )\n\t\t: null;\n} );\n\nexport const getTemplateId = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst homepage = unlock( select( STORE_NAME ) ).getHomePage();\n\n\t\tif ( ! homepage ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// For the front page, we always use the front page template if existing.\n\t\tif (\n\t\t\tpostType === 'page' &&\n\t\t\tpostType === homepage?.postType &&\n\t\t\tpostId.toString() === homepage?.postId\n\t\t) {\n\t\t\t// The /lookup endpoint cannot currently handle a lookup\n\t\t\t// when a page is set as the front page, so specifically in\n\t\t\t// that case, we want to check if there is a front page\n\t\t\t// template, and instead of falling back to the home\n\t\t\t// template, we want to fall back to the page template.\n\t\t\tconst templates = select( STORE_NAME ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t);\n\t\t\tif ( ! templates ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst id = templates.find( ( { slug } ) => slug === 'front-page' )\n\t\t\t\t?.id;\n\t\t\tif ( id ) {\n\t\t\t\treturn id;\n\t\t\t}\n\t\t\t// If no front page template is found, continue with the\n\t\t\t// logic below (fetching the page template).\n\t\t}\n\n\t\tconst editedEntity = select( STORE_NAME ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tpostId\n\t\t);\n\t\tif ( ! editedEntity ) {\n\t\t\treturn;\n\t\t}\n\t\tconst postsPageId = unlock( select( STORE_NAME ) ).getPostsPageId();\n\t\t// Check if the current page is the posts page.\n\t\tif ( postType === 'page' && postsPageId === postId.toString() ) {\n\t\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\t\tslug: 'home',\n\t\t\t} );\n\t\t}\n\t\t// First see if the post/page has an assigned template and fetch it.\n\t\tconst currentTemplateSlug = editedEntity.template;\n\t\tif ( currentTemplateSlug ) {\n\t\t\tconst currentTemplate = select( STORE_NAME )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', {\n\t\t\t\t\tper_page: -1,\n\t\t\t\t} )\n\t\t\t\t?.find( ( { slug } ) => slug === currentTemplateSlug );\n\t\t\tif ( currentTemplate ) {\n\t\t\t\treturn currentTemplate.id;\n\t\t\t}\n\t\t}\n\t\t// If no template is assigned, use the default template.\n\t\tlet slugToCheck;\n\t\t// In `draft` status we might not have a slug available, so we use the `single`\n\t\t// post type templates slug(ex page, single-post, single-product etc..).\n\t\t// Pages do not need the `single` prefix in the slug to be prioritized\n\t\t// through template hierarchy.\n\t\tif ( editedEntity.slug ) {\n\t\t\tslugToCheck =\n\t\t\t\tpostType === 'page'\n\t\t\t\t\t? `${ postType }-${ editedEntity.slug }`\n\t\t\t\t\t: `single-${ postType }-${ editedEntity.slug }`;\n\t\t} else {\n\t\t\tslugToCheck = postType === 'page' ? 'page' : `single-${ postType }`;\n\t\t}\n\t\treturn select( STORE_NAME ).getDefaultTemplateId( {\n\t\t\tslug: slugToCheck,\n\t\t} );\n\t}\n);\n\n/**\n * Returns the editor settings.\n *\n * @param state Data state.\n * @return Editor settings object or null if not loaded.\n */\nexport function getEditorSettings(\n\tstate: State\n): Record< string, any > | null {\n\treturn state.editorSettings;\n}\n\n/**\n * Returns the editor assets.\n *\n * @param state Data state.\n * @return Editor assets object or null if not loaded.\n */\nexport function getEditorAssets( state: State ): Record< string, any > | null {\n\treturn state.editorAssets;\n}\n\n/**\n * Returns whether collaboration is supported.\n *\n * @param state Data state.\n * @return Whether collaboration is supported.\n */\nexport function isCollaborationSupported( state: State ): boolean {\n\treturn state.collaborationSupported;\n}\n", "/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { deprecatedEntities } from '../entities';\n\nlet loggedAlready = false;\n\n/**\n * Logs a deprecation warning for an entity, if it's deprecated.\n *\n * @param kind                            The kind of the entity.\n * @param name                            The name of the entity.\n * @param functionName                    The name of the function that was called with a deprecated entity.\n * @param options                         The options for the deprecation warning.\n * @param options.alternativeFunctionName The name of the alternative function that should be used instead.\n * @param options.isShorthandSelector     Whether the function is a shorthand selector.\n */\nexport default function logEntityDeprecation(\n\tkind: string,\n\tname: string,\n\tfunctionName: string,\n\t{\n\t\talternativeFunctionName,\n\t\tisShorthandSelector = false,\n\t}: {\n\t\talternativeFunctionName?: string;\n\t\tisShorthandSelector?: boolean;\n\t} = {}\n) {\n\tconst deprecation = deprecatedEntities[ kind ]?.[ name ];\n\tif ( ! deprecation ) {\n\t\treturn;\n\t}\n\n\tif ( ! loggedAlready ) {\n\t\tconst { alternative } = deprecation;\n\n\t\tconst message = isShorthandSelector\n\t\t\t? `'${ functionName }'`\n\t\t\t: `The '${ kind }', '${ name }' entity (used via '${ functionName }')`;\n\n\t\tlet alternativeMessage = `the '${ alternative.kind }', '${ alternative.name }' entity`;\n\t\tif ( alternativeFunctionName ) {\n\t\t\talternativeMessage += ` via the '${ alternativeFunctionName }' function`;\n\t\t}\n\n\t\tdeprecated( message, {\n\t\t\t...deprecation,\n\t\t\talternative: alternativeMessage,\n\t\t} );\n\t}\n\n\t// Only log an entity deprecation once per call stack,\n\t// else there's spurious logging when selections or actions call through to other selectors or actions.\n\t// Note: this won't prevent the deprecation warning being logged if a selector or action makes an async call\n\t// to another selector or action, but this is probably the best we can do.\n\tloggedAlready = true;\n\t// At the end of the call stack, reset the flag.\n\tsetTimeout( () => {\n\t\tloggedAlready = false;\n\t}, 0 );\n}\n", "/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { getNestedValue, setNestedValue } from './utils';\nimport { receiveItems, removeItems, receiveQueriedItems } from './queried-data';\nimport { DEFAULT_ENTITY_KEY } from './entities';\nimport { createBatch } from './batch';\nimport { STORE_NAME } from './name';\nimport {\n\tLOCAL_EDITOR_ORIGIN,\n\tLOCAL_UNDO_IGNORED_ORIGIN,\n\tgetSyncManager,\n} from './sync';\nimport logEntityDeprecation from './utils/log-entity-deprecation';\n\nfunction addTitleToAutoDraft( record ) {\n\treturn record.status === 'auto-draft' ? { ...record, title: '' } : record;\n}\n\n/**\n * Returns an action object used in signalling that authors have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string}       queryID Query ID.\n * @param {Array|Object} users   Users received.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserQuery( queryID, users ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_QUERY',\n\t\tusers: Array.isArray( users ) ? users : [ users ],\n\t\tqueryID,\n\t};\n}\n\n/**\n * Returns an action used in signalling that the current user has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentUser Current user object.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentUser( currentUser ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_USER',\n\t\tcurrentUser,\n\t};\n}\n\n/**\n * Returns an action object used in adding new entities.\n *\n * @param {Array} entities Entities received.\n *\n * @return {Object} Action object.\n */\nexport function addEntities( entities ) {\n\treturn {\n\t\ttype: 'ADD_ENTITIES',\n\t\tentities,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that entity records have been received.\n *\n * @param {string}       kind            Kind of the received entity record.\n * @param {string}       name            Name of the received entity record.\n * @param {Array|Object} records         Records received.\n * @param {?Object}      query           Query Object.\n * @param {?boolean}     invalidateCache Should invalidate query caches.\n * @param {?Object}      edits           Edits to reset.\n * @param {?Object}      meta            Meta information about pagination.\n * @return {Object} Action object.\n */\nexport function receiveEntityRecords(\n\tkind,\n\tname,\n\trecords,\n\tquery = undefined,\n\tinvalidateCache = false,\n\tedits = undefined,\n\tmeta = undefined\n) {\n\t// Auto drafts should not have titles, but some plugins rely on them so we can't filter this\n\t// on the server.\n\tif ( kind === 'postType' ) {\n\t\trecords = Array.isArray( records )\n\t\t\t? records.map( addTitleToAutoDraft )\n\t\t\t: addTitleToAutoDraft( records );\n\t}\n\tlet action;\n\tif ( query ) {\n\t\taction = receiveQueriedItems( records, query, edits, meta );\n\t} else {\n\t\taction = receiveItems( records, edits, meta );\n\t}\n\n\treturn {\n\t\t...action,\n\t\tkind,\n\t\tname,\n\t\tinvalidateCache,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current theme has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object} currentTheme The current theme.\n *\n * @return {Object} Action object.\n */\nexport function receiveCurrentTheme( currentTheme ) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_THEME',\n\t\tcurrentTheme,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current global styles id has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} currentGlobalStylesId The current global styles id.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveCurrentGlobalStylesId(\n\tcurrentGlobalStylesId\n) {\n\treturn {\n\t\ttype: 'RECEIVE_CURRENT_GLOBAL_STYLES_ID',\n\t\tid: currentGlobalStylesId,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme base global styles have been received\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet   The theme's identifier\n * @param {Object} globalStyles The global styles object.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeBaseGlobalStyles(\n\tstylesheet,\n\tglobalStyles\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLES',\n\t\tstylesheet,\n\t\tglobalStyles,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles variations have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} stylesheet The theme's identifier\n * @param {Array}  variations The global styles variations.\n *\n * @return {Object} Action object.\n */\nexport function __experimentalReceiveThemeGlobalStyleVariations(\n\tstylesheet,\n\tvariations\n) {\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_VARIATIONS',\n\t\tstylesheet,\n\t\tvariations,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the index has been received.\n *\n * @deprecated since WP 5.9, this is not useful anymore, use the selector directly.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeSupports() {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveThemeSupports\", {\n\t\tsince: '5.9',\n\t} );\n\n\treturn {\n\t\ttype: 'DO_NOTHING',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the theme global styles CPT post revisions have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @deprecated since WordPress 6.5.0. Callers should use `dispatch( 'core' ).receiveRevision` instead.\n *\n * @ignore\n *\n * @param {number} currentId The post id.\n * @param {Array}  revisions The global styles revisions.\n *\n * @return {Object} Action object.\n */\nexport function receiveThemeGlobalStyleRevisions( currentId, revisions ) {\n\tdeprecated(\n\t\t\"wp.data.dispatch( 'core' ).receiveThemeGlobalStyleRevisions()\",\n\t\t{\n\t\t\tsince: '6.5.0',\n\t\t\talternative: \"wp.data.dispatch( 'core' ).receiveRevisions\",\n\t\t}\n\t);\n\treturn {\n\t\ttype: 'RECEIVE_THEME_GLOBAL_STYLE_REVISIONS',\n\t\tcurrentId,\n\t\trevisions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the preview data for\n * a given URl has been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string} url     URL to preview the embed for.\n * @param {*}      preview Preview data.\n *\n * @return {Object} Action object.\n */\nexport function receiveEmbedPreview( url, preview ) {\n\treturn {\n\t\ttype: 'RECEIVE_EMBED_PREVIEW',\n\t\turl,\n\t\tpreview,\n\t};\n}\n\n/**\n * Action triggered to delete an entity record.\n *\n * @param {string}        kind                         Kind of the deleted entity.\n * @param {string}        name                         Name of the deleted entity.\n * @param {number|string} recordId                     Record ID of the deleted entity.\n * @param {?Object}       query                        Special query parameters for the\n *                                                     DELETE API call.\n * @param {Object}        [options]                    Delete options.\n * @param {Function}      [options.__unstableFetch]    Internal use only. Function to\n *                                                     call instead of `apiFetch()`.\n *                                                     Must return a promise.\n * @param {boolean}       [options.throwOnError=false] If false, this action suppresses all\n *                                                     the exceptions. Defaults to false.\n */\nexport const deleteEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecordId,\n\t\tquery,\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'deleteEntityRecord' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tlet error;\n\t\tlet deletedRecord = false;\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\ttry {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'DELETE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t} );\n\n\t\t\tlet hasError = false;\n\t\t\tlet { baseURL } = entityConfig;\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\t( ( recordId &&\n\t\t\t\t\ttypeof recordId === 'string' &&\n\t\t\t\t\t! /^\\d+$/.test( recordId ) ) ||\n\t\t\t\t\t! window?.__experimentalTemplateActivate )\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tlet path = `${ baseURL }/${ recordId }`;\n\n\t\t\t\tif ( query ) {\n\t\t\t\t\tpath = addQueryArgs( path, query );\n\t\t\t\t}\n\n\t\t\t\tdeletedRecord = await __unstableFetch( {\n\t\t\t\t\tpath,\n\t\t\t\t\tmethod: 'DELETE',\n\t\t\t\t} );\n\n\t\t\t\tawait dispatch( removeItems( kind, name, recordId, true ) );\n\n\t\t\t\tif ( entityConfig.syncConfig ) {\n\t\t\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\t\t\tconst objectId = recordId;\n\n\t\t\t\t\tgetSyncManager()?.unload( objectType, objectId );\n\t\t\t\t}\n\t\t\t} catch ( _error ) {\n\t\t\t\thasError = true;\n\t\t\t\terror = _error;\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'DELETE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn deletedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Returns an action object that triggers an\n * edit to an entity record.\n *\n * @param {string}        kind                 Kind of the edited entity record.\n * @param {string}        name                 Name of the edited entity record.\n * @param {number|string} recordId             Record ID of the edited entity record.\n * @param {Object}        edits                The edits.\n * @param {Object}        options              Options for the edit.\n * @param {boolean}       [options.undoIgnore] Whether to ignore the edit in undo history or not.\n *\n * @return {Object} Action object.\n */\nexport const editEntityRecord =\n\t( kind, name, recordId, edits, options = {} ) =>\n\t( { select, dispatch } ) => {\n\t\tlogEntityDeprecation( kind, name, 'editEntityRecord' );\n\t\tconst entityConfig = select.getEntityConfig( kind, name );\n\t\tif ( ! entityConfig ) {\n\t\t\tthrow new Error(\n\t\t\t\t`The entity being edited (${ kind }, ${ name }) does not have a loaded config.`\n\t\t\t);\n\t\t}\n\t\tconst { mergedEdits = {} } = entityConfig;\n\t\tconst record = select.getRawEntityRecord( kind, name, recordId );\n\t\tconst editedRecord = select.getEditedEntityRecord(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\n\t\t// Some fields are merged with the existing value instead of replaced.\n\t\t// See `mergedEdits` definition on the entity config.\n\t\tconst editsWithMerges = Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\tacc[ key ] = mergedEdits[ key ]\n\t\t\t\t? { ...editedRecord[ key ], ...edits[ key ] }\n\t\t\t\t: edits[ key ];\n\n\t\t\treturn acc;\n\t\t}, {} );\n\n\t\tconst edit = {\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId,\n\t\t\t// Clear edits when they are equal to their persisted counterparts\n\t\t\t// so that the property is not considered dirty.\n\t\t\tedits: Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\t\tconst recordValue = record[ key ];\n\t\t\t\tconst value = editsWithMerges[ key ];\n\t\t\t\tacc[ key ] = fastDeepEqual( recordValue, value )\n\t\t\t\t\t? undefined\n\t\t\t\t\t: value;\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\t\tif ( entityConfig.syncConfig ) {\n\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\tconst objectId = recordId;\n\n\t\t\t// Determine whether this edit should create a new undo level.\n\t\t\t//\n\t\t\t// In Gutenberg, block changes flow through two callbacks:\n\t\t\t// - `onInput`: For transient/in-progress changes (e.g., typing each\n\t\t\t//   character). These use `isCached: true` and get merged into\n\t\t\t//   the current undo item.\n\t\t\t// - `onChange`: For persistent/completed changes (e.g., formatting\n\t\t\t//   transforms, block insertions). These use `isCached: false` and\n\t\t\t//   should create a new undo level.\n\t\t\t//\n\t\t\t// Additionally, `undoIgnore: true` means the change should not\n\t\t\t// affect the undo history at all (e.g., selection-only changes).\n\t\t\tconst isNewUndoLevel = options.undoIgnore\n\t\t\t\t? false\n\t\t\t\t: ! options.isCached;\n\n\t\t\t// Use an untracked origin for undoIgnore changes so the Yjs\n\t\t\t// UndoManager does not capture them as undo levels, while\n\t\t\t// still syncing them to the CRDT document and other peers.\n\t\t\tconst origin = options.undoIgnore\n\t\t\t\t? LOCAL_UNDO_IGNORED_ORIGIN\n\t\t\t\t: LOCAL_EDITOR_ORIGIN;\n\n\t\t\tgetSyncManager()?.update(\n\t\t\t\tobjectType,\n\t\t\t\tobjectId,\n\t\t\t\teditsWithMerges,\n\t\t\t\torigin,\n\t\t\t\t{ isNewUndoLevel }\n\t\t\t);\n\t\t}\n\t\tif ( ! options.undoIgnore ) {\n\t\t\tselect.getUndoManager().addRecord(\n\t\t\t\t[\n\t\t\t\t\t{\n\t\t\t\t\t\tid: { kind, name, recordId },\n\t\t\t\t\t\tchanges: Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\t\t\t\t\tacc[ key ] = {\n\t\t\t\t\t\t\t\tfrom: editedRecord[ key ],\n\t\t\t\t\t\t\t\tto: edits[ key ],\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t}, {} ),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\toptions.isCached\n\t\t\t);\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t...edit,\n\t\t} );\n\t};\n\n/**\n * Action triggered to clear all edits from\n * an entity record.\n *\n * @param {string}        kind     Kind of the entity.\n * @param {string}        name     Name of the entity.\n * @param {number|string} recordId Record ID of the entity record.\n *\n * @return {Object} Action object.\n */\nexport const clearEntityRecordEdits =\n\t( kind, name, recordId ) =>\n\t( { select, dispatch } ) => {\n\t\tconst entityConfig = select.getEntityConfig( kind, name );\n\t\tlogEntityDeprecation( kind, name, 'clearEntityRecordEdits' );\n\t\tif ( ! entityConfig ) {\n\t\t\tthrow new Error(\n\t\t\t\t`The entity being edited (${ kind }, ${ name }) does not have a loaded config.`\n\t\t\t);\n\t\t}\n\n\t\tconst currentEdits = select.getEntityRecordEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tif ( ! currentEdits ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Build an edits object with all current edit keys set to undefined\n\t\t// so the reducer removes them.\n\t\tconst clearedEdits = Object.keys( currentEdits ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tacc[ key ] = undefined;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tdispatch( {\n\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId,\n\t\t\tedits: clearedEdits,\n\t\t} );\n\t};\n\n/**\n * Action triggered to undo the last edit to\n * an entity record, if any.\n */\nexport const undo =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\tconst undoRecord = select.getUndoManager().undo();\n\t\tif ( ! undoRecord ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'UNDO',\n\t\t\trecord: undoRecord,\n\t\t} );\n\t};\n\n/**\n * Action triggered to redo the last undone\n * edit to an entity record, if any.\n */\nexport const redo =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\tconst redoRecord = select.getUndoManager().redo();\n\t\tif ( ! redoRecord ) {\n\t\t\treturn;\n\t\t}\n\t\tdispatch( {\n\t\t\ttype: 'REDO',\n\t\t\trecord: redoRecord,\n\t\t} );\n\t};\n\n/**\n * Forces the creation of a new undo level.\n *\n * @return {Object} Action object.\n */\nexport const __unstableCreateUndoLevel =\n\t() =>\n\t( { select } ) => {\n\t\tselect.getUndoManager().addRecord();\n\t};\n\n/**\n * Action triggered to save an entity record.\n *\n * @param {string}   kind                         Kind of the received entity.\n * @param {string}   name                         Name of the received entity.\n * @param {Object}   record                       Record to be saved.\n * @param {Object}   options                      Saving options.\n * @param {boolean}  [options.isAutosave=false]   Whether this is an autosave.\n * @param {Function} [options.__unstableFetch]    Internal use only. Function to\n *                                                call instead of `apiFetch()`.\n *                                                Must return a promise.\n * @param {boolean}  [options.throwOnError=false] If false, this action suppresses all\n *                                                the exceptions. Defaults to false.\n */\nexport const saveEntityRecord =\n\t(\n\t\tkind,\n\t\tname,\n\t\trecord,\n\t\t{\n\t\t\tisAutosave = false,\n\t\t\t__unstableFetch = apiFetch,\n\t\t\tthrowOnError = false,\n\t\t} = {}\n\t) =>\n\tasync ( { select, resolveSelect, dispatch } ) => {\n\t\tlogEntityDeprecation( kind, name, 'saveEntityRecord' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\t\tconst entityIdKey = entityConfig.key ?? DEFAULT_ENTITY_KEY;\n\t\tconst recordId = record[ entityIdKey ];\n\t\tconst isNewRecord = !! entityIdKey && ! recordId;\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId || uuid() ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\ttry {\n\t\t\t// Evaluate optimized edits.\n\t\t\t// (Function edits that should be evaluated on save to avoid expensive computations on every edit.)\n\t\t\tfor ( const [ key, value ] of Object.entries( record ) ) {\n\t\t\t\tif ( typeof value === 'function' ) {\n\t\t\t\t\tconst evaluatedValue = value(\n\t\t\t\t\t\tselect.getEditedEntityRecord( kind, name, recordId )\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.editEntityRecord(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\trecordId,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[ key ]: evaluatedValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ undoIgnore: true }\n\t\t\t\t\t);\n\t\t\t\t\trecord[ key ] = evaluatedValue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\tisAutosave,\n\t\t\t} );\n\t\t\tlet updatedRecord;\n\t\t\tlet error;\n\t\t\tlet hasError = false;\n\t\t\tlet { baseURL } = entityConfig;\n\t\t\t// For \"string\" IDs, use the old templates endpoint.\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\t( ( recordId &&\n\t\t\t\t\ttypeof recordId === 'string' &&\n\t\t\t\t\t! /^\\d+$/.test( recordId ) ) ||\n\t\t\t\t\t! window?.__experimentalTemplateActivate )\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst path = `${ baseURL }${ recordId ? '/' + recordId : '' }`;\n\t\t\t\t// Skip the raw values check when creating a new record; they don't exist yet.\n\t\t\t\tconst persistedRecord = ! isNewRecord\n\t\t\t\t\t? select.getRawEntityRecord( kind, name, recordId )\n\t\t\t\t\t: {};\n\n\t\t\t\t// Most of this autosave logic is very specific to posts.\n\t\t\t\t// This is fine for now as it is the only supported autosave,\n\t\t\t\t// but ideally this should all be handled in the back end,\n\t\t\t\t// so the client just sends and receives objects.\n\t\t\t\tif ( isAutosave ) {\n\t\t\t\t\t// Build the autosave payload from the persisted\n\t\t\t\t\t// record and the incoming edits. The previous autosave\n\t\t\t\t\t// is intentionally excluded to avoid stale values\n\t\t\t\t\t// overriding reverted fields.\n\t\t\t\t\tconst merged = { ...persistedRecord, ...record };\n\t\t\t\t\tconst data = [\n\t\t\t\t\t\t'title',\n\t\t\t\t\t\t'excerpt',\n\t\t\t\t\t\t'content',\n\t\t\t\t\t\t'meta',\n\t\t\t\t\t].reduce(\n\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\tif ( key in merged ) {\n\t\t\t\t\t\t\t\tacc[ key ] = merged[ key ];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t// Do not update the `status` if we have edited it when auto saving.\n\t\t\t\t\t\t\t// It's very important to let the user explicitly save this change,\n\t\t\t\t\t\t\t// because it can lead to unexpected results. An example would be to\n\t\t\t\t\t\t\t// have a draft post and change the status to publish.\n\t\t\t\t\t\t\tstatus:\n\t\t\t\t\t\t\t\tmerged.status === 'auto-draft'\n\t\t\t\t\t\t\t\t\t? 'draft'\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath: `${ path }/autosaves`,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tdata,\n\t\t\t\t\t} );\n\n\t\t\t\t\t// An autosave may be processed by the server as a regular save\n\t\t\t\t\t// when its update is requested by the author and the post had\n\t\t\t\t\t// draft or auto-draft status.\n\t\t\t\t\tif ( persistedRecord.id === updatedRecord.id ) {\n\t\t\t\t\t\tlet newRecord = {\n\t\t\t\t\t\t\t...persistedRecord,\n\t\t\t\t\t\t\t...data,\n\t\t\t\t\t\t\t...updatedRecord,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tnewRecord = Object.keys( newRecord ).reduce(\n\t\t\t\t\t\t\t( acc, key ) => {\n\t\t\t\t\t\t\t\t// These properties are persisted in autosaves.\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\t\t\t'title',\n\t\t\t\t\t\t\t\t\t\t'excerpt',\n\t\t\t\t\t\t\t\t\t\t'content',\n\t\t\t\t\t\t\t\t\t\t'meta',\n\t\t\t\t\t\t\t\t\t].includes( key )\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tacc[ key ] = newRecord[ key ];\n\t\t\t\t\t\t\t\t} else if ( key === 'status' ) {\n\t\t\t\t\t\t\t\t\t// Status is only persisted in autosaves when going from\n\t\t\t\t\t\t\t\t\t// \"auto-draft\" to \"draft\".\n\t\t\t\t\t\t\t\t\tacc[ key ] =\n\t\t\t\t\t\t\t\t\t\tpersistedRecord.status ===\n\t\t\t\t\t\t\t\t\t\t\t'auto-draft' &&\n\t\t\t\t\t\t\t\t\t\tnewRecord.status === 'draft'\n\t\t\t\t\t\t\t\t\t\t\t? newRecord.status\n\t\t\t\t\t\t\t\t\t\t\t: persistedRecord.status;\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t// These properties are not persisted in autosaves.\n\t\t\t\t\t\t\t\t\tacc[ key ] = persistedRecord[ key ];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tnewRecord,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\ttrue\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdispatch.receiveAutosaves(\n\t\t\t\t\t\t\tpersistedRecord.id,\n\t\t\t\t\t\t\tupdatedRecord\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tlet edits = record;\n\t\t\t\t\tif ( entityConfig.__unstablePrePersist ) {\n\t\t\t\t\t\tedits = {\n\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t...( await entityConfig.__unstablePrePersist(\n\t\t\t\t\t\t\t\tpersistedRecord,\n\t\t\t\t\t\t\t\tedits\n\t\t\t\t\t\t\t) ),\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\tupdatedRecord = await __unstableFetch( {\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tmethod: recordId ? 'PUT' : 'POST',\n\t\t\t\t\t\tdata: edits,\n\t\t\t\t\t} );\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tedits\n\t\t\t\t\t);\n\t\t\t\t\tif ( entityConfig.syncConfig ) {\n\t\t\t\t\t\t// Use an untracked origin so that the save\n\t\t\t\t\t\t// response does not create undo levels.\n\t\t\t\t\t\tgetSyncManager()?.update(\n\t\t\t\t\t\t\t`${ kind }/${ name }`,\n\t\t\t\t\t\t\trecordId,\n\t\t\t\t\t\t\tupdatedRecord,\n\t\t\t\t\t\t\tLOCAL_UNDO_IGNORED_ORIGIN,\n\t\t\t\t\t\t\t{ isSave: true }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch ( _error ) {\n\t\t\t\thasError = true;\n\t\t\t\terror = _error;\n\t\t\t}\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t\tisAutosave,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn updatedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Runs multiple core-data actions at the same time using one API request.\n *\n * Example:\n *\n * ```\n * const [ savedRecord, updatedRecord, deletedRecord ] =\n *   await dispatch( 'core' ).__experimentalBatch( [\n *     ( { saveEntityRecord } ) => saveEntityRecord( 'root', 'widget', widget ),\n *     ( { saveEditedEntityRecord } ) => saveEntityRecord( 'root', 'widget', 123 ),\n *     ( { deleteEntityRecord } ) => deleteEntityRecord( 'root', 'widget', 123, null ),\n *   ] );\n * ```\n *\n * @param {Array} requests Array of functions which are invoked simultaneously.\n *                         Each function is passed an object containing\n *                         `saveEntityRecord`, `saveEditedEntityRecord`, and\n *                         `deleteEntityRecord`.\n *\n * @return {(thunkArgs: Object) => Promise} A promise that resolves to an array containing the return\n *                                          values of each function given in `requests`.\n */\nexport const __experimentalBatch =\n\t( requests ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst batch = createBatch();\n\t\tconst api = {\n\t\t\tsaveEntityRecord( kind, name, record, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.saveEntityRecord( kind, name, record, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t\tsaveEditedEntityRecord( kind, name, recordId, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.saveEditedEntityRecord( kind, name, recordId, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t\tdeleteEntityRecord( kind, name, recordId, query, options ) {\n\t\t\t\treturn batch.add( ( add ) =>\n\t\t\t\t\tdispatch.deleteEntityRecord( kind, name, recordId, query, {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\t__unstableFetch: add,\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t};\n\t\tconst resultPromises = requests.map( ( request ) => request( api ) );\n\t\tconst [ , ...results ] = await Promise.all( [\n\t\t\tbatch.run(),\n\t\t\t...resultPromises,\n\t\t] );\n\t\treturn results;\n\t};\n\n/**\n * Action triggered to save an entity record's edits.\n *\n * @param {string}  kind     Kind of the entity.\n * @param {string}  name     Name of the entity.\n * @param {Object}  recordId ID of the record.\n * @param {Object=} options  Saving options.\n */\nexport const saveEditedEntityRecord =\n\t( kind, name, recordId, options ) =>\n\tasync ( { select, dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'saveEditedEntityRecord' );\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\t\tconst entityIdKey = entityConfig.key || DEFAULT_ENTITY_KEY;\n\n\t\tconst edits = select.getEntityRecordNonTransientEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tconst record = { [ entityIdKey ]: recordId, ...edits };\n\t\treturn await dispatch.saveEntityRecord( kind, name, record, options );\n\t};\n\n/**\n * Action triggered to save only specified properties for the entity.\n *\n * @param {string}        kind        Kind of the entity.\n * @param {string}        name        Name of the entity.\n * @param {number|string} recordId    ID of the record.\n * @param {Array}         itemsToSave List of entity properties or property paths to save.\n * @param {Object}        options     Saving options.\n */\nexport const __experimentalSaveSpecifiedEntityEdits =\n\t( kind, name, recordId, itemsToSave, options ) =>\n\tasync ( { select, dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation(\n\t\t\tkind,\n\t\t\tname,\n\t\t\t'__experimentalSaveSpecifiedEntityEdits'\n\t\t);\n\t\tif ( ! select.hasEditsForEntityRecord( kind, name, recordId ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst edits = select.getEntityRecordNonTransientEdits(\n\t\t\tkind,\n\t\t\tname,\n\t\t\trecordId\n\t\t);\n\t\tconst editsToSave = {};\n\n\t\tfor ( const item of itemsToSave ) {\n\t\t\tsetNestedValue( editsToSave, item, getNestedValue( edits, item ) );\n\t\t}\n\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\n\t\tconst entityIdKey = entityConfig?.key || DEFAULT_ENTITY_KEY;\n\n\t\t// If a record key is provided then update the existing record.\n\t\t// This necessitates providing `recordKey` to saveEntityRecord as part of the\n\t\t// `record` argument (here called `editsToSave`) to stop that action creating\n\t\t// a new record and instead cause it to update the existing record.\n\t\tif ( recordId ) {\n\t\t\teditsToSave[ entityIdKey ] = recordId;\n\t\t}\n\t\treturn await dispatch.saveEntityRecord(\n\t\t\tkind,\n\t\t\tname,\n\t\t\teditsToSave,\n\t\t\toptions\n\t\t);\n\t};\n\n/**\n * Returns an action object used in signalling that Upload permissions have been received.\n *\n * @deprecated since WP 5.9, use receiveUserPermission instead.\n *\n * @param {boolean} hasUploadPermissions Does the user have permission to upload files?\n *\n * @return {Object} Action object.\n */\nexport function receiveUploadPermissions( hasUploadPermissions ) {\n\tdeprecated( \"wp.data.dispatch( 'core' ).receiveUploadPermissions\", {\n\t\tsince: '5.9',\n\t\talternative: 'receiveUserPermission',\n\t} );\n\n\treturn receiveUserPermission( 'create/media', hasUploadPermissions );\n}\n\n/**\n * Returns an action object used in signalling that the current user has\n * permission to perform an action on a REST resource.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {string}  key       A key that represents the action and REST resource.\n * @param {boolean} isAllowed Whether or not the user can perform the action.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserPermission( key, isAllowed ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_PERMISSION',\n\t\tkey,\n\t\tisAllowed,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the current user has\n * permission to perform an action on a REST resource. Ignored from\n * documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {Object<string, boolean>} permissions An object where keys represent\n *                                              actions and REST resources, and\n *                                              values indicate whether the user\n *                                              is allowed to perform the\n *                                              action.\n *\n * @return {Object} Action object.\n */\nexport function receiveUserPermissions( permissions ) {\n\treturn {\n\t\ttype: 'RECEIVE_USER_PERMISSIONS',\n\t\tpermissions,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the autosaves for a\n * post have been received.\n * Ignored from documentation as it's internal to the data store.\n *\n * @ignore\n *\n * @param {number}       postId    The id of the post that is parent to the autosave.\n * @param {Array|Object} autosaves An array of autosaves or singular autosave object.\n *\n * @return {Object} Action object.\n */\nexport function receiveAutosaves( postId, autosaves ) {\n\treturn {\n\t\ttype: 'RECEIVE_AUTOSAVES',\n\t\tpostId,\n\t\tautosaves: Array.isArray( autosaves ) ? autosaves : [ autosaves ],\n\t};\n}\n\n/**\n * Returns an action object signalling that the fallback Navigation\n * Menu id has been received.\n *\n * @param {integer} fallbackId the id of the fallback Navigation Menu\n * @return {Object} Action object.\n */\nexport function receiveNavigationFallbackId( fallbackId ) {\n\treturn {\n\t\ttype: 'RECEIVE_NAVIGATION_FALLBACK_ID',\n\t\tfallbackId,\n\t};\n}\n\n/**\n * Returns an action object used to set the template for a given query.\n *\n * @param {Object} query      The lookup query.\n * @param {string} templateId The resolved template id.\n *\n * @return {Object} Action object.\n */\nexport function receiveDefaultTemplateId( query, templateId ) {\n\treturn {\n\t\ttype: 'RECEIVE_DEFAULT_TEMPLATE',\n\t\tquery,\n\t\ttemplateId,\n\t};\n}\n\n/**\n * Action triggered to receive revision items.\n *\n * @param {string}        kind            Kind of the received entity record revisions.\n * @param {string}        name            Name of the received entity record revisions.\n * @param {number|string} recordKey       The key of the entity record whose revisions you want to fetch.\n * @param {Array|Object}  records         Revisions received.\n * @param {?Object}       query           Query Object.\n * @param {?boolean}      invalidateCache Should invalidate query caches.\n * @param {?Object}       meta            Meta information about pagination.\n */\nexport const receiveRevisions =\n\t( kind, name, recordKey, records, query, invalidateCache = false, meta ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlogEntityDeprecation( kind, name, 'receiveRevisions' );\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\t\tconst key = entityConfig?.revisionKey ?? DEFAULT_ENTITY_KEY;\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_ITEM_REVISIONS',\n\t\t\tkey,\n\t\t\titems: records,\n\t\t\trecordKey,\n\t\t\tmeta,\n\t\t\tquery,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tinvalidateCache,\n\t\t} );\n\t};\n\n/**\n * Returns an action object used to set the sync connection status for an entity or collection.\n *\n * @param {string}             kind   Kind of the entity.\n * @param {string}             name   Name of the entity.\n * @param {number|string|null} key    The entity key, or null for collections.\n * @param {Object|null}        status The connection state object or null on unload.\n *\n * @return {Object} Action object.\n */\nexport function setSyncConnectionStatus( kind, name, key, status ) {\n\tif ( ! status ) {\n\t\treturn {\n\t\t\ttype: 'CLEAR_SYNC_CONNECTION_STATUS',\n\t\t\tkind,\n\t\t\tname,\n\t\t\tkey,\n\t\t};\n\t}\n\n\treturn {\n\t\ttype: 'SET_SYNC_CONNECTION_STATUS',\n\t\tkind,\n\t\tname,\n\t\tkey,\n\t\tstatus,\n\t};\n}\n", "/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Maximum number of requests to place in a single batch request. Obtained by\n * sending a preflight OPTIONS request to /batch/v1/.\n *\n * @type {number?}\n */\nlet maxItems = null;\n\nfunction chunk( arr, chunkSize ) {\n\tconst tmp = [ ...arr ];\n\tconst cache = [];\n\twhile ( tmp.length ) {\n\t\tcache.push( tmp.splice( 0, chunkSize ) );\n\t}\n\n\treturn cache;\n}\n\n/**\n * Default batch processor. Sends its input requests to /batch/v1.\n *\n * @param {Array} requests List of API requests to perform at once.\n *\n * @return {Promise} Promise that resolves to a list of objects containing\n *                   either `output` (if that request was successful) or `error`\n *                   (if not ).\n */\nexport default async function defaultProcessor( requests ) {\n\tif ( maxItems === null ) {\n\t\tconst preflightResponse = await apiFetch( {\n\t\t\tpath: '/batch/v1',\n\t\t\tmethod: 'OPTIONS',\n\t\t} );\n\t\tmaxItems = preflightResponse.endpoints[ 0 ].args.requests.maxItems;\n\t}\n\n\tconst results = [];\n\n\t// @ts-ignore We would have crashed or never gotten to this point if we hadn't received the maxItems count.\n\tfor ( const batchRequests of chunk( requests, maxItems ) ) {\n\t\tconst batchResponse = await apiFetch( {\n\t\t\tpath: '/batch/v1',\n\t\t\tmethod: 'POST',\n\t\t\tdata: {\n\t\t\t\tvalidation: 'require-all-validate',\n\t\t\t\trequests: batchRequests.map( ( request ) => ( {\n\t\t\t\t\tpath: request.path,\n\t\t\t\t\tbody: request.data, // Rename 'data' to 'body'.\n\t\t\t\t\tmethod: request.method,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t} ) ),\n\t\t\t},\n\t\t} );\n\n\t\tlet batchResults;\n\n\t\tif ( batchResponse.failed ) {\n\t\t\tbatchResults = batchResponse.responses.map( ( response ) => ( {\n\t\t\t\terror: response?.body,\n\t\t\t} ) );\n\t\t} else {\n\t\t\tbatchResults = batchResponse.responses.map( ( response ) => {\n\t\t\t\tconst result = {};\n\t\t\t\tif ( response.status >= 200 && response.status < 300 ) {\n\t\t\t\t\tresult.output = response.body;\n\t\t\t\t} else {\n\t\t\t\t\tresult.error = response.body;\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t} );\n\t\t}\n\n\t\tresults.push( ...batchResults );\n\t}\n\n\treturn results;\n}\n", "/**\n * Internal dependencies\n */\nimport defaultProcessor from './default-processor';\n\n/**\n * Creates a batch, which can be used to combine multiple API requests into one\n * API request using the WordPress batch processing API (/v1/batch).\n *\n * ```\n * const batch = createBatch();\n * const dunePromise = batch.add( {\n *   path: '/v1/books',\n *   method: 'POST',\n *   data: { title: 'Dune' }\n * } );\n * const lotrPromise = batch.add( {\n *   path: '/v1/books',\n *   method: 'POST',\n *   data: { title: 'Lord of the Rings' }\n * } );\n * const isSuccess = await batch.run(); // Sends one POST to /v1/batch.\n * if ( isSuccess ) {\n *   console.log(\n *     'Saved two books:',\n *     await dunePromise,\n *     await lotrPromise\n *   );\n * }\n * ```\n *\n * @param {Function} [processor] Processor function. Can be used to replace the\n *                               default functionality which is to send an API\n *                               request to /v1/batch. Is given an array of\n *                               inputs and must return a promise that\n *                               resolves to an array of objects containing\n *                               either `output` or `error`.\n */\nexport default function createBatch( processor = defaultProcessor ) {\n\tlet lastId = 0;\n\t/** @type {Array<{ input: any; resolve: ( value: any ) => void; reject: ( error: any ) => void }>} */\n\tlet queue = [];\n\tconst pending = new ObservableSet();\n\n\treturn {\n\t\t/**\n\t\t * Adds an input to the batch and returns a promise that is resolved or\n\t\t * rejected when the input is processed by `batch.run()`.\n\t\t *\n\t\t * You may also pass a thunk which allows inputs to be added\n\t\t * asynchronously.\n\t\t *\n\t\t * ```\n\t\t * // Both are allowed:\n\t\t * batch.add( { path: '/v1/books', ... } );\n\t\t * batch.add( ( add ) => add( { path: '/v1/books', ... } ) );\n\t\t * ```\n\t\t *\n\t\t * If a thunk is passed, `batch.run()` will pause until either:\n\t\t *\n\t\t * - The thunk calls its `add` argument, or;\n\t\t * - The thunk returns a promise and that promise resolves, or;\n\t\t * - The thunk returns a non-promise.\n\t\t *\n\t\t * @param {any|Function} inputOrThunk Input to add or thunk to execute.\n\t\t *\n\t\t * @return {Promise|any} If given an input, returns a promise that\n\t\t *                       is resolved or rejected when the batch is\n\t\t *                       processed. If given a thunk, returns the return\n\t\t *                       value of that thunk.\n\t\t */\n\t\tadd( inputOrThunk ) {\n\t\t\tconst id = ++lastId;\n\t\t\tpending.add( id );\n\n\t\t\tconst add = ( input ) =>\n\t\t\t\tnew Promise( ( resolve, reject ) => {\n\t\t\t\t\tqueue.push( {\n\t\t\t\t\t\tinput,\n\t\t\t\t\t\tresolve,\n\t\t\t\t\t\treject,\n\t\t\t\t\t} );\n\t\t\t\t\tpending.delete( id );\n\t\t\t\t} );\n\n\t\t\tif ( typeof inputOrThunk === 'function' ) {\n\t\t\t\treturn Promise.resolve( inputOrThunk( add ) ).finally( () => {\n\t\t\t\t\tpending.delete( id );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\treturn add( inputOrThunk );\n\t\t},\n\n\t\t/**\n\t\t * Runs the batch. This calls `batchProcessor` and resolves or rejects\n\t\t * all promises returned by `add()`.\n\t\t *\n\t\t * @return {Promise<boolean>} A promise that resolves to a boolean that is true\n\t\t *                   if the processor returned no errors.\n\t\t */\n\t\tasync run() {\n\t\t\tif ( pending.size ) {\n\t\t\t\tawait new Promise( ( resolve ) => {\n\t\t\t\t\tconst unsubscribe = pending.subscribe( () => {\n\t\t\t\t\t\tif ( ! pending.size ) {\n\t\t\t\t\t\t\tunsubscribe();\n\t\t\t\t\t\t\tresolve( undefined );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tlet results;\n\n\t\t\ttry {\n\t\t\t\tresults = await processor(\n\t\t\t\t\tqueue.map( ( { input } ) => input )\n\t\t\t\t);\n\n\t\t\t\tif ( results.length !== queue.length ) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'run: Array returned by processor must be same size as input array.'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch ( error ) {\n\t\t\t\tfor ( const { reject } of queue ) {\n\t\t\t\t\treject( error );\n\t\t\t\t}\n\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tlet isSuccess = true;\n\n\t\t\tresults.forEach( ( result, key ) => {\n\t\t\t\tconst queueItem = queue[ key ];\n\n\t\t\t\tif ( result?.error ) {\n\t\t\t\t\tqueueItem?.reject( result.error );\n\t\t\t\t\tisSuccess = false;\n\t\t\t\t} else {\n\t\t\t\t\tqueueItem?.resolve( result?.output ?? result );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tqueue = [];\n\n\t\t\treturn isSuccess;\n\t\t},\n\t};\n}\n\nclass ObservableSet {\n\tconstructor( ...args ) {\n\t\tthis.set = new Set( ...args );\n\t\tthis.subscribers = new Set();\n\t}\n\n\tget size() {\n\t\treturn this.set.size;\n\t}\n\n\tadd( value ) {\n\t\tthis.set.add( value );\n\t\tthis.subscribers.forEach( ( subscriber ) => subscriber() );\n\t\treturn this;\n\t}\n\n\tdelete( value ) {\n\t\tconst isSuccess = this.set.delete( value );\n\t\tthis.subscribers.forEach( ( subscriber ) => subscriber() );\n\t\treturn isSuccess;\n\t}\n\n\tsubscribe( subscriber ) {\n\t\tthis.subscribers.add( subscriber );\n\t\treturn () => {\n\t\t\tthis.subscribers.delete( subscriber );\n\t\t};\n\t}\n}\n", "/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\n\n/**\n * Returns an action object used in signalling that the registered post meta\n * fields for a post type have been received.\n *\n * @param {string} postType           Post type slug.\n * @param {Object} registeredPostMeta Registered post meta.\n *\n * @return {Object} Action object.\n */\nexport function receiveRegisteredPostMeta( postType, registeredPostMeta ) {\n\treturn {\n\t\ttype: 'RECEIVE_REGISTERED_POST_META',\n\t\tpostType,\n\t\tregisteredPostMeta,\n\t};\n}\n\n/**\n * @typedef {Object} Modifier\n * @property {string} [type] - The type of modifier.\n * @property {Object} [args] - The arguments of the modifier.\n */\n\n/**\n * @typedef {Object} Edits\n * @property {string}     [src]       - The URL of the media item.\n * @property {Modifier[]} [modifiers] - The modifiers to apply to the media item.\n */\n\n/**\n * Duplicates a media (attachment) entity record and, optionally, modifies it.\n *\n * @param {string}   recordId                Entity record ID.\n * @param {Edits}    edits                   Edits to apply to the record.\n * @param {Object}   options                 Options object.\n * @param {Function} options.__unstableFetch Custom fetch function.\n * @param {boolean}  options.throwOnError    Whether to throw an error if the request fails.\n *\n * @return {Promise} Promise resolving to the updated record.\n */\nexport const editMediaEntity =\n\t(\n\t\trecordId,\n\t\tedits = {},\n\t\t{ __unstableFetch = apiFetch, throwOnError = false } = {}\n\t) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tif ( ! recordId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst kind = 'postType';\n\t\tconst name = 'attachment';\n\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.kind === kind && config.name === name\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordId ],\n\t\t\t{ exclusive: true }\n\t\t);\n\n\t\tlet updatedRecord;\n\t\tlet error;\n\t\tlet hasError = false;\n\n\t\ttry {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_START',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t} );\n\n\t\t\ttry {\n\t\t\t\tconst path = `${ entityConfig.baseURL }/${ recordId }/edit`;\n\t\t\t\tconst newRecord = await __unstableFetch( {\n\t\t\t\t\tpath,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\t...edits,\n\t\t\t\t\t},\n\t\t\t\t} );\n\n\t\t\t\tif ( newRecord ) {\n\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tnewRecord,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined\n\t\t\t\t\t);\n\t\t\t\t\tupdatedRecord = newRecord;\n\t\t\t\t}\n\t\t\t} catch ( e ) {\n\t\t\t\terror = e;\n\t\t\t\thasError = true;\n\t\t\t}\n\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SAVE_ENTITY_RECORD_FINISH',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId,\n\t\t\t\terror,\n\t\t\t} );\n\n\t\t\tif ( hasError && throwOnError ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\treturn updatedRecord;\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Returns an action object used to receive editor settings.\n *\n * @param {Object} settings Editor settings object.\n *\n * @return {Object} Action object.\n */\nexport function receiveEditorSettings( settings ) {\n\treturn {\n\t\ttype: 'RECEIVE_EDITOR_SETTINGS',\n\t\tsettings,\n\t};\n}\n\n/**\n * Returns an action object used to receive editor assets.\n *\n * @param {Object} assets Editor assets object.\n *\n * @return {Object} Action object.\n */\nexport function receiveEditorAssets( assets ) {\n\treturn {\n\t\ttype: 'RECEIVE_EDITOR_ASSETS',\n\t\tassets,\n\t};\n}\n\n/**\n * Returns an action object used to set whether collaboration is supported.\n *\n * @param {boolean} supported Whether collaboration is supported.\n *\n * @return {Object} Action object.\n */\nexport const setCollaborationSupported =\n\t( supported ) =>\n\t( { dispatch } ) => {\n\t\tdispatch( { type: 'SET_COLLABORATION_SUPPORTED', supported } );\n\t};\n", "/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { additionalEntityConfigLoaders, DEFAULT_ENTITY_KEY } from './entities';\nimport { getSyncManager } from './sync';\nimport {\n\tforwardResolver,\n\tgetNormalizedCommaSeparable,\n\tgetUserPermissionCacheKey,\n\tgetUserPermissionsFromAllowHeader,\n\tALLOWED_RESOURCE_ACTIONS,\n\tRECEIVE_INTERMEDIATE_RESULTS,\n\tisNumericID,\n\tnormalizeQueryForResolution,\n} from './utils';\nimport { fetchBlockPatterns } from './fetch';\nimport { restoreSelection, getSelectionHistory } from './utils/crdt-selection';\n\n/**\n * Requests authors from the REST API.\n *\n * @param {Object|undefined} query Optional object of query parameters to\n *                                 include with request.\n */\nexport const getAuthors =\n\t( query ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst path = addQueryArgs(\n\t\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\t\tquery\n\t\t);\n\t\tconst users = await apiFetch( { path } );\n\t\tdispatch.receiveUserQuery( path, users );\n\t};\n\n/**\n * Requests the current user from the REST API.\n */\nexport const getCurrentUser =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst currentUser = await apiFetch( { path: '/wp/v2/users/me' } );\n\t\tdispatch.receiveCurrentUser( currentUser );\n\t};\n\n/**\n * Requests an entity's record from the REST API.\n *\n * @param {string}           kind  Entity kind.\n * @param {string}           name  Entity name.\n * @param {number|string}    key   Record's key\n * @param {Object|undefined} query Optional object of query parameters to\n *                                 include with request. If requesting specific\n *                                 fields, fields must always include the ID.\n */\nexport const getEntityRecord =\n\t( kind, name, key = '', query ) =>\n\tasync ( { select, dispatch, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, key ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( query !== undefined && query._fields ) {\n\t\t\t\t// The resolution cache won't consider query as reusable based on the\n\t\t\t\t// fields, so it's tested here, prior to initiating the REST request,\n\t\t\t\t// and without causing `getEntityRecord` resolution to occur.\n\t\t\t\tconst hasRecord = select.hasEntityRecord(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tkey,\n\t\t\t\t\tquery\n\t\t\t\t);\n\t\t\t\tif ( hasRecord ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet { baseURL } = entityConfig;\n\n\t\t\t// For \"string\" IDs, use the old templates endpoint.\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\t( ( key && typeof key === 'string' && ! /^\\d+$/.test( key ) ) ||\n\t\t\t\t\t! window?.__experimentalTemplateActivate )\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs( baseURL + ( key ? '/' + key : '' ), {\n\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t...query,\n\t\t\t} );\n\t\t\tconst response = await apiFetch( { path, parse: false } );\n\t\t\tconst record = await response.json();\n\t\t\tconst permissions = getUserPermissionsFromAllowHeader(\n\t\t\t\tresponse.headers?.get( 'allow' )\n\t\t\t);\n\n\t\t\tconst canUserResolutionsArgs = [];\n\t\t\tconst receiveUserPermissionArgs = {};\n\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\treceiveUserPermissionArgs[\n\t\t\t\t\tgetUserPermissionCacheKey( action, {\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tid: key,\n\t\t\t\t\t} )\n\t\t\t\t] = permissions[ action ];\n\n\t\t\t\tcanUserResolutionsArgs.push( [\n\t\t\t\t\taction,\n\t\t\t\t\t{ kind, name, id: key },\n\t\t\t\t] );\n\t\t\t}\n\n\t\t\t// Entity supports syncing.\n\t\t\tif ( entityConfig.syncConfig && isNumericID( key ) && ! query ) {\n\t\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\t\tconst objectId = key;\n\n\t\t\t\t// Use the new transient \"read/write\" config to compute transients for\n\t\t\t\t// the sync manager. Otherwise these transients are not available\n\t\t\t\t// if / until the record is edited. Use a copy of the record so that\n\t\t\t\t// it does not change the behavior outside this experimental flag.\n\t\t\t\tconst recordWithTransients = { ...record };\n\t\t\t\tObject.entries( entityConfig.transientEdits ?? {} )\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( [ propName, transientConfig ] ) =>\n\t\t\t\t\t\t\tundefined === recordWithTransients[ propName ] &&\n\t\t\t\t\t\t\ttransientConfig &&\n\t\t\t\t\t\t\t'object' === typeof transientConfig &&\n\t\t\t\t\t\t\t'read' in transientConfig &&\n\t\t\t\t\t\t\t'function' === typeof transientConfig.read\n\t\t\t\t\t)\n\t\t\t\t\t.forEach( ( [ propName, transientConfig ] ) => {\n\t\t\t\t\t\trecordWithTransients[ propName ] =\n\t\t\t\t\t\t\ttransientConfig.read( recordWithTransients );\n\t\t\t\t\t} );\n\n\t\t\t\t// Load the entity record for syncing. Do not await promise.\n\t\t\t\tvoid getSyncManager()?.load(\n\t\t\t\t\tentityConfig.syncConfig,\n\t\t\t\t\tobjectType,\n\t\t\t\t\tobjectId,\n\t\t\t\t\trecordWithTransients,\n\t\t\t\t\t{\n\t\t\t\t\t\t// Handle edits sourced from the sync manager.\n\t\t\t\t\t\teditRecord: ( edits, options = {} ) => {\n\t\t\t\t\t\t\tif ( ! Object.keys( edits ).length ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tdispatch( {\n\t\t\t\t\t\t\t\ttype: 'EDIT_ENTITY_RECORD',\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\trecordId: key,\n\t\t\t\t\t\t\t\tedits,\n\t\t\t\t\t\t\t\tmeta: {\n\t\t\t\t\t\t\t\t\tundo: undefined,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\toptions,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t\t// Get the current entity record (with edits)\n\t\t\t\t\t\tgetEditedRecord: async () =>\n\t\t\t\t\t\t\tawait resolveSelect.getEditedEntityRecord(\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tkey\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t// Handle sync connection status changes.\n\t\t\t\t\t\tonStatusChange: ( status ) => {\n\t\t\t\t\t\t\tdispatch.setSyncConnectionStatus(\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\t\tstatus\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t// Refetch the current entity record from the database.\n\t\t\t\t\t\trefetchRecord: async () => {\n\t\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tawait apiFetch( { path, parse: true } ),\n\t\t\t\t\t\t\t\tquery\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t// Persist the CRDT document.\n\t\t\t\t\t\t//\n\t\t\t\t\t\t// TODO: Currently, persisted CRDT documents are stored in post meta.\n\t\t\t\t\t\t// This effectively means that only post entities support CRDT\n\t\t\t\t\t\t// persistence. As we add support for syncing additional entity,\n\t\t\t\t\t\t// we'll need to revisit where persisted CRDT documents are stored.\n\t\t\t\t\t\tpersistCRDTDoc: () => {\n\t\t\t\t\t\t\tresolveSelect\n\t\t\t\t\t\t\t\t.getEditedEntityRecord( kind, name, key )\n\t\t\t\t\t\t\t\t.then( ( editedRecord ) => {\n\t\t\t\t\t\t\t\t\t// Don't persist the CRDT document if the record is still an\n\t\t\t\t\t\t\t\t\t// auto-draft or if the entity does not support meta.\n\t\t\t\t\t\t\t\t\tconst { meta, status } = editedRecord;\n\t\t\t\t\t\t\t\t\tif ( 'auto-draft' === status || ! meta ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Trigger a save to persist the CRDT document. The entity's\n\t\t\t\t\t\t\t\t\t// pre-persist hooks will create the persisted CRDT document\n\t\t\t\t\t\t\t\t\t// and apply it to the record's meta.\n\t\t\t\t\t\t\t\t\tdispatch.saveEntityRecord(\n\t\t\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\t\t\teditedRecord\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t},\n\t\t\t\t\t\taddUndoMeta: ( ydoc, meta ) => {\n\t\t\t\t\t\t\tconst selectionHistory =\n\t\t\t\t\t\t\t\tgetSelectionHistory( ydoc );\n\n\t\t\t\t\t\t\tif ( selectionHistory ) {\n\t\t\t\t\t\t\t\tmeta.set(\n\t\t\t\t\t\t\t\t\t'selectionHistory',\n\t\t\t\t\t\t\t\t\tselectionHistory\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\trestoreUndoMeta: ( ydoc, meta ) => {\n\t\t\t\t\t\t\tconst selectionHistory =\n\t\t\t\t\t\t\t\tmeta.get( 'selectionHistory' );\n\n\t\t\t\t\t\t\tif ( selectionHistory ) {\n\t\t\t\t\t\t\t\t// Because Yjs initiates an undo, we need to\n\t\t\t\t\t\t\t\t// wait until the content is restored before\n\t\t\t\t\t\t\t\t// we can update the selection.\n\t\t\t\t\t\t\t\t// Use setTimeout() to wait until content is\n\t\t\t\t\t\t\t\t// finished updating, and then set the correct\n\t\t\t\t\t\t\t\t// selection.\n\t\t\t\t\t\t\t\tsetTimeout( () => {\n\t\t\t\t\t\t\t\t\trestoreSelection( selectionHistory, ydoc );\n\t\t\t\t\t\t\t\t}, 0 );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveEntityRecords( kind, name, record, query );\n\t\t\t\tdispatch.receiveUserPermissions( receiveUserPermissionArgs );\n\t\t\t\tdispatch.finishResolutions( 'canUser', canUserResolutionsArgs );\n\t\t\t} );\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n// Whenever a template is saved, the active templates might be updated, so\n// invalidate the site settings when a template is updated or deleted.\ngetEntityRecord.shouldInvalidate = ( action, kind, name ) => {\n\treturn (\n\t\tkind === 'root' &&\n\t\tname === 'site' &&\n\t\t( ( action.type === 'RECEIVE_ITEMS' &&\n\t\t\t// Making sure persistedEdits is set seems to be the only way of\n\t\t\t// knowing whether it's an update or fetch. Only an update would\n\t\t\t// have persistedEdits.\n\t\t\taction.persistedEdits &&\n\t\t\taction.persistedEdits.status !== 'auto-draft' ) ||\n\t\t\taction.type === 'REMOVE_ITEMS' ) &&\n\t\taction.kind === 'postType' &&\n\t\taction.name === 'wp_template'\n\t);\n};\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getRawEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests an entity's record from the REST API.\n */\nexport const getEditedEntityRecord = forwardResolver( 'getEntityRecord' );\n\n/**\n * Requests the entity's records from the REST API.\n *\n * @param {string}  kind  Entity kind.\n * @param {string}  name  Entity name.\n * @param {?Object} query Query Object. If requesting specific fields, fields\n *                        must always include the ID.\n */\nexport const getEntityRecords =\n\t( kind, name, query = {} ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\t// Keep a copy of the original query for later use in getResolutionsArgs.\n\t\t// The query object may be modified below (for example, when _fields is\n\t\t// specified), but we want to use the original query when marking\n\t\t// resolutions as finished.\n\t\tconst rawQuery = { ...query };\n\t\tconst key = entityConfig.key || DEFAULT_ENTITY_KEY;\n\n\t\tfunction getResolutionsArgs( records, recordsQuery ) {\n\t\t\tconst normalizedQuery = normalizeQueryForResolution( recordsQuery );\n\t\t\treturn records\n\t\t\t\t.filter( ( record ) => record?.[ key ] )\n\t\t\t\t.map( ( record ) => [\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecord[ key ],\n\t\t\t\t\tnormalizedQuery,\n\t\t\t\t] );\n\t\t}\n\n\t\ttry {\n\t\t\tif ( query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet { baseURL } = entityConfig;\n\t\t\t// `combinedTemplates` means that we fetch templates from the \"old\"\n\t\t\t// /templates endpoint, which combines active user templates with\n\t\t\t// the registered templates and rewrites IDs in the form of\n\t\t\t// `theme-slug/template-slug`. When turned off, we only fetch\n\t\t\t// database templates (posts). To fetch registered templates without\n\t\t\t// edits applied, use the `registeredTemplate` entity.\n\t\t\tconst { combinedTemplates = true } = query;\n\n\t\t\tif (\n\t\t\t\tkind === 'postType' &&\n\t\t\t\tname === 'wp_template' &&\n\t\t\t\tcombinedTemplates\n\t\t\t) {\n\t\t\t\tbaseURL =\n\t\t\t\t\tbaseURL.slice( 0, baseURL.lastIndexOf( '/' ) ) +\n\t\t\t\t\t'/templates';\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs( baseURL, {\n\t\t\t\t...entityConfig.baseURLParams,\n\t\t\t\t...query,\n\t\t\t} );\n\n\t\t\tlet records = [],\n\t\t\t\tmeta;\n\t\t\tif ( entityConfig.supportsPagination && query.per_page !== -1 ) {\n\t\t\t\tconst response = await apiFetch( { path, parse: false } );\n\t\t\t\trecords = Object.values( await response.json() );\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-Total' )\n\t\t\t\t\t),\n\t\t\t\t\ttotalPages: parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-TotalPages' )\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t} else if (\n\t\t\t\tquery.per_page === -1 &&\n\t\t\t\tquery[ RECEIVE_INTERMEDIATE_RESULTS ] === true\n\t\t\t) {\n\t\t\t\tlet page = 1;\n\t\t\t\tlet totalPages;\n\n\t\t\t\tdo {\n\t\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\t\tpath: addQueryArgs( path, { page, per_page: 100 } ),\n\t\t\t\t\t\tparse: false,\n\t\t\t\t\t} );\n\t\t\t\t\tconst pageRecords = Object.values( await response.json() );\n\n\t\t\t\t\ttotalPages = parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-TotalPages' )\n\t\t\t\t\t);\n\n\t\t\t\t\tif ( ! meta ) {\n\t\t\t\t\t\tmeta = {\n\t\t\t\t\t\t\ttotalItems: parseInt(\n\t\t\t\t\t\t\t\tresponse.headers.get( 'X-WP-Total' )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\ttotalPages: 1,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\trecords.push( ...pageRecords );\n\t\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\trecords,\n\t\t\t\t\t\t\tquery,\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tmeta\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t\t\tgetResolutionsArgs( pageRecords, rawQuery )\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t\tpage++;\n\t\t\t\t} while ( page <= totalPages );\n\t\t\t} else {\n\t\t\t\trecords = Object.values( await apiFetch( { path } ) );\n\t\t\t\tmeta = {\n\t\t\t\t\ttotalItems: records.length,\n\t\t\t\t\ttotalPages: 1,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( entityConfig.syncConfig && -1 === query.per_page ) {\n\t\t\t\tconst objectType = `${ kind }/${ name }`;\n\t\t\t\tgetSyncManager()?.loadCollection(\n\t\t\t\t\tentityConfig.syncConfig,\n\t\t\t\t\tobjectType,\n\t\t\t\t\t{\n\t\t\t\t\t\tonStatusChange: ( status ) => {\n\t\t\t\t\t\t\tdispatch.setSyncConnectionStatus(\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tnull,\n\t\t\t\t\t\t\t\tstatus\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\trefetchRecords: async () => {\n\t\t\t\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tawait apiFetch( { path, parse: true } ),\n\t\t\t\t\t\t\t\tquery\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// If we request fields but the result doesn't contain the fields,\n\t\t\t// explicitly set these fields as \"undefined\"\n\t\t\t// that way we consider the query \"fulfilled\".\n\t\t\tif ( query._fields ) {\n\t\t\t\trecords = records.map( ( record ) => {\n\t\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn record;\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecords,\n\t\t\t\t\tquery,\n\t\t\t\t\tfalse,\n\t\t\t\t\tundefined,\n\t\t\t\t\tmeta\n\t\t\t\t);\n\n\t\t\t\tconst targetHints = records\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( record ) =>\n\t\t\t\t\t\t\t!! record?.[ key ] &&\n\t\t\t\t\t\t\t!! record?._links?.self?.[ 0 ]?.targetHints?.allow\n\t\t\t\t\t)\n\t\t\t\t\t.map( ( record ) => ( {\n\t\t\t\t\t\tid: record[ key ],\n\t\t\t\t\t\tpermissions: getUserPermissionsFromAllowHeader(\n\t\t\t\t\t\t\trecord._links.self[ 0 ].targetHints.allow\n\t\t\t\t\t\t),\n\t\t\t\t\t} ) );\n\n\t\t\t\tconst canUserResolutionsArgs = [];\n\t\t\t\tconst receiveUserPermissionArgs = {};\n\t\t\t\tfor ( const targetHint of targetHints ) {\n\t\t\t\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\t\t\t\tcanUserResolutionsArgs.push( [\n\t\t\t\t\t\t\taction,\n\t\t\t\t\t\t\t{ kind, name, id: targetHint.id },\n\t\t\t\t\t\t] );\n\n\t\t\t\t\t\treceiveUserPermissionArgs[\n\t\t\t\t\t\t\tgetUserPermissionCacheKey( action, {\n\t\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tid: targetHint.id,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t] = targetHint.permissions[ action ];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( targetHints.length > 0 ) {\n\t\t\t\t\tdispatch.receiveUserPermissions(\n\t\t\t\t\t\treceiveUserPermissionArgs\n\t\t\t\t\t);\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'canUser',\n\t\t\t\t\t\tcanUserResolutionsArgs\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\tgetResolutionsArgs( records, rawQuery )\n\t\t\t\t);\n\n\t\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t\t} );\n\t\t} catch ( e ) {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\ngetEntityRecords.shouldInvalidate = ( action, kind, name ) => {\n\treturn (\n\t\t( action.type === 'RECEIVE_ITEMS' || action.type === 'REMOVE_ITEMS' ) &&\n\t\taction.invalidateCache &&\n\t\tkind === action.kind &&\n\t\tname === action.name\n\t);\n};\n\n/**\n * Requests the total number of entity records.\n */\nexport const getEntityRecordsTotalItems = forwardResolver( 'getEntityRecords' );\n\n/**\n * Requests the number of available pages for the given query.\n */\nexport const getEntityRecordsTotalPages = forwardResolver( 'getEntityRecords' );\n\n/**\n * Requests the current theme.\n */\nexport const getCurrentTheme =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\n\t\tdispatch.receiveCurrentTheme( activeThemes[ 0 ] );\n\t};\n\n/**\n * Requests theme supports data from the index.\n */\nexport const getThemeSupports = forwardResolver( 'getCurrentTheme' );\n\n/**\n * Requests a preview from the Embed API.\n *\n * @param {string} url URL to get the preview for.\n */\nexport const getEmbedPreview =\n\t( url ) =>\n\tasync ( { dispatch } ) => {\n\t\ttry {\n\t\t\tconst embedProxyResponse = await apiFetch( {\n\t\t\t\tpath: addQueryArgs( '/oembed/1.0/proxy', { url } ),\n\t\t\t} );\n\t\t\tdispatch.receiveEmbedPreview( url, embedProxyResponse );\n\t\t} catch ( error ) {\n\t\t\t// Embed API 404s if the URL cannot be embedded, so we have to catch the error from the apiRequest here.\n\t\t\tdispatch.receiveEmbedPreview( url, false );\n\t\t}\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string}        requestedAction Action to check. One of: 'create', 'read', 'update',\n *                                        'delete'.\n * @param {string|Object} resource        Entity resource to check. Accepts entity object `{ kind: 'postType', name: 'attachment', id: 1 }`\n *                                        or REST base as a string - `media`.\n * @param {?string}       id              ID of the rest resource to check.\n */\nexport const canUser =\n\t( requestedAction, resource, id ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tif ( ! ALLOWED_RESOURCE_ACTIONS.includes( requestedAction ) ) {\n\t\t\tthrow new Error( `'${ requestedAction }' is not a valid action.` );\n\t\t}\n\n\t\tconst { hasStartedResolution } = registry.select( STORE_NAME );\n\n\t\t// Prevent resolving the same resource twice.\n\t\tfor ( const relatedAction of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\tif ( relatedAction === requestedAction ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst isAlreadyResolving = hasStartedResolution( 'canUser', [\n\t\t\t\trelatedAction,\n\t\t\t\tresource,\n\t\t\t\tid,\n\t\t\t] );\n\t\t\tif ( isAlreadyResolving ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tlet resourcePath = null;\n\t\tif ( typeof resource === 'object' ) {\n\t\t\tif ( ! resource.kind || ! resource.name ) {\n\t\t\t\tthrow new Error( 'The entity resource object is not valid.' );\n\t\t\t}\n\n\t\t\tconst configs = await resolveSelect.getEntitiesConfig(\n\t\t\t\tresource.kind\n\t\t\t);\n\t\t\tconst entityConfig = configs.find(\n\t\t\t\t( config ) =>\n\t\t\t\t\tconfig.name === resource.name &&\n\t\t\t\t\tconfig.kind === resource.kind\n\t\t\t);\n\t\t\tif ( ! entityConfig ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresourcePath =\n\t\t\t\tentityConfig.baseURL + ( resource.id ? '/' + resource.id : '' );\n\t\t} else {\n\t\t\tresourcePath = `/wp/v2/${ resource }` + ( id ? '/' + id : '' );\n\t\t}\n\n\t\tlet response;\n\t\ttry {\n\t\t\tresponse = await apiFetch( {\n\t\t\t\tpath: resourcePath,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t\tparse: false,\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if our OPTIONS request comes back with an API error (4xx or\n\t\t\t// 5xx). The previously determined isAllowed value will remain in the store.\n\t\t\treturn;\n\t\t}\n\n\t\t// Optional chaining operator is used here because the API requests don't\n\t\t// return the expected result in the React native version. Instead, API requests\n\t\t// only return the result, without including response properties like the headers.\n\t\tconst permissions = getUserPermissionsFromAllowHeader(\n\t\t\tresponse.headers?.get( 'allow' )\n\t\t);\n\t\tconst receiveUserPermissionArgs = {};\n\t\tconst canUserResolutionsArgs = [];\n\t\tfor ( const action of ALLOWED_RESOURCE_ACTIONS ) {\n\t\t\treceiveUserPermissionArgs[\n\t\t\t\tgetUserPermissionCacheKey( action, resource, id )\n\t\t\t] = permissions[ action ];\n\n\t\t\t// Mark related action resolutions as finished.\n\t\t\tif ( action !== requestedAction ) {\n\t\t\t\tcanUserResolutionsArgs.push( [ action, resource, id ] );\n\t\t\t}\n\t\t}\n\t\tregistry.batch( () => {\n\t\t\tdispatch.receiveUserPermissions( receiveUserPermissionArgs );\n\t\t\tdispatch.finishResolutions( 'canUser', canUserResolutionsArgs );\n\t\t} );\n\t};\n\n/**\n * Checks whether the current user can perform the given action on the given\n * REST resource.\n *\n * @param {string}        kind     Entity kind.\n * @param {string}        name     Entity name.\n * @param {number|string} recordId Record's id.\n */\nexport const canUserEditEntityRecord =\n\t( kind, name, recordId ) =>\n\tasync ( { dispatch } ) => {\n\t\tawait dispatch( canUser( 'update', { kind, name, id: recordId } ) );\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId   The id of the parent post.\n */\nexport const getAutosaves =\n\t( postType, postId ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst {\n\t\t\trest_base: restBase,\n\t\t\trest_namespace: restNamespace = 'wp/v2',\n\t\t\tsupports,\n\t\t} = await resolveSelect.getPostType( postType );\n\t\tif ( ! supports?.autosave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst autosaves = await apiFetch( {\n\t\t\tpath: `/${ restNamespace }/${ restBase }/${ postId }/autosaves?context=edit`,\n\t\t} );\n\n\t\tif ( autosaves && autosaves.length ) {\n\t\t\tdispatch.receiveAutosaves( postId, autosaves );\n\t\t}\n\t};\n\n/**\n * Request autosave data from the REST API.\n *\n * This resolver exists to ensure the underlying autosaves are fetched via\n * `getAutosaves` when a call to the `getAutosave` selector is made.\n *\n * @param {string} postType The type of the parent post.\n * @param {number} postId   The id of the parent post.\n */\nexport const getAutosave =\n\t( postType, postId ) =>\n\tasync ( { resolveSelect } ) => {\n\t\tawait resolveSelect.getAutosaves( postType, postId );\n\t};\n\nexport const __experimentalGetCurrentGlobalStylesId =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst activeThemes = await resolveSelect.getEntityRecords(\n\t\t\t'root',\n\t\t\t'theme',\n\t\t\t{ status: 'active' }\n\t\t);\n\t\tconst globalStylesURL =\n\t\t\tactiveThemes?.[ 0 ]?._links?.[ 'wp:user-global-styles' ]?.[ 0 ]\n\t\t\t\t?.href;\n\t\tif ( ! globalStylesURL ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Regex matches the ID at the end of a URL or immediately before\n\t\t// the query string.\n\t\tconst matches = globalStylesURL.match( /\\/(\\d+)(?:\\?|$)/ );\n\t\tconst id = matches ? Number( matches[ 1 ] ) : null;\n\n\t\tif ( id ) {\n\t\t\tdispatch.__experimentalReceiveCurrentGlobalStylesId( id );\n\t\t}\n\t};\n\nexport const __experimentalGetCurrentThemeBaseGlobalStyles =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\t// Please adjust the preloaded requests if this changes!\n\t\tconst themeGlobalStyles = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }?context=view`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeBaseGlobalStyles(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tthemeGlobalStyles\n\t\t);\n\t};\n\nexport const __experimentalGetCurrentThemeGlobalStylesVariations =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst currentTheme = await resolveSelect.getCurrentTheme();\n\t\t// Please adjust the preloaded requests if this changes!\n\t\tconst variations = await apiFetch( {\n\t\t\tpath: `/wp/v2/global-styles/themes/${ currentTheme.stylesheet }/variations?context=view`,\n\t\t} );\n\t\tdispatch.__experimentalReceiveThemeGlobalStyleVariations(\n\t\t\tcurrentTheme.stylesheet,\n\t\t\tvariations\n\t\t);\n\t};\n\n/**\n * Fetches and returns the revisions of the current global styles theme.\n */\nexport const getCurrentThemeGlobalStylesRevisions =\n\t() =>\n\tasync ( { resolveSelect, dispatch } ) => {\n\t\tconst globalStylesId =\n\t\t\tawait resolveSelect.__experimentalGetCurrentGlobalStylesId();\n\t\tconst record = globalStylesId\n\t\t\t? await resolveSelect.getEntityRecord(\n\t\t\t\t\t'root',\n\t\t\t\t\t'globalStyles',\n\t\t\t\t\tglobalStylesId\n\t\t\t  )\n\t\t\t: undefined;\n\t\tconst revisionsURL = record?._links?.[ 'version-history' ]?.[ 0 ]?.href;\n\n\t\tif ( revisionsURL ) {\n\t\t\tconst resetRevisions = await apiFetch( {\n\t\t\t\turl: revisionsURL,\n\t\t\t} );\n\t\t\tconst revisions = resetRevisions?.map( ( revision ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( revision ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\t\t\tdispatch.receiveThemeGlobalStyleRevisions(\n\t\t\t\tglobalStylesId,\n\t\t\t\trevisions\n\t\t\t);\n\t\t}\n\t};\n\ngetCurrentThemeGlobalStylesRevisions.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'SAVE_ENTITY_RECORD_FINISH' &&\n\t\taction.kind === 'root' &&\n\t\t! action.error &&\n\t\taction.name === 'globalStyles'\n\t);\n};\n\nexport const getBlockPatterns =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst patterns = await fetchBlockPatterns();\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\nexport const getBlockPatternCategories =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst categories = await apiFetch( {\n\t\t\tpath: '/wp/v2/block-patterns/categories',\n\t\t} );\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERN_CATEGORIES', categories } );\n\t};\n\nexport const getUserPatternCategories =\n\t() =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tconst patternCategories = await resolveSelect.getEntityRecords(\n\t\t\t'taxonomy',\n\t\t\t'wp_pattern_category',\n\t\t\t{\n\t\t\t\tper_page: -1,\n\t\t\t\t_fields: 'id,name,description,slug',\n\t\t\t\tcontext: 'view',\n\t\t\t}\n\t\t);\n\n\t\tconst mappedPatternCategories =\n\t\t\tpatternCategories?.map( ( userCategory ) => ( {\n\t\t\t\t...userCategory,\n\t\t\t\tlabel: decodeEntities( userCategory.name ),\n\t\t\t\tname: userCategory.slug,\n\t\t\t} ) ) || [];\n\n\t\tdispatch( {\n\t\t\ttype: 'RECEIVE_USER_PATTERN_CATEGORIES',\n\t\t\tpatternCategories: mappedPatternCategories,\n\t\t} );\n\t};\n\nexport const getNavigationFallbackId =\n\t() =>\n\tasync ( { dispatch, select, registry } ) => {\n\t\tconst fallback = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/wp-block-editor/v1/navigation-fallback', {\n\t\t\t\t_embed: true,\n\t\t\t} ),\n\t\t} );\n\n\t\tconst record = fallback?._embedded?.self;\n\n\t\tregistry.batch( () => {\n\t\t\tdispatch.receiveNavigationFallbackId( fallback?.id );\n\n\t\t\tif ( ! record ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the fallback is already in the store, don't invalidate navigation queries.\n\t\t\t// Otherwise, invalidate the cache for the scenario where there were no Navigation\n\t\t\t// posts in the state and the fallback created one.\n\t\t\tconst existingFallbackEntityRecord = select.getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\tfallback.id\n\t\t\t);\n\t\t\tconst invalidateNavigationQueries = ! existingFallbackEntityRecord;\n\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\trecord,\n\t\t\t\tundefined,\n\t\t\t\tinvalidateNavigationQueries\n\t\t\t);\n\n\t\t\t// Resolve to avoid further network requests.\n\t\t\tdispatch.finishResolution( 'getEntityRecord', [\n\t\t\t\t'postType',\n\t\t\t\t'wp_navigation',\n\t\t\t\tfallback.id,\n\t\t\t] );\n\t\t} );\n\t};\n\nexport const getDefaultTemplateId =\n\t( query ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tconst template = await apiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/templates/lookup', query ),\n\t\t} );\n\t\t// Wait for the the entities config to be loaded, otherwise receiving\n\t\t// the template as an entity will not work.\n\t\tawait resolveSelect.getEntitiesConfig( 'postType' );\n\t\t// When active_templates experiment is enabled, use numeric wp_id if it\n\t\t// exists, otherwise fall back to string ID format (theme//slug) as the\n\t\t// frontend expects string IDs for templates.\n\t\tconst id = window?.__experimentalTemplateActivate\n\t\t\t? template?.wp_id || template?.id\n\t\t\t: template?.id;\n\t\t// Endpoint may return an empty object if no template is found.\n\t\tif ( id ) {\n\t\t\ttemplate.id = id;\n\t\t\tregistry.batch( () => {\n\t\t\t\tdispatch.receiveDefaultTemplateId( query, id );\n\t\t\t\tdispatch.receiveEntityRecords(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate\n\t\t\t\t);\n\t\t\t\t// Avoid further network requests.\n\t\t\t\tdispatch.finishResolution( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\tid,\n\t\t\t\t] );\n\t\t\t} );\n\t\t}\n\t};\n\ngetDefaultTemplateId.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'RECEIVE_ITEMS' &&\n\t\taction.kind === 'root' &&\n\t\taction.name === 'site'\n\t);\n};\n\n/**\n * Requests an entity's revisions from the REST API.\n *\n * @param {string}           kind      Entity kind.\n * @param {string}           name      Entity name.\n * @param {number|string}    recordKey The key of the entity record whose revisions you want to fetch.\n * @param {Object|undefined} query     Optional object of query parameters to\n *                                     include with request. If requesting specific\n *                                     fields, fields must always include the ID.\n */\nexport const getRevisions =\n\t( kind, name, recordKey, query = {} ) =>\n\tasync ( { dispatch, registry, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst rawQuery = { ...query };\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[ 'entities', 'records', kind, name, recordKey, 'revisions' ],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif ( query._fields ) {\n\t\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t\t// the ID.\n\t\t\t\tquery = {\n\t\t\t\t\t...query,\n\t\t\t\t\t_fields: [\n\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\t\tentityConfig.revisionKey || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t\t] ),\n\t\t\t\t\t].join(),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs(\n\t\t\t\tentityConfig.getRevisionsUrl( recordKey ),\n\t\t\t\tquery\n\t\t\t);\n\n\t\t\tlet records, response;\n\t\t\tconst meta = {};\n\t\t\tconst isPaginated =\n\t\t\t\tentityConfig.supportsPagination && query.per_page !== -1;\n\t\t\ttry {\n\t\t\t\tresponse = await apiFetch( { path, parse: ! isPaginated } );\n\t\t\t} catch ( error ) {\n\t\t\t\t// Do nothing if our request comes back with an API error.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( response ) {\n\t\t\t\tif ( isPaginated ) {\n\t\t\t\t\trecords = Object.values( await response.json() );\n\t\t\t\t\tmeta.totalItems = parseInt(\n\t\t\t\t\t\tresponse.headers.get( 'X-WP-Total' )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\trecords = Object.values( response );\n\t\t\t\t}\n\n\t\t\t\t// If we request fields but the result doesn't contain the fields,\n\t\t\t\t// explicitly set these fields as \"undefined\"\n\t\t\t\t// that way we consider the query \"fulfilled\".\n\t\t\t\tif ( query._fields ) {\n\t\t\t\t\trecords = records.map( ( record ) => {\n\t\t\t\t\t\tquery._fields.split( ',' ).forEach( ( field ) => {\n\t\t\t\t\t\t\tif ( ! record.hasOwnProperty( field ) ) {\n\t\t\t\t\t\t\t\trecord[ field ] = undefined;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\treturn record;\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tdispatch.receiveRevisions(\n\t\t\t\t\t\tkind,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\trecordKey,\n\t\t\t\t\t\trecords,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tmeta\n\t\t\t\t\t);\n\n\t\t\t\t\t// Mark individual getRevision resolutions as done so that\n\t\t\t\t\t// subsequent getRevision calls skip redundant API fetches.\n\t\t\t\t\tconst key = entityConfig.revisionKey || DEFAULT_ENTITY_KEY;\n\t\t\t\t\tconst normalizedQuery =\n\t\t\t\t\t\tnormalizeQueryForResolution( rawQuery );\n\t\t\t\t\tconst resolutionsArgs = records\n\t\t\t\t\t\t.filter( ( record ) => record[ key ] )\n\t\t\t\t\t\t.map( ( record ) => [\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\trecordKey,\n\t\t\t\t\t\t\trecord[ key ],\n\t\t\t\t\t\t\tnormalizedQuery,\n\t\t\t\t\t\t] );\n\n\t\t\t\t\tdispatch.finishResolutions(\n\t\t\t\t\t\t'getRevision',\n\t\t\t\t\t\tresolutionsArgs\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n// Invalidate cache when a new revision is created.\ngetRevisions.shouldInvalidate = ( action, kind, name, recordKey ) =>\n\taction.type === 'SAVE_ENTITY_RECORD_FINISH' &&\n\tname === action.name &&\n\tkind === action.kind &&\n\t! action.error &&\n\trecordKey === action.recordId;\n\n/**\n * Requests a specific Entity revision from the REST API.\n *\n * @param {string}           kind        Entity kind.\n * @param {string}           name        Entity name.\n * @param {number|string}    recordKey   The key of the entity record whose revisions you want to fetch.\n * @param {number|string}    revisionKey The revision's key.\n * @param {Object|undefined} query       Optional object of query parameters to\n *                                       include with request. If requesting specific\n *                                       fields, fields must always include the ID.\n */\nexport const getRevision =\n\t( kind, name, recordKey, revisionKey, query ) =>\n\tasync ( { select, dispatch, resolveSelect } ) => {\n\t\tconst configs = await resolveSelect.getEntitiesConfig( kind );\n\t\tconst entityConfig = configs.find(\n\t\t\t( config ) => config.name === name && config.kind === kind\n\t\t);\n\n\t\tif ( ! entityConfig ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( query !== undefined && query._fields ) {\n\t\t\t// If requesting specific fields, items and query association to said\n\t\t\t// records are stored by ID reference. Thus, fields must always include\n\t\t\t// the ID.\n\t\t\tquery = {\n\t\t\t\t...query,\n\t\t\t\t_fields: [\n\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t...( getNormalizedCommaSeparable( query._fields ) ||\n\t\t\t\t\t\t\t[] ),\n\t\t\t\t\t\tentityConfig.revisionKey || DEFAULT_ENTITY_KEY,\n\t\t\t\t\t] ),\n\t\t\t\t].join(),\n\t\t\t};\n\t\t}\n\n\t\tconst lock = await dispatch.__unstableAcquireStoreLock(\n\t\t\tSTORE_NAME,\n\t\t\t[\n\t\t\t\t'entities',\n\t\t\t\t'records',\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordKey,\n\t\t\t\t'revisions',\n\t\t\t\trevisionKey,\n\t\t\t],\n\t\t\t{ exclusive: false }\n\t\t);\n\n\t\ttry {\n\t\t\tif (\n\t\t\t\tselect.hasRevision( kind, name, recordKey, revisionKey, query )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst path = addQueryArgs(\n\t\t\t\tentityConfig.getRevisionsUrl( recordKey, revisionKey ),\n\t\t\t\tquery\n\t\t\t);\n\n\t\t\tlet record;\n\t\t\ttry {\n\t\t\t\trecord = await apiFetch( { path } );\n\t\t\t} catch ( error ) {\n\t\t\t\t// Do nothing if our request comes back with an API error.\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( record ) {\n\t\t\t\tdispatch.receiveRevisions(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordKey,\n\t\t\t\t\trecord,\n\t\t\t\t\tquery\n\t\t\t\t);\n\t\t\t}\n\t\t} finally {\n\t\t\tdispatch.__unstableReleaseStoreLock( lock );\n\t\t}\n\t};\n\n/**\n * Requests a specific post type options from the REST API.\n *\n * @param {string} postType Post type slug.\n */\nexport const getRegisteredPostMeta =\n\t( postType ) =>\n\tasync ( { dispatch, resolveSelect } ) => {\n\t\tlet options;\n\t\ttry {\n\t\t\tconst {\n\t\t\t\trest_namespace: restNamespace = 'wp/v2',\n\t\t\t\trest_base: restBase,\n\t\t\t} = ( await resolveSelect.getPostType( postType ) ) || {};\n\t\t\toptions = await apiFetch( {\n\t\t\t\tpath: `${ restNamespace }/${ restBase }/?context=edit`,\n\t\t\t\tmethod: 'OPTIONS',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\t// Do nothing if the request comes back with an API error.\n\t\t\treturn;\n\t\t}\n\n\t\tif ( options ) {\n\t\t\tdispatch.receiveRegisteredPostMeta(\n\t\t\t\tpostType,\n\t\t\t\toptions?.schema?.properties?.meta?.properties\n\t\t\t);\n\t\t}\n\t};\n\n/**\n * Requests entity configs for the given kind from the REST API.\n *\n * @param {string} kind Entity kind.\n */\nexport const getEntitiesConfig =\n\t( kind ) =>\n\tasync ( { dispatch } ) => {\n\t\tconst loader = additionalEntityConfigLoaders.find(\n\t\t\t( l ) => l.kind === kind\n\t\t);\n\n\t\tif ( ! loader ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst configs = await loader.loadEntities();\n\t\t\tif ( ! configs.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdispatch.addEntities( configs );\n\t\t} catch {\n\t\t\t// Do nothing if the request comes back with an API error.\n\t\t}\n\t};\n\n/**\n * Requests editor settings from the REST API.\n */\nexport const getEditorSettings =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst settings = await apiFetch( {\n\t\t\tpath: '/wp-block-editor/v1/settings',\n\t\t} );\n\t\tdispatch.receiveEditorSettings( settings );\n\t};\n\n/**\n * Requests editor assets from the REST API.\n */\nexport const getEditorAssets =\n\t() =>\n\tasync ( { dispatch } ) => {\n\t\tconst assets = await apiFetch( {\n\t\t\tpath: '/wp-block-editor/v1/assets',\n\t\t} );\n\t\tdispatch.receiveEditorAssets( assets );\n\t};\n", "/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\nexport { default as __experimentalFetchLinkSuggestions } from './__experimental-fetch-link-suggestions';\nexport { default as __experimentalFetchUrlData } from './__experimental-fetch-url-data';\n\nexport async function fetchBlockPatterns() {\n\tconst restPatterns = await apiFetch( {\n\t\tpath: '/wp/v2/block-patterns/patterns',\n\t} );\n\tif ( ! restPatterns ) {\n\t\treturn [];\n\t}\n\treturn restPatterns.map( ( pattern ) =>\n\t\tObject.fromEntries(\n\t\t\tObject.entries( pattern ).map( ( [ key, value ] ) => [\n\t\t\t\tcamelCase( key ),\n\t\t\t\tvalue,\n\t\t\t] )\n\t\t)\n\t);\n}\n", "/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\nexport type SearchOptions = {\n\t/**\n\t * Displays initial search suggestions, when true.\n\t */\n\tisInitialSuggestions?: boolean;\n\t/**\n\t * Search options for initial suggestions.\n\t */\n\tinitialSuggestionsSearchOptions?: Omit<\n\t\tSearchOptions,\n\t\t'isInitialSuggestions' | 'initialSuggestionsSearchOptions'\n\t>;\n\t/**\n\t * Filters by search type.\n\t */\n\ttype?: 'attachment' | 'post' | 'term' | 'post-format';\n\t/**\n\t * Slug of the post-type or taxonomy.\n\t */\n\tsubtype?: string;\n\t/**\n\t * Which page of results to return.\n\t */\n\tpage?: number;\n\t/**\n\t * Search results per page.\n\t */\n\tperPage?: number;\n};\n\nexport type EditorSettings = {\n\t/**\n\t * Disables post formats, when true.\n\t */\n\tdisablePostFormats?: boolean;\n};\n\ntype SearchAPIResult = {\n\tid: number;\n\ttitle: string;\n\turl: string;\n\ttype: string;\n\tsubtype: string;\n};\n\ntype MediaAPIResult = {\n\tid: number;\n\ttitle: { rendered: string };\n\tsource_url: string;\n\ttype: string;\n};\n\nexport type SearchResult = {\n\t/**\n\t * Post or term id.\n\t */\n\tid: number;\n\t/**\n\t * Link url.\n\t */\n\turl: string;\n\t/**\n\t * Title of the link.\n\t */\n\ttitle: string;\n\t/**\n\t * The taxonomy or post type slug or type URL.\n\t */\n\ttype: string;\n\t/**\n\t * Link kind of post-type or taxonomy\n\t */\n\tkind?: string;\n};\n\n/**\n * Fetches link suggestions from the WordPress API.\n *\n * WordPress does not support searching multiple tables at once, e.g. posts and terms, so we\n * perform multiple queries at the same time and then merge the results together.\n *\n * @param search\n * @param searchOptions\n * @param editorSettings\n *\n * @example\n * ```js\n * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchLinkSuggestions = (\n *     search,\n *     searchOptions\n * ) => fetchLinkSuggestions( search, searchOptions, settings );\n * ```\n */\nexport default async function fetchLinkSuggestions(\n\tsearch: string,\n\tsearchOptions: SearchOptions = {},\n\teditorSettings: EditorSettings = {}\n): Promise< SearchResult[] > {\n\tconst searchOptionsToUse =\n\t\tsearchOptions.isInitialSuggestions &&\n\t\tsearchOptions.initialSuggestionsSearchOptions\n\t\t\t? {\n\t\t\t\t\t...searchOptions,\n\t\t\t\t\t...searchOptions.initialSuggestionsSearchOptions,\n\t\t\t  }\n\t\t\t: searchOptions;\n\n\tconst {\n\t\ttype,\n\t\tsubtype,\n\t\tpage,\n\t\tperPage = searchOptions.isInitialSuggestions ? 3 : 20,\n\t} = searchOptionsToUse;\n\n\tconst { disablePostFormats = false } = editorSettings;\n\n\tconst queries: Promise< SearchResult[] >[] = [];\n\n\tif ( ! type || type === 'post' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'post-type',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'term' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'term',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! disablePostFormats && ( ! type || type === 'post-format' ) ) {\n\t\tqueries.push(\n\t\t\tapiFetch< SearchAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post-format',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\t\t\tkind: 'taxonomy',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'attachment' ) {\n\t\tqueries.push(\n\t\t\tapiFetch< MediaAPIResult[] >( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/media', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: result.id,\n\t\t\t\t\t\t\turl: result.source_url,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tdecodeEntities( result.title.rendered || '' ) ||\n\t\t\t\t\t\t\t\t__( '(no title)' ),\n\t\t\t\t\t\t\ttype: result.type,\n\t\t\t\t\t\t\tkind: 'media',\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tconst responses = await Promise.all( queries );\n\n\tlet results = responses.flat();\n\tresults = results.filter( ( result ) => !! result.id );\n\tresults = sortResults( results, search );\n\tresults = results.slice( 0, perPage );\n\treturn results;\n}\n\n/**\n * Sort search results by relevance to the given query.\n *\n * Sorting is necessary as we're querying multiple endpoints and merging the results. For example\n * a taxonomy title might be more relevant than a post title, but by default taxonomy results will\n * be ordered after all the (potentially irrelevant) post results.\n *\n * We sort by scoring each result, where the score is the number of tokens in the title that are\n * also in the search query, divided by the total number of tokens in the title. This gives us a\n * score between 0 and 1, where 1 is a perfect match.\n *\n * @param results\n * @param search\n */\nexport function sortResults( results: SearchResult[], search: string ) {\n\tconst searchTokens = tokenize( search );\n\n\tconst scores = {};\n\tfor ( const result of results ) {\n\t\tif ( result.title ) {\n\t\t\tconst titleTokens = tokenize( result.title );\n\t\t\tconst exactMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) => titleToken === searchToken\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst subMatchingTokens = titleTokens.filter( ( titleToken ) =>\n\t\t\t\tsearchTokens.some(\n\t\t\t\t\t( searchToken ) =>\n\t\t\t\t\t\ttitleToken !== searchToken &&\n\t\t\t\t\t\ttitleToken.includes( searchToken )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\t// The score is a combination of exact matches and sub-matches.\n\t\t\t// More weight is given to exact matches, as they are more relevant (e.g. \"cat\" vs \"caterpillar\").\n\t\t\t// Diving by the total number of tokens in the title normalizes the score and skews\n\t\t\t// the results towards shorter titles.\n\t\t\tconst exactMatchScore =\n\t\t\t\t( exactMatchingTokens.length / titleTokens.length ) * 10;\n\n\t\t\tconst subMatchScore = subMatchingTokens.length / titleTokens.length;\n\n\t\t\tscores[ result.id ] = exactMatchScore + subMatchScore;\n\t\t} else {\n\t\t\tscores[ result.id ] = 0;\n\t\t}\n\t}\n\n\treturn results.sort( ( a, b ) => scores[ b.id ] - scores[ a.id ] );\n}\n\n/**\n * Turns text into an array of tokens, with whitespace and punctuation removed.\n *\n * For example, `\"I'm having a ball.\"` becomes `[ \"im\", \"having\", \"a\", \"ball\" ]`.\n *\n * @param text\n */\nexport function tokenize( text: string ): string[] {\n\t// \\p{L} matches any kind of letter from any language.\n\t// \\p{N} matches any kind of numeric character.\n\treturn text.toLowerCase().match( /[\\p{L}\\p{N}]+/gu ) || [];\n}\n", "/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport {\n\taddQueryArgs,\n\tprependHTTP,\n\tisURL,\n\tgetProtocol,\n\tisValidProtocol,\n} from '@wordpress/url';\n\n/**\n * A simple in-memory cache for requests.\n * This avoids repeat HTTP requests which may be beneficial\n * for those wishing to preserve low-bandwidth.\n */\nconst CACHE = new Map();\n\n/**\n * @typedef WPRemoteUrlData\n *\n * @property {string} title contents of the remote URL's `<title>` tag.\n */\n\n/**\n * Fetches data about a remote URL.\n * eg: <title> tag, favicon...etc.\n *\n * @async\n * @param {string}  url     the URL to request details from.\n * @param {?Object} options any options to pass to the underlying fetch.\n * @example\n * ```js\n * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchUrlData = (\n * url\n * ) => fetchUrlData( url );\n * ```\n * @return {Promise< WPRemoteUrlData[] >} Remote URL data.\n */\nconst fetchUrlData = async ( url, options = {} ) => {\n\tconst endpoint = '/wp-block-editor/v1/url-details';\n\n\tconst args = {\n\t\turl: prependHTTP( url ),\n\t};\n\n\tif ( ! isURL( url ) ) {\n\t\treturn Promise.reject( `${ url } is not a valid URL.` );\n\t}\n\n\t// Test for \"http\" based URL as it is possible for valid\n\t// yet unusable URLs such as `tel:123456` to be passed.\n\tconst protocol = getProtocol( url );\n\n\tif (\n\t\t! protocol ||\n\t\t! isValidProtocol( protocol ) ||\n\t\t! protocol.startsWith( 'http' ) ||\n\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( url )\n\t) {\n\t\treturn Promise.reject(\n\t\t\t`${ url } does not have a valid protocol. URLs must be \"http\" based`\n\t\t);\n\t}\n\n\tif ( CACHE.has( url ) ) {\n\t\treturn CACHE.get( url );\n\t}\n\n\treturn apiFetch( {\n\t\tpath: addQueryArgs( endpoint, args ),\n\t\t...options,\n\t} ).then( ( res ) => {\n\t\tCACHE.set( url, res );\n\t\treturn res;\n\t} );\n};\n\nexport default fetchUrlData;\n", "export function deepCopyLocksTreePath( tree, path ) {\n\tconst newTree = { ...tree };\n\tlet currentNode = newTree;\n\tfor ( const branchName of path ) {\n\t\tcurrentNode.children = {\n\t\t\t...currentNode.children,\n\t\t\t[ branchName ]: {\n\t\t\t\tlocks: [],\n\t\t\t\tchildren: {},\n\t\t\t\t...currentNode.children[ branchName ],\n\t\t\t},\n\t\t};\n\t\tcurrentNode = currentNode.children[ branchName ];\n\t}\n\treturn newTree;\n}\n\nexport function getNode( tree, path ) {\n\tlet currentNode = tree;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\treturn null;\n\t\t}\n\t\tcurrentNode = nextNode;\n\t}\n\treturn currentNode;\n}\n\nexport function* iteratePath( tree, path ) {\n\tlet currentNode = tree;\n\tyield currentNode;\n\tfor ( const branchName of path ) {\n\t\tconst nextNode = currentNode.children[ branchName ];\n\t\tif ( ! nextNode ) {\n\t\t\tbreak;\n\t\t}\n\t\tyield nextNode;\n\t\tcurrentNode = nextNode;\n\t}\n}\n\nexport function* iterateDescendants( node ) {\n\tconst stack = Object.values( node.children );\n\twhile ( stack.length ) {\n\t\tconst childNode = stack.pop();\n\t\tyield childNode;\n\t\tstack.push( ...Object.values( childNode.children ) );\n\t}\n}\n\nexport function hasConflictingLock( { exclusive }, locks ) {\n\tif ( exclusive && locks.length ) {\n\t\treturn true;\n\t}\n\n\tif ( ! exclusive && locks.filter( ( lock ) => lock.exclusive ).length ) {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n", "/**\n * Internal dependencies\n */\nimport { getNode, deepCopyLocksTreePath } from './utils';\n\nconst DEFAULT_STATE = {\n\trequests: [],\n\ttree: {\n\t\tlocks: [],\n\t\tchildren: {},\n\t},\n};\n\n/**\n * Reducer returning locks.\n *\n * @param {Object} state  Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport default function locks( state = DEFAULT_STATE, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'ENQUEUE_LOCK_REQUEST': {\n\t\t\tconst { request } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: [ request, ...state.requests ],\n\t\t\t};\n\t\t}\n\t\tcase 'GRANT_LOCK_REQUEST': {\n\t\t\tconst { lock, request } = action;\n\t\t\tconst { store, path } = request;\n\t\t\tconst storePath = [ store, ...path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = [ ...node.locks, lock ];\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\trequests: state.requests.filter( ( r ) => r !== request ),\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t\tcase 'RELEASE_LOCK': {\n\t\t\tconst { lock } = action;\n\t\t\tconst storePath = [ lock.store, ...lock.path ];\n\n\t\t\tconst newTree = deepCopyLocksTreePath( state.tree, storePath );\n\t\t\tconst node = getNode( newTree, storePath );\n\t\t\tnode.locks = node.locks.filter( ( l ) => l !== lock );\n\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\ttree: newTree,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn state;\n}\n", "/**\n * Internal dependencies\n */\nimport {\n\titerateDescendants,\n\titeratePath,\n\thasConflictingLock,\n\tgetNode,\n} from './utils';\n\nexport function getPendingLockRequests( state ) {\n\treturn state.requests;\n}\n\nexport function isLockAvailable( state, store, path, { exclusive } ) {\n\tconst storePath = [ store, ...path ];\n\tconst locks = state.tree;\n\n\t// Validate all parents and the node itself\n\tfor ( const node of iteratePath( locks, storePath ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, node.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// iteratePath terminates early if path is unreachable, let's\n\t// re-fetch the node and check it exists in the tree.\n\tconst node = getNode( locks, storePath );\n\tif ( ! node ) {\n\t\treturn true;\n\t}\n\n\t// Validate all nested nodes\n\tfor ( const descendant of iterateDescendants( node ) ) {\n\t\tif ( hasConflictingLock( { exclusive }, descendant.locks ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n", "/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport { isLockAvailable, getPendingLockRequests } from './selectors';\n\nexport default function createLocks() {\n\tlet state = reducer( undefined, { type: '@@INIT' } );\n\n\tfunction processPendingLockRequests() {\n\t\tfor ( const request of getPendingLockRequests( state ) ) {\n\t\t\tconst { store, path, exclusive, notifyAcquired } = request;\n\t\t\tif ( isLockAvailable( state, store, path, { exclusive } ) ) {\n\t\t\t\tconst lock = { store, path, exclusive };\n\t\t\t\tstate = reducer( state, {\n\t\t\t\t\ttype: 'GRANT_LOCK_REQUEST',\n\t\t\t\t\tlock,\n\t\t\t\t\trequest,\n\t\t\t\t} );\n\t\t\t\tnotifyAcquired( lock );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction acquire( store, path, exclusive ) {\n\t\treturn new Promise( ( resolve ) => {\n\t\t\tstate = reducer( state, {\n\t\t\t\ttype: 'ENQUEUE_LOCK_REQUEST',\n\t\t\t\trequest: { store, path, exclusive, notifyAcquired: resolve },\n\t\t\t} );\n\t\t\tprocessPendingLockRequests();\n\t\t} );\n\t}\n\tfunction release( lock ) {\n\t\tstate = reducer( state, {\n\t\t\ttype: 'RELEASE_LOCK',\n\t\t\tlock,\n\t\t} );\n\t\tprocessPendingLockRequests();\n\t}\n\n\treturn { acquire, release };\n}\n", "/**\n * Internal dependencies\n */\nimport createLocks from './engine';\n\nexport default function createLocksActions() {\n\tconst locks = createLocks();\n\n\tfunction __unstableAcquireStoreLock( store, path, { exclusive } ) {\n\t\treturn () => locks.acquire( store, path, exclusive );\n\t}\n\n\tfunction __unstableReleaseStoreLock( lock ) {\n\t\treturn () => locks.release( lock );\n\t}\n\n\treturn { __unstableAcquireStoreLock, __unstableReleaseStoreLock };\n}\n", "/**\n * Internal dependencies\n */\nimport type { GetRecordsHttpQuery, State } from './selectors';\nimport type * as ET from './entity-types';\n\nexport type WPEntityTypes< C extends ET.Context = 'edit' > = {\n\tComment: ET.Comment< C >;\n\tGlobalStyles: ET.GlobalStylesRevision< C >;\n\tMedia: ET.Attachment< C >;\n\tMenu: ET.NavMenu< C >;\n\tMenuItem: ET.NavMenuItem< C >;\n\tMenuLocation: ET.MenuLocation< C >;\n\tPlugin: ET.Plugin< C >;\n\tPostType: ET.Type< C >;\n\tRevision: ET.PostRevision< C >;\n\tSidebar: ET.Sidebar< C >;\n\tSite: ET.Settings< C >;\n\tStatus: ET.PostStatusObject< C >;\n\tTaxonomy: ET.Taxonomy< C >;\n\tTerm: ET.Term< C >;\n\tTheme: ET.Theme< C >;\n\tUnstableBase: ET.UnstableBase< C >;\n\tUser: ET.User< C >;\n\tWidget: ET.Widget< C >;\n\tWidgetType: ET.WidgetType< C >;\n};\n\n/**\n * A simple utility that pluralizes a string.\n * Converts:\n * - \"post\" to \"posts\"\n * - \"taxonomy\" to \"taxonomies\"\n * - \"media\" to \"mediaItems\"\n * - \"status\" to \"statuses\"\n *\n * It does not pluralize \"GlobalStyles\" due to lack of clarity about it at time of writing.\n */\ntype PluralizeEntity< T extends string > = T extends 'GlobalStyles'\n\t? never\n\t: T extends 'Media'\n\t? 'MediaItems'\n\t: T extends 'Status'\n\t? 'Statuses'\n\t: T extends `${ infer U }y`\n\t? `${ U }ies`\n\t: `${ T }s`;\n\n/**\n * A simple utility that singularizes a string.\n *\n * Converts:\n * - \"posts\" to \"post\"\n * - \"taxonomies\" to \"taxonomy\"\n * - \"mediaItems\" to \"media\"\n * - \"statuses\" to \"status\"\n */\ntype SingularizeEntity< T extends string > = T extends 'MediaItems'\n\t? 'Media'\n\t: T extends 'Statuses'\n\t? 'Status'\n\t: T extends `${ infer U }ies`\n\t? `${ U }y`\n\t: T extends `${ infer U }s`\n\t? U\n\t: T;\n\nexport type SingularGetters = {\n\t[ Key in `get${ keyof WPEntityTypes }` ]: (\n\t\tstate: State,\n\t\tid: number | string,\n\t\tquery?: GetRecordsHttpQuery\n\t) => WPEntityTypes[ Key extends `get${ infer E }` ? E : never ] | undefined;\n};\n\nexport type PluralGetters = {\n\t[ Key in `get${ PluralizeEntity< keyof WPEntityTypes > }` ]: (\n\t\tstate: State,\n\t\tquery?: GetRecordsHttpQuery\n\t) => Array<\n\t\tWPEntityTypes[ Key extends `get${ infer E }`\n\t\t\t? SingularizeEntity< E >\n\t\t\t: never ]\n\t> | null;\n};\n\ntype ActionOptions = {\n\tthrowOnError?: boolean;\n};\n\ntype DeleteRecordsHttpQuery = Record< string, any >;\n\nexport type SaveActions = {\n\t[ Key in `save${ keyof WPEntityTypes }` ]: (\n\t\tdata: Partial<\n\t\t\tWPEntityTypes[ Key extends `save${ infer E }` ? E : never ]\n\t\t>,\n\t\toptions?: ActionOptions\n\t) => Promise< void >;\n};\n\nexport type DeleteActions = {\n\t[ Key in `delete${ keyof WPEntityTypes }` ]: (\n\t\tid: number | string,\n\t\tquery?: DeleteRecordsHttpQuery,\n\t\toptions?: ActionOptions\n\t) => Promise< void >;\n};\n\nexport let dynamicActions: SaveActions & DeleteActions;\n\nexport let dynamicSelectors: SingularGetters & PluralGetters;\n", "/**\n * WordPress dependencies\n */\nimport { useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { EntityContext } from './entity-context';\n\n/**\n * Context provider component for providing\n * an entity for a specific entity.\n *\n * @param {Object} props              The component's props.\n * @param {string} props.kind         The entity kind.\n * @param {string} props.type         The entity name.\n * @param {number} props.id           The entity ID.\n * @param {number} [props.revisionId] Optional revision ID. When set,\n *                                    `useEntityProp` reads from the\n *                                    revision record instead of the\n *                                    current entity.\n * @param {*}      props.children     The children to wrap.\n *\n * @return {Object} The provided children, wrapped with\n *                   the entity's context provider.\n */\nexport default function EntityProvider( {\n\tkind,\n\ttype: name,\n\tid,\n\trevisionId,\n\tchildren,\n} ) {\n\tconst parent = useContext( EntityContext );\n\tconst childContext = useMemo(\n\t\t() => ( {\n\t\t\t...parent,\n\t\t\t...( kind && {\n\t\t\t\t[ kind ]: {\n\t\t\t\t\t...parent?.[ kind ],\n\t\t\t\t\t[ name ]: id,\n\t\t\t\t},\n\t\t\t} ),\n\t\t\t...( revisionId !== undefined && { revisionId } ),\n\t\t} ),\n\t\t[ parent, kind, name, id, revisionId ]\n\t);\n\treturn (\n\t\t<EntityContext.Provider value={ childContext }>\n\t\t\t{ children }\n\t\t</EntityContext.Provider>\n\t);\n}\n", "/**\n * WordPress dependencies\n */\nimport { createContext } from '@wordpress/element';\n\nexport const EntityContext = createContext( {} );\nEntityContext.displayName = 'EntityContext';\n", "/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useQuerySelect from './use-query-select';\nimport { store as coreStore } from '../';\nimport type { Status } from './constants';\n\nexport interface EntityRecordResolution< RecordType > {\n\t/** The requested entity record */\n\trecord: RecordType | null;\n\n\t/** The edited entity record */\n\teditedRecord: Partial< RecordType >;\n\n\t/** The edits to the edited entity record */\n\tedits: Partial< RecordType >;\n\n\t/** Apply local (in-browser) edits to the edited entity record */\n\tedit: ( diff: Partial< RecordType > ) => void;\n\n\t/** Persist the edits to the server */\n\tsave: () => Promise< void >;\n\n\t/**\n\t * Is the record still being resolved?\n\t */\n\tisResolving: boolean;\n\n\t/**\n\t * Does the record have any local edits?\n\t */\n\thasEdits: boolean;\n\n\t/**\n\t * Is the record resolved by now?\n\t */\n\thasResolved: boolean;\n\n\t/** Resolution status */\n\tstatus: Status;\n}\n\nexport interface Options {\n\t/**\n\t * Whether to run the query or short-circuit and return null.\n\t *\n\t * @default true\n\t */\n\tenabled: boolean;\n}\n\nconst EMPTY_OBJECT = {};\n\n/**\n * Resolves the specified entity record.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param    kind     Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.\n * @param    name     Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.\n * @param    recordId ID of the requested entity record.\n * @param    options  Optional hook options.\n * @example\n * ```js\n * import { useEntityRecord } from '@wordpress/core-data';\n *\n * function PageTitleDisplay( { id } ) {\n *   const { record, isResolving } = useEntityRecord( 'postType', 'page', id );\n *\n *   if ( isResolving ) {\n *     return 'Loading...';\n *   }\n *\n *   return record.title;\n * }\n *\n * // Rendered in the application:\n * // <PageTitleDisplay id={ 1 } />\n * ```\n *\n * In the above example, when `PageTitleDisplay` is rendered into an\n * application, the page and the resolution details will be retrieved from\n * the store state using `getEntityRecord()`, or resolved if missing.\n *\n * @example\n * ```js\n * import { useCallback } from 'react';\n * import { useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * import { TextControl } from '@wordpress/components';\n * import { store as noticeStore } from '@wordpress/notices';\n * import { useEntityRecord } from '@wordpress/core-data';\n *\n * function PageRenameForm( { id } ) {\n * \tconst page = useEntityRecord( 'postType', 'page', id );\n * \tconst { createSuccessNotice, createErrorNotice } =\n * \t\tuseDispatch( noticeStore );\n *\n * \tconst setTitle = useCallback( ( title ) => {\n * \t\tpage.edit( { title } );\n * \t}, [ page.edit ] );\n *\n * \tif ( page.isResolving ) {\n * \t\treturn 'Loading...';\n * \t}\n *\n * \tasync function onRename( event ) {\n * \t\tevent.preventDefault();\n * \t\ttry {\n * \t\t\tawait page.save();\n * \t\t\tcreateSuccessNotice( __( 'Page renamed.' ), {\n * \t\t\t\ttype: 'snackbar',\n * \t\t\t} );\n * \t\t} catch ( error ) {\n * \t\t\tcreateErrorNotice( error.message, { type: 'snackbar' } );\n * \t\t}\n * \t}\n *\n * \treturn (\n * \t\t<form onSubmit={ onRename }>\n * \t\t\t<TextControl\n *\t\t\t\t__next40pxDefaultSize\n * \t\t\t\tlabel={ __( 'Name' ) }\n * \t\t\t\tvalue={ page.editedRecord.title }\n * \t\t\t\tonChange={ setTitle }\n * \t\t\t/>\n * \t\t\t<button type=\"submit\">{ __( 'Save' ) }</button>\n * \t\t</form>\n * \t);\n * }\n *\n * // Rendered in the application:\n * // <PageRenameForm id={ 1 } />\n * ```\n *\n * In the above example, updating and saving the page title is handled\n * via the `edit()` and `save()` mutation helpers provided by\n * `useEntityRecord()`;\n *\n * @return Entity record data.\n * @template RecordType\n */\nexport default function useEntityRecord< RecordType >(\n\tkind: string,\n\tname: string,\n\trecordId: string | number,\n\toptions: Options = { enabled: true }\n): EntityRecordResolution< RecordType > {\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\tconst mutations = useMemo(\n\t\t() => ( {\n\t\t\tedit: ( record, editOptions: any = {} ) =>\n\t\t\t\teditEntityRecord( kind, name, recordId, record, editOptions ),\n\t\t\tsave: ( saveOptions: any = {} ) =>\n\t\t\t\tsaveEditedEntityRecord( kind, name, recordId, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t...saveOptions,\n\t\t\t\t} ),\n\t\t} ),\n\t\t[ editEntityRecord, kind, name, recordId, saveEditedEntityRecord ]\n\t);\n\n\tconst { editedRecord, hasEdits, edits } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! options.enabled ) {\n\t\t\t\treturn {\n\t\t\t\t\teditedRecord: EMPTY_OBJECT,\n\t\t\t\t\thasEdits: false,\n\t\t\t\t\tedits: EMPTY_OBJECT,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\teditedRecord: select( coreStore ).getEditedEntityRecord(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t),\n\t\t\t\thasEdits: select( coreStore ).hasEditsForEntityRecord(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t),\n\t\t\t\tedits: select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\trecordId\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ kind, name, recordId, options.enabled ]\n\t);\n\n\tconst { data: record, ...querySelectRest } = useQuerySelect(\n\t\t( query ) => {\n\t\t\tif ( ! options.enabled ) {\n\t\t\t\treturn {\n\t\t\t\t\tdata: null,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn query( coreStore ).getEntityRecord( kind, name, recordId );\n\t\t},\n\t\t[ kind, name, recordId, options.enabled ]\n\t);\n\n\treturn {\n\t\trecord,\n\t\teditedRecord,\n\t\thasEdits,\n\t\tedits,\n\t\t...querySelectRest,\n\t\t...mutations,\n\t};\n}\n\nexport function __experimentalUseEntityRecord(\n\tkind: string,\n\tname: string,\n\trecordId: any,\n\toptions: any\n) {\n\tdeprecated( `wp.data.__experimentalUseEntityRecord`, {\n\t\talternative: 'wp.data.useEntityRecord',\n\t\tsince: '6.1',\n\t} );\n\treturn useEntityRecord( kind, name, recordId, options );\n}\n", "/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport memoize from './memoize';\nimport { Status } from './constants';\n\nexport const META_SELECTORS = [\n\t'getIsResolving',\n\t'hasStartedResolution',\n\t'hasFinishedResolution',\n\t'isResolving',\n\t'getCachedResolvers',\n];\n\ninterface QuerySelectResponse< Data > {\n\t/** the requested selector return value */\n\tdata: Data;\n\n\t/** is the record still being resolved? Via the `isResolving` meta-selector */\n\tisResolving: boolean;\n\n\t/** was the resolution started? Via the `hasStartedResolution` meta-selector */\n\thasStarted: boolean;\n\n\t/** has the resolution finished? Via the `hasFinishedResolution` meta-selector. */\n\thasResolved: boolean;\n}\n\n/**\n * Like useSelect, but the selectors return objects containing\n * both the original data AND the resolution info.\n *\n * @since 6.1.0 Introduced in WordPress core.\n * @private\n *\n * @param {Function} mapQuerySelect see useSelect\n * @param {Array}    deps           see useSelect\n *\n * @example\n * ```js\n * import { useQuerySelect } from '@wordpress/data';\n * import { store as coreDataStore } from '@wordpress/core-data';\n *\n * function PageTitleDisplay( { id } ) {\n *   const { data: page, isResolving } = useQuerySelect( ( query ) => {\n *     return query( coreDataStore ).getEntityRecord( 'postType', 'page', id )\n *   }, [ id ] );\n *\n *   if ( isResolving ) {\n *     return 'Loading...';\n *   }\n *\n *   return page.title;\n * }\n *\n * // Rendered in the application:\n * // <PageTitleDisplay id={ 10 } />\n * ```\n *\n * In the above example, when `PageTitleDisplay` is rendered into an\n * application, the page and the resolution details will be retrieved from\n * the store state using the `mapSelect` callback on `useQuerySelect`.\n *\n * If the id prop changes then any page in the state for that id is\n * retrieved. If the id prop doesn't change and other props are passed in\n * that do change, the title will not change because the dependency is just\n * the id.\n * @see useSelect\n *\n * @return {QuerySelectResponse} Queried data.\n */\nexport default function useQuerySelect( mapQuerySelect, deps ) {\n\treturn useSelect( ( select, registry ) => {\n\t\tconst resolve = ( store ) => enrichSelectors( select( store ) );\n\t\treturn mapQuerySelect( resolve, registry );\n\t}, deps );\n}\n\ninterface EnrichedSelectors {\n\t< Selectors extends Record< string, ( ...args: any[] ) => any > >(\n\t\tselectors: Selectors\n\t): {\n\t\t[ Selector in keyof Selectors ]: (\n\t\t\t...args: Parameters< Selectors[ Selector ] >\n\t\t) => QuerySelectResponse< ReturnType< Selectors[ Selector ] > >;\n\t};\n}\n\n/**\n * Transform simple selectors into ones that return an object with the\n * original return value AND the resolution info.\n *\n * @param {Object} selectors Selectors to enrich\n * @return {EnrichedSelectors} Enriched selectors\n */\nconst enrichSelectors = memoize( ( ( selectors ) => {\n\tconst resolvers = {};\n\tfor ( const selectorName in selectors ) {\n\t\tif ( META_SELECTORS.includes( selectorName ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\tObject.defineProperty( resolvers, selectorName, {\n\t\t\tget:\n\t\t\t\t() =>\n\t\t\t\t( ...args: unknown[] ) => {\n\t\t\t\t\tconst data = selectors[ selectorName ]( ...args );\n\t\t\t\t\tconst resolutionStatus = selectors.getResolutionState(\n\t\t\t\t\t\tselectorName,\n\t\t\t\t\t\targs\n\t\t\t\t\t)?.status;\n\n\t\t\t\t\tlet status;\n\t\t\t\t\tswitch ( resolutionStatus ) {\n\t\t\t\t\t\tcase 'resolving':\n\t\t\t\t\t\t\tstatus = Status.Resolving;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'finished':\n\t\t\t\t\t\t\tstatus = Status.Success;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'error':\n\t\t\t\t\t\t\tstatus = Status.Error;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase undefined:\n\t\t\t\t\t\t\tstatus = Status.Idle;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata,\n\t\t\t\t\t\tstatus,\n\t\t\t\t\t\tisResolving: status === Status.Resolving,\n\t\t\t\t\t\thasStarted: status !== Status.Idle,\n\t\t\t\t\t\thasResolved:\n\t\t\t\t\t\t\tstatus === Status.Success ||\n\t\t\t\t\t\t\tstatus === Status.Error,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t} );\n\t}\n\treturn resolvers;\n} ) as EnrichedSelectors );\n", "/**\n * Memize options object.\n *\n * @typedef MemizeOptions\n *\n * @property {number} [maxSize] Maximum size of the cache.\n */\n\n/**\n * Internal cache entry.\n *\n * @typedef MemizeCacheNode\n *\n * @property {?MemizeCacheNode|undefined} [prev] Previous node.\n * @property {?MemizeCacheNode|undefined} [next] Next node.\n * @property {Array<*>}                   args   Function arguments for cache\n *                                               entry.\n * @property {*}                          val    Function result.\n */\n\n/**\n * Properties of the enhanced function for controlling cache.\n *\n * @typedef MemizeMemoizedFunction\n *\n * @property {()=>void} clear Clear the cache.\n */\n\n/**\n * Accepts a function to be memoized, and returns a new memoized function, with\n * optional options.\n *\n * @template {(...args: any[]) => any} F\n *\n * @param {F}             fn        Function to memoize.\n * @param {MemizeOptions} [options] Options object.\n *\n * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.\n */\nfunction memize(fn, options) {\n\tvar size = 0;\n\n\t/** @type {?MemizeCacheNode|undefined} */\n\tvar head;\n\n\t/** @type {?MemizeCacheNode|undefined} */\n\tvar tail;\n\n\toptions = options || {};\n\n\tfunction memoized(/* ...args */) {\n\t\tvar node = head,\n\t\t\tlen = arguments.length,\n\t\t\targs,\n\t\t\ti;\n\n\t\tsearchCache: while (node) {\n\t\t\t// Perform a shallow equality test to confirm that whether the node\n\t\t\t// under test is a candidate for the arguments passed. Two arrays\n\t\t\t// are shallowly equal if their length matches and each entry is\n\t\t\t// strictly equal between the two sets. Avoid abstracting to a\n\t\t\t// function which could incur an arguments leaking deoptimization.\n\n\t\t\t// Check whether node arguments match arguments length\n\t\t\tif (node.args.length !== arguments.length) {\n\t\t\t\tnode = node.next;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Check whether node arguments match arguments values\n\t\t\tfor (i = 0; i < len; i++) {\n\t\t\t\tif (node.args[i] !== arguments[i]) {\n\t\t\t\t\tnode = node.next;\n\t\t\t\t\tcontinue searchCache;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// At this point we can assume we've found a match\n\n\t\t\t// Surface matched node to head if not already\n\t\t\tif (node !== head) {\n\t\t\t\t// As tail, shift to previous. Must only shift if not also\n\t\t\t\t// head, since if both head and tail, there is no previous.\n\t\t\t\tif (node === tail) {\n\t\t\t\t\ttail = node.prev;\n\t\t\t\t}\n\n\t\t\t\t// Adjust siblings to point to each other. If node was tail,\n\t\t\t\t// this also handles new tail's empty `next` assignment.\n\t\t\t\t/** @type {MemizeCacheNode} */ (node.prev).next = node.next;\n\t\t\t\tif (node.next) {\n\t\t\t\t\tnode.next.prev = node.prev;\n\t\t\t\t}\n\n\t\t\t\tnode.next = head;\n\t\t\t\tnode.prev = null;\n\t\t\t\t/** @type {MemizeCacheNode} */ (head).prev = node;\n\t\t\t\thead = node;\n\t\t\t}\n\n\t\t\t// Return immediately\n\t\t\treturn node.val;\n\t\t}\n\n\t\t// No cached value found. Continue to insertion phase:\n\n\t\t// Create a copy of arguments (avoid leaking deoptimization)\n\t\targs = new Array(len);\n\t\tfor (i = 0; i < len; i++) {\n\t\t\targs[i] = arguments[i];\n\t\t}\n\n\t\tnode = {\n\t\t\targs: args,\n\n\t\t\t// Generate the result from original function\n\t\t\tval: fn.apply(null, args),\n\t\t};\n\n\t\t// Don't need to check whether node is already head, since it would\n\t\t// have been returned above already if it was\n\n\t\t// Shift existing head down list\n\t\tif (head) {\n\t\t\thead.prev = node;\n\t\t\tnode.next = head;\n\t\t} else {\n\t\t\t// If no head, follows that there's no tail (at initial or reset)\n\t\t\ttail = node;\n\t\t}\n\n\t\t// Trim tail if we're reached max size and are pending cache insertion\n\t\tif (size === /** @type {MemizeOptions} */ (options).maxSize) {\n\t\t\ttail = /** @type {MemizeCacheNode} */ (tail).prev;\n\t\t\t/** @type {MemizeCacheNode} */ (tail).next = null;\n\t\t} else {\n\t\t\tsize++;\n\t\t}\n\n\t\thead = node;\n\n\t\treturn node.val;\n\t}\n\n\tmemoized.clear = function () {\n\t\thead = null;\n\t\ttail = null;\n\t\tsize = 0;\n\t};\n\n\t// Ignore reason: There's not a clear solution to create an intersection of\n\t// the function with additional properties, where the goal is to retain the\n\t// function signature of the incoming argument and add control properties\n\t// on the return value.\n\n\t// @ts-ignore\n\treturn memoized;\n}\n\nexport { memize as default };\n", "/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n// re-export due to restrictive esModuleInterop setting\nexport default memoize;\n", "export const enum Status {\n\tIdle = 'IDLE',\n\tResolving = 'RESOLVING',\n\tError = 'ERROR',\n\tSuccess = 'SUCCESS',\n}\n", "/**\n * WordPress dependencies\n */\nimport { addQueryArgs } from '@wordpress/url';\nimport deprecated from '@wordpress/deprecated';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useQuerySelect from './use-query-select';\nimport { store as coreStore } from '../';\nimport type { Options } from './use-entity-record';\nimport type { Status } from './constants';\nimport { unlock } from '../lock-unlock';\nimport { getNormalizedCommaSeparable } from '../utils';\n\ninterface EntityRecordsResolution< RecordType > {\n\t/** The requested entity records */\n\trecords: RecordType[] | null;\n\n\t/**\n\t * Is the record still being resolved?\n\t */\n\tisResolving: boolean;\n\n\t/**\n\t * Is the record resolved by now?\n\t */\n\thasResolved: boolean;\n\n\t/** Resolution status */\n\tstatus: Status;\n\n\t/**\n\t * The total number of available items (if not paginated).\n\t */\n\ttotalItems: number | null;\n\n\t/**\n\t * The total number of pages.\n\t */\n\ttotalPages: number | null;\n}\n\nexport type WithPermissions< RecordType > = RecordType & {\n\tpermissions: { delete: boolean; update: boolean };\n};\n\ninterface EntityRecordsWithPermissionsResolution< RecordType >\n\textends Omit< EntityRecordsResolution< RecordType >, 'records' > {\n\t/** The requested entity records with permissions */\n\trecords: WithPermissions< RecordType >[] | null;\n}\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Resolves the specified entity records.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param    kind      Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.\n * @param    name      Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.\n * @param    queryArgs Optional HTTP query description for how to fetch the data, passed to the requested API endpoint.\n * @param    options   Optional hook options.\n * @example\n * ```js\n * import { useEntityRecords } from '@wordpress/core-data';\n *\n * function PageTitlesList() {\n *   const { records, isResolving } = useEntityRecords( 'postType', 'page' );\n *\n *   if ( isResolving ) {\n *     return 'Loading...';\n *   }\n *\n *   return (\n *     <ul>\n *       {records.map(( page ) => (\n *         <li>{ page.title }</li>\n *       ))}\n *     </ul>\n *   );\n * }\n *\n * // Rendered in the application:\n * // <PageTitlesList />\n * ```\n *\n * In the above example, when `PageTitlesList` is rendered into an\n * application, the list of records and the resolution details will be retrieved from\n * the store state using `getEntityRecords()`, or resolved if missing.\n *\n * @return Entity records data.\n * @template RecordType\n */\nexport default function useEntityRecords< RecordType >(\n\tkind: string,\n\tname: string,\n\tqueryArgs: Record< string, unknown > = {},\n\toptions: Options = { enabled: true }\n): EntityRecordsResolution< RecordType > {\n\t// Serialize queryArgs to a string that can be safely used as a React dep.\n\t// We can't just pass queryArgs as one of the deps, because if it is passed\n\t// as an object literal, then it will be a different object on each call even\n\t// if the values remain the same.\n\tconst queryAsString = addQueryArgs( '', queryArgs );\n\n\tconst { data: records, ...rest } = useQuerySelect(\n\t\t( query ) => {\n\t\t\tif ( ! options.enabled ) {\n\t\t\t\treturn {\n\t\t\t\t\t// Avoiding returning a new reference on every execution.\n\t\t\t\t\tdata: EMPTY_ARRAY,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn query( coreStore ).getEntityRecords( kind, name, queryArgs );\n\t\t},\n\t\t[ kind, name, queryAsString, options.enabled ]\n\t);\n\n\tconst { totalItems, totalPages } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! options.enabled ) {\n\t\t\t\treturn {\n\t\t\t\t\ttotalItems: null,\n\t\t\t\t\ttotalPages: null,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttotalItems: select( coreStore ).getEntityRecordsTotalItems(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tqueryArgs\n\t\t\t\t),\n\t\t\t\ttotalPages: select( coreStore ).getEntityRecordsTotalPages(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tqueryArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ kind, name, queryAsString, options.enabled ]\n\t);\n\n\treturn {\n\t\trecords,\n\t\ttotalItems,\n\t\ttotalPages,\n\t\t...rest,\n\t};\n}\n\nexport function __experimentalUseEntityRecords(\n\tkind: string,\n\tname: string,\n\tqueryArgs: any,\n\toptions: any\n) {\n\tdeprecated( `wp.data.__experimentalUseEntityRecords`, {\n\t\talternative: 'wp.data.useEntityRecords',\n\t\tsince: '6.1',\n\t} );\n\treturn useEntityRecords( kind, name, queryArgs, options );\n}\n\nexport function useEntityRecordsWithPermissions< RecordType >(\n\tkind: string,\n\tname: string,\n\tqueryArgs: Record< string, unknown > = {},\n\toptions: Options = { enabled: true }\n): EntityRecordsWithPermissionsResolution< RecordType > {\n\tconst entityConfig = useSelect(\n\t\t( select ) => select( coreStore ).getEntityConfig( kind, name ),\n\t\t[ kind, name ]\n\t);\n\tconst { records: data, ...ret } = useEntityRecords(\n\t\tkind,\n\t\tname,\n\t\t{\n\t\t\t...queryArgs,\n\t\t\t// If _fields is provided, we need to include _links in the request for permission caching to work.\n\t\t\t...( queryArgs._fields\n\t\t\t\t? {\n\t\t\t\t\t\t_fields: [\n\t\t\t\t\t\t\t...new Set( [\n\t\t\t\t\t\t\t\t...( getNormalizedCommaSeparable(\n\t\t\t\t\t\t\t\t\tqueryArgs._fields\n\t\t\t\t\t\t\t\t) || [] ),\n\t\t\t\t\t\t\t\t'_links',\n\t\t\t\t\t\t\t] ),\n\t\t\t\t\t\t].join(),\n\t\t\t\t  }\n\t\t\t\t: {} ),\n\t\t},\n\t\toptions\n\t);\n\tconst ids = useMemo(\n\t\t() =>\n\t\t\tdata?.map(\n\t\t\t\t// @ts-ignore\n\t\t\t\t( record: RecordType ) => record[ entityConfig?.key ?? 'id' ]\n\t\t\t) ?? [],\n\t\t[ data, entityConfig?.key ]\n\t);\n\n\tconst permissions = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecordsPermissions } = unlock(\n\t\t\t\tselect( coreStore )\n\t\t\t);\n\t\t\treturn getEntityRecordsPermissions( kind, name, ids );\n\t\t},\n\t\t[ ids, kind, name ]\n\t);\n\n\tconst dataWithPermissions = useMemo(\n\t\t() =>\n\t\t\tdata?.map( ( record, index ) => ( {\n\t\t\t\t// @ts-ignore\n\t\t\t\t...record,\n\t\t\t\tpermissions: permissions[ index ],\n\t\t\t} ) ) ?? [],\n\t\t[ data, permissions ]\n\t);\n\n\treturn { records: dataWithPermissions, ...ret };\n}\n", "/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport { store as coreStore } from '../';\nimport { Status } from './constants';\nimport useQuerySelect from './use-query-select';\n\ninterface GlobalResourcePermissionsResolution {\n\t/** Can the current user create new resources of this type? */\n\tcanCreate: boolean;\n}\ninterface SpecificResourcePermissionsResolution {\n\t/** Can the current user update resources of this type? */\n\tcanUpdate: boolean;\n\t/** Can the current user delete resources of this type? */\n\tcanDelete: boolean;\n}\ninterface ResolutionDetails {\n\t/** Resolution status */\n\tstatus: Status;\n\t/**\n\t * Is the data still being resolved?\n\t */\n\tisResolving: boolean;\n}\n\n/**\n * Is the data resolved by now?\n */\ntype HasResolved = boolean;\n\ntype ResourcePermissionsResolution< IdType > = [\n\tHasResolved,\n\tResolutionDetails &\n\t\tGlobalResourcePermissionsResolution &\n\t\t( IdType extends void ? SpecificResourcePermissionsResolution : {} ),\n];\n\ntype EntityResource = { kind: string; name: string; id?: string | number };\n\nfunction useResourcePermissions< IdType = void >(\n\tresource: string,\n\tid?: IdType\n): ResourcePermissionsResolution< IdType >;\n\nfunction useResourcePermissions< IdType = void >(\n\tresource: EntityResource,\n\tid?: never\n): ResourcePermissionsResolution< IdType >;\n\n/**\n * Resolves resource permissions.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param    resource Entity resource to check. Accepts entity object `{ kind: 'postType', name: 'attachment', id: 1 }`\n *                    or REST base as a string - `media`.\n * @param    id       Optional ID of the resource to check, e.g. 10. Note: This argument is discouraged\n *                    when using an entity object as a resource to check permissions and will be ignored.\n *\n * @example\n * ```js\n * import { useResourcePermissions } from '@wordpress/core-data';\n *\n * function PagesList() {\n *   const { canCreate, isResolving } = useResourcePermissions( { kind: 'postType', name: 'page' } );\n *\n *   if ( isResolving ) {\n *     return 'Loading ...';\n *   }\n *\n *   return (\n *     <div>\n *       {canCreate ? (<button>+ Create a new page</button>) : false}\n *       // ...\n *     </div>\n *   );\n * }\n *\n * // Rendered in the application:\n * // <PagesList />\n * ```\n *\n * @example\n * ```js\n * import { useResourcePermissions } from '@wordpress/core-data';\n *\n * function Page({ pageId }) {\n *   const {\n *     canCreate,\n *     canUpdate,\n *     canDelete,\n *     isResolving\n *   } = useResourcePermissions( { kind: 'postType', name: 'page', id: pageId } );\n *\n *   if ( isResolving ) {\n *     return 'Loading ...';\n *   }\n *\n *   return (\n *     <div>\n *       {canCreate ? (<button>+ Create a new page</button>) : false}\n *       {canUpdate ? (<button>Edit page</button>) : false}\n *       {canDelete ? (<button>Delete page</button>) : false}\n *       // ...\n *     </div>\n *   );\n * }\n *\n * // Rendered in the application:\n * // <Page pageId={ 15 } />\n * ```\n *\n * In the above example, when `PagesList` is rendered into an\n * application, the appropriate permissions and the resolution details will be retrieved from\n * the store state using `canUser()`, or resolved if missing.\n *\n * @return Entity records data.\n * @template IdType\n */\nfunction useResourcePermissions< IdType = void >(\n\tresource: string | EntityResource,\n\tid?: IdType\n): ResourcePermissionsResolution< IdType > {\n\t// Serialize `resource` to a string that can be safely used as a React dep.\n\t// We can't just pass `resource` as one of the deps, because if it is passed\n\t// as an object literal, then it will be a different object on each call even\n\t// if the values remain the same.\n\tconst isEntity = typeof resource === 'object';\n\tconst resourceAsString = isEntity ? JSON.stringify( resource ) : resource;\n\n\tif ( isEntity && typeof id !== 'undefined' ) {\n\t\twarning(\n\t\t\t`When 'resource' is an entity object, passing 'id' as a separate argument isn't supported.`\n\t\t);\n\t}\n\n\treturn useQuerySelect(\n\t\t( resolve ) => {\n\t\t\tconst hasId = isEntity ? !! resource.id : !! id;\n\t\t\tconst { canUser } = resolve( coreStore );\n\t\t\tconst create = canUser(\n\t\t\t\t'create',\n\t\t\t\tisEntity\n\t\t\t\t\t? { kind: resource.kind, name: resource.name }\n\t\t\t\t\t: resource\n\t\t\t);\n\n\t\t\tif ( ! hasId ) {\n\t\t\t\tconst read = canUser( 'read', resource );\n\n\t\t\t\tconst isResolving = create.isResolving || read.isResolving;\n\t\t\t\tconst hasResolved = create.hasResolved && read.hasResolved;\n\t\t\t\tlet status = Status.Idle;\n\t\t\t\tif ( isResolving ) {\n\t\t\t\t\tstatus = Status.Resolving;\n\t\t\t\t} else if ( hasResolved ) {\n\t\t\t\t\tstatus = Status.Success;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tstatus,\n\t\t\t\t\tisResolving,\n\t\t\t\t\thasResolved,\n\t\t\t\t\tcanCreate: create.hasResolved && create.data,\n\t\t\t\t\tcanRead: read.hasResolved && read.data,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst read = canUser( 'read', resource, id );\n\t\t\tconst update = canUser( 'update', resource, id );\n\t\t\tconst _delete = canUser( 'delete', resource, id );\n\t\t\tconst isResolving =\n\t\t\t\tread.isResolving ||\n\t\t\t\tcreate.isResolving ||\n\t\t\t\tupdate.isResolving ||\n\t\t\t\t_delete.isResolving;\n\t\t\tconst hasResolved =\n\t\t\t\tread.hasResolved &&\n\t\t\t\tcreate.hasResolved &&\n\t\t\t\tupdate.hasResolved &&\n\t\t\t\t_delete.hasResolved;\n\n\t\t\tlet status = Status.Idle;\n\t\t\tif ( isResolving ) {\n\t\t\t\tstatus = Status.Resolving;\n\t\t\t} else if ( hasResolved ) {\n\t\t\t\tstatus = Status.Success;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstatus,\n\t\t\t\tisResolving,\n\t\t\t\thasResolved,\n\t\t\t\tcanRead: hasResolved && read.data,\n\t\t\t\tcanCreate: hasResolved && create.data,\n\t\t\t\tcanUpdate: hasResolved && update.data,\n\t\t\t\tcanDelete: hasResolved && _delete.data,\n\t\t\t};\n\t\t},\n\t\t[ resourceAsString, id ]\n\t);\n}\n\nexport default useResourcePermissions;\n\nexport function __experimentalUseResourcePermissions(\n\tresource: string,\n\tid?: unknown\n) {\n\tdeprecated( `wp.data.__experimentalUseResourcePermissions`, {\n\t\talternative: 'wp.data.useResourcePermissions',\n\t\tsince: '6.1',\n\t} );\n\treturn useResourcePermissions( resource, id );\n}\n", "/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from '../name';\nimport useEntityId from './use-entity-id';\nimport { updateFootnotesFromMeta } from '../footnotes';\n\nconst EMPTY_ARRAY = [];\nconst parsedBlocksCache = new Map();\n\n/**\n * Hook that returns block content getters and setters for\n * the nearest provided entity of the specified type.\n *\n * The return value has the shape `[ blocks, onInput, onChange ]`.\n * `onInput` is for block changes that don't create undo levels\n * or dirty the post, non-persistent changes, and `onChange` is for\n * persistent changes. They map directly to the props of a\n * `BlockEditorProvider` and are intended to be used with it,\n * or similar components or hooks.\n *\n * @param {string} kind         The entity kind.\n * @param {string} name         The entity name.\n * @param {Object} options\n * @param {string} [options.id] An entity ID to use instead of the context-provided one.\n *\n * @return {[unknown[], Function, Function]} The block array and setters.\n */\nexport default function useEntityBlockEditor( kind, name, { id: _id } = {} ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst { content, editedBlocks, meta } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst { getEditedEntityRecord } = select( STORE_NAME );\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn {\n\t\t\t\teditedBlocks: editedRecord.blocks,\n\t\t\t\tcontent: editedRecord.content,\n\t\t\t\tmeta: editedRecord.meta,\n\t\t\t};\n\t\t},\n\t\t[ kind, name, id ]\n\t);\n\tconst { __unstableCreateUndoLevel, editEntityRecord } =\n\t\tuseDispatch( STORE_NAME );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( ! id ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( editedBlocks ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\tif ( ! content || typeof content !== 'string' ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\n\t\t// Cache parsed blocks by entity identity. Store the content\n\t\t// alongside the blocks so we can validate it hasn't changed.\n\t\tconst cacheKey = `${ kind }:${ name }:${ id }`;\n\t\tconst cached = parsedBlocksCache.get( cacheKey );\n\t\tlet _blocks;\n\n\t\tif ( cached && cached.content === content ) {\n\t\t\t_blocks = cached.blocks;\n\t\t} else {\n\t\t\t_blocks = parse( content );\n\t\t\tparsedBlocksCache.set( cacheKey, { content, blocks: _blocks } );\n\t\t}\n\n\t\treturn _blocks;\n\t}, [ kind, name, id, editedBlocks, content ] );\n\n\tconst onChange = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst noChange = blocks === newBlocks;\n\t\t\tif ( noChange ) {\n\t\t\t\treturn __unstableCreateUndoLevel( kind, name, id );\n\t\t\t}\n\t\t\tconst { selection, ...rest } = options;\n\n\t\t\t// We create a new function here on every persistent edit\n\t\t\t// to make sure the edit makes the post dirty and creates\n\t\t\t// a new undo level.\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t...updateFootnotesFromMeta( newBlocks, meta ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: false,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tkind,\n\t\t\tname,\n\t\t\tid,\n\t\t\tblocks,\n\t\t\tmeta,\n\t\t\t__unstableCreateUndoLevel,\n\t\t\teditEntityRecord,\n\t\t]\n\t);\n\n\tconst onInput = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst { selection, ...rest } = options;\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\t...updateFootnotesFromMeta( newBlocks, meta ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: true,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[ kind, name, id, meta, editEntityRecord ]\n\t);\n\n\treturn [ blocks, onInput, onChange ];\n}\n", "/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { EntityContext } from '../entity-context';\n\n/**\n * Hook that returns the ID for the nearest\n * provided entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n */\nexport default function useEntityId( kind, name ) {\n\tconst context = useContext( EntityContext );\n\treturn context?.[ kind ]?.[ name ];\n}\n", "/**\n * WordPress dependencies\n */\nimport { RichTextData, create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getFootnotesOrder from './get-footnotes-order';\n\nlet oldFootnotes = {};\n\nexport function updateFootnotesFromMeta( blocks, meta ) {\n\tconst output = { blocks };\n\tif ( ! meta ) {\n\t\treturn output;\n\t}\n\n\t// If meta.footnotes is empty, it means the meta is not registered.\n\tif ( meta.footnotes === undefined ) {\n\t\treturn output;\n\t}\n\n\tconst newOrder = getFootnotesOrder( blocks );\n\n\tconst footnotes = meta.footnotes ? JSON.parse( meta.footnotes ) : [];\n\tconst currentOrder = footnotes.map( ( fn ) => fn.id );\n\n\tif ( currentOrder.join( '' ) === newOrder.join( '' ) ) {\n\t\treturn output;\n\t}\n\n\tconst newFootnotes = newOrder.map(\n\t\t( fnId ) =>\n\t\t\tfootnotes.find( ( fn ) => fn.id === fnId ) ||\n\t\t\toldFootnotes[ fnId ] || {\n\t\t\t\tid: fnId,\n\t\t\t\tcontent: '',\n\t\t\t}\n\t);\n\n\tfunction updateAttributes( attributes ) {\n\t\t// Only attempt to update attributes, if attributes is an object.\n\t\tif (\n\t\t\t! attributes ||\n\t\t\tArray.isArray( attributes ) ||\n\t\t\ttypeof attributes !== 'object'\n\t\t) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes = { ...attributes };\n\n\t\tfor ( const key in attributes ) {\n\t\t\tconst value = attributes[ key ];\n\n\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\tattributes[ key ] = value.map( updateAttributes );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// To do, remove support for string values?\n\t\t\tif (\n\t\t\t\ttypeof value !== 'string' &&\n\t\t\t\t! ( value instanceof RichTextData )\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst richTextValue =\n\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t? RichTextData.fromHTMLString( value )\n\t\t\t\t\t: new RichTextData( value );\n\n\t\t\tlet hasFootnotes = false;\n\n\t\t\trichTextValue.replacements.forEach( ( replacement ) => {\n\t\t\t\tif ( replacement.type === 'core/footnote' ) {\n\t\t\t\t\tconst id = replacement.attributes[ 'data-fn' ];\n\t\t\t\t\tconst index = newOrder.indexOf( id );\n\t\t\t\t\t// The innerHTML contains the count wrapped in a link.\n\t\t\t\t\tconst countValue = create( {\n\t\t\t\t\t\thtml: replacement.innerHTML,\n\t\t\t\t\t} );\n\t\t\t\t\tcountValue.text = String( index + 1 );\n\t\t\t\t\tcountValue.formats = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.formats[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\tcountValue.replacements = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.replacements[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\treplacement.innerHTML = toHTMLString( {\n\t\t\t\t\t\tvalue: countValue,\n\t\t\t\t\t} );\n\t\t\t\t\thasFootnotes = true;\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tif ( hasFootnotes ) {\n\t\t\t\tattributes[ key ] =\n\t\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t\t? richTextValue.toHTMLString()\n\t\t\t\t\t\t: richTextValue;\n\t\t\t}\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tfunction updateBlocksAttributes( __blocks ) {\n\t\treturn __blocks.map( ( block ) => {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tattributes: updateAttributes( block.attributes ),\n\t\t\t\tinnerBlocks: updateBlocksAttributes( block.innerBlocks ),\n\t\t\t};\n\t\t} );\n\t}\n\n\t// We need to go through all block attributes deeply and update the\n\t// footnote anchor numbering (textContent) to match the new order.\n\tconst newBlocks = updateBlocksAttributes( blocks );\n\n\toldFootnotes = {\n\t\t...oldFootnotes,\n\t\t...footnotes.reduce( ( acc, fn ) => {\n\t\t\tif ( ! newOrder.includes( fn.id ) ) {\n\t\t\t\tacc[ fn.id ] = fn;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} ),\n\t};\n\n\treturn {\n\t\tmeta: {\n\t\t\t...meta,\n\t\t\tfootnotes: JSON.stringify( newFootnotes ),\n\t\t},\n\t\tblocks: newBlocks,\n\t};\n}\n", "/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\n// TODO: The following line should have been:\n//\n//   const unlockedApis = unlock( blockEditorPrivateApis );\n//\n// But there are hidden circular dependencies in RNMobile code, specifically in\n// certain native components in the `components` package that depend on\n// `block-editor`. What follows is a workaround that defers the `unlock` call\n// to prevent native code from failing.\n//\n// Fix once https://github.com/WordPress/gutenberg/issues/52692 is closed.\nlet unlockedApis;\n\nconst cache = new WeakMap();\n\nexport default function getRichTextValuesCached( block ) {\n\tif ( ! unlockedApis ) {\n\t\tunlockedApis = unlock( blockEditorPrivateApis );\n\t}\n\n\tif ( ! cache.has( block ) ) {\n\t\tconst values = unlockedApis.getRichTextValues( [ block ] );\n\t\tcache.set( block, values );\n\t}\n\treturn cache.get( block );\n}\n", "/**\n * Internal dependencies\n */\nimport getRichTextValuesCached from './get-rich-text-values-cached';\n\nconst cache = new WeakMap();\n\nfunction getBlockFootnotesOrder( block ) {\n\tif ( ! cache.has( block ) ) {\n\t\tconst order = [];\n\t\tfor ( const value of getRichTextValuesCached( block ) ) {\n\t\t\tif ( ! value ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// replacements is a sparse array, use forEach to skip empty slots.\n\t\t\tvalue.replacements.forEach( ( { type, attributes } ) => {\n\t\t\t\tif ( type === 'core/footnote' ) {\n\t\t\t\t\torder.push( attributes[ 'data-fn' ] );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\tcache.set( block, order );\n\t}\n\n\treturn cache.get( block );\n}\n\nexport default function getFootnotesOrder( blocks ) {\n\t// We can only separate getting order from blocks at the root level. For\n\t// deeper inner blocks, this will not work since it's possible to have both\n\t// inner blocks and block attributes, so order needs to be computed from the\n\t// Edit functions as a whole.\n\treturn blocks.flatMap( getBlockFootnotesOrder );\n}\n", "/**\n * WordPress dependencies\n */\nimport { useCallback, useContext } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from '../name';\nimport { DEFAULT_ENTITY_KEY } from '../entities';\nimport { EntityContext } from '../entity-context';\nimport useEntityId from './use-entity-id';\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string}        kind  The entity kind.\n * @param {string}        name  The entity name.\n * @param {string}        prop  The property name.\n * @param {number|string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n *                            property value, the second is the\n *                            setter and the third is the full value\n * \t\t\t\t\t\t\t  object from REST API containing more\n * \t\t\t\t\t\t\t  information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t  `protected` props.\n */\nexport default function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst context = useContext( EntityContext );\n\tconst revisionId = context?.revisionId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( revisionId ) {\n\t\t\t\t// Use getRevisions (not getRevision) to read from the\n\t\t\t\t// already-cached collection. Using getRevision would\n\t\t\t\t// trigger a redundant single-revision API fetch that\n\t\t\t\t// can wipe the collection due to a race condition.\n\t\t\t\t// See https://github.com/WordPress/gutenberg/pull/76043.\n\t\t\t\tconst revisions = select( STORE_NAME ).getRevisions(\n\t\t\t\t\tkind,\n\t\t\t\t\tname,\n\t\t\t\t\tid,\n\t\t\t\t\t{\n\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t\tcontext: 'edit',\n\t\t\t\t\t\t_fields:\n\t\t\t\t\t\t\t'id,date,author,meta,title.raw,excerpt.raw,content.raw',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tconst entityConfig = select( STORE_NAME ).getEntityConfig(\n\t\t\t\t\tkind,\n\t\t\t\t\tname\n\t\t\t\t);\n\t\t\t\tconst revKey = entityConfig?.revisionKey || DEFAULT_ENTITY_KEY;\n\t\t\t\tconst revision = revisions?.find(\n\t\t\t\t\t( r ) => r[ revKey ] === revisionId\n\t\t\t\t);\n\t\t\t\treturn revision\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tvalue: revision[ prop ],\n\t\t\t\t\t\t\tfullValue: revision[ prop ],\n\t\t\t\t\t  }\n\t\t\t\t\t: {};\n\t\t\t}\n\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t  }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop, revisionId ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\tif ( revisionId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop, revisionId ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n", "/**\n * External dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { useEffect, useState } from '@wordpress/element';\nimport type { Y } from '@wordpress/sync';\n\n/**\n * Internal dependencies\n */\nimport { getSyncManager } from '../sync';\nimport type {\n\tPostEditorAwarenessState as ActiveCollaborator,\n\tPostSaveEvent,\n\tYDocDebugData,\n} from '../awareness/types';\nimport type { SelectionState, ResolvedSelection } from '../types';\nimport type { PostEditorAwareness } from '../awareness/post-editor-awareness';\n\ninterface AwarenessState {\n\tactiveCollaborators: ActiveCollaborator[];\n\tresolveSelection: ( selection: SelectionState ) => ResolvedSelection;\n\tgetDebugData: () => YDocDebugData;\n\tisCurrentCollaboratorDisconnected: boolean;\n}\n\nconst defaultResolvedSelection: ResolvedSelection = {\n\trichTextOffset: null,\n\tlocalClientId: null,\n};\n\nconst defaultState: AwarenessState = {\n\tactiveCollaborators: [],\n\tresolveSelection: () => defaultResolvedSelection,\n\tgetDebugData: () => ( {\n\t\tdoc: {},\n\t\tclients: {},\n\t\tcollaboratorMap: {},\n\t} ),\n\tisCurrentCollaboratorDisconnected: false,\n};\n\nfunction getAwarenessState(\n\tawareness: PostEditorAwareness,\n\tnewState?: ActiveCollaborator[]\n): AwarenessState {\n\tconst activeCollaborators = newState ?? awareness.getCurrentState();\n\n\treturn {\n\t\tactiveCollaborators,\n\t\tresolveSelection: ( selection: SelectionState ) =>\n\t\t\tawareness.convertSelectionStateToAbsolute( selection ),\n\t\tgetDebugData: () => awareness.getDebugData(),\n\t\tisCurrentCollaboratorDisconnected:\n\t\t\tactiveCollaborators.find( ( collaborator ) => collaborator.isMe )\n\t\t\t\t?.isConnected === false,\n\t};\n}\n\nfunction usePostEditorAwarenessState(\n\tpostId: number | null,\n\tpostType: string | null\n): AwarenessState {\n\tconst [ state, setState ] = useState< AwarenessState >( defaultState );\n\n\tuseEffect( () => {\n\t\tif ( null === postId || null === postType ) {\n\t\t\tsetState( defaultState );\n\t\t\treturn;\n\t\t}\n\n\t\tconst objectType = `postType/${ postType }`;\n\t\tconst objectId = postId.toString();\n\t\tconst awareness = getSyncManager()?.getAwareness< PostEditorAwareness >(\n\t\t\tobjectType,\n\t\t\tobjectId\n\t\t);\n\n\t\tif ( ! awareness ) {\n\t\t\tsetState( defaultState );\n\t\t\treturn;\n\t\t}\n\n\t\tawareness.setUp();\n\n\t\t// Initialize with current awareness state.\n\t\tsetState( getAwarenessState( awareness ) );\n\n\t\tconst unsubscribe = awareness?.onStateChange(\n\t\t\t( newState: ActiveCollaborator[] ) => {\n\t\t\t\tsetState( getAwarenessState( awareness, newState ) );\n\t\t\t}\n\t\t);\n\n\t\treturn unsubscribe;\n\t}, [ postId, postType ] );\n\n\treturn state;\n}\n\n/**\n * Hook to get the active collaborators for a post editor.\n *\n * @param  postId   - The ID of the post.\n * @param  postType - The type of the post.\n * @return {ActiveCollaborator[]} The active collaborators.\n */\nexport function useActiveCollaborators(\n\tpostId: number | null,\n\tpostType: string | null\n): ActiveCollaborator[] {\n\treturn usePostEditorAwarenessState( postId, postType ).activeCollaborators;\n}\n\n/**\n * Hook to resolve a selection state to a text index and block client ID.\n *\n * @param postId   - The ID of the post.\n * @param postType - The type of the post.\n * @return A function that resolves a selection to its text index and block client ID.\n */\nexport function useResolvedSelection(\n\tpostId: number | null,\n\tpostType: string | null\n): ( selection: SelectionState ) => ResolvedSelection {\n\treturn usePostEditorAwarenessState( postId, postType ).resolveSelection;\n}\n\n/**\n * Hook to get data for debugging, using the awareness state.\n *\n * @param  postId   - The ID of the post.\n * @param  postType - The type of the post.\n * @return {YDocDebugData} The debug data.\n */\nexport function useGetDebugData(\n\tpostId: number | null,\n\tpostType: string | null\n): YDocDebugData {\n\treturn usePostEditorAwarenessState( postId, postType ).getDebugData();\n}\n\n/**\n * Hook to check if the current collaborator is disconnected.\n *\n * @param  postId   - The ID of the post.\n * @param  postType - The type of the post.\n * @return {boolean} Whether the current collaborator is disconnected.\n */\nexport function useIsDisconnected(\n\tpostId: number | null,\n\tpostType: string | null\n): boolean {\n\treturn usePostEditorAwarenessState( postId, postType )\n\t\t.isCurrentCollaboratorDisconnected;\n}\n\n/**\n * Hook that subscribes to the CRDT state map and returns the most recent\n * save event (timestamp + client ID). The state map is updated by\n * `markEntityAsSaved` in `@wordpress/sync`\n *\n * @param postId   The ID of the post.\n * @param postType The type of the post.\n */\nfunction useLastPostSave(\n\tpostId: number | null,\n\tpostType: string | null\n): PostSaveEvent | null {\n\tconst [ lastSave, setLastSave ] = useState< PostSaveEvent | null >( null );\n\n\tuseEffect( () => {\n\t\tif ( null === postId || null === postType ) {\n\t\t\tsetLastSave( null );\n\t\t\treturn;\n\t\t}\n\n\t\tconst awareness = getSyncManager()?.getAwareness< PostEditorAwareness >(\n\t\t\t`postType/${ postType }`,\n\t\t\tpostId.toString()\n\t\t);\n\n\t\tif ( ! awareness ) {\n\t\t\tsetLastSave( null );\n\t\t\treturn;\n\t\t}\n\n\t\tawareness.setUp();\n\n\t\tconst stateMap = awareness.doc.getMap( 'state' );\n\t\tconst recordMap = awareness.doc.getMap( 'document' );\n\n\t\t// Only notify for saves that occur after the observer is\n\t\t// set up. This prevents false notifications when the Y.Doc\n\t\t// syncs historical state on page load or peer reconnect.\n\t\tconst setupTime = Date.now();\n\n\t\tconst observer = ( event: Y.YMapEvent< unknown > ) => {\n\t\t\tif ( event.keysChanged.has( 'savedAt' ) ) {\n\t\t\t\tconst savedAt = stateMap.get( 'savedAt' ) as number;\n\t\t\t\tconst savedByClientId = stateMap.get( 'savedBy' ) as number;\n\n\t\t\t\tif (\n\t\t\t\t\ttypeof savedAt === 'number' &&\n\t\t\t\t\ttypeof savedByClientId === 'number' &&\n\t\t\t\t\tsavedAt > setupTime\n\t\t\t\t) {\n\t\t\t\t\tconst postStatus = recordMap.get( 'status' ) as\n\t\t\t\t\t\t| string\n\t\t\t\t\t\t| undefined;\n\t\t\t\t\tsetLastSave( { savedAt, savedByClientId, postStatus } );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tstateMap.observe( observer );\n\n\t\treturn () => {\n\t\t\tstateMap.unobserve( observer );\n\t\t};\n\t}, [ postId, postType ] );\n\n\treturn lastSave;\n}\n\n/**\n * Hook that fires a callback when a new collaborator joins the post.\n * Handles initial hydration and state diffing internally\u2014consumers\n * only receive \"join\" events for collaborators that appear after the\n * initial state has loaded.\n *\n * The callback receives the joining collaborator and, when available,\n * the current user's state (useful for comparing `enteredAt` timestamps).\n *\n * @param postId   The ID of the post.\n * @param postType The type of the post.\n * @param callback Invoked for each collaborator that joins.\n */\nexport function useOnCollaboratorJoin(\n\tpostId: number | null,\n\tpostType: string | null,\n\tcallback: (\n\t\tcollaborator: ActiveCollaborator,\n\t\tme?: ActiveCollaborator\n\t) => void\n): void {\n\tconst { activeCollaborators } = usePostEditorAwarenessState(\n\t\tpostId,\n\t\tpostType\n\t);\n\tconst prevCollaborators = usePrevious( activeCollaborators );\n\n\tuseEffect( () => {\n\t\t/*\n\t\t * On first render usePrevious returns undefined. On subsequent\n\t\t * renders the list may still be empty while the store hydrates.\n\t\t * In both cases, skip to avoid spurious \"joined\" callbacks for\n\t\t * users already present.\n\t\t */\n\t\tif ( ! prevCollaborators || prevCollaborators.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst prevMap = new Map< number, ActiveCollaborator >(\n\t\t\tprevCollaborators.map( ( collaborator ) => [\n\t\t\t\tcollaborator.clientId,\n\t\t\t\tcollaborator,\n\t\t\t] )\n\t\t);\n\t\tconst me = activeCollaborators.find(\n\t\t\t( collaborator ) => collaborator.isMe\n\t\t);\n\n\t\tfor ( const collaborator of activeCollaborators ) {\n\t\t\tif (\n\t\t\t\t! prevMap.has( collaborator.clientId ) &&\n\t\t\t\t! collaborator.isMe\n\t\t\t) {\n\t\t\t\tcallback( collaborator, me );\n\t\t\t}\n\t\t}\n\t}, [ activeCollaborators, prevCollaborators, callback ] );\n}\n\n/**\n * Hook that fires a callback when a collaborator leaves the post.\n * A \"leave\" is detected when a previously-connected collaborator either\n * transitions to `isConnected = false` or disappears from the list\n * entirely while still connected. Already-disconnected collaborators\n * that are later removed from the list are silently ignored.\n *\n * @param postId   The ID of the post.\n * @param postType The type of the post.\n * @param callback Invoked for each collaborator that leaves.\n */\nexport function useOnCollaboratorLeave(\n\tpostId: number | null,\n\tpostType: string | null,\n\tcallback: ( collaborator: ActiveCollaborator ) => void\n): void {\n\tconst { activeCollaborators } = usePostEditorAwarenessState(\n\t\tpostId,\n\t\tpostType\n\t);\n\tconst prevCollaborators = usePrevious( activeCollaborators );\n\n\tuseEffect( () => {\n\t\tif ( ! prevCollaborators || prevCollaborators.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newMap = new Map< number, ActiveCollaborator >(\n\t\t\tactiveCollaborators.map( ( collaborator ) => [\n\t\t\t\tcollaborator.clientId,\n\t\t\t\tcollaborator,\n\t\t\t] )\n\t\t);\n\n\t\tfor ( const prevCollab of prevCollaborators ) {\n\t\t\tif ( prevCollab.isMe || ! prevCollab.isConnected ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst newCollab = newMap.get( prevCollab.clientId );\n\t\t\tif ( ! newCollab?.isConnected ) {\n\t\t\t\tcallback( prevCollab );\n\t\t\t}\n\t\t}\n\t}, [ activeCollaborators, prevCollaborators, callback ] );\n}\n\n/**\n * Hook that fires a callback when a remote collaborator saves the post.\n * Only fires for saves by other collaborators (not the current user).\n * Deduplicates by `savedAt` timestamp so the same save event is never\n * reported twice.\n *\n * @param postId   The ID of the post.\n * @param postType The type of the post.\n * @param callback Invoked with the save event, the collaborator who saved,\n *                 and the previous save event (if any) for transition detection.\n */\nexport function useOnPostSave(\n\tpostId: number | null,\n\tpostType: string | null,\n\tcallback: (\n\t\tevent: PostSaveEvent,\n\t\tsaver: ActiveCollaborator,\n\t\tprevEvent: PostSaveEvent | null\n\t) => void\n): void {\n\tconst { activeCollaborators } = usePostEditorAwarenessState(\n\t\tpostId,\n\t\tpostType\n\t);\n\tconst lastPostSave = useLastPostSave( postId, postType );\n\tconst prevPostSave = usePrevious( lastPostSave );\n\n\tuseEffect( () => {\n\t\tif ( ! lastPostSave ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( prevPostSave && lastPostSave.savedAt === prevPostSave.savedAt ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst saver = activeCollaborators.find(\n\t\t\t( collaborator ) =>\n\t\t\t\tcollaborator.clientId === lastPostSave.savedByClientId &&\n\t\t\t\t! collaborator.isMe\n\t\t);\n\n\t\tif ( ! saver ) {\n\t\t\treturn;\n\t\t}\n\n\t\tcallback( lastPostSave, saver, prevPostSave ?? null );\n\t}, [ lastPostSave, prevPostSave, activeCollaborators, callback ] );\n}\n", "/**\n * Internal dependencies\n */\nimport { useEntityRecordsWithPermissions } from './hooks/use-entity-records';\nimport { RECEIVE_INTERMEDIATE_RESULTS } from './utils';\nimport {\n\tuseActiveCollaborators,\n\tuseResolvedSelection,\n\tuseOnCollaboratorJoin,\n\tuseOnCollaboratorLeave,\n\tuseOnPostSave,\n} from './hooks/use-post-editor-awareness-state';\nimport { lock } from './lock-unlock';\nimport { retrySyncConnection } from './sync';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tuseEntityRecordsWithPermissions,\n\tRECEIVE_INTERMEDIATE_RESULTS,\n\tretrySyncConnection,\n\tuseActiveCollaborators,\n\tuseResolvedSelection,\n\tuseOnCollaboratorJoin,\n\tuseOnCollaboratorLeave,\n\tuseOnPostSave,\n} );\n"],
  "mappings": "wqBAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,KAAA,CAAAA,GAAO,QAAU,OAAO,GAAG,OCA3B,IAAAC,GAAAC,EAAA,CAAAC,GAAAC,KAAA,cAQAA,GAAO,QAAU,SAASC,EAAMC,EAAGC,EAAG,CACpC,GAAID,IAAMC,EAAG,MAAO,GAEpB,GAAID,GAAKC,GAAK,OAAOD,GAAK,UAAY,OAAOC,GAAK,SAAU,CAC1D,GAAID,EAAE,cAAgBC,EAAE,YAAa,MAAO,GAE5C,IAAIC,EAAQC,EAAGC,EACf,GAAI,MAAM,QAAQJ,CAAC,EAAG,CAEpB,GADAE,EAASF,EAAE,OACPE,GAAUD,EAAE,OAAQ,MAAO,GAC/B,IAAKE,EAAID,EAAQC,MAAQ,GACvB,GAAI,CAACJ,EAAMC,EAAEG,CAAC,EAAGF,EAAEE,CAAC,CAAC,EAAG,MAAO,GACjC,MAAO,EACT,CAGA,GAAKH,aAAa,KAASC,aAAa,IAAM,CAC5C,GAAID,EAAE,OAASC,EAAE,KAAM,MAAO,GAC9B,IAAKE,KAAKH,EAAE,QAAQ,EAClB,GAAI,CAACC,EAAE,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Ed,EAAKC,EAAOW,KACtDV,EAAsBR,EAAMC,EAAMmB,EAA8B,CAC/D,oBAAqB,GACrB,wBAAyB,oBAC1B,CAAE,EACaC,GAAoBrB,EAAMC,EAAMK,EAAKC,EAAOW,CAAQ,GAG7DpB,CACR,EAAG,CAAC,CAAE,EAEAwB,GAAc,KAAQ,CAC3B,QAAAC,GACA,QAAS,CACR,GAAGC,GACH,GAAGC,GACH,GAAGV,GACH,GAAGW,GAAmB,CACvB,EACA,UAAW,CACV,GAAGC,GACH,GAAGC,GACH,GAAG/B,EACJ,EACA,UAAW,CAAE,GAAGgC,GAAW,GAAGjB,EAAgB,CAC/C,GAOakB,KAAQ,qBAAkBC,EAAYT,GAAY,CAAE,EACjEU,EAAQF,CAAM,EAAE,yBAA0BG,EAAiB,EAC3DD,EAAQF,CAAM,EAAE,uBAAwBI,EAAe,KACvD,aAAUJ,CAAM",
  "names": ["require_data", "__commonJSMin", "exports", "module", "require_es6", "__commonJSMin", "exports", "module", "equal", "a", "b", "length", "i", "keys", "key", "require_compose", "__commonJSMin", "exports", "module", "require_undo_manager", "__commonJSMin", "exports", "module", "require_equivalent_key_map", "__commonJSMin", "exports", "module", "_typeof", "obj", "_classCallCheck", "instance", "Constructor", "_defineProperties", "target", "props", "i", "descriptor", "_createClass", "protoProps", "staticProps", "getValuePair", "key", "_map", "_arrayTreeMap", "_objectTreeMap", "properties", "map", "property", "propertyValue", "valuePair", "EquivalentKeyMap", "iterable", "iterablePairs", "value", "previousValuePair", "callback", "_this", "thisArg", "require_url", "__commonJSMin", "exports", "module", "require_api_fetch", "__commonJSMin", "exports", "module", "require_blocks", "__commonJSMin", "exports", "module", "require_i18n", "__commonJSMin", "exports", "module", "require_sync", "__commonJSMin", "exports", "module", "require_block_editor", "__commonJSMin", "exports", "module", "require_rich_text", "__commonJSMin", "exports", "module", "require_private_apis", "__commonJSMin", "exports", "module", "require_deprecated", "__commonJSMin", "exports", "module", "require_html_entities", "__commonJSMin", "exports", "module", "require_element", "__commonJSMin", "exports", "module", "require_jsx_runtime", "__commonJSMin", "exports", "module", "require_warning", "__commonJSMin", "exports", "module", "import_data", "import_es6", "import_compose", "import_data", "import_undo_manager", "import_es6", "conservativeMapItem", "item", "nextItem", "hasChanges", "result", "key", "fastDeepEqual", "getNormalizedCommaSeparable", "value", "get_normalized_comma_separable_default", "ifMatchingAction", "isMatch", "reducer", "state", "action", "if_matching_action_default", "forwardResolver", "resolverName", "args", "resolveSelect", "forward_resolver_default", "onSubKey", "actionProperty", "reducer", "state", "action", "key", "nextKeyState", "on_sub_key_default", "replaceAction", "replacer", "reducer", "state", "action", "replace_action_default", "withWeakMapCache", "fn", "cache", "key", "value", "with_weak_map_cache_default", "isRawAttribute", "entity", "attribute", "setNestedValue", "object", "path", "value", "normalizedPath", "acc", "key", "idx", "getNestedValue", "object", "path", "defaultValue", "normalizedPath", "value", "fieldName", "isNumericID", "id", "ALLOWED_RESOURCE_ACTIONS", "getUserPermissionsFromAllowHeader", "allowedMethods", "permissions", "methods", "actionName", "methodName", "getUserPermissionCacheKey", "action", "resource", "id", "RECEIVE_INTERMEDIATE_RESULTS", "normalizeQueryForResolution", "query", "entries", "k", "v", "receiveItems", "items", "edits", "meta", "removeItems", "kind", "name", "records", "invalidateCache", "receiveQueriedItems", "query", "import_equivalent_key_map", "import_data", "import_url", "getQueryParts", "query", "parts", "keys", "i", "key", "value", "numericOffset", "get_normalized_comma_separable_default", "get_query_parts_default", "with_weak_map_cache_default", "queriedItemsCacheByState", "getQueriedItemsUncached", "state", "query", "stableKey", "page", "perPage", "queryOffset", "include", "fields", "context", "get_query_parts_default", "itemIds", "startOffset", "endOffset", "totalItems", "effectiveTotal", "items", "i", "itemId", "item", "filteredItem", "f", "field", "value", "fieldName", "setNestedValue", "getQueriedItems", "queriedItemsCache", "queriedItems", "EquivalentKeyMap", "getQueriedTotalItems", "getQueriedTotalPages", "import_data", "import_compose", "__assign", "s", "i", "n", "p", "lowerCase", "str", "DEFAULT_SPLIT_REGEXP", "DEFAULT_STRIP_REGEXP", "noCase", "input", "options", "_a", "splitRegexp", "_b", "stripRegexp", "_c", "transform", "lowerCase", "_d", "delimiter", "result", "replace", "start", "end", "re", "value", "pascalCaseTransform", "input", "index", "firstChar", "lowerChars", "pascalCase", "input", "options", "noCase", "__assign", "pascalCaseTransform", "camelCaseTransform", "input", "index", "pascalCaseTransform", "camelCase", "input", "options", "pascalCase", "__assign", "camelCaseTransform", "upperCaseFirst", "input", "capitalCaseTransform", "input", "upperCaseFirst", "capitalCase", "options", "noCase", "__assign", "import_api_fetch", "import_blocks", "import_i18n", "import_data", "import_sync", "import_block_editor", "import_data", "AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS", "LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS", "REMOVAL_DELAY_IN_MS", "import_sync", "getBrowserName", "userAgent", "browserName", "areMapsEqual", "map1", "map2", "comparatorFn", "key", "value1", "areCollaboratorInfosEqual", "collaboratorInfo1", "collaboratorInfo2", "value", "generateCollaboratorInfo", "currentCollaborator", "avatar_urls", "id", "name", "slug", "getRecordValue", "obj", "getTypedKeys", "TypedAwareness", "field", "state", "getRecordValue", "value", "AwarenessWithEqualityChecks", "TypedAwareness", "field", "value", "value1", "value2", "fn", "state1", "state2", "getTypedKeys", "AwarenessState", "added", "removed", "updated", "id", "REMOVAL_DELAY_IN_MS", "callback", "cb", "wait", "isConnected", "forceUpdate", "states", "updatedStates", "clientId", "rawState", "isMe", "myState", "state", "areMapsEqual", "STORE_NAME", "BaseAwarenessState", "AwarenessState", "currentUser", "STORE_NAME", "collaboratorInfo", "generateCollaboratorInfo", "baseEqualityFieldChecks", "areCollaboratorInfosEqual", "BaseAwareness", "import_data", "import_sync", "import_block_editor", "getBlockPathInYdoc", "yType", "path", "current", "parentArray", "index", "grandparent", "resolveBlockClientIdByPath", "getBlocks", "blockEditorStore", "blocks", "getPostContentBlocks", "i", "block", "rootBlocks", "postContentBlock", "findBlockByName", "name", "found", "import_sync", "import_rich_text", "import_sync", "import_private_apis", "lock", "unlock", "ConnectionErrorCode", "createSyncManager", "Delta", "CRDT_DOC_META_PERSISTENCE_KEY", "CRDT_RECORD_MAP_KEY", "LOCAL_EDITOR_ORIGIN", "LOCAL_UNDO_IGNORED_ORIGIN", "retrySyncConnection", "unlock", "syncPrivateApis", "syncManager", "getSyncManager", "getRootMap", "doc", "key", "createYMap", "partial", "isYMap", "value", "findBlockByClientIdInDoc", "blockId", "ydoc", "blocks", "CRDT_RECORD_MAP_KEY", "findBlockByClientIdInBlocks", "MARKER_START", "pickMarker", "text", "code", "candidate", "htmlIndexToRichTextOffset", "html", "htmlIndex", "marker", "withMarker", "markerPos", "richTextOffsetToHtmlIndex", "richTextOffset", "markerValue", "markerIndex", "block", "innerBlocks", "innerBlock", "import_data", "import_sync", "import_block_editor", "SelectionType", "getSelectionState", "selectionStart", "selectionEnd", "yDoc", "options", "selectionDirection", "yBlocks", "getRootMap", "CRDT_RECORD_MAP_KEY", "isSelectionEmpty", "noSelection", "isSelectionInOneBlock", "isCursorOnly", "path", "getBlockPathForLocalClientId", "blockPosition", "createRelativePositionForBlockPath", "cursorPosition", "getCursorPosition", "cursorStartPosition", "cursorEndPosition", "selection", "blocks", "block", "findBlockByPath", "currentYText", "richTextOffsetToHtmlIndex", "clientId", "getBlockIndex", "getBlockRootClientId", "getBlockName", "blockEditorStore", "current", "index", "parent", "currentBlocks", "i", "areSelectionsStatesEqual", "selection1", "selection2", "areCursorPositionsEqual", "cursorPosition1", "cursorPosition2", "isRelativePositionEqual", "isAbsoluteOffsetEqual", "SelectionDirection", "PostEditorAwareness", "BaseAwarenessState", "doc", "kind", "name", "postId", "baseEqualityFieldChecks", "getSelectionStart", "getSelectionEnd", "getSelectedBlocksInitialCaretPosition", "blockEditorStore", "selectionStart", "selectionEnd", "localCursorTimeout", "selectionBeforeDebounce", "newSelectionStart", "newSelectionEnd", "initialPosition", "selectionStateOptions", "detectSelectionDirection", "selectionState", "getSelectionState", "AWARENESS_CURSOR_UPDATE_THROTTLE_IN_MS", "LOCAL_CURSOR_UPDATE_DEBOUNCE_IN_MS", "edits", "options", "STORE_NAME", "state1", "state2", "areSelectionsStatesEqual", "selection", "SelectionType", "absolutePos", "localClientId", "block", "path", "getBlockPathInYdoc", "resolveBlockClientIdByPath", "cursorPos", "absolutePosition", "yType", "htmlIndexToRichTextOffset", "struct", "ydoc", "docData", "key", "value", "collaboratorMapData", "clientId", "collaboratorState", "serializableClientItems", "structs", "items", "item", "left", "right", "rest", "prevStart", "prevEnd", "newStart", "newEnd", "startMoved", "areBlockSelectionsEqual", "endMoved", "SelectionDirection", "a", "b", "import_es6", "import_blocks", "import_sync", "getRandomValues", "rnds8", "rng", "byteToHex", "i", "unsafeStringify", "arr", "offset", "randomUUID", "native_default", "v4", "options", "buf", "offset", "native_default", "rnds", "rng", "i", "unsafeStringify", "v4_default", "import_es6", "import_blocks", "import_rich_text", "import_sync", "import_rich_text", "RICH_TEXT_CACHE_MAX_SIZE", "createRichTextDataCache", "maxSize", "cache", "value", "cached", "result", "getCachedRichTextData", "serializableBlocksCache", "serializeAttributeValue", "value", "result", "k", "v", "makeBlockAttributesSerializable", "blockName", "attributes", "newAttributes", "key", "isLocalAttribute", "makeBlocksSerializable", "blocks", "block", "name", "innerBlocks", "rest", "deserializeAttributeValue", "schema", "getCachedRichTextData", "item", "innerValue", "deserializeBlockAttributes", "getBlockAttributeType", "areBlocksEqual", "gblock", "yblock", "yblockAsJson", "overwrites", "res", "fastDeepEqual", "inners", "yinners", "i", "createNewYAttributeMap", "attributeName", "attributeValue", "createNewYAttributeValue", "isRichTextAttribute", "createNewYBlock", "createYMap", "innerBlock", "mergeCrdtBlocks", "yblocks", "incomingBlocks", "cursorPosition", "blocksToSync", "numOfCommonEntries", "left", "right", "numOfUpdatesNeeded", "numOfInsertionsNeeded", "numOfDeletionsNeeded", "currentAttributes", "currentAttribute", "isExpectedAttributeType", "updateYBlockAttribute", "_attrValue", "attrName", "yInnerBlocks", "_v", "newBlock", "knownClientIds", "j", "clientId", "v4_default", "isRichText", "mergeRichTextUpdate", "cachedBlockAttributeTypes", "blockType", "definition", "role", "type", "query", "expectedAttributeType", "localDoc", "blockYText", "updatedValue", "localYText", "currentValueAsDelta", "Delta", "updatedValueAsDelta", "deltaDiff", "import_data", "import_block_editor", "import_blocks", "import_sync", "import_sync", "SELECTION_HISTORY_DEFAULT_SIZE", "YSelectionType", "createBlockSelectionHistory", "ydoc", "historySize", "history", "getSelectionHistory", "updateSelection", "newSelection", "selectionStart", "selectionEnd", "start", "convertWPBlockSelectionToSelection", "end", "addToHistory", "yFullSelection", "startClientId", "endClientId", "entry", "selection", "clientId", "attributes", "findBlockByClientIdInDoc", "attributeKey", "changedYText", "offset", "relativePosition", "richTextOffsetToHtmlIndex", "selectionHistoryMap", "getBlockSelectionHistory", "ydoc", "history", "createBlockSelectionHistory", "getSelectionHistory", "updateSelectionHistory", "wpSelection", "convertYSelectionToBlockSelection", "ySelection", "YSelectionType", "relativePosition", "attributeKey", "clientId", "absolutePosition", "htmlIndexToRichTextOffset", "convertYFullSelectionToWPSelection", "yFullSelection", "start", "end", "startBlock", "findBlockByClientIdInDoc", "endBlock", "startBlockSelection", "endBlockSelection", "findSelectionFromHistory", "selectionHistory", "positionToTry", "result", "restoreSelection", "selectionToRestore", "getBlock", "blockEditorStore", "resetSelection", "selectionStart", "selectionEnd", "block", "isBlockEmpty", "selectionStartWithoutOffset", "selectionEndWithoutOffset", "getShiftedSelection", "startShifted", "endShifted", "POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE", "disallowedPostMetaKeys", "defaultApplyChangesToCRDTDoc", "ydoc", "changes", "ymap", "getRootMap", "CRDT_RECORD_MAP_KEY", "key", "newValue", "currentValue", "updateMapValue", "applyPostChangesToCRDTDoc", "syncedProperties", "currentBlocks", "cursorPosition", "mergeCrdtBlocks", "rawValue", "getRawValue", "mergeRichTextUpdate", "newYText", "metaMap", "isYMap", "createYMap", "metaKey", "metaValue", "selection", "updateSelectionHistory", "defaultGetChangesFromCRDTDoc", "crdtDoc", "getPostChangesFromCRDTDoc", "editedRecord", "allowedMetaChanges", "CRDT_DOC_META_PERSISTENCE_KEY", "blocksJson", "haveValuesChanged", "mergedValue", "deserializeBlockAttributes", "selectionHistory", "getSelectionHistory", "shiftedSelection", "getShiftedSelection", "defaultSyncConfig", "BaseAwareness", "value", "fastDeepEqual", "map", "DEFAULT_ENTITY_KEY", "POST_RAW_ATTRIBUTES", "blocksTransientEdits", "record", "rootEntitiesConfig", "parentId", "revisionId", "entity", "defaultSyncConfig", "deprecatedEntities", "additionalEntityConfigLoaders", "loadPostTypeEntities", "loadTaxonomyEntities", "loadSiteEntity", "prePersistPostType", "persistedRecord", "edits", "name", "isTemplate", "newEdits", "objectType", "objectId", "serializedDoc", "getSyncManager", "POST_META_KEY_FOR_CRDT_DOC_PERSISTENCE", "postTypesPromise", "apiFetch", "taxonomiesPromise", "postTypes", "taxonomies", "postType", "namespace", "syncedProperties", "taxonomy", "capitalCase", "crdtDoc", "changes", "applyPostChangesToCRDTDoc", "ydoc", "kind", "id", "PostEditorAwareness", "editedRecord", "getPostChangesFromCRDTDoc", "site", "labels", "key", "value", "getMethodName", "prefix", "kindPrefix", "pascalCase", "suffix", "getContextFromAction", "action", "query", "get_query_parts_default", "getMergedItemIds", "itemIds", "nextItemIds", "page", "perPage", "nextItemIdsStartIndex", "size", "mergedItemIds", "i", "isInNextItemsRange", "removeEntitiesById", "entities", "ids", "id", "itemId", "items", "state", "context", "key", "DEFAULT_ENTITY_KEY", "itemsList", "item", "conservativeMapItem", "contextState", "itemIsComplete", "queryParts", "isCompleteQuery", "result", "receiveQueries", "if_matching_action_default", "replace_action_default", "on_sub_key_default", "queries", "removedItems", "queryGroup", "contextQueries", "queryItems", "queryId", "reducer_default", "users", "state", "action", "newUsers", "user", "currentUser", "currentTheme", "currentGlobalStylesId", "themeBaseGlobalStyles", "themeGlobalStyleVariations", "withMultiEntityRecordEdits", "reducer", "record", "newState", "kind", "name", "recordId", "changes", "acc", "key", "value", "entity", "entityConfig", "if_matching_action_default", "replace_action_default", "DEFAULT_ENTITY_KEY", "reducer_default", "nextState", "itemsList", "edits", "nextEdits", "fastDeepEqual", "recordKey", "id", "itemId", "entitiesConfig", "rootEntitiesConfig", "entities", "newConfig", "entitiesDataReducer", "entitiesByKind", "subEntities", "kindReducer", "newData", "undoManager", "editsReference", "embedPreviews", "url", "preview", "userPermissions", "autosaves", "postId", "autosavesData", "blockPatterns", "blockPatternCategories", "userPatternCategories", "navigationFallbackId", "themeGlobalStyleRevisions", "defaultTemplates", "registeredPostMeta", "editorSettings", "editorAssets", "syncConnectionStatuses", "_", "rest", "collaborationSupported", "ConnectionErrorCode", "import_data", "import_url", "import_deprecated", "import_data", "import_deprecated", "loggedAlready", "logEntityDeprecation", "kind", "name", "functionName", "alternativeFunctionName", "isShorthandSelector", "deprecation", "deprecatedEntities", "alternative", "message", "alternativeMessage", "deprecated", "getUndoManager", "state", "getSyncManager", "getNavigationFallbackId", "getBlockPatternsForPostType", "select", "postType", "STORE_NAME", "postTypes", "getEntityRecordsPermissions", "kind", "name", "ids", "id", "getEntityRecordPermissions", "logEntityDeprecation", "getRegisteredPostMeta", "normalizePageId", "value", "getHomePage", "siteData", "homepageId", "frontPageTemplateId", "getEntityRecord", "getDefaultTemplateId", "getPostsPageId", "getTemplateId", "postId", "homepage", "unlock", "templates", "slug", "editedEntity", "postsPageId", "currentTemplateSlug", "currentTemplate", "slugToCheck", "getEditorSettings", "getEditorAssets", "isCollaborationSupported", "EMPTY_OBJECT", "isRequestingEmbedPreview", "select", "state", "url", "STORE_NAME", "getAuthors", "query", "deprecated", "path", "getUserQueryResults", "getCurrentUser", "queryID", "id", "getEntitiesByKind", "kind", "getEntitiesConfig", "entity", "getEntity", "name", "getEntityConfig", "logEntityDeprecation", "config", "getEntityRecord", "key", "queriedState", "context", "item", "filteredItem", "fields", "get_normalized_comma_separable_default", "f", "field", "value", "fieldName", "setNestedValue", "recordId", "args", "newArgs", "recordKey", "isNumericID", "hasEntityRecord", "i", "p", "part", "__experimentalGetEntityRecordNoResolver", "getRawEntityRecord", "record", "accumulator", "_key", "isRawAttribute", "hasEntityRecords", "getEntityRecords", "getQueriedItems", "getEntityRecordsTotalItems", "getQueriedTotalItems", "getEntityRecordsTotalPages", "totalItems", "getQueriedTotalPages", "__experimentalGetDirtyEntityRecords", "records", "dirtyRecords", "primaryKeys", "primaryKey", "hasEditsForEntityRecord", "entityConfig", "entityRecord", "getEditedEntityRecord", "DEFAULT_ENTITY_KEY", "__experimentalGetEntitiesBeingSaved", "recordsBeingSaved", "isSavingEntityRecord", "getEntityRecordEdits", "getEntityRecordNonTransientEdits", "transientEdits", "edits", "acc", "raw", "edited", "isAutosavingEntityRecord", "pending", "isAutosave", "isDeletingEntityRecord", "getLastEntitySaveError", "getLastEntityDeleteError", "getUndoEdit", "getRedoEdit", "hasUndo", "getUndoManager", "hasRedo", "getCurrentTheme", "__experimentalGetCurrentGlobalStylesId", "getThemeSupports", "getEmbedPreview", "isPreviewEmbedFallback", "preview", "oEmbedLinkCheck", "canUser", "action", "resource", "isEntity", "getUserPermissionCacheKey", "canUserEditEntityRecord", "getAutosaves", "postType", "postId", "getAutosave", "authorId", "autosave", "hasFetchedAutosaves", "getReferenceByDistinctEdits", "__experimentalGetCurrentThemeBaseGlobalStyles", "currentTheme", "__experimentalGetCurrentThemeGlobalStylesVariations", "getBlockPatterns", "getBlockPatternCategories", "getUserPatternCategories", "getCurrentThemeGlobalStylesRevisions", "currentGlobalStylesId", "getDefaultTemplateId", "getRevisions", "queriedStateRevisions", "hasRevision", "revisionKey", "getRevision", "getSyncConnectionStatus", "PRIORITIZED_STATUSES", "coalesced", "status", "import_es6", "import_api_fetch", "import_url", "import_deprecated", "import_api_fetch", "maxItems", "chunk", "arr", "chunkSize", "tmp", "cache", "defaultProcessor", "requests", "apiFetch", "results", "batchRequests", "batchResponse", "request", "batchResults", "response", "result", "createBatch", "processor", "defaultProcessor", "lastId", "queue", "pending", "ObservableSet", "inputOrThunk", "id", "add", "input", "resolve", "reject", "unsubscribe", "results", "error", "isSuccess", "result", "key", "queueItem", "args", "value", "subscriber", "addTitleToAutoDraft", "record", "receiveUserQuery", "queryID", "users", "receiveCurrentUser", "currentUser", "addEntities", "entities", "receiveEntityRecords", "kind", "name", "records", "query", "invalidateCache", "edits", "meta", "action", "receiveQueriedItems", "receiveItems", "receiveCurrentTheme", "currentTheme", "__experimentalReceiveCurrentGlobalStylesId", "currentGlobalStylesId", "__experimentalReceiveThemeBaseGlobalStyles", "stylesheet", "globalStyles", "__experimentalReceiveThemeGlobalStyleVariations", "variations", "receiveThemeSupports", "deprecated", "receiveThemeGlobalStyleRevisions", "currentId", "revisions", "receiveEmbedPreview", "url", "preview", "deleteEntityRecord", "recordId", "__unstableFetch", "apiFetch", "throwOnError", "dispatch", "resolveSelect", "logEntityDeprecation", "entityConfig", "config", "error", "deletedRecord", "lock", "STORE_NAME", "hasError", "baseURL", "path", "removeItems", "objectType", "objectId", "getSyncManager", "_error", "editEntityRecord", "options", "select", "mergedEdits", "editedRecord", "editsWithMerges", "acc", "key", "edit", "recordValue", "value", "fastDeepEqual", "isNewUndoLevel", "origin", "LOCAL_UNDO_IGNORED_ORIGIN", "LOCAL_EDITOR_ORIGIN", "clearEntityRecordEdits", "currentEdits", "clearedEdits", "undo", "undoRecord", "redo", "redoRecord", "__unstableCreateUndoLevel", "saveEntityRecord", "isAutosave", "entityIdKey", "DEFAULT_ENTITY_KEY", "isNewRecord", "v4_default", "evaluatedValue", "updatedRecord", "persistedRecord", "merged", "data", "newRecord", "__experimentalBatch", "requests", "batch", "createBatch", "api", "add", "resultPromises", "request", "results", "saveEditedEntityRecord", "__experimentalSaveSpecifiedEntityEdits", "itemsToSave", "editsToSave", "item", "setNestedValue", "getNestedValue", "receiveUploadPermissions", "hasUploadPermissions", "receiveUserPermission", "isAllowed", "receiveUserPermissions", "permissions", "receiveAutosaves", "postId", "autosaves", "receiveNavigationFallbackId", "fallbackId", "receiveDefaultTemplateId", "templateId", "receiveRevisions", "recordKey", "setSyncConnectionStatus", "status", "import_api_fetch", "receiveRegisteredPostMeta", "postType", "registeredPostMeta", "editMediaEntity", "recordId", "edits", "__unstableFetch", "apiFetch", "throwOnError", "dispatch", "resolveSelect", "kind", "name", "entityConfig", "config", "lock", "STORE_NAME", "updatedRecord", "error", "hasError", "path", "newRecord", "e", "receiveEditorSettings", "settings", "receiveEditorAssets", "assets", "setCollaborationSupported", "supported", "import_url", "import_html_entities", "import_api_fetch", "import_api_fetch", "import_api_fetch", "import_url", "import_html_entities", "import_i18n", "fetchLinkSuggestions", "search", "searchOptions", "editorSettings", "searchOptionsToUse", "type", "subtype", "page", "perPage", "disablePostFormats", "queries", "apiFetch", "results", "result", "sortResults", "searchTokens", "tokenize", "scores", "titleTokens", "exactMatchingTokens", "titleToken", "searchToken", "subMatchingTokens", "exactMatchScore", "subMatchScore", "a", "b", "text", "import_api_fetch", "import_url", "CACHE", "fetchUrlData", "url", "options", "endpoint", "args", "protocol", "apiFetch", "res", "experimental_fetch_url_data_default", "fetchBlockPatterns", "restPatterns", "apiFetch", "pattern", "key", "value", "camelCase", "getAuthors", "query", "dispatch", "path", "users", "apiFetch", "getCurrentUser", "currentUser", "getEntityRecord", "kind", "name", "key", "select", "registry", "resolveSelect", "entityConfig", "config", "lock", "STORE_NAME", "get_normalized_comma_separable_default", "DEFAULT_ENTITY_KEY", "baseURL", "response", "record", "permissions", "getUserPermissionsFromAllowHeader", "canUserResolutionsArgs", "receiveUserPermissionArgs", "action", "ALLOWED_RESOURCE_ACTIONS", "getUserPermissionCacheKey", "isNumericID", "objectType", "objectId", "recordWithTransients", "propName", "transientConfig", "getSyncManager", "edits", "options", "status", "editedRecord", "meta", "ydoc", "selectionHistory", "getSelectionHistory", "restoreSelection", "getRawEntityRecord", "forward_resolver_default", "getEditedEntityRecord", "getEntityRecords", "rawQuery", "getResolutionsArgs", "records", "recordsQuery", "normalizedQuery", "normalizeQueryForResolution", "combinedTemplates", "RECEIVE_INTERMEDIATE_RESULTS", "page", "totalPages", "pageRecords", "field", "targetHints", "targetHint", "getEntityRecordsTotalItems", "getEntityRecordsTotalPages", "getCurrentTheme", "activeThemes", "getThemeSupports", "getEmbedPreview", "url", "embedProxyResponse", "canUser", "requestedAction", "resource", "id", "hasStartedResolution", "relatedAction", "resourcePath", "canUserEditEntityRecord", "recordId", "getAutosaves", "postType", "postId", "restBase", "restNamespace", "supports", "autosaves", "getAutosave", "__experimentalGetCurrentGlobalStylesId", "globalStylesURL", "matches", "__experimentalGetCurrentThemeBaseGlobalStyles", "currentTheme", "themeGlobalStyles", "__experimentalGetCurrentThemeGlobalStylesVariations", "variations", "getCurrentThemeGlobalStylesRevisions", "globalStylesId", "revisionsURL", "revisions", "revision", "value", "camelCase", "getBlockPatterns", "patterns", "fetchBlockPatterns", "getBlockPatternCategories", "categories", "getUserPatternCategories", "mappedPatternCategories", "userCategory", "getNavigationFallbackId", "fallback", "invalidateNavigationQueries", "getDefaultTemplateId", "template", "getRevisions", "recordKey", "isPaginated", "resolutionsArgs", "getRevision", "revisionKey", "getRegisteredPostMeta", "getEntitiesConfig", "loader", "additionalEntityConfigLoaders", "l", "configs", "getEditorSettings", "settings", "getEditorAssets", "assets", "deepCopyLocksTreePath", "tree", "path", "newTree", "currentNode", "branchName", "getNode", "nextNode", "iteratePath", "iterateDescendants", "node", "stack", "childNode", "hasConflictingLock", "exclusive", "locks", "lock", "DEFAULT_STATE", "locks", "state", "action", "request", "lock", "store", "path", "storePath", "newTree", "deepCopyLocksTreePath", "node", "getNode", "r", "l", "getPendingLockRequests", "state", "isLockAvailable", "store", "path", "exclusive", "storePath", "locks", "node", "iteratePath", "hasConflictingLock", "getNode", "descendant", "iterateDescendants", "createLocks", "state", "locks", "processPendingLockRequests", "request", "getPendingLockRequests", "store", "path", "exclusive", "notifyAcquired", "isLockAvailable", "lock", "acquire", "resolve", "release", "createLocksActions", "locks", "createLocks", "__unstableAcquireStoreLock", "store", "path", "exclusive", "__unstableReleaseStoreLock", "lock", "dynamicActions", "dynamicSelectors", "import_element", "import_element", "EntityContext", "import_jsx_runtime", "EntityProvider", "kind", "name", "id", "revisionId", "children", "parent", "EntityContext", "childContext", "import_data", "import_deprecated", "import_element", "import_data", "memize", "fn", "options", "size", "head", "tail", "memoized", "node", "len", "args", "i", "searchCache", "memoize_default", "memize", "Status", "META_SELECTORS", "useQuerySelect", "mapQuerySelect", "deps", "select", "registry", "store", "enrichSelectors", "memoize_default", "selectors", "resolvers", "selectorName", "args", "data", "resolutionStatus", "status", "Status", "EMPTY_OBJECT", "useEntityRecord", "kind", "name", "recordId", "options", "editEntityRecord", "saveEditedEntityRecord", "store", "mutations", "record", "editOptions", "saveOptions", "editedRecord", "hasEdits", "edits", "select", "querySelectRest", "useQuerySelect", "query", "__experimentalUseEntityRecord", "deprecated", "import_url", "import_deprecated", "import_data", "import_element", "EMPTY_ARRAY", "useEntityRecords", "kind", "name", "queryArgs", "options", "queryAsString", "records", "rest", "useQuerySelect", "query", "store", "totalItems", "totalPages", "select", "__experimentalUseEntityRecords", "deprecated", "useEntityRecordsWithPermissions", "entityConfig", "data", "ret", "get_normalized_comma_separable_default", "ids", "record", "permissions", "getEntityRecordsPermissions", "unlock", "index", "import_deprecated", "import_warning", "useResourcePermissions", "resource", "id", "isEntity", "resourceAsString", "warning", "useQuerySelect", "resolve", "hasId", "canUser", "store", "create", "read", "isResolving", "hasResolved", "status", "Status", "update", "_delete", "use_resource_permissions_default", "__experimentalUseResourcePermissions", "deprecated", "import_element", "import_data", "import_blocks", "import_element", "useEntityId", "kind", "name", "EntityContext", "import_rich_text", "import_block_editor", "unlockedApis", "cache", "getRichTextValuesCached", "block", "unlock", "blockEditorPrivateApis", "values", "cache", "getBlockFootnotesOrder", "block", "order", "value", "getRichTextValuesCached", "type", "attributes", "getFootnotesOrder", "blocks", "oldFootnotes", "updateFootnotesFromMeta", "blocks", "meta", "output", "newOrder", "getFootnotesOrder", "footnotes", "fn", "newFootnotes", "fnId", "updateAttributes", "attributes", "key", "value", "richTextValue", "hasFootnotes", "replacement", "id", "index", "countValue", "updateBlocksAttributes", "__blocks", "block", "newBlocks", "acc", "EMPTY_ARRAY", "parsedBlocksCache", "useEntityBlockEditor", "kind", "name", "_id", "providerId", "useEntityId", "id", "content", "editedBlocks", "meta", "select", "getEditedEntityRecord", "STORE_NAME", "editedRecord", "__unstableCreateUndoLevel", "editEntityRecord", "blocks", "cacheKey", "cached", "_blocks", "onChange", "newBlocks", "options", "selection", "rest", "edits", "blocksForSerialization", "updateFootnotesFromMeta", "onInput", "import_element", "import_data", "useEntityProp", "kind", "name", "prop", "_id", "providerId", "useEntityId", "id", "revisionId", "EntityContext", "value", "fullValue", "select", "revisions", "STORE_NAME", "revKey", "DEFAULT_ENTITY_KEY", "revision", "r", "getEntityRecord", "getEditedEntityRecord", "record", "editedRecord", "editEntityRecord", "setValue", "newValue", "import_compose", "import_element", "defaultResolvedSelection", "defaultState", "getAwarenessState", "awareness", "newState", "activeCollaborators", "selection", "collaborator", "usePostEditorAwarenessState", "postId", "postType", "state", "setState", "objectType", "objectId", "getSyncManager", "useActiveCollaborators", "useResolvedSelection", "useLastPostSave", "postId", "postType", "lastSave", "setLastSave", "awareness", "getSyncManager", "stateMap", "recordMap", "setupTime", "observer", "event", "savedAt", "savedByClientId", "postStatus", "useOnCollaboratorJoin", "callback", "activeCollaborators", "usePostEditorAwarenessState", "prevCollaborators", "prevMap", "collaborator", "me", "useOnCollaboratorLeave", "newMap", "prevCollab", "useOnPostSave", "lastPostSave", "prevPostSave", "saver", "privateApis", "lock", "useEntityRecordsWithPermissions", "RECEIVE_INTERMEDIATE_RESULTS", "retrySyncConnection", "useActiveCollaborators", "useResolvedSelection", "useOnCollaboratorJoin", "useOnCollaboratorLeave", "useOnPostSave", "entitiesConfig", "rootEntitiesConfig", "additionalEntityConfigLoaders", "config", "entitySelectors", "result", "entity", "kind", "name", "plural", "getEntityRecordMethodName", "getMethodName", "state", "key", "query", "logEntityDeprecation", "getEntityRecord", "getEntityRecordsMethodName", "getEntityRecords", "entityResolvers", "args", "action", "entityActions", "saveEntityRecordMethodName", "record", "options", "saveEntityRecord", "deleteEntityRecordMethodName", "deleteEntityRecord", "storeConfig", "reducer_default", "dynamicActions", "actions_exports", "createLocksActions", "dynamicSelectors", "selectors_exports", "resolvers_exports", "store", "STORE_NAME", "unlock", "private_selectors_exports", "private_actions_exports"]
}