import { BaseInfo, EntityInfo, EntityFieldInfo, UserInfo, EntitySaveOptions } from "@memberjunction/core";
import { MJUserViewEntity, MJUserViewEntity_IColumnFormat as ColumnFormat, MJUserViewEntity_IGridSortSetting as ViewGridSortSetting, MJUserViewEntity_IGridColumnSetting as ViewGridColumnSetting, MJUserViewEntity_IGridAggregatesConfig as ViewGridAggregatesConfig, MJUserViewEntity_IGridAggregateDisplay as ViewGridAggregateDisplay, MJUserViewEntity_IDisplayState as ViewDisplayState, MJUserViewEntity_ITimelineState as ViewTimelineState } from "../generated/entity_subclasses.js";
export declare class MJUserViewEntityExtended extends MJUserViewEntity {
    private _ViewEntityInfo;
    /**
     * This is a read-only property that returns the filters for this view. This information
     * is persisted in a JSON format in the FilterState column of the MJUserViewEntity table. To access
     * the filters easily, use this property.
     * @readonly
     * @type {ViewFilterInfo[]}
     * @memberof UserViewEntitySubclass
     */
    get Filter(): ViewFilterInfo[];
    /**
     * This is a read-only property that returns the columns for this view. This information
     * is persisted in a JSON format in the GridState column of the MJUserViewEntity table. To access
     * the columns easily, use this property.
     */
    get Columns(): ViewColumnInfo[];
    /**
     * The entity info for the entity that this view is based on
     * @readonly
     * @type {EntityInfo}
     * @memberof UserViewEntitySubclass
     */
    get ViewEntityInfo(): EntityInfo;
    get ViewSortInfo(): ViewSortInfo[];
    get OrderByClause(): string;
    /**
     * Attempts to build an ORDER BY clause from GridState.sortSettings.
     * Returns an empty string if GridState has no sort settings.
     */
    private buildOrderByFromGridState;
    /**
     * Get the parsed DisplayState object from the DisplayState JSON column.
     * DisplayState contains view mode preferences and mode-specific configuration (e.g., timeline settings).
     * @returns The parsed ViewDisplayState object or null if not set/invalid
     */
    get ParsedDisplayState(): ViewDisplayState | null;
    /**
     * Set the DisplayState from a ViewDisplayState object.
     * @param state The ViewDisplayState object to serialize and store
     */
    setDisplayState(state: ViewDisplayState): void;
    /**
     * Get the default view mode from DisplayState, or 'grid' if not set.
     */
    get DefaultViewMode(): 'grid' | 'cards' | 'timeline';
    /**
     * Get the timeline configuration from DisplayState.
     * @returns TimelineState or null if not configured
     */
    get TimelineConfig(): ViewTimelineState | null;
    /**
     * Update timeline configuration in DisplayState.
     * Creates DisplayState if it doesn't exist.
     * @param config The timeline configuration to set
     */
    setTimelineConfig(config: ViewTimelineState): void;
    /**
     * Check if a specific view mode is enabled.
     * By default, all modes are enabled unless explicitly disabled.
     * @param mode The view mode to check
     */
    isViewModeEnabled(mode: 'grid' | 'cards' | 'timeline'): boolean;
    /**
     * Get the best date field for timeline display based on entity metadata.
     * Priority: 1) DefaultInView=true date fields (lowest Sequence wins)
     *           2) Any date field (lowest Sequence wins)
     * @returns The field name or null if no date fields exist
     */
    getDefaultTimelineDateField(): string | null;
    /**
     * Get all date fields available for timeline configuration.
     * @returns Array of field info objects for date fields
     */
    getAvailableDateFields(): EntityFieldInfo[];
    LoadFromData(data: any): Promise<boolean>;
    /**
     * This property determines if the specified user can edit the view object. All of the below assumes the user has base Create/Update permissions on the "MJ: User Views" entity.
     * The flow of the logic is:
     *  1) The view is a new record, by definition the user can edit this because it is new
     *  2) The user is the owner of the current view - e.g. UserID in the view record matches the ID of the user provided, allowed
     *  3) The user is a sysadmin (Type === 'Owner' in the User object), allowed
     *  4) If neither of the above conditions are met, the Resource Permissions are checked to see if the user, directly or via Roles, has either Edit or Owner permissions on the current view
     * @returns
     */
    get UserCanEdit(): boolean;
    private _cachedCanUserEdit;
    /**
     * This property determines if the specified user can view the view at all.
     */
    get UserCanView(): boolean;
    private CalculateUserCanView;
    private _cachedCanUserView;
    /**
     * This property determines if the specified user can delete the view object. All of the below assumes the user has base Delete permissions on the "MJ: User Views" entity.
     * The flow of the logic is:
     *  1) The view is a new record, by definition the user can't delete this because it is new
     *  2) The user is the owner of the current view - e.g. UserID in the view record matches the ID of the user provided, allowed
     *  3) The user is a sysadmin (Type === 'Owner' in the User object), allowed
     *  4) If neither of the above conditions are met, the Resource Permissions are checked to see if the user, directly or via Roles, has OWNER permissions on the current view
     */
    get UserCanDelete(): boolean;
    private _cachedUserCanDelete;
    protected ResetCachedCanUserSettings(): void;
    private CalculateUserCanDelete;
    private CalculateUserCanEdit;
    /**
     * Returns the ID of the Resource Type metadata record that corresponds to the User Views entity
     */
    get ViewResourceTypeID(): string;
    private _ViewResourceTypeID;
    Load(ID: string, EntityRelationshipsToLoad?: string[]): Promise<boolean>;
    Delete(): Promise<boolean>;
    Save(options?: EntitySaveOptions): Promise<boolean>;
    SetDefaultsFromEntity(e: EntityInfo): Promise<void>;
    NewRecord(): boolean;
    /**
     * This method is used to update the view's where clause based on the following logic.
     * 1) If the view has a regular Filter State (which is typically set by an end-user in a UI), the FilterState will be processed and a WHERE clause will be generated
     * 2) If SmartFilterEnabled === 1 and the view has a SmartFilterPrompt, the SmartFilterPrompt will be processed by AI and the SmartFilterWhereClause will be generated. SmartFilterWhereClause will only be generated whenever the SmartFilterPrompt changes.
     * 3) If CustomWhereClause === 1, this function will NOT modify the WhereClause because the sysadmin has set CustomWhereClause === 1 which means we don't want any changes to this particular view's WhereClause
     * IMPORTANT NOTE: This method does not save the record. You still call .Save() to save the record as desired. If you want to get the new WhereClause based on the FilterState but not
     * update the FilterState column, call the GenerateWhereClause() method.
     * KEY ASSUMPTION: The server code must set a property in the MJGlobal.Properties array with a key of OPENAI_API_KEY to use the AI functionality. If this property is not set, the AI functionality will not work.
     */
    UpdateWhereClause(ignoreDirtyState?: boolean): Promise<void>;
    /**
     * This is a stub method - the intent is for the server-only sub-class to override this method and implement the AI functionality to generate a where clause based on the prompt provided
     * @param prompt - string from the end user describing the filter they want to apply
     * @param entityInfo - entity info for the entity that the view is based on
     */
    GenerateSmartFilterWhereClause(prompt: string, entityInfo: EntityInfo): Promise<{
        whereClause: string;
        userExplanation: string;
    }>;
    /**
     * This is a stub method that always returns false - the intent is for the server-only sub-class to override this and return true if it supprots smart filters and then the rest of the smart filter
     * infrastructure will be enabled from the UpdateWhereClause() method.
     */
    protected get SmartFilterImplemented(): boolean;
    Set(FieldName: string, Value: any): void;
    /**
     * Create a where clause for SQL from the structured filter state JSON information
     * @param FilterState A string containing a valid Filter State JSON string - this uses the format that the Kendo Filter component uses which is generic and can be used anywhere
     * with/without kendo
     * @param EntityInfo The entity info for the entity that the UserView is based on
     * @returns a string that represents a valid SQL WHERE clause
     * @memberof UserViewEntitySubclass
     * @example Example Filter State JSON below
        FilterState = `{
          "logic": "or",
          "filters": [{
            "field": "Name",
            "operator": "startswith",
            "value": "A"
          }, {
            "logic": "or",
            "filters": [{
              "field": "TotalRevenue",
              "operator": "gt",
              "value": 10000000
            }, {
              "field": "NumberEmployees",
              "operator": "gte",
              "value": 25
            }, {
              "field": "InformationTechnologyExpense",
              "operator": "gte",
              "value": 500000
            }, {
              "logic": "and",
              "filters": [{
                "field": "City",
                "operator": "eq",
                "value": "Chicago"
              }, {
                "field": "ActivityCount",
                "operator": "gte",
                "value": 5
              }]
            }]
          }, {
            "field": "LatestActivityDate",
            "operator": "gte",
            "value": "2023-01-01T06:00:00.000Z"
          }]
        }`;
     */
    protected GenerateWhereClause(FilterState: string, entityInfo: EntityInfo): string;
    private wrapQuotes;
    private convertFilterToSQL;
    private processFilterGroup;
}
export declare class ViewInfo {
    /**
     * Returns a list of views for the specified user. If no user is specified, the current user is used.
     * @param contextUser optional, the user to use for context when loading the view
     * @param entityId optional, the entity ID to filter the views by, if not provided, there is no filter on EntityID and all views for the user are returned
     * @returns an array of UserViewEntityBase objects
     * @memberof ViewInfo
     * @static
     * @async
     */
    static GetViewsForUser(entityId?: string, contextUser?: UserInfo): Promise<MJUserViewEntityExtended[]>;
    /**
     * Returns a view ID for a given viewName
     * @param viewName Name of the view to lookup the ID for
     * @returns the ID of the User View record that matches the provided name, if found
     */
    static GetViewID(viewName: string): Promise<string>;
    /**
     * Gets a User View entity from the UserViewEngine cache.
     * @param viewId record ID for the view to load
     * @param contextUser optional, the user context for loading views
     * @returns UserViewEntityBase (or a subclass of it)
     * @throws Error if the view is not found in the engine cache
     * @memberof ViewInfo
     * @static
     * @async
     */
    static GetViewEntity(viewId: string, contextUser?: UserInfo): Promise<MJUserViewEntityExtended>;
    /**
     * Gets a User View entity from the UserViewEngine cache by name.
     * @param viewName name for the view to load
     * @param contextUser optional, the user context for loading views
     * @returns UserViewEntityBase (or a subclass of it)
     * @throws Error if the view is not found in the engine cache
     * @memberof ViewInfo
     * @static
     * @async
     */
    static GetViewEntityByName(viewName: string, contextUser?: UserInfo): Promise<MJUserViewEntityExtended>;
}
/**
 * Column information for a saved view, including AG Grid-specific properties
 */
