/**
 * Widget Registry for JSON Structure Forms
 *
 * Manages custom widget registrations and resolution.
 */
import type { Renderable } from '@tempots/dom';
import type { Controller } from '../../form';
import type { StructureContext } from '../structure-context';
/**
 * Props passed to widget factories
 */
export interface WidgetProps<T = unknown> {
    /** Controller for this field's value */
    controller: Controller<T>;
    /** Current structure context */
    ctx: StructureContext;
    /** Widget-specific options */
    options?: Record<string, unknown>;
}
/**
 * Factory function to create a widget
 */
export interface WidgetFactory<T = unknown> {
    (props: WidgetProps<T>): Renderable;
}
/**
 * Widget registration entry
 */
export interface WidgetRegistration {
    /** Factory function to create the widget */
    factory: WidgetFactory;
    /** Human-readable display name */
    displayName: string;
    /** Optional description */
    description?: string;
    /** JSON Structure types this widget handles */
    supportedTypes?: string[];
    /** JSON Structure formats this widget handles */
    supportedFormats?: string[];
    /** Resolution priority (higher = preferred) */
    priority?: number;
    /** Whether this can be used as fallback */
    canFallback?: boolean;
    /** Custom matching logic */
    matcher?: (ctx: StructureContext) => boolean;
}
/**
 * Resolved widget ready for use
 */
export interface ResolvedWidget {
    name: string;
    registration: WidgetRegistration;
}
/**
 * Widget registry interface
 */
export interface WidgetRegistry {
    /** Register a widget */
    register(name: string, registration: WidgetRegistration): void;
    /** Unregister a widget */
    unregister(name: string): void;
    /** Get all registrations for a type */
    getForType(type: string): WidgetRegistration[];
    /** Get all registrations for a format */
    getForFormat(format: string): WidgetRegistration[];
    /** Find best matching widget for context */
    findBestWidget(ctx: StructureContext): ResolvedWidget | null;
    /** Get registration by name */
    get(name: string): WidgetRegistration | undefined;
    /** Check if a widget is registered */
    has(name: string): boolean;
    /** Get all widget names */
    names(): string[];
    /** Create a child registry that inherits from this one */
    createChild(): WidgetRegistry;
}
/**
 * Default implementation of WidgetRegistry
 */
export declare class DefaultWidgetRegistry implements WidgetRegistry {
    private readonly registrations;
    private readonly parent;
    constructor(parent?: WidgetRegistry);
    register(name: string, registration: WidgetRegistration): void;
    unregister(name: string): void;
    get(name: string): WidgetRegistration | undefined;
    has(name: string): boolean;
    names(): string[];
    getForType(type: string): WidgetRegistration[];
    getForFormat(format: string): WidgetRegistration[];
    findBestWidget(ctx: StructureContext): ResolvedWidget | null;
    /**
     * Score how well a widget matches the context
     */
    private scoreWidget;
    createChild(): WidgetRegistry;
}
/**
 * Get the global widget registry
 */
export declare function getGlobalWidgetRegistry(): WidgetRegistry;
/**
 * Set the global widget registry
 */
export declare function setGlobalWidgetRegistry(registry: WidgetRegistry): void;
/**
 * Create a new widget registry
 */
export declare function createWidgetRegistry(parent?: WidgetRegistry): WidgetRegistry;
export interface WidgetRegistrationOptions {
    displayName?: string;
    description?: string;
    priority?: number;
    canFallback?: boolean;
}
/**
 * Create a widget registration for a specific type
 */
export declare function forType(type: string, factory: WidgetFactory, options?: WidgetRegistrationOptions): {
    name: string;
    registration: WidgetRegistration;
};
/**
 * Create a widget registration for a specific format
 */
export declare function forFormat(format: string, factory: WidgetFactory, options?: WidgetRegistrationOptions): {
    name: string;
    registration: WidgetRegistration;
};
/**
 * Create a widget registration for a type+format combination
 */
export declare function forTypeAndFormat(type: string, format: string, factory: WidgetFactory, options?: WidgetRegistrationOptions): {
    name: string;
    registration: WidgetRegistration;
};
/**
 * Create a widget registration with custom matcher
 */
export declare function forMatcher(name: string, matcher: (ctx: StructureContext) => boolean, factory: WidgetFactory, options?: WidgetRegistrationOptions): {
    name: string;
    registration: WidgetRegistration;
};
