import { ViewContainerRef, OnDestroy } from '@angular/core';
import { MJActionEntity, MJAIAgentLearningCycleEntity, MJAIAgentNoteEntity, MJAIAgentTypeEntity, MJAIAgentRelationshipEntity } from '@memberjunction/core-entities';
import { MJAIAgentRunEntityExtended, MJAIPromptEntityExtended, MJAIAgentEntityExtended } from "@memberjunction/ai-core-plus";
import { CompositeKey } from '@memberjunction/core';
import { TreeBranchConfig } from '@memberjunction/ng-trees';
import { MJAIAgentFormComponent } from '../../generated/Entities/MJAIAgent/mjaiagent.form.component';
import * as i0 from "@angular/core";
/**
 * Type for sub-agent filter options
 */
export type SubAgentFilterType = 'all' | 'child' | 'related';
/**
 * Interface for unified sub-agent display
 */
export interface UnifiedSubAgent {
    agent: MJAIAgentEntityExtended;
    type: 'child' | 'related';
    relationship?: MJAIAgentRelationshipEntity;
}
/**
 * Enhanced AI Agent form component that extends the auto-generated base form
 * with comprehensive agent management capabilities including test harness integration,
 * related entity management, and execution history tracking.
 *
 * ## Key Features:
 * - **Integrated Test Harness**: Built-in access to agent testing capabilities
 * - **Related Entity Management**: Display and manage sub-agents, prompts, and actions
 * - **Execution History**: View recent agent runs with status and timing information
 * - **Rich UI Components**: Enhanced cards, badges, and status indicators
 * - **Navigation Support**: Links to related entities and management functions
 *
 * ## Form Sections:
 * - **Agent Details**: Basic agent configuration and settings
 * - **Sub-Agents**: Hierarchical agent relationships
 * - **Prompts**: Associated prompts with priority ordering
 * - **Actions**: Available actions and configurations
 * - **Execution History**: Recent runs with detailed status information
 *
 * ## Usage:
 * This component is automatically loaded when editing AI Agent entities through
 * the MemberJunction form system. It extends the base generated form with
 * additional functionality while maintaining full compatibility.
 *
 * @example
 * ```html
 * <!-- Automatically used by form system -->
 * <mj-ai-agent-form [recordId]="agentId"></mj-ai-agent-form>
 * ```
 */
