/**
 * @fileoverview Knowledge Hub Clusters Dashboard Tab
 *
 * Full-page cluster visualization with:
 * - Left sidebar: saved cluster visualizations (persisted via UserInfoEngine)
 * - Main area: SVG scatter plot (mj-cluster-scatter)
 * - Floating config panel (mj-cluster-config-panel)
 * - Top metrics bar
 *
 * Registered as BaseResourceComponent for the Knowledge Hub application.
 */
import { OnDestroy, AfterViewInit, EventEmitter } from '@angular/core';
import { Subject } from 'rxjs';
import { ResourceData } from '@memberjunction/core-entities';
import { BaseResourceComponent, NavigationService } from '@memberjunction/ng-shared';
import { ClusterConfig, ClusterConfigPanelEntityOption, ClusterConfigPanelEntityDocOption, ClusterVisualizationResult, ClusterMetrics, ClusterPoint, ClusterLabel, SavedClusterVisualization } from '@memberjunction/ng-clustering';
import { ClusterScatterComponent } from '@memberjunction/ng-clustering';
import * as i0 from "@angular/core";
export declare class ClusterVisualizationResourceComponent extends BaseResourceComponent implements AfterViewInit, OnDestroy {
    scatterPlot?: ClusterScatterComponent;
    private cdr;
    private clusteringService;
    private activityService;
    protected navigationService: NavigationService;
    protected destroy$: Subject<void>;
    /** LLM-generated cluster labels for the current result */
    ClusterLabels: ClusterLabel[];
    /**
     * When true, this component is embedded inside the Visualize host surface.
     * In that case the host owns the resource lifecycle (NotifyLoadComplete,
     * agent context) and record navigation, so this component suppresses those
     * and instead emits open-record intents via {@link OpenRecordRequested}.
     */
    Embedded: boolean;
    /** Emitted (only when Embedded) to ask the host to open an entity record. */
    OpenRecordRequested: EventEmitter<{
        EntityName: string;
        RecordID: string;
    }>;
    GetResourceDisplayName(_data: ResourceData): Promise<string>;
    GetResourceIconClass(_data: ResourceData): Promise<string>;
    /** Current visualization result */
    Result: ClusterVisualizationResult | null;
    /** Whether a clustering run is in progress */
    IsRunning: boolean;
    /** The active cluster config */
    ActiveConfig: ClusterConfig;
    /** Title for the top bar */
    VisualizationTitle: string;
    /** Entity options for the config panel dropdown */
    EntityOptions: ClusterConfigPanelEntityOption[];
    /** Entity document options for the selected entity (shown when 2+) */
    EntityDocOptions: ClusterConfigPanelEntityDocOption[];
    /** All entity documents across entities (for the multi-entity source selector) */
    AllEntityDocOptions: ClusterConfigPanelEntityDocOption[];
    /** User-facing error from the last run (e.g. multi-entity embedding mismatch) */
    RunError: string | null;
    /** Ordered field keys for prioritized display in scatter tooltip/detail */
    FieldPriority: string[];
    /** Map of field names to human-readable display names */
    FieldDisplayNames: Record<string, string>;
    SavedVisualizations: SavedClusterVisualization[];
    ActiveSavedId: string | null;
    private userSettingEntity;
    ngAfterViewInit(): Promise<void>;
    ngOnDestroy(): void;
    get Metrics(): ClusterMetrics | null;
    get HasResult(): boolean;
    get SilhouetteScoreFormatted(): string;
    get IsSilhouetteGood(): boolean;
    get ComputationTimeFormatted(): string;
    /** Handle "Run Clustering" from the config panel */
    OnRunClustering(config: ClusterConfig): Promise<void>;
    /**
     * Re-run when the user flips 2D⇄3D so the projection updates immediately.
     * A 3D layout needs a Z coordinate that only a fresh projection produces, so
     * toggling alone wouldn't change the existing plot.
     */
    OnDimensionsChanged(dims: 2 | 3): void;
    /** Handle point click — log for now */
    OnPointClicked(_point: ClusterPoint): void;
    /** Handle point hover */
    OnPointHovered(_point: ClusterPoint | null): void;
    /** Navigate to the entity record when "Open Record" is clicked in the detail panel */
    OnOpenRecord(point: ClusterPoint): void;
    /** Save the current visualization */
    OnSaveVisualization(): Promise<void>;
    /** Select a saved visualization — restore from cache if available, otherwise re-run */
    OnSelectSaved(saved: SavedClusterVisualization): Promise<void>;
    /** Delete a saved visualization */
    OnDeleteSaved(saved: SavedClusterVisualization, event: MouseEvent): Promise<void>;
    /** Start a new analysis (clear current) */
    OnNewAnalysis(): void;
    IsActiveSaved(saved: SavedClusterVisualization): boolean;
    TrackSavedBy(_index: number, saved: SavedClusterVisualization): string;
    FormatDate(iso: string): string;
    /** Populate the entity options for the config panel dropdown */
    private loadEntityOptions;
    /** Update entity document options when the selected entity changes */
    private updateEntityDocOptions;
    /**
     * Fetch vectors from Entity Document Runs via RunView.
     * Entity Documents store vectorized entity data; we query for runs
     * that match the requested entity.
     */
    private fetchVectorsForEntity;
    /** Resolve which entity-document IDs to source vectors from for a run. */
    private resolveDocIDs;
    /** Parse the JSON metadata string from the vector DB into a record */
    private parseVectorMetadata;
    /**
     * Build a human-readable label from vector metadata using entity field metadata.
     * Combines all IsNameField fields in Sequence order (e.g., "Sarah Chen" from FirstName + LastName).
     * Falls back to heuristic field detection when entity metadata isn't available.
     */
    private buildLabel;
    /**
     * After clustering completes, send sample records per cluster to an LLM for naming.
     * Updates ClusterLabels and refreshes the view.
     */
    private requestClusterLabelsFromLLM;
    /** Build a text block describing sample records per cluster for the LLM prompt */
    private buildClusterDataForPrompt;
    /**
     * Handle inline label edits from the scatter component legend.
     * Updates the ClusterLabels cache and marks the label as user-edited.
     */
    OnLabelEdited(event: {
        ClusterId: number;
        OldLabel: string;
        NewLabel: string;
    }): void;
    /**
     * Compute the prioritized field order and display names from entity metadata.
     * Sets both FieldPriority and FieldDisplayNames.
     * Returns field names sorted: IsNameField first, then DefaultInView by Sequence,
     * then remaining fields by Sequence.
     */
    private ComputeFieldPriority;
    /** Apply cluster labels to the result's Clusters array (sets the Label property) */
    private applyLabelsToResult;
    /**
     * Strip full vector arrays from the result before saving (they're large and not needed for display).
     * Keeps points with 2D coordinates and metadata but removes the original high-dimensional vectors.
     */
    private stripVectorsFromResult;
    /** Load saved visualizations from UserInfoEngine settings */
    private loadSavedVisualizations;
    /**
     * Auto-save the current session to localStorage so it can be restored
     * when the user navigates away and comes back.
     */
    private saveLastSession;
    /**
     * Restore the last session from localStorage if no saved visualization is active.
     * This handles the "navigate away and come back" case.
     */
    private restoreLastSession;
    /** Persist saved visualizations to UserInfoEngine settings */
    private persistSavedVisualizations;
    static ɵfac: i0.ɵɵFactoryDeclaration<ClusterVisualizationResourceComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<ClusterVisualizationResourceComponent, "app-cluster-visualization-resource", never, { "Embedded": { "alias": "Embedded"; "required": false; }; }, { "OpenRecordRequested": "OpenRecordRequested"; }, never, never, false, never>;
}
/** Tree-shaking prevention */
export declare function LoadClusterVisualizationResource(): void;
//# sourceMappingURL=cluster-visualization-resource.component.d.ts.map