/**
 * Resource Composite Implementation
 *
 * This module provides the implementation of the Composite pattern for
 * grouping related resources with recursive operations.
 *
 * @module declarative-api/composite/resource-composite
 */
import type { IResourceEntity, IResourceVisitor, ILifecycleState, ResourceMetadata, LifecycleStateType, IResourceComposite, CompositeGroupType, AddChildOptions, ILazyChildrenProvider, ResourceCompositeOptions } from '../../../lib/runtime-web/types/declarative-api';
/**
 * Error thrown when attempting to add a duplicate child.
 */
export declare class DuplicateChildError extends Error {
    readonly compositeId: string;
    readonly childId: string;
    constructor(compositeId: string, childId: string);
}
/**
 * Type guard for DuplicateChildError.
 */
export declare function isDuplicateChildError(error: unknown): error is DuplicateChildError;
/**
 * Error thrown when children are not yet loaded for lazy composite.
 */
export declare class ChildrenNotLoadedError extends Error {
    readonly compositeId: string;
    constructor(compositeId: string);
}
/**
 * Type guard for ChildrenNotLoadedError.
 */
export declare function isChildrenNotLoadedError(error: unknown): error is ChildrenNotLoadedError;
/**
 * Resource Composite implementation.
 *
 * Implements the Composite pattern for tree structure of resources.
 * Supports recursive operations, visitor pattern, and lazy loading.
 *
 * @example
 * ```typescript
 * const databaseGroup = new ResourceComposite('database-resources', {
 *   groupType: 'database',
 *   children: [usersTable, ordersTable],
 * });
 *
 * // Recursive operations
 * databaseGroup.forEach(resource => console.log(resource.id));
 *
 * // Visitor pattern
 * const count = databaseGroup.accept(new ResourceCountVisitor());
 * ```
 *
 * Validates: Requirements 8.1, 8.2, 8.3, 8.4, 8.5, 8.6
 */
export declare class ResourceComposite implements IResourceComposite {
    readonly id: string;
    readonly metadata: ResourceMetadata;
    readonly type: "composite";
    readonly groupType: CompositeGroupType;
    readonly construct: unknown;
    private _state;
    private readonly _children;
    private readonly _childOrder;
    private readonly _lazyProvider?;
    private _lazyLoaded;
    constructor(id: string, metadata: ResourceMetadata, options: ResourceCompositeOptions);
    /**
     * Get the current lifecycle state.
     */
    get state(): ILifecycleState;
    /**
     * Transition to a new lifecycle state.
     */
    transitionTo(targetState: LifecycleStateType): void;
    /**
     * Add a child resource to this composite.
     */
    add(resource: IResourceEntity, options?: AddChildOptions): this;
    /**
     * Remove a child resource by ID.
     */
    remove(resourceId: string): boolean;
    /**
     * Get all direct children of this composite.
     */
    getChildren(): readonly IResourceEntity[];
    /**
     * Get a specific child by ID.
     */
    getChild(id: string): IResourceEntity | undefined;
    /**
     * Check if this composite has a child with the given ID.
     */
    hasChild(id: string): boolean;
    /**
     * Get the number of direct children.
     */
    childCount(): number;
    /**
     * Execute a callback for each resource in the tree (depth-first).
     */
    forEach(callback: (resource: IResourceEntity) => void): void;
    /**
     * Map each resource in the tree to a new value (depth-first).
     */
    map<T>(callback: (resource: IResourceEntity) => T): T[];
    /**
     * Filter resources in the tree by a predicate (depth-first).
     */
    filter(predicate: (resource: IResourceEntity) => boolean): IResourceEntity[];
    /**
     * Find a resource in the tree by predicate (depth-first).
     */
    find(predicate: (resource: IResourceEntity) => boolean): IResourceEntity | undefined;
    /**
     * Check if any resource in the tree satisfies the predicate.
     */
    some(predicate: (resource: IResourceEntity) => boolean): boolean;
    /**
     * Check if all resources in the tree satisfy the predicate.
     */
    every(predicate: (resource: IResourceEntity) => boolean): boolean;
    /**
     * Get all resources in the tree flattened to an array (depth-first).
     */
    flatten(): IResourceEntity[];
    /**
     * Accept a visitor for traversal operations.
     */
    accept<T>(visitor: IResourceVisitor<T>): T;
    /**
     * Load children lazily if a provider is configured.
     */
    loadChildren(): Promise<void>;
    /**
     * Check if children have been loaded (for lazy composites).
     */
    isChildrenLoaded(): boolean;
    /**
     * Internal method to add a child.
     */
    private _addChild;
    /**
     * Check if a resource is a composite.
     */
    private _isComposite;
    /**
     * Accept an extended visitor with traversal control.
     */
    private _acceptExtended;
    /**
     * Create a state instance from state type.
     */
    private _createStateInstance;
}
/**
 * Create a lazy-loading proxy for a resource composite.
 *
 * The proxy intercepts access to children and loads them on first access.
 * This is useful for large resource trees where loading all children
 * upfront would be expensive.
 *
 * @param composite - The composite to wrap
 * @param provider - The lazy loading provider
 * @returns A proxy that loads children on first access
 *
 * Validates: Requirements 8.6
 */
export declare function createLazyCompositeProxy(composite: ResourceComposite, provider: ILazyChildrenProvider): IResourceComposite;
/**
 * Factory function to create a resource composite.
 *
 * @param id - Unique identifier for the composite
 * @param metadata - Resource metadata
 * @param options - Composite options
 * @returns A new ResourceComposite instance
 */
export declare function createResourceComposite(id: string, metadata: ResourceMetadata, options: ResourceCompositeOptions): IResourceComposite;
/**
 * Simple metadata factory for testing and convenience.
 *
 * @param serviceName - The service name
 * @param stage - The deployment stage
 * @returns ResourceMetadata with defaults
 */
export declare function createCompositeMetadata(serviceName: string, stage?: 'dev' | 'staging' | 'prod'): ResourceMetadata;
