import { BaseContext } from '../AdaptableState/Common/BaseContext';
import { IRowNode } from 'ag-grid-enterprise';
import { Action, Chart, ChatInitSettings, ChatMessage, ChatRoom, ChatSearchCriteria, Contact, ContactList, Context, ContextMetadata, ContextType, Country, Currency, Email, Instrument, InstrumentList, Intent, IntentResolution, IntentResult, Interaction, Message, Organization, Portfolio, Position, StandardContextType, StandardIntent, TimeRange, TransactionResult, Valuation } from '@finos/fdc3';
import { AdaptableIcon } from '../AdaptableState/Common/AdaptableIcon';
import { ButtonStyle } from '../AdaptableState/Common/ButtonStyle';
import { RowScope } from '../types';
/**
 * Options for configuring FDC3 in AdapTable
 */
export interface Fdc3Options {
    /**
     * Enable logging message exchanges to Console
     *
     * @defaultValue false
     */
    enableLogging?: boolean;
    /**
     * Maps Context Type to AdapTable Grid Data
     */
    gridDataContextMapping?: GridDataContextMapping;
    /**
     * Builds Context Data (useful for postprocessing Context Data mapped from Grid data)
     */
    resolveContextData?: (context: ResolveContextDataContext) => Context;
    /**
     * Configures FDC3 standard Intents that AdapTable will listen for and raise
     */
    intents?: Fdc3IntentOptions;
    /**
     * Configures FDC3 standard Contexts that AdapTable will listen for and broadcast
     */
    contexts?: Fdc3ContextOptions;
    /**
     * Configures the default FDC3 Actions column
     */
    actionColumnDefaultConfiguration?: ActionColumnDefaultConfiguration;
    /**
     * Customises FDC3 UI Controls
     */
    uiControlsDefaultConfiguration?: {
        contexts?: {
            [contextName in StandardContextType]?: UIControlConfig;
        };
        intents?: {
            [intentName in StandardIntent]?: UIControlConfig;
        };
    };
}
/**
 * Options for configuring FDC3 Intent Behaviour in AdapTable
 */
export interface Fdc3IntentOptions {
    /**
     * Raises given standard Intent(s) on various Grid Actions
     */
    raises?: RaiseIntentConfiguration;
    /**
     * Subscribe to given standard Intent(s)
     */
    listensFor?: Intent[];
    /**
     * Handles incoming Intents (standard and custom)
     */
    handleIntent?: (context: HandleFdc3IntentContext) => Promise<IntentResult> | void;
    /**
     * Handles the IntentResolution that a raised Intent might return
     */
    handleIntentResolution?: (context: HandleFdc3IntentResolutionContext) => Promise<void>;
}
/**
 * Options for configuring FDC3 Context Behaviour in AdapTable
 */
export interface Fdc3ContextOptions {
    /**
     * Broadcasts given standard Context(s) on various Grid Actions
     */
    broadcasts?: BroadcastConfiguration;
    /**
     * Subscribe to given standard Context(s)
     */
    listensFor?: ContextType[];
    /**
     * Handles incoming Contexts (standard and custom)
     */
    handleContext?: (context: HandleFdc3Context) => void;
}
/**
 * Used to customise FDC3 controls (e.g. Action Columns)
 */
export interface UIControlConfig {
    /**
     * Icon to display
     */
    icon?: AdaptableIcon;
}
/**
 * Default configuration to use for an FDC3 Action Column
 */
export interface ActionColumnDefaultConfiguration {
    /**
     * Column Id
     * @defaultValue 'fdc3ActionColumn'
     */
    columnId?: string;
    /**
     * Column Header
     * @defaultValue 'FDC3 Actions'
     */
    headerName?: string;
    /**
     * Column Width in pixels
     * @defaultValue 200
     */
    width?: number;
    /**
     * If Column is resizable
     * @defaultValue true
     */
    resizable?: boolean;
    /**
     * If Column is movable
     * @defaultValue true
     */
    movable?: boolean;
    /**
     * Which rows button appears in
     * @defaultValue data rows only
     */
    rowScope?: RowScope;
}
/**
 * Used to build Context Data
 */
export interface ResolveContextDataContext extends BaseContext {
    /**
     * FDC3 Context Type
     */
    contextType: ContextType;
    /**
     * FDC3 Context Data which has been mapped from the grid data based on the given configuration in `gridDataContextMapping`
     */
    contextMappedFromGridData?: Context;
    /**
     * Row Node which is source of the context data
     */
    rowNode: IRowNode;
    /**
     * Row data which is the source of the context data
     */
    rowData: any;
    /**
     * Primary Key value of row
     */
    primaryKeyValue: any;
}
/**
 * Context used when handling incoming FDC3 messages
 */
