/**
 * @fileoverview Knowledge Hub Analytics & Insights Resource Component
 *
 * Multi-tab analytics dashboard for the Knowledge Hub: Overview (interactive cards),
 * Tags (top 20, distribution), Sources (comparison, health), Pipeline (throughput,
 * processing time, errors), and Quality (confidence, weight, model comparison).
 *
 * All chart rendering is pure CSS/inline SVG -- no JS chart libraries.
 */
import { OnDestroy, AfterViewInit } from '@angular/core';
import { Subject } from 'rxjs';
import { ResourceData } from '@memberjunction/core-entities';
import { BaseResourceComponent, NavigationService } from '@memberjunction/ng-shared';
import { MJLeftNavItem, MJLeftNavSection } from '@memberjunction/ng-ui-components';
import * as i0 from "@angular/core";
interface NavItem {
    ID: string;
    Label: string;
    Icon: string;
}
interface DateRangeOption {
    Label: string;
    Days: number;
}
interface KPIData {
    Label: string;
    Value: string;
    Delta: string;
    DeltaDirection: 'up' | 'down' | 'flat';
    SparklinePoints: string;
    SparklineColor: string;
    SparklineGradId: string;
    DrillDownKey: string;
}
interface WidgetCard {
    Key: string;
    Title: string;
    Icon: string;
}
interface TagGrowthMonth {
    Label: string;
    Count: number;
    Percentage: number;
}
interface CoverageEntity {
    Name: string;
    Tagged: number;
    Total: number;
    Percentage: number;
    Color: string;
    StrokeDash: string;
}
interface SourcePerformanceRow {
    Name: string;
    AvgTagsPerItem: number;
    Percentage: number;
    Color: string;
}
interface ThroughputDay {
    Label: string;
    Percentage: number;
    IsError: boolean;
}
interface TaxonomyStat {
    Label: string;
    Count: number;
    Color: string;
    BgColor: string;
}
interface TopTagRow {
    Rank: number;
    Name: string;
    UsageCount: number;
    AvgWeight: number;
    WeightBarWidth: number;
    WeightBarColor: string;
    TrendPoints: string;
    TrendColor: string;
    TopEntity: string;
    FirstSeen: string;
}
interface EntityDistributionRow {
    EntityName: string;
    Segments: EntityDistSegment[];
}
interface EntityDistSegment {
    Label: string;
    Percentage: number;
    Color: string;
}
interface TagDepthBar {
    Label: string;
    Count: number;
    Percentage: number;
}
interface SourceComparisonRow {
    Name: string;
    Type: string;
    TypeIcon: string;
    TypeColor: string;
    Items: number;
    TagsGenerated: number;
    AvgTagsPerItem: number;
    AvgWeight: number;
    LastRun: string;
    Status: string;
    StatusClass: string;
}
interface SourceHealthCard {
    Name: string;
    Uptime: number;
    Color: string;
}
interface PipelineBar {
    Percentage: number;
    IsError: boolean;
}
interface ProcessingStage {
    Name: string;
    Time: number;
    Percentage: number;
    Color: string;
}
interface ActiveRunRow {
    RunID: string;
    Source: string;
    Started: string;
    Progress: number;
    Stage: string;
    StageClass: string;
    Items: number;
}
interface ErrorLogEntry {
    Time: string;
    Source: string;
    Message: string;
}
interface HistogramBin {
    Label: string;
    Count: number;
    Percentage: number;
    Color: string;
}
interface WeightGroupedEntity {
    Name: string;
    High: number;
    Med: number;
    Low: number;
}
interface LowConfidenceTag {
    Name: string;
    AvgWeight: number;
    UsageCount: number;
    TopEntity: string;
    SuggestedAction: string;
    ActionClass: string;
}
interface ModelComparison {
    Name: string;
    Icon: string;
    IconColor: string;
    ScorePercentage: number;
    ScoreColor: string;
    AvgConfidence: number;
    TagsGenerated: number;
    Role: string;
    RoleColor: string;
    StrokeDash: string;
}
interface CoOccurrencePairRow {
    TagAName: string;
    TagBName: string;
    Count: number;
    /** Bar width as percentage of the max count in the displayed list */
    BarWidth: number;
}
interface DrillDownRecord {
    [key: string]: string | number | null;
}
export declare class AnalyticsResourceComponent extends BaseResourceComponent implements AfterViewInit, OnDestroy {
    private cdr;
    protected navigationService: NavigationService;
    protected destroy$: Subject<void>;
    GetResourceDisplayName(_data: ResourceData): Promise<string>;
    GetResourceIconClass(_data: ResourceData): Promise<string>;
    NavItems: NavItem[];
    ActiveTab: string;
    IsLoading: boolean;
    DateRanges: DateRangeOption[];
    ActiveDateRange: string;
    EntityFilter: string;
    EntityFilterOptions: string[];
    DrillDownTarget: string | null;
    DrillDownData: DrillDownRecord[];
    DrillDownColumns: string[];
    IsDrillDownLoading: boolean;
    /** Whether the current drill-down rows have navigable records */
    DrillDownHasActions: boolean;
    /** AN-1: Open a record from a drill-down table row */
    OpenDrillDownRecord(row: DrillDownRecord): void;
    /**
     * D9: Navigate to the Classify dashboard's Tag Library tab with a tag pre-selected.
     * Uses NavigationService.OpenNavItemByName to switch to the Classify nav item
     * and passes the tag name and target tab via configuration.
     */
    private navigateToClassifyTagLibrary;
    KPIs: KPIData[];
    WidgetCards: WidgetCard[];
    TagGrowthData: TagGrowthMonth[];
    CoverageData: CoverageEntity[];
    QualityScore: number;
    MiniConfidenceBins: {
        Height: number;
        Color: string;
        Title: string;
    }[];
    SourcePerfData: SourcePerformanceRow[];
    ThroughputData: ThroughputDay[];
    TaxonomyTotal: number;
    TaxonomyStats: TaxonomyStat[];
    TaxonomyRingSegments: {
        StrokeDash: string;
        StrokeOffset: string;
        Color: string;
    }[];
    TopTags: TopTagRow[];
    EntityDistribution: EntityDistributionRow[];
    DistributionLegend: {
        Label: string;
        Color: string;
    }[];
    TagDepthBars: TagDepthBar[];
    CoOccurrencePairs: CoOccurrencePairRow[];
    CoOccurrenceLastComputed: string | null;
    IsRecomputingCoOccurrence: boolean;
    SourceComparison: SourceComparisonRow[];
    SelectedSourceName: string;
    SourceWeeklyBars: {
        Label: string;
        Value: number;
        Percentage: number;
    }[];
    SourceQualityBands: {
        Label: string;
        Percentage: number;
        Color: string;
    }[];
    SourceQualityNote: string;
    SourceHealthCards: SourceHealthCard[];
    PipelineThroughputBars: PipelineBar[];
    PipelineDateLabels: string[];
    ProcessingStages: ProcessingStage[];
    TotalAvgProcessingTime: number;
    BottleneckStage: string;
    BottleneckPercent: number;
    SuccessRateAvg: number;
    FailureRateAvg: number;
    ActiveRuns: ActiveRunRow[];
    ErrorLog: ErrorLogEntry[];
    ConfidenceHistogram: HistogramBin[];
    ConfidenceStats: {
        Label: string;
        Value: string;
    }[];
    WeightByEntity: WeightGroupedEntity[];
    WeightLegend: {
        Label: string;
        Color: string;
    }[];
    AccuracyLinePoints: string;
    AccuracyDots: {
        Cx: number;
        Cy: number;
    }[];
    AccuracyMonthLabels: string[];
    AccuracyTrendText: string;
    LowConfidenceTags: LowConfidenceTag[];
    ModelComparisons: ModelComparison[];
    ModelRecommendation: string;
    TrendingTags: {
        Name: string;
        Size: number;
        Weight: number;
    }[];
    PipelineStatusText: string;
    PipelineStatusOk: boolean;
    CostKPIs: {
        Label: string;
        Value: string;
        Icon: string;
        SubLabel: string;
    }[];
    CostPerRunRows: {
        RunID: string;
        Source: string;
        Tokens: number;
        Cost: number;
        Started: string;
    }[];
    private rawTags;
    private rawContentItemTags;
    private rawContentItems;
    rawProcessRuns: Record<string, unknown>[];
    private rawContentSources;
    private rawContentTypes;
    private rawRunDetails;
    ngAfterViewInit(): Promise<void>;
    private emitAgentContext;
    private registerAgentTools;
    ngOnDestroy(): void;
    /** Wraps `NavItems` for `<mj-left-nav>`. */
    get navSections(): MJLeftNavSection[];
    /** Adapter for `<mj-left-nav>`'s `(ItemClicked)` output. */
    onNavItemClicked(item: MJLeftNavItem): void;
    SelectTab(tabId: string): void;
    SetDateRange(label: string): void;
    SetEntityFilter(value: string): void;
    OpenDrillDown(key: string): void;
    CloseDrillDown(): void;
    /** Export drill-down data as CSV */
    ExportDrillDownCSV(): void;
    /** Export a named data set (top-tags, sources, etc.) as CSV */
    ExportTabDataCSV(dataKey: string): void;
    private downloadCSV;
    SelectSource(name: string): void;
    FormatNumber(n: number): string;
    TrackByIndex(index: number): number;
    TrackByID(_index: number, item: {
        ID?: string;
        Key?: string;
        Label?: string;
        Name?: string;
    }): string;
    private loadAllData;
    private buildEntityFilterOptions;
    private rebuildAllAggregations;
    private getDateFilteredItems;
    private buildKPIs;
    private buildTagGrowth;
    private buildCoverageData;
    private buildQualityScore;
    private buildSourcePerformance;
    private buildThroughput;
    private buildTaxonomyHealth;
    private buildTopTags;
    private generateTrendPoints;
    private buildEntityDistribution;
    private buildTagDepth;
    private buildSourceComparison;
    private getSourceTypeIcon;
    private getSourceTypeColor;
    private formatRelativeTime;
    private buildSourceDetail;
    private buildSourceHealth;
    private buildPipelineThroughput;
    private buildProcessingStages;
    private buildActiveRuns;
    private buildErrorLog;
    private buildConfidenceHistogram;
    private buildWeightByEntity;
    private buildAccuracyTrend;
    private buildLowConfidenceTags;
    private buildModelComparisons;
    private buildTrendingTags;
    private buildPipelineStatus;
    private loadDrillDownData;
    private buildWidgetDrillDown;
    /**
     * D10 Tags tab: Click a tag row to see content items using that tag.
     */
    private buildTagRowDrillDown;
    /**
     * D10 Sources tab: Click a source row to see recent runs, items, and errors.
     */
    private buildSourceRowDrillDown;
    /**
     * D10 Pipeline tab: Click throughput chart to see individual run details.
     */
    private buildPipelineThroughputDrillDown;
    /**
     * D10 Quality tab: Click confidence histogram bin to see matching items.
     */
    private buildQualityBinDrillDown;
    /**
     * Aggregates cost and token data from ContentProcessRunDetail records.
     * Each detail record has TotalTokensUsed and TotalCost fields that are
     * pre-rolled-up from linked AIPromptRun records.
     */
    private buildCostUsageData;
    /** Sum a numeric field across an array of raw records */
    static SumField(records: Record<string, unknown>[], fieldName: string): number;
    private sumField;
    private formatLargeNumber;
    private buildCostPerRunRows;
    /**
     * D5: Opens the browser print dialog with print-friendly CSS.
     * This is a zero-dependency approach to PDF export.
     * NOTE: For full XLSX export, an xlsx library (e.g. SheetJS) can be added later.
     */
    PrintCurrentTab(): void;
    private static readonly PREFS_KEY;
    private persistAnalyticsPreferences;
    private loadAnalyticsPreferences;
    /**
     * Load the top 20 co-occurring tag pairs and the staleness timestamp.
     * Runs in background so it does not block initial render.
     */
    private loadCoOccurrenceData;
    /** Recompute co-occurrence data (triggered by user button click) */
    RecomputeCoOccurrence(): Promise<void>;
    static ɵfac: i0.ɵɵFactoryDeclaration<AnalyticsResourceComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<AnalyticsResourceComponent, "app-analytics-resource", never, {}, {}, never, never, false, never>;
}
/** Tree-shaking prevention */
export declare function LoadAnalyticsResource(): void;
export {};
//# sourceMappingURL=analytics-resource.component.d.ts.map