/**
 * Created by rburson on 1/6/16.
 */
import * as React from 'react';
import { NavRequest, AppWinDef, AppContext, PaneContext, PropDef } from 'catavolt-sdk';
/**
  Base interface for Catavolt component properties
  Components may choose to support any of these properties
 */
export interface CvProps {
    /**
     *  The Catavolt SDK entry point, an instance of the sdk {AppContext} which is always available to components.
     *  A singleton instance is used by the underlying components to interact with the sdk.
     */
    catavolt?: AppContext;
    /**
     *  The {@link CvEventRegistry} handles decoupled communication between components.  Any component may subscribe to and publish
     *  {@link CvEvent}s.  See also {@link CvListener} and {@link CvEventType}
     */
    eventRegistry?: CvEventRegistry;
    /**
     * Allows for a component's rendering logic to be overridden and completely customized.
     * The first argument, the {@link CvContext}, exposes the {@link CvScopeContext} which provides the relevant SDK object
     * for use by the renderer.  {@link CvScopeContext.scopeObj} will always be an SDK object exposing the data related to
     * the current component.
     */
    renderer?: (cvContext: CvContext, callbackObj?: any) => {};
}
/**
 Base interface for catavolt component state
 */
export interface CvState {
}
/**
 Top-level Catavolt Context Object
 */
export interface CvContext {
    /**
     *  The Catavolt SDK entry point, an instance of the sdk {AppContext} which is always available to components.
     *  A singleton instance is used by the underlying components to interact with the sdk.
     */
    catavolt?: AppContext;
    /**
     *  The {@link CvEventRegistry} handles decoupled communication between components.  Any component may subscribe to and publish
     *  {@link CvEvent}s.  See also {@link CvListener} and {@link CvEventType}
     */
    eventRegistry?: CvEventRegistry;
    /**
     Allows for exposing a 'scope' object to child components
     This is usually the corresponding SDK object
     */
    scopeCtx?: CvScopeContext;
}
/**
    Allows for exposing a 'scope' object to child components
    This is usually the corresponding SDK object
 */
export interface CvScopeContext {
    /**
     * The object relevant to this components 'scope'.  Usually an SDK object corresponding to the component type.
     */
    scopeObj: any;
    /**
     * The parent's scope context (if any)
     * This allows for navigation back up the component hierarchy
     */
    parentScopeCtx: CvScopeContext;
}
/**
 Base Mixin for all catavolt components
 */
export declare var CvBaseMixin: {
    contextTypes: {
        cvContext: React.Requireable<any>;
    };
    childContextTypes: {
        cvContext: React.Requireable<any>;
    };
    catavolt: () => AppContext;
    eventRegistry: () => CvEventRegistry;
    findFirstDescendant: (elem: any, filter: (o: any) => boolean) => any;
    findAllDescendants: (elem: any, filter: (o: any) => boolean, results?: any[]) => any[];
    findFirstScopeCtx: (matchFn: (scopeCtx: CvScopeContext) => boolean, startingCtx?: CvScopeContext) => CvScopeContext;
    findEntityRec: (startingContext?: CvScopeContext) => any;
    findPaneContext: (startingContext: CvScopeContext) => any;
    findPaneTitle: (paneContext: PaneContext) => string;
    firstInScope: (type: any, startingScopeCtx?: CvScopeContext) => any;
    getDefaultChildContext: () => {
        cvContext: {
            catavolt: any;
            eventRegistry: any;
            scopeCtx: {
                scopeObj: any;
                parentScopeCtx: any;
            };
        };
    };
    resourceIdForObject: (o: any) => string;
    scopeCtx: () => CvScopeContext;
    shouldCacheResult: () => boolean;
};
/**
 ******************************************************************
 * General Callback mechanism
 ******************************************************************
 */
export interface CvResultCallback<A> {
    (success: A, error?: any): void;
}
export interface CvListener<T> {
    (event: CvEvent<T>): void;
}
export interface CvEvent<T> {
    type: CvEventType;
    eventObj: T;
    resourceId?: string;
}
/**
 *  Enumeration of event types to be used with {@link CvEvent}
 *  There is also a corresponding 'payload' object type for each of these
 *  enum values, that is used as the {@link CvEvent.eventObj} type
 */
export declare enum CvEventType {
    LOGIN = 0,
    LOGOUT = 1,
    ACTION_FIRED = 2,
    NAVIGATION = 3,
    STATE_CHANGE = 4,
    MESSAGE = 5,
}
export interface CvLoginResult {
    appWinDef: AppWinDef;
}
export interface CvLogoutResult {
}
export declare enum CvNavigationResultType {
    FORM = 0,
    URL = 1,
    NULL = 2,
}
export interface CvNavigationResult {
    navRequest: NavRequest;
    workbenchId?: string;
    actionId?: string;
    navTarget?: string;
    sourceIsDestroyed?: boolean;
    noTransition?: boolean;
    type: CvNavigationResultType;
}
export declare enum CvMessageType {
    ERROR = 0,
    WARN = 1,
    INFO = 2,
}
export interface CvMessage {
    type: CvMessageType;
    message: string;
    messageObj?: any;
}
export declare class CvNavigationResultUtil {
    static determineType(navRequest: NavRequest): CvNavigationResultType;
}
export declare enum CvStateChangeType {
    DATA_CHANGE = 0,
    DESTROYED = 1,
}
export interface CvStateChangeResult {
    source?: PaneContext;
    type: CvStateChangeType;
}
export declare enum CvActionFiredResultType {
    ACTION_STARTED = 0,
    ACTION_COMPLETED = 1,
}
export interface CvActionFiredResult {
    actionId: string;
    type: CvActionFiredResultType;
    source: PaneContext;
    clientAction: boolean;
}
/**
 *  The {@link CvEventRegistry} handles decoupled communication between components.  Any component may subscribe to and publish
 *  {@link CvEvent}s.  See also {@link CvListener} and {@link CvEventType}.  It also provides resource caching (i.e. caching of
 *  some server provided objects to allow retrieval by 'id')
 */
export declare class CvEventRegistry {
    private _cache;
    private _listenerMap;
    constructor();
    clearAll(): void;
    clearCache(): void;
    enableCache(): void;
    disableCache(): void;
    isCacheEnabled(): boolean;
    getEventByKey<T>(key: string): CvEvent<T>;
    publish<T>(event: CvEvent<T>, shouldCache?: boolean): void;
    removeFromCache(key: string): void;
    subscribe<T>(listener: CvListener<T>, eventType: CvEventType): void;
    removeAllListeners(): void;
    unsubscribe(listener: CvListener<any>): void;
}
/**
 *  Part of a generalized interface for allowing two components to communicate 'state' changes
 *  i.e. a workbench display and a workbench selector menu.
 *  The following compose this mechanism: {@link CvValueListener}, {@link CvValueProvider}, {@link CvValueAdapter}
 */
export interface CvValueListener<T> {
    (value: T): void;
}
export interface CvValueProvider<T> {
    value: T;
    subscribe(updateListener: CvValueListener<T>): void;
}
export declare class CvValueAdapter<T> implements CvValueProvider<T> {
    private _value;
    private _subscriberArray;
    value: T;
    createValueListener(): CvValueListener<T>;
    subscribe(updateListener: CvValueListener<T>): void;
}
/**
 * Localization
 */
export declare class CvLocale {
    currencySymbol: string;
    percentageSymbol: string;
    constructor(currencySymbol: string, percentageSymbol: string);
    getAssociatedSymbol(value: string, propDef: PropDef): string;
}
export declare const DefaultLocale: CvLocale;
