import { AfterViewInit, OnDestroy, OnInit } from '@angular/core';
import { BaseResourceComponent } from '@memberjunction/ng-shared';
import { MJConversationDetailEntity, ResourceData } from '@memberjunction/core-entities';
import { MediaTranscriptCue } from '@memberjunction/ng-media-player';
import { type SessionSortDirection, type SessionSortField } from './realtime-recordings-agent-context';
import * as i0 from "@angular/core";
/**
 * A recorded realtime session, projected from `MJ: AI Agent Sessions` for the list pane.
 * Only the fields the master list needs are kept (the detail pane loads turns on demand).
 */
interface RecordedSession {
    /** The `MJ: AI Agent Sessions` id. */
    ID: string;
    /** Denormalized agent name (view field), or a friendly fallback. */
    AgentName: string;
    /** Denormalized conversation name (view field), or null. */
    ConversationName: string | null;
    /** The `MJ: Files` id of the recording audio (always non-null here — we filter on it). */
    RecordingFileID: string;
    /** What was captured (`Audio` / `AudioVideo`). */
    RecordingMedia: string | null;
    /** Recording alignment origin (t0), used by the playback transcript sync. */
    RecordingStartedAt: Date | null;
    /** When the session row was created — the list's primary sort + date column. */
    CreatedAt: Date | null;
    /** Human-readable duration derived from t0 → last turn, or null when not derivable. */
    DurationLabel: string | null;
}
/**
 * REALTIME RECORDINGS — an Explorer resource dashboard for reviewing & replaying historical realtime
 * sessions that were recorded. The left pane lists every recorded session (agent · date · duration ·
 * conversation); selecting one loads its time-aligned transcript turns and resolves the recording's
 * builds transcript cues, then hands the recording's `RecordingFileID` + cues to
 * {@link MJStorageMediaPlayerComponent} in the right pane — the player resolves the authenticated
 * audio itself for synchronized audio + transcript playback.
 *
 * Data sources:
 *  - List: `RunView('MJ: AI Agent Sessions', RecordingFileID IS NOT NULL)` — `simple` rows.
 *  - Turns: `RunView('MJ: Conversation Details', AgentSessionID = <id>)` — `entity_object` rows.
 *  - Audio: resolved by the storage media player from `RecordingFileID` (authenticated bytes → blob).
 */
