import { Inject, Pipe } from '@angular/core';
import { LOGGER } from '@anglr/common';
import { FormComponentControlType } from '../../misc/enums';
import { getControlForType, getFormControl } from '../../misc/utils';
import * as i0 from "@angular/core";
/**
 * Transforms control name to FormControl|FormArray|FormGroup
 */
export class FormComponentControlSAPipe {
    constructor(_logger) {
        this._logger = _logger;
    }
    //######################### public methods - implementation of PipeTransform #########################
    /**
     * Transforms control name to FormControl|FormArray|FormGroup
     */
    transform(controlName, parentControl, defaultControlType = FormComponentControlType.FormControl, defaultValue) {
        const control = getFormControl(controlName, parentControl, defaultControlType, defaultValue);
        if (!control) {
            this._logger?.warn('FormComponentControlSAPipe: Unable to find control with name {{@name}}', { name: controlName });
        }
        return control ?? getControlForType(defaultControlType, defaultValue);
    }
}
FormComponentControlSAPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: FormComponentControlSAPipe, deps: [{ token: LOGGER }], target: i0.ɵɵFactoryTarget.Pipe });
FormComponentControlSAPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "17.0.4", ngImport: i0, type: FormComponentControlSAPipe, isStandalone: true, name: "formComponentControl" });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: FormComponentControlSAPipe, decorators: [{
            type: Pipe,
            args: [{ name: 'formComponentControl', standalone: true }]
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [LOGGER]
                }] }] });
//# sourceMappingURL=control.pipe.js.map