/**
 * @fileoverview OrdoJS Component System - Modern component architecture
 * @author OrdoJS Framework Team
 */
import type { Props } from '../types/index.js';
import { type EffectCleanup, type Signal } from './reactivity.js';
/**
 * Component lifecycle phases
 */
export declare enum ComponentLifecycle {
    CREATED = "created",
    MOUNTED = "mounted",
    UPDATED = "updated",
    UNMOUNTED = "unmounted",
    ERROR = "error"
}
/**
 * Component context for dependency injection
 */
export interface ComponentContext {
    /** Parent component */
    parent?: ComponentInstance;
    /** Injected dependencies */
    injected: Map<string | symbol, any>;
    /** Provided dependencies */
    provided: Map<string | symbol, any>;
    /** Component registry */
    registry: ComponentRegistry;
}
/**
 * Component definition interface
 */
export interface ComponentDefinition<P extends Props = Props, S = any> {
    /** Component name */
    name: string;
    /** Props validation schema */
    props?: PropSchema<P>;
    /** Setup function */
    setup?: (props: P, context: SetupContext) => S | Promise<S>;
    /** Render function */
    render?: (state: S, props: P) => VNode | string;
    /** Lifecycle hooks */
    lifecycle?: Partial<LifecycleHooks>;
    /** Component styles */
    styles?: string | (() => string);
    /** Component metadata */
    meta?: ComponentMeta;
}
/**
 * Component metadata
 */
export interface ComponentMeta {
    /** Component version */
    version?: string;
    /** Component description */
    description?: string;
    /** Component tags */
    tags?: string[];
    /** Is component async */
    async?: boolean;
    /** Component dependencies */
    dependencies?: string[];
}
/**
 * Props validation schema
 */
export interface PropSchema<P = any> {
    [key: string]: PropDefinition<any>;
}
/**
 * Prop definition
 */
export interface PropDefinition<T = any> {
    /** Prop type */
    type: PropType<T>;
    /** Is required */
    required?: boolean;
    /** Default value */
    default?: T | (() => T);
    /** Validation function */
    validator?: (value: T) => boolean;
    /** Prop description */
    description?: string;
}
/**
 * Prop types
 */
export type PropType<T> = 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function' | ((value: any) => value is T);
/**
 * Setup context
 */
export interface SetupContext {
    /** Component props */
    props: Signal<Props>;
    /** Emit events */
    emit: (event: string, payload?: any) => void;
    /** Expose public API */
    expose: (api: Record<string, any>) => void;
    /** Access parent context */
    parent?: ComponentInstance;
    /** Inject dependency */
    inject: <T>(key: string | symbol, defaultValue?: T) => T;
    /** Provide dependency */
    provide: <T>(key: string | symbol, value: T) => void;
    /** Component slots */
    slots: Record<string, () => VNode[]>;
}
/**
 * Lifecycle hooks
 */
export interface LifecycleHooks {
    /** Before component creation */
    beforeCreate?: () => void;
    /** After component creation */
    created?: () => void;
    /** Before component mount */
    beforeMount?: () => void;
    /** After component mount */
    mounted?: () => void;
    /** Before component update */
    beforeUpdate?: () => void;
    /** After component update */
    updated?: () => void;
    /** Before component unmount */
    beforeUnmount?: () => void;
    /** After component unmount */
    unmounted?: () => void;
    /** Error handler */
    errorCaptured?: (error: Error, instance: ComponentInstance) => boolean | void;
}
/**
 * Virtual DOM node
 */
export interface VNode {
    /** Node type */
    type: string | ComponentDefinition;
    /** Node props */
    props?: Props;
    /** Child nodes */
    children?: VNode[];
    /** Node key */
    key?: string | number;
    /** Node ref */
    ref?: (el: Element | ComponentInstance | null) => void;
    /** Raw HTML */
    innerHTML?: string;
}
/**
 * Component instance
 */
export interface ComponentInstance<P extends Props = Props, S = any> {
    /** Component ID */
    id: string;
    /** Component definition */
    definition: ComponentDefinition<P, S>;
    /** Component props */
    props: Signal<P>;
    /** Component state */
    state: S;
    /** Component context */
    context: ComponentContext;
    /** Current lifecycle phase */
    lifecycle: Signal<ComponentLifecycle>;
    /** DOM element */
    element: Element | null;
    /** Child components */
    children: ComponentInstance[];
    /** Event emitter */
    emit: (event: string, payload?: any) => void;
    /** Exposed API */
    exposed: Record<string, any>;
    /** Cleanup functions */
    cleanups: EffectCleanup[];
    /** Mount component */
    mount: (target: Element) => Promise<void>;
    /** Unmount component */
    unmount: () => Promise<void>;
    /** Update component */
    update: (newProps?: Partial<P>) => Promise<void>;
    /** Force re-render */
    forceUpdate: () => Promise<void>;
}
/**
 * Component registry
 */
export interface ComponentRegistry {
    /** Register component */
    register: (definition: ComponentDefinition) => void;
    /** Get component */
    get: (name: string) => ComponentDefinition | undefined;
    /** Unregister component */
    unregister: (name: string) => boolean;
    /** List all components */
    list: () => ComponentDefinition[];
}
/**
 * Component factory options
 */
export interface ComponentFactoryOptions {
    /** Global component registry */
    registry?: ComponentRegistry;
    /** Global error handler */
    errorHandler?: (error: Error, instance: ComponentInstance) => void;
    /** Development mode */
    devMode?: boolean;
}
/**
 * Create component instance
 */
export declare function createComponent<P extends Props = Props, S = any>(definition: ComponentDefinition<P, S>, props: P, context?: ComponentContext): ComponentInstance<P, S>;
/**
 * Define a component
 */
export declare function defineComponent<P extends Props = Props, S = any>(definition: ComponentDefinition<P, S>): ComponentDefinition<P, S>;
/**
 * Create virtual DOM node
 */
export declare function h(type: string | ComponentDefinition, props?: Props, ...children: (VNode | string)[]): VNode;
/**
 * Fragment component for multiple root nodes
 */
export declare const Fragment: ComponentDefinition<Props, any>;
/**
 * Component factory
 */
export declare class ComponentFactory {
    private registry;
    private options;
    constructor(options?: ComponentFactoryOptions);
    /**
     * Register component
     */
    register(definition: ComponentDefinition): void;
    /**
     * Create component instance
     */
    create<P extends Props = Props>(nameOrDefinition: string | ComponentDefinition<P>, props: P): ComponentInstance<P>;
    /**
     * Get registry
     */
    getRegistry(): ComponentRegistry;
}
/**
 * Default component factory
 */
export declare const componentFactory: ComponentFactory;
/**
 * Global component registration
 */
export declare function registerComponent(definition: ComponentDefinition): void;
/**
 * Create component from name
 */
export declare function createComponentByName<P extends Props = Props>(name: string, props: P): ComponentInstance<P>;
//# sourceMappingURL=component-system.d.ts.map