import { ComponentInterface } from '../../stencil-public-runtime';
import { FormFieldValidationRule } from './rules/form-field-validation-rule';
import { Validator } from './validator';
import { FieldErrorUIControllerSlimmer } from '../slimmers/field-error-ui-controller-slimmer';
import { FormFieldOptionForSlimmer } from '../slimmers/form-field-controller-slimmer';
import { PageResizeObserverSlimmer } from '../slimmers/page-resize-observer-slimmer';
import { EvaluateResultBase } from './rules/validation-rule';
import { FormFieldMessageTranslatorSlimmer } from '../slimmers/form-field-message-translator';
export declare type FormFieldDefaultValueType<T> = T | ((host: ComponentInterface) => T);
export declare type FormFieldElement<T> = HTMLElement & {
  value?: T;
  componentOnReady?: () => Promise<HTMLElement>;
  autoValidation?: boolean;
  isValid?: boolean;
};
export declare type InputValidatorListener = {
  callback: (isValid: boolean) => void;
};
/**
 * The FormFieldController class is a class that validates the value of an input elements
 *
 * @implements {Validator<number | string | boolean | null>}
 * @property {FormFieldValidationRule<number | string | boolean>[] = []} defaultRules default rules used for validation
 * @property {FormFieldValidationRule<number | string | boolean>[]} additionalRules additional rules used for validation
 * @property {InputValidatorListener[]} listeners listeners monitoring on the validation result
 * @property {unknown & { value?: number | string | boolean }} hostElement host element used to get the value for validation if input element is not present
 * @property {boolean} isTouched true if an element is touched
 * @property {boolean} isModified true if an element is modified
 * @property {boolean} isVisible true if an element is visible
 * @property {string} touchableArea define the area which listen to the blur event
 * @property {MutationObserver} disabledAttrObserver reference to the MutationObserver
 * @property {ResizeObserver} visibilityObserver reference to the ResizeObserver
 * @property {Observer<boolean>} formResetTriggeredObserver reference to formResetTriggeredObserver
 */
