import { type SchemaObject } from 'ajv';
import { Value, Renderable } from '@tempots/dom';
import { Controller, ControllerValidation } from '../form';
/**
 * External reference resolver function type.
 * Called when the form encounters external $ref URIs that need to be resolved.
 *
 * @param ids - Array of external schema IDs that need to be resolved
 * @returns Promise resolving to array of schema objects with matching $id properties
 *
 * @example
 * ```typescript
 * const refResolver = async (ids: string[]) => {
 *   const schemas = await Promise.all(
 *     ids.map(id => fetch(`/schemas/${id}`).then(r => r.json()))
 *   )
 *   return schemas
 * }
 * ```
 */
export type ExternalRefResolver = (ids: ReadonlyArray<string>) => Promise<ReadonlyArray<SchemaObject>>;
/**
 * Configuration options for JSONSchemaForm external reference resolution.
 */
export interface JSONSchemaFormExternalOptions {
    /**
     * Pre-bundled external schemas to register with AJV before compilation.
     * These schemas should have $id properties and will be available for $ref resolution.
     *
     * @example
     * ```typescript
     * const externalSchemas = [
     *   { $id: 'https://example.com/address', type: 'object', properties: { ... } },
     *   { $id: 'https://example.com/person', type: 'object', properties: { ... } }
     * ]
     * ```
     */
    externalSchemas?: ReadonlyArray<SchemaObject>;
    /**
     * Dynamic resolver for external $ref URIs not found in externalSchemas.
     * Called when the form encounters external references during schema compilation.
     * The resolver should fetch and return schemas with matching $id properties.
     *
     * @example
     * ```typescript
     * const refResolver = async (ids: string[]) => {
     *   // Fetch schemas from API, filesystem, or other sources
     *   return await fetchSchemasById(ids)
     * }
     * ```
     */
    refResolver?: ExternalRefResolver;
    /**
     * Controls automatic sanitization of form data to remove properties
     * not allowed by the schema (e.g., when additionalProperties: false).
     *
     * - 'all': Remove all additional properties
     * - 'failing': Remove only properties that cause validation failures
     * - false: No automatic sanitization (default)
     */
    sanitizeAdditional?: 'all' | 'failing' | false;
}
/**
 * Props for the JSONSchemaForm component.
 */
export interface JSONSchemaFormProps<T> extends JSONSchemaFormExternalOptions {
    /** The root JSON Schema to render as a form */
    schema: SchemaObject;
    /** Reactive value containing the form data */
    initialValue: Value<T>;
    /** Validation behavior */
    validationMode?: 'onSubmit' | 'continuous' | 'touchedOrSubmit';
    validateDebounceMs?: number;
}
export declare function JSONSchemaForm<T>({ schema, initialValue, externalSchemas, refResolver, sanitizeAdditional, validationMode, validateDebounceMs, }: JSONSchemaFormProps<T>, fn: ({ Form, controller, setStatus, }: {
    Form: Renderable;
    controller: Controller<T>;
    setStatus: (result: ControllerValidation) => void;
}) => Renderable): Renderable;
