{"version":3,"file":"StructureToolProvider.mjs","sources":["../../src/structure/i18n/index.ts","../../src/structure/structureBuilder/util/getExtendedProjection.ts","../../src/structure/structureBuilder/SerializeError.ts","../../src/structure/structureBuilder/Sort.ts","../../src/structure/structureBuilder/MenuItem.ts","../../src/structure/structureBuilder/MenuItemGroup.ts","../../src/structure/structureBuilder/util/validateId.ts","../../src/structure/structureBuilder/util/getStructureNodeId.ts","../../src/structure/structureBuilder/Component.ts","../../src/structure/structureBuilder/util/resolveTypeForDocument.ts","../../src/structure/structureBuilder/views/View.ts","../../src/structure/structureBuilder/views/ComponentView.ts","../../src/structure/structureBuilder/views/FormView.ts","../../src/structure/structureBuilder/views/index.ts","../../src/structure/structureBuilder/Document.ts","../../src/structure/structureBuilder/InitialValueTemplateItem.ts","../../src/structure/structureBuilder/Intent.ts","../../src/structure/structureBuilder/Layout.ts","../../src/structure/structureBuilder/GenericList.ts","../../src/structure/structureBuilder/DocumentList.ts","../../src/structure/structureBuilder/List.ts","../../src/structure/structureBuilder/ListItem.ts","../../src/structure/structureBuilder/DocumentListItem.ts","../../src/structure/structureBuilder/DocumentTypeList.ts","../../src/structure/structureBuilder/documentTypeListItems.ts","../../src/structure/structureBuilder/createStructureBuilder.ts","../../src/structure/StructureToolProvider.tsx"],"sourcesContent":["import {defineLocaleResourceBundle} from 'sanity'\n\n/**\n * The locale namespace for the structure tool\n *\n * @public\n */\nexport const structureLocaleNamespace = 'structure' as const\n\n/**\n * The default locale bundle for the structure tool, which is US English.\n *\n * @internal\n */\nexport const structureUsEnglishLocaleBundle = defineLocaleResourceBundle({\n  locale: 'en-US',\n  namespace: structureLocaleNamespace,\n  resources: () => import('./resources'),\n})\n\n/**\n * The locale resource keys for the structure tool.\n *\n * @alpha\n * @hidden\n */\nexport type {StructureLocaleResourceKeys} from './resources'\n","import {type SchemaType, type SortOrderingItem} from '@sanity/types'\n\nconst IMPLICIT_SCHEMA_TYPE_FIELDS = ['_id', '_type', '_createdAt', '_updatedAt', '_rev']\n\n// Takes a path array and a schema type and builds a GROQ join every time it enters a reference field\nfunction joinReferences(schemaType: SchemaType, path: string[], strict: boolean = false): string {\n  const [head, ...tail] = path\n\n  if (!('fields' in schemaType)) {\n    return ''\n  }\n\n  const schemaField = schemaType.fields.find((field) => field.name === head)\n  if (!schemaField) {\n    if (!IMPLICIT_SCHEMA_TYPE_FIELDS.includes(head)) {\n      const errorMessage = `The current ordering config targeted the nonexistent field \"${head}\" on schema type \"${schemaType.name}\". It should be one of ${schemaType.fields.map((field) => field.name).join(', ')}`\n      if (strict) {\n        throw new Error(errorMessage)\n      } else {\n        // eslint-disable-next-line no-console\n        console.warn(errorMessage)\n      }\n    }\n    return ''\n  }\n\n  if ('to' in schemaField.type && schemaField.type.name === 'reference') {\n    const refTypes = schemaField.type.to\n    return `${head}->{${refTypes.map((refType) => joinReferences(refType, tail)).join(',')}}`\n  }\n\n  const tailFields = tail.length > 0 && joinReferences(schemaField.type, tail)\n  const tailWrapper = tailFields ? `{${tailFields}}` : ''\n  return tail.length > 0 ? `${head}${tailWrapper}` : head\n}\n\nexport function getExtendedProjection(\n  schemaType: SchemaType,\n  orderBy: SortOrderingItem[],\n  strict: boolean = false,\n): string {\n  return orderBy\n    .map((ordering) => joinReferences(schemaType, ordering.field.split('.'), strict))\n    .join(', ')\n}\n","import {type SerializePath} from './StructureNodes'\n\n/** @internal */\nexport class SerializeError extends Error {\n  public readonly path: SerializePath\n  public helpId?: HELP_URL\n\n  constructor(\n    message: string,\n    parentPath: SerializePath,\n    pathSegment: string | number | undefined,\n    hint?: string,\n  ) {\n    super(message)\n    this.name = 'SerializeError'\n    const segment = typeof pathSegment === 'undefined' ? '<unknown>' : `${pathSegment}`\n    this.path = (parentPath || []).concat(hint ? `${segment} (${hint})` : segment)\n  }\n\n  withHelpUrl(id: HELP_URL): SerializeError {\n    this.helpId = id\n    return this\n  }\n}\n\n/** @internal */\nexport enum HELP_URL {\n  ID_REQUIRED = 'structure-node-id-required',\n  TITLE_REQUIRED = 'structure-title-required',\n  FILTER_REQUIRED = 'structure-filter-required',\n  INVALID_LIST_ITEM = 'structure-invalid-list-item',\n  COMPONENT_REQUIRED = 'structure-view-component-required',\n  DOCUMENT_ID_REQUIRED = 'structure-document-id-required',\n  DOCUMENT_TYPE_REQUIRED = 'structure-document-type-required',\n  SCHEMA_TYPE_REQUIRED = 'structure-schema-type-required',\n  SCHEMA_TYPE_NOT_FOUND = 'structure-schema-type-not-found',\n  LIST_ITEMS_MUST_BE_ARRAY = 'structure-list-items-must-be-array',\n  QUERY_PROVIDED_FOR_FILTER = 'structure-query-provided-for-filter',\n  ACTION_OR_INTENT_REQUIRED = 'structure-action-or-intent-required',\n  LIST_ITEM_IDS_MUST_BE_UNIQUE = 'structure-list-item-ids-must-be-unique',\n  ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE = 'structure-action-and-intent-mutually-exclusive',\n  API_VERSION_REQUIRED_FOR_CUSTOM_FILTER = 'structure-api-version-required-for-custom-filter',\n}\n","import {type SortOrdering} from '@sanity/types'\n\nimport {structureLocaleNamespace} from '../i18n'\n\nexport const ORDER_BY_UPDATED_AT: SortOrdering = {\n  title: 'Last edited',\n  i18n: {\n    title: {\n      key: 'menu-items.sort-by.last-edited',\n      ns: structureLocaleNamespace,\n    },\n  },\n  name: 'lastEditedDesc',\n  by: [{field: '_updatedAt', direction: 'desc'}],\n}\n\nexport const ORDER_BY_CREATED_AT: SortOrdering = {\n  title: 'Created',\n  i18n: {\n    title: {\n      key: 'menu-items.sort-by.created',\n      ns: structureLocaleNamespace,\n    },\n  },\n  name: 'lastCreatedDesc',\n  by: [{field: '_createdAt', direction: 'desc'}],\n}\n\nexport const DEFAULT_SELECTED_ORDERING_OPTION = ORDER_BY_UPDATED_AT\n\nexport const DEFAULT_ORDERING_OPTIONS: SortOrdering[] = [\n  ORDER_BY_UPDATED_AT, // _updatedAt\n  ORDER_BY_CREATED_AT, // _createdAt\n]\n","import {SortIcon} from '@sanity/icons'\nimport {type SchemaType, type SortOrdering, type SortOrderingItem} from '@sanity/types'\nimport {type I18nTextRecord} from 'sanity'\n\nimport {type Intent} from './Intent'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {DEFAULT_ORDERING_OPTIONS} from './Sort'\nimport {type Serializable, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\nimport {getExtendedProjection} from './util/getExtendedProjection'\n\n/** @internal */\nexport function maybeSerializeMenuItem(\n  item: MenuItem | MenuItemBuilder,\n  index: number,\n  path: SerializePath,\n): MenuItem {\n  return item instanceof MenuItemBuilder ? item.serialize({path, index}) : item\n}\n\n/**\n * Menu item action type\n * @public */\nexport type MenuItemActionType =\n  | string\n  | ((params: Record<string, string> | undefined, scope?: any) => void)\n\n/**\n * Menu items parameters\n *\n * @public */\nexport type MenuItemParamsType = Record<string, string | unknown | undefined>\n\n/**\n * Interface for menu items\n *\n * @public */\nexport interface MenuItem {\n  /**\n   * The i18n key and namespace used to populate the localized title. This is\n   * the recommend way to set the title if you are localizing your studio.\n   */\n  i18n?: I18nTextRecord<'title'>\n  /**\n   * Menu Item title. Note that the `i18n` configuration will take\n   * precedence and this title is left here as a fallback if no i18n key is\n   * provided and compatibility with older plugins\n   */\n  title: string\n  /** Menu Item action */\n  action?: MenuItemActionType\n  /** Menu Item intent */\n  intent?: Intent\n  /** Menu Item group */\n  group?: string\n  // TODO: align these with TemplateItem['icon']\n  /** Menu Item icon */\n  icon?: React.ComponentType | React.ReactNode\n  /** Menu Item parameters. See {@link MenuItemParamsType} */\n  params?: MenuItemParamsType\n  /** Determine if it will show the MenuItem as action */\n  showAsAction?: boolean\n}\n\n/**\n * Partial menu items\n * @public\n */\nexport type PartialMenuItem = Partial<MenuItem>\n\n/**\n * Class for building menu items.\n *\n * @public */\nexport class MenuItemBuilder implements Serializable<MenuItem> {\n  /** menu item option object. See {@link PartialMenuItem} */\n  protected spec: PartialMenuItem\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: MenuItem,\n  ) {\n    this.spec = spec ? spec : {}\n  }\n\n  /**\n   * Set menu item action\n   * @param action - menu item action. See {@link MenuItemActionType}\n   * @returns menu item builder based on action provided. See {@link MenuItemBuilder}\n   */\n  action(action: MenuItemActionType): MenuItemBuilder {\n    return this.clone({action})\n  }\n\n  /**\n   * Get menu item action\n   * @returns menu item builder action. See {@link PartialMenuItem}\n   */\n  getAction(): PartialMenuItem['action'] {\n    return this.spec.action\n  }\n\n  /**\n   * Set menu item intent\n   * @param intent - menu item intent. See {@link Intent}\n   * @returns menu item builder based on intent provided. See {@link MenuItemBuilder}\n   */\n  intent(intent: Intent): MenuItemBuilder {\n    return this.clone({intent})\n  }\n\n  /**\n   * Get menu item intent\n   * @returns menu item intent. See {@link PartialMenuItem}\n   */\n  getIntent(): PartialMenuItem['intent'] {\n    return this.spec.intent\n  }\n\n  /**\n   * Set menu item title\n   * @param title - menu item title\n   * @returns menu item builder based on title provided. See {@link MenuItemBuilder}\n   */\n  title(title: string): MenuItemBuilder {\n    return this.clone({title})\n  }\n\n  /**\n   * Get menu item title. Note that the `i18n` configuration will take\n   * precedence and this title is left here for compatibility.\n   * @returns menu item title\n   */\n  getTitle(): string | undefined {\n    return this.spec.title\n  }\n\n  /**\n   * Set the i18n key and namespace used to populate the localized title.\n   * @param i18n - object with i18n key and related namespace\n   * @returns menu item builder based on i18n config provided. See {@link MenuItemBuilder}\n   */\n  i18n(i18n: I18nTextRecord<'title'>): MenuItemBuilder {\n    return this.clone({i18n})\n  }\n\n  /**\n   * Get the i18n key and namespace used to populate the localized title.\n   * @returns the i18n key and namespace used to populate the localized title.\n   */\n  getI18n(): I18nTextRecord<'title'> | undefined {\n    return this.spec.i18n\n  }\n\n  /**\n   * Set menu item group\n   * @param group - menu item group\n   * @returns menu item builder based on group provided. See {@link MenuItemBuilder}\n   */\n  group(group: string): MenuItemBuilder {\n    return this.clone({group})\n  }\n\n  /**\n   * Get menu item group\n   * @returns menu item group. See {@link PartialMenuItem}\n   */\n  getGroup(): PartialMenuItem['group'] {\n    return this.spec.group\n  }\n\n  /**\n   * Set menu item icon\n   * @param icon - menu item icon\n   * @returns menu item builder based on icon provided. See {@link MenuItemBuilder}\n   */\n  icon(icon: React.ComponentType | React.ReactNode): MenuItemBuilder {\n    return this.clone({icon})\n  }\n\n  /**\n   * Get menu item icon\n   * @returns menu item icon. See {@link PartialMenuItem}\n   */\n  getIcon(): PartialMenuItem['icon'] {\n    return this.spec.icon\n  }\n\n  /**\n   * Set menu item parameters\n   * @param params - menu item parameters. See {@link MenuItemParamsType}\n   * @returns menu item builder based on parameters provided. See {@link MenuItemBuilder}\n   */\n  params(params: MenuItemParamsType): MenuItemBuilder {\n    return this.clone({params})\n  }\n\n  /**\n   * Get meny item parameters\n   * @returns menu item parameters. See {@link PartialMenuItem}\n   */\n  getParams(): PartialMenuItem['params'] {\n    return this.spec.params\n  }\n\n  /**\n   * Set menu item to show as action\n   * @param showAsAction - determine if menu item should show as action\n   * @returns menu item builder based on if it should show as action. See {@link MenuItemBuilder}\n   */\n  showAsAction(showAsAction = true): MenuItemBuilder {\n    return this.clone({showAsAction: Boolean(showAsAction)})\n  }\n\n  /**\n   * Check if menu item should show as action\n   * @returns true if menu item should show as action, false if not. See {@link PartialMenuItem}\n   */\n  getShowAsAction(): PartialMenuItem['showAsAction'] {\n    return this.spec.showAsAction\n  }\n\n  /** Serialize menu item builder\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns menu item node based on path provided in options. See {@link MenuItem}\n   */\n  serialize(options: SerializeOptions = {path: []}): MenuItem {\n    const {title, action, intent} = this.spec\n    if (!title) {\n      const hint = typeof action === 'string' ? `action: \"${action}\"` : undefined\n      throw new SerializeError(\n        '`title` is required for menu item',\n        options.path,\n        options.index,\n        hint,\n      ).withHelpUrl(HELP_URL.TITLE_REQUIRED)\n    }\n\n    if (!action && !intent) {\n      throw new SerializeError(\n        `\\`action\\` or \\`intent\\` required for menu item with title ${this.spec.title}`,\n        options.path,\n        options.index,\n        `\"${title}\"`,\n      ).withHelpUrl(HELP_URL.ACTION_OR_INTENT_REQUIRED)\n    }\n\n    if (intent && action) {\n      throw new SerializeError(\n        'cannot set both `action` AND `intent`',\n        options.path,\n        options.index,\n        `\"${title}\"`,\n      ).withHelpUrl(HELP_URL.ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE)\n    }\n\n    return {...this.spec, title}\n  }\n\n  /** Clone menu item builder\n   * @param withSpec - menu item options. See {@link PartialMenuItem}\n   * @returns menu item builder based on context and spec provided. See {@link MenuItemBuilder}\n   */\n  clone(withSpec?: PartialMenuItem): MenuItemBuilder {\n    const builder = new MenuItemBuilder(this._context)\n    builder.spec = {...this.spec, ...(withSpec || {})}\n    return builder\n  }\n}\n\n/** @internal */\nexport interface SortMenuItem extends MenuItem {\n  params: {\n    by: SortOrderingItem[]\n  }\n}\n\n/** @internal */\nexport function getOrderingMenuItem(\n  context: StructureContext,\n  {by, title, i18n}: SortOrdering,\n  extendedProjection?: string,\n): MenuItemBuilder {\n  let builder = new MenuItemBuilder(context)\n    .group('sorting')\n    .title(\n      context.i18n.t('default-menu-item.fallback-title', {\n        // note this lives in the `studio` bundle because that one is loaded by default\n        ns: 'studio',\n        replace: {title}, // replaces the `{{title}}` option\n      }),\n    ) // fallback title\n    .icon(SortIcon)\n    .action('setSortOrder')\n    .params({by, extendedProjection})\n\n  if (i18n) {\n    builder = builder.i18n(i18n)\n  }\n\n  return builder\n}\n\n/** @internal */\nexport function getOrderingMenuItemsForSchemaType(\n  context: StructureContext,\n  typeName: SchemaType | string,\n): MenuItemBuilder[] {\n  const {schema} = context\n  const type = typeof typeName === 'string' ? schema.get(typeName) : typeName\n  if (!type || !('orderings' in type)) {\n    return []\n  }\n\n  return (\n    type.orderings ? type.orderings.concat(DEFAULT_ORDERING_OPTIONS) : DEFAULT_ORDERING_OPTIONS\n  ).map((ordering: SortOrdering) =>\n    getOrderingMenuItem(context, ordering, getExtendedProjection(type, ordering.by)),\n  )\n}\n","import {type I18nTextRecord} from 'sanity'\n\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Serializable, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/** @internal */\nexport function maybeSerializeMenuItemGroup(\n  item: MenuItemGroup | MenuItemGroupBuilder,\n  index: number,\n  path: SerializePath,\n): MenuItemGroup {\n  return item instanceof MenuItemGroupBuilder ? item.serialize({path, index}) : item\n}\n\n/**\n * Interface for menu item groups\n * @public\n */\nexport interface MenuItemGroup {\n  /** Menu group Id */\n  id: string\n  /** Menu group title */\n  title: string\n  i18n?: I18nTextRecord<'title'>\n}\n\n/**\n * Class for building menu item groups.\n *\n * @public\n */\nexport class MenuItemGroupBuilder implements Serializable<MenuItemGroup> {\n  /** Menu item group ID */\n  protected _id: string\n  /** Menu item group title */\n  protected _title: string\n\n  protected _i18n?: I18nTextRecord<'title'>\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: MenuItemGroup,\n  ) {\n    this._id = spec ? spec.id : ''\n    this._title = spec ? spec.title : ''\n    this._i18n = spec ? spec.i18n : undefined\n  }\n\n  /**\n   * Set menu item group ID\n   * @param id - menu item group ID\n   * @returns menu item group builder based on ID provided. See {@link MenuItemGroupBuilder}\n   */\n  id(id: string): MenuItemGroupBuilder {\n    return new MenuItemGroupBuilder(this._context, {id, title: this._title, i18n: this._i18n})\n  }\n\n  /**\n   * Get menu item group ID\n   * @returns menu item group ID\n   */\n  getId(): string {\n    return this._id\n  }\n\n  /**\n   * Set menu item group title\n   * @param title - menu item group title\n   * @returns menu item group builder based on title provided. See {@link MenuItemGroupBuilder}\n   */\n  title(title: string): MenuItemGroupBuilder {\n    return new MenuItemGroupBuilder(this._context, {title, id: this._id, i18n: this._i18n})\n  }\n\n  /**\n   * Get menu item group title\n   * @returns menu item group title\n   */\n  getTitle(): string {\n    return this._title\n  }\n\n  /**\n   * Set the i18n key and namespace used to populate the localized title.\n   * @param i18n - object with i18n key and related namespace\n   * @returns menu item group builder based on i18n info provided. See {@link MenuItemGroupBuilder}\n   */\n  i18n(i18n: I18nTextRecord<'title'>): MenuItemGroupBuilder {\n    return new MenuItemGroupBuilder(this._context, {i18n, id: this._id, title: this._title})\n  }\n\n  /**\n   * Get the i18n key and namespace used to populate the localized title.\n   * @returns the i18n key and namespace used to populate the localized title.\n   */\n  getI18n(): I18nTextRecord<'title'> | undefined {\n    return this._i18n\n  }\n\n  /**\n   * Serialize menu item group builder\n   * @param options - serialization options (path). See {@link SerializeOptions}\n   * @returns menu item group based on path provided in options. See {@link MenuItemGroup}\n   */\n  serialize(options: SerializeOptions = {path: []}): MenuItemGroup {\n    const {_id, _title, _i18n} = this\n    if (!_id) {\n      throw new SerializeError(\n        '`id` is required for a menu item group',\n        options.path,\n        options.index,\n        _title,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    if (!_title) {\n      throw new SerializeError(\n        '`title` is required for a menu item group',\n        options.path,\n        _id,\n      ).withHelpUrl(HELP_URL.TITLE_REQUIRED)\n    }\n\n    return {\n      id: _id,\n      title: _title,\n      i18n: _i18n,\n    }\n  }\n}\n","import {SerializeError} from '../SerializeError'\nimport {type SerializePath} from '../StructureNodes'\n\nexport const disallowedPattern = /([^A-Za-z0-9-_.])/\n\nexport function validateId(\n  id: string,\n  parentPath: SerializePath,\n  pathSegment: string | number | undefined,\n): string {\n  if (typeof id !== 'string') {\n    throw new SerializeError(\n      `Structure node id must be of type string, got ${typeof id}`,\n      parentPath,\n      pathSegment,\n    )\n  }\n\n  const [disallowedChar] = id.match(disallowedPattern) || []\n  if (disallowedChar) {\n    throw new SerializeError(\n      `Structure node id cannot contain character \"${disallowedChar}\"`,\n      parentPath,\n      pathSegment,\n    )\n  }\n\n  if (id.startsWith('__edit__')) {\n    throw new SerializeError(\n      `Structure node id cannot start with __edit__`,\n      parentPath,\n      pathSegment,\n    )\n  }\n\n  return id\n}\n","import {camelCase} from 'lodash'\nimport getSlug from 'speakingurl'\n\nimport {disallowedPattern} from './validateId'\n\nexport function getStructureNodeId(title: string, id?: string): string {\n  if (id) {\n    return id\n  }\n\n  const camelCased = camelCase(title)\n\n  return disallowedPattern.test(camelCased) ? camelCase(getSlug(title)) : camelCased\n}\n","import {type I18nTextRecord} from 'sanity'\n\nimport {type IntentChecker} from './Intent'\nimport {maybeSerializeMenuItem, type MenuItem, type MenuItemBuilder} from './MenuItem'\nimport {\n  maybeSerializeMenuItemGroup,\n  type MenuItemGroup,\n  type MenuItemGroupBuilder,\n} from './MenuItemGroup'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {\n  type Child,\n  type Serializable,\n  type SerializeOptions,\n  type StructureNode,\n} from './StructureNodes'\nimport {type UserComponent} from './types'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {validateId} from './util/validateId'\n\n/**\n * Interface for component\n *\n * @public\n */\n// TODO: rename to `StructureComponent` since it clashes with React?\nexport interface Component extends StructureNode {\n  /** Component of type {@link UserComponent} */\n  component: UserComponent\n  /** Component child of type {@link Child} */\n  child?: Child\n  /** Component menu items, array of type {@link MenuItem} */\n  menuItems: MenuItem[]\n  /** Component menu item group, array of type {@link MenuItemGroup} */\n  menuItemGroups: MenuItemGroup[]\n  /** Component options */\n  options: {[key: string]: unknown}\n  canHandleIntent?: IntentChecker\n}\n\n/**\n * Interface for component input\n *\n * @public\n */\nexport interface ComponentInput extends StructureNode {\n  /** Component of type {@link UserComponent} */\n  component: UserComponent\n  /** Component child of type {@link Child} */\n  child?: Child\n  /** Component options */\n  options?: {[key: string]: unknown}\n  /** Component menu items. See {@link MenuItem} and {@link MenuItemBuilder}  */\n  menuItems?: (MenuItem | MenuItemBuilder)[]\n  /** Component menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n  menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n}\n\n/**\n * Interface for buildable component\n *\n * @public\n */\nexport interface BuildableComponent extends Partial<StructureNode> {\n  /** Component of type {@link UserComponent} */\n  component?: UserComponent\n  /** Component child of type {@link Child} */\n  child?: Child\n  /** Component options */\n  options?: {[key: string]: unknown}\n  /** Component menu items. See {@link MenuItem} and {@link MenuItemBuilder}  */\n  menuItems?: (MenuItem | MenuItemBuilder)[]\n  /** Component menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n  menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n  canHandleIntent?: IntentChecker\n}\n\n/**\n * Class for building components\n *\n * @public\n */\nexport class ComponentBuilder implements Serializable<Component> {\n  /** component builder option object */\n  protected spec: BuildableComponent\n\n  constructor(spec?: ComponentInput) {\n    this.spec = {options: {}, ...(spec ? spec : {})}\n  }\n\n  /** Set Component ID\n   * @param id - component ID\n   * @returns component builder based on ID provided\n   */\n  id(id: string): ComponentBuilder {\n    return this.clone({id})\n  }\n\n  /** Get ID\n   * @returns ID\n   */\n  getId(): BuildableComponent['id'] {\n    return this.spec.id\n  }\n\n  /** Set Component title\n   * @param title - component title\n   * @returns component builder based on title provided (and ID)\n   */\n  title(title: string): ComponentBuilder {\n    return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n  }\n\n  /** Get Component title\n   * @returns title\n   */\n  getTitle(): BuildableComponent['title'] {\n    return this.spec.title\n  }\n\n  /** Set the i18n key and namespace used to populate the localized title.\n   * @param i18n - the key and namespaced used to populate the localized title.\n   * @returns component builder based on i18n key and ns provided\n   */\n  i18n(i18n: I18nTextRecord<'title'>): ComponentBuilder {\n    return this.clone({i18n})\n  }\n\n  /** Get i18n key and namespace used to populate the localized title\n   * @returns the i18n key and namespace used to populate the localized title\n   */\n  getI18n(): I18nTextRecord<'title'> | undefined {\n    return this.spec.i18n\n  }\n\n  /** Set Component child\n   * @param child - child component\n   * @returns component builder based on child component provided\n   */\n  child(child: Child): ComponentBuilder {\n    return this.clone({child})\n  }\n\n  /** Get Component child\n   * @returns child component\n   */\n  getChild(): BuildableComponent['child'] {\n    return this.spec.child\n  }\n\n  /** Set component\n   * @param component - user built component\n   * @returns component builder based on component provided\n   */\n  component(component: UserComponent): ComponentBuilder {\n    return this.clone({component})\n  }\n\n  /** Get Component\n   * @returns component\n   */\n  getComponent(): BuildableComponent['component'] {\n    return this.spec.component\n  }\n\n  /** Set Component options\n   * @param options - component options\n   * @returns component builder based on options provided\n   */\n  options(options: {[key: string]: unknown}): ComponentBuilder {\n    return this.clone({options})\n  }\n\n  /** Get Component options\n   * @returns component options\n   */\n  getOptions(): NonNullable<BuildableComponent['options']> {\n    return this.spec.options || {}\n  }\n\n  /** Set Component menu items\n   * @param menuItems - component menu items\n   * @returns component builder based on menuItems provided\n   */\n  menuItems(menuItems: (MenuItem | MenuItemBuilder)[]): ComponentBuilder {\n    return this.clone({menuItems})\n  }\n\n  /** Get Component menu items\n   * @returns menu items\n   */\n  getMenuItems(): BuildableComponent['menuItems'] {\n    return this.spec.menuItems\n  }\n\n  /** Set Component menu item groups\n   * @param menuItemGroups - component menu item groups\n   * @returns component builder based on menuItemGroups provided\n   */\n  menuItemGroups(menuItemGroups: (MenuItemGroup | MenuItemGroupBuilder)[]): ComponentBuilder {\n    return this.clone({menuItemGroups})\n  }\n\n  /** Get Component menu item groups\n   * @returns menu item groups\n   */\n  getMenuItemGroups(): BuildableComponent['menuItemGroups'] {\n    return this.spec.menuItemGroups\n  }\n\n  canHandleIntent(canHandleIntent: IntentChecker): ComponentBuilder {\n    return this.clone({canHandleIntent})\n  }\n\n  /** Serialize component\n   * @param options - serialization options\n   * @returns component object based on path provided in options\n   *\n   */\n  serialize(options: SerializeOptions = {path: []}): Component {\n    const {id, title, child, options: componentOptions, component} = this.spec\n    if (!id) {\n      throw new SerializeError(\n        '`id` is required for `component` structure item',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    if (!component) {\n      throw new SerializeError(\n        '`component` is required for `component` structure item',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    return {\n      id: validateId(id, options.path, options.index),\n      title,\n      type: 'component',\n      child,\n      component,\n      canHandleIntent: this.spec.canHandleIntent,\n      options: componentOptions || {},\n      menuItems: (this.spec.menuItems || []).map((item, i) =>\n        maybeSerializeMenuItem(item, i, options.path),\n      ),\n      menuItemGroups: (this.spec.menuItemGroups || []).map((item, i) =>\n        maybeSerializeMenuItemGroup(item, i, options.path),\n      ),\n    }\n  }\n\n  /** Clone component builder (allows for options overriding)\n   * @param withSpec - component builder options\n   * @returns cloned builder\n   */\n  clone(withSpec?: BuildableComponent): ComponentBuilder {\n    const builder = new ComponentBuilder()\n    builder.spec = {...this.spec, ...(withSpec || {})}\n    return builder\n  }\n}\n","import {type SanityClient} from '@sanity/client'\nimport {DEFAULT_STUDIO_CLIENT_OPTIONS, getPublishedId, type SourceClientOptions} from 'sanity'\n\nexport async function resolveTypeForDocument(\n  getClient: (options: SourceClientOptions) => SanityClient,\n  id: string,\n): Promise<string | undefined> {\n  const query = '*[sanity::versionOf($publishedId)][0]._type'\n\n  const type = await getClient(DEFAULT_STUDIO_CLIENT_OPTIONS).fetch(\n    query,\n    {publishedId: getPublishedId(id)},\n    {tag: 'structure.resolve-type'},\n  )\n\n  return type\n}\n","import {kebabCase} from 'lodash'\n\nimport {HELP_URL, SerializeError} from '../SerializeError'\nimport {type Serializable, type SerializeOptions, type SerializePath} from '../StructureNodes'\nimport {type View} from '../types'\nimport {validateId} from '../util/validateId'\nimport {type ComponentViewBuilder} from './ComponentView'\nimport {type FormViewBuilder} from './FormView'\n\n/**\n * Interface for base view\n *\n * @public */\nexport interface BaseView {\n  /** View id */\n  id: string\n  /** View Title */\n  title: string\n  /** View Icon */\n  icon?: React.ComponentType | React.ReactNode\n}\n\n/**\n * Class for building generic views.\n *\n * @public\n */\nexport abstract class GenericViewBuilder<TView extends Partial<BaseView>, ConcreteImpl>\n  implements Serializable<BaseView>\n{\n  /** Generic view option object */\n  protected spec: TView = {} as TView\n\n  /** Set generic view ID\n   * @param id - generic view ID\n   * @returns generic view builder based on ID provided.\n   */\n  id(id: string): ConcreteImpl {\n    return this.clone({id})\n  }\n  /** Get generic view ID\n   * @returns generic view ID\n   */\n  getId(): TView['id'] {\n    return this.spec.id\n  }\n\n  /** Set generic view title\n   * @param title - generic view title\n   * @returns generic view builder based on title provided and (if provided) its ID.\n   */\n  title(title: string): ConcreteImpl {\n    return this.clone({title, id: this.spec.id || kebabCase(title)})\n  }\n\n  /** Get generic view title\n   * @returns generic view title\n   */\n  getTitle(): TView['title'] {\n    return this.spec.title\n  }\n\n  /** Set generic view icon\n   * @param icon - generic view icon\n   * @returns generic view builder based on icon provided.\n   */\n  icon(icon: React.ComponentType | React.ReactNode): ConcreteImpl {\n    return this.clone({icon})\n  }\n\n  /** Get generic view icon\n   * @returns generic view icon\n   */\n  getIcon(): TView['icon'] {\n    return this.spec.icon\n  }\n\n  /** Serialize generic view\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns generic view object based on path provided in options. See {@link BaseView}\n   */\n  serialize(options: SerializeOptions = {path: []}): BaseView {\n    const {id, title, icon} = this.spec\n    if (!id) {\n      throw new SerializeError(\n        '`id` is required for view item',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    if (!title) {\n      throw new SerializeError(\n        '`title` is required for view item',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.TITLE_REQUIRED)\n    }\n\n    return {\n      id: validateId(id, options.path, options.index),\n      title,\n      icon,\n    }\n  }\n\n  /** Clone generic view builder (allows for options overriding)\n   * @param withSpec - Partial generic view builder options. See {@link BaseView}\n   * @returns Generic view builder.\n   */\n  abstract clone(withSpec?: Partial<BaseView>): ConcreteImpl\n}\n\nfunction isSerializable(view: BaseView | Serializable<BaseView>): view is Serializable<BaseView> {\n  return typeof (view as Serializable<BaseView>).serialize === 'function'\n}\n\n/** @internal */\nexport function maybeSerializeView(\n  item: View | Serializable<View>,\n  index: number,\n  path: SerializePath,\n): View {\n  return isSerializable(item) ? item.serialize({path, index}) : item\n}\n\n/**\n * View builder. See {@link ComponentViewBuilder} and {@link FormViewBuilder}\n *\n * @public\n */\nexport type ViewBuilder = ComponentViewBuilder | FormViewBuilder\n","import {isRecord} from 'sanity'\n\nimport {HELP_URL, SerializeError} from '../SerializeError'\nimport {type SerializeOptions} from '../StructureNodes'\nimport {type UserViewComponent} from '../types'\nimport {type BaseView, GenericViewBuilder} from './View'\n\n/**\n * Interface for component views.\n *\n * @public */\nexport interface ComponentView<TOptions = Record<string, any>> extends BaseView {\n  type: 'component'\n  /** Component view components. See {@link UserViewComponent} */\n  component: UserViewComponent\n  /** Component view options */\n  options: TOptions\n}\n\nconst isComponentSpec = (spec: unknown): spec is ComponentView =>\n  isRecord(spec) && spec.type === 'component'\n\n/**\n * Class for building a component view.\n *\n * @public */\nexport class ComponentViewBuilder extends GenericViewBuilder<\n  Partial<ComponentView>,\n  ComponentViewBuilder\n> {\n  /** Partial Component view option object. See {@link ComponentView} */\n  protected spec: Partial<ComponentView>\n\n  constructor(\n    /**\n     * Component view component or spec\n     * @param componentOrSpec - user view component or partial component view. See {@link UserViewComponent} and {@link ComponentView}\n     */\n    componentOrSpec?: UserViewComponent | Partial<ComponentView>,\n  ) {\n    const spec = isComponentSpec(componentOrSpec) ? {...componentOrSpec} : {options: {}}\n\n    super()\n    this.spec = spec\n\n    const userComponent =\n      typeof componentOrSpec === 'function' ? componentOrSpec : this.spec.component\n\n    if (userComponent) {\n      // Because we're cloning, this'll return a new instance, so grab the spec from it\n      this.spec = this.component(userComponent).spec\n    }\n  }\n\n  /** Set view Component\n   * @param component - component view component. See {@link UserViewComponent}\n   * @returns component view builder based on component view provided. See {@link ComponentViewBuilder}\n   */\n  component(component: UserViewComponent): ComponentViewBuilder {\n    return this.clone({component})\n  }\n\n  /** Get view Component\n   * @returns Partial component view. See {@link ComponentView}\n   */\n  getComponent(): Partial<ComponentView>['component'] {\n    return this.spec.component\n  }\n\n  /** Set view Component options\n   * @param options - component view options\n   * @returns component view builder based on options provided. See {@link ComponentViewBuilder}\n   */\n  options(options: {[key: string]: any}): ComponentViewBuilder {\n    return this.clone({options})\n  }\n\n  /** Get view Component options\n   * @returns component view options. See {@link ComponentView}\n   */\n  getOptions(): ComponentView['options'] {\n    return this.spec.options || {}\n  }\n\n  /** Serialize view Component\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns component view based on path provided in options. See {@link ComponentView}\n   *\n   */\n  serialize(options: SerializeOptions = {path: []}): ComponentView {\n    const base = super.serialize(options)\n\n    const component = this.spec.component\n    if (typeof component !== 'function') {\n      throw new SerializeError(\n        '`component` is required and must be a function for `component()` view item',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.COMPONENT_REQUIRED)\n    }\n\n    return {\n      ...base,\n      component,\n      options: this.spec.options || {},\n      type: 'component',\n    }\n  }\n\n  /** Clone Component view builder (allows for options overriding)\n   * @param withSpec - partial for component view option. See {@link ComponentView}\n   * @returns component view builder. See {@link ComponentViewBuilder}\n   */\n  clone(withSpec?: Partial<ComponentView>): ComponentViewBuilder {\n    const builder = new ComponentViewBuilder()\n    builder.spec = {...this.spec, ...(withSpec || {})}\n    return builder\n  }\n}\n","import {type SerializeOptions} from '../StructureNodes'\nimport {type BaseView, GenericViewBuilder} from './View'\n\n/**\n * Interface for form views.\n *\n * @public */\nexport interface FormView extends BaseView {\n  type: 'form'\n}\n\n/**\n * Class for building a form view.\n *\n * @public */\nexport class FormViewBuilder extends GenericViewBuilder<Partial<BaseView>, FormViewBuilder> {\n  /** Document list options. See {@link FormView} */\n  protected spec: Partial<FormView>\n\n  constructor(spec?: Partial<FormView>) {\n    super()\n    this.spec = {id: 'editor', title: 'Editor', ...(spec ? spec : {})}\n  }\n\n  /**\n   * Serialize Form view builder\n   * @param options - Serialize options. See {@link SerializeOptions}\n   * @returns form view builder based on path provided in options. See {@link FormView}\n   */\n  serialize(options: SerializeOptions = {path: []}): FormView {\n    return {\n      ...super.serialize(options),\n      type: 'form',\n    }\n  }\n\n  /**\n   * Clone Form view builder (allows for options overriding)\n   * @param withSpec - Partial form view builder options. See {@link FormView}\n   * @returns form view builder. See {@link FormViewBuilder}\n   */\n  clone(withSpec?: Partial<FormView>): FormViewBuilder {\n    const builder = new FormViewBuilder()\n    builder.spec = {...this.spec, ...(withSpec || {})}\n    return builder\n  }\n}\n","import {type UserViewComponent} from '../types'\nimport {type ComponentView, ComponentViewBuilder} from './ComponentView'\nimport {type FormView, FormViewBuilder} from './FormView'\n\nexport * from './ComponentView'\nexport * from './FormView'\nexport * from './View'\n\n/** @internal */\nexport const form = (spec?: Partial<FormView>): FormViewBuilder => new FormViewBuilder(spec)\n\n/** @internal */\nexport const component = (\n  componentOrSpec?: UserViewComponent | Partial<ComponentView>,\n): ComponentViewBuilder => new ComponentViewBuilder(componentOrSpec)\n","import {type SchemaType} from '@sanity/types'\nimport {uniq} from 'lodash'\nimport {type I18nTextRecord} from 'sanity'\n\nimport {type ChildResolver} from './ChildResolver'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {\n  type Child,\n  type DocumentNode,\n  type EditorNode,\n  type Serializable,\n  type SerializeOptions,\n} from './StructureNodes'\nimport {type StructureContext, type View} from './types'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {resolveTypeForDocument} from './util/resolveTypeForDocument'\nimport {validateId} from './util/validateId'\nimport {form} from './views'\nimport {maybeSerializeView, type ViewBuilder} from './views/View'\n\nconst createDocumentChildResolver =\n  ({resolveDocumentNode, getClient}: StructureContext): ChildResolver =>\n  async (itemId, {params, path}) => {\n    let type = params.type\n\n    const parentPath = path.slice(0, path.length - 1)\n    const currentSegment = path[path.length - 1]\n\n    if (!type) {\n      type = await resolveTypeForDocument(getClient, itemId)\n    }\n\n    if (!type) {\n      throw new SerializeError(\n        `Failed to resolve document, and no type provided in parameters.`,\n        parentPath,\n        currentSegment,\n      )\n    }\n\n    return resolveDocumentNode({documentId: itemId, schemaType: type})\n  }\n\n/**\n * Interface for options of Partial Documents. See {@link PartialDocumentNode}\n *\n * @public */\nexport interface DocumentOptions {\n  /** Document Id */\n  id: string\n  /** Document Type */\n  type: string\n  /** Document Template */\n  template?: string\n  /** Template parameters */\n  templateParameters?: Record<string, unknown>\n}\n\n/**\n * Interface for partial document (focused on the document pane)\n *\n * @public */\nexport interface PartialDocumentNode {\n  /** Document Id */\n  id?: string\n  /** Document title */\n  title?: string\n  /** I18n key and namespace used to populate the localized title */\n  i18n?: I18nTextRecord<'title'>\n  /** Document children of type {@link Child} */\n  child?: Child\n  /**\n   * Views for the document pane. See {@link ViewBuilder} and {@link View}\n   */\n  views?: (View | ViewBuilder)[]\n  /**\n   * Document options. See {@link DocumentOptions}\n   */\n  options?: Partial<DocumentOptions>\n}\n\n/**\n * A `DocumentBuilder` is used to build a document node.\n *\n * @public */\nexport class DocumentBuilder implements Serializable<DocumentNode> {\n  /** Component builder option object See {@link PartialDocumentNode} */\n  protected spec: PartialDocumentNode\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: PartialDocumentNode,\n  ) {\n    this.spec = spec ? spec : {}\n  }\n\n  /** Set Document Builder ID\n   * @param id - document builder ID\n   * @returns document builder based on ID provided. See {@link DocumentBuilder}\n   */\n  id(id: string): DocumentBuilder {\n    return this.clone({id})\n  }\n\n  /** Get Document Builder ID\n   * @returns document ID. See {@link PartialDocumentNode}\n   */\n  getId(): PartialDocumentNode['id'] {\n    return this.spec.id\n  }\n\n  /** Set Document title\n   * @param title - document title\n   * @returns document builder based on title provided (and ID). See {@link DocumentBuilder}\n   */\n  title(title: string): DocumentBuilder {\n    return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n  }\n\n  /** Get Document title\n   * @returns document title. See {@link PartialDocumentNode}\n   */\n  getTitle(): PartialDocumentNode['title'] {\n    return this.spec.title\n  }\n\n  /** Set the i18n key and namespace used to populate the localized title.\n   * @param i18n - the key and namespaced used to populate the localized title.\n   * @returns component builder based on i18n key and ns provided\n   */\n  i18n(i18n: I18nTextRecord<'title'>): DocumentBuilder {\n    return this.clone({i18n})\n  }\n\n  /** Get i18n key and namespace used to populate the localized title\n   * @returns the i18n key and namespace used to populate the localized title\n   */\n  getI18n(): I18nTextRecord<'title'> | undefined {\n    return this.spec.i18n\n  }\n\n  /** Set Document child\n   * @param child - document child\n   * @returns document builder based on child provided. See {@link DocumentBuilder}\n   */\n  child(child: Child): DocumentBuilder {\n    return this.clone({child})\n  }\n\n  /** Get Document child\n   * @returns document child. See {@link PartialDocumentNode}\n   */\n  getChild(): PartialDocumentNode['child'] {\n    return this.spec.child\n  }\n\n  /** Set Document ID\n   * @param documentId - document ID\n   * @returns document builder with document based on ID provided. See {@link DocumentBuilder}\n   */\n  documentId(documentId: string): DocumentBuilder {\n    // Let's try to be a bit helpful and assign an ID from document ID if none is specified\n    const paneId = this.spec.id || documentId\n    return this.clone({\n      id: paneId,\n      options: {\n        ...(this.spec.options || {}),\n        id: documentId,\n      },\n    })\n  }\n\n  /** Get Document ID\n   * @returns document ID. See {@link DocumentOptions}\n   */\n  getDocumentId(): Partial<DocumentOptions>['id'] {\n    return this.spec.options?.id\n  }\n\n  /** Set Document Type\n   * @param documentType - document type\n   * @returns document builder with document based on type provided. See {@link DocumentBuilder}\n   */\n  schemaType(documentType: SchemaType | string): DocumentBuilder {\n    return this.clone({\n      options: {\n        ...(this.spec.options || {}),\n        type: typeof documentType === 'string' ? documentType : documentType.name,\n      },\n    })\n  }\n\n  /** Get Document Type\n   * @returns document type. See {@link DocumentOptions}\n   */\n  getSchemaType(): Partial<DocumentOptions>['type'] {\n    return this.spec.options?.type\n  }\n\n  /** Set Document Template\n   * @param templateId - document template ID\n   * @param parameters - document template parameters\n   * @returns document builder with document based on template provided. See {@link DocumentBuilder}\n   */\n  initialValueTemplate(templateId: string, parameters?: Record<string, unknown>): DocumentBuilder {\n    return this.clone({\n      options: {\n        ...(this.spec.options || {}),\n        template: templateId,\n        templateParameters: parameters,\n      },\n    })\n  }\n\n  /** Get Document Template\n   * @returns document template. See {@link DocumentOptions}\n   */\n  getInitialValueTemplate(): Partial<DocumentOptions>['template'] {\n    return this.spec.options?.template\n  }\n\n  /** Get Document's initial value Template parameters\n   * @returns document template parameters. See {@link DocumentOptions}\n   */\n  getInitialValueTemplateParameters(): Partial<DocumentOptions>['templateParameters'] {\n    return this.spec.options?.templateParameters\n  }\n\n  /** Set Document views\n   * @param views - document views. See {@link ViewBuilder} and {@link View}\n   * @returns document builder with document based on views provided. See {@link DocumentBuilder}\n   */\n  views(views: (View | ViewBuilder)[]): DocumentBuilder {\n    return this.clone({views})\n  }\n\n  /** Get Document views\n   * @returns document views. See {@link ViewBuilder} and {@link View}\n   */\n  getViews(): (View | ViewBuilder)[] {\n    return this.spec.views || []\n  }\n\n  /** Serialize Document builder\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns document node based on path, index and hint provided in options. See {@link DocumentNode}\n   */\n  serialize({path = [], index, hint}: SerializeOptions = {path: []}): DocumentNode {\n    const urlId = path[index || path.length - 1]\n\n    // Try to grab document ID / editor ID from URL if not defined\n    const id = this.spec.id || (urlId && `${urlId}`) || ''\n    const options: Partial<DocumentOptions> = {\n      id,\n      type: undefined,\n      template: undefined,\n      templateParameters: undefined,\n      ...this.spec.options,\n    }\n\n    if (typeof id !== 'string' || !id) {\n      throw new SerializeError(\n        '`id` is required for document nodes',\n        path,\n        index,\n        hint,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    if (!options || !options.id) {\n      throw new SerializeError(\n        'document id (`id`) is required for document nodes',\n        path,\n        id,\n        hint,\n      ).withHelpUrl(HELP_URL.DOCUMENT_ID_REQUIRED)\n    }\n\n    if (!options || !options.type) {\n      throw new SerializeError(\n        'document type (`schemaType`) is required for document nodes',\n        path,\n        id,\n        hint,\n      )\n    }\n\n    const views = (this.spec.views && this.spec.views.length > 0 ? this.spec.views : [form()]).map(\n      (item, i) => maybeSerializeView(item, i, path),\n    )\n\n    const viewIds = views.map((view) => view.id)\n    const dupes = uniq(viewIds.filter((viewId, i) => viewIds.includes(viewId, i + 1)))\n    if (dupes.length > 0) {\n      throw new SerializeError(\n        `document node has views with duplicate IDs: ${dupes.join(',  ')}`,\n        path,\n        id,\n        hint,\n      )\n    }\n\n    return {\n      ...this.spec,\n      child: this.spec.child || createDocumentChildResolver(this._context),\n      id: validateId(id, path, index),\n      type: 'document',\n      options: getDocumentOptions(options),\n      views,\n    }\n  }\n\n  /** Clone Document builder\n   * @param withSpec - partial document node specification used to extend the cloned builder. See {@link PartialDocumentNode}\n   * @returns document builder based on context and spec provided. See {@link DocumentBuilder}\n   */\n  clone(withSpec: PartialDocumentNode = {}): DocumentBuilder {\n    const builder = new DocumentBuilder(this._context)\n    const options = {...(this.spec.options || {}), ...(withSpec.options || {})}\n    builder.spec = {...this.spec, ...withSpec, options}\n    return builder\n  }\n}\n\nfunction getDocumentOptions(spec: Partial<DocumentOptions>): DocumentOptions {\n  const opts: DocumentOptions = {\n    id: spec.id || '',\n    type: spec.type || '*',\n  }\n\n  if (spec.template) {\n    opts.template = spec.template\n  }\n\n  if (spec.templateParameters) {\n    opts.templateParameters = spec.templateParameters\n  }\n\n  return opts\n}\n\n/** @internal */\nexport function documentFromEditor(context: StructureContext, spec?: EditorNode): DocumentBuilder {\n  let doc = spec?.type\n    ? // Use user-defined document fragment as base if possible\n      context.resolveDocumentNode({schemaType: spec.type})\n    : // Fall back to plain old document builder\n      new DocumentBuilder(context)\n\n  if (!spec) return doc\n\n  const {id, type, template, templateParameters} = spec.options\n  doc = doc.id(spec.id).documentId(id)\n\n  if (type) {\n    doc = doc.schemaType(type)\n  }\n  if (template) {\n    doc = doc.initialValueTemplate(template, templateParameters)\n  }\n  if (spec.child) {\n    doc = doc.child(spec.child)\n  }\n\n  return doc\n}\n\n/** @internal */\nexport function documentFromEditorWithInitialValue(\n  {resolveDocumentNode, templates}: StructureContext,\n  templateId: string,\n  parameters?: Record<string, unknown>,\n): DocumentBuilder {\n  const template = templates.find((t) => t.id === templateId)\n\n  if (!template) {\n    throw new Error(`Template with ID \"${templateId}\" not defined`)\n  }\n\n  return resolveDocumentNode({schemaType: template.schemaType}).initialValueTemplate(\n    templateId,\n    parameters,\n  )\n}\n","import {AddIcon} from '@sanity/icons'\nimport {type InitialValueTemplateItem} from 'sanity'\n\nimport {type BaseIntentParams, type IntentParams} from './Intent'\nimport {type MenuItem, MenuItemBuilder} from './MenuItem'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Serializable, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/**\n * A `InitialValueTemplateItemBuilder` is used to build a document node with an initial value set.\n *\n * @public\n */\nexport class InitialValueTemplateItemBuilder implements Serializable<InitialValueTemplateItem> {\n  /** Initial Value template item option object. See {@link InitialValueTemplateItem} */\n  protected spec: Partial<InitialValueTemplateItem>\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: Partial<InitialValueTemplateItem>,\n  ) {\n    this.spec = spec ? spec : {}\n  }\n\n  /** Set initial value template item builder ID\n   * @param id - initial value template item ID\n   * @returns initial value template item based on ID provided. See {@link InitialValueTemplateItemBuilder}\n   */\n  id(id: string): InitialValueTemplateItemBuilder {\n    return this.clone({id})\n  }\n\n  /** Get initial value template item builder ID\n   * @returns initial value template item ID. See {@link InitialValueTemplateItem}\n   */\n  getId(): Partial<InitialValueTemplateItem>['id'] {\n    return this.spec.id\n  }\n\n  /** Set initial value template item title\n   * @param title - initial value template item title\n   * @returns initial value template item based on title provided. See {@link InitialValueTemplateItemBuilder}\n   */\n  title(title: string): InitialValueTemplateItemBuilder {\n    return this.clone({title})\n  }\n\n  /** Get initial value template item title\n   * @returns initial value template item title. See {@link InitialValueTemplateItem}\n   */\n  getTitle(): Partial<InitialValueTemplateItem>['title'] {\n    return this.spec.title\n  }\n\n  /** Set initial value template item description\n   * @param description - initial value template item description\n   * @returns initial value template item builder based on description provided. See {@link InitialValueTemplateItemBuilder}\n   */\n  description(description: string): InitialValueTemplateItemBuilder {\n    return this.clone({description})\n  }\n\n  /** Get initial value template item description\n   * @returns initial value template item description. See {@link InitialValueTemplateItem}\n   */\n  getDescription(): Partial<InitialValueTemplateItem>['description'] {\n    return this.spec.description\n  }\n\n  /** Set initial value template ID\n   * @param templateId - initial value template item template ID\n   * @returns initial value template item based builder on template ID provided. See {@link InitialValueTemplateItemBuilder}\n   */\n  templateId(templateId: string): InitialValueTemplateItemBuilder {\n    // Let's try to be a bit helpful and assign an ID from template ID if none is specified\n    const paneId = this.spec.id || templateId\n    return this.clone({\n      id: paneId,\n      templateId,\n    })\n  }\n\n  /** Get initial value template item template ID\n   * @returns initial value template item ID. See {@link InitialValueTemplateItem}\n   */\n  getTemplateId(): Partial<InitialValueTemplateItem>['templateId'] {\n    return this.spec.templateId\n  }\n\n  /** Get initial value template item template parameters\n   * @param parameters - initial value template item parameters\n   * @returns initial value template item builder based on parameters provided. See {@link InitialValueTemplateItemBuilder}\n   */\n  parameters(parameters: {[key: string]: any}): InitialValueTemplateItemBuilder {\n    return this.clone({parameters})\n  }\n\n  /** Get initial value template item template parameters\n   * @returns initial value template item parameters. See {@link InitialValueTemplateItem}\n   */\n  getParameters(): Partial<InitialValueTemplateItem>['parameters'] {\n    return this.spec.parameters\n  }\n\n  /** Serialize initial value template item\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns initial value template item object based on the path, index and hint provided in options. See {@link InitialValueTemplateItem}\n   */\n  serialize({path = [], index, hint}: SerializeOptions = {path: []}): InitialValueTemplateItem {\n    const {spec, _context} = this\n    const {templates} = _context\n\n    if (typeof spec.id !== 'string' || !spec.id) {\n      throw new SerializeError(\n        '`id` is required for initial value template item nodes',\n        path,\n        index,\n        hint,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    if (!spec.templateId) {\n      throw new SerializeError(\n        'template id (`templateId`) is required for initial value template item nodes',\n        path,\n        spec.id,\n        hint,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    const template = templates.find((t) => t.id === spec.templateId)\n\n    if (!template) {\n      throw new SerializeError(\n        'template id (`templateId`) is required for initial value template item nodes',\n        path,\n        spec.id,\n        hint,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    return {\n      id: spec.id,\n      templateId: spec.id,\n      schemaType: template.schemaType,\n      type: 'initialValueTemplateItem',\n      description: spec.description || template.description,\n      title: spec.title || template.title,\n      subtitle: spec.subtitle,\n      icon: spec.icon || template.icon,\n      initialDocumentId: spec.initialDocumentId,\n      parameters: spec.parameters,\n    }\n  }\n\n  /** Clone generic view builder (allows for options overriding)\n   * @param withSpec - initial value template item builder options. See {@link InitialValueTemplateItemBuilder}\n   * @returns initial value template item builder based on the context and options provided. See {@link InitialValueTemplateItemBuilder}\n   */\n  clone(withSpec: Partial<InitialValueTemplateItem> = {}): InitialValueTemplateItemBuilder {\n    const builder = new InitialValueTemplateItemBuilder(this._context)\n    builder.spec = {...this.spec, ...withSpec}\n    return builder\n  }\n}\n\n/** @internal */\nexport function defaultInitialValueTemplateItems(\n  context: StructureContext,\n): InitialValueTemplateItemBuilder[] {\n  const {schema, getStructureBuilder, templates} = context\n\n  // Sort templates by their schema type, in order or definition\n  const typeNames = schema.getTypeNames()\n  const ordered = templates\n    // Don't list templates that require parameters\n    // TODO: this should use the new-document template items instead maybe?\n    .filter((tpl) => !tpl.parameters?.length)\n    .sort((a, b) => typeNames.indexOf(a.schemaType) - typeNames.indexOf(b.schemaType))\n\n  // Create actual template items out of the templates\n  return ordered.map((tpl) => getStructureBuilder().initialValueTemplateItem(tpl.id))\n}\n\n/** @internal */\nexport function maybeSerializeInitialValueTemplateItem(\n  item: InitialValueTemplateItem | InitialValueTemplateItemBuilder,\n  index: number,\n  path: SerializePath,\n): InitialValueTemplateItem {\n  return item instanceof InitialValueTemplateItemBuilder ? item.serialize({path, index}) : item\n}\n\n/** @internal */\nexport function menuItemsFromInitialValueTemplateItems(\n  context: StructureContext,\n  templateItems: InitialValueTemplateItem[],\n): MenuItem[] {\n  const {schema, templates} = context\n  return templateItems.map((item) => {\n    const template = templates.find((t) => t.id === item.templateId)\n    const title = item.title || template?.title || 'Create'\n\n    const params: BaseIntentParams = {}\n    if (template && template.schemaType) {\n      params.type = template.schemaType\n    }\n\n    if (item.templateId) {\n      params.template = item.templateId\n    }\n\n    const intentParams: IntentParams = item.parameters ? [params, item.parameters] : params\n    const schemaType = template && schema.get(template.schemaType)\n\n    const i18n = item.i18n || template?.i18n\n\n    let builder = new MenuItemBuilder(context)\n      .title(title)\n      .icon((template && template.icon) || schemaType?.icon || AddIcon)\n      .intent({type: 'create', params: intentParams})\n\n    if (i18n) {\n      builder = builder.i18n(i18n)\n    }\n\n    return builder.serialize()\n  })\n}\n","import {type SearchParam} from 'sanity/router'\n\nimport {getTypeNamesFromFilter, type PartialDocumentList} from './DocumentList'\nimport {type StructureNode} from './StructureNodes'\n\n/**\n * Intent parameters (json)\n *\n * @public\n */\nexport type IntentJsonParams = {[key: string]: any}\n\n/**\n * Base intent parameters\n *\n * @public\n * @todo dedupe with core\n */\nexport interface BaseIntentParams {\n  /**\n   * Document schema type name to create/edit.\n   * Required for `create` intents, optional for `edit` (but encouraged, safer and faster)\n   */\n  type?: string\n\n  /**\n   * ID of the document to create/edit.\n   * Required for `edit` intents, optional for `create`.\n   */\n  id?: string\n\n  /**\n   * Name (ID) of initial value template to use for `create` intent. Optional.\n   */\n  template?: string\n\n  /**\n   * Experimental field path\n   *\n   * @beta\n   * @experimental\n   * @hidden\n   */\n  path?: string\n\n  /**\n   * Optional \"mode\" to use for edit intent.\n   * Known modes are `structure` and `presentation`.\n   */\n  mode?: string\n\n  /**\n   * Arbitrary/custom parameters are generally discouraged - try to keep them to a minimum,\n   * or use `payload` (arbitrary JSON-serializable object) instead.\n   */\n  [key: string]: string | undefined\n}\n\n/** @internal */\nexport const DEFAULT_INTENT_HANDLER = Symbol('Document type list canHandleIntent')\n\n/**\n * Intent parameters\n * See {@link structure.BaseIntentParams} and {@link structure.IntentJsonParams}\n *\n * @public\n */\nexport type IntentParams = BaseIntentParams | [BaseIntentParams, IntentJsonParams]\n\n/**\n * Interface for intents\n * @public */\n// TODO: intents should be unified somewhere\nexport interface Intent {\n  /** Intent type */\n  type: string\n  /** Intent parameters. See {@link IntentParams}\n   */\n  params?: IntentParams\n\n  searchParams?: SearchParam[]\n}\n\n/**\n * Interface for intent checker\n *\n * @public\n */\nexport interface IntentChecker {\n  (\n    /** Intent name */\n    intentName: string,\n    /** Intent checker parameter */\n    params: {[key: string]: any},\n    /** Structure context. See {@link StructureNode} */\n    context: {pane: StructureNode; index: number},\n  ): boolean\n  /** intent checker identify */\n  identity?: symbol\n}\n\n/** @internal */\nexport const defaultIntentChecker: IntentChecker = (intentName, params, {pane}): boolean => {\n  const isEdit = intentName === 'edit'\n  const isCreate = intentName === 'create'\n  const typedSpec = pane as PartialDocumentList\n  const paneFilter = typedSpec.options?.filter || ''\n  const paneParams = typedSpec.options?.params || {}\n  const typeNames = typedSpec.schemaTypeName\n    ? [typedSpec.schemaTypeName]\n    : getTypeNamesFromFilter(paneFilter, paneParams)\n\n  const initialValueTemplates = typedSpec.initialValueTemplates || []\n\n  if (isCreate && params.template) {\n    return initialValueTemplates.some((tpl) => tpl.templateId === params.template)\n  }\n\n  return (\n    (isEdit && params.id && typeNames.includes(params.type)) ||\n    (isCreate && typeNames.includes(params.type))\n  )\n}\n\ndefaultIntentChecker.identity = DEFAULT_INTENT_HANDLER\n","export const layoutOptions = ['default', 'card', 'media', 'detail', 'block']\n","import {type I18nTextRecord, type InitialValueTemplateItem, type PreviewLayoutKey} from 'sanity'\n\nimport {\n  type InitialValueTemplateItemBuilder,\n  maybeSerializeInitialValueTemplateItem,\n} from './InitialValueTemplateItem'\nimport {defaultIntentChecker, type IntentChecker} from './Intent'\nimport {layoutOptions} from './Layout'\nimport {maybeSerializeMenuItem, type MenuItem, type MenuItemBuilder} from './MenuItem'\nimport {\n  maybeSerializeMenuItemGroup,\n  type MenuItemGroup,\n  type MenuItemGroupBuilder,\n} from './MenuItemGroup'\nimport {SerializeError} from './SerializeError'\nimport {\n  type Child,\n  type Serializable,\n  type SerializeOptions,\n  type StructureNode,\n} from './StructureNodes'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {validateId} from './util/validateId'\n\nfunction noChildResolver() {\n  return undefined\n}\n\n/** @internal */\nexport const shallowIntentChecker: IntentChecker = (intentName, params, {pane, index}): boolean => {\n  return index <= 1 && defaultIntentChecker(intentName, params, {pane, index})\n}\n\n/**\n * Interface for list display options\n *\n * @public */\nexport interface ListDisplayOptions {\n  /** Check if list display should show icons */\n  showIcons?: boolean\n}\n\n/**\n * Interface for base generic list\n *\n * @public\n */\nexport interface BaseGenericList extends StructureNode {\n  /** List layout key. */\n  defaultLayout?: PreviewLayoutKey\n  /** Can handle intent. See {@link IntentChecker} */\n  canHandleIntent?: IntentChecker\n  /** List display options. See {@link ListDisplayOptions} */\n  displayOptions?: ListDisplayOptions\n  /** List child. See {@link Child} */\n  child: Child\n  /** List initial values array. See {@link InitialValueTemplateItem} and {@link InitialValueTemplateItemBuilder} */\n  initialValueTemplates?: (InitialValueTemplateItem | InitialValueTemplateItemBuilder)[]\n}\n\n/**\n * Interface for generic list\n *\n * @public\n */\n// \"POJO\"/verbatim-version - end result\nexport interface GenericList extends BaseGenericList {\n  /** List type */\n  type: string\n  /** List menu items array. See {@link MenuItem} */\n  menuItems: MenuItem[]\n  /** List menu item groups array. See {@link MenuItemGroup} */\n  menuItemGroups: MenuItemGroup[]\n}\n\n/**\n * Interface for buildable generic list\n *\n * @public\n */\n// Used internally in builder classes to make everything optional\nexport interface BuildableGenericList extends Partial<BaseGenericList> {\n  /** List menu items array. See {@link MenuItem} and {@link MenuItemBuilder} */\n  menuItems?: (MenuItem | MenuItemBuilder)[]\n  /** List menu items groups array. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n  menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n}\n\n/**\n * Interface for generic list input\n * Allows builders and only requires things not inferrable\n *\n * @public */\n// Input version, allows builders and only requires things not inferrable\nexport interface GenericListInput extends StructureNode {\n  /** Input id */\n  id: string\n  /** Input title */\n  title: string\n  /** Input menu items groups. See {@link MenuItem} and {@link MenuItemBuilder} */\n  menuItems?: (MenuItem | MenuItemBuilder)[]\n  /** Input menu items groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder} */\n  menuItemGroups?: (MenuItemGroup | MenuItemGroupBuilder)[]\n  /** Input initial value array. See {@link InitialValueTemplateItem} and {@link InitialValueTemplateItemBuilder} */\n  initialValueTemplates?: (InitialValueTemplateItem | InitialValueTemplateItemBuilder)[]\n  /** Input default layout. */\n  defaultLayout?: PreviewLayoutKey\n  /** If input can handle intent. See {@link IntentChecker} */\n  canHandleIntent?: IntentChecker\n  /** Input child of type {@link Child} */\n  child?: Child\n}\n\n/**\n * Class for building generic lists\n *\n * @public\n */\nexport abstract class GenericListBuilder<TList extends BuildableGenericList, ConcreteImpl>\n  implements Serializable<GenericList>\n{\n  /** Check if initial value templates are set */\n  protected initialValueTemplatesSpecified = false\n  /** Generic list option object */\n  protected spec: TList = {} as TList\n\n  /** Set generic list ID\n   * @param id - generic list ID\n   * @returns generic list builder based on ID provided.\n   */\n  id(id: string): ConcreteImpl {\n    return this.clone({id})\n  }\n\n  /** Get generic list ID\n   * @returns generic list ID\n   */\n  getId(): TList['id'] {\n    return this.spec.id\n  }\n\n  /** Set generic list title\n   * @param title - generic list title\n   * @returns generic list builder based on title and ID provided.\n   */\n  title(title: string): ConcreteImpl {\n    return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n  }\n\n  /** Get generic list title\n   * @returns generic list title\n   */\n  getTitle(): TList['title'] {\n    return this.spec.title\n  }\n\n  /** Set the i18n key and namespace used to populate the localized title.\n   * @param i18n - the key and namespaced used to populate the localized title.\n   * @returns component builder based on i18n key and ns provided\n   */\n  i18n(i18n: I18nTextRecord<'title'>): ConcreteImpl {\n    return this.clone({i18n})\n  }\n\n  /** Get i18n key and namespace used to populate the localized title\n   * @returns the i18n key and namespace used to populate the localized title\n   */\n  getI18n(): TList['i18n'] {\n    return this.spec.i18n\n  }\n\n  /** Set generic list layout\n   * @param defaultLayout - generic list layout key.\n   * @returns generic list builder based on layout provided.\n   */\n  defaultLayout(defaultLayout: PreviewLayoutKey): ConcreteImpl {\n    return this.clone({defaultLayout})\n  }\n\n  /** Get generic list layout\n   * @returns generic list layout\n   */\n  getDefaultLayout(): TList['defaultLayout'] {\n    return this.spec.defaultLayout\n  }\n\n  /** Set generic list menu items\n   * @param menuItems - generic list menu items. See {@link MenuItem} and {@link MenuItemBuilder}\n   * @returns generic list builder based on menu items provided.\n   */\n  menuItems(menuItems: (MenuItem | MenuItemBuilder)[] | undefined): ConcreteImpl {\n    return this.clone({menuItems})\n  }\n\n  /** Get generic list menu items\n   * @returns generic list menu items\n   */\n  getMenuItems(): TList['menuItems'] {\n    return this.spec.menuItems\n  }\n\n  /** Set generic list menu item groups\n   * @param menuItemGroups - generic list menu item groups. See {@link MenuItemGroup} and {@link MenuItemGroupBuilder}\n   * @returns generic list builder based on menu item groups provided.\n   */\n  menuItemGroups(menuItemGroups: (MenuItemGroup | MenuItemGroupBuilder)[]): ConcreteImpl {\n    return this.clone({menuItemGroups})\n  }\n\n  /** Get generic list menu item groups\n   * @returns generic list menu item groups\n   */\n  getMenuItemGroups(): TList['menuItemGroups'] {\n    return this.spec.menuItemGroups\n  }\n\n  /** Set generic list child\n   * @param child - generic list child. See {@link Child}\n   * @returns generic list builder based on child provided (clone).\n   */\n  child(child: Child): ConcreteImpl {\n    return this.clone({child})\n  }\n\n  /** Get generic list child\n   * @returns generic list child\n   */\n  getChild(): TList['child'] {\n    return this.spec.child\n  }\n\n  /** Set generic list can handle intent\n   * @param canHandleIntent - generic list intent checker. See {@link IntentChecker}\n   * @returns generic list builder based on can handle intent provided.\n   */\n  canHandleIntent(canHandleIntent?: IntentChecker): ConcreteImpl {\n    return this.clone({canHandleIntent})\n  }\n\n  /** Get generic list can handle intent\n   * @returns generic list can handle intent\n   */\n  getCanHandleIntent(): TList['canHandleIntent'] {\n    return this.spec.canHandleIntent\n  }\n\n  /** Set generic list display options\n   * @param enabled - allow / disallow for showing icons\n   * @returns generic list builder based on display options (showIcons) provided.\n   */\n  showIcons(enabled = true): ConcreteImpl {\n    return this.clone({\n      displayOptions: {...(this.spec.displayOptions || {}), showIcons: enabled},\n    })\n  }\n\n  /** Get generic list display options\n   * @returns generic list display options (specifically showIcons)\n   */\n  getShowIcons(): boolean | undefined {\n    return this.spec.displayOptions ? this.spec.displayOptions.showIcons : undefined\n  }\n\n  /** Set generic list initial value templates\n   * @param templates - generic list initial value templates. See {@link InitialValueTemplateItemBuilder}\n   * @returns generic list builder based on templates provided.\n   */\n  initialValueTemplates(\n    templates:\n      | InitialValueTemplateItem\n      | InitialValueTemplateItemBuilder\n      | Array<InitialValueTemplateItem | InitialValueTemplateItemBuilder>,\n  ): ConcreteImpl {\n    this.initialValueTemplatesSpecified = true\n    return this.clone({initialValueTemplates: Array.isArray(templates) ? templates : [templates]})\n  }\n\n  /** Get generic list initial value templates\n   * @returns generic list initial value templates\n   */\n  getInitialValueTemplates(): TList['initialValueTemplates'] {\n    return this.spec.initialValueTemplates\n  }\n\n  /** Serialize generic list\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns generic list object based on path provided in options. See {@link GenericList}\n   */\n  serialize(options: SerializeOptions = {path: []}): GenericList {\n    const id = this.spec.id || ''\n    const path = options.path\n\n    const defaultLayout = this.spec.defaultLayout\n    if (defaultLayout && !layoutOptions.includes(defaultLayout)) {\n      throw new SerializeError(\n        `\\`layout\\` must be one of ${layoutOptions.map((item) => `\"${item}\"`).join(', ')}`,\n        path,\n        id || options.index,\n        this.spec.title,\n      )\n    }\n\n    const initialValueTemplates = (this.spec.initialValueTemplates || []).map((item, i) =>\n      maybeSerializeInitialValueTemplateItem(item, i, path),\n    )\n\n    return {\n      id: validateId(id, options.path, id || options.index),\n      title: this.spec.title,\n      i18n: this.spec.i18n,\n      type: 'genericList',\n      defaultLayout,\n      child: this.spec.child || noChildResolver,\n      canHandleIntent: this.spec.canHandleIntent || shallowIntentChecker,\n      displayOptions: this.spec.displayOptions,\n      initialValueTemplates,\n      menuItems: (this.spec.menuItems || []).map((item, i) =>\n        maybeSerializeMenuItem(item, i, path),\n      ),\n      menuItemGroups: (this.spec.menuItemGroups || []).map((item, i) =>\n        maybeSerializeMenuItemGroup(item, i, path),\n      ),\n    }\n  }\n\n  /** Clone generic list builder (allows for options overriding)\n   * @param _withSpec - generic list options.\n   * @returns generic list builder.\n   */\n  abstract clone(_withSpec?: object): ConcreteImpl\n}\n","import {generateHelpUrl} from '@sanity/generate-help-url'\nimport {AddIcon} from '@sanity/icons'\nimport {type SchemaType, type SortOrderingItem} from '@sanity/types'\nimport {DEFAULT_STUDIO_CLIENT_OPTIONS, type InitialValueTemplateItem} from 'sanity'\n\nimport {type ChildResolver, type ChildResolverOptions, type ItemChild} from './ChildResolver'\nimport {DocumentBuilder} from './Document'\nimport {\n  type BuildableGenericList,\n  type GenericList,\n  GenericListBuilder,\n  type GenericListInput,\n} from './GenericList'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Child, type SerializeOptions} from './StructureNodes'\nimport {type StructureContext} from './types'\nimport {resolveTypeForDocument} from './util/resolveTypeForDocument'\n\nconst validateFilter = (spec: PartialDocumentList, options: SerializeOptions) => {\n  const filter = spec.options?.filter.trim() || ''\n\n  if (['*', '{'].includes(filter[0])) {\n    throw new SerializeError(\n      `\\`filter\\` cannot start with \\`${filter[0]}\\` - looks like you are providing a query, not a filter`,\n      options.path,\n      spec.id,\n      spec.title,\n    ).withHelpUrl(HELP_URL.QUERY_PROVIDED_FOR_FILTER)\n  }\n\n  return filter\n}\n\nconst createDocumentChildResolverForItem =\n  (context: StructureContext): ChildResolver =>\n  (itemId: string, options: ChildResolverOptions): ItemChild | Promise<ItemChild> | undefined => {\n    const parentItem = options.parent as DocumentList\n    const template = options.params?.template\n      ? context.templates.find((tpl) => tpl.id === options.params.template)\n      : undefined\n    const type = template\n      ? template.schemaType\n      : parentItem.schemaTypeName || resolveTypeForDocument(context.getClient, itemId)\n\n    return Promise.resolve(type).then((schemaType) =>\n      schemaType\n        ? context.resolveDocumentNode({schemaType, documentId: itemId})\n        : new DocumentBuilder(context).id('editor').documentId(itemId).schemaType(''),\n    )\n  }\n\n/**\n * Partial document list\n *\n * @public\n */\nexport interface PartialDocumentList extends BuildableGenericList {\n  /** Document list options. See {@link DocumentListOptions} */\n  options?: DocumentListOptions\n  /** Schema type name */\n  schemaTypeName?: string\n}\n\n/**\n * Interface for document list input\n *\n * @public\n */\nexport interface DocumentListInput extends GenericListInput {\n  /** Document list options. See {@link DocumentListOptions} */\n  options: DocumentListOptions\n}\n\n/**\n * Interface for document list\n *\n * @public\n */\nexport interface DocumentList extends GenericList {\n  type: 'documentList'\n  /** Document list options. See {@link DocumentListOptions} */\n  options: DocumentListOptions\n  /** Document list child. See {@link Child} */\n  child: Child\n  /** Document schema type name */\n  schemaTypeName?: string\n}\n\n/**\n * Interface for document List options\n *\n * @public\n */\nexport interface DocumentListOptions {\n  /** Document list filter */\n  filter: string\n  /** Document list parameters */\n  params?: Record<string, unknown>\n  /** Document list API version */\n  apiVersion?: string\n  /** Document list API default ordering array. */\n  defaultOrdering?: SortOrderingItem[]\n}\n\n/**\n * Class for building document list\n *\n * @public\n */\nexport class DocumentListBuilder extends GenericListBuilder<\n  PartialDocumentList,\n  DocumentListBuilder\n> {\n  /** Document list options. See {@link PartialDocumentList} */\n  protected spec: PartialDocumentList\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: DocumentListInput,\n  ) {\n    super()\n    this.spec = spec || {}\n    this.initialValueTemplatesSpecified = Boolean(spec?.initialValueTemplates)\n  }\n\n  /** Set API version\n   * @param apiVersion - API version\n   * @returns document list builder based on the options and API version provided. See {@link DocumentListBuilder}\n   */\n  apiVersion(apiVersion: string): DocumentListBuilder {\n    return this.clone({options: {...(this.spec.options || {filter: ''}), apiVersion}})\n  }\n\n  /** Get API version\n   * @returns API version\n   */\n  getApiVersion(): string | undefined {\n    return this.spec.options?.apiVersion\n  }\n\n  /** Set Document list filter\n   * @param filter - GROQ-filter used to determine which documents to display. Do not support joins, since they operate on individual documents, and will ignore order-clauses and projections. See {@link https://www.sanity.io/docs/realtime-updates}\n   * @returns document list builder based on the options and filter provided. See {@link DocumentListBuilder}\n   */\n  filter(filter: string): DocumentListBuilder {\n    return this.clone({options: {...(this.spec.options || {}), filter}})\n  }\n\n  /** Get Document list filter\n   * @returns filter\n   */\n  getFilter(): string | undefined {\n    return this.spec.options?.filter\n  }\n\n  /** Set Document list schema type name\n   * @param type - schema type name.\n   * @returns document list builder based on the schema type name provided. See {@link DocumentListBuilder}\n   */\n  schemaType(type: SchemaType | string): DocumentListBuilder {\n    const schemaTypeName = typeof type === 'string' ? type : type.name\n    return this.clone({schemaTypeName})\n  }\n\n  /** Get Document list schema type name\n   * @returns schema type name\n   */\n  getSchemaType(): string | undefined {\n    return this.spec.schemaTypeName\n  }\n\n  /** Set Document list options' parameters\n   * @param params - parameters\n   * @returns document list builder based on the options provided. See {@link DocumentListBuilder}\n   */\n  params(params: Record<string, unknown>): DocumentListBuilder {\n    return this.clone({\n      options: {...(this.spec.options || {filter: ''}), params},\n    })\n  }\n\n  /** Get Document list options' parameters\n   * @returns options\n   */\n  getParams(): Record<string, unknown> | undefined {\n    return this.spec.options?.params\n  }\n\n  /** Set Document list default ordering\n   * @param ordering - default sort ordering array. See {@link SortOrderingItem}\n   * @returns document list builder based on ordering provided. See {@link DocumentListBuilder}\n   */\n  defaultOrdering(ordering: SortOrderingItem[]): DocumentListBuilder {\n    if (!Array.isArray(ordering)) {\n      throw new Error('`defaultOrdering` must be an array of order clauses')\n    }\n\n    return this.clone({\n      options: {...(this.spec.options || {filter: ''}), defaultOrdering: ordering},\n    })\n  }\n\n  /** Get Document list default ordering\n   * @returns default ordering. See {@link SortOrderingItem}\n   */\n  getDefaultOrdering(): SortOrderingItem[] | undefined {\n    return this.spec.options?.defaultOrdering\n  }\n\n  /** Serialize Document list\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns document list object based on path provided in options. See {@link DocumentList}\n   */\n  serialize(options: SerializeOptions = {path: []}): DocumentList {\n    if (typeof this.spec.id !== 'string' || !this.spec.id) {\n      throw new SerializeError(\n        '`id` is required for document lists',\n        options.path,\n        options.index,\n        this.spec.title,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    if (!this.spec.options || !this.spec.options.filter) {\n      throw new SerializeError(\n        '`filter` is required for document lists',\n        options.path,\n        this.spec.id,\n        this.spec.title,\n      ).withHelpUrl(HELP_URL.FILTER_REQUIRED)\n    }\n\n    const hasSimpleFilter = this.spec.options?.filter === '_type == $type'\n    if (!hasSimpleFilter && this.spec.options.filter && !this.spec.options.apiVersion) {\n      console.warn(\n        `No apiVersion specified for document type list with custom filter: \\`${this.spec.options.filter}\\`. This will be required in the future. See %s for more info.`,\n        generateHelpUrl(HELP_URL.API_VERSION_REQUIRED_FOR_CUSTOM_FILTER),\n      )\n    }\n    return {\n      ...super.serialize(options),\n      type: 'documentList',\n      schemaTypeName: this.spec.schemaTypeName,\n      child: this.spec.child || createDocumentChildResolverForItem(this._context),\n      options: {\n        ...this.spec.options,\n        // @todo: make specifying .apiVersion required when using custom (non-simple) filters in v4\n        apiVersion: this.spec.options.apiVersion || DEFAULT_STUDIO_CLIENT_OPTIONS.apiVersion,\n        filter: validateFilter(this.spec, options),\n      },\n    }\n  }\n\n  /** Clone Document list builder (allows for options overriding)\n   * @param withSpec - override document list spec. See {@link PartialDocumentList}\n   * @returns document list builder. See {@link DocumentListBuilder}\n   */\n  clone(withSpec?: PartialDocumentList): DocumentListBuilder {\n    const builder = new DocumentListBuilder(this._context)\n    builder.spec = {...this.spec, ...(withSpec || {})}\n\n    if (!this.initialValueTemplatesSpecified) {\n      builder.spec.initialValueTemplates = inferInitialValueTemplates(this._context, builder.spec)\n    }\n\n    if (!builder.spec.schemaTypeName) {\n      builder.spec.schemaTypeName = inferTypeName(builder.spec)\n    }\n\n    return builder\n  }\n\n  /** Get Document list spec\n   * @returns document list spec. See {@link PartialDocumentList}\n   */\n  getSpec(): PartialDocumentList {\n    return this.spec\n  }\n}\n\nfunction inferInitialValueTemplates(\n  context: StructureContext,\n  spec: PartialDocumentList,\n): InitialValueTemplateItem[] | undefined {\n  const {document} = context\n  const {schemaTypeName, options} = spec\n  const {filter, params} = options || {filter: '', params: {}}\n  const typeNames = schemaTypeName\n    ? [schemaTypeName]\n    : Array.from(new Set(getTypeNamesFromFilter(filter, params)))\n\n  if (typeNames.length === 0) {\n    return undefined\n  }\n\n  return typeNames\n    .flatMap((schemaType) =>\n      document.resolveNewDocumentOptions({\n        type: 'structure',\n        schemaType,\n      }),\n    )\n    .map((option) => ({...option, icon: AddIcon}))\n}\n\nfunction inferTypeName(spec: PartialDocumentList): string | undefined {\n  const {options} = spec\n  const {filter, params} = options || {filter: '', params: {}}\n  const typeNames = getTypeNamesFromFilter(filter, params)\n  return typeNames.length === 1 ? typeNames[0] : undefined\n}\n\n/** @internal */\nexport function getTypeNamesFromFilter(\n  filter: string,\n  params: Record<string, unknown> = {},\n): string[] {\n  let typeNames = getTypeNamesFromEqualityFilter(filter, params)\n\n  if (typeNames.length === 0) {\n    typeNames = getTypeNamesFromInTypesFilter(filter, params)\n  }\n\n  return typeNames\n}\n\n// From _type == \"movie\" || _type == $otherType\nfunction getTypeNamesFromEqualityFilter(\n  filter: string,\n  params: Record<string, unknown> = {},\n): string[] {\n  const pattern =\n    /\\b_type\\s*==\\s*(['\"].*?['\"]|\\$.*?(?:\\s|$))|\\B(['\"].*?['\"]|\\$.*?(?:\\s|$))\\s*==\\s*_type/g\n  const matches: string[] = []\n  let match\n  while ((match = pattern.exec(filter)) !== null) {\n    matches.push(match[1] || match[2])\n  }\n\n  return matches\n    .map((candidate) => {\n      const typeName = candidate[0] === '$' ? params[candidate.slice(1)] : candidate\n      const normalized = ((typeName as string) || '').trim().replace(/^[\"']|[\"']$/g, '')\n      return normalized\n    })\n    .filter(Boolean)\n}\n\n// From _type in [\"dog\", \"cat\", $otherSpecies]\nfunction getTypeNamesFromInTypesFilter(\n  filter: string,\n  params: Record<string, unknown> = {},\n): string[] {\n  const pattern = /\\b_type\\s+in\\s+\\[(.*?)\\]/\n  const matches = filter.match(pattern)\n  if (!matches) {\n    return []\n  }\n\n  return matches[1]\n    .split(/,\\s*/)\n    .map((match) => match.trim().replace(/^[\"']+|[\"']+$/g, ''))\n    .map((item) => (item[0] === '$' ? params[item.slice(1)] : item))\n    .filter(Boolean) as string[]\n}\n","import {find} from 'lodash'\nimport {isRecord} from 'sanity'\n\nimport {type ChildResolver, type ChildResolverOptions} from './ChildResolver'\nimport {isDocumentListItem} from './DocumentListItem'\nimport {\n  type BuildableGenericList,\n  type GenericList,\n  GenericListBuilder,\n  type GenericListInput,\n  shallowIntentChecker,\n} from './GenericList'\nimport {type IntentChecker} from './Intent'\nimport {type ListItem, ListItemBuilder} from './ListItem'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type Divider, type SerializeOptions, type SerializePath} from './StructureNodes'\nimport {type StructureContext} from './types'\n\nconst getArgType = (thing: ListItem) => {\n  if (thing instanceof ListBuilder) {\n    return 'ListBuilder'\n  }\n\n  if (isPromise<ListItem>(thing)) {\n    return 'Promise'\n  }\n\n  return Array.isArray(thing) ? 'array' : typeof thing\n}\n\nconst isListItem = (item: ListItem | Divider): item is ListItem => {\n  return item.type === 'listItem'\n}\n\nconst defaultCanHandleIntent: IntentChecker = (intentName: string, params, context) => {\n  const pane = context.pane as List\n  const items = pane.items || []\n  return (\n    items\n      .filter(isDocumentListItem)\n      .some((item) => item.schemaType.name === params.type && item._id === params.id) ||\n    shallowIntentChecker(intentName, params, context)\n  )\n}\n\nconst resolveChildForItem: ChildResolver = (itemId: string, options: ChildResolverOptions) => {\n  const parentItem = options.parent as List\n  const items = parentItem.items.filter(isListItem)\n  const target = (items.find((item) => item.id === itemId) || {child: undefined}).child\n\n  if (!target || typeof target !== 'function') {\n    return target\n  }\n\n  return typeof target === 'function' ? target(itemId, options) : target\n}\n\nfunction maybeSerializeListItem(\n  item: ListItem | ListItemBuilder | Divider,\n  index: number,\n  path: SerializePath,\n): ListItem | Divider {\n  if (item instanceof ListItemBuilder) {\n    return item.serialize({path, index})\n  }\n\n  const listItem = item as ListItem\n  if (listItem && listItem.type === 'divider') {\n    return item as Divider\n  }\n\n  if (!listItem || listItem.type !== 'listItem') {\n    const gotWhat = (listItem && listItem.type) || getArgType(listItem)\n    const helpText = gotWhat === 'array' ? ' - did you forget to spread (...moreItems)?' : ''\n    throw new SerializeError(\n      `List items must be of type \"listItem\", got \"${gotWhat}\"${helpText}`,\n      path,\n      index,\n    ).withHelpUrl(HELP_URL.INVALID_LIST_ITEM)\n  }\n\n  return item\n}\n\nfunction isPromise<T>(thing: unknown): thing is PromiseLike<T> {\n  return isRecord(thing) && typeof thing.then === 'function'\n}\n\n/**\n * Interface for List\n *\n * @public\n */\nexport interface List extends GenericList {\n  type: 'list'\n  /** List items. See {@link ListItem} and {@link Divider} */\n  items: (ListItem | Divider)[]\n}\n\n/**\n * Interface for list input\n *\n * @public\n */\nexport interface ListInput extends GenericListInput {\n  /** List input items array. See {@link ListItem}, {@link ListItemBuilder} and {@link Divider} */\n  items?: (ListItem | ListItemBuilder | Divider)[]\n}\n\n/**\n * Interface for buildable list\n *\n * @public\n */\nexport interface BuildableList extends BuildableGenericList {\n  /** List items. See {@link ListItem}, {@link ListItemBuilder} and {@link Divider} */\n  items?: (ListItem | ListItemBuilder | Divider)[]\n}\n\n/**\n * A `ListBuilder` is used to build a list of items in the structure tool.\n *\n * @public */\nexport class ListBuilder extends GenericListBuilder<BuildableList, ListBuilder> {\n  /** buildable list option object. See {@link BuildableList} */\n  protected spec: BuildableList\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: ListInput,\n  ) {\n    super()\n    this.spec = spec ? spec : {}\n    this.initialValueTemplatesSpecified = Boolean(spec && spec.initialValueTemplates)\n  }\n\n  /**\n   * Set list builder based on items provided\n   * @param items - list items. See {@link ListItemBuilder}, {@link ListItem} and {@link Divider}\n   * @returns list builder based on items provided. See {@link ListBuilder}\n   */\n  items(items: (ListItemBuilder | ListItem | Divider)[]): ListBuilder {\n    return this.clone({items})\n  }\n\n  /** Get list builder items\n   * @returns list items. See {@link BuildableList}\n   */\n  getItems(): BuildableList['items'] {\n    return this.spec.items\n  }\n\n  /** Serialize list builder\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns list based on path in options. See {@link List}\n   */\n  serialize(options: SerializeOptions = {path: []}): List {\n    const id = this.spec.id\n    if (typeof id !== 'string' || !id) {\n      throw new SerializeError(\n        '`id` is required for lists',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    const items = typeof this.spec.items === 'undefined' ? [] : this.spec.items\n    if (!Array.isArray(items)) {\n      throw new SerializeError(\n        '`items` must be an array of items',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.LIST_ITEMS_MUST_BE_ARRAY)\n    }\n\n    const path = (options.path || []).concat(id)\n    const serializedItems = items.map((item, index) => maybeSerializeListItem(item, index, path))\n    const dupes = serializedItems.filter((val, i) => find(serializedItems, {id: val.id}, i + 1))\n\n    if (dupes.length > 0) {\n      const dupeIds = dupes.map((item) => item.id).slice(0, 5)\n      const dupeDesc = dupes.length > 5 ? `${dupeIds.join(', ')}...` : dupeIds.join(', ')\n      throw new SerializeError(\n        `List items with same ID found (${dupeDesc})`,\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.LIST_ITEM_IDS_MUST_BE_UNIQUE)\n    }\n\n    return {\n      ...super.serialize(options),\n      type: 'list',\n      canHandleIntent: this.spec.canHandleIntent || defaultCanHandleIntent,\n      child: this.spec.child || resolveChildForItem,\n      items: serializedItems,\n    }\n  }\n\n  /**\n   * Clone list builder and return new list builder based on context and spec provided\n   * @param withSpec - list options. See {@link BuildableList}\n   * @returns new list builder based on context and spec provided. See {@link ListBuilder}\n   */\n  clone(withSpec?: BuildableList): ListBuilder {\n    const builder = new ListBuilder(this._context)\n    builder.spec = {...this.spec, ...(withSpec || {})}\n    return builder\n  }\n}\n","import {type SchemaType} from '@sanity/types'\nimport {type Observable} from 'rxjs'\nimport {type I18nTextRecord} from 'sanity'\n\nimport {type ChildResolver, type ItemChild} from './ChildResolver'\nimport {ComponentBuilder} from './Component'\nimport {DocumentBuilder} from './Document'\nimport {DocumentListBuilder} from './DocumentList'\nimport {ListBuilder} from './List'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {\n  type Collection,\n  type CollectionBuilder,\n  type Serializable,\n  type SerializeOptions,\n} from './StructureNodes'\nimport {type StructureContext} from './types'\nimport {getStructureNodeId} from './util/getStructureNodeId'\nimport {validateId} from './util/validateId'\n\n/**\n * Unserialized list item child.\n * See {@link Collection}, {@link CollectionBuilder}, {@link ChildResolver} and {@link ItemChild}\n *\n * @public\n */\nexport type UnserializedListItemChild =\n  | Collection\n  | CollectionBuilder\n  | ChildResolver\n  | Observable<ItemChild>\n\n/**\n * Child of List Item\n * See {@link Collection}, {@link ChildResolver}, {@link ItemChild}\n * @public\n */\nexport type ListItemChild = Collection | ChildResolver | Observable<ItemChild> | undefined\n\n/**\n * Interface for serialize list item options\n *\n * @public\n */\nexport interface ListItemSerializeOptions extends SerializeOptions {\n  /** Check if list item title is optional */\n  titleIsOptional?: boolean\n}\n\n/**\n * Interface for ist item display options\n *\n * @public */\nexport interface ListItemDisplayOptions {\n  /** Check if list item display should show icon */\n  showIcon?: boolean\n}\n\n/**\n * interface for list item input\n *\n * @public */\nexport interface ListItemInput {\n  /** List item id */\n  id: string\n  /** List item title */\n  title?: string\n  /** List item icon */\n  icon?: React.ComponentType | React.ReactNode\n  /** List item child. See {@link ListItemChild} */\n  child?: ListItemChild\n  /** List item display options. See {@link ListItemDisplayOptions} */\n  displayOptions?: ListItemDisplayOptions\n  /** List item schema type. See {@link SchemaType} */\n  schemaType?: SchemaType | string\n}\n\n/**\n * Interface for List Item\n *\n * @public */\nexport interface ListItem {\n  /** List item id */\n  id: string\n  /** List item type */\n  type: string\n  /**\n   * The i18n key and namespace used to populate the localized title. This is\n   * the recommend way to set the title if you are localizing your studio.\n   */\n  i18n?: I18nTextRecord<'title'>\n  /** List item title. Note that the `i18n` key and namespace will take precedence. */\n  title?: string\n  /** List item icon */\n  icon?: React.ComponentType | React.ReactNode\n  /** List item child. See {@link ListItemChild} */\n  child?: ListItemChild\n  /** List item display options. See {@link ListItemDisplayOptions} */\n  displayOptions?: ListItemDisplayOptions\n  /** List item schema type. See {@link SchemaType} */\n  schemaType?: SchemaType\n}\n\n/**\n * Interface for unserialized list items.\n *\n * @public\n */\nexport interface UnserializedListItem {\n  /** List item ID */\n  id: string\n  /** List item title */\n  title: string\n  /**\n   * The i18n key and namespace used to populate the localized title. This is\n   * the recommend way to set the title if you are localizing your studio.\n   */\n  i18n?: I18nTextRecord<'title'>\n  /** List item icon */\n  icon?: React.ComponentType | React.ReactNode\n  /** List item child. See {@link UnserializedListItemChild} */\n  child?: UnserializedListItemChild\n  /** List item display options. See {@link ListItemDisplayOptions} */\n  displayOptions?: ListItemDisplayOptions\n  /** List item schema. See {@link SchemaType} */\n  schemaType?: SchemaType | string\n}\n\n/**\n * Partial list item. See {@link UnserializedListItem}\n *\n * @public */\nexport type PartialListItem = Partial<UnserializedListItem>\n\n/**\n * Class for building list items\n *\n * @public */\nexport class ListItemBuilder implements Serializable<ListItem> {\n  /** List item option object. See {@link PartialListItem} */\n  protected spec: PartialListItem\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: ListItemInput,\n  ) {\n    this.spec = spec ? spec : {}\n  }\n\n  /**\n   * Set list item ID\n   * @returns list item builder based on ID provided. See {@link ListItemBuilder}\n   */\n  id(id: string): ListItemBuilder {\n    return this.clone({id})\n  }\n\n  /**\n   * Get list item ID\n   * @returns list item ID. See {@link PartialListItem}\n   */\n  getId(): PartialListItem['id'] {\n    return this.spec.id\n  }\n\n  /**\n   * Set list item title\n   * @returns list item builder based on title provided. See {@link ListItemBuilder}\n   */\n  title(title: string): ListItemBuilder {\n    return this.clone({title, id: getStructureNodeId(title, this.spec.id)})\n  }\n\n  /**\n   * Get list item title\n   * @returns list item title. See {@link PartialListItem}\n   */\n  getTitle(): PartialListItem['title'] {\n    return this.spec.title\n  }\n\n  /** Set the i18n key and namespace used to populate the localized title.\n   * @param i18n - the key and namespaced used to populate the localized title.\n   * @returns component builder based on i18n key and ns provided\n   */\n  i18n(i18n: I18nTextRecord<'title'>): ListItemBuilder {\n    return this.clone({i18n})\n  }\n\n  /** Get i18n key and namespace used to populate the localized title\n   * @returns the i18n key and namespace used to populate the localized title\n   */\n  getI18n(): I18nTextRecord<'title'> | undefined {\n    return this.spec.i18n\n  }\n\n  /**\n   * Set list item icon\n   * @returns list item builder based on icon provided. See {@link ListItemBuilder}\n   */\n  icon(icon: React.ComponentType | React.ReactNode): ListItemBuilder {\n    return this.clone({icon})\n  }\n\n  /**\n   * Set if list item should show icon\n   * @returns list item builder based on showIcon provided. See {@link ListItemBuilder}\n   */\n  showIcon(enabled = true): ListItemBuilder {\n    return this.clone({\n      displayOptions: {...(this.spec.displayOptions || {}), showIcon: enabled},\n    })\n  }\n\n  /**\n   * Check if list item should show icon\n   * @returns true if it should show the icon, false if not, undefined if not set\n   */\n  getShowIcon(): boolean | undefined {\n    return this.spec.displayOptions ? this.spec.displayOptions.showIcon : undefined\n  }\n\n  /**\n   *Get list item icon\n   * @returns list item icon. See {@link PartialListItem}\n   */\n  getIcon(): PartialListItem['icon'] {\n    return this.spec.icon\n  }\n\n  /**\n   * Set list item child\n   * @param child - list item child. See {@link UnserializedListItemChild}\n   * @returns list item builder based on child provided. See {@link ListItemBuilder}\n   */\n  child(child: UnserializedListItemChild): ListItemBuilder {\n    return this.clone({child})\n  }\n\n  /**\n   * Get list item child\n   * @returns list item child. See {@link PartialListItem}\n   */\n  getChild(): PartialListItem['child'] {\n    return this.spec.child\n  }\n\n  /**\n   * Set list item schema type\n   * @param schemaType - list item schema type. See {@link SchemaType}\n   * @returns list item builder based on schema type provided. See {@link ListItemBuilder}\n   */\n  schemaType(schemaType: SchemaType | string): ListItemBuilder {\n    return this.clone({schemaType})\n  }\n\n  /**\n   * Get list item schema type\n   * @returns list item schema type. See {@link PartialListItem}\n   */\n  getSchemaType(): PartialListItem['schemaType'] {\n    const schemaType = this.spec.schemaType\n\n    if (typeof schemaType === 'string') {\n      return this._context.schema.get(schemaType)\n    }\n\n    return this.spec.schemaType\n  }\n\n  /** Serialize list item builder\n   * @param options - serialization options. See {@link ListItemSerializeOptions}\n   * @returns list item node based on path provided in options. See {@link ListItem}\n   */\n  serialize(options: ListItemSerializeOptions = {path: []}): ListItem {\n    const {id, title, child} = this.spec\n    if (typeof id !== 'string' || !id) {\n      throw new SerializeError(\n        '`id` is required for list items',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.ID_REQUIRED)\n    }\n\n    if (!options.titleIsOptional && (typeof title !== 'string' || !title)) {\n      throw new SerializeError('`title` is required for list items', options.path, id).withHelpUrl(\n        HELP_URL.TITLE_REQUIRED,\n      )\n    }\n\n    let schemaType = this.spec.schemaType\n    if (typeof schemaType === 'string') {\n      const type = this._context.schema.get(schemaType)\n      if (!type) {\n        throw new SerializeError(\n          `Could not find type \"${schemaType}\" in schema`,\n          options.path,\n          id,\n        ).withHelpUrl(HELP_URL.SCHEMA_TYPE_NOT_FOUND)\n      }\n\n      schemaType = type\n    }\n\n    const serializeOptions = {path: options.path.concat(id), hint: 'child'}\n    let listChild =\n      child instanceof ComponentBuilder ||\n      child instanceof DocumentListBuilder ||\n      child instanceof DocumentBuilder ||\n      child instanceof ListBuilder\n        ? child.serialize(serializeOptions)\n        : child\n\n    // In the case of a function, create a bound version that will pass the correct serialize\n    // context, so we may lazily resolve it at some point in the future without losing context\n    if (typeof listChild === 'function') {\n      const originalChild = listChild\n      listChild = (itemId, childOptions) => {\n        return originalChild(itemId, {...childOptions, serializeOptions})\n      }\n    }\n\n    return {\n      ...this.spec,\n      id: validateId(id, options.path, options.index),\n      schemaType,\n      child: listChild,\n      title,\n      type: 'listItem',\n    }\n  }\n\n  /** Clone list item builder\n   * @param withSpec - partial list item options. See {@link PartialListItem}\n   * @returns list item builder based on context and spec provided. See {@link ListItemBuilder}\n   */\n  clone(withSpec?: PartialListItem): ListItemBuilder {\n    const builder = new ListItemBuilder(this._context)\n    builder.spec = {...this.spec, ...(withSpec || {})}\n    return builder\n  }\n}\n","import {type SchemaType} from '@sanity/types'\nimport {isRecord} from 'sanity'\n\nimport {DocumentBuilder} from './Document'\nimport {\n  type ListItem,\n  ListItemBuilder,\n  type ListItemInput,\n  type UnserializedListItem,\n} from './ListItem'\nimport {HELP_URL, SerializeError} from './SerializeError'\nimport {type SerializeOptions} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/**\n * Interface for document list item input\n *\n * @public\n */\nexport interface DocumentListItemInput extends ListItemInput {\n  /** Document list item input schema type. See {@link SchemaType} */\n  schemaType: SchemaType | string\n}\n\n/**\n * Interface for document list item\n *\n * @public\n */\nexport interface DocumentListItem extends ListItem {\n  /** Document schema type. See {@link SchemaType} */\n  schemaType: SchemaType\n  /** Document ID */\n  _id: string\n}\n\n/**\n * Partial document list item\n *\n * @public\n */\nexport type PartialDocumentListItem = Partial<UnserializedListItem>\n\nconst createDefaultChildResolver =\n  (context: StructureContext, spec: PartialDocumentListItem) => (documentId: string) => {\n    const schemaType =\n      spec.schemaType &&\n      (typeof spec.schemaType === 'string' ? spec.schemaType : spec.schemaType.name)\n\n    return schemaType\n      ? context.resolveDocumentNode({schemaType, documentId})\n      : new DocumentBuilder(context).id('documentEditor').documentId(documentId)\n  }\n\n/**\n * Class for building a document list item\n *\n * @public\n */\nexport class DocumentListItemBuilder extends ListItemBuilder {\n  /** Document list options. See {@link PartialDocumentListItem} */\n  protected spec: PartialDocumentListItem\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: DocumentListItemInput,\n  ) {\n    super(_context, spec)\n    this.spec = spec ? spec : {}\n  }\n\n  /**\n   * Serialize document list item\n   * @param options - serialization options. See {@link SerializeOptions}\n   * @returns document list item object based on path provided in options. See {@link DocumentListItem}\n   */\n  serialize(options: SerializeOptions = {path: []}): DocumentListItem {\n    const spec = super.serialize({...options, titleIsOptional: true})\n\n    if (!spec.schemaType) {\n      throw new SerializeError(\n        '`schemaType` is required for document list items',\n        options.path,\n        options.index,\n      ).withHelpUrl(HELP_URL.SCHEMA_TYPE_REQUIRED)\n    }\n\n    const child = spec.child || createDefaultChildResolver(this._context, spec)\n    return {...spec, child, schemaType: spec.schemaType, _id: spec.id}\n  }\n\n  /** Clone Document list item builder (allows for options overriding)\n   * @param withSpec - Document list item builder options. See {@link PartialDocumentListItem}\n   * @returns document list item builder. See {@link DocumentListItemBuilder}\n   */\n  clone(withSpec?: PartialDocumentListItem): DocumentListItemBuilder {\n    const builder = new DocumentListItemBuilder(this._context)\n    builder.spec = {...this.spec, ...(withSpec || {})}\n    return builder\n  }\n}\n\n/** @internal */\nexport function isDocumentListItem(item: unknown): item is DocumentListItem {\n  return isRecord(item) && typeof item.schemaType !== 'undefined' && typeof item._id === 'string'\n}\n","import {type SchemaType} from '@sanity/types'\n\nimport {DocumentListBuilder, type DocumentListInput, type PartialDocumentList} from './DocumentList'\nimport {type GenericListInput} from './GenericList'\nimport {DEFAULT_INTENT_HANDLER} from './Intent'\nimport {type Child} from './StructureNodes'\nimport {type StructureContext} from './types'\n\n/**\n * Interface for document type list input\n *\n * @public\n */\nexport interface DocumentTypeListInput extends Partial<GenericListInput> {\n  /** Document type list input schema type. See {@link SchemaType} */\n  schemaType: SchemaType | string\n}\n\n/**\n * Class for building a document type list\n *\n * @public\n */\nexport class DocumentTypeListBuilder extends DocumentListBuilder {\n  /** Document list options. See {@link PartialDocumentList} */\n  protected spec: PartialDocumentList\n\n  constructor(\n    /**\n     * Structure context. See {@link StructureContext}\n     */\n    protected _context: StructureContext,\n    spec?: DocumentListInput,\n  ) {\n    super(_context)\n    this.spec = spec ? spec : {}\n  }\n\n  /**\n   * Set Document type list child\n   * @param child - Child component. See {@link Child}\n   * @returns document type list builder based on child component provided without default intent handler. See {@link DocumentTypeListBuilder}\n   */\n  child(child: Child): DocumentTypeListBuilder {\n    return this.cloneWithoutDefaultIntentHandler({child})\n  }\n\n  /** Clone Document type list builder (allows for options overriding)\n   * @param withSpec - Document type list builder options. See {@link PartialDocumentList}\n   * @returns document type list builder. See {@link DocumentTypeListBuilder}\n   */\n  clone(withSpec?: PartialDocumentList): DocumentTypeListBuilder {\n    const parent = super.clone(withSpec)\n    const builder = new DocumentTypeListBuilder(this._context)\n    builder.spec = {...this.spec, ...parent.getSpec(), ...(withSpec || {})}\n    return builder\n  }\n\n  /** Clone Document type list builder (allows for options overriding) and remove default intent handler\n   * @param withSpec - Document type list builder options. See {@link PartialDocumentList}\n   * @returns document type list builder without default intent handler. See {@link DocumentTypeListBuilder}\n   */\n  cloneWithoutDefaultIntentHandler(withSpec?: PartialDocumentList): DocumentTypeListBuilder {\n    const parent = super.clone(withSpec)\n    const builder = new DocumentTypeListBuilder(this._context)\n    const canHandleIntent = this.spec.canHandleIntent\n    const shouldOverride = canHandleIntent && canHandleIntent.identity === DEFAULT_INTENT_HANDLER\n    const override = shouldOverride ? {canHandleIntent: undefined} : {}\n    builder.spec = {\n      ...parent.getSpec(),\n      ...this.spec,\n      ...(withSpec || {}),\n      ...override,\n    }\n    return builder\n  }\n}\n","import {StackCompactIcon, StackIcon} from '@sanity/icons'\nimport {type SchemaType} from '@sanity/types'\nimport {startCase} from 'lodash'\n\nimport {structureLocaleNamespace} from '../i18n'\nimport {type DocumentListBuilder} from './DocumentList'\nimport {DocumentTypeListBuilder, type DocumentTypeListInput} from './DocumentTypeList'\nimport {defaultIntentChecker} from './Intent'\nimport {type List} from './List'\nimport {type ListItem, ListItemBuilder} from './ListItem'\nimport {getOrderingMenuItemsForSchemaType, MenuItemBuilder} from './MenuItem'\nimport {DEFAULT_SELECTED_ORDERING_OPTION} from './Sort'\nimport {type Collection} from './StructureNodes'\nimport {type StructureContext} from './types'\n\nconst BUNDLED_DOC_TYPES = ['sanity.imageAsset', 'sanity.fileAsset']\n\nfunction isBundledDocType(typeName: string) {\n  return BUNDLED_DOC_TYPES.includes(typeName)\n}\n\nfunction isDocumentType(schemaType: SchemaType) {\n  return schemaType.type?.name === 'document'\n}\n\nfunction isList(collection: Collection): collection is List {\n  return collection.type === 'list'\n}\n\nexport function getDocumentTypes({schema}: StructureContext): string[] {\n  return schema\n    .getTypeNames()\n    .filter((n) => {\n      const schemaType = schema.get(n)\n      return schemaType && isDocumentType(schemaType)\n    })\n    .filter((n) => !isBundledDocType(n))\n}\n\nexport function getDocumentTypeListItems(context: StructureContext): ListItemBuilder[] {\n  const types = getDocumentTypes(context)\n  return types.map((typeName) => getDocumentTypeListItem(context, typeName))\n}\n\nexport function getDocumentTypeListItem(\n  context: StructureContext,\n  typeName: string,\n): ListItemBuilder {\n  const {schema} = context\n\n  const type = schema.get(typeName)\n  if (!type) {\n    throw new Error(`Schema type with name \"${typeName}\" not found`)\n  }\n\n  const title = type.title || startCase(typeName)\n\n  return new ListItemBuilder(context)\n    .id(typeName)\n    .title(title)\n    .schemaType(type)\n    .child((id, childContext) => {\n      const parent = childContext.parent as Collection\n      const parentItem = isList(parent)\n        ? (parent.items.find((item) => item.id === id) as ListItem)\n        : null\n\n      let list = getDocumentTypeList(context, typeName)\n      if (parentItem && parentItem.title) {\n        list = list.title(parentItem.title)\n      }\n\n      return list\n    })\n}\n\nexport function getDocumentTypeList(\n  context: StructureContext,\n  typeNameOrSpec: string | DocumentTypeListInput,\n): DocumentListBuilder {\n  const {schema, resolveDocumentNode} = context\n\n  const schemaType = typeof typeNameOrSpec === 'string' ? typeNameOrSpec : typeNameOrSpec.schemaType\n  const typeName = typeof schemaType === 'string' ? schemaType : schemaType.name\n  const spec: DocumentTypeListInput =\n    typeof typeNameOrSpec === 'string' ? {schemaType} : typeNameOrSpec\n\n  const type = schema.get(typeName)\n  if (!type) {\n    throw new Error(`Schema type with name \"${typeName}\" not found`)\n  }\n\n  const title = type.title || startCase(typeName)\n\n  return new DocumentTypeListBuilder(context)\n    .id(spec.id || typeName)\n    .title(spec.title || title)\n    .filter('_type == $type')\n    .params({type: typeName})\n    .schemaType(type)\n    .defaultOrdering(DEFAULT_SELECTED_ORDERING_OPTION.by)\n    .menuItemGroups(\n      spec.menuItemGroups || [\n        {\n          id: 'sorting',\n          title: 'Sort',\n          i18n: {title: {key: 'menu-item-groups.actions-group', ns: structureLocaleNamespace}},\n        },\n        {\n          id: 'layout',\n          title: 'Layout',\n          i18n: {title: {key: 'menu-item-groups.layout-group', ns: structureLocaleNamespace}},\n        },\n        {\n          id: 'actions',\n          title: 'Actions',\n          i18n: {title: {key: 'menu-item-groups.sorting-group', ns: structureLocaleNamespace}},\n        },\n      ],\n    )\n    .child(\n      spec.child ||\n        ((documentId: string) => resolveDocumentNode({schemaType: typeName, documentId})),\n    )\n    .canHandleIntent(spec.canHandleIntent || defaultIntentChecker)\n    .menuItems(\n      spec.menuItems || [\n        // Create new (from action button) will be added in serialization step of GenericList\n\n        // Sort by <Y>\n        ...getOrderingMenuItemsForSchemaType(context, type),\n\n        // Display as <Z>\n        new MenuItemBuilder(context)\n          .group('layout')\n          .i18n({title: {key: 'menu-items.layout.compact-view', ns: structureLocaleNamespace}})\n          .title('Compact view') // fallback title\n          .icon(StackCompactIcon)\n          .action('setLayout')\n          .params({layout: 'default'}),\n\n        new MenuItemBuilder(context)\n          .group('layout')\n          .i18n({title: {key: 'menu-items.layout.detailed-view', ns: structureLocaleNamespace}})\n          .title('Detailed view') // fallback title\n          .icon(StackIcon)\n          .action('setLayout')\n          .params({layout: 'detail'}),\n\n        // Create new (from menu) will be added in serialization step of GenericList\n      ],\n    )\n}\n","import {type SchemaType} from '@sanity/types'\nimport {uniqueId} from 'lodash'\nimport {isValidElementType} from 'react-is'\nimport {getConfigContextFromSource, getPublishedId, type Source} from 'sanity'\n\nimport {structureLocaleNamespace} from '../i18n'\nimport {ComponentBuilder, type ComponentInput} from './Component'\nimport {DocumentBuilder, documentFromEditor, documentFromEditorWithInitialValue} from './Document'\nimport {DocumentListBuilder} from './DocumentList'\nimport {DocumentListItemBuilder} from './DocumentListItem'\nimport {\n  getDocumentTypeList,\n  getDocumentTypeListItem,\n  getDocumentTypeListItems,\n} from './documentTypeListItems'\nimport {\n  defaultInitialValueTemplateItems,\n  InitialValueTemplateItemBuilder,\n  menuItemsFromInitialValueTemplateItems,\n} from './InitialValueTemplateItem'\nimport {ListBuilder} from './List'\nimport {ListItemBuilder} from './ListItem'\nimport {getOrderingMenuItem, getOrderingMenuItemsForSchemaType, MenuItemBuilder} from './MenuItem'\nimport {MenuItemGroupBuilder} from './MenuItemGroup'\nimport {type Divider} from './StructureNodes'\nimport {\n  type DefaultDocumentNodeResolver,\n  type StructureBuilder,\n  type StructureContext,\n  type UserComponent,\n} from './types'\nimport * as views from './views'\n\n/** @internal */\nexport interface StructureBuilderOptions {\n  source: Source\n  defaultDocumentNode?: DefaultDocumentNodeResolver\n}\n\nfunction hasIcon(schemaType?: SchemaType | string): boolean {\n  if (!schemaType || typeof schemaType === 'string') {\n    return false\n  }\n\n  return Boolean(schemaType.icon)\n}\n\nfunction getDefaultStructure(context: StructureContext): ListBuilder {\n  const items = getDocumentTypeListItems(context)\n  return new ListBuilder(context)\n    .id('__root__')\n    .title('Content')\n    .i18n({title: {key: 'default-definition.content-title', ns: structureLocaleNamespace}})\n    .items(items)\n    .showIcons(items.some((item) => hasIcon(item.getSchemaType())))\n}\n\n/** @internal */\nexport function createStructureBuilder({\n  defaultDocumentNode,\n  source,\n}: StructureBuilderOptions): StructureBuilder {\n  const configContext = getConfigContextFromSource(source)\n  const context: StructureContext = {\n    ...source,\n    getStructureBuilder: () => structureBuilder,\n    resolveDocumentNode: (options) => {\n      let builder =\n        defaultDocumentNode?.(structureBuilder, {...options, ...configContext}) ||\n        new DocumentBuilder(context)\n\n      if (!builder.getId()) {\n        builder = builder.id('documentEditor')\n      }\n\n      if (options.documentId) {\n        builder = builder.documentId(getPublishedId(options.documentId))\n      }\n\n      return builder.schemaType(options.schemaType)\n    },\n  }\n\n  const structureBuilder: StructureBuilder = {\n    defaults: () => getDefaultStructure(context),\n    documentTypeList: (...args) => getDocumentTypeList(context, ...args),\n    documentTypeListItem: (...args) => getDocumentTypeListItem(context, ...args),\n    documentTypeListItems: (...args) => getDocumentTypeListItems(context, ...args),\n    document: (...args) => new DocumentBuilder(context, ...args),\n    documentWithInitialValueTemplate: (...args) =>\n      documentFromEditorWithInitialValue(context, ...args),\n    defaultDocument: context.resolveDocumentNode,\n\n    list: (...args) => new ListBuilder(context, ...args),\n    listItem: (...args) => new ListItemBuilder(context, ...args),\n\n    menuItem: (...args) => new MenuItemBuilder(context, ...args),\n    menuItemGroup: (...args) => new MenuItemGroupBuilder(context, ...args),\n    menuItemsFromInitialValueTemplateItems: (...args) =>\n      menuItemsFromInitialValueTemplateItems(context, ...args),\n\n    documentList: (...args) => new DocumentListBuilder(context, ...args),\n    documentListItem: (...args) => new DocumentListItemBuilder(context, ...args),\n\n    orderingMenuItem: (...args) => getOrderingMenuItem(context, ...args),\n    orderingMenuItemsForType: (...args) => getOrderingMenuItemsForSchemaType(context, ...args),\n\n    editor: (...args) => documentFromEditor(context, ...args),\n\n    defaultInitialValueTemplateItems: (...args) =>\n      defaultInitialValueTemplateItems(context, ...args),\n\n    initialValueTemplateItem: (\n      templateId: string,\n      parameters?: Record<string, unknown>,\n    ): InitialValueTemplateItemBuilder =>\n      new InitialValueTemplateItemBuilder(context, {\n        id: templateId,\n        parameters,\n        templateId,\n      }),\n\n    component: (spec?: ComponentInput | UserComponent) => {\n      return isValidElementType(spec)\n        ? new ComponentBuilder().component(spec as UserComponent)\n        : new ComponentBuilder(spec as ComponentInput)\n    },\n\n    divider: (): Divider => ({id: uniqueId('__divider__'), type: 'divider'}),\n\n    view: views,\n    context,\n  }\n\n  return structureBuilder\n}\n","import {type ReactNode, useMemo, useState} from 'react'\nimport {useConfigContextFromSource, useDocumentStore, useSource} from 'sanity'\nimport {StructureToolContext} from 'sanity/_singletons'\n\nimport {createStructureBuilder, type DefaultDocumentNodeResolver} from './structureBuilder'\nimport {\n  type StructureResolver,\n  type StructureToolContextValue,\n  type UnresolvedPaneNode,\n} from './types'\n\n/** @internal */\nexport interface StructureToolProviderProps {\n  structure?: StructureResolver\n  defaultDocumentNode?: DefaultDocumentNodeResolver\n  children: ReactNode\n}\n\n/** @internal */\nexport function StructureToolProvider({\n  defaultDocumentNode,\n  structure: resolveStructure,\n  children,\n}: StructureToolProviderProps): React.JSX.Element {\n  const [layoutCollapsed, setLayoutCollapsed] = useState(false)\n  const source = useSource()\n  const configContext = useConfigContextFromSource(source)\n  const documentStore = useDocumentStore()\n\n  const S = useMemo(() => {\n    return createStructureBuilder({\n      defaultDocumentNode,\n      source,\n    })\n  }, [defaultDocumentNode, source])\n\n  const rootPaneNode = useMemo(() => {\n    // TODO: unify types and remove cast\n    if (resolveStructure)\n      return resolveStructure(S, {\n        ...configContext,\n        documentStore,\n      }) as UnresolvedPaneNode\n    return S.defaults() as UnresolvedPaneNode\n  }, [S, resolveStructure, configContext, documentStore])\n\n  const features: StructureToolContextValue['features'] = useMemo(\n    () => ({\n      backButton: layoutCollapsed,\n      resizablePanes: !layoutCollapsed,\n      reviewChanges: !layoutCollapsed,\n      splitPanes: !layoutCollapsed,\n      splitViews: !layoutCollapsed,\n    }),\n    [layoutCollapsed],\n  )\n\n  const structureTool: StructureToolContextValue = useMemo(() => {\n    return {\n      features,\n      layoutCollapsed,\n      setLayoutCollapsed,\n      rootPaneNode,\n      structureContext: S.context,\n    }\n  }, [features, layoutCollapsed, rootPaneNode, S.context])\n\n  return (\n    <StructureToolContext.Provider value={structureTool}>{children}</StructureToolContext.Provider>\n  )\n}\n"],"names":["structureLocaleNamespace","structureUsEnglishLocaleBundle","defineLocaleResourceBundle","locale","namespace","resources","IMPLICIT_SCHEMA_TYPE_FIELDS","joinReferences","schemaType","path","strict","head","tail","schemaField","fields","find","field","name","includes","errorMessage","map","join","Error","console","warn","type","refTypes","to","refType","tailFields","length","tailWrapper","getExtendedProjection","orderBy","ordering","split","SerializeError","constructor","message","parentPath","pathSegment","hint","segment","concat","withHelpUrl","id","helpId","HELP_URL","ORDER_BY_UPDATED_AT","title","i18n","key","ns","by","direction","ORDER_BY_CREATED_AT","DEFAULT_SELECTED_ORDERING_OPTION","DEFAULT_ORDERING_OPTIONS","maybeSerializeMenuItem","item","index","MenuItemBuilder","serialize","_context","spec","action","clone","getAction","intent","getIntent","getTitle","getI18n","group","getGroup","icon","getIcon","params","getParams","showAsAction","Boolean","getShowAsAction","options","undefined","TITLE_REQUIRED","ACTION_OR_INTENT_REQUIRED","ACTION_AND_INTENT_MUTUALLY_EXCLUSIVE","withSpec","builder","getOrderingMenuItem","context","extendedProjection","t","replace","SortIcon","getOrderingMenuItemsForSchemaType","typeName","schema","get","orderings","maybeSerializeMenuItemGroup","MenuItemGroupBuilder","_id","_title","_i18n","getId","ID_REQUIRED","disallowedPattern","validateId","disallowedChar","match","startsWith","getStructureNodeId","camelCased","camelCase","test","getSlug","ComponentBuilder","child","getChild","component","getComponent","getOptions","menuItems","getMenuItems","menuItemGroups","getMenuItemGroups","canHandleIntent","componentOptions","i","resolveTypeForDocument","getClient","DEFAULT_STUDIO_CLIENT_OPTIONS","fetch","publishedId","getPublishedId","tag","GenericViewBuilder","kebabCase","isSerializable","view","maybeSerializeView","isComponentSpec","isRecord","ComponentViewBuilder","componentOrSpec","userComponent","base","COMPONENT_REQUIRED","FormViewBuilder","form","createDocumentChildResolver","resolveDocumentNode","itemId","slice","currentSegment","documentId","DocumentBuilder","paneId","getDocumentId","documentType","getSchemaType","initialValueTemplate","templateId","parameters","template","templateParameters","getInitialValueTemplate","getInitialValueTemplateParameters","views","getViews","urlId","DOCUMENT_ID_REQUIRED","viewIds","dupes","uniq","filter","viewId","getDocumentOptions","opts","documentFromEditor","doc","documentFromEditorWithInitialValue","templates","InitialValueTemplateItemBuilder","description","getDescription","getTemplateId","getParameters","subtitle","initialDocumentId","defaultInitialValueTemplateItems","getStructureBuilder","typeNames","getTypeNames","tpl","sort","a","b","indexOf","initialValueTemplateItem","maybeSerializeInitialValueTemplateItem","menuItemsFromInitialValueTemplateItems","templateItems","intentParams","AddIcon","DEFAULT_INTENT_HANDLER","Symbol","defaultIntentChecker","intentName","pane","isEdit","isCreate","typedSpec","paneFilter","paneParams","schemaTypeName","getTypeNamesFromFilter","initialValueTemplates","some","identity","layoutOptions","noChildResolver","shallowIntentChecker","GenericListBuilder","initialValueTemplatesSpecified","defaultLayout","getDefaultLayout","getCanHandleIntent","showIcons","enabled","displayOptions","getShowIcons","Array","isArray","getInitialValueTemplates","validateFilter","trim","QUERY_PROVIDED_FOR_FILTER","createDocumentChildResolverForItem","parentItem","parent","Promise","resolve","then","DocumentListBuilder","apiVersion","getApiVersion","getFilter","defaultOrdering","getDefaultOrdering","FILTER_REQUIRED","generateHelpUrl","API_VERSION_REQUIRED_FOR_CUSTOM_FILTER","inferInitialValueTemplates","inferTypeName","getSpec","document","from","Set","flatMap","resolveNewDocumentOptions","option","getTypeNamesFromEqualityFilter","getTypeNamesFromInTypesFilter","pattern","matches","exec","push","candidate","getArgType","thing","ListBuilder","isPromise","isListItem","defaultCanHandleIntent","items","isDocumentListItem","resolveChildForItem","target","maybeSerializeListItem","ListItemBuilder","listItem","gotWhat","helpText","INVALID_LIST_ITEM","getItems","LIST_ITEMS_MUST_BE_ARRAY","serializedItems","val","dupeIds","dupeDesc","LIST_ITEM_IDS_MUST_BE_UNIQUE","showIcon","getShowIcon","titleIsOptional","SCHEMA_TYPE_NOT_FOUND","serializeOptions","listChild","originalChild","childOptions","createDefaultChildResolver","DocumentListItemBuilder","SCHEMA_TYPE_REQUIRED","DocumentTypeListBuilder","cloneWithoutDefaultIntentHandler","override","BUNDLED_DOC_TYPES","isBundledDocType","isDocumentType","isList","collection","getDocumentTypes","n","getDocumentTypeListItems","getDocumentTypeListItem","startCase","childContext","list","getDocumentTypeList","typeNameOrSpec","StackCompactIcon","layout","StackIcon","hasIcon","getDefaultStructure","createStructureBuilder","defaultDocumentNode","source","configContext","getConfigContextFromSource","structureBuilder","defaults","documentTypeList","args","documentTypeListItem","documentTypeListItems","documentWithInitialValueTemplate","defaultDocument","menuItem","menuItemGroup","documentList","documentListItem","orderingMenuItem","orderingMenuItemsForType","editor","isValidElementType","divider","uniqueId","StructureToolProvider","structure","resolveStructure","children","layoutCollapsed","setLayoutCollapsed","useState","useSource","useConfigContextFromSource","documentStore","useDocumentStore","S","useMemo","rootPaneNode","features","backButton","resizablePanes","reviewChanges","splitPanes","splitViews","structureTool","structureContext"],"mappings":";;;;;;;;;;;;;;AAOaA,MAAAA,2BAA2B,aAO3BC,iCAAiCC,2BAA2B;AAAA,EACvEC,QAAQ;AAAA,EACRC,WAAWJ;AAAAA,EACXK,WAAWA,MAAM,OAAO,kBAAa;AACvC,CAAC,GChBKC,8BAA8B,CAAC,OAAO,SAAS,cAAc,cAAc,MAAM;AAGvF,SAASC,eAAeC,YAAwBC,MAAgBC,SAAkB,IAAe;AAC/F,QAAM,CAACC,MAAM,GAAGC,IAAI,IAAIH;AAExB,MAAI,EAAE,YAAYD;AACT,WAAA;AAGT,QAAMK,cAAcL,WAAWM,OAAOC,KAAMC,CAAUA,UAAAA,MAAMC,SAASN,IAAI;AACzE,MAAI,CAACE,aAAa;AAChB,QAAI,CAACP,4BAA4BY,SAASP,IAAI,GAAG;AAC/C,YAAMQ,eAAe,+DAA+DR,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