export declare class ViewColumnInfo extends BaseInfo {
    /** Entity field ID */
    ID: string;
    /** Field name */
    Name: string;
    /** Display name for column header (from entity metadata) */
    DisplayName: string;
    /** User-defined display name override for column header */
    userDisplayName?: string;
    /** Whether column is hidden */
    hidden: boolean;
    /** Column width in pixels */
    width?: number;
    /** Column order index */
    orderIndex?: number;
    /** Column pinning position ('left', 'right', or null for not pinned) */
    pinned?: 'left' | 'right' | null;
    /** Flex grow factor (for auto-sizing columns) */
    flex?: number;
    /** Minimum column width */
    minWidth?: number;
    /** Maximum column width */
    maxWidth?: number;
    /** Column formatting configuration */
    format?: ColumnFormat;
    /** Reference to the entity field metadata (not persisted) */
    EntityField: EntityFieldInfo;
    constructor(initData?: any);
}
export declare const ViewFilterLogicInfo: {
    readonly And: "And";
    readonly Or: "Or";
};
export type ViewFilterLogicInfo = typeof ViewFilterLogicInfo[keyof typeof ViewFilterLogicInfo];
export declare class ViewFilterInfo extends BaseInfo {
    logicOperator: ViewFilterLogicInfo;
    field: string;
    operator: string;
    value: string;
    filters: ViewFilterInfo[];
    constructor(initData?: any);
}
export declare const ViewSortDirectionInfo: {
    readonly Asc: "Asc";
    readonly Desc: "Desc";
};
export type ViewSortDirectionInfo = typeof ViewSortDirectionInfo[keyof typeof ViewSortDirectionInfo];
export declare class ViewSortInfo extends BaseInfo {
    field: string;
    direction: ViewSortDirectionInfo;
    constructor(initData?: any);
}
/**
 * Grid state persisted in UserView.GridState column
 * Contains column configuration, sort settings, and optional filter state
 */
export declare class ViewGridState {
    /** Sort settings - array of field/direction pairs */
    sortSettings?: ViewGridSortSetting[];
    /** Column settings - visibility, width, order, pinning, etc. */
    columnSettings?: ViewGridColumnSetting[];
    /** Filter state (Kendo-compatible format) */
    filter?: ViewFilterInfo;
    /** Aggregate calculations and display configuration */
    aggregates?: ViewGridAggregatesConfig;
}
/**
 * Default display settings for aggregates
 */
export declare const DEFAULT_AGGREGATE_DISPLAY: Required<ViewGridAggregateDisplay>;
//# sourceMappingURL=MJUserViewEntityExtended.d.ts.map