export declare class MJAIAgentFormComponentExtended extends MJAIAgentFormComponent implements OnDestroy {
    /** The AI Agent entity being edited */
    record: MJAIAgentEntityExtended;
    /** Subject for managing component lifecycle and cleaning up subscriptions */
    private destroy$;
    /** Track active timeouts for cleanup */
    private activeTimeouts;
    /** Helper method to create tracked setTimeout calls */
    private setTrackedTimeout;
    /** Remove timeout from tracking array */
    private removeTimeoutFromTracking;
    /** ViewChild for dynamic custom section container */
    private _customSectionContainer;
    set customSectionContainer(container: ViewContainerRef);
    get customSectionContainer(): ViewContainerRef;
    /** The agent type entity for this agent */
    agentType: MJAIAgentTypeEntity | null;
    /** Reference to the dynamically loaded custom section component */
    private customSectionComponent;
    /** Track if custom section has been loaded to avoid reloading */
    private customSectionLoaded;
    /** Track the component reference to check if it still exists */
    private customSectionComponentRef;
    /** Update custom section when EditMode changes */
    ngDoCheck(): void;
    /** Number of sub-agents under this agent (for backward compatibility) */
    get subAgentCount(): number;
    /** Number of child sub-agents (ParentID-based) */
    get childSubAgentCount(): number;
    /** Number of related sub-agents (Relationship-based) */
    get relatedSubAgentCount(): number;
    /** Total number of sub-agents across both types */
    get totalSubAgentCount(): number;
    /** Number of prompts associated with this agent */
    get promptCount(): number;
    /** Number of actions configured for this agent */
    get actionCount(): number;
    /** Number of learning cycles for this agent */
    get learningCycleCount(): number;
    /** Number of notes associated with this agent */
    get noteCount(): number;
    /** Number of execution history records */
    get executionHistoryCount(): number;
    /** Array of sub-agent entities for card display (DEPRECATED - use allSubAgents) */
    subAgents: MJAIAgentEntityExtended[];
    /** Unified sub-agent data (both child and related) */
    private allSubAgents;
    /** Current filter for sub-agents display */
    subAgentFilter: SubAgentFilterType;
    /** Filtered sub-agents based on current filter */
    get filteredSubAgents(): UnifiedSubAgent[];
    /** Array of agent prompt entities for card display */
    agentPrompts: MJAIPromptEntityExtended[];
    /** Array of agent action entities for card display */
    agentActions: MJActionEntity[];
    /** Array of learning cycle entities for display */
    learningCycles: MJAIAgentLearningCycleEntity[];
    /** Array of agent note entities for display */
    agentNotes: MJAIAgentNoteEntity[];
    /** Array of recent execution records for history display */
    recentExecutions: MJAIAgentRunEntityExtended[];
    totalExecutionHistoryCount: number;
    /** Track which execution cards are expanded */
    expandedExecutions: {
        [key: string]: boolean;
    };
    /** Search functionality for execution history */
    executionSearchText: string;
    filteredExecutions: MJAIAgentRunEntityExtended[];
    /** Pagination state for execution history */
    executionHistoryPageSize: number;
    executionHistoryCurrentPage: number;
    isLoadingPage: boolean;
    /** Cache all loaded execution records for pagination */
    private allLoadedExecutions;
    /** Main loading state for initial data load */
    isLoadingData: boolean;
    /** Individual loading states for each section, start off true until loading complete */
    loadingStates: {
        executionHistory: boolean;
        subAgents: boolean;
        prompts: boolean;
        actions: boolean;
        learningCycles: boolean;
        notes: boolean;
        customSection: boolean;
    };
    private static readonly PREFS_KEY;
    private preferencesLoaded;
    /** Whether the form header is collapsed to a single compact line */
    HeaderCollapsed: boolean;
    /** Tracked expanded/collapsed state for each panelbar section */
    SectionStates: Record<string, boolean>;
    /** Model selection mode options for the dropdown */
    modelSelectionModes: {
        text: string;
        value: string;
    }[];
    /** Agent status options for the dropdown */
    statusOptions: {
        text: string;
        value: string;
    }[];
    /** Agent types loaded from the database */
    agentTypes: any[];
    /** TreeDropdown configuration for the agent category field */
    CategoryBranchConfig: TreeBranchConfig;
    /** Current category selection for the TreeDropdown */
    SelectedCategoryKey: CompositeKey | null;
    /** Handle category selection change from the TreeDropdown */
    OnCategoryChange(value: CompositeKey | CompositeKey[] | null): void;
    /** Currently selected context compression prompt */
    selectedContextCompressionPrompt: any;
    /**
     * Loads agent types from the database for the dropdown
     * @private
     */
    private loadAgentTypes;
    /**
     * Loads the context compression prompt details for display
     * @private
     */
    private loadContextCompressionPrompt;
    /**
     * Opens the prompt selector dialog for context compression prompt
     */
    openContextCompressionPromptSelector(): Promise<void>;
    /**
     * Clears the selected context compression prompt
     */
    clearContextCompressionPrompt(): void;
    /** Cache for permission checks to avoid repeated calculations */
    private _permissionCache;
    /** Check if user can create AI Agent Actions */
    get UserCanCreateActions(): boolean;
    /** Check if user can update AI Agent Actions */
    get UserCanUpdateActions(): boolean;
    /** Check if user can delete AI Agent Actions */
    get UserCanDeleteActions(): boolean;
    /** Check if user can create AI Agent Prompts */
    get UserCanCreatePrompts(): boolean;
    /** Check if user can update AI Agent Prompts */
    get UserCanUpdatePrompts(): boolean;
    /** Check if user can delete AI Agent Prompts */
    get UserCanDeletePrompts(): boolean;
    /** Check if user can create AI Agents (for sub-agents) */
    get UserCanCreateSubAgents(): boolean;
    /** Check if user can update AI Agents (for sub-agents) */
    get UserCanUpdateSubAgents(): boolean;
    /** Check if user can delete AI Agents (for sub-agents) */
    get UserCanDeleteSubAgents(): boolean;
    /** Check if user can create AI Agent Notes */
    get UserCanCreateNotes(): boolean;
    /** Check if user can update AI Agent Notes */
    get UserCanUpdateNotes(): boolean;
    /** Check if user can delete AI Agent Notes */
    get UserCanDeleteNotes(): boolean;
    /** Check if user can view AI Agent Learning Cycles */
    get UserCanViewLearningCycles(): boolean;
    /** Check if user can view AI Agent Runs (execution history) */
    get UserCanViewExecutionHistory(): boolean;
    /** Check if user can create AI Prompts (needed for creating new prompts) */
    get UserCanCreateAIPrompts(): boolean;
    /** Check if user can create both AI Prompts and AI Agent Prompts (for createNewPrompt functionality) */
    get UserCanCreateNewPrompts(): boolean;
    /**
     * Helper method to check entity permissions with caching
     * @param entityName - The name of the entity to check permissions for
     * @param permissionType - The type of permission to check (Create, Read, Update, Delete)
     * @returns boolean indicating if user has the permission
     */
    private checkEntityPermission;
    /**
     * Clears the permission cache. Call this when user context changes or permissions are updated.
     */
    clearPermissionCache(): void;
    /** Now using BaseFormComponent's PendingRecords system exclusively */
    /** Flag to indicate if there are unsaved changes */
    hasUnsavedChanges: boolean;
    private _changeDetectionCount;
    private static readonly MAX_CHANGE_DETECTIONS;
    /** Snapshots of original data for reverting UI changes */
    private originalSnapshots;
    private sharedService;
    private dialogService;
    private viewContainerRef;
    private agentManagementService;
    private testHarnessService;
    private createAgentService;
    /**
     * After view initialization, load any custom form section if defined
     */
    ngOnInit(): Promise<void>;
    /**
     * Loads counts and preview data for all related entities including sub-agents,
     * prompts, actions, learning cycles, notes, and execution history.
     * This data populates the various expander panels in the enhanced form interface.
     * @private
     */
    private loadRelatedCounts;
    /**
     * Creates a snapshot of the current UI state for cancel/revert functionality
     * @private
     */
    private createOriginalSnapshot;
    /**
     * Navigates to the next page of execution history
     */
    goToNextPage(): Promise<void>;
    /**
     * Navigates to the previous page of execution history
     */
    goToPreviousPage(): Promise<void>;
    /**
     * Loads a specific page of execution history, using cache when available
     */
    private loadPage;
    /**
     * Checks if there is a next page available
     */
    get hasNextPage(): boolean;
    /**
     * Checks if there is a previous page available
     */
    get hasPreviousPage(): boolean;
    /**
     * Gets the total number of pages
     */
    get totalPages(): number;
    /**
     * Loads the agent type entity for this agent
     * @private
     */
    private loadCurrentAgentType;
    /**
     * Dynamically loads a custom form section if the agent type defines one
     * @private
     */
    private loadCustomFormSection;
    /**
     * Handles state change events for the custom section panel
     * @param event The panel bar state change event
     */
    onCustomSectionStateChange(event: {
        expanded: boolean;
    }): void;
    /** Load saved preferences for header state and section expand/collapse */
    private loadUserPreferences;
    /** Persist preferences with debounce */
    private persistPreferences;
    /** Toggle the header between expanded and collapsed modes */
    ToggleHeaderCollapsed(): void;
    /** Get the expanded state for a panelbar section, falling back to a default */
    GetSectionExpanded(sectionId: string, defaultValue: boolean): boolean;
    /** Handle panelbar stateChange — fires when any section expands or collapses */
    OnPanelBarStateChange(event: {
        items: Array<{
            id: string;
            expanded: boolean;
        }>;
    }): void;
    /**
     * Restores the UI to its original state using saved snapshots
     * @private
     */
    private restoreFromSnapshots;
    /**
     * Override CancelEdit to restore UI state when user cancels changes
     */
    CancelEdit(): void;
    /**
     * Opens the integrated test harness for the current agent.
     * Validates that the agent has been saved before allowing testing.
     * Shows a notification if the agent needs to be saved first.
     */
    openTestHarness(): void;
    /**
     * Opens the permissions management dialog for this agent.
     * Allows viewing and editing user/role-based permissions for the agent.
     */
    /** Controls visibility of the new permissions dialog from @memberjunction/ng-agents */
    ShowPermissionsDialog: boolean;
    /** True when no explicit permission records exist (agent is open to everyone) */
    IsOpenToEveryone: boolean;
    openPermissionsDialog(): void;
    onPermissionsDialogClosed(): Promise<void>;
    private refreshPermissionState;
    /**
     * Returns the appropriate color for the agent status badge.
     * Uses standard color coding: green for active, yellow for pending, gray for disabled.
     * @returns CSS color value for the status badge
     */
    getStatusBadgeColor(): string;
    /**
     * Event handler for test harness visibility changes.
     * Updates the component state when the test harness is opened or closed.
     * @param isVisible - Whether the test harness is currently visible
     */
    /**
     * Gets the count of sub-agents
     */
    getSubAgentCount(): number;
    /**
     * Gets the count of prompts
     */
    getPromptCount(): number;
    /**
     * Gets the count of actions
     */
    getActionCount(): number;
    /**
     * Gets the icon for the execution mode
     */
    getExecutionModeIcon(mode: string): string;
    /**
     * Gets the agent's display icon
     * Prioritizes LogoURL, falls back to IconClass, then default robot icon
     */
    getAgentIcon(): string;
    /**
     * Checks if the agent has a logo URL (for image display)
     */
    hasLogoURL(): boolean;
    /**
     * Gets the icon for a sub-agent
     * Prioritizes LogoURL, falls back to IconClass, then default robot icon
     */
    getSubAgentIcon(subAgent: MJAIAgentEntityExtended): string;
    /**
     * Gets the icon class for an action
     * Falls back to default bolt icon if no IconClass is set
     */
    getActionIcon(action: MJActionEntity): string;
    /**
     * Checks if a sub-agent has a logo URL
     */
    hasSubAgentLogoURL(subAgent: MJAIAgentEntityExtended): boolean;
    /**
     * Creates a new sub-agent using the CreateAgentService slide-in panel.
     * Uses the new unified agent creation UI from @memberjunction/ng-agents.
     */
    createSubAgent(): Promise<void>;
    /**
     * Handles the result from the create sub-agent slide-in.
     * Adds entities to PendingRecords for atomic save with parent.
     */
    private handleSubAgentCreated;
    /**
     * Adds a new prompt to the agent (deferred until save)
     */
    addPrompt(): Promise<void>;
    /**
     * Handle context compression toggle and reset related fields when disabled
     */
    onContextCompressionToggle(value: any): void;
    /**
     * Opens the modern Add Action dialog for selecting actions (deferred until save)
     */
    configureActions(): Promise<void>;
    /**
     * Gets the status icon for execution runs
     */
    getExecutionStatusIcon(status: string): string;
    /**
     * Gets the status color for execution runs
     */
    getExecutionStatusColor(status: string): string;
    formatExecutionTimeFromDates(startDate: Date, endDate: Date): string;
    /**
     * Formats execution time
     */
    formatExecutionTime(milliseconds: number): string;
    /**
     * Formats token count with appropriate units (K for thousands, M for millions)
     */
    formatTokenCount(tokens: number | null): string;
    /**
     * Formats cost with appropriate precision
     */
    formatCost(cost: number | null): string;
    /**
     * Gets the running time for an execution that hasn't completed yet
     * Uses a cached timestamp to avoid ExpressionChangedAfterItHasBeenCheckedError
     */
    private _runningTimeCache;
    private _runningTimeUpdater;
    getRunningTime(startDate: Date): string;
    /**
     * Starts the background timer for updating running times
     */
    private startRunningTimeUpdater;
    /**
     * Gets the priority badge color
     */
    getPriorityBadgeColor(priority: number): string;
    /**
     * Gets the priority label
     */
    getPriorityLabel(priority: number): string;
    /**
     * Navigates to a related entity
     */
    navigateToEntity(entityName: string, recordId: string): void;
    /**
     * Toggles the expanded state of an execution card
     */
    toggleExecutionExpanded(executionId: string): void;
    /**
     * Handles search text changes - debounced to avoid excessive processing
     */
    onExecutionSearchChange(): void;
    private _searchDebounceTimer;
    /**
     * Applies search filter across all cached records and loads from database if needed
     */
    private applySearchFilter;
    /**
     * Searches execution history from database when not found in cache
     */
    private searchExecutionsFromDatabase;
    /**
     * Opens the full execution record in a new view
     */
    openExecutionRecord(executionId: string): void;
    /**
     * Gets a preview of the execution result for collapsed view
     */
    getExecutionResultPreview(execution: MJAIAgentRunEntityExtended, trimLongMessages: boolean): string;
    /**
     * Gets the full execution result message for expanded view
     */
    getExecutionResultMessage(execution: MJAIAgentRunEntityExtended): string;
    /**
     * Refreshes the related data and updates snapshots
     */
    refreshRelatedData(): Promise<void>;
    /**
     * Manually refreshes the snapshot for cancel/revert functionality
     * Useful when you want to reset the "original state" to the current state
     */
    refreshSnapshot(): void;
    /**
     * Debug method to check current pending records state
     * Useful for troubleshooting cancel/revert issues
     */
    debugPendingRecords(): void;
    /**
     * Adds a new note to the agent
     */
    addNote(): void;
    /**
     * Creates a new prompt and links it to the agent
     */
    private createNewPrompt;
    /**
     * Removes a prompt from the agent (deferred until save)
     */
    removePrompt(prompt: MJAIPromptEntityExtended, event: Event): Promise<void>;
    /**
     * Updates payload field values from code editor
     */
    updatePayloadField(fieldName: string, value: any): void;
    /**
     * Opens the sub-agent selector dialog for adding sub-agents (deferred until save)
     */
    addSubAgents(): Promise<void>;
    /**
     * Removes a sub-agent from this agent (deferred until save)
     */
    removeSubAgent(subAgent: MJAIAgentEntityExtended, event: Event): Promise<void>;
    /**
     * Sets the sub-agent filter to show all, child, or related sub-agents
     */
    setSubAgentFilter(filter: SubAgentFilterType): void;
    /**
     * Gets the badge color for a sub-agent based on its type
     */
    getSubAgentBadgeColor(item: UnifiedSubAgent): string;
    /**
     * Gets the badge icon for a sub-agent based on its type
     */
    getSubAgentBadgeIcon(item: UnifiedSubAgent): string;
    /**
     * Gets the badge text for a sub-agent based on its type
     */
    getSubAgentBadgeText(item: UnifiedSubAgent): string;
    /**
     * Gets the payload information string for display
     */
    getSubAgentPayloadInfo(item: UnifiedSubAgent): string;
    /**
     * Opens a dialog to configure the output mapping for a related sub-agent
     */
    configureOutputMapping(item: UnifiedSubAgent, event: Event): Promise<void>;
    /**
     * Unlinks a related sub-agent (removes the relationship)
     */
    unlinkRelatedSubAgent(item: UnifiedSubAgent, event: Event): Promise<void>;
    /**
     * Removes a child sub-agent (updated to work with UnifiedSubAgent)
     */
    removeChildSubAgent(item: UnifiedSubAgent, event: Event): Promise<void>;
    /**
     * Creates a new child sub-agent (renamed from createSubAgent for clarity)
     */
    createChildSubAgent(): Promise<void>;
    /**
     * Opens dialog to link an existing agent as a related sub-agent
     */
    linkRelatedSubAgent(): Promise<void>;
    /**
     * Removes an action from the agent (deferred until save)
     */
    removeAction(action: MJActionEntity, event: Event): Promise<void>;
    /**
     * Opens the advanced settings dialog for a prompt
     */
    openPromptAdvancedSettings(prompt: MJAIPromptEntityExtended, event: Event): Promise<void>;
    /**
     * Opens the advanced settings dialog for a sub-agent
     */
    openSubAgentAdvancedSettings(subAgentEntity: MJAIAgentEntityExtended, event: Event): Promise<void>;
    /**
     * Override PopulatePendingRecords to preserve our pending records before parent clears them
     * However, during cancel operations, we want to clear all pending records completely
     */
    protected PopulatePendingRecords(): void;
    /** Flag to track if we're currently performing a cancel operation */
    private isPerformingCancel;
    /**
     * Override InternalSaveRecord to handle agent-specific transaction logic
     * AI Agent must be saved first since related entities depend on it
     */
    /**
     * The base SaveRecord() method will call this InternalSaveRecord() method
     * after handling validation and pending record population
     */
    protected InternalSaveRecord(): Promise<boolean>;
    /**
     * Navigates to the parent agent when the "Child of..." badge is clicked
     */
    navigateToParentAgent(): void;
    /**
     * Component cleanup - critical for preventing memory leaks
     */
    ngOnDestroy(): void;
    static ɵfac: i0.ɵɵFactoryDeclaration<MJAIAgentFormComponentExtended, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<MJAIAgentFormComponentExtended, "mj-ai-agent-form", never, {}, {}, never, never, false, never>;
}
//# sourceMappingURL=ai-agent-form.component.d.ts.map