import * as _angular_core from '@angular/core';
import { DoCheck, InjectionToken, Signal, AfterContentInit, AfterContentChecked, OnChanges, OnInit, OnDestroy, ElementRef, SimpleChanges, ModuleWithProviders, Provider } from '@angular/core';
import * as _angular_forms from '@angular/forms';
import { AbstractControl, FormGroup, NgControl, RequiredValidator } from '@angular/forms';
import { Breakpoints } from '@siemens/element-ng/resize-observer';
import { TranslatableString } from '@siemens/element-translate-ng/translate';
import * as _siemens_element_ng_form from '@siemens/element-ng/form';

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

/**
 * Interface for form error mapper.
 * It resolves a key to either a translatable string or function
 * which is called with the validation error for its key and should return a translatable string.
 */
interface SiFormValidationErrorMapper {
    required?: TranslatableString | ((error: {
        required: boolean;
    }) => TranslatableString);
    requiredTrue?: TranslatableString | ((error: {
        required: boolean;
    }) => TranslatableString);
    email?: TranslatableString | ((error: {
        email: boolean;
    }) => TranslatableString);
    min?: TranslatableString | ((error: {
        min: number;
        actual: number;
    }) => TranslatableString);
    max?: TranslatableString | ((error: {
        max: number;
        actual: number;
    }) => TranslatableString);
    minLength?: TranslatableString | ((error: {
        requiredLength: number;
        actualLength: number;
    }) => TranslatableString);
    maxLength?: TranslatableString | ((error: {
        requiredLength: number;
        actualLength: number;
    }) => TranslatableString);
    pattern?: TranslatableString | ((error: {
        pattern: string | RegExp;
    }) => TranslatableString);
    numberFormat?: TranslatableString | ((error: {
        numberFormat: boolean;
    }) => TranslatableString);
    dateFormat?: TranslatableString | ((error: {
        format: string;
    }) => TranslatableString);
    maxDate?: TranslatableString | ((error: {
        max: Date;
        actual: Date;
    }) => TranslatableString);
    minDate?: TranslatableString | ((error: {
        min: Date;
        actual: Date;
    }) => TranslatableString);
    [key: string]: undefined | string | ((error: any) => string);
}