export declare class FormFieldController<T> implements Validator<T> {
  protected readonly formFieldMessageTranslatorSlimmer: FormFieldMessageTranslatorSlimmer;
  protected readonly fieldErrorUIController: FieldErrorUIControllerSlimmer;
  protected readonly resizeObserverSlimmer: PageResizeObserverSlimmer;
  protected options: Partial<FormFieldOptionForSlimmer<T>>;
  private defaultRules;
  private additionalRules;
  private listeners;
  private readonly host;
  private isTouched;
  private isModified;
  private isVisible;
  private disabledAttrObserver;
  private formResetTriggeredObserver;
  private defaultValue;
  private formFieldValidationRuleHandlerChain;
  private hostValueChangeObserver;
  private hostChildrenObserver;
  private hostChildAddedBlurEventMap;
  private disableBlurValidation;
  /**
   * This function is called when the component is created, and it sets up the observers that will be used to detect changes to the component's state.
   * The first thing the constructor does is set the defaultRules, hostElement, touchableArea, isTouched, isModified, and isDisabled properties
   *
   * @param {FormFieldValidationRule<number | string | boolean>[]} defaultRules - FormFieldValidationRule<T>[]
   * @param {FormFieldElement<number | string | boolean>} hostElement - The form field element that this validation manager is attached to.
   * @param {FormFieldDefaultValueType}  defaultValue - This is defualt value for value property of component.
   * @param {FormFieldOptionForSlimmer} options - The selector for the element that contains the input element.
   */
  constructor(defaultRules: FormFieldValidationRule<T>[], hostElement: FormFieldElement<T>, defaultValue: FormFieldDefaultValueType<T> | null, options: Partial<FormFieldOptionForSlimmer<T>>);
  /**
   * It validates the input against the rules and returns a boolean indicating whether the input is valid or not
   *
   * @param {boolean} showError whether the validation result should be reflected in UI
   * @returns {Promise<EvaluateResultBase>} A promise value.
   */
  validate(showError?: boolean | 'rule'): Promise<EvaluateResultBase>;
  /**
   * This function adds a listener to the listeners array.
   *
   * @param {InputValidatorListener} listener - The listener to add.
   */
  addListener(listener: InputValidatorListener): void;
  /**
   * It returns an array of all the validation rules for the field
   *
   * @typedef T generic type
   * @returns {FormFieldValidationRule<T>[]} An array of FormFieldValidationRule<T>
   */
  getRules(): FormFieldValidationRule<T>[];
  /**
   * Set the default rules for the form field.
   *
   * @param {FormFieldValidationRule<number | string | boolean>[]} rules - FormFieldValidationRule<T>[]
   */
  setDefaultRules(rules: FormFieldValidationRule<T>[]): void;
  /**
   * This function sets the additional rules for the form field
   *
   * @param {FormFieldValidationRule<number | string | boolean>[]} rules - The rules that are required for the field to be valid.
   */
  setAdditionalRules(rules: FormFieldValidationRule<T>[]): void;
  /**
   * The destroy function unregister the form reset observer
   */
  destroy(): void;
  /**
   * It creates an observer that will watch the host element and set the isVisible property to true if
   * the element is visible.
   */
  connectResizeObserver(): void;
  /**
   * Updates the `disableBlurValidation.
   *
   * @param {boolean} disableBlurValidation - From parent vega form.
   */
  updateDisableBlurValidation(disableBlurValidation: boolean): void;
  /**
   * The function "updateValidationHandlers" initializes the validation rule handler chain with the rules obtained from the "getRules" function.
   */
  private updateValidationHandlers;
  /**
   * valid function to validate the rules
   */
  private valid;
  /**
   * The function handles the validation result and updates the UI accordingly.
   *
   * @param {boolean | 'rule'} showError - which indicates that the error message should only be shown if the `shouldShowError` property of the
   * `validationResult` object is `true` or `rule`
   * @param {ValidationResult} invalidationResult - The `validationResult` parameter is an object that
   * represents the result of a validation process. It contains information about whether the validation
   * was successful or not, and an optional error message.
   * @returns {boolean} a boolean value, which represents whether the validation result is valid or not.
   */
  private handleValidationResult;
  /**
   * Invoke all listeners with the given isValid value
   *
   * @param {boolean} isValid - boolean
   */
  private invokeListeners;
  /**
   * It returns an object with the current status of the form field
   *
   * @returns {FormFieldStatusMeta} The status of the form field.
   */
  private getStatus;
  /**
   * It updates the `isTouched` property and if auto validation is enabled, it validates the input
   *
   * @param {boolean} touched - boolean - whether the input is touched or not
   */
  private updateIsTouched;
  /**
   * "If the value of the `isModified` property has changed, then update the `isModified` property and if auto-validation is enabled, then validate the control."
   *
   * @param {boolean} modified - boolean - whether the value has been modified or not
   */
  private updateIsModified;
  /**
   * It creates a new MutationObserver that watches for changes to the disabled attribute of the host
   * element, and when it detects a change, it validates the host element's value
   */
  private initDisabledAttrObserver;
  /**
   * If the input form is a child of the current form, then the current form can accept the input form's reset operation
   *
   * @param {ResetOperationPayload} input - VegaForm - The form that is being reset.
   * @returns {boolean} A boolean value.
   */
  private canAcceptFormResetOperation;
  /**
   * Unregister the form reset observer.
   */
  private unregisterFormResetObserver;
  /**
   * monitor the host component touchable area elements update
   */
  private monitorTouchedListener;
  /**
   * It adds a blur event listener to all elements that match the selector in the touchableArea property
   */
  private setupTouchedListener;
  /**
   * Get an array of HTMLElements that represent the touchable area elements based on the host's tag name.
   *
   * @returns {Nullable<HTMLElement>[]} an array of HTMLElements.
   */
  private getTouchableAreaElements;
  /**
   * Get the input container element based on the options provided.
   *
   * @returns {Nullable<HTMLElement>} the form field element input container element
   */
  private getInputContainerElements;
  /**
   * It adds an event listener to the host element that listens for a custom event called `vegaChange`.
   * When that event is fired, the `updateIsModified` function is called with the argument `true`
   */
  private setupModifiedListener;
  /**
   * The function checks if the host of the input matches the host of the current target.
   *
   * @param {NotifyObserverPayload<unknown>} input - The `input` parameter is of type `NotifyObserverPayload<unknown>`.
   * @returns {boolean} a boolean value, which indicates whether the `host` property of the current object is
   * equal to the `host` property of the `input` object.
   */
  private isCurrentTarget;
  /**
   * It resets the form field's status and then validates the form field with the current value
   *
   * @param {ResetOperationPayload} payload - ResetOperationPayload
   */
  private reset;
  /**
   * If the default value is a function, call it with the host element as the argument, otherwise return
   * the default value
   */
  private getDefaultValue;
  /**
   * This function is called after the component has been rendered. It re-attaches the invalid UI to
   * the input element, and sets up the listeners for the `touched` and `modified` events
   */
  private didRender;
  /**
   * This function registers an observer with the ChangeManager that will be notified when a form
   * reset operation is triggered
   */
  private initFormResetObserver;
  /**
   * "If the host element's autoValidation property is not false, then return true."
   * The host element is the element that the directive is attached to. In this case, the host element is the input element
   *
   * @returns {boolean} A boolean value.
   */
  private isAutoValidationEnabled;
  /**
   * Return true if the HTMLElement has data-vega-form property and it's not disabled and not invisible if these two properties have to be checked.
   *
   * @param {HTMLElement} element - The HTMLElement to check.
   * @param {boolean} skipDisabled - If true, then disabled form fields will be skipped.
   * @param {boolean} skipInvisible - If true, only visible elements will be visited.
   * @returns {boolean} a boolean value.
   */
  private shouldVisitElement;
  /**
   * It listens for the keydown event on the host element, and if the key pressed is the enter key, it
   * notifies the ChangeManager that the form has been submitted
   */
  private listenHostElementKeydown;
  /**
   * The function determines whether a form can be submitted based on the event type and the element's
   * tag name.
   *
   * @param {KeyboardEvent} event - The event parameter is of type KeyboardEvent. It represents the
   * keyboard event that occurred.
   * @returns {boolean} a boolean value.
   */
  private canSubmitFormByEvent;
  /**
   * It overrides the default rule by checking if the additional rules contain a custom rule that overrides.
   * If it does, it returns that additional rule, and the rule will be removed from the additional rules array.
   * otherwise, it returns the default rule.
   *
   * @typedef T generic type
   * @param {InternalFormFieldValidationRule} defaultRule - The rule to be overridden.
   * @param {FormFieldValidationRule[]} additionalRules - The additional rules to be applied.
   * @returns {FormFieldValidationRule<T>} The overridden rule.
   */
  private overrideDefaultRuleByAdditionalRule;
}