export declare class RealtimeRecordingsDashboardComponent extends BaseResourceComponent implements OnInit, OnDestroy, AfterViewInit {
    /** All recorded sessions (master list), newest first. */
    Sessions: RecordedSession[];
    /** Active client-side text filter applied to the list (empty when none). */
    SearchQuery: string;
    /** Active client-side sort field for the list. */
    SortField: SessionSortField;
    /** Active client-side sort direction for the list. */
    SortDirection: SessionSortDirection;
    /** The session currently selected for playback, or null. */
    SelectedSession: RecordedSession | null;
    /** Transcript turns for the selected session (used to build the cues). */
    SelectedTurns: MJConversationDetailEntity[];
    /** Transcript cues for the selected session, built from its turns (passed to the media player). */
    SelectedCues: MediaTranscriptCue[];
    /** True while the master list is loading. */
    IsLoading: boolean;
    /** True while a selected session's turns are loading. */
    IsDetailLoading: boolean;
    /** Master-list load error, shown in the body when set. */
    ErrorMessage: string | null;
    /** Detail-pane (turns) error, shown in the right pane when set. */
    DetailErrorMessage: string | null;
    private readonly cdr;
    GetResourceDisplayName(_data: ResourceData): Promise<string>;
    GetResourceIconClass(_data: ResourceData): Promise<string>;
    ngOnInit(): Promise<void>;
    /**
     * After the view initializes, publish the initial agent context and register the read-only
     * playback-navigation tools the AI agent can invoke against this surface. The ongoing context
     * re-emit happens after every meaningful state change (load, select, deselect).
     */
    ngAfterViewInit(): void;
    ngOnDestroy(): void;
    /** Loads the master list of recorded sessions. */
    LoadData(): Promise<void>;
    /** Selects a session and loads its transcript into the playback pane (the player resolves audio). */
    SelectSession(session: RecordedSession): Promise<void>;
    /** Keyboard activation for a list row (Enter / Space select it). */
    OnRowKeydown(event: KeyboardEvent, session: RecordedSession): void;
    /** Stable `@for` track for the session list. */
    TrackBySession(_index: number, session: RecordedSession): string;
    /**
     * The recordings currently visible — the master list narrowed by the active client-side
     * text filter and ordered by the active sort field + direction. Pure derivation from
     * `Sessions` / `SearchQuery` / `SortField` / `SortDirection`; drives both the list UI and
     * the agent context, so the agent's "what's selectable" view matches the screen exactly.
     */
    get VisibleSessions(): RecordedSession[];
    /** Comparator for two recordings on the given sort field (ascending; caller applies direction). */
    private compareSessions;
    /** A stable numeric sort key for a recording's duration (createdAt epoch as a coarse proxy when absent). */
    private durationSortKey;
    /** A short, localized date/time label for a session row. */
    SessionDateLabel(session: RecordedSession): string;
    /** Clears the current playback selection, returning the surface to the empty playback state. */
    DeselectSession(): void;
    /**
     * Publish the current Realtime Recordings state to the AI agent via NavigationService.
     * Reports the recordings-list size (total + filtered), the active search/sort state, the open
     * selection (id / agent / conversation / media / duration), the loaded turn count, the detail
     * loading flag, and a bounded structured summary of the visible recordings. The shaping lives in
     * the pure {@link buildRealtimeRecordingsAgentContext} helper so it stays unit-testable. Called
     * on init and after every meaningful state change (load, select, deselect, search, sort).
     */
    private publishAgentContext;
    /**
     * Register the read-only playback-navigation tools the AI agent can invoke against this surface.
     * Each handler delegates to the same component method a user interaction would call, and returns
     * `{ Success: true, Data? }` on success or `{ Success: false, ErrorMessage }` on failure.
     * Handlers are tolerant — they never throw.
     *
     * Tools (read-only — see the SAFETY BOUNDARY comment above):
     * - SelectSession / PlayRecording: select a recording by id OR name and load/play its transcript.
     * - DeselectSession: clear the current playback selection.
     * - RefreshSessionList: reload the master list of recorded sessions.
     * - SearchSessions: narrow the visible list by a client-side text filter (updates the list).
     * - SortSessions: re-order the visible list by date / agent / duration, asc or desc.
     */
    private registerAgentClientTools;
    /**
     * Resolve a session reference (id OR name) to a loaded recording and select it for playback.
     * Tolerant: returns a structured failure (with a sample of available recordings) on a miss.
     */
    private toolSelectSession;
    /** Apply a client-side text filter to the visible list (updates the UI + agent context). */
    private toolSearchSessions;
    /** Re-order the visible list by date / agent / duration, asc or desc. Read-only display ordering. */
    private toolSortSessions;
    /** Loads the transcript turns for a session as full entity objects (for the playback component). */
    private loadTurns;
    /**
     * Builds time-aligned {@link MediaTranscriptCue}s from the loaded turns, for the media player's
     * transcript panel. Skips turns with no text; derives each cue's start from `UtteranceStartMs`,
     * falling back to (turn-created − recording-start) ms, else 0. Cues sort by start ascending.
     */
    private buildCues;
    /** A turn's media-relative start (ms): precise offset when present, else derived from t0, else 0. */
    private cueStartMs;
    /** Projects a raw `simple` view row into the list model, deriving display fields. */
    private toRecordedSession;
    /**
     * Once turns are loaded, derive a duration (t0 → last turn's end/start) and stamp it on the row
     * so the list shows it. Best-effort: skipped when we lack a recording start time or any turns.
     */
    private maybeBackfillDuration;
    /** The end offset (ms) of the last turn relative to the recording start, or null. */
    private lastTurnOffsetMs;
    /** Formats a ms span as `m:ss` (or `h:mm:ss` past an hour). */
    private formatDuration;
    /** Coerces a `simple` row's date-ish value (string | Date | null) to a Date or null. */
    private toDate;
    static ɵfac: i0.ɵɵFactoryDeclaration<RealtimeRecordingsDashboardComponent, never>;
    static ɵcmp: i0.ɵɵComponentDeclaration<RealtimeRecordingsDashboardComponent, "mj-realtime-recordings-dashboard", never, {}, {}, never, never, false, never>;
}
/**
 * Tree-shaking guard — referenced from the feature module's public-api so the bundler can't drop the
 * `@RegisterClass`-decorated component (which is only ever instantiated dynamically via the class factory).
 */
export declare function LoadRealtimeRecordingsDashboard(): void;
export {};
//# sourceMappingURL=realtime-recordings-dashboard.component.d.ts.map