import { FormGroup } from '@angular/forms';
import { Observable } from 'rxjs';
import * as i0 from "@angular/core";
/**
 * The QdFormGroupManagerService provides centralized registration, snapshotting, and value tracking
 * for multiple Angular `FormGroup` instances. It supports efficient state restoration, including dynamic
 * resizing of embedded `FormArray` controls, while avoiding any structural cloning in snapshots.
 *
 * #### Purpose:
 * This service is useful when managing multiple reactive forms that must be:
 * - Observed for changes
 * - Checked for validity
 * - Compared against a previous state (snapshot)
 * - Reset to a previous state, including dynamic form arrays
 *
 * #### Value Snapshot
 * Snapshots store only **raw values** (via `getRawValue()`), not any control instances.
 * This allows for minimal memory usage and easy comparison using deep equality checks.
 *
 * #### Smart FormArray Reset
 * When restoring a `FormArray`, the service ensures that the number and structure of controls
 * matches the snapshot values. Controls are cloned dynamically from an existing prototype.
 * If a `FormArray` was emptied (e.g. via `removeAt()`), a minimal control structure is inferred
 * from the snapshot data.
 *
 * #### Example Usage:
 *
 * **Register a FormGroup**
 * ```ts
 * service.setFormGroup('userForm', formGroup);
 * ```
 *
 * **Take a Snapshot**
 * ```ts
 * service.takeFormGroupsSnapshot();
 * ```
 *
 * **Detect Changes**
 * ```ts
 * service.$hasValuesChanged().subscribe(changed => {
 *   if (changed) {
 *     console.log('Form data has changed');
 *   }
 * });
 * ```
 *
 * **Restore from Snapshot**
 * ```ts
 * service.restoreFormGroupsFromSnapshot();
 * ```
 *
 * **Check if All Forms Are Valid**
 * ```ts
 * service.$areFormGroupsValid().subscribe(valid => {
 *   if (valid) {
 *     console.log('All forms valid!');
 *   }
 * });
 * ```
 *
 * #### Notes:
 * - FormArrays are not replaced during restore. Their length is adjusted and their content reset.
 * - Control cloning is recursive and structure-preserving.
 * - No structural information is stored in the snapshot; only data.
 */
export declare class QdFormGroupManagerService {
    private _formGroups;
    private _formGroupsSnapshot;
    private _formGroupsChanged$;
    setFormGroup(key: string, formGroup: FormGroup): void;
    getFormGroup(key: string): FormGroup | undefined;
    getAllFormGroups(): Map<string, FormGroup>;
    tryRemoveFormGroup(key: string): void;
    hasFormGroups(): boolean;
    getAllValues(): Record<string, unknown>;
    isFormGroupKeyUnique(key: string): boolean;
    $areFormGroupsValid(): Observable<boolean>;
    $hasValuesChanged(): Observable<boolean>;
    takeFormGroupsSnapshot(): void;
    restoreFormGroupsFromSnapshot(): void;
    private restoreFormGroup;
    /**
     * Cancels any in-flight async validators on all registered form groups.
     *
     * 1. Collect all PENDING controls and their async validators
     * 2. Clear all async validators, then update validity (sync-only, no cascade)
     * 3. Re-attach async validators for future use
     */
    cancelPendingAsyncValidation(): void;
    private collectPendingControls;
    private resetFormArrayToValues;
    private initFormArrayFromValues;
    private deepCloneControl;
    private areFormGroupsValid;
    static ɵfac: i0.ɵɵFactoryDeclaration<QdFormGroupManagerService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<QdFormGroupManagerService>;
}
//# sourceMappingURL=form-group-manager.service.d.ts.map