export interface HandleFdc3Context extends BaseContext {
    /**
     * The FDC3 Context
     */
    context: Context;
    /**
     * The FDC3 Context Metadata related to the context
     */
    metadata?: ContextMetadata;
}
/**
 * Context used when handling incoming FDC3 Intents
 */
export interface HandleFdc3IntentContext extends HandleFdc3Context {
    /**
     * The FDC3 Intent
     */
    intent: Intent;
}
export declare const ColumnRefTypePrefix = "_colId.";
export declare const FieldRefTypePrefix = "_field.";
export type GridDataRef = `_colId.${string}` | `_field.${string}`;
export type Fdc3ContentMapping<T> = PropertiesToGridRefs<Omit<T, 'type'>>;
/**
 * Mapping of FDC3 Context Types to Grid Data/Columns
 */
export interface GridDataContextMapping {
    'fdc3.action'?: Fdc3ContentMapping<Action>;
    'fdc3.chart'?: Fdc3ContentMapping<Chart>;
    'fdc3.chat.initSettings'?: Fdc3ContentMapping<ChatInitSettings>;
    'fdc3.chat.message'?: Fdc3ContentMapping<ChatMessage>;
    'fdc3.chat.room'?: Fdc3ContentMapping<ChatRoom>;
    'fdc3.chat.searchCriteria'?: Fdc3ContentMapping<ChatSearchCriteria>;
    'fdc3.contact'?: Fdc3ContentMapping<Contact>;
    'fdc3.contactList'?: Fdc3ContentMapping<ContactList>;
    'fdc3.country'?: Fdc3ContentMapping<Country>;
    'fdc3.currency'?: Fdc3ContentMapping<Currency>;
    'fdc3.email'?: Fdc3ContentMapping<Email>;
    'fdc3.instrument'?: Fdc3ContentMapping<Instrument>;
    'fdc3.instrumentList'?: Fdc3ContentMapping<InstrumentList>;
    'fdc3.interaction'?: Fdc3ContentMapping<Interaction>;
    'fdc3.message'?: Fdc3ContentMapping<Message>;
    'fdc3.organization'?: Fdc3ContentMapping<Organization>;
    'fdc3.portfolio'?: Fdc3ContentMapping<Portfolio>;
    'fdc3.position'?: Fdc3ContentMapping<Position>;
    'fdc3.timerange'?: Fdc3ContentMapping<TimeRange>;
    'fdc3.transactionResult'?: Fdc3ContentMapping<TransactionResult>;
    'fdc3.valuation'?: Fdc3ContentMapping<Valuation>;
    custom?: {
        [key: string]: Fdc3ContentMapping<Context>;
    };
}
/**
 * Defines config options for Raising FDC3 Intents
 */
export interface RaiseIntentConfiguration {
    StartCall?: RaiseIntentConfig[];
    StartChat?: RaiseIntentConfig[];
    StartEmail?: RaiseIntentConfig[];
    ViewAnalysis?: RaiseIntentConfig[];
    ViewChart?: RaiseIntentConfig[];
    ViewContact?: RaiseIntentConfig[];
    ViewHoldings?: RaiseIntentConfig[];
    ViewInstrument?: RaiseIntentConfig[];
    ViewInteractions?: RaiseIntentConfig[];
    ViewNews?: RaiseIntentConfig[];
    ViewOrders?: RaiseIntentConfig[];
    ViewProfile?: RaiseIntentConfig[];
    ViewQuote?: RaiseIntentConfig[];
    ViewResearch?: RaiseIntentConfig[];
    custom?: {
        [customIntent: string]: RaiseIntentConfig[];
    };
}
/**
 * Defines config options for Broadcasting FDC3 Context
 */
export interface BroadcastConfiguration {
    'fdc3.chart'?: BroadcastConfig;
    'fdc3.chat.initSettings'?: BroadcastConfig;
    'fdc3.contact'?: BroadcastConfig;
    'fdc3.contactList'?: BroadcastConfig;
    'fdc3.country'?: BroadcastConfig;
    'fdc3.currency'?: BroadcastConfig;
    'fdc3.email'?: BroadcastConfig;
    'fdc3.instrument'?: BroadcastConfig;
    'fdc3.instrumentList'?: BroadcastConfig;
    'fdc3.organization'?: BroadcastConfig;
    'fdc3.portfolio'?: BroadcastConfig;
    'fdc3.position'?: BroadcastConfig;
    'fdc3.timerange'?: BroadcastConfig;
    'fdc3.valuation'?: BroadcastConfig;
    custom?: {
        [customContext: string]: BroadcastConfig;
    };
}
/**
 * Config used when raising an FDC3 Intent
 */
