import Bluebird from "../deps/bluebird_fork";
import * as defs from "./FormDefinition";
import { FormPresenterHost, Facility } from "./FormPresenterHost";
import { FormatOptions } from "./numberFormatter";
import { Lookup } from "../Collections";
import { Calendar } from "./components/Calendar";
export { defs, Facility };
export interface FormEventSubscription {
    (): boolean;
    active: boolean;
}
export interface FormEventHandler {
    (event: defs.Event): void;
}
/** Exposes functionality for driving a form. */
export declare abstract class FormHost implements FormPresenterHost {
    /** Indicates the overall state of the form. */
    form: defs.Form;
    /** Indicates all errors to be assigned. */
    errors: Lookup<defs.Text>;
    /** Indicates any reference information relevant to components. */
    refs: {};
    /** Indicates if the form is enabled. */
    enabled: boolean;
    /** Indicates if the form is visible. */
    visible: boolean;
    /** Indicates if the form should be dismissed. */
    dismiss: boolean;
    /** Indicates if the form is a custom form. */
    custom: boolean;
    /** The DOM container node. */
    container: HTMLElement;
    /** The next event index. */
    protected eventIndex: number;
    /** The event queue. */
    protected eventQueue: defs.Event[];
    private resolveEvent;
    /** The event promise, for when the consumer is waiting. */
    private eventTask;
    /** The timer handler for idle/busy handling. */
    protected timerHandle: () => void;
    /** Indicates a method to restore the last focus. */
    protected lastFocus: HTMLElement;
    /** Indicates the next element that should receive focus. */
    protected nextFocus: boolean | string;
    /** Indicates the next element that should receive a refresh. */
    protected nextRefresh: boolean | Lookup<boolean>;
    /** Indicates the focus observer. */
    protected focusObserver: (event: FocusEvent) => void;
    /** Indicates the style o */
    protected style: HTMLStyleElement;
    /** Mounts the form into the DOM. */
    protected mount(): void;
    /** Removes the form from the DOM. */
    protected unmount(): void;
    /** Intelligently tracks the last focus, */
    protected observeFocus(target: EventTarget): void;
    /** Focuses the form. */
    focus(): void;
    /** Focuses the form optionally focusing the initial element. */
    focus(initial: boolean): void;
    /** Focuses the form focusing the named element. */
    focus(name: string): void;
    /** Shows the form. */
    show(): boolean;
    /** Shows the form in a disabled state. */
    spin(): boolean;
    /** Hides the form in a disabled state. */
    hide(): boolean;
    /** Disposes the form. */
    dispose(): boolean;
    /** Renders focus for just rendered elements. */
    renderFocus(target: HTMLElement, name?: string): boolean;
    /** Renders form text as HTML. */
    renderHtml(content: defs.Text, htmlContentCategory?: defs.HTMLContentCategory): string;
    /** Renders form text as plain text. */
    renderText(content: defs.Text | undefined): string;
    /** Renders the style for the form. */
    renderStyle(css?: string): HTMLStyleElement;
    /** Renders the form component. */
    renderVisual(component: {}): any;
    /** Qualifies an event with defaults. */
    protected qualifyDefault(event: defs.Event): string;
    /** Qualifies an event. */
    protected qualify(type: defs.EventType, event?: defs.Event): defs.Event;
    /** Posts an event. */
    post(type: defs.EventType, event?: defs.Event): void;
    /** Subscribes to all posted events (this does not capture enqueued events). */
    subscribe(action: FormEventHandler): FormEventSubscription;
    /** Forcefully refresh the form (use this with care). */
    refresh(name?: string): void;
    /** Invalidates the form with a full refresh. */
    invalidate(): void;
    /** Invalidates the form with optionally a full refresh. */
    invalidate(full: boolean): void;
    /** Invalidates the form refreshing a single element. */
    invalidate(name: string): void;
    /** Updates the form if appropriate. */
    update(): void;
    /** Clears the busy timer. */
    idle(): void;
    /** Starts the busy timer. */
    busy(): void;
    /** Publishes an event (used by post()). */
    publish(type: defs.EventType, event?: defs.Event): defs.Event;
    /** Enqueues an event (used by publish()). */
    enqueue(type: defs.EventType, event?: defs.Event): defs.Event;
    /** Dequeues the next event (used by observe()). */
    dequeue(): defs.Event;
    /** Observes the form. */
    observe(): Bluebird<defs.Event>;
    /** Loads the form. */
    load(): boolean;
    /** Loads the form with a new definition. */
    load(form: defs.Form, template?: defs.Form): boolean;
    /** Routes an event to achieve default behavior. */
    route(event: defs.Event): boolean;
    /** Generates a new changed event given the source event. */
    protected changed(event: defs.Event): boolean;
    /**
     * Returns true if the supplied element is considered valid, false otherwise.
     * @param element The element to be tested.
     * @param isInvisibleValid True if the element should be considered valid when not visible, false otherwise. Defaults to true.
     * @param result An optional object which can be passed in to capture the error status, if any.
     */
    protected isElementValid(element: defs.Element, isInvisibleValid?: boolean, result?: defs.StatusRef): boolean;
    /**
     * Returns true if the supplied element is effectively visible (i.e. has parent
     * section - if it exists - visible) as well as itself, false otherwise.
     * @param element The element to be tested.
     */
    protected isElementEffectivelyVisible(element: defs.Element): boolean;
    /**
     * Returns true if the element has a value defined. False otherwise.
     * @param element The element to be tested.
     */
    protected isElementValueDefined(element: defs.Element): boolean;
    /**
     * Attempts to trap the event. This is relevant during cascading behavior which affects
     * other elements but afterwards.
     */
    trap(event: defs.Event): boolean;
    /** Attempts to cascade the form. */
    protected cascade(name: string): boolean;
    /** Routes a click event. */
    protected click(event: defs.Event): boolean;
    /** Routes a prepare event. */
    protected hydrate(event: defs.Event): boolean;
    /** Determines if the event origin is a submit button. */
    protected shouldTriggerValidation(event: defs.Event): boolean | void;
    /** Routes a validate event. */
    protected validate(event: defs.Event): boolean;
    /** Verifies the element given the event. */
    protected verify(event: defs.Event): boolean;
    /** Routes a suggest event. */
    protected suggest(event: defs.Event): boolean;
    /** Routes a submit event. */
    protected submit(event: defs.Event): boolean;
    /** Checks the form's validity. */
    hasErrors(): boolean;
    /** Finds an element. */
    find(name: string | {
        name: string;
    }): defs.Element;
    /** Coerces a number. */
    coerceNumber(value: string): number;
    /** Formats a number. */
    formatNumber(value: number, options: Intl.NumberFormatOptions | FormatOptions, useBrowserIntlApi?: boolean): string;
    /** Renders a custom element. */
    renderCustom(component: {}, element: defs.Element): JSX.Element;
    /** Renders a component's state. */
    renderState(name: string, type: "geometry", state?: defs.GeometryState[]): boolean;
    /** Renders a component's state. */
    renderState(name: string, type: string, state?: {}): boolean;
    /** Derives the locale for the given facility. */
    deriveCalendar(format: defs.DateTimeFormat): Calendar;
    /** Derives the locale for the given facility. */
    deriveLocale(facility: Facility): string;
    /** Derives the locale for the given facility. */
    deriveTimeZone(facility: Facility): any;
    private getParentSection;
    private isSectionCollapsed;
}
