import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, SchemaTypeDefinition } from "@sanity/types";
import { Schema } from "@portabletext/schema";
/**
 * @public
 * Sanity-specific schema types for Portable Text.
 */
type PortableTextMemberSchemaTypes = {
  annotations: (ObjectSchemaType & {
    i18nTitleKey?: string;
  })[];
  block: ObjectSchemaType;
  blockObjects: ObjectSchemaType[];
  decorators: BlockDecoratorDefinition[];
  inlineObjects: ObjectSchemaType[];
  portableText: ArraySchemaType<PortableTextBlock>;
  span: ObjectSchemaType;
  styles: BlockStyleDefinition[];
  lists: BlockListDefinition[];
};
/**
 * @public
 * Create Sanity-specific schema types for Portable Text from a Sanity array
 * schema type.
 */
declare function createPortableTextMemberSchemaTypes(portableTextType: ArraySchemaType<PortableTextBlock>): PortableTextMemberSchemaTypes;
/**
 * Resolve the {@link PortableTextMemberSchemaTypes} view at `path`
 * against `value`. Walks `path` to find the nearest Portable-Text-
 * shaped ancestor — a container's child array, or the root — and
 * bucketizes its `of` declaration into the same shape as
 * {@link createPortableTextMemberSchemaTypes}.
 *
 * Sanity-side counterpart to `@portabletext/schema`'s `getSubSchema`,
 * composed with the same walk that PTE's `getPathSubSchema` performs.
 * The two functions answer the same question — "what's the schema
 * here?" — in their respective type universes: `@portabletext/schema`
 * operates over the PTE `Schema` shape; this one over Sanity's
 * `SchemaType`. Same algorithm, different inputs.
 *
 * The walk is structured against the raw Sanity `ArraySchemaType` and
 * value tree directly, without consulting PTE's runtime `Containers`
 * map, so it can run from anywhere a Studio integration sits.
 *
 * A "Portable-Text-shaped" `of` is an array declaration that includes
 * a `{type: 'block'}` member. Text blocks' `children` field carries a
 * span-content `of` (no block member) and is not Portable-Text-shaped;
 * descending into it would not yield a `PortableTextMemberSchemaTypes`
 * view. The walk therefore tracks the deepest PT-shaped `of` it has
 * traversed and returns its bucketization. When `path` traverses no
 * containers (or is empty), returns the root bucketization.
 *
 * Falls back to the root bucketization when:
 * - `path` traverses only text blocks and their span children,
 * - any segment along the walk can't be resolved against the value, or
 * - any member along the walk has no child array field.
 *
 * @public
 */
declare function getSanitySubSchema(rootPortableTextType: ArraySchemaType<PortableTextBlock>, value: ReadonlyArray<PortableTextBlock>, path: Path): PortableTextMemberSchemaTypes;
/**
 * @public
 * Compile a Sanity schema to a Portable Text `Schema`.
 *
 * A Portable Text `Schema` is compatible with a Portable Text
 * `SchemaDefinition` and can be used as configuration for the Portable Text
 * Editor.
 *
 * For a raw (uncompiled) array definition whose fields reference a sibling
 * type by name, use `sanitySchemaDefinitionToPortableTextSchema` instead.
 *
 * @example
 * ```tsx
 * const schema = sanitySchemaToPortableTextSchema(sanitySchema)
 *
 * return (
 *   <EditorProvider
 *     initialConfig={{
 *       // ...
 *       schemaDefinition: schema,
 *     }}
 *   >
 *     // ...
 *   </EditorProvider>
 * ```
 */
declare function sanitySchemaToPortableTextSchema(sanitySchema: ArraySchemaType<unknown> | ArrayDefinition): Schema;
/**
 * @public
 * Compile a raw (uncompiled) Sanity array definition to a Portable Text
 * `Schema`, resolving named references to sibling types via
 * `options.types`.
 *
 * A raw definition whose fields reference another type by name (for
 * example a `customLink` annotation field typed `customUrl`) fails to
 * compile on its own: `definition` only carries the types nested inside
 * it, not its siblings elsewhere in the schema. Pass those siblings
 * through `options.types`.
 *
 * `options.types` entries named the same as `definition` itself are
 * ignored, `definition` wins, so a complete schema type list that
 * includes the portable text field can be passed as-is. Entries named
 * like one of Sanity's built-in types (`image`, `block`, `span`, ...) are
 * also ignored: Sanity's compiler gives built-ins precedence over
 * same-named custom types.
 *
 * When a reference still cannot be resolved, the thrown error names the
 * fix: ``Unknown type: customUrl. Define 'customUrl' in the schema or
 * pass it via `options.types`.``
 *
 * @example
 * ```tsx
 * const schema = sanitySchemaDefinitionToPortableTextSchema(richTextDefinition, {
 *   types: [customUrl],
 * })
 * ```
 */
declare function sanitySchemaDefinitionToPortableTextSchema(definition: ArrayDefinition, options?: {
  types?: ReadonlyArray<SchemaTypeDefinition>;
}): Schema;
export { type PortableTextMemberSchemaTypes, createPortableTextMemberSchemaTypes, getSanitySubSchema, sanitySchemaDefinitionToPortableTextSchema, sanitySchemaToPortableTextSchema };
//# sourceMappingURL=index.d.ts.map