export interface RaiseIntentConfig {
    /**
     * Key of Context being Raised
     */
    contextType: ContextType;
    /**
     * Columns to display a 'Raise Intent' Context Menu item
     */
    contextMenu?: {
        /**
         * Columns to display a 'Raise Intent' Context Menu item
         */
        columnIds: string[];
        /**
         * Menu Item's Icon; can be an AdaptableIcon or function that provides `AdaptableIcon` object
         */
        icon?: '_defaultFdc3' | AdaptableIcon;
    };
    /**
     * Definition of Action Button (to be put in default FDC3 Action Column)
     */
    actionButton?: Fdc3AdaptableButton;
    /**
     * Custom FDC3 Action Column definition for the Intent
     */
    actionColumn?: {
        columnId: string;
        friendlyName?: string;
        button: Fdc3AdaptableButton;
        width?: number;
    };
    /**
     * Handles the IntentResolution for this specific raise intent configuration
     */
    handleIntentResolution?: (context: HandleFdc3IntentResolutionContext) => Promise<void>;
}
/**
 * Config used when broadcasting FDC3 Context
 */
export interface BroadcastConfig {
    /**
     * Columns to display a 'Broadcast' Context Menu item
     */
    contextMenu?: {
        /**
         * Columns to display a 'Broadcast' Context Menu item
         */
        columnIds: string[];
        /**
         * Menu Item's Icon; can be an AdaptableIcon or function that provides `AdaptableIcon` object
         */
        icon?: '_defaultFdc3' | AdaptableIcon;
    };
    /**
     * Definition of Action Button (to be put in default FDC3 Action Column)
     */
    actionButton?: Fdc3AdaptableButton;
    /**
     * Custom FDC3 Action Column definition to broadcast the Context
     */
    actionColumn?: FDC3ActionColumn;
}
/**
 * Action Column used for FDC3 workflows
 */
export interface FDC3ActionColumn {
    /**
     * Id of the Column
     */
    columnId: string;
    /**
     * Column's friendly name
     */
    friendlyName?: string;
    /**
     * FDC3 Button to display
     */
    button: Fdc3AdaptableButton;
    /**
     * Default Width of column
     */
    defaultWidth?: number;
}
/**
 * Context provided in `handleIntentResolution` callback
 */
export interface HandleFdc3IntentResolutionContext extends BaseContext {
    /**
     * The FDC3 Intent Resolution
     */
    intentResolution: IntentResolution;
}
/**
 * Context provided in dynamic FDC3 Buttons
 */
export interface Fdc3ButtonContext extends BaseContext {
    /**
     * The FDC3 Context
     */
    context: Context;
    /**
     * The FDC3 Intent
     */
    intent?: Intent;
    /**
     * The row node which is the source of the context data
     */
    rowNode: IRowNode;
    /**
     * The row data which is the source of the context data
     */
    rowData: any;
    /**
     * Primary key value of row
     */
    primaryKeyValue: any;
}
/**
 * Button used in FDC3 Action Columns
 */
export interface Fdc3AdaptableButton {
    /**
     * Unique id for the button
     */
    id: string;
    /**
     * Button's Icon; can be object or function that provides `AdaptableIcon` object
     */
    icon?: '_defaultFdc3' | AdaptableIcon | ((button: Fdc3AdaptableButton, context: Fdc3ButtonContext) => AdaptableIcon);
    /**
     * Button's Label; can be string or function that provides string
     */
    label?: '_defaultFdc3' | string | ((button: Fdc3AdaptableButton, context: Fdc3ButtonContext) => string);
    /**
     * Button's Tooltip; can be string or function that provides string
     */
    tooltip?: '_defaultFdc3' | string | ((button: Fdc3AdaptableButton, context: Fdc3ButtonContext) => string);
    /**
     * Button's Style; can be object or function that provides `ButtonStyle` object
     */
    buttonStyle?: ButtonStyle | ((button: Fdc3AdaptableButton, context: Fdc3ButtonContext) => ButtonStyle);
    /**
     * Function to disable / enable button based on evaluation result
     */
    disabled?: (button: Fdc3AdaptableButton, context: Fdc3ButtonContext) => boolean;
    /**
     * Function to hide the Button
     */
    hidden?: (button: Fdc3AdaptableButton, context: Fdc3ButtonContext) => boolean;
}
/**
 * TypeScript magic to convert all non-string property types to string (but keep the object structures), incl. nested objects.
 */
type PropertiesToGridRefs<Type> = Type extends object ? ReplaceTypes<Type> : Type extends string ? GridDataRef : Type extends Date ? GridDataRef : Type;
type ReplaceTypes<ObjType extends object> = {
    [KeyType in keyof ObjType]: PropertiesToGridRefs<ObjType[KeyType]>;
};
export {};