interface SiFormValidationError {
    controlName?: string;
    controlNameTranslationKey?: string;
    errorCode: TranslatableString;
    errorCodeTranslationKey?: string;
    errorParams?: any;
}
declare class SiFormContainerComponent<TControl extends {
    [K in keyof TControl]: AbstractControl;
}> {
    /**
     * Set the form entity to the container to enable the overall form validation on in
     * the form container edit panel.
     */
    readonly form: _angular_core.InputSignal<FormGroup<TControl> | undefined>;
    /**
     * A form container in readonly mode is only displaying the form content without ability
     * to change it. The edit panel with typically save and cancel buttons is hidden. Set
     * to true to display the edit panel.
     *
     * @defaultValue false
     */
    readonly readonly: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * The container hosts the form within a siResizeContainer to configure the breakpoint for
     * different screen sizes. Optionally, change the container breakpoints with the contentContainerBreakpoints
     * input.
     */
    readonly contentContainerBreakpoints: _angular_core.InputSignal<Breakpoints | undefined>;
    /**
     * In some scenarios, one may not want the form container to be responsible for the layout relevant
     * `si-container-[xs|...]` classes, but let this be done by a different, nested component, e.g. by a
     * group box. In these cases, the property should be set to true.
     *
     * @defaultValue false
     */
    readonly disableContainerBreakpoints: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Every validation error has an errorCode. This map holds translate keys for error codes. The keys can
     * be used to display a translated message for each validation error. The defaults old english readable
     * key defaults for the Angular standard validators of the `Validators` class like `min`, `max` or `required`.
     *
     * Use the input to set your own translate keys for the form validators you need.
     */
    readonly errorCodeTranslateKeyMap: _angular_core.InputSignal<SiFormValidationErrorMapper | Map<string, string> | undefined>;
    /**
     * A map the maps from control names of the form to their translate keys.
     * The initial map is empty and the user is responsible to add the required
     * translate keys.
     *
     * @defaultValue
     * ```
     * new Map<string, string>()
     * ```
     */
    readonly controlNameTranslateKeyMap: _angular_core.InputSignal<Map<string, string>>;
    /**
     * Disables the automatic error printing in all nested {@link SiFormItemComponent}. Error printing will be enabled by default in v46.
     *
     * @defaultValue false
     */
    readonly disableErrorPrinting: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * A custom width value to be applied to all labels.
     *
     * @example labelWidth="100px".
     */
    readonly labelWidth: _angular_core.InputSignal<string | undefined>;
    protected hasParentContainer: boolean;
    /** @internal */
    readonly formErrorMapper: _angular_core.Signal<{
        [key: string]: string | ((error: any) => string) | undefined;
        required?: TranslatableString | ((error: {
            required: boolean;
        }) => TranslatableString);
        requiredTrue?: TranslatableString | ((error: {
            required: boolean;
        }) => TranslatableString);
        email?: TranslatableString | ((error: {
            email: boolean;
        }) => TranslatableString);
        min?: TranslatableString | ((error: {
            min: number;
            actual: number;
        }) => TranslatableString);
        max?: TranslatableString | ((error: {
            max: number;
            actual: number;
        }) => TranslatableString);
        minLength?: TranslatableString | ((error: {
            requiredLength: number;
            actualLength: number;
        }) => TranslatableString);
        maxLength?: TranslatableString | ((error: {
            requiredLength: number;
            actualLength: number;
        }) => TranslatableString);
        pattern?: TranslatableString | ((error: {
            pattern: string | RegExp;
        }) => TranslatableString);
        numberFormat?: TranslatableString | ((error: {
            numberFormat: boolean;
        }) => TranslatableString);
        dateFormat?: TranslatableString | ((error: {
            format: string;
        }) => TranslatableString);
        maxDate?: TranslatableString | ((error: {
            max: Date;
            actual: Date;
        }) => TranslatableString);
        minDate?: TranslatableString | ((error: {
            min: Date;
            actual: Date;
        }) => TranslatableString);
    }>;
    /**
     * Indicates whether the user interacted with the form.
     * @returns `true`, if the user selected at least one form element and
     * [blurred]{@link https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event} by losing focus again
     * (e.g. by setting focus on another element), or by editing the content of a form element.
     * Otherwise `false`.
     */
    get userInteractedWithForm(): boolean;
    /**
     * Indicates whether content editor message shall be styled as success.
     * @returns `true`, if {@link SiFormContainerComponent.userInteractedWithForm} is true and
     * the form is valid.
     */
    get validFormContainerMessage(): boolean;
    /**
     * Indicates whether the content editor message shall be styled as warning.
     * @returns `true`, if {@link SiFormContainerComponent.userInteractedWithForm} is true and
     * the form is invalid.
     */
    get invalidFormContainerMessage(): boolean;
    protected getControlNameTranslateKey(controlName: string): string | undefined;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFormContainerComponent<any>, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiFormContainerComponent<any>, "si-form-container", never, { "form": { "alias": "form"; "required": false; "isSignal": true; }; "readonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "contentContainerBreakpoints": { "alias": "contentContainerBreakpoints"; "required": false; "isSignal": true; }; "disableContainerBreakpoints": { "alias": "disableContainerBreakpoints"; "required": false; "isSignal": true; }; "errorCodeTranslateKeyMap": { "alias": "errorCodeTranslateKeyMap"; "required": false; "isSignal": true; }; "controlNameTranslateKeyMap": { "alias": "controlNameTranslateKeyMap"; "required": false; "isSignal": true; }; "disableErrorPrinting": { "alias": "disableErrorPrinting"; "required": false; "isSignal": true; }; "labelWidth": { "alias": "labelWidth"; "required": false; "isSignal": true; }; }, {}, never, ["[si-form-container-message]", "[si-form-container-buttons]", "[si-form-container-content]"], true, never>;
}

declare class SiFormFieldsetComponent implements DoCheck {
    private static labelIdCounter;
    /** The label for the entire fieldset. */
    readonly label: _angular_core.InputSignal<TranslatableString>;
    /** Overrides the parent label width. */
    readonly labelWidth: _angular_core.InputSignal<string | undefined>;
    /**
     * Adds a required marker to the label
     *
     * @defaultValue false
     */
    readonly required: _angular_core.InputSignalWithTransform<boolean, unknown>;
    /**
     * Switches all child inputs to inline mode
     *
     * @defaultValue false
     */
    readonly inline: _angular_core.InputSignalWithTransform<boolean, unknown>;
    private readonly formItems;
    /** @internal */
    readonly hasOnlyRadios: _angular_core.Signal<boolean>;
    protected readonly errors: _angular_core.Signal<_siemens_element_ng_form.SiFormError[]>;
    protected readonly touched: _angular_core.WritableSignal<boolean>;
    protected readonly isRequired: _angular_core.Signal<boolean>;
    protected labelId: string;
    ngDoCheck(): void;
    /** @internal */
    registerFormItem(item: SiFormItemComponent): void;
    /** @internal */
    unregisterFormItem(item: SiFormItemComponent): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFormFieldsetComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiFormFieldsetComponent, "si-form-fieldset", never, { "label": { "alias": "label"; "required": true; "isSignal": true; }; "labelWidth": { "alias": "labelWidth"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "inline": { "alias": "inline"; "required": false; "isSignal": true; }; }, {}, never, ["[si-help-button]", "*"], true, never>;
}

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

declare const SI_FORM_ITEM_CONTROL: InjectionToken<SiFormItemControl>;
/**
 * Common interface for form item controls.
 * Controls that should be connected to {@link SiFormItemComponent} must implement this interface
 * and must be provided using the {@link SI_FORM_ITEM_CONTROL} token.
 */
interface SiFormItemControl {
    /** The actual id of the control that should be used in the `for` attribute of a label. */
    readonly id?: string | Signal<string | undefined>;
    /**
     * ID that should be assigned to the label element inside the {@link SiFormItemComponent}.
     *
     * If the target control is not of type <i>input</i>, <i>select</i> or <i>button</i>, it cannot be referenced by a label.
     * Instead, aria-labelledby must be used to create a reference to a label.
     * In such a case, an implementation of {@link SiFormItemControl} must provide the id of the label in {@link labelledby}.
     * {@link SiFormItemComponent} will apply the id to the label
     * so that it can be used inside the control to reference it in the aria-labelledby attribute.
     */
    readonly labelledby?: string | Signal<string | undefined> | null;
    /**
     * Generated ID that the {@link SiFormItemComponent} will assign to the element containing the error messages.
     * Implementations of {@link SiFormItemControl} must generate this ID
     * and assign it to the `aria-describedby` attribute of their focusable elements.
     */
    readonly errormessageId: string | Signal<string>;
    /** If the control is meant to be used a checkbox. This affects the label positioning. */
    readonly isFormCheck?: boolean;
}

/** @internal */
interface SiFormError {
    key: string;
    message?: TranslatableString;
    params: any;
}
declare class SiFormItemComponent implements AfterContentInit, AfterContentChecked, OnChanges, OnInit, OnDestroy {
    /**
     * The label to be displayed in the form item.
     * It will be translated if a translation key is available.
     */
    readonly label: _angular_core.InputSignal<TranslatableString>;
    /**
     * A custom width value to be applied to the label.
     * A value of 0 is allowed as well to visually hide away the label area.
     *
     * Numbers will be converted to pixels.
     * Using numbers is discouraged and might be dropped.
     *
     * @example labelWidth="100px"
     */
    readonly labelWidth: _angular_core.InputSignal<string | number | undefined>;
    /**
     * Disables the automatic error printing. Error printing will be enabled by default in v46.
     *
     * @defaultValue false
     */
    readonly disableErrorPrinting: _angular_core.InputSignalWithTransform<boolean, unknown>;
    readonly formErrorMapper: _angular_core.InputSignal<SiFormValidationErrorMapper | undefined>;
    /**
     * Defines that this form item is required for the overall form to be valid.
     *
     * @defaultValue false
     */
    readonly requiredInput: _angular_core.InputSignalWithTransform<boolean, unknown>;
    protected readonly fieldControlQuery: _angular_core.Signal<SiFormItemControl | undefined>;
    /** @internal */
    readonly ngControl: _angular_core.Signal<NgControl | undefined>;
    protected readonly controlElementRef: _angular_core.Signal<ElementRef<HTMLElement> | undefined>;
    protected readonly requiredValidator: _angular_core.Signal<RequiredValidator | undefined>;
    /** @internal */
    readonly errors: _angular_core.WritableSignal<SiFormError[]>;
    protected fieldset: SiFormFieldsetComponent | null;
    protected container: SiFormContainerComponent<{
        [x: string]: _angular_forms.AbstractControl<any, any, any>;
    }> | null;
    protected get formItemId(): string | null;
    protected get formItemLabelledBy(): string | null;
    protected get formItemErrormessageId(): string | null;
    protected readonly fieldControl: _angular_core.Signal<SiFormItemControl | undefined>;
    private validationErrorService;
    private requiredTestControl;
    private validator?;
    private previousErrors?;
    private readonly hasRequiredValidator;
    private readonly fieldControlNative;
    protected readonly labelWidthCssVar: _angular_core.Signal<string | undefined>;
    protected readonly printErrors: _angular_core.Signal<boolean>;
    /** @internal */
    readonly required: _angular_core.Signal<boolean>;
    ngOnChanges(changes: SimpleChanges<this>): void;
    ngOnInit(): void;
    ngAfterContentInit(): void;
    ngAfterContentChecked(): void;
    ngOnDestroy(): void;
    private updateRequiredState;
    private updateValidationMessages;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFormItemComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<SiFormItemComponent, "si-form-item", never, { "label": { "alias": "label"; "required": true; "isSignal": true; }; "labelWidth": { "alias": "labelWidth"; "required": false; "isSignal": true; }; "disableErrorPrinting": { "alias": "disableErrorPrinting"; "required": false; "isSignal": true; }; "formErrorMapper": { "alias": "formErrorMapper"; "required": false; "isSignal": true; }; "requiredInput": { "alias": "required"; "required": false; "isSignal": true; }; }, {}, ["fieldControlQuery", "ngControl", "controlElementRef", "requiredValidator"], ["[si-help-button]", ".warning-feedback, .info-feedback, .invalid-feedback", "*"], true, never>;
}

/**
 * Directive to show a tooltip with validation errors of a form control.
 *
 * In general, `si-form-item` should be used.
 * This directive is intended only for cases where the tooltip cannot be shown inline.
 * This is typically the case for tables and lists where the validation message would break the layout.
 *
 * @example
 * ```html
 * <input siFormValidationTooltip [formControl]="control" />
 * ```
 */
declare class SiFormValidationTooltipDirective implements OnDestroy, DoCheck {
    private static idCounter;
    private tooltipService;
    private formValidationService;
    private formContainer;
    readonly formErrorMapper: _angular_core.InputSignal<SiFormValidationErrorMapper | undefined>;
    private ngControl;
    private elementRef;
    private tooltipRef?;
    private readonly errors;
    private currentErrors;
    private touched;
    private activationCount;
    protected readonly describedBy: string;
    ngDoCheck(): void;
    ngOnDestroy(): void;
    protected increaseActivation(): void;
    private updateErrors;
    protected decreaseActivation(): void;
    private destroyTooltip;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFormValidationTooltipDirective, never>;
    static ɵdir: _angular_core.ɵɵDirectiveDeclaration<SiFormValidationTooltipDirective, "[siFormValidationTooltip]", never, { "formErrorMapper": { "alias": "formErrorMapper"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
}

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

declare class SiFormModule {
    /**
     * Overrides the default configuration of the form module.
     *
     * @param errorMapper - The error mappers is used to resolve angular validation errors.
     * It will be merged with already existing error mappers.
     */
    static withConfiguration({ validationErrorMapper }: {
        validationErrorMapper: SiFormValidationErrorMapper;
    }): ModuleWithProviders<SiFormModule>;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<SiFormModule, never>;
    static ɵmod: _angular_core.ɵɵNgModuleDeclaration<SiFormModule, never, [typeof SiFormContainerComponent, typeof SiFormFieldsetComponent, typeof SiFormItemComponent], [typeof SiFormContainerComponent, typeof SiFormFieldsetComponent, typeof SiFormItemComponent]>;
    static ɵinj: _angular_core.ɵɵInjectorDeclaration<SiFormModule>;
}

/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */

/**
 * The error mapper is used to resolve an angular validation error to a {@link TranslatableString}.
 * It will be merged with already existing error mappers.
 */
declare const provideFormValidationErrorMapper: (mapper: SiFormValidationErrorMapper) => Provider;

export { SI_FORM_ITEM_CONTROL, SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent, SiFormModule, SiFormValidationTooltipDirective, provideFormValidationErrorMapper };
export type { SiFormError, SiFormItemControl, SiFormValidationError, SiFormValidationErrorMapper };
