/**
 * @fileoverview Vector Management Resource Component
 *
 * Dashboard resource for managing vector databases and entity vectorization.
 * Displays KPI cards (total vectors, entities synced, last sync, avg embedding time),
 * an entity sync table, and sidebar panels for DB health, embedding model info,
 * and storage usage.
 */
import { OnDestroy, AfterViewInit, ElementRef } from '@angular/core';
import { Subject } from 'rxjs';
import { ResourceData, MJVectorDatabaseEntity } from '@memberjunction/core-entities';
import { BaseResourceComponent, NavigationService } from '@memberjunction/ng-shared';
import { ViewToggleOption } from '@memberjunction/ng-ui-components';
import { KPICardData } from '../widgets/kpi-card.component';
import * as i0 from "@angular/core";
/** Flattened row for the entity sync table */
interface EntitySyncRow {
    EntityDocumentID: string;
    EntityName: string;
    DocumentName: string;
    VectorCount: number;
    LastSynced: Date | null;
    Status: 'Synced' | 'Syncing' | 'Error' | 'Pending';
    /** Percent complete during active sync (0-100) */
    PercentComplete: number;
    /** Pipeline run ID for tracking active subscription */
    PipelineRunID?: string;
}
/** Sidebar embedding model summary */
interface EmbeddingModelInfo {
    Name: string;
    Dimensions: number | null;
}
/** Result from AI document suggestion */
interface DocumentSuggestionResult {
    template: string;
    selectedFields: string[];
    selectedRelationships?: {
        name: string;
        fields: string[];
    }[];
    potentialMatchThreshold: number;
    absoluteMatchThreshold: number;
    reasoning: string;
}
export declare class VectorManagementResourceComponent extends BaseResourceComponent implements AfterViewInit, OnDestroy {
    private cdr;
    private activityService;
    protected navigationService: NavigationService;
    protected destroy$: Subject<void>;
    /** View mode: 'index' = Option A (shared index as hero, entity docs as children),
     *  'operations' = Option C (operations monitoring with real-time sync status) */
    ViewMode: 'index' | 'operations';
    readonly VectorViewOptions: ViewToggleOption[];
    /**
     * When true, renders only the body content (no chrome). Set by parent shells
     * that embed this resource. See plans/explorer-chrome-conventions.md Section 5.
     */
    HideToolbar: boolean;
    /** Toggle between view modes */
    ToggleViewMode(): void;
    IsLoading: boolean;
    KPICards: KPICardData[];
    SyncRows: EntitySyncRow[];
    SyncingIds: Set<string>;
    VectorDBName: string;
    VectorDBStatus: 'Healthy' | 'Degraded' | 'Offline';
    /** Human-readable explanation of the current health status (shown as helper text / tooltip). */
    VectorDBStatusReason: string;
    EmbeddingModel: EmbeddingModelInfo;
    StorageUsagePercent: number;
    TotalVectors: number;
    ShowEditPanel: boolean;
    IsEditSaving: boolean;
    IsEditDeleting: boolean;
    EditDocID: string;
    EditDocName: string;
    EditDocEntityName: string;
    EditDocVectorDBID: string;
    EditDocAIModelID: string;
    EditDocVectorIndexID: string;
    EditDocStatus: string;
    EditDocTemplate: string;
    IsEditRegenerating: boolean;
    /** Parse {{ FieldName }} patterns from the edit panel's template */
    get EditDocSelectedFields(): string[];
    ShowNoIndexWarning: boolean;
    /** Open the edit panel for an entity document */
    OpenEditPanel(entityDocumentId: string): Promise<void>;
    /** Load the template text for the edit panel from the associated Template Contents record */
    private loadEditDocTemplate;
    CloseEditPanel(): void;
    SaveEditedDocument(): Promise<void>;
    /** Save the edited template text back to the Template Contents record */
    private saveEditDocTemplate;
    /** Regenerate the template using AI for the current edit panel entity */
    RegenerateTemplate(): Promise<void>;
    /** Handle template edits from the edit panel's code editor */
    OnEditTemplateChange(newValue: string): void;
    DeleteEntityDocument(): Promise<void>;
    ShowScheduleSyncDialog: boolean;
    ScheduleSyncSaving: boolean;
    ScheduleSyncDocID: string;
    ScheduleSyncDocName: string;
    ScheduleSyncCron: string;
    ScheduleSyncEnabled: boolean;
    /** Opens the schedule sync dialog for a specific entity document */
    OpenScheduleSyncDialog(entityDocumentId: string): void;
    /** Closes the schedule sync dialog */
    CloseScheduleSyncDialog(): void;
    /** Returns a human-readable description of a cron expression */
    GetScheduleCronPreview(cron: string): string;
    /** Saves a new ScheduledAction for vectorizing the selected entity document */
    SaveScheduleSync(): Promise<void>;
    /** Find the __VectorizeEntity action ID */
    private findVectorizeActionID;
    /** Create a ScheduledActionParam linking the entity document ID */
    private createVectorizeScheduleParam;
    ShowSuggestDialog: boolean;
    IsSuggesting: boolean;
    SuggestEntityName: string;
    SuggestUseCase: string;
    SuggestionResult: DocumentSuggestionResult | null;
    SaveDocumentName: string;
    SuggestionError: string;
    IsSavingDocument: boolean;
    EditableTemplate: string;
    /** Prerequisites check — are vector DB and embedding model configured? */
    HasVectorDB: boolean;
    HasEmbeddingModel: boolean;
    get PrerequisitesMet(): boolean;
    /** Available embedding models for selection in save form */
    AvailableEmbeddingModels: {
        ID: string;
        Name: string;
    }[];
    /** Selected embedding model ID for the new entity document */
    SelectedEmbeddingModelID: string;
    /** Selected vector database ID for the new entity document */
    SelectedVectorDBID: string;
    /** Available vector indexes for selection */
    AvailableVectorIndexes: {
        ID: string;
        Name: string;
        VectorDatabaseID: string;
        EmbeddingModelID: string;
    }[];
    /** Selected vector index ID — if user picks an existing one */
    SelectedVectorIndexID: string;
    /** Indexes filtered by the currently selected vector DB (for create/edit forms) */
    get FilteredIndexesForSelectedDB(): {
        ID: string;
        Name: string;
        VectorDatabaseID: string;
        EmbeddingModelID: string;
    }[];
    /** Indexes filtered by the edit panel's selected vector DB */
    get EditFilteredIndexes(): {
        ID: string;
        Name: string;
        VectorDatabaseID: string;
        EmbeddingModelID: string;
    }[];
    /** Grouped entity list for the suggestion panel — schemas as groups, entities as items */
    EntityGroups: {
        SchemaName: string;
        Entities: {
            Name: string;
            ID: string;
        }[];
    }[];
    /** Filtered entity groups based on search input */
    FilteredEntityGroups: {
        SchemaName: string;
        Entities: {
            Name: string;
            ID: string;
        }[];
    }[];
    /** Search text for filtering entities */
    EntitySearchText: string;
    /** Whether the entity picker dropdown is open */
    ShowEntityPicker: boolean;
    SelectedEntityIndex: number;
    /** Reference to the entity search input for programmatic focus */
    entitySearchInput?: ElementRef<HTMLInputElement>;
    private entityDocuments;
    protected vectorDatabases: MJVectorDatabaseEntity[];
    private vectorIndexes;
    private aiModels;
    /** Lightweight aggregate stats per EntityDocumentID — avoids loading all record documents */
    private erdStats;
    ngAfterViewInit(): Promise<void>;
    ngOnDestroy(): void;
    GetResourceDisplayName(_data: ResourceData): Promise<string>;
    GetResourceIconClass(_data: ResourceData): Promise<string>;
    /** Reload all dashboard data */
    LoadData(): Promise<void>;
    /** Trigger vectorization for a specific entity document via GraphQL (fire-and-forget with progress subscription) */
    SyncEntity(entityDocumentId: string): Promise<void>;
    /** Subscribe to PipelineProgress for a specific pipeline run */
    private subscribeToPipelineProgress;
    /**
     * Add an ID to SyncingIds, creating a new Set reference so Angular
     * change detection picks up the mutation in template bindings.
     */
    private addSyncingId;
    /**
     * Remove an ID from SyncingIds, creating a new Set reference so Angular
     * change detection picks up the mutation in template bindings.
     */
    private removeSyncingId;
    /** Opens the AI suggestion dialog, or shows a warning if no vector indexes exist */
    OpenSuggestDialog(): void;
    /** Close the no-index warning dialog */
    CloseNoIndexWarning(): void;
    /** Navigate to the Configuration section from the no-index warning */
    GoToConfiguration(): Promise<void>;
    /** Select an entity from the grouped picker */
    SelectEntity(entityName: string): void;
    /** Filter entities by search text */
    FilterEntities(): void;
    /**
     * Get a flat list of all entities across groups (for keyboard navigation indexing)
     */
    get FlatFilteredEntities(): {
        Name: string;
        ID: string;
    }[];
    /**
     * Handle keyboard events in the entity picker search input
     */
    OnEntityPickerKeyDown(event: KeyboardEvent): void;
    /**
     * Scroll the currently selected entity picker item into view
     */
    private scrollSelectedEntityIntoView;
    /** Toggle entity picker visibility */
    ToggleEntityPicker(): void;
    /** Handle template edits from code editor */
    OnTemplateChange(newValue: string): void;
    /** Closes the suggestion dialog */
    CloseSuggestDialog(): void;
    /** Clears the current suggestion to try again */
    ClearSuggestion(): void;
    /**
     * Runs the AI suggestion by calling the server-side "Entity Document Suggestion"
     * AI prompt via GraphQL. The LLM analyzes the entity schema and generates
     * natural language Nunjucks templates optimized for embedding quality.
     */
    RunSuggestion(): Promise<void>;
    /** Saves the current suggestion as an Entity Document record */
    SaveAsEntityDocument(): Promise<void>;
    /** Returns the CSS class for a given sync status badge */
    GetStatusClass(status: string): string;
    /** Returns the icon class for a given sync status */
    GetStatusIcon(status: string): string;
    /** Format a Date value for display */
    FormatDate(date: Date | null): string;
    /** Format the storage gauge label */
    get StorageLabel(): string;
    /** CSS class for the DB health indicator dot */
    get DBHealthClass(): string;
    private fetchAllData;
    private buildSyncRows;
    private computeSyncStatus;
    private buildKPICards;
    private buildSidebarData;
    private buildVectorDBHealth;
    private buildEmbeddingModelInfo;
    private buildStorageUsage;
    /** Check if vector DB and embedding model are configured, populate selection lists */
    private checkPrerequisites;
    /** Find the best embedding model from loaded AI models */
    private findEmbeddingModel;
    /**
     * Populate required foreign key fields on an Entity Document before saving.
     * Throws if prerequisites are not met.
     */
    private populateEntityDocumentFKs;
    /** Create a Template + TemplateContent record for the entity document */
    private createTemplateForDocument;
    /** Build grouped entity list from metadata, grouped by SchemaName */
    private loadEntityGroups;
    private updateRowStatus;
    private updateRowProgress;
    /** Refresh a single sync row's vector count and status from the DB */
    private refreshSyncRow;
    /**
     * Calls the "Entity Document Suggestion" AI prompt via GraphQL to generate
     * a natural language template optimized for vector embeddings.
     */
    private callSuggestionPrompt;
    /** Find the Entity Document Suggestion prompt from AIEngineBase */
    private findSuggestionPrompt;
    /** Build the data payload for the suggestion prompt */
    private buildPromptData;
    static ɵfac: i0.ɵɵFactoryDeclaration<VectorManagementResourceComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<VectorManagementResourceComponent, "app-vector-management-resource", never, { "HideToolbar": { "alias": "HideToolbar"; "required": false; }; }, {}, never, never, false, never>;
}
export declare function LoadVectorManagementResource(): void;
export {};
//# sourceMappingURL=vector-management-resource.component.d.